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.
- checksums.yaml +5 -5
- data/Gemfile +5 -2
- data/README.md +132 -66
- data/Rakefile +7 -4
- data/atrium-ruby.gemspec +40 -32
- data/docs/Account.md +35 -0
- data/docs/AccountNumber.md +12 -0
- data/docs/AccountNumbersResponseBody.md +8 -0
- data/docs/AccountOwner.md +18 -0
- data/docs/AccountOwnersResponseBody.md +8 -0
- data/docs/AccountResponseBody.md +8 -0
- data/docs/AccountsApi.md +174 -0
- data/docs/AccountsResponseBody.md +9 -0
- data/docs/Challenge.md +13 -0
- data/docs/ChallengeOption.md +10 -0
- data/docs/ChallengesResponseBody.md +8 -0
- data/docs/ConnectWidget.md +9 -0
- data/docs/ConnectWidgetApi.md +44 -0
- data/docs/ConnectWidgetRequestBody.md +11 -0
- data/docs/ConnectWidgetResponseBody.md +8 -0
- data/docs/CredentialOption.md +9 -0
- data/docs/CredentialRequest.md +9 -0
- data/docs/CredentialResponse.md +12 -0
- data/docs/CredentialsResponseBody.md +8 -0
- data/docs/IdentityApi.md +82 -0
- data/docs/Institution.md +14 -0
- data/docs/InstitutionResponseBody.md +8 -0
- data/docs/InstitutionsApi.md +120 -0
- data/docs/InstitutionsResponseBody.md +9 -0
- data/docs/Member.md +18 -0
- data/docs/MemberConnectionStatus.md +16 -0
- data/docs/MemberConnectionStatusResponseBody.md +8 -0
- data/docs/MemberCreateRequest.md +11 -0
- data/docs/MemberCreateRequestBody.md +8 -0
- data/docs/MemberResponseBody.md +8 -0
- data/docs/MemberResumeRequest.md +8 -0
- data/docs/MemberResumeRequestBody.md +8 -0
- data/docs/MemberUpdateRequest.md +10 -0
- data/docs/MemberUpdateRequestBody.md +8 -0
- data/docs/MembersApi.md +487 -0
- data/docs/MembersResponseBody.md +9 -0
- data/docs/Pagination.md +11 -0
- data/docs/Transaction.md +38 -0
- data/docs/TransactionCleanseAndCategorizeRequest.md +11 -0
- data/docs/TransactionCleanseAndCategorizeResponse.md +20 -0
- data/docs/TransactionResponseBody.md +8 -0
- data/docs/TransactionsApi.md +126 -0
- data/docs/TransactionsCleanseAndCategorizeRequestBody.md +8 -0
- data/docs/TransactionsCleanseAndCategorizeResponseBody.md +8 -0
- data/docs/TransactionsResponseBody.md +9 -0
- data/docs/User.md +11 -0
- data/docs/UserCreateRequestBody.md +8 -0
- data/docs/UserResponseBody.md +8 -0
- data/docs/UserUpdateRequestBody.md +8 -0
- data/docs/UsersApi.md +193 -0
- data/docs/UsersResponseBody.md +9 -0
- data/docs/VerificationApi.md +120 -0
- data/git_push.sh +49 -0
- data/lib/atrium-ruby.rb +88 -0
- data/lib/atrium-ruby/api/accounts_api.rb +272 -0
- data/lib/atrium-ruby/api/atrium_client.rb +28 -0
- data/lib/atrium-ruby/api/connect_widget_api.rb +82 -0
- data/lib/atrium-ruby/api/identity_api.rb +140 -0
- data/lib/atrium-ruby/api/institutions_api.rb +181 -0
- data/lib/atrium-ruby/api/members_api.rb +749 -0
- data/lib/atrium-ruby/api/transactions_api.rb +198 -0
- data/lib/atrium-ruby/api/users_api.rb +287 -0
- data/lib/atrium-ruby/api/verification_api.rb +198 -0
- data/lib/atrium-ruby/api_client.rb +384 -0
- data/lib/atrium-ruby/api_error.rb +34 -0
- data/lib/atrium-ruby/configuration.rb +212 -0
- data/lib/atrium-ruby/models/account.rb +422 -0
- data/lib/atrium-ruby/models/account_number.rb +215 -0
- data/lib/atrium-ruby/models/account_numbers_response_body.rb +181 -0
- data/lib/atrium-ruby/models/account_owner.rb +269 -0
- data/lib/atrium-ruby/models/account_owners_response_body.rb +181 -0
- data/lib/atrium-ruby/models/account_response_body.rb +179 -0
- data/lib/atrium-ruby/models/accounts_response_body.rb +190 -0
- data/lib/atrium-ruby/models/challenge.rb +226 -0
- data/lib/atrium-ruby/models/challenge_option.rb +197 -0
- data/lib/atrium-ruby/models/challenges_response_body.rb +181 -0
- data/lib/atrium-ruby/models/connect_widget.rb +188 -0
- data/lib/atrium-ruby/models/connect_widget_request_body.rb +206 -0
- data/lib/atrium-ruby/models/connect_widget_response_body.rb +179 -0
- data/lib/atrium-ruby/models/credential_option.rb +188 -0
- data/lib/atrium-ruby/models/credential_request.rb +188 -0
- data/lib/atrium-ruby/models/credential_response.rb +217 -0
- data/lib/atrium-ruby/models/credentials_response_body.rb +181 -0
- data/lib/atrium-ruby/models/institution.rb +233 -0
- data/lib/atrium-ruby/models/institution_response_body.rb +179 -0
- data/lib/atrium-ruby/models/institutions_response_body.rb +190 -0
- data/lib/atrium-ruby/models/member.rb +269 -0
- data/lib/atrium-ruby/models/member_connection_status.rb +253 -0
- data/lib/atrium-ruby/models/member_connection_status_response_body.rb +179 -0
- data/lib/atrium-ruby/models/member_create_request.rb +218 -0
- data/lib/atrium-ruby/models/member_create_request_body.rb +179 -0
- data/lib/atrium-ruby/models/member_response_body.rb +179 -0
- data/lib/atrium-ruby/models/member_resume_request.rb +181 -0
- data/lib/atrium-ruby/models/member_resume_request_body.rb +179 -0
- data/lib/atrium-ruby/models/member_update_request.rb +199 -0
- data/lib/atrium-ruby/models/member_update_request_body.rb +179 -0
- data/lib/atrium-ruby/models/members_response_body.rb +190 -0
- data/lib/atrium-ruby/models/pagination.rb +206 -0
- data/lib/atrium-ruby/models/transaction.rb +449 -0
- data/lib/atrium-ruby/models/transaction_cleanse_and_categorize_request.rb +206 -0
- data/lib/atrium-ruby/models/transaction_cleanse_and_categorize_response.rb +287 -0
- data/lib/atrium-ruby/models/transaction_response_body.rb +179 -0
- data/lib/atrium-ruby/models/transactions_cleanse_and_categorize_request_body.rb +181 -0
- data/lib/atrium-ruby/models/transactions_cleanse_and_categorize_response_body.rb +181 -0
- data/lib/atrium-ruby/models/transactions_response_body.rb +190 -0
- data/lib/atrium-ruby/models/user.rb +206 -0
- data/lib/atrium-ruby/models/user_create_request_body.rb +179 -0
- data/lib/atrium-ruby/models/user_response_body.rb +179 -0
- data/lib/atrium-ruby/models/user_update_request_body.rb +179 -0
- data/lib/atrium-ruby/models/users_response_body.rb +190 -0
- data/lib/atrium-ruby/version.rb +11 -0
- data/spec/api/accounts_api_spec.rb +88 -0
- data/spec/api/connect_widget_api_spec.rb +43 -0
- data/spec/api/identity_api_spec.rb +56 -0
- data/spec/api/institutions_api_spec.rb +68 -0
- data/spec/api/members_api_spec.rb +195 -0
- data/spec/api/transactions_api_spec.rb +71 -0
- data/spec/api/users_api_spec.rb +92 -0
- data/spec/api/verification_api_spec.rb +69 -0
- data/spec/api_client_spec.rb +222 -0
- data/spec/configuration_spec.rb +38 -0
- data/spec/models/account_number_spec.rb +60 -0
- data/spec/models/account_numbers_response_body_spec.rb +36 -0
- data/spec/models/account_owner_spec.rb +96 -0
- data/spec/models/account_owners_response_body_spec.rb +36 -0
- data/spec/models/account_response_body_spec.rb +36 -0
- data/spec/models/account_spec.rb +198 -0
- data/spec/models/accounts_response_body_spec.rb +42 -0
- data/spec/models/challenge_option_spec.rb +48 -0
- data/spec/models/challenge_spec.rb +66 -0
- data/spec/models/challenges_response_body_spec.rb +36 -0
- data/spec/models/connect_widget_request_body_spec.rb +54 -0
- data/spec/models/connect_widget_response_body_spec.rb +36 -0
- data/spec/models/connect_widget_spec.rb +42 -0
- data/spec/models/credential_option_spec.rb +42 -0
- data/spec/models/credential_request_spec.rb +42 -0
- data/spec/models/credential_response_spec.rb +60 -0
- data/spec/models/credentials_response_body_spec.rb +36 -0
- data/spec/models/institution_response_body_spec.rb +36 -0
- data/spec/models/institution_spec.rb +72 -0
- data/spec/models/institutions_response_body_spec.rb +42 -0
- data/spec/models/member_connection_status_response_body_spec.rb +36 -0
- data/spec/models/member_connection_status_spec.rb +84 -0
- data/spec/models/member_create_request_body_spec.rb +36 -0
- data/spec/models/member_create_request_spec.rb +54 -0
- data/spec/models/member_response_body_spec.rb +36 -0
- data/spec/models/member_resume_request_body_spec.rb +36 -0
- data/spec/models/member_resume_request_spec.rb +36 -0
- data/spec/models/member_spec.rb +96 -0
- data/spec/models/member_update_request_body_spec.rb +36 -0
- data/spec/models/member_update_request_spec.rb +48 -0
- data/spec/models/members_response_body_spec.rb +42 -0
- data/spec/models/pagination_spec.rb +54 -0
- data/spec/models/transaction_cleanse_and_categorize_request_spec.rb +54 -0
- data/spec/models/transaction_cleanse_and_categorize_response_spec.rb +108 -0
- data/spec/models/transaction_response_body_spec.rb +36 -0
- data/spec/models/transaction_spec.rb +216 -0
- data/spec/models/transactions_cleanse_and_categorize_request_body_spec.rb +36 -0
- data/spec/models/transactions_cleanse_and_categorize_response_body_spec.rb +36 -0
- data/spec/models/transactions_response_body_spec.rb +42 -0
- data/spec/models/user_create_request_body_spec.rb +36 -0
- data/spec/models/user_response_body_spec.rb +36 -0
- data/spec/models/user_spec.rb +54 -0
- data/spec/models/user_update_request_body_spec.rb +36 -0
- data/spec/models/users_response_body_spec.rb +42 -0
- data/spec/spec_helper.rb +107 -0
- metadata +323 -91
- data/.gitignore +0 -10
- data/.rubocop.yml +0 -12
- data/.travis.yml +0 -12
- data/bin/console +0 -14
- data/bin/demo +0 -49
- data/bin/setup +0 -8
- data/examples/accounts_and_transactions.rb +0 -49
- data/examples/all_endpoints.rb +0 -226
- data/examples/example_workflow.rb +0 -176
- data/examples/multi_factor_authentication.rb +0 -57
- data/examples/update_credentials.rb +0 -58
- data/examples/user_and_member_creation.rb +0 -53
- data/lib/atrium.rb +0 -40
- data/lib/atrium/account.rb +0 -100
- data/lib/atrium/account_number.rb +0 -13
- data/lib/atrium/account_owner.rb +0 -19
- data/lib/atrium/challenge.rb +0 -13
- data/lib/atrium/client.rb +0 -51
- data/lib/atrium/connect.rb +0 -34
- data/lib/atrium/credential.rb +0 -11
- data/lib/atrium/error.rb +0 -4
- data/lib/atrium/institution.rb +0 -38
- data/lib/atrium/member.rb +0 -264
- data/lib/atrium/pageable.rb +0 -74
- data/lib/atrium/paginate.rb +0 -92
- data/lib/atrium/ruby.rb +0 -3
- data/lib/atrium/transaction.rb +0 -74
- data/lib/atrium/user.rb +0 -150
- data/lib/atrium/version.rb +0 -3
data/lib/atrium/credential.rb
DELETED
data/lib/atrium/error.rb
DELETED
data/lib/atrium/institution.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
module Atrium
|
2
|
-
class Institution
|
3
|
-
extend ::Atrium::Paginate
|
4
|
-
include ::ActiveAttr::Model
|
5
|
-
|
6
|
-
attribute :code
|
7
|
-
attribute :name
|
8
|
-
attribute :url
|
9
|
-
attribute :small_logo_url
|
10
|
-
attribute :medium_logo_url
|
11
|
-
|
12
|
-
# @todo Normalize params interface across gem, most of gem favors hash
|
13
|
-
def self.credentials(institution_code)
|
14
|
-
endpoint = "/institutions/#{institution_code}/credentials"
|
15
|
-
response = ::Atrium.client.make_request(:get, endpoint)
|
16
|
-
|
17
|
-
response["credentials"].map do |credential|
|
18
|
-
::Atrium::Credential.new(credential)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.read(institution_code:)
|
23
|
-
endpoint = "/institutions/#{institution_code}"
|
24
|
-
response = ::Atrium.client.make_request(:get, endpoint)
|
25
|
-
|
26
|
-
institution_params = response["institution"]
|
27
|
-
::Atrium::Institution.new(institution_params)
|
28
|
-
end
|
29
|
-
|
30
|
-
def self.list(query_params: nil, limit: nil)
|
31
|
-
paginate_endpoint(:query_params => query_params, :limit => limit)
|
32
|
-
end
|
33
|
-
|
34
|
-
def self.list_in_batches(query_params: nil, limit: nil, &block)
|
35
|
-
paginate_endpoint_in_batches(:query_params => query_params, :limit => limit, &block)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
data/lib/atrium/member.rb
DELETED
@@ -1,264 +0,0 @@
|
|
1
|
-
module Atrium
|
2
|
-
class Member
|
3
|
-
extend ::Atrium::Pageable
|
4
|
-
include ::ActiveAttr::Model
|
5
|
-
|
6
|
-
attribute :aggregated_at
|
7
|
-
attribute :connection_status
|
8
|
-
attribute :challenges
|
9
|
-
attribute :guid
|
10
|
-
attribute :has_processed_accounts
|
11
|
-
attribute :has_processed_transactions
|
12
|
-
attribute :identifier
|
13
|
-
attribute :institution_code
|
14
|
-
attribute :is_being_aggregated
|
15
|
-
attribute :metadata
|
16
|
-
attribute :name
|
17
|
-
attribute :status
|
18
|
-
attribute :successfully_aggregated_at
|
19
|
-
attribute :user_guid
|
20
|
-
|
21
|
-
##
|
22
|
-
# CLASS METHODS
|
23
|
-
#
|
24
|
-
def self.create(user_guid:, institution_code:, credentials:)
|
25
|
-
endpoint = "/users/#{user_guid}/members"
|
26
|
-
body = create_params(institution_code, credentials)
|
27
|
-
member_response = ::Atrium.client.make_request(:post, endpoint, body)
|
28
|
-
|
29
|
-
member_params = member_response["member"]
|
30
|
-
::Atrium::Member.new(member_params)
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.list(options = {})
|
34
|
-
options = _member_pagination_options(options)
|
35
|
-
paginate(options)
|
36
|
-
end
|
37
|
-
|
38
|
-
def self.list_each(options = {})
|
39
|
-
options = _member_pagination_options(options)
|
40
|
-
paginate_each(options) { |member| yield member }
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.list_in_batches(options = {})
|
44
|
-
options = _member_pagination_options(options)
|
45
|
-
paginate_in_batches(options) { |batch| yield batch }
|
46
|
-
end
|
47
|
-
|
48
|
-
def self.read(user_guid:, member_guid:)
|
49
|
-
endpoint = "/users/#{user_guid}/members/#{member_guid}"
|
50
|
-
member_response = ::Atrium.client.make_request(:get, endpoint)
|
51
|
-
|
52
|
-
member_params = member_response["member"]
|
53
|
-
::Atrium::Member.new(member_params)
|
54
|
-
end
|
55
|
-
|
56
|
-
##
|
57
|
-
# INSTANCE METHODS
|
58
|
-
#
|
59
|
-
def accounts(options = {})
|
60
|
-
options = _account_pagination_options(options)
|
61
|
-
self.class.paginate(options)
|
62
|
-
end
|
63
|
-
|
64
|
-
def each_account(options = {})
|
65
|
-
options = _account_pagination_options(options)
|
66
|
-
self.class.paginate_each(options) { |account| yield account }
|
67
|
-
end
|
68
|
-
|
69
|
-
def accounts_in_batches(options = {})
|
70
|
-
options = _account_pagination_options(options)
|
71
|
-
self.class.paginate_in_batches(options) { |batch| yield batch }
|
72
|
-
end
|
73
|
-
|
74
|
-
def aggregate
|
75
|
-
endpoint = "/users/#{user_guid}/members/#{guid}/aggregate"
|
76
|
-
member_response = ::Atrium.client.make_request(:post, endpoint)
|
77
|
-
|
78
|
-
member_params = member_response["member"]
|
79
|
-
assign_attributes(member_params)
|
80
|
-
self
|
81
|
-
end
|
82
|
-
|
83
|
-
def aggregation_status
|
84
|
-
endpoint = "/users/#{user_guid}/members/#{guid}/status"
|
85
|
-
member_response = ::Atrium.client.make_request(:get, endpoint)
|
86
|
-
|
87
|
-
member_params = member_response["member"]
|
88
|
-
assign_attributes(member_params)
|
89
|
-
self
|
90
|
-
end
|
91
|
-
|
92
|
-
def mfa_challenges
|
93
|
-
endpoint = "/users/#{user_guid}/members/#{guid}/challenges"
|
94
|
-
challenge_response = ::Atrium.client.make_request(:get, endpoint)
|
95
|
-
|
96
|
-
return nil if challenge_response.nil?
|
97
|
-
|
98
|
-
challenge_params = challenge_response["challenges"]
|
99
|
-
|
100
|
-
challenge_params.map do |challenge|
|
101
|
-
::Atrium::Challenge.new(challenge)
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
def delete
|
106
|
-
endpoint = "/users/#{user_guid}/members/#{guid}"
|
107
|
-
::Atrium.client.make_request(:delete, endpoint)
|
108
|
-
|
109
|
-
self
|
110
|
-
end
|
111
|
-
|
112
|
-
def read_account(account_guid:)
|
113
|
-
endpoint = "/users/#{user_guid}/members/#{guid}/accounts/#{account_guid}"
|
114
|
-
account_response = ::Atrium.client.make_request(:get, endpoint)
|
115
|
-
|
116
|
-
account_params = account_response["account"]
|
117
|
-
::Atrium::Account.new(account_params)
|
118
|
-
end
|
119
|
-
|
120
|
-
def resume(challenge_credentials)
|
121
|
-
endpoint = "/users/#{user_guid}/members/#{guid}/resume"
|
122
|
-
body = resume_params(challenge_credentials)
|
123
|
-
member_response = ::Atrium.client.make_request(:put, endpoint, body)
|
124
|
-
|
125
|
-
member_params = member_response["member"]
|
126
|
-
assign_attributes(member_params)
|
127
|
-
self
|
128
|
-
end
|
129
|
-
|
130
|
-
def update(params)
|
131
|
-
endpoint = "/users/#{user_guid}/members/#{guid}"
|
132
|
-
body = member_body(params)
|
133
|
-
member_response = ::Atrium.client.make_request(:put, endpoint, body)
|
134
|
-
|
135
|
-
member_params = member_response["member"]
|
136
|
-
assign_attributes(member_params)
|
137
|
-
self
|
138
|
-
end
|
139
|
-
|
140
|
-
def credentials
|
141
|
-
endpoint = "/users/#{user_guid}/members/#{guid}/credentials"
|
142
|
-
credential_response = ::Atrium.client.make_request(:get, endpoint)
|
143
|
-
|
144
|
-
return nil if credential_response.nil?
|
145
|
-
|
146
|
-
credential_params = credential_response["credentials"]
|
147
|
-
|
148
|
-
credential_params.map do |credential|
|
149
|
-
::Atrium::Credential.new(credential)
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
def transactions(options = {})
|
154
|
-
options = _transaction_pagination_options(options)
|
155
|
-
self.class.paginate(options)
|
156
|
-
end
|
157
|
-
|
158
|
-
def each_transaction(options = {})
|
159
|
-
options = _transaction_pagination_options(options)
|
160
|
-
self.class.paginate_each(options) { |transaction| yield transaction }
|
161
|
-
end
|
162
|
-
|
163
|
-
def transactions_in_batches(options = {})
|
164
|
-
options = _transaction_pagination_options(options)
|
165
|
-
self.class.paginate_in_batches(options) { |batch| yield batch }
|
166
|
-
end
|
167
|
-
|
168
|
-
def self._member_pagination_options(options)
|
169
|
-
user_guid = options.fetch(:user_guid)
|
170
|
-
endpoint = "/users/#{user_guid}/members"
|
171
|
-
options.merge(:endpoint => endpoint, :resource => "members")
|
172
|
-
end
|
173
|
-
|
174
|
-
def verify
|
175
|
-
endpoint = "/users/#{user_guid}/members/#{guid}/verify"
|
176
|
-
member_response = ::Atrium.client.make_request(:post, endpoint)
|
177
|
-
|
178
|
-
member_params = member_response["member"]
|
179
|
-
assign_attributes(member_params)
|
180
|
-
self
|
181
|
-
end
|
182
|
-
|
183
|
-
def account_numbers
|
184
|
-
endpoint = "/users/#{user_guid}/members/#{guid}/account_numbers"
|
185
|
-
account_numbers_response = ::Atrium.client.make_request(:get, endpoint)
|
186
|
-
|
187
|
-
return nil if account_numbers_response.nil?
|
188
|
-
|
189
|
-
account_numbers_params = account_numbers_response["account_numbers"]
|
190
|
-
|
191
|
-
account_numbers_params.map do |account_number|
|
192
|
-
::Atrium::AccountNumber.new(account_number)
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
|
-
def identify
|
197
|
-
endpoint = "/users/#{user_guid}/members/#{guid}/identify"
|
198
|
-
member_response = ::Atrium.client.make_request(:post, endpoint)
|
199
|
-
|
200
|
-
member_params = member_response["member"]
|
201
|
-
assign_attributes(member_params)
|
202
|
-
self
|
203
|
-
end
|
204
|
-
|
205
|
-
def account_owners
|
206
|
-
endpoint = "/users/#{user_guid}/members/#{guid}/account_owners"
|
207
|
-
account_owners_response = ::Atrium.client.make_request(:get, endpoint)
|
208
|
-
|
209
|
-
return nil if account_owners_response.nil?
|
210
|
-
|
211
|
-
account_owners_params = account_owners_response["account_owners"]
|
212
|
-
|
213
|
-
account_owners_params.map do |account_owner|
|
214
|
-
::Atrium::AccountOwner.new(account_owner)
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
##
|
219
|
-
# PRIVATE CLASS METHODS
|
220
|
-
#
|
221
|
-
def self.create_params(institution_code, credentials_array)
|
222
|
-
{
|
223
|
-
:member => {
|
224
|
-
:institution_code => institution_code,
|
225
|
-
:credentials => credentials_array
|
226
|
-
}
|
227
|
-
}
|
228
|
-
end
|
229
|
-
private_class_method :create_params
|
230
|
-
|
231
|
-
private
|
232
|
-
|
233
|
-
##
|
234
|
-
# PRIVATE INSTANCE METHODS
|
235
|
-
#
|
236
|
-
def _account_pagination_options(options)
|
237
|
-
endpoint = "/users/#{user_guid}/members/#{guid}/accounts"
|
238
|
-
options.merge(:endpoint => endpoint, :resource => "accounts", :klass => ::Atrium::Account)
|
239
|
-
end
|
240
|
-
|
241
|
-
def member_body(params)
|
242
|
-
{
|
243
|
-
:member => {
|
244
|
-
:credentials => params[:credentials],
|
245
|
-
:identifier => params[:identifier],
|
246
|
-
:metadata => params[:metadata]
|
247
|
-
}
|
248
|
-
}
|
249
|
-
end
|
250
|
-
|
251
|
-
def resume_params(challenge_credentials)
|
252
|
-
{
|
253
|
-
:member => {
|
254
|
-
:challenges => challenge_credentials
|
255
|
-
}
|
256
|
-
}
|
257
|
-
end
|
258
|
-
|
259
|
-
def _transaction_pagination_options(options)
|
260
|
-
endpoint = "/users/#{user_guid}/members/#{guid}/transactions"
|
261
|
-
options.merge(:endpoint => endpoint, :resource => "transactions", :klass => ::Atrium::Transaction)
|
262
|
-
end
|
263
|
-
end
|
264
|
-
end
|
data/lib/atrium/pageable.rb
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
module Atrium
|
2
|
-
class PaginationBatch < ::Array
|
3
|
-
attr_accessor :total_pages, :total_entries, :current_page, :records_per_page
|
4
|
-
end
|
5
|
-
|
6
|
-
module Pageable
|
7
|
-
DEFAULT_RECORDS_PER_PAGE = 25
|
8
|
-
|
9
|
-
def make_get_request(endpoint, query_params)
|
10
|
-
uri = endpoint + "?" + ::URI.encode_www_form(query_params.sort)
|
11
|
-
::Atrium.client.make_request(:get, uri)
|
12
|
-
end
|
13
|
-
|
14
|
-
def paginate(options = {})
|
15
|
-
records_per_page = options.fetch(:records_per_page, DEFAULT_RECORDS_PER_PAGE)
|
16
|
-
results = PaginationBatch.new
|
17
|
-
paginate_in_batches(options.merge(:limit => records_per_page)) do |batch|
|
18
|
-
results = batch
|
19
|
-
end
|
20
|
-
results
|
21
|
-
end
|
22
|
-
|
23
|
-
def paginate_each(options = {})
|
24
|
-
paginate_in_batches(options) do |batch|
|
25
|
-
batch.each do |record|
|
26
|
-
yield record
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def paginate_in_batches(options = {})
|
32
|
-
fail ::ArgumentError, "A block is required" unless block_given?
|
33
|
-
|
34
|
-
endpoint = options.fetch(:endpoint)
|
35
|
-
resource = options.fetch(:resource)
|
36
|
-
klass = options.fetch(:klass, self)
|
37
|
-
|
38
|
-
query_params = options.fetch(:query_params, {})
|
39
|
-
limit = options.fetch(:limit, nil)
|
40
|
-
current_page = options.fetch(:initial_page, 1)
|
41
|
-
records_per_page = options.fetch(:records_per_page, DEFAULT_RECORDS_PER_PAGE)
|
42
|
-
|
43
|
-
pagination_info_query_params = query_params.merge(:records_per_page => records_per_page)
|
44
|
-
pagination = pagination_info(endpoint, pagination_info_query_params)
|
45
|
-
total_pages = pagination["total_pages"]
|
46
|
-
total_entries = pagination["total_entries"]
|
47
|
-
# "total_pages > 1" check exists since some query_params only return 1 page
|
48
|
-
total_pages = limit / records_per_page if limit.present? && total_pages > 1
|
49
|
-
|
50
|
-
until current_page > total_pages
|
51
|
-
params = query_params.merge(:page => current_page, :records_per_page => records_per_page)
|
52
|
-
response = make_get_request(endpoint, params)
|
53
|
-
|
54
|
-
records = response[resource].map { |attributes| klass.new(attributes) }
|
55
|
-
|
56
|
-
batch = ::Atrium::PaginationBatch.new(records)
|
57
|
-
batch.total_pages = total_pages
|
58
|
-
batch.total_entries = total_entries
|
59
|
-
batch.current_page = current_page
|
60
|
-
batch.records_per_page = records_per_page
|
61
|
-
yield batch
|
62
|
-
|
63
|
-
current_page += 1
|
64
|
-
end
|
65
|
-
|
66
|
-
nil
|
67
|
-
end
|
68
|
-
|
69
|
-
def pagination_info(endpoint, query_params)
|
70
|
-
response = make_get_request(endpoint, query_params.merge(:page => 1))
|
71
|
-
response["pagination"]
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
data/lib/atrium/paginate.rb
DELETED
@@ -1,92 +0,0 @@
|
|
1
|
-
require "uri"
|
2
|
-
|
3
|
-
module Atrium
|
4
|
-
module Paginate
|
5
|
-
DEFAULT_RECORDS_PER_PAGE = 25
|
6
|
-
INITIAL_PAGE = 1
|
7
|
-
|
8
|
-
attr_accessor :current_page, :endpoint, :total_pages
|
9
|
-
|
10
|
-
def endpoint_name(query_params: nil)
|
11
|
-
@endpoint = if query_params.present?
|
12
|
-
"/" + klass_name + "?" + URI.encode_www_form(query_params) + "&"
|
13
|
-
else
|
14
|
-
"/" + klass_name + "?"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
# rubocop:disable Style/AccessorMethodName
|
19
|
-
def get_total_pages
|
20
|
-
@current_page = INITIAL_PAGE
|
21
|
-
|
22
|
-
paginated_endpoint = endpoint + "page=#{current_page}&records_per_page=#{records_per_page}"
|
23
|
-
response = ::Atrium.client.make_request(:get, paginated_endpoint)
|
24
|
-
|
25
|
-
pagination = response["pagination"]
|
26
|
-
@total_pages = pagination["total_pages"]
|
27
|
-
end
|
28
|
-
# rubocop:enable Style/AccessorMethodName
|
29
|
-
|
30
|
-
def klass_name
|
31
|
-
@klass_name ||= name.gsub("Atrium::", "").downcase.pluralize
|
32
|
-
end
|
33
|
-
|
34
|
-
def paginate_endpoint(query_params: nil, limit: nil)
|
35
|
-
endpoint_name(:query_params => query_params)
|
36
|
-
get_total_pages
|
37
|
-
response_list(:limit => limit)
|
38
|
-
end
|
39
|
-
|
40
|
-
def paginate_endpoint_in_batches(query_params: nil, limit: nil, &block)
|
41
|
-
return "method requires block to be passed" unless block_given?
|
42
|
-
|
43
|
-
endpoint_name(:query_params => query_params)
|
44
|
-
get_total_pages
|
45
|
-
response_list_in_batches(:limit => limit, &block)
|
46
|
-
end
|
47
|
-
|
48
|
-
def records_per_page
|
49
|
-
@records_per_page ||= DEFAULT_RECORDS_PER_PAGE
|
50
|
-
end
|
51
|
-
|
52
|
-
def response_list(limit: nil)
|
53
|
-
# "total_pages > 1" check exists since some query_params only return 1 page
|
54
|
-
@total_pages = limit / records_per_page if limit.present? && total_pages > 1
|
55
|
-
list = []
|
56
|
-
|
57
|
-
until current_page > total_pages
|
58
|
-
paginated_endpoint = endpoint + "page=#{current_page}&records_per_page=#{records_per_page}"
|
59
|
-
response = ::Atrium.client.make_request(:get, paginated_endpoint)
|
60
|
-
|
61
|
-
# Add new objects to the list
|
62
|
-
response[klass_name.to_s].each do |params|
|
63
|
-
list << new(params)
|
64
|
-
end
|
65
|
-
@current_page += 1
|
66
|
-
end
|
67
|
-
|
68
|
-
if limit.present?
|
69
|
-
list.first(limit)
|
70
|
-
else
|
71
|
-
list
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def response_list_in_batches(limit: nil)
|
76
|
-
# "total_pages > 1" check exists since some query_params only return 1 page
|
77
|
-
@total_pages = limit / records_per_page if limit.present? && total_pages > 1
|
78
|
-
|
79
|
-
until current_page > total_pages
|
80
|
-
paginated_endpoint = endpoint + "page=#{current_page}&records_per_page=#{records_per_page}"
|
81
|
-
response = ::Atrium.client.make_request(:get, paginated_endpoint)
|
82
|
-
list = []
|
83
|
-
|
84
|
-
response[klass_name.to_s].each do |params|
|
85
|
-
list << new(params)
|
86
|
-
end
|
87
|
-
@current_page += 1
|
88
|
-
yield list
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|