belvo 0.13.1 → 0.17.2
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 +4 -4
- data/.circleci/config.yml +53 -0
- data/.github/workflows/danger-pr-reviews.yml +1 -1
- data/Gemfile +1 -1
- data/Gemfile.lock +16 -17
- data/README.md +44 -15
- data/belvo.gemspec +1 -1
- data/lib/belvo/options.rb +15 -24
- data/lib/belvo/resources.rb +28 -13
- data/lib/belvo/utils.rb +16 -0
- data/lib/belvo/version.rb +1 -1
- data/lib/belvo.rb +12 -1
- metadata +5 -5
- data/.travis.yml +0 -18
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4f8989d1ceda36ab9e24ffc51abf4c4ae24240bb326c61c6f73334c2e158b91b
|
|
4
|
+
data.tar.gz: 6f70b4441db3d4660b6556bc47a50dcc9f13849163f1dcb34bd5c20311ad70a5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 63664183b35c4ca87b5420f092a55efe0f1ba4aac5f1d3c6426023328ed84812e30f0da71571671b2a0d7bbce987042a17e15b1962a645ce47621689de8f58e4
|
|
7
|
+
data.tar.gz: 9ff161b2584cb17e00101b6b9f19080af9bad061959a931c8e67df894fe974a8db2741d786bcd6ef7733ef3d12dd07c2a2375b1abc897cf441ce6dec70ccd75e
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
version: 2.1
|
|
2
|
+
orbs:
|
|
3
|
+
ruby: circleci/ruby@1.0.4
|
|
4
|
+
jobs:
|
|
5
|
+
test:
|
|
6
|
+
docker:
|
|
7
|
+
- image: cimg/ruby:2.7
|
|
8
|
+
steps:
|
|
9
|
+
- checkout
|
|
10
|
+
- ruby/install-deps
|
|
11
|
+
- run:
|
|
12
|
+
name: Install deps
|
|
13
|
+
command: gem install bundler -v 2.1.4
|
|
14
|
+
- run:
|
|
15
|
+
name: Run tests
|
|
16
|
+
command: |
|
|
17
|
+
bundle exec rubocop
|
|
18
|
+
bundle exec rspec spec
|
|
19
|
+
deploy-to-rubygems:
|
|
20
|
+
docker:
|
|
21
|
+
- image: cimg/ruby:2.7
|
|
22
|
+
steps:
|
|
23
|
+
- checkout
|
|
24
|
+
- ruby/install-deps
|
|
25
|
+
- run:
|
|
26
|
+
name: Set Rubygems credentials
|
|
27
|
+
command: |
|
|
28
|
+
mkdir ~/.gem
|
|
29
|
+
echo -e "---\r\n:rubygems_api_key: $GEM_HOST_API_KEY" > ~/.gem/credentials
|
|
30
|
+
chmod 0600 /home/circleci/.gem/credentials
|
|
31
|
+
- run:
|
|
32
|
+
name: Publish gem to Rubygems
|
|
33
|
+
command: bundle exec rake release
|
|
34
|
+
|
|
35
|
+
workflows:
|
|
36
|
+
build-test-deploy:
|
|
37
|
+
jobs:
|
|
38
|
+
- test:
|
|
39
|
+
filters:
|
|
40
|
+
tags:
|
|
41
|
+
only: /v.*/
|
|
42
|
+
context:
|
|
43
|
+
- shared
|
|
44
|
+
- deploy-to-rubygems:
|
|
45
|
+
requires:
|
|
46
|
+
- test
|
|
47
|
+
filters:
|
|
48
|
+
branches:
|
|
49
|
+
ignore: /.*/
|
|
50
|
+
tags:
|
|
51
|
+
only: /^v.*/
|
|
52
|
+
context:
|
|
53
|
+
- shared
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
belvo (0.
|
|
4
|
+
belvo (0.17.2)
|
|
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.
|
|
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)
|
|
@@ -20,12 +20,11 @@ GEM
|
|
|
20
20
|
colored2 (3.1.2)
|
|
21
21
|
cork (0.3.0)
|
|
22
22
|
colored2 (~> 3.1)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
tins (~> 1.6)
|
|
23
|
+
coveralls_reborn (0.23.0)
|
|
24
|
+
simplecov (>= 0.18.1, < 0.22.0)
|
|
25
|
+
term-ansicolor (~> 1.6)
|
|
26
|
+
thor (>= 0.20.3, < 2.0)
|
|
27
|
+
tins (~> 1.16)
|
|
29
28
|
crack (0.4.4)
|
|
30
29
|
danger (8.2.1)
|
|
31
30
|
claide (~> 1.0)
|
|
@@ -41,7 +40,7 @@ GEM
|
|
|
41
40
|
octokit (~> 4.7)
|
|
42
41
|
terminal-table (~> 1)
|
|
43
42
|
diff-lcs (1.4.4)
|
|
44
|
-
docile (1.
|
|
43
|
+
docile (1.4.0)
|
|
45
44
|
ethon (0.12.0)
|
|
46
45
|
ffi (>= 1.3.0)
|
|
47
46
|
faraday (1.1.0)
|
|
@@ -56,7 +55,6 @@ GEM
|
|
|
56
55
|
rchardet (~> 1.8)
|
|
57
56
|
hashdiff (1.0.1)
|
|
58
57
|
jaro_winkler (1.5.4)
|
|
59
|
-
json (2.3.1)
|
|
60
58
|
kramdown (2.3.1)
|
|
61
59
|
rexml
|
|
62
60
|
kramdown-parser-gfm (1.1.0)
|
|
@@ -104,18 +102,19 @@ GEM
|
|
|
104
102
|
sawyer (0.8.2)
|
|
105
103
|
addressable (>= 2.3.5)
|
|
106
104
|
faraday (> 0.8, < 2.0)
|
|
107
|
-
simplecov (0.
|
|
105
|
+
simplecov (0.21.2)
|
|
108
106
|
docile (~> 1.1)
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
simplecov-html (0.
|
|
107
|
+
simplecov-html (~> 0.11)
|
|
108
|
+
simplecov_json_formatter (~> 0.1)
|
|
109
|
+
simplecov-html (0.12.3)
|
|
110
|
+
simplecov_json_formatter (0.1.3)
|
|
112
111
|
sync (0.5.0)
|
|
113
112
|
term-ansicolor (1.7.1)
|
|
114
113
|
tins (~> 1.0)
|
|
115
114
|
terminal-table (1.8.0)
|
|
116
115
|
unicode-display_width (~> 1.1, >= 1.1.1)
|
|
117
|
-
thor (1.0
|
|
118
|
-
tins (1.
|
|
116
|
+
thor (1.1.0)
|
|
117
|
+
tins (1.29.1)
|
|
119
118
|
sync
|
|
120
119
|
typhoeus (1.4.0)
|
|
121
120
|
ethon (>= 0.9.0)
|
|
@@ -130,7 +129,7 @@ PLATFORMS
|
|
|
130
129
|
|
|
131
130
|
DEPENDENCIES
|
|
132
131
|
belvo!
|
|
133
|
-
|
|
132
|
+
coveralls_reborn
|
|
134
133
|
danger (= 8.2.1)
|
|
135
134
|
faraday
|
|
136
135
|
faraday_middleware
|
data/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<h1 align="center">Belvo Ruby Gem</h1>
|
|
2
2
|
<p align="center">
|
|
3
3
|
<a href="https://rubygems.org/gems/belvo"><img alt="Rubygems.org" src="https://img.shields.io/gem/v/belvo?style=for-the-badge"></a>
|
|
4
|
-
<a href="https://
|
|
4
|
+
<a href="https://app.circleci.com/pipelines/github/belvo-finance/belvo-ruby"><img alt="CircleCI (.com)" src="https://img.shields.io/travis/com/belvo-finance/belvo-ruby/master?style=for-the-badge"></a>
|
|
5
5
|
<a href="https://coveralls.io/github/belvo-finance/belvo-ruby"><img alt="Coveralls github" src="https://img.shields.io/coveralls/github/belvo-finance/belvo-ruby?style=for-the-badge"></a>
|
|
6
6
|
<a href="https://codeclimate.com/github/belvo-finance/belvo-ruby"><img alt="CodeClimate maintainability" src="https://img.shields.io/codeclimate/maintainability/belvo-finance/belvo-ruby?style=for-the-badge"></a>
|
|
7
7
|
</p>
|
|
@@ -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
|
-
'
|
|
43
|
-
'
|
|
44
|
-
'
|
|
45
|
+
'your-secret-id',
|
|
46
|
+
'your-secret-password',
|
|
47
|
+
'sandbox'
|
|
45
48
|
)
|
|
46
49
|
|
|
47
50
|
begin
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
60
|
-
|
|
88
|
+
puts e.status_code
|
|
89
|
+
puts e.detail
|
|
61
90
|
end
|
|
62
91
|
```
|
|
63
92
|
|
data/belvo.gemspec
CHANGED
|
@@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
|
|
|
33
33
|
spec.add_dependency 'faraday_middleware'
|
|
34
34
|
spec.add_dependency 'typhoeus'
|
|
35
35
|
|
|
36
|
-
spec.add_development_dependency '
|
|
36
|
+
spec.add_development_dependency 'coveralls_reborn'
|
|
37
37
|
spec.add_development_dependency 'rake', '~> 12.0'
|
|
38
38
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
|
39
39
|
spec.add_development_dependency 'rubocop', '~> 0.81.0'
|
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
|
-
|
|
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
|
|
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
|
-
:
|
|
102
|
-
:
|
|
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,12 +132,10 @@ 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
141
|
:type,
|
|
@@ -155,12 +148,10 @@ module Belvo
|
|
|
155
148
|
# Contains configurable properties of a TaxStatus
|
|
156
149
|
# @!attribute save_data [rw] Should data be persisted or not.
|
|
157
150
|
# @!attribute token [rw] OTP token required by the institution
|
|
158
|
-
# @!attribute encryption_key [rw] Custom encryption key
|
|
159
151
|
# @!attribute attach_pdf [rw] Should the PDF file be included in the
|
|
160
152
|
# response or not.
|
|
161
153
|
class TaxStatusOptions < Faraday::Options.new(
|
|
162
154
|
:token,
|
|
163
|
-
:encryption_key,
|
|
164
155
|
:save_data,
|
|
165
156
|
:attach_pdf
|
|
166
157
|
)
|
data/lib/belvo/resources.rb
CHANGED
|
@@ -99,7 +99,7 @@ module Belvo
|
|
|
99
99
|
@session.post(@endpoint, body)
|
|
100
100
|
end
|
|
101
101
|
|
|
102
|
-
# Allows to change password, password2
|
|
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
|
-
|
|
319
|
-
|
|
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)
|
|
@@ -412,7 +429,6 @@ 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
|
|
@@ -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
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
|
-
|
|
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.
|
|
4
|
+
version: 0.17.2
|
|
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-
|
|
11
|
+
date: 2021-11-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
@@ -53,7 +53,7 @@ dependencies:
|
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: '0'
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
56
|
+
name: coveralls_reborn
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
59
|
- - ">="
|
|
@@ -146,6 +146,7 @@ executables: []
|
|
|
146
146
|
extensions: []
|
|
147
147
|
extra_rdoc_files: []
|
|
148
148
|
files:
|
|
149
|
+
- ".circleci/config.yml"
|
|
149
150
|
- ".codeclimate.yml"
|
|
150
151
|
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
|
151
152
|
- ".github/pull_request_template.md"
|
|
@@ -153,7 +154,6 @@ files:
|
|
|
153
154
|
- ".gitignore"
|
|
154
155
|
- ".rspec"
|
|
155
156
|
- ".rubocop.yml"
|
|
156
|
-
- ".travis.yml"
|
|
157
157
|
- CODE_OF_CONDUCT.md
|
|
158
158
|
- Dangerfile
|
|
159
159
|
- Gemfile
|
|
@@ -193,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
193
193
|
- !ruby/object:Gem::Version
|
|
194
194
|
version: '0'
|
|
195
195
|
requirements: []
|
|
196
|
-
rubygems_version: 3.
|
|
196
|
+
rubygems_version: 3.2.22
|
|
197
197
|
signing_key:
|
|
198
198
|
specification_version: 4
|
|
199
199
|
summary: The Ruby gem for the Belvo API
|
data/.travis.yml
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
language: ruby
|
|
2
|
-
cache: bundler
|
|
3
|
-
rvm:
|
|
4
|
-
- 2.5.5
|
|
5
|
-
before_install: gem install bundler -v 2.1.4
|
|
6
|
-
script:
|
|
7
|
-
- bundle exec rubocop
|
|
8
|
-
- bundle exec rspec spec
|
|
9
|
-
deploy:
|
|
10
|
-
provider: rubygems
|
|
11
|
-
api_key:
|
|
12
|
-
secure: nsKurIEds1W6zwyj0mDmYx77amlDJOycegZV9o+OrBOzRRcpT+O3oFHGouMzAQyIbdUtmWyXp9uJHBEz7Q6Zc5fy6iG05sGO7tFoJMlKiPE5piiOTM5y6qt1GjZ1MYIU0rpnsp9QDsVUR1ATGpoD9O/zzn/lOPbxp2FoWHqWra84D/1jvVXPTqslLgup+GDsxseiAfwTMoTy65TXodISkvoYtlPL3EBV4/XQVBjVGGtM5mdjDJg+YA4yVA2NwCCjhFcj88fRxBmqWRnG/pzmX3nyRlMGjtUBm8OpLSR1NiXXqgzYUAVMD8/8VL/h3OsBqvwqgjZKMO6rXqNKFJQAxYUqvJaLcHP8D05dxWlumqwxlHzscKWLjAe7JbVo2DiAMvMTR8NTJOI7LOraU10iFHtmwAVnyBOaSJUVJuFgAoybq9tqYoZ/uZ7shCuWVNUIWIQM7HN9v99tfvemXMB+2RIN565bzBWSorn5MvXsApvqCLLDFuRnt7urR+0ZyT4dKXgvWRhnNOQgiMwEE/8+Y66nKVB7iNxFDw6LtittyoOZ0HvbHQDtqXOkzT/yaq2Ff2zwuUNYrCHqcdnxg5TBOYg5ndurcFxAc77ZlNSvidEC9tgXHA1m+r0Vq+ZCWOiyyohX33ZfA/UsAIStKr7a6ZLZZywuiqXasg1O9XoRB74=
|
|
13
|
-
gem: belvo
|
|
14
|
-
on:
|
|
15
|
-
tags: true
|
|
16
|
-
repo: belvo-finance/belvo-ruby
|
|
17
|
-
branch: master
|
|
18
|
-
skip_cleanup: 'true'
|