bridgeapi_client 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/.env.example +2 -0
  3. data/.github/workflows/ci-analysis.yml +24 -0
  4. data/.github/workflows/rubocop-analysis.yml +24 -0
  5. data/.gitignore +11 -0
  6. data/.rspec +3 -0
  7. data/.rubocop.yml +50 -0
  8. data/CHANGELOG.md +24 -0
  9. data/Gemfile +23 -0
  10. data/Gemfile.lock +186 -0
  11. data/LICENSE.txt +21 -0
  12. data/README.md +229 -0
  13. data/Rakefile +12 -0
  14. data/bin/bundle +114 -0
  15. data/bin/coderay +27 -0
  16. data/bin/console +21 -0
  17. data/bin/htmldiff +27 -0
  18. data/bin/ldiff +27 -0
  19. data/bin/pry +27 -0
  20. data/bin/racc +27 -0
  21. data/bin/rake +27 -0
  22. data/bin/rspec +27 -0
  23. data/bin/rubocop +27 -0
  24. data/bin/ruby-parse +27 -0
  25. data/bin/ruby-rewrite +27 -0
  26. data/bin/setup +8 -0
  27. data/bridge_api.gemspec +40 -0
  28. data/lib/bridge_api/account.rb +46 -0
  29. data/lib/bridge_api/api/client.rb +206 -0
  30. data/lib/bridge_api/api/error.rb +48 -0
  31. data/lib/bridge_api/api/resource.rb +25 -0
  32. data/lib/bridge_api/authorization.rb +44 -0
  33. data/lib/bridge_api/bank.rb +18 -0
  34. data/lib/bridge_api/bridge_object.rb +120 -0
  35. data/lib/bridge_api/category.rb +39 -0
  36. data/lib/bridge_api/configuration.rb +38 -0
  37. data/lib/bridge_api/connect.rb +59 -0
  38. data/lib/bridge_api/insight.rb +27 -0
  39. data/lib/bridge_api/item.rb +91 -0
  40. data/lib/bridge_api/object_types.rb +28 -0
  41. data/lib/bridge_api/payment.rb +260 -0
  42. data/lib/bridge_api/provider.rb +40 -0
  43. data/lib/bridge_api/resources.rb +15 -0
  44. data/lib/bridge_api/stock.rb +45 -0
  45. data/lib/bridge_api/transaction.rb +79 -0
  46. data/lib/bridge_api/transfer.rb +42 -0
  47. data/lib/bridge_api/user.rb +98 -0
  48. data/lib/bridge_api/version.rb +5 -0
  49. data/lib/bridge_api.rb +22 -0
  50. data/lib/bridgeapi_client.rb +3 -0
  51. metadata +97 -0
@@ -0,0 +1,91 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BridgeApi
4
+ #
5
+ # Item resource (bank connector)
6
+ #
7
+ class Item < BridgeObject
8
+ RESOURCE_TYPE = "item"
9
+
10
+ # TODO: Add support of item statuses
11
+
12
+ class << self
13
+ include API::Resource
14
+
15
+ #
16
+ # List all logged in user items
17
+ #
18
+ # @param [String] access_token the access token provided during the user authentication
19
+ # @param [Hash] params any params that might be required (or optional) to communicate with the API
20
+ #
21
+ # @return [Array<Item>] the user items
22
+ #
23
+ def list(access_token:, **params)
24
+ protected_resource(access_token) do
25
+ data = api_client.get("/v3/aggregation/items", **params)
26
+ convert_to_bridge_object(**data)
27
+ end
28
+ end
29
+
30
+ #
31
+ # Retrieve a single item for logged in user
32
+ #
33
+ # @param [Integer] id the id of the requested resource
34
+ # @param [String] access_token the access token provided during the user authentication
35
+ # @param [Hash] params any params that might be required (or optional) to communicate with the API
36
+ #
37
+ # @return [Account] the requested user item
38
+ #
39
+ def find(id:, access_token:, **params)
40
+ protected_resource(access_token) do
41
+ data = api_client.get("/v3/aggregation/items/#{id}", **params)
42
+ convert_to_bridge_object(**data)
43
+ end
44
+ end
45
+
46
+ #
47
+ # Trigger a refresh for a specific item
48
+ #
49
+ # @param [Integer] id the id of the requested resource
50
+ # @param [String] access_token the access token provided during the user authentication
51
+ # @param [Hash] params any params that might be required (or optional) to communicate with the API
52
+ #
53
+ # @return [BridgeObject] the item refresh status path
54
+ #
55
+ def refresh(id:, access_token:, **params)
56
+ warn "BridgeApi::Item.refresh is deprecated."
57
+ super
58
+ end
59
+
60
+ #
61
+ # Request the refresh status of a specific item
62
+ #
63
+ # @param [Integer] id the id of the requested resource
64
+ # @param [String] access_token the access token provided during the user authentication
65
+ # @param [Hash] params any params that might be required (or optional) to communicate with the API
66
+ #
67
+ # @return [BridgeObject] the user item refresh status
68
+ #
69
+ def refresh_status(id:, access_token:, **params)
70
+ warn "BridgeApi::Item.refresh_status is deprecated."
71
+ super
72
+ end
73
+
74
+ #
75
+ # Delete a specific item
76
+ #
77
+ # @param [Integer] id the id of the requested resource
78
+ # @param [String] access_token the access token provided during the user authentication
79
+ # @param [Hash] params any params that might be required (or optional) to communicate with the API
80
+ #
81
+ # @return [Boolean] the request success status
82
+ #
83
+ def delete(id:, access_token:, **params)
84
+ protected_resource(access_token) do
85
+ api_client.delete("/v3/aggregation/items/#{id}", **params)
86
+ true
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BridgeApi
4
+ #
5
+ # Supported resources types
6
+ #
7
+ module ObjectTypes
8
+ #
9
+ # Matches API resources with corresponding gem classes
10
+ #
11
+ # @return [Account, Bank, Category, Item, Stock, Transaction, Transfer, User, nil] the matched resource or nil
12
+ #
13
+ def self.resource_types_to_classes
14
+ {
15
+ Account::RESOURCE_TYPE => Account,
16
+ Bank::RESOURCE_TYPE => Bank,
17
+ Provider::RESOURCE_TYPE => Provider,
18
+ Category::RESOURCE_TYPE => Category,
19
+ Item::RESOURCE_TYPE => Item,
20
+ Stock::RESOURCE_TYPE => Stock,
21
+ Transaction::RESOURCE_TYPE => Transaction,
22
+ Transfer::RESOURCE_TYPE => Transfer,
23
+ Payment::RESOURCE_TYPE => Payment,
24
+ User::RESOURCE_TYPE => User
25
+ }
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,260 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BridgeApi
4
+ #
5
+ # Payment resource
6
+ #
7
+ class Payment < BridgeObject
8
+ RESOURCE_TYPE = "payment"
9
+
10
+ class << self
11
+ include API::Resource
12
+
13
+ #
14
+ # Payment Links
15
+ #
16
+
17
+ #
18
+ # Create a new payment link
19
+ #
20
+ # @param [String] access_token the access token provided during the user authentication
21
+ # @param [Hash] params any params that might be required (or optional) to communicate with the API
22
+ #
23
+ # @return [BridgeObject] the created payment link
24
+ #
25
+ def create_payment_link(access_token:, **params)
26
+ protected_resource(access_token) do
27
+ data = api_client.post("/v3/payment/payment-links", **params)
28
+ convert_to_bridge_object(**data)
29
+ end
30
+ end
31
+
32
+ #
33
+ # List all payment links
34
+ #
35
+ # @param [String] access_token the access token provided during the user authentication
36
+ # @param [Hash] params any params that might be required (or optional) to communicate with the API
37
+ #
38
+ # @return [Array<BridgeObject>] the list of payment links
39
+ #
40
+ def list_payment_links(access_token:, **params)
41
+ protected_resource(access_token) do
42
+ data = api_client.get("/v3/payment/payment-links", **params)
43
+ convert_to_bridge_object(**data)
44
+ end
45
+ end
46
+
47
+ #
48
+ # Get a single payment link
49
+ #
50
+ # @param [String] id the id of the payment link
51
+ # @param [String] access_token the access token provided during the user authentication
52
+ # @param [Hash] params any params that might be required (or optional) to communicate with the API
53
+ #
54
+ # @return [BridgeObject] the requested payment link
55
+ #
56
+ def get_payment_link(id:, access_token:, **params)
57
+ protected_resource(access_token) do
58
+ data = api_client.get("/v3/payment/payment-links/#{id}", **params)
59
+ convert_to_bridge_object(**data)
60
+ end
61
+ end
62
+
63
+ #
64
+ # Revoke a payment link
65
+ #
66
+ # @param [String] id the id of the payment link
67
+ # @param [String] access_token the access token provided during the user authentication
68
+ # @param [Hash] params any params that might be required (or optional) to communicate with the API
69
+ #
70
+ # @return [BridgeObject] the revoked payment link
71
+ #
72
+ def revoke_payment_link(id:, access_token:, **params)
73
+ protected_resource(access_token) do
74
+ data = api_client.post("/v3/payment/payment-links/#{id}/revoke", **params)
75
+ convert_to_bridge_object(**data)
76
+ end
77
+ end
78
+
79
+ #
80
+ # Payment Requests
81
+ #
82
+
83
+ #
84
+ # Create a new payment request
85
+ #
86
+ # @param [String] access_token the access token provided during the user authentication
87
+ # @param [Hash] params any params that might be required (or optional) to communicate with the API
88
+ #
89
+ # @return [BridgeObject] the created payment request
90
+ #
91
+ def create_payment_request(access_token:, **params)
92
+ protected_resource(access_token) do
93
+ data = api_client.post("/v3/payment/payment-requests", **params)
94
+ convert_to_bridge_object(**data)
95
+ end
96
+ end
97
+
98
+ #
99
+ # List all payment requests
100
+ #
101
+ # @param [String] access_token the access token provided during the user authentication
102
+ # @param [Hash] params any params that might be required (or optional) to communicate with the API
103
+ #
104
+ # @return [Array<BridgeObject>] the list of payment requests
105
+ #
106
+ def list_payment_requests(access_token:, **params)
107
+ protected_resource(access_token) do
108
+ data = api_client.get("/v3/payment/payment-requests", **params)
109
+ convert_to_bridge_object(**data)
110
+ end
111
+ end
112
+
113
+ #
114
+ # Get a single payment request
115
+ #
116
+ # @param [String] id the id of the payment request
117
+ # @param [String] access_token the access token provided during the user authentication
118
+ # @param [Hash] params any params that might be required (or optional) to communicate with the API
119
+ #
120
+ # @return [BridgeObject] the requested payment request
121
+ #
122
+ def get_payment_request(id:, access_token:, **params)
123
+ protected_resource(access_token) do
124
+ data = api_client.get("/v3/payment/payment-requests/#{id}", **params)
125
+ convert_to_bridge_object(**data)
126
+ end
127
+ end
128
+
129
+ #
130
+ # Payment Consents
131
+ #
132
+
133
+ #
134
+ # Create a payment consent
135
+ #
136
+ # @param [String] access_token the access token provided during the user authentication
137
+ # @param [Hash] params any params that might be required (or optional) to communicate with the API
138
+ #
139
+ # @return [BridgeObject] the created payment consent
140
+ #
141
+ def create_payment_consent(access_token:, **params)
142
+ protected_resource(access_token) do
143
+ data = api_client.post("/v3/payment/consents", **params)
144
+ convert_to_bridge_object(**data)
145
+ end
146
+ end
147
+
148
+ #
149
+ # Payment Account
150
+ #
151
+
152
+ #
153
+ # Create a refund
154
+ #
155
+ # @param [String] access_token the access token provided during the user authentication
156
+ # @param [Hash] params any params that might be required (or optional) to communicate with the API
157
+ #
158
+ # @return [BridgeObject] the created refund
159
+ #
160
+ def create_refund(access_token:, **params)
161
+ protected_resource(access_token) do
162
+ data = api_client.post("/v3/payment/refunds", **params)
163
+ convert_to_bridge_object(**data)
164
+ end
165
+ end
166
+
167
+ #
168
+ # List refunds
169
+ #
170
+ # @param [String] access_token the access token provided during the user authentication
171
+ # @param [Hash] params any params that might be required (or optional) to communicate with the API
172
+ #
173
+ # @return [Array<BridgeObject>] the list of refunds
174
+ #
175
+ def list_refunds(access_token:, **params)
176
+ protected_resource(access_token) do
177
+ data = api_client.get("/v3/payment/refunds", **params)
178
+ convert_to_bridge_object(**data)
179
+ end
180
+ end
181
+
182
+ #
183
+ # Get a single refund
184
+ #
185
+ # @param [String] id the id of the refund
186
+ # @param [String] access_token the access token provided during the user authentication
187
+ # @param [Hash] params any params that might be required (or optional) to communicate with the API
188
+ #
189
+ # @return [BridgeObject] the requested refund
190
+ #
191
+ def get_refund(id:, access_token:, **params)
192
+ protected_resource(access_token) do
193
+ data = api_client.get("/v3/payment/refunds/#{id}", **params)
194
+ convert_to_bridge_object(**data)
195
+ end
196
+ end
197
+
198
+ #
199
+ # List beneficiaries
200
+ #
201
+ # @param [String] access_token the access token provided during the user authentication
202
+ # @param [Hash] params any params that might be required (or optional) to communicate with the API
203
+ #
204
+ # @return [Array<BridgeObject>] the list of beneficiaries
205
+ #
206
+ def list_beneficiaries(access_token:, **params)
207
+ protected_resource(access_token) do
208
+ data = api_client.get("/v3/payment/beneficiaries", **params)
209
+ convert_to_bridge_object(**data)
210
+ end
211
+ end
212
+
213
+ #
214
+ # Create a payout
215
+ #
216
+ # @param [String] access_token the access token provided during the user authentication
217
+ # @param [Hash] params any params that might be required (or optional) to communicate with the API
218
+ #
219
+ # @return [BridgeObject] the created payout
220
+ #
221
+ def create_payout(access_token:, **params)
222
+ protected_resource(access_token) do
223
+ data = api_client.post("/v3/payment/payouts", **params)
224
+ convert_to_bridge_object(**data)
225
+ end
226
+ end
227
+
228
+ #
229
+ # List payouts
230
+ #
231
+ # @param [String] access_token the access token provided during the user authentication
232
+ # @param [Hash] params any params that might be required (or optional) to communicate with the API
233
+ #
234
+ # @return [Array<BridgeObject>] the list of payouts
235
+ #
236
+ def list_payouts(access_token:, **params)
237
+ protected_resource(access_token) do
238
+ data = api_client.get("/v3/payment/payouts", **params)
239
+ convert_to_bridge_object(**data)
240
+ end
241
+ end
242
+
243
+ #
244
+ # Get a single payout
245
+ #
246
+ # @param [String] id the id of the payout
247
+ # @param [String] access_token the access token provided during the user authentication
248
+ # @param [Hash] params any params that might be required (or optional) to communicate with the API
249
+ #
250
+ # @return [BridgeObject] the requested payout
251
+ #
252
+ def get_payout(id:, access_token:, **params)
253
+ protected_resource(access_token) do
254
+ data = api_client.get("/v3/payment/payouts/#{id}", **params)
255
+ convert_to_bridge_object(**data)
256
+ end
257
+ end
258
+ end
259
+ end
260
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BridgeApi
4
+ #
5
+ # Provider resource (formerly Bank)
6
+ #
7
+ class Provider < BridgeObject
8
+ RESOURCE_TYPE = "provider"
9
+
10
+ class << self
11
+ include API::Resource
12
+
13
+ #
14
+ # List all providers supported by the Bridge API
15
+ #
16
+ # @param [Hash] params any params that might be required (or optional) to communicate with the API
17
+ #
18
+ # @return [Array<Provider>] the supported providers list
19
+ #
20
+ def list(**params)
21
+ data = api_client.get("/v3/providers", **params)
22
+ convert_to_bridge_object(**data)
23
+ end
24
+
25
+ #
26
+ # Retrieve a single provider
27
+ #
28
+ # @param [Integer] id the id of the requested resource
29
+ # @param [Hash] params any params that might be required (or optional) to communicate with the API
30
+ #
31
+ # @return [Provider] the requested provider
32
+ #
33
+ def find(id:, **params)
34
+ data = api_client.get("/v3/providers/#{id}", **params)
35
+ convert_to_bridge_object(**data)
36
+ end
37
+ end
38
+ end
39
+ end
40
+
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bridge_api/authorization"
4
+ require "bridge_api/account"
5
+ require "bridge_api/category"
6
+ require "bridge_api/stock"
7
+ require "bridge_api/provider"
8
+ require "bridge_api/bank"
9
+ require "bridge_api/user"
10
+ require "bridge_api/connect"
11
+ require "bridge_api/item"
12
+ require "bridge_api/transaction"
13
+ require "bridge_api/payment"
14
+ require "bridge_api/transfer"
15
+ require "bridge_api/insight"
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BridgeApi
4
+ #
5
+ # Stock resource
6
+ #
7
+ class Stock < BridgeObject
8
+ RESOURCE_TYPE = "stock"
9
+
10
+ class << self
11
+ include API::Resource
12
+
13
+ #
14
+ # List all logged in user stocks
15
+ #
16
+ # @param [String] access_token the access token provided during the user authentication
17
+ # @param [Hash] params any params that might be required (or optional) to communicate with the API
18
+ #
19
+ # @return [Array<Stock>] the user accounts
20
+ #
21
+ def list(access_token:, **params)
22
+ protected_resource(access_token) do
23
+ data = api_client.get("/v3/aggregation/stocks", **params)
24
+ convert_to_bridge_object(**data)
25
+ end
26
+ end
27
+
28
+ #
29
+ # Retrieve a single stock for logged in user
30
+ #
31
+ # @param [Integer] id the id of the requested resource
32
+ # @param [String] access_token the access token provided during the user authentication
33
+ # @param [Hash] params any params that might be required (or optional) to communicate with the API
34
+ #
35
+ # @return [Account] the user accounts
36
+ #
37
+ def find(id:, access_token:, **params)
38
+ protected_resource(access_token) do
39
+ data = api_client.get("/v3/aggregation/stocks/#{id}", **params)
40
+ convert_to_bridge_object(**data)
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BridgeApi
4
+ #
5
+ # Transaction resource
6
+ #
7
+ class Transaction < BridgeObject
8
+ RESOURCE_TYPE = "transaction"
9
+
10
+ class << self
11
+ include API::Resource
12
+
13
+ #
14
+ # List all logged in user transactions
15
+ #
16
+ # @param [String] access_token the access token provided during the user authentication
17
+ # @param [Hash] params any params that might be required (or optional) to communicate with the API
18
+ #
19
+ # @return [Array<Transaction>] the user transactions
20
+ #
21
+ def list(access_token:, **params)
22
+ protected_resource(access_token) do
23
+ data = api_client.get("/v3/aggregation/transactions", **params)
24
+ convert_to_bridge_object(**data)
25
+ end
26
+ end
27
+
28
+ #
29
+ # Retrieve a single transaction for logged in user
30
+ #
31
+ # @param [Integer] id the id of the requested resource
32
+ # @param [String] access_token the access token provided during the user authentication
33
+ # @param [Hash] params any params that might be required (or optional) to communicate with the API
34
+ #
35
+ # @return [Transaction] the requested transaction
36
+ #
37
+ def find(id:, access_token:, **params)
38
+ protected_resource(access_token) do
39
+ data = api_client.get("/v3/aggregation/transactions/#{id}", **params)
40
+ convert_to_bridge_object(**data)
41
+ end
42
+ end
43
+
44
+ #
45
+ # List all logged in user transactions for a specific account
46
+ #
47
+ # @param [Integer] account_id the account id
48
+ # @param [String] access_token the access token provided during the user authentication
49
+ # @param [Hash] params any params that might be required (or optional) to communicate with the API
50
+ #
51
+ # @return [Array<Transaction>] the user transactions for the account
52
+ #
53
+ def list_by_account(account_id:, access_token:, **params)
54
+ protected_resource(access_token) do
55
+ params[:account_ids] = account_id
56
+ data = api_client.get("/v3/aggregation/transactions", **params)
57
+ convert_to_bridge_object(**data)
58
+ end
59
+ end
60
+
61
+ # Deprecated methods
62
+
63
+ def list_updated(access_token:, **params)
64
+ warn "BridgeApi::Transaction.list_updated is deprecated. Use BridgeApi::Transaction.list with since parameter instead."
65
+ list(access_token: access_token, **params)
66
+ end
67
+
68
+ def list_updated_by_account(account_id:, access_token:, **params)
69
+ warn "BridgeApi::Transaction.list_updated_by_account is deprecated. Use BridgeApi::Transaction.list_by_account with since parameter instead."
70
+ list_by_account(account_id: account_id, access_token: access_token, **params)
71
+ end
72
+
73
+ def list_by_iban(access_token:, **params)
74
+ warn "BridgeApi::Transaction.list_by_iban is deprecated. Use BridgeApi::Transaction.list with filters instead."
75
+ list(access_token: access_token, **params)
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BridgeApi
4
+ #
5
+ # Transfer resource is deprecated, use Payment instead
6
+ #
7
+ class Transfer < Payment
8
+ RESOURCE_TYPE = "transfert"
9
+
10
+ class << self
11
+ def send(access_token:, **params)
12
+ warn "BridgeApi::Transfer.send is deprecated. Use BridgeApi::Payment.create_payment_link instead."
13
+ create_payment_link(access_token: access_token, **params)
14
+ end
15
+
16
+ def list(access_token:, **params)
17
+ warn "BridgeApi::Transfer.list is deprecated. Use BridgeApi::Payment.list_payment_requests instead."
18
+ list_payment_requests(access_token: access_token, **params)
19
+ end
20
+
21
+ def find(uuid:, access_token:, **params)
22
+ warn "BridgeApi::Transfer.find is deprecated. Use BridgeApi::Payment.get_payment_request instead."
23
+ get_payment_request(id: uuid, access_token: access_token, **params)
24
+ end
25
+
26
+ def list_all_sender_accounts(access_token:, **params)
27
+ warn "BridgeApi::Transfer.list_all_sender_accounts is deprecated."
28
+ {}
29
+ end
30
+
31
+ def list_all_receiver_accounts(access_token:, **params)
32
+ warn "BridgeApi::Transfer.list_all_receiver_accounts is deprecated. Use BridgeApi::Payment.list_beneficiaries instead."
33
+ list_beneficiaries(access_token: access_token, **params)
34
+ end
35
+
36
+ def list_receiver_accounts_for_sender(sender_account_id:, access_token:, **params)
37
+ warn "BridgeApi::Transfer.list_receiver_accounts_for_sender is deprecated. Use BridgeApi::Payment.list_beneficiaries instead."
38
+ list_beneficiaries(access_token: access_token, **params)
39
+ end
40
+ end
41
+ end
42
+ end