belvo 0.12.0 → 0.13.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: d3ccb9e6a9841f2313f4a3307a67c3a0527fad92b91f3a84a607150b2bd86dd8
4
- data.tar.gz: 1103d2e823428b7a1db97821714bd60764cd0c649d59c1876b309cf2f20e0b8d
3
+ metadata.gz: 7f69b2401f03d00f211b1029e686b5ecb35b717bdff42dcbac781e207b2feb87
4
+ data.tar.gz: f93e791acf610e5b1d3f9e3df2fd4cc161003b03d9a303ee66b5ada7c6857b5e
5
5
  SHA512:
6
- metadata.gz: f95143ddfe260d93a6462c70e224df80dd43d2c0a76db8c38b8176d0471643fd22de8db22e2f7299d527dd4c7f56842b3c19045a5d2482c9dfc0a0cdaa4b6566
7
- data.tar.gz: 85ac380d5e207a78915c4a84c21d2efaf03c76f525e49080a5ef9192931b39b1e983df207e8e614cbdc5c4dcf7c0ca2c69cd64cb403839cb5f1c459b572db658
6
+ metadata.gz: 5e2ba29bf5d230d3f250b9dd3c284f09a01fe0dad4d05b29f6e360392258d5d6e5e93c056863345e6aeb22665fb934368e8b6ca5eac76c4e4089b8eda178d637
7
+ data.tar.gz: b124c2ce6c01aed682954cc6ee9f08c6f3507c6bee994249466c9f013992b5830e7649aee52032a56f7b20e12722229c7ccf84c9c7cb26db23e742e26051c7e0
@@ -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: 1
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.13.0)
5
5
  faraday
6
6
  faraday_middleware
7
7
  typhoeus
@@ -12,6 +12,14 @@ GEM
12
12
  addressable (2.7.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/lib/belvo/options.rb CHANGED
@@ -144,7 +144,8 @@ module Belvo
144
144
  :token,
145
145
  :encryption_key,
146
146
  :save_data,
147
- :attach_pdf
147
+ :attach_pdf,
148
+ :type
148
149
  )
149
150
  end
150
151
 
@@ -134,6 +134,24 @@ module Belvo
134
134
  }
135
135
  @session.token(@endpoint, id, body)
136
136
  end
137
+
138
+ # Patch an existing link
139
+ # @param id [String] Link UUID
140
+ # @param options [LinkOptions] Configurable properties
141
+ # @return [Hash] created link details
142
+ # @raise [RequestError] If response code is different than 2XX
143
+ def patch(
144
+ id:,
145
+ options: nil
146
+ )
147
+ options = LinkOptions.from(options)
148
+ body = {
149
+ access_mode: options.access_mode
150
+ }.merge(options)
151
+ body = clean body: body
152
+ resource_path = format('%<path>s%<id>s/', path: @endpoint, id: id)
153
+ @session.patch(resource_path, body)
154
+ end
137
155
  end
138
156
 
139
157
  # An Account is the representation of a bank account inside a financial
@@ -377,24 +395,35 @@ module Belvo
377
395
  @endpoint = 'tax-returns/'
378
396
  end
379
397
 
398
+ class TaxReturnType
399
+ YEARLY = 'yearly'
400
+ MONTHLY = 'monthly'
401
+ end
402
+
380
403
  # Retrieve tax returns information from a specific fiscal link.
381
404
  # @param link [String] Link UUID
382
- # @param year_from [Integer]
383
- # @param year_to [Integer]
405
+ # @param year_from [Integer] | [Date]
406
+ # @param year_to [Integer] | [Date]
384
407
  # @param options [TaxReturnOptions] Configurable properties
385
408
  # @return [Hash] created tax returns details
386
409
  # @raise [RequestError] If response code is different than 2XX
387
- def retrieve(link:, year_from:, year_to:, options: nil)
410
+ def retrieve(link:, year_from: nil, year_to: nil, options: nil)
388
411
  options = TaxReturnOptions.from(options)
389
412
  body = {
390
413
  link: link,
391
- year_from: year_from,
392
- year_to: year_to,
393
414
  token: options.token,
394
415
  encryption_key: options.encryption_key,
395
416
  save_data: options.save_data || true,
396
- attach_pdf: options.attach_pdf
417
+ attach_pdf: options.attach_pdf,
418
+ type: options.type
397
419
  }.merge(options)
420
+ if options.type == TaxReturnType::MONTHLY
421
+ body[:date_from] = year_from
422
+ body[:date_to] = year_to
423
+ else
424
+ body[:year_from] = year_from
425
+ body[:year_to] = year_to
426
+ end
398
427
  body = clean body: body
399
428
  @session.post(@endpoint, body)
400
429
  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.13.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.13.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-06-23 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