belvo 0.12.0 → 0.15.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d3ccb9e6a9841f2313f4a3307a67c3a0527fad92b91f3a84a607150b2bd86dd8
4
- data.tar.gz: 1103d2e823428b7a1db97821714bd60764cd0c649d59c1876b309cf2f20e0b8d
3
+ metadata.gz: 6b7f8335b754a94a4223c81da12e6968e3dfe266a39e3b20e10f2d20a129a3dc
4
+ data.tar.gz: 1ac5dc601938bd343f480c391f3951b6e1e8cc2261397c38c540094b6bd78428
5
5
  SHA512:
6
- metadata.gz: f95143ddfe260d93a6462c70e224df80dd43d2c0a76db8c38b8176d0471643fd22de8db22e2f7299d527dd4c7f56842b3c19045a5d2482c9dfc0a0cdaa4b6566
7
- data.tar.gz: 85ac380d5e207a78915c4a84c21d2efaf03c76f525e49080a5ef9192931b39b1e983df207e8e614cbdc5c4dcf7c0ca2c69cd64cb403839cb5f1c459b572db658
6
+ metadata.gz: 683c82016ad8b0c264d3c76b9559a432986a639645416f6ee82ff7925810c0a004325ddc880841ff6a4f140a268e6b01863a1a395bf1d790f34b43391871e89d
7
+ data.tar.gz: a4072bb4ffe6d220deefddcebdef857e0e9c9d06cdd0f6255520b5bbea72223e9a4451c0f93c5dbfc4485c9e2f9dbc43723d5916cd304fd63e02e97225310dd8
@@ -0,0 +1,48 @@
1
+ name: Run Danger
2
+
3
+ on: [pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ name: Run Danger
8
+ runs-on: ubuntu-latest
9
+
10
+ steps:
11
+ - name: Checkout Code
12
+ uses: actions/checkout@v2
13
+ with:
14
+ fetch-depth: 10
15
+
16
+ # Setup ruby
17
+ - name: Set up Ruby 2.6
18
+ uses: actions/setup-ruby@v1
19
+ with:
20
+ ruby-version: 2.6
21
+
22
+ # Install the right bundler version
23
+ - name: Install bundler
24
+ run: gem install bundler
25
+
26
+ # Cache dependencies
27
+ - name: Cache ruby dependencies
28
+ id: cache-ruby
29
+ uses: actions/cache@v2
30
+ with:
31
+ path: vendor/bundle
32
+ key: union-gems-${{ hashFiles('**/Gemfile.lock') }}
33
+ restore-keys: |
34
+ union-gems-
35
+ # Install dependencies on cache miss
36
+ - name: Install ruby dependencies
37
+ if: steps.cache-ruby.outputs.cache-hit != 'true'
38
+ run: |
39
+ bundle config path vendor/bundle
40
+ bundle install --jobs 4 --retry 3 --without=documentation
41
+ # Run danger
42
+ - name: Run danger
43
+ env:
44
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45
+ run: |
46
+ bundle config path vendor/bundle
47
+ bundle exec danger
48
+
data/Dangerfile ADDED
@@ -0,0 +1,21 @@
1
+ # rubocop:disable all
2
+ # Mainly to encourage writing up some reasoning about the PR, rather than
3
+ # just leaving a title
4
+ fail "Please provide a short summary in the PR description :page_with_curl:" if github.pr_body.length < 10
5
+
6
+ # The title should include the correct prefix tag
7
+ if !github.pr_title.match(/^\[(?:Fixed|Added|Changed|Removed|Security|Other)\]/)
8
+ fail "Please provide a valid PR title label: [Added]/[Fixed]/[Changed]/[Removed]/[Security]/[Other]"
9
+ end
10
+
11
+ # The title should include the JIRA ticket unless is a dependabot PR
12
+ if github.pr_labels.include?("dependencies")
13
+ message ("PR autogenerated by dependabot")
14
+ elsif !github.pr_title.match(/^\[.*\]\s?\[BEL-\d+\]/)
15
+ fail "Please provide a valid Jira ticket ID associated to this PR: [BEL-XXXX]. If you do not have any associated Jira ticket, just use [BEL-XXXX]"
16
+ end
17
+
18
+ warn("PR is classed as Work in Progress", sticky: false) if github.pr_title.include? "[WIP]"
19
+
20
+ message("One approval required for merging :smiley_cat: :smiley_cat:")
21
+ # rubocop:enable all
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
+ # rubocop:disable all
1
2
  # frozen_string_literal: true
2
3
 
3
4
  source 'https://rubygems.org'
@@ -13,4 +14,6 @@ gem 'rspec', '~> 3.0'
13
14
  gem 'rubocop', '~> 0.81.0', require: false
14
15
  gem 'rubocop-rspec', require: false
15
16
  gem 'typhoeus'
17
+ gem 'danger', '8.2.1'
16
18
  gem 'webmock'
19
+ # rubocop:enable all
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- belvo (0.12.0)
4
+ belvo (0.15.0)
5
5
  faraday
6
6
  faraday_middleware
7
7
  typhoeus
@@ -9,9 +9,17 @@ 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
+ claide (1.0.3)
16
+ claide-plugins (0.9.2)
17
+ cork
18
+ nap
19
+ open4 (~> 1.3)
20
+ colored2 (3.1.2)
21
+ cork (0.3.0)
22
+ colored2 (~> 3.1)
15
23
  coveralls (0.8.23)
16
24
  json (>= 1.8, < 3)
17
25
  simplecov (~> 0.16.1)
@@ -19,6 +27,19 @@ GEM
19
27
  thor (>= 0.19.4, < 2.0)
20
28
  tins (~> 1.6)
21
29
  crack (0.4.4)
30
+ danger (8.2.1)
31
+ claide (~> 1.0)
32
+ claide-plugins (>= 0.9.2)
33
+ colored2 (~> 3.1)
34
+ cork (~> 0.1)
35
+ faraday (>= 0.9.0, < 2.0)
36
+ faraday-http-cache (~> 2.0)
37
+ git (~> 1.7)
38
+ kramdown (~> 2.3)
39
+ kramdown-parser-gfm (~> 1.0)
40
+ no_proxy_fix
41
+ octokit (~> 4.7)
42
+ terminal-table (~> 1)
22
43
  diff-lcs (1.4.4)
23
44
  docile (1.3.2)
24
45
  ethon (0.12.0)
@@ -26,19 +47,34 @@ GEM
26
47
  faraday (1.1.0)
27
48
  multipart-post (>= 1.2, < 3)
28
49
  ruby2_keywords
50
+ faraday-http-cache (2.2.0)
51
+ faraday (>= 0.8)
29
52
  faraday_middleware (1.0.0)
30
53
  faraday (~> 1.0)
31
54
  ffi (1.13.1)
55
+ git (1.8.1)
56
+ rchardet (~> 1.8)
32
57
  hashdiff (1.0.1)
33
58
  jaro_winkler (1.5.4)
34
59
  json (2.3.1)
60
+ kramdown (2.3.1)
61
+ rexml
62
+ kramdown-parser-gfm (1.1.0)
63
+ kramdown (~> 2.0)
35
64
  multipart-post (2.1.1)
65
+ nap (1.1.0)
66
+ no_proxy_fix (0.1.2)
67
+ octokit (4.21.0)
68
+ faraday (>= 0.9)
69
+ sawyer (~> 0.8.0, >= 0.5.3)
70
+ open4 (1.3.4)
36
71
  parallel (1.20.0)
37
72
  parser (2.7.2.0)
38
73
  ast (~> 2.4.1)
39
74
  public_suffix (4.0.6)
40
75
  rainbow (3.0.0)
41
76
  rake (12.3.3)
77
+ rchardet (1.8.0)
42
78
  rexml (3.2.5)
43
79
  rspec (3.10.0)
44
80
  rspec-core (~> 3.10.0)
@@ -65,6 +101,9 @@ GEM
65
101
  rubocop (>= 0.68.1)
66
102
  ruby-progressbar (1.10.1)
67
103
  ruby2_keywords (0.0.2)
104
+ sawyer (0.8.2)
105
+ addressable (>= 2.3.5)
106
+ faraday (> 0.8, < 2.0)
68
107
  simplecov (0.16.1)
69
108
  docile (~> 1.1)
70
109
  json (>= 1.8, < 3)
@@ -73,6 +112,8 @@ GEM
73
112
  sync (0.5.0)
74
113
  term-ansicolor (1.7.1)
75
114
  tins (~> 1.0)
115
+ terminal-table (1.8.0)
116
+ unicode-display_width (~> 1.1, >= 1.1.1)
76
117
  thor (1.0.1)
77
118
  tins (1.26.0)
78
119
  sync
@@ -90,6 +131,7 @@ PLATFORMS
90
131
  DEPENDENCIES
91
132
  belvo!
92
133
  coveralls
134
+ danger (= 8.2.1)
93
135
  faraday
94
136
  faraday_middleware
95
137
  rake (~> 12.0)
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: 'banamex_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.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
 
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,13 +98,11 @@ 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
@@ -122,12 +111,10 @@ module Belvo
122
111
  # Contains configurable properties of a TaxComplianceStatus
123
112
  # @!attribute save_data [rw] Should data be persisted or not.
124
113
  # @!attribute token [rw] OTP token required by the institution
125
- # @!attribute encryption_key [rw] Custom encryption key
126
114
  # @!attribute attach_pdf [rw] Should the PDF file be included in the
127
115
  # response or not.
128
116
  class TaxComplianceStatusOptions < Faraday::Options.new(
129
117
  :token,
130
- :encryption_key,
131
118
  :save_data,
132
119
  :attach_pdf
133
120
  )
@@ -137,14 +124,15 @@ module Belvo
137
124
  # Contains configurable properties of a TaxReturn
138
125
  # @!attribute save_data [rw] Should data be persisted or not.
139
126
  # @!attribute token [rw] OTP token required by the institution
140
- # @!attribute encryption_key [rw] Custom encryption key
141
127
  # @!attribute attach_pdf [rw] Should the PDF file be included in the
142
128
  # response or not.
143
129
  class TaxReturnOptions < Faraday::Options.new(
144
130
  :token,
145
- :encryption_key,
146
131
  :save_data,
147
- :attach_pdf
132
+ :attach_pdf,
133
+ :type,
134
+ :date_from,
135
+ :date_to
148
136
  )
149
137
  end
150
138
 
@@ -152,12 +140,10 @@ module Belvo
152
140
  # Contains configurable properties of a TaxStatus
153
141
  # @!attribute save_data [rw] Should data be persisted or not.
154
142
  # @!attribute token [rw] OTP token required by the institution
155
- # @!attribute encryption_key [rw] Custom encryption key
156
143
  # @!attribute attach_pdf [rw] Should the PDF file be included in the
157
144
  # response or not.
158
145
  class TaxStatusOptions < Faraday::Options.new(
159
146
  :token,
160
- :encryption_key,
161
147
  :save_data,
162
148
  :attach_pdf
163
149
  )
@@ -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
@@ -134,6 +133,24 @@ module Belvo
134
133
  }
135
134
  @session.token(@endpoint, id, body)
136
135
  end
136
+
137
+ # Patch an existing link
138
+ # @param id [String] Link UUID
139
+ # @param options [LinkOptions] Configurable properties
140
+ # @return [Hash] created link details
141
+ # @raise [RequestError] If response code is different than 2XX
142
+ def patch(
143
+ id:,
144
+ options: nil
145
+ )
146
+ options = LinkOptions.from(options)
147
+ body = {
148
+ access_mode: options.access_mode
149
+ }.merge(options)
150
+ body = clean body: body
151
+ resource_path = format('%<path>s%<id>s/', path: @endpoint, id: id)
152
+ @session.patch(resource_path, body)
153
+ end
137
154
  end
138
155
 
139
156
  # An Account is the representation of a bank account inside a financial
@@ -154,7 +171,6 @@ module Belvo
154
171
  body = {
155
172
  link: link,
156
173
  token: options.token,
157
- encryption_key: options.encryption_key,
158
174
  save_data: options.save_data || true
159
175
  }.merge(options)
160
176
  body = clean body: body
@@ -185,7 +201,6 @@ module Belvo
185
201
  date_to: date_to,
186
202
  token: options.token,
187
203
  account: options.account,
188
- encryption_key: options.encryption_key,
189
204
  save_data: options.save_data || true
190
205
  }.merge(options)
191
206
  body = clean body: body
@@ -211,7 +226,6 @@ module Belvo
211
226
  body = {
212
227
  link: link,
213
228
  token: options.token,
214
- encryption_key: options.encryption_key,
215
229
  save_data: options.save_data || true
216
230
  }.merge(options)
217
231
  body = clean body: body
@@ -242,7 +256,6 @@ module Belvo
242
256
  date_to: date_to,
243
257
  token: options.token,
244
258
  account: options.account,
245
- encryption_key: options.encryption_key,
246
259
  save_data: options.save_data || true
247
260
  }.merge(options)
248
261
  body = clean body: body
@@ -272,7 +285,6 @@ module Belvo
272
285
  year: year,
273
286
  month: month,
274
287
  token: options.token,
275
- encryption_key: options.encryption_key,
276
288
  save_data: options.save_data || true,
277
289
  attach_pdf: options.attach_pdf
278
290
  }.merge(options)
@@ -297,8 +309,9 @@ module Belvo
297
309
  options = IncomeOptions.from(options)
298
310
  body = {
299
311
  link: link,
300
- encryption_key: options.encryption_key,
301
- 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
302
315
  }.merge(options)
303
316
  body = clean body: body
304
317
  @session.post(@endpoint, body)
@@ -328,7 +341,6 @@ module Belvo
328
341
  date_to: date_to,
329
342
  type: type,
330
343
  token: options.token,
331
- encryption_key: options.encryption_key,
332
344
  save_data: options.save_data || true,
333
345
  attach_xml: options.attach_xml
334
346
  }.merge(options)
@@ -355,7 +367,6 @@ module Belvo
355
367
  body = {
356
368
  link: link,
357
369
  token: options.token,
358
- encryption_key: options.encryption_key,
359
370
  save_data: options.save_data || true,
360
371
  attach_pdf: options.attach_pdf
361
372
  }.merge(options)
@@ -377,6 +388,11 @@ module Belvo
377
388
  @endpoint = 'tax-returns/'
378
389
  end
379
390
 
391
+ class TaxReturnType
392
+ YEARLY = 'yearly'
393
+ MONTHLY = 'monthly'
394
+ end
395
+
380
396
  # Retrieve tax returns information from a specific fiscal link.
381
397
  # @param link [String] Link UUID
382
398
  # @param year_from [Integer]
@@ -384,17 +400,22 @@ module Belvo
384
400
  # @param options [TaxReturnOptions] Configurable properties
385
401
  # @return [Hash] created tax returns details
386
402
  # @raise [RequestError] If response code is different than 2XX
387
- def retrieve(link:, year_from:, year_to:, options: nil)
403
+ def retrieve(link:, year_from: nil, year_to: nil, options: nil)
388
404
  options = TaxReturnOptions.from(options)
389
405
  body = {
390
406
  link: link,
391
- year_from: year_from,
392
- year_to: year_to,
393
407
  token: options.token,
394
- encryption_key: options.encryption_key,
395
408
  save_data: options.save_data || true,
396
- attach_pdf: options.attach_pdf
409
+ attach_pdf: options.attach_pdf,
410
+ type: options.type
397
411
  }.merge(options)
412
+ if options.type == TaxReturnType::MONTHLY
413
+ body[:date_from] = options.date_from
414
+ body[:date_to] = options.date_to
415
+ else
416
+ body[:year_from] = year_from
417
+ body[:year_to] = year_to
418
+ end
398
419
  body = clean body: body
399
420
  @session.post(@endpoint, body)
400
421
  end
@@ -422,7 +443,6 @@ module Belvo
422
443
  body = {
423
444
  link: link,
424
445
  token: options.token,
425
- encryption_key: options.encryption_key,
426
446
  save_data: options.save_data || true,
427
447
  attach_pdf: options.attach_pdf
428
448
  }.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.12.0'
5
+ VERSION = '0.15.0'
6
6
  end
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.12.0
4
+ version: 0.15.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-05-12 00:00:00.000000000 Z
11
+ date: 2021-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -149,11 +149,13 @@ files:
149
149
  - ".codeclimate.yml"
150
150
  - ".github/ISSUE_TEMPLATE/feature_request.md"
151
151
  - ".github/pull_request_template.md"
152
+ - ".github/workflows/danger-pr-reviews.yml"
152
153
  - ".gitignore"
153
154
  - ".rspec"
154
155
  - ".rubocop.yml"
155
156
  - ".travis.yml"
156
157
  - CODE_OF_CONDUCT.md
158
+ - Dangerfile
157
159
  - Gemfile
158
160
  - Gemfile.lock
159
161
  - LICENSE