atrium-ruby 1.3.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (201) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +5 -2
  3. data/README.md +132 -66
  4. data/Rakefile +7 -4
  5. data/atrium-ruby.gemspec +40 -32
  6. data/docs/Account.md +35 -0
  7. data/docs/AccountNumber.md +12 -0
  8. data/docs/AccountNumbersResponseBody.md +8 -0
  9. data/docs/AccountOwner.md +18 -0
  10. data/docs/AccountOwnersResponseBody.md +8 -0
  11. data/docs/AccountResponseBody.md +8 -0
  12. data/docs/AccountsApi.md +174 -0
  13. data/docs/AccountsResponseBody.md +9 -0
  14. data/docs/Challenge.md +13 -0
  15. data/docs/ChallengeOption.md +10 -0
  16. data/docs/ChallengesResponseBody.md +8 -0
  17. data/docs/ConnectWidget.md +9 -0
  18. data/docs/ConnectWidgetApi.md +44 -0
  19. data/docs/ConnectWidgetRequestBody.md +11 -0
  20. data/docs/ConnectWidgetResponseBody.md +8 -0
  21. data/docs/CredentialOption.md +9 -0
  22. data/docs/CredentialRequest.md +9 -0
  23. data/docs/CredentialResponse.md +12 -0
  24. data/docs/CredentialsResponseBody.md +8 -0
  25. data/docs/IdentityApi.md +82 -0
  26. data/docs/Institution.md +14 -0
  27. data/docs/InstitutionResponseBody.md +8 -0
  28. data/docs/InstitutionsApi.md +120 -0
  29. data/docs/InstitutionsResponseBody.md +9 -0
  30. data/docs/Member.md +18 -0
  31. data/docs/MemberConnectionStatus.md +16 -0
  32. data/docs/MemberConnectionStatusResponseBody.md +8 -0
  33. data/docs/MemberCreateRequest.md +11 -0
  34. data/docs/MemberCreateRequestBody.md +8 -0
  35. data/docs/MemberResponseBody.md +8 -0
  36. data/docs/MemberResumeRequest.md +8 -0
  37. data/docs/MemberResumeRequestBody.md +8 -0
  38. data/docs/MemberUpdateRequest.md +10 -0
  39. data/docs/MemberUpdateRequestBody.md +8 -0
  40. data/docs/MembersApi.md +487 -0
  41. data/docs/MembersResponseBody.md +9 -0
  42. data/docs/Pagination.md +11 -0
  43. data/docs/Transaction.md +38 -0
  44. data/docs/TransactionCleanseAndCategorizeRequest.md +11 -0
  45. data/docs/TransactionCleanseAndCategorizeResponse.md +20 -0
  46. data/docs/TransactionResponseBody.md +8 -0
  47. data/docs/TransactionsApi.md +126 -0
  48. data/docs/TransactionsCleanseAndCategorizeRequestBody.md +8 -0
  49. data/docs/TransactionsCleanseAndCategorizeResponseBody.md +8 -0
  50. data/docs/TransactionsResponseBody.md +9 -0
  51. data/docs/User.md +11 -0
  52. data/docs/UserCreateRequestBody.md +8 -0
  53. data/docs/UserResponseBody.md +8 -0
  54. data/docs/UserUpdateRequestBody.md +8 -0
  55. data/docs/UsersApi.md +193 -0
  56. data/docs/UsersResponseBody.md +9 -0
  57. data/docs/VerificationApi.md +120 -0
  58. data/git_push.sh +49 -0
  59. data/lib/atrium-ruby.rb +88 -0
  60. data/lib/atrium-ruby/api/accounts_api.rb +272 -0
  61. data/lib/atrium-ruby/api/atrium_client.rb +28 -0
  62. data/lib/atrium-ruby/api/connect_widget_api.rb +82 -0
  63. data/lib/atrium-ruby/api/identity_api.rb +140 -0
  64. data/lib/atrium-ruby/api/institutions_api.rb +181 -0
  65. data/lib/atrium-ruby/api/members_api.rb +749 -0
  66. data/lib/atrium-ruby/api/transactions_api.rb +198 -0
  67. data/lib/atrium-ruby/api/users_api.rb +287 -0
  68. data/lib/atrium-ruby/api/verification_api.rb +198 -0
  69. data/lib/atrium-ruby/api_client.rb +384 -0
  70. data/lib/atrium-ruby/api_error.rb +34 -0
  71. data/lib/atrium-ruby/configuration.rb +212 -0
  72. data/lib/atrium-ruby/models/account.rb +422 -0
  73. data/lib/atrium-ruby/models/account_number.rb +215 -0
  74. data/lib/atrium-ruby/models/account_numbers_response_body.rb +181 -0
  75. data/lib/atrium-ruby/models/account_owner.rb +269 -0
  76. data/lib/atrium-ruby/models/account_owners_response_body.rb +181 -0
  77. data/lib/atrium-ruby/models/account_response_body.rb +179 -0
  78. data/lib/atrium-ruby/models/accounts_response_body.rb +190 -0
  79. data/lib/atrium-ruby/models/challenge.rb +226 -0
  80. data/lib/atrium-ruby/models/challenge_option.rb +197 -0
  81. data/lib/atrium-ruby/models/challenges_response_body.rb +181 -0
  82. data/lib/atrium-ruby/models/connect_widget.rb +188 -0
  83. data/lib/atrium-ruby/models/connect_widget_request_body.rb +206 -0
  84. data/lib/atrium-ruby/models/connect_widget_response_body.rb +179 -0
  85. data/lib/atrium-ruby/models/credential_option.rb +188 -0
  86. data/lib/atrium-ruby/models/credential_request.rb +188 -0
  87. data/lib/atrium-ruby/models/credential_response.rb +217 -0
  88. data/lib/atrium-ruby/models/credentials_response_body.rb +181 -0
  89. data/lib/atrium-ruby/models/institution.rb +233 -0
  90. data/lib/atrium-ruby/models/institution_response_body.rb +179 -0
  91. data/lib/atrium-ruby/models/institutions_response_body.rb +190 -0
  92. data/lib/atrium-ruby/models/member.rb +269 -0
  93. data/lib/atrium-ruby/models/member_connection_status.rb +253 -0
  94. data/lib/atrium-ruby/models/member_connection_status_response_body.rb +179 -0
  95. data/lib/atrium-ruby/models/member_create_request.rb +218 -0
  96. data/lib/atrium-ruby/models/member_create_request_body.rb +179 -0
  97. data/lib/atrium-ruby/models/member_response_body.rb +179 -0
  98. data/lib/atrium-ruby/models/member_resume_request.rb +181 -0
  99. data/lib/atrium-ruby/models/member_resume_request_body.rb +179 -0
  100. data/lib/atrium-ruby/models/member_update_request.rb +199 -0
  101. data/lib/atrium-ruby/models/member_update_request_body.rb +179 -0
  102. data/lib/atrium-ruby/models/members_response_body.rb +190 -0
  103. data/lib/atrium-ruby/models/pagination.rb +206 -0
  104. data/lib/atrium-ruby/models/transaction.rb +449 -0
  105. data/lib/atrium-ruby/models/transaction_cleanse_and_categorize_request.rb +206 -0
  106. data/lib/atrium-ruby/models/transaction_cleanse_and_categorize_response.rb +287 -0
  107. data/lib/atrium-ruby/models/transaction_response_body.rb +179 -0
  108. data/lib/atrium-ruby/models/transactions_cleanse_and_categorize_request_body.rb +181 -0
  109. data/lib/atrium-ruby/models/transactions_cleanse_and_categorize_response_body.rb +181 -0
  110. data/lib/atrium-ruby/models/transactions_response_body.rb +190 -0
  111. data/lib/atrium-ruby/models/user.rb +206 -0
  112. data/lib/atrium-ruby/models/user_create_request_body.rb +179 -0
  113. data/lib/atrium-ruby/models/user_response_body.rb +179 -0
  114. data/lib/atrium-ruby/models/user_update_request_body.rb +179 -0
  115. data/lib/atrium-ruby/models/users_response_body.rb +190 -0
  116. data/lib/atrium-ruby/version.rb +11 -0
  117. data/spec/api/accounts_api_spec.rb +88 -0
  118. data/spec/api/connect_widget_api_spec.rb +43 -0
  119. data/spec/api/identity_api_spec.rb +56 -0
  120. data/spec/api/institutions_api_spec.rb +68 -0
  121. data/spec/api/members_api_spec.rb +195 -0
  122. data/spec/api/transactions_api_spec.rb +71 -0
  123. data/spec/api/users_api_spec.rb +92 -0
  124. data/spec/api/verification_api_spec.rb +69 -0
  125. data/spec/api_client_spec.rb +222 -0
  126. data/spec/configuration_spec.rb +38 -0
  127. data/spec/models/account_number_spec.rb +60 -0
  128. data/spec/models/account_numbers_response_body_spec.rb +36 -0
  129. data/spec/models/account_owner_spec.rb +96 -0
  130. data/spec/models/account_owners_response_body_spec.rb +36 -0
  131. data/spec/models/account_response_body_spec.rb +36 -0
  132. data/spec/models/account_spec.rb +198 -0
  133. data/spec/models/accounts_response_body_spec.rb +42 -0
  134. data/spec/models/challenge_option_spec.rb +48 -0
  135. data/spec/models/challenge_spec.rb +66 -0
  136. data/spec/models/challenges_response_body_spec.rb +36 -0
  137. data/spec/models/connect_widget_request_body_spec.rb +54 -0
  138. data/spec/models/connect_widget_response_body_spec.rb +36 -0
  139. data/spec/models/connect_widget_spec.rb +42 -0
  140. data/spec/models/credential_option_spec.rb +42 -0
  141. data/spec/models/credential_request_spec.rb +42 -0
  142. data/spec/models/credential_response_spec.rb +60 -0
  143. data/spec/models/credentials_response_body_spec.rb +36 -0
  144. data/spec/models/institution_response_body_spec.rb +36 -0
  145. data/spec/models/institution_spec.rb +72 -0
  146. data/spec/models/institutions_response_body_spec.rb +42 -0
  147. data/spec/models/member_connection_status_response_body_spec.rb +36 -0
  148. data/spec/models/member_connection_status_spec.rb +84 -0
  149. data/spec/models/member_create_request_body_spec.rb +36 -0
  150. data/spec/models/member_create_request_spec.rb +54 -0
  151. data/spec/models/member_response_body_spec.rb +36 -0
  152. data/spec/models/member_resume_request_body_spec.rb +36 -0
  153. data/spec/models/member_resume_request_spec.rb +36 -0
  154. data/spec/models/member_spec.rb +96 -0
  155. data/spec/models/member_update_request_body_spec.rb +36 -0
  156. data/spec/models/member_update_request_spec.rb +48 -0
  157. data/spec/models/members_response_body_spec.rb +42 -0
  158. data/spec/models/pagination_spec.rb +54 -0
  159. data/spec/models/transaction_cleanse_and_categorize_request_spec.rb +54 -0
  160. data/spec/models/transaction_cleanse_and_categorize_response_spec.rb +108 -0
  161. data/spec/models/transaction_response_body_spec.rb +36 -0
  162. data/spec/models/transaction_spec.rb +216 -0
  163. data/spec/models/transactions_cleanse_and_categorize_request_body_spec.rb +36 -0
  164. data/spec/models/transactions_cleanse_and_categorize_response_body_spec.rb +36 -0
  165. data/spec/models/transactions_response_body_spec.rb +42 -0
  166. data/spec/models/user_create_request_body_spec.rb +36 -0
  167. data/spec/models/user_response_body_spec.rb +36 -0
  168. data/spec/models/user_spec.rb +54 -0
  169. data/spec/models/user_update_request_body_spec.rb +36 -0
  170. data/spec/models/users_response_body_spec.rb +42 -0
  171. data/spec/spec_helper.rb +107 -0
  172. metadata +323 -91
  173. data/.gitignore +0 -10
  174. data/.rubocop.yml +0 -12
  175. data/.travis.yml +0 -12
  176. data/bin/console +0 -14
  177. data/bin/demo +0 -49
  178. data/bin/setup +0 -8
  179. data/examples/accounts_and_transactions.rb +0 -49
  180. data/examples/all_endpoints.rb +0 -226
  181. data/examples/example_workflow.rb +0 -176
  182. data/examples/multi_factor_authentication.rb +0 -57
  183. data/examples/update_credentials.rb +0 -58
  184. data/examples/user_and_member_creation.rb +0 -53
  185. data/lib/atrium.rb +0 -40
  186. data/lib/atrium/account.rb +0 -100
  187. data/lib/atrium/account_number.rb +0 -13
  188. data/lib/atrium/account_owner.rb +0 -19
  189. data/lib/atrium/challenge.rb +0 -13
  190. data/lib/atrium/client.rb +0 -51
  191. data/lib/atrium/connect.rb +0 -34
  192. data/lib/atrium/credential.rb +0 -11
  193. data/lib/atrium/error.rb +0 -4
  194. data/lib/atrium/institution.rb +0 -38
  195. data/lib/atrium/member.rb +0 -264
  196. data/lib/atrium/pageable.rb +0 -74
  197. data/lib/atrium/paginate.rb +0 -92
  198. data/lib/atrium/ruby.rb +0 -3
  199. data/lib/atrium/transaction.rb +0 -74
  200. data/lib/atrium/user.rb +0 -150
  201. data/lib/atrium/version.rb +0 -3
@@ -0,0 +1,71 @@
1
+ =begin
2
+ #MX API
3
+
4
+ #The MX Atrium API supports over 48,000 data connections to thousands of financial institutions. It provides secure access to your users' accounts and transactions with industry-leading cleansing, categorization, and classification. Atrium is designed according to resource-oriented REST architecture and responds with JSON bodies and HTTP response codes. Use Atrium's development environment, vestibule.mx.com, to quickly get up and running. The development environment limits are 100 users, 25 members per user, and access to the top 15 institutions. Contact MX to purchase production access.
5
+
6
+
7
+ =end
8
+
9
+ require 'spec_helper'
10
+ require 'json'
11
+
12
+ # Unit tests for Atrium::TransactionsApi
13
+ # Please update as you see appropriate
14
+ describe 'TransactionsApi' do
15
+ before do
16
+ # run before each test
17
+ @instance = Atrium::TransactionsApi.new
18
+ end
19
+
20
+ after do
21
+ # run after each test
22
+ end
23
+
24
+ describe 'test an instance of TransactionsApi' do
25
+ it 'should create an instance of TransactionsApi' do
26
+ expect(@instance).to be_instance_of(Atrium::TransactionsApi)
27
+ end
28
+ end
29
+
30
+ # unit tests for cleanse_and_categorize_transactions
31
+ # Categorize transactions
32
+ # Use this endpoint to categorize, cleanse, and classify transactions. These transactions are not persisted or stored on the MX platform.
33
+ # @param body User object to be created with optional parameters (amount, type) amd required parameters (description, identifier)
34
+ # @param [Hash] opts the optional parameters
35
+ # @return [TransactionsCleanseAndCategorizeResponseBody]
36
+ describe 'cleanse_and_categorize_transactions test' do
37
+ it 'should work' do
38
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
39
+ end
40
+ end
41
+
42
+ # unit tests for list_user_transactions
43
+ # List transactions for a user
44
+ # Use this endpoint to get all transactions that belong to a specific user, across all the user's members and accounts.<br> This endpoint accepts optional query parameters, from_date and to_date, which filter transactions according to the date they were posted. If no values are given, from_date will default to 90 days prior to the request, and to_date will default to 5 days from the time of the request.
45
+ # @param user_guid The unique identifier for a `user`.
46
+ # @param [Hash] opts the optional parameters
47
+ # @option opts [Integer] :page Specify current page.
48
+ # @option opts [String] :from_date Filter transactions from this date.
49
+ # @option opts [Integer] :records_per_page Specify records per page.
50
+ # @option opts [String] :to_date Filter transactions to this date.
51
+ # @return [TransactionsResponseBody]
52
+ describe 'list_user_transactions test' do
53
+ it 'should work' do
54
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
55
+ end
56
+ end
57
+
58
+ # unit tests for read_transaction
59
+ # Read a transaction
60
+ # This endpoint allows you to view information about a specific transaction that belongs to a user.<br>
61
+ # @param transaction_guid The unique identifier for a `transaction`.
62
+ # @param user_guid The unique identifier for a `user`.
63
+ # @param [Hash] opts the optional parameters
64
+ # @return [TransactionResponseBody]
65
+ describe 'read_transaction test' do
66
+ it 'should work' do
67
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
68
+ end
69
+ end
70
+
71
+ end
@@ -0,0 +1,92 @@
1
+ =begin
2
+ #MX API
3
+
4
+ #The MX Atrium API supports over 48,000 data connections to thousands of financial institutions. It provides secure access to your users' accounts and transactions with industry-leading cleansing, categorization, and classification. Atrium is designed according to resource-oriented REST architecture and responds with JSON bodies and HTTP response codes. Use Atrium's development environment, vestibule.mx.com, to quickly get up and running. The development environment limits are 100 users, 25 members per user, and access to the top 15 institutions. Contact MX to purchase production access.
5
+
6
+
7
+ =end
8
+
9
+ require 'spec_helper'
10
+ require 'json'
11
+
12
+ # Unit tests for Atrium::UsersApi
13
+ # Please update as you see appropriate
14
+ describe 'UsersApi' do
15
+ before do
16
+ # run before each test
17
+ @instance = Atrium::UsersApi.new
18
+ end
19
+
20
+ after do
21
+ # run after each test
22
+ end
23
+
24
+ describe 'test an instance of UsersApi' do
25
+ it 'should create an instance of UsersApi' do
26
+ expect(@instance).to be_instance_of(Atrium::UsersApi)
27
+ end
28
+ end
29
+
30
+ # unit tests for create_user
31
+ # Create user
32
+ # Call this endpoint to create a new user. Atrium will respond with the newly-created user object if successful. This endpoint accepts several parameters: identifier, metadata, and is_disabled.<br> Disabling a user means that accounts and transactions associated with it will not be updated in the background by MX. It will also restrict access to that user's data until they are no longer disabled. Users who are disabled for the entirety of an Atrium billing period will not be factored into that month's bill.
33
+ # @param body User object to be created with optional parameters (identifier, is_disabled, metadata)
34
+ # @param [Hash] opts the optional parameters
35
+ # @return [UserResponseBody]
36
+ describe 'create_user test' do
37
+ it 'should work' do
38
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
39
+ end
40
+ end
41
+
42
+ # unit tests for delete_user
43
+ # Delete user
44
+ # Calling this endpoint will permanently delete a user from Atrium. If successful, the API will respond with Status: 204 No Content.
45
+ # @param user_guid The unique identifier for a `user`.
46
+ # @param [Hash] opts the optional parameters
47
+ # @return [nil]
48
+ describe 'delete_user test' do
49
+ it 'should work' do
50
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
51
+ end
52
+ end
53
+
54
+ # unit tests for list_users
55
+ # List users
56
+ # Use this endpoint to list every user you've created in Atrium.
57
+ # @param [Hash] opts the optional parameters
58
+ # @option opts [Integer] :page Specify current page.
59
+ # @option opts [Integer] :records_per_page Specify records per page.
60
+ # @return [UsersResponseBody]
61
+ describe 'list_users test' do
62
+ it 'should work' do
63
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
64
+ end
65
+ end
66
+
67
+ # unit tests for read_user
68
+ # Read user
69
+ # Use this endpoint to read the attributes of a specific user.
70
+ # @param user_guid The unique identifier for a `user`.
71
+ # @param [Hash] opts the optional parameters
72
+ # @return [UserResponseBody]
73
+ describe 'read_user test' do
74
+ it 'should work' do
75
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
76
+ end
77
+ end
78
+
79
+ # unit tests for update_user
80
+ # Update user
81
+ # Use this endpoint to update the attributes of a specific user. Atrium will respond with the updated user object.<br> Disabling a user means that accounts and transactions associated with it will not be updated in the background by MX. It will also restrict access to that user's data until they are no longer disabled. Users who are disabled for the entirety of an Atrium billing period will not be factored into that month's bill.<br> To disable a user, update it and set the is_disabled parameter to true. Set it to false to re-enable the user.
82
+ # @param user_guid The unique identifier for a `user`.
83
+ # @param [Hash] opts the optional parameters
84
+ # @option opts [UserUpdateRequestBody] :body User object to be updated with optional parameters (identifier, is_disabled, metadata)
85
+ # @return [UserResponseBody]
86
+ describe 'update_user test' do
87
+ it 'should work' do
88
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
89
+ end
90
+ end
91
+
92
+ end
@@ -0,0 +1,69 @@
1
+ =begin
2
+ #MX API
3
+
4
+ #The MX Atrium API supports over 48,000 data connections to thousands of financial institutions. It provides secure access to your users' accounts and transactions with industry-leading cleansing, categorization, and classification. Atrium is designed according to resource-oriented REST architecture and responds with JSON bodies and HTTP response codes. Use Atrium's development environment, vestibule.mx.com, to quickly get up and running. The development environment limits are 100 users, 25 members per user, and access to the top 15 institutions. Contact MX to purchase production access.
5
+
6
+
7
+ =end
8
+
9
+ require 'spec_helper'
10
+ require 'json'
11
+
12
+ # Unit tests for Atrium::VerificationApi
13
+ # Please update as you see appropriate
14
+ describe 'VerificationApi' do
15
+ before do
16
+ # run before each test
17
+ @instance = Atrium::VerificationApi.new
18
+ end
19
+
20
+ after do
21
+ # run after each test
22
+ end
23
+
24
+ describe 'test an instance of VerificationApi' do
25
+ it 'should create an instance of VerificationApi' do
26
+ expect(@instance).to be_instance_of(Atrium::VerificationApi)
27
+ end
28
+ end
29
+
30
+ # unit tests for list_account_numbers
31
+ # Read account numbers
32
+ # Use this endpoint to check whether account and routing numbers are available for accounts associated with a particular member. It returns the account_numbers object, which contains account and routing number data for each account associated with the member.
33
+ # @param member_guid The unique identifier for a `member`.
34
+ # @param user_guid The unique identifier for a `user`.
35
+ # @param [Hash] opts the optional parameters
36
+ # @return [AccountNumbersResponseBody]
37
+ describe 'list_account_numbers test' do
38
+ it 'should work' do
39
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
40
+ end
41
+ end
42
+
43
+ # unit tests for list_account_numbers_by_account
44
+ # Read account numbers by account GUID
45
+ # Use this endpoint to check whether account and routing numbers are available for a specific account. It returns the account_numbers object, which contains account and routing number data.
46
+ # @param account_guid The unique identifier for an `account`.
47
+ # @param user_guid The unique identifier for a `user`.
48
+ # @param [Hash] opts the optional parameters
49
+ # @return [AccountNumbersResponseBody]
50
+ describe 'list_account_numbers_by_account test' do
51
+ it 'should work' do
52
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
53
+ end
54
+ end
55
+
56
+ # unit tests for verify_member
57
+ # Verify
58
+ # The verify endpoint begins a verification process for a member.
59
+ # @param member_guid The unique identifier for a `member`.
60
+ # @param user_guid The unique identifier for a `user`.
61
+ # @param [Hash] opts the optional parameters
62
+ # @return [MemberResponseBody]
63
+ describe 'verify_member test' do
64
+ it 'should work' do
65
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
66
+ end
67
+ end
68
+
69
+ end
@@ -0,0 +1,222 @@
1
+ =begin
2
+ #MX API
3
+
4
+ #The MX Atrium API supports over 48,000 data connections to thousands of financial institutions. It provides secure access to your users' accounts and transactions with industry-leading cleansing, categorization, and classification. Atrium is designed according to resource-oriented REST architecture and responds with JSON bodies and HTTP response codes. Use Atrium's development environment, vestibule.mx.com, to quickly get up and running. The development environment limits are 100 users, 25 members per user, and access to the top 15 institutions. Contact MX to purchase production access.
5
+
6
+
7
+ =end
8
+
9
+ require 'spec_helper'
10
+
11
+ describe Atrium::ApiClient do
12
+ context 'initialization' do
13
+ context 'URL stuff' do
14
+ context 'host' do
15
+ it 'removes http from host' do
16
+ Atrium.configure { |c| c.host = 'http://example.com' }
17
+ expect(Atrium::Configuration.default.host).to eq('example.com')
18
+ end
19
+
20
+ it 'removes https from host' do
21
+ Atrium.configure { |c| c.host = 'https://wookiee.com' }
22
+ expect(Atrium::ApiClient.default.config.host).to eq('wookiee.com')
23
+ end
24
+
25
+ it 'removes trailing path from host' do
26
+ Atrium.configure { |c| c.host = 'hobo.com/v4' }
27
+ expect(Atrium::Configuration.default.host).to eq('hobo.com')
28
+ end
29
+ end
30
+
31
+ context 'base_path' do
32
+ it "prepends a slash to base_path" do
33
+ Atrium.configure { |c| c.base_path = 'v4/dog' }
34
+ expect(Atrium::Configuration.default.base_path).to eq('/v4/dog')
35
+ end
36
+
37
+ it "doesn't prepend a slash if one is already there" do
38
+ Atrium.configure { |c| c.base_path = '/v4/dog' }
39
+ expect(Atrium::Configuration.default.base_path).to eq('/v4/dog')
40
+ end
41
+
42
+ it "ends up as a blank string if nil" do
43
+ Atrium.configure { |c| c.base_path = nil }
44
+ expect(Atrium::Configuration.default.base_path).to eq('')
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ describe 'params_encoding in #build_request' do
51
+ let(:config) { Atrium::Configuration.new }
52
+ let(:api_client) { Atrium::ApiClient.new(config) }
53
+
54
+ it 'defaults to nil' do
55
+ expect(Atrium::Configuration.default.params_encoding).to eq(nil)
56
+ expect(config.params_encoding).to eq(nil)
57
+
58
+ request = api_client.build_request(:get, '/test')
59
+ expect(request.options[:params_encoding]).to eq(nil)
60
+ end
61
+
62
+ it 'can be customized' do
63
+ config.params_encoding = :multi
64
+ request = api_client.build_request(:get, '/test')
65
+ expect(request.options[:params_encoding]).to eq(:multi)
66
+ end
67
+ end
68
+
69
+ describe 'timeout in #build_request' do
70
+ let(:config) { Atrium::Configuration.new }
71
+ let(:api_client) { Atrium::ApiClient.new(config) }
72
+
73
+ it 'defaults to 0' do
74
+ expect(Atrium::Configuration.default.timeout).to eq(0)
75
+ expect(config.timeout).to eq(0)
76
+
77
+ request = api_client.build_request(:get, '/test')
78
+ expect(request.options[:timeout]).to eq(0)
79
+ end
80
+
81
+ it 'can be customized' do
82
+ config.timeout = 100
83
+ request = api_client.build_request(:get, '/test')
84
+ expect(request.options[:timeout]).to eq(100)
85
+ end
86
+ end
87
+
88
+ describe '#deserialize' do
89
+ it "handles Array<Integer>" do
90
+ api_client = Atrium::ApiClient.new
91
+ headers = { 'Content-Type' => 'application/json' }
92
+ response = double('response', headers: headers, body: '[12, 34]')
93
+ data = api_client.deserialize(response, 'Array<Integer>')
94
+ expect(data).to be_instance_of(Array)
95
+ expect(data).to eq([12, 34])
96
+ end
97
+
98
+ it 'handles Array<Array<Integer>>' do
99
+ api_client = Atrium::ApiClient.new
100
+ headers = { 'Content-Type' => 'application/json' }
101
+ response = double('response', headers: headers, body: '[[12, 34], [56]]')
102
+ data = api_client.deserialize(response, 'Array<Array<Integer>>')
103
+ expect(data).to be_instance_of(Array)
104
+ expect(data).to eq([[12, 34], [56]])
105
+ end
106
+
107
+ it 'handles Hash<String, String>' do
108
+ api_client = Atrium::ApiClient.new
109
+ headers = { 'Content-Type' => 'application/json' }
110
+ response = double('response', headers: headers, body: '{"message": "Hello"}')
111
+ data = api_client.deserialize(response, 'Hash<String, String>')
112
+ expect(data).to be_instance_of(Hash)
113
+ expect(data).to eq(:message => 'Hello')
114
+ end
115
+ end
116
+
117
+ describe "#object_to_hash" do
118
+ it 'ignores nils and includes empty arrays' do
119
+ # uncomment below to test object_to_hash for model
120
+ # api_client = Atrium::ApiClient.new
121
+ # _model = Atrium::ModelName.new
122
+ # update the model attribute below
123
+ # _model.id = 1
124
+ # update the expected value (hash) below
125
+ # expected = {id: 1, name: '', tags: []}
126
+ # expect(api_client.object_to_hash(_model)).to eq(expected)
127
+ end
128
+ end
129
+
130
+ describe '#build_collection_param' do
131
+ let(:param) { ['aa', 'bb', 'cc'] }
132
+ let(:api_client) { Atrium::ApiClient.new }
133
+
134
+ it 'works for csv' do
135
+ expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
136
+ end
137
+
138
+ it 'works for ssv' do
139
+ expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc')
140
+ end
141
+
142
+ it 'works for tsv' do
143
+ expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
144
+ end
145
+
146
+ it 'works for pipes' do
147
+ expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
148
+ end
149
+
150
+ it 'works for multi' do
151
+ expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
152
+ end
153
+
154
+ it 'fails for invalid collection format' do
155
+ expect(proc { api_client.build_collection_param(param, :INVALID) }).to raise_error(RuntimeError, 'unknown collection format: :INVALID')
156
+ end
157
+ end
158
+
159
+ describe '#json_mime?' do
160
+ let(:api_client) { Atrium::ApiClient.new }
161
+
162
+ it 'works' do
163
+ expect(api_client.json_mime?(nil)).to eq false
164
+ expect(api_client.json_mime?('')).to eq false
165
+
166
+ expect(api_client.json_mime?('application/json')).to eq true
167
+ expect(api_client.json_mime?('application/json; charset=UTF8')).to eq true
168
+ expect(api_client.json_mime?('APPLICATION/JSON')).to eq true
169
+
170
+ expect(api_client.json_mime?('application/xml')).to eq false
171
+ expect(api_client.json_mime?('text/plain')).to eq false
172
+ expect(api_client.json_mime?('application/jsonp')).to eq false
173
+ end
174
+ end
175
+
176
+ describe '#select_header_accept' do
177
+ let(:api_client) { Atrium::ApiClient.new }
178
+
179
+ it 'works' do
180
+ expect(api_client.select_header_accept(nil)).to be_nil
181
+ expect(api_client.select_header_accept([])).to be_nil
182
+
183
+ expect(api_client.select_header_accept(['application/json'])).to eq('application/json')
184
+ expect(api_client.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
185
+ expect(api_client.select_header_accept(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
186
+
187
+ expect(api_client.select_header_accept(['application/xml'])).to eq('application/xml')
188
+ expect(api_client.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml')
189
+ end
190
+ end
191
+
192
+ describe '#select_header_content_type' do
193
+ let(:api_client) { Atrium::ApiClient.new }
194
+
195
+ it 'works' do
196
+ expect(api_client.select_header_content_type(nil)).to eq('application/json')
197
+ expect(api_client.select_header_content_type([])).to eq('application/json')
198
+
199
+ expect(api_client.select_header_content_type(['application/json'])).to eq('application/json')
200
+ expect(api_client.select_header_content_type(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
201
+ expect(api_client.select_header_content_type(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
202
+ expect(api_client.select_header_content_type(['application/xml'])).to eq('application/xml')
203
+ expect(api_client.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain')
204
+ end
205
+ end
206
+
207
+ describe '#sanitize_filename' do
208
+ let(:api_client) { Atrium::ApiClient.new }
209
+
210
+ it 'works' do
211
+ expect(api_client.sanitize_filename('sun')).to eq('sun')
212
+ expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif')
213
+ expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif')
214
+ expect(api_client.sanitize_filename('/var/tmp/sun.gif')).to eq('sun.gif')
215
+ expect(api_client.sanitize_filename('./sun.gif')).to eq('sun.gif')
216
+ expect(api_client.sanitize_filename('..\sun.gif')).to eq('sun.gif')
217
+ expect(api_client.sanitize_filename('\var\tmp\sun.gif')).to eq('sun.gif')
218
+ expect(api_client.sanitize_filename('c:\var\tmp\sun.gif')).to eq('sun.gif')
219
+ expect(api_client.sanitize_filename('.\sun.gif')).to eq('sun.gif')
220
+ end
221
+ end
222
+ end