belvo 0.13.0 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f69b2401f03d00f211b1029e686b5ecb35b717bdff42dcbac781e207b2feb87
4
- data.tar.gz: f93e791acf610e5b1d3f9e3df2fd4cc161003b03d9a303ee66b5ada7c6857b5e
3
+ metadata.gz: '08f8c79b4030cd51cf761a4e158721f669b2f5cd2003d8675156f5b956f6445b'
4
+ data.tar.gz: dc16cd3cb2ae3a9c248cd596940a3c2ed6a6c1cfc992ded399afdda299b74d76
5
5
  SHA512:
6
- metadata.gz: 5e2ba29bf5d230d3f250b9dd3c284f09a01fe0dad4d05b29f6e360392258d5d6e5e93c056863345e6aeb22665fb934368e8b6ca5eac76c4e4089b8eda178d637
7
- data.tar.gz: b124c2ce6c01aed682954cc6ee9f08c6f3507c6bee994249466c9f013992b5830e7649aee52032a56f7b20e12722229c7ccf84c9c7cb26db23e742e26051c7e0
6
+ metadata.gz: 53899dee07e04a593907700009de516caafa3cd1d7a98ead7f9156382841e6569e0a1ec05ef0850bdf380f65eedf51c96c4d31b8275ec31ec1d994cde1bd1c67
7
+ data.tar.gz: 226b8b4aec7e9ae60cda79a153f70afb6252d0cec45be354e6dbfc539175e8b945be1ccc715ccef137510164cab52edb017d6f4b91113fa22e6ab70c1bb31903
@@ -11,7 +11,7 @@ jobs:
11
11
  - name: Checkout Code
12
12
  uses: actions/checkout@v2
13
13
  with:
14
- fetch-depth: 1
14
+ fetch-depth: 10
15
15
 
16
16
  # Setup ruby
17
17
  - name: Set up Ruby 2.6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- belvo (0.13.0)
4
+ belvo (0.16.0)
5
5
  faraday
6
6
  faraday_middleware
7
7
  typhoeus
@@ -9,7 +9,7 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- addressable (2.7.0)
12
+ addressable (2.8.0)
13
13
  public_suffix (>= 2.0.2, < 5.0)
14
14
  ast (2.4.1)
15
15
  claide (1.0.3)
@@ -142,4 +142,4 @@ DEPENDENCIES
142
142
  webmock
143
143
 
144
144
  BUNDLED WITH
145
- 2.1.4
145
+ 2.2.22
data/README.md CHANGED
@@ -33,31 +33,60 @@ Or install it yourself as:
33
33
 
34
34
  $ gem install belvo
35
35
 
36
- ## Usage
36
+ ## Usage (create link via widget)
37
+
38
+ When your user successfully links their account using the [Connect Widget](https://developers.belvo.com/docs/connect-widget), your implemented callback funciton will return the `link_id` required to make further API to retrieve information.
39
+
37
40
 
38
41
  ```ruby
39
42
  require 'belvo'
40
43
 
41
44
  belvo = Belvo::Client.new(
42
- 'af6e69ff-43fa-4e10-8d90-3d217309a1e5',
43
- 'gdi64m68Lc6xUjIKN3aJF2fZd51wD36lTjGVyJO5xQBfL7PRsgFef-ADXBxIhUnd',
44
- 'https://sandbox.belvo.com'
45
+ 'your-secret-id',
46
+ 'your-secret-password',
47
+ 'sandbox'
45
48
  )
46
49
 
47
50
  begin
48
- new_link = belvo.links.register(
49
- institution: 'banamex_mx_retail',
50
- username: 'janedoe',
51
- password: 'super-secret',
52
- options: { access_mode: Belvo::Link::AccessMode::SINGLE }
53
- )
51
+ # Get the link_id from the result of your widget callback function
52
+ link_id = result_from_callback_function.id
53
+
54
+ belvo.accounts.retrieve(link: link_id)
55
+
56
+ puts belvo.accounts.list
57
+ rescue Belvo::RequestError => e
58
+ puts e.status_code
59
+ puts e.detail
60
+ end
61
+ ```
62
+
63
+ ## Usage (create link via SDK)
54
64
 
55
- belvo.accounts.retrieve(link: new_link['id'])
65
+ You can also manually create the link using the SDK. However, for security purposes, we highly recommend, that you use the [Connect Widget](https://developers.belvo.com/docs/connect-widget) to create the link and follow the **Usage (create link via widget)** example.
56
66
 
57
- puts belvo.accounts.list
67
+ ```ruby
68
+ require 'belvo'
69
+
70
+ belvo = Belvo::Client.new(
71
+ 'your-secret-id',
72
+ 'your-secret-password',
73
+ 'sandbox'
74
+ )
75
+
76
+ begin
77
+ new_link = belvo.links.register( # Creating the link
78
+ institution: 'erebor_mx_retail',
79
+ username: 'janedoe',
80
+ password: 'super-secret',
81
+ options: { access_mode: Belvo::Link::AccessMode::SINGLE }
82
+ )
83
+
84
+ belvo.accounts.retrieve(link: new_link['id'])
85
+
86
+ puts belvo.accounts.list
58
87
  rescue Belvo::RequestError => e
59
- puts e.status_code
60
- puts e.detail
88
+ puts e.status_code
89
+ puts e.detail
61
90
  end
62
91
  ```
63
92
 
data/lib/belvo/options.rb CHANGED
@@ -10,7 +10,6 @@ module Belvo
10
10
  # @!attribute username2 [rw] End-user secondary username, if any
11
11
  # @!attribute username3 [rw] End-user tertiary username, if any
12
12
  # @!attribute password2 [rw] End-user secondary password, if any
13
- # @!attribute encryption_key [rw] Custom encryption key
14
13
  # @!attribute username_type [rw] Type of the username provided
15
14
  class LinkOptions < Faraday::Options.new(
16
15
  :access_mode,
@@ -18,7 +17,6 @@ module Belvo
18
17
  :username2,
19
18
  :username3,
20
19
  :password2,
21
- :encryption_key,
22
20
  :username_type,
23
21
  :certificate,
24
22
  :private_key,
@@ -30,11 +28,9 @@ module Belvo
30
28
  # Contains the configurable properties for an Account
31
29
  # @!attribute save_data [rw] Should data be persisted or not.
32
30
  # @!attribute token [rw] OTP token required by the institution
33
- # @!attribute encryption_key [rw] Custom encryption key
34
31
  class AccountOptions < Faraday::Options.new(
35
32
  :save_data,
36
- :token,
37
- :encryption_key
33
+ :token
38
34
  )
39
35
  end
40
36
 
@@ -44,12 +40,10 @@ module Belvo
44
40
  # @!attribute account [rw] Account ID (UUID)
45
41
  # @!attribute save_data [rw] Should data be persisted or not.
46
42
  # @!attribute token [rw] OTP token required by the institution
47
- # @!attribute encryption_key [rw] Custom encryption key
48
43
  class TransactionOptions < Faraday::Options.new(
49
44
  :date_to,
50
45
  :account,
51
46
  :token,
52
- :encryption_key,
53
47
  :save_data
54
48
  )
55
49
  end
@@ -58,8 +52,7 @@ module Belvo
58
52
  # Contains configurable properties of an Owner
59
53
  # @!attribute save_data [rw] Should data be persisted or not.
60
54
  # @!attribute token [rw] OTP token required by the institution
61
- # @!attribute encryption_key [rw] Custom encryption key
62
- class OwnerOptions < Faraday::Options.new(:token, :encryption_key, :save_data)
55
+ class OwnerOptions < Faraday::Options.new(:token, :save_data)
63
56
  end
64
57
 
65
58
  # @!class BalanceOptions < Faraday::Options
@@ -68,12 +61,10 @@ module Belvo
68
61
  # @!attribute account [rw] Account ID (UUID)
69
62
  # @!attribute save_data [rw] Should data be persisted or not.
70
63
  # @!attribute token [rw] OTP token required by the institution
71
- # @!attribute encryption_key [rw] Custom encryption key
72
64
  class BalanceOptions < Faraday::Options.new(
73
65
  :date_to,
74
66
  :account,
75
67
  :token,
76
- :encryption_key,
77
68
  :save_data
78
69
  )
79
70
  end
@@ -82,12 +73,10 @@ module Belvo
82
73
  # Contains configurable properties of a Statement
83
74
  # @!attribute save_data [rw] Should data be persisted or not.
84
75
  # @!attribute token [rw] OTP token required by the institution
85
- # @!attribute encryption_key [rw] Custom encryption key
86
76
  # @!attribute attach_pdf [rw] Should the PDF file be included in the
87
77
  # response or not.
88
78
  class StatementOptions < Faraday::Options.new(
89
79
  :token,
90
- :encryption_key,
91
80
  :save_data,
92
81
  :attach_pdf
93
82
  )
@@ -96,10 +85,12 @@ module Belvo
96
85
  # @!class IncomeOptions < Faraday::Options
97
86
  # Contains configurable properties of an Income
98
87
  # @!attribute save_data [rw] Should data be persisted or not.
99
- # @!attribute encryption_key [rw] Custom encryption key
88
+ # @!attribute date_from [rw] Date string (YYYY-MM-DD)
89
+ # @!attribute date_to [rw] Date string (YYYY-MM-DD)
100
90
  class IncomeOptions < Faraday::Options.new(
101
- :encryption_key,
102
- :save_data
91
+ :save_data,
92
+ :date_from,
93
+ :date_to
103
94
  )
104
95
  end
105
96
 
@@ -107,27 +98,31 @@ module Belvo
107
98
  # Contains configurable properties of an Invoice
108
99
  # @!attribute save_data [rw] Should data be persisted or not.
109
100
  # @!attribute token [rw] OTP token required by the institution
110
- # @!attribute encryption_key [rw] Custom encryption key
111
101
  # @!attribute attach_xml [rw] Should the XML file be included in the
112
102
  # response or not.
113
103
  class InvoiceOptions < Faraday::Options.new(
114
104
  :save_data,
115
105
  :token,
116
- :encryption_key,
117
106
  :attach_xml
118
107
  )
119
108
  end
120
109
 
110
+ # @!class RecurringExpensesOptions < Faraday::Options
111
+ # Contains configurable properties of a Recurring Expense
112
+ # @!attribute save_data [rw] Should data be persisted or not.
113
+ class RecurringExpensesOptions < Faraday::Options.new(
114
+ :save_data
115
+ )
116
+ end
117
+
121
118
  # @!class TaxComplianceStatusOptions < Faraday::Options
122
119
  # Contains configurable properties of a TaxComplianceStatus
123
120
  # @!attribute save_data [rw] Should data be persisted or not.
124
121
  # @!attribute token [rw] OTP token required by the institution
125
- # @!attribute encryption_key [rw] Custom encryption key
126
122
  # @!attribute attach_pdf [rw] Should the PDF file be included in the
127
123
  # response or not.
128
124
  class TaxComplianceStatusOptions < Faraday::Options.new(
129
125
  :token,
130
- :encryption_key,
131
126
  :save_data,
132
127
  :attach_pdf
133
128
  )
@@ -137,15 +132,15 @@ module Belvo
137
132
  # Contains configurable properties of a TaxReturn
138
133
  # @!attribute save_data [rw] Should data be persisted or not.
139
134
  # @!attribute token [rw] OTP token required by the institution
140
- # @!attribute encryption_key [rw] Custom encryption key
141
135
  # @!attribute attach_pdf [rw] Should the PDF file be included in the
142
136
  # response or not.
143
137
  class TaxReturnOptions < Faraday::Options.new(
144
138
  :token,
145
- :encryption_key,
146
139
  :save_data,
147
140
  :attach_pdf,
148
- :type
141
+ :type,
142
+ :date_from,
143
+ :date_to
149
144
  )
150
145
  end
151
146
 
@@ -153,12 +148,10 @@ module Belvo
153
148
  # Contains configurable properties of a TaxStatus
154
149
  # @!attribute save_data [rw] Should data be persisted or not.
155
150
  # @!attribute token [rw] OTP token required by the institution
156
- # @!attribute encryption_key [rw] Custom encryption key
157
151
  # @!attribute attach_pdf [rw] Should the PDF file be included in the
158
152
  # response or not.
159
153
  class TaxStatusOptions < Faraday::Options.new(
160
154
  :token,
161
- :encryption_key,
162
155
  :save_data,
163
156
  :attach_pdf
164
157
  )
@@ -99,7 +99,7 @@ module Belvo
99
99
  @session.post(@endpoint, body)
100
100
  end
101
101
 
102
- # Allows to change password, password2 or setting a custom encryption key
102
+ # Allows to change password, password2
103
103
  # @param id [String] Link UUID
104
104
  # @param password [String] End-user password
105
105
  # @param password2 [String, nil] End-user secondary password, if any
@@ -114,7 +114,6 @@ module Belvo
114
114
  password: password,
115
115
  password2: password2,
116
116
  token: options.token,
117
- encryption_key: options.encryption_key,
118
117
  username_type: options.username_type,
119
118
  certificate: options.certificate,
120
119
  private_key: options.private_key
@@ -172,7 +171,6 @@ module Belvo
172
171
  body = {
173
172
  link: link,
174
173
  token: options.token,
175
- encryption_key: options.encryption_key,
176
174
  save_data: options.save_data || true
177
175
  }.merge(options)
178
176
  body = clean body: body
@@ -203,7 +201,6 @@ module Belvo
203
201
  date_to: date_to,
204
202
  token: options.token,
205
203
  account: options.account,
206
- encryption_key: options.encryption_key,
207
204
  save_data: options.save_data || true
208
205
  }.merge(options)
209
206
  body = clean body: body
@@ -229,7 +226,6 @@ module Belvo
229
226
  body = {
230
227
  link: link,
231
228
  token: options.token,
232
- encryption_key: options.encryption_key,
233
229
  save_data: options.save_data || true
234
230
  }.merge(options)
235
231
  body = clean body: body
@@ -260,7 +256,6 @@ module Belvo
260
256
  date_to: date_to,
261
257
  token: options.token,
262
258
  account: options.account,
263
- encryption_key: options.encryption_key,
264
259
  save_data: options.save_data || true
265
260
  }.merge(options)
266
261
  body = clean body: body
@@ -290,7 +285,6 @@ module Belvo
290
285
  year: year,
291
286
  month: month,
292
287
  token: options.token,
293
- encryption_key: options.encryption_key,
294
288
  save_data: options.save_data || true,
295
289
  attach_pdf: options.attach_pdf
296
290
  }.merge(options)
@@ -315,8 +309,9 @@ module Belvo
315
309
  options = IncomeOptions.from(options)
316
310
  body = {
317
311
  link: link,
318
- encryption_key: options.encryption_key,
319
- save_data: options.save_data || true
312
+ save_data: options.save_data || true,
313
+ date_from: options.date_from,
314
+ date_to: options.date_to
320
315
  }.merge(options)
321
316
  body = clean body: body
322
317
  @session.post(@endpoint, body)
@@ -346,7 +341,6 @@ module Belvo
346
341
  date_to: date_to,
347
342
  type: type,
348
343
  token: options.token,
349
- encryption_key: options.encryption_key,
350
344
  save_data: options.save_data || true,
351
345
  attach_xml: options.attach_xml
352
346
  }.merge(options)
@@ -355,6 +349,30 @@ module Belvo
355
349
  end
356
350
  end
357
351
 
352
+ # Recurring Expenses contain a resume of one year
353
+ # of Transactions inside an Account.
354
+ class RecurringExpenses < Resource
355
+ def initialize(session)
356
+ super(session)
357
+ @endpoint = 'recurring-expenses/'
358
+ end
359
+
360
+ # Retrieve recurring expenses information from a specific banking link
361
+ # @param link [String] Link UUID
362
+ # @param options [RecurringExpensesOptions] Configurable properties
363
+ # @return [Hash] created incomes details
364
+ # @raise [RequestError] If response code is different than 2XX
365
+ def retrieve(link:, options: nil)
366
+ options = RecurringExpensesOptions.from(options)
367
+ body = {
368
+ link: link,
369
+ save_data: options.save_data || true
370
+ }.merge(options)
371
+ body = clean body: body
372
+ @session.post(@endpoint, body)
373
+ end
374
+ end
375
+
358
376
  # A Tax compliance status is the representation of the tax situation
359
377
  # of a person or a business to the tax authority in the country.
360
378
  class TaxComplianceStatus < Resource
@@ -373,7 +391,6 @@ module Belvo
373
391
  body = {
374
392
  link: link,
375
393
  token: options.token,
376
- encryption_key: options.encryption_key,
377
394
  save_data: options.save_data || true,
378
395
  attach_pdf: options.attach_pdf
379
396
  }.merge(options)
@@ -402,8 +419,8 @@ module Belvo
402
419
 
403
420
  # Retrieve tax returns information from a specific fiscal link.
404
421
  # @param link [String] Link UUID
405
- # @param year_from [Integer] | [Date]
406
- # @param year_to [Integer] | [Date]
422
+ # @param year_from [Integer]
423
+ # @param year_to [Integer]
407
424
  # @param options [TaxReturnOptions] Configurable properties
408
425
  # @return [Hash] created tax returns details
409
426
  # @raise [RequestError] If response code is different than 2XX
@@ -412,14 +429,13 @@ module Belvo
412
429
  body = {
413
430
  link: link,
414
431
  token: options.token,
415
- encryption_key: options.encryption_key,
416
432
  save_data: options.save_data || true,
417
433
  attach_pdf: options.attach_pdf,
418
434
  type: options.type
419
435
  }.merge(options)
420
436
  if options.type == TaxReturnType::MONTHLY
421
- body[:date_from] = year_from
422
- body[:date_to] = year_to
437
+ body[:date_from] = options.date_from
438
+ body[:date_to] = options.date_to
423
439
  else
424
440
  body[:year_from] = year_from
425
441
  body[:year_to] = year_to
@@ -451,7 +467,6 @@ module Belvo
451
467
  body = {
452
468
  link: link,
453
469
  token: options.token,
454
- encryption_key: options.encryption_key,
455
470
  save_data: options.save_data || true,
456
471
  attach_pdf: options.attach_pdf
457
472
  }.merge(options)
data/lib/belvo/utils.rb CHANGED
@@ -11,3 +11,19 @@ class Utils
11
11
  Base64.encode64(data)
12
12
  end
13
13
  end
14
+
15
+ # Class to get the api url given an environment name
16
+ class Environment
17
+ SANDBOX = 'https://sandbox.belvo.com'
18
+ DEVELOPMENT = 'https://development.belvo.com'
19
+ PRODUCTION = 'https://api.belvo.com'
20
+
21
+ def self.get_url(environment)
22
+ nil unless environment
23
+ begin
24
+ const_get environment.upcase
25
+ rescue NameError
26
+ environment
27
+ end
28
+ end
29
+ end
data/lib/belvo/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Belvo
4
4
  # belvo-ruby current version
5
- VERSION = '0.13.0'
5
+ VERSION = '0.16.0'
6
6
  end
data/lib/belvo.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require 'belvo/http'
4
4
  require 'belvo/exceptions'
5
5
  require 'belvo/resources'
6
+ require 'belvo/utils'
6
7
 
7
8
  module Belvo
8
9
  # Allows easy access to Belvo API servers.
@@ -18,7 +19,11 @@ module Belvo
18
19
  # @return [APISession] Authenticated Belvo API session
19
20
  def initialize(secret_key_id, secret_key_password, url = nil)
20
21
  (belvo_api_url = url) || ENV['BELVO_API_URL']
21
- raise BelvoAPIError, 'You need to provide a URL.' if belvo_api_url.nil?
22
+ belvo_api_url = Environment.get_url(belvo_api_url)
23
+
24
+ if belvo_api_url.nil?
25
+ raise BelvoAPIError, 'You need to provide a URL or a valid environment.'
26
+ end
22
27
 
23
28
  @session = Belvo::APISession.new(belvo_api_url)
24
29
 
@@ -75,6 +80,12 @@ module Belvo
75
80
  @invoices = Invoice.new @session
76
81
  end
77
82
 
83
+ # Provides access to RecurringExpenses resource
84
+ # @return [RecurringExpense]
85
+ def recurring_expenses
86
+ @recurring_expenses = RecurringExpenses.new @session
87
+ end
88
+
78
89
  # Provides access to TaxComplianceStatus resource
79
90
  # @return [TaxComplianceStatus]
80
91
  def tax_compliance_status
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: belvo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Belvo Finance S.L.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-23 00:00:00.000000000 Z
11
+ date: 2021-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday