belvo 0.4.1 → 0.5.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: aa4fbcb0144298783943d06abf59f004483704a3677efc1ab61bfdf0e7c2d1c6
4
- data.tar.gz: 56df1994b401363be388f902af16b4ddd7100306ae59a922895910d5a3160fa3
3
+ metadata.gz: cd5733a59d486efcc6a6d9e62331a2d6734304bc231e76a19f27a285f7b4c47f
4
+ data.tar.gz: 408ae0cb0d7a27e8b4f8f4f8a9b7a7a6b3a6d08539d5f938e328af137f26bcb4
5
5
  SHA512:
6
- metadata.gz: c92cf94deeae258a916c89ae61f8dfdd2436fb22c8f9d14ff55ee8b34ad7197d07b8d3fb13fe7fc34f105182b25d8232b78f7d759f3a4dbd2b9737767066b182
7
- data.tar.gz: caccc705af819123b0a613e988a6cf55094b45e3830b7afb925e721dd9c9787ef51626c596402bbd66d1f030ccc60fd6fe4b4b65dbea034d62478c37d29b66df
6
+ metadata.gz: 84f3d999c67f38697b1c18973a70503787a2a4009d41b4bb7d9525bfbc8844451cdfb7f9b1bb71b150df5e1cf76f6164c527d92c4129d49696a80f5526662fbf
7
+ data.tar.gz: ff94f967de7f91895bc8323f0c6265d405991f4ce547582b920ec657b4c76926225adb6ddade63c72fe3b0e4f1c2e80ea6a7d12764c4ac9d7c3d83c93c6583dc
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- belvo (0.4.1)
4
+ belvo (0.5.0)
5
5
  faraday
6
6
  faraday_middleware
7
7
  typhoeus
@@ -34,9 +34,9 @@ GEM
34
34
  json (2.3.0)
35
35
  multipart-post (2.1.1)
36
36
  parallel (1.19.1)
37
- parser (2.7.1.1)
37
+ parser (2.7.1.2)
38
38
  ast (~> 2.4.0)
39
- public_suffix (4.0.4)
39
+ public_suffix (4.0.5)
40
40
  rainbow (3.0.0)
41
41
  rake (12.3.3)
42
42
  rexml (3.2.4)
@@ -44,15 +44,15 @@ GEM
44
44
  rspec-core (~> 3.9.0)
45
45
  rspec-expectations (~> 3.9.0)
46
46
  rspec-mocks (~> 3.9.0)
47
- rspec-core (3.9.1)
48
- rspec-support (~> 3.9.1)
49
- rspec-expectations (3.9.1)
47
+ rspec-core (3.9.2)
48
+ rspec-support (~> 3.9.3)
49
+ rspec-expectations (3.9.2)
50
50
  diff-lcs (>= 1.2.0, < 2.0)
51
51
  rspec-support (~> 3.9.0)
52
52
  rspec-mocks (3.9.1)
53
53
  diff-lcs (>= 1.2.0, < 2.0)
54
54
  rspec-support (~> 3.9.0)
55
- rspec-support (3.9.2)
55
+ rspec-support (3.9.3)
56
56
  rubocop (0.81.0)
57
57
  jaro_winkler (~> 1.5.1)
58
58
  parallel (~> 1.10)
@@ -61,7 +61,7 @@ GEM
61
61
  rexml
62
62
  ruby-progressbar (~> 1.7)
63
63
  unicode-display_width (>= 1.4.0, < 2.0)
64
- rubocop-rspec (1.38.1)
64
+ rubocop-rspec (1.39.0)
65
65
  rubocop (>= 0.68.1)
66
66
  ruby-progressbar (1.10.1)
67
67
  safe_yaml (1.0.5)
@@ -76,7 +76,7 @@ GEM
76
76
  thor (1.0.1)
77
77
  tins (1.24.1)
78
78
  sync
79
- typhoeus (1.3.1)
79
+ typhoeus (1.4.0)
80
80
  ethon (>= 0.9.0)
81
81
  unicode-display_width (1.7.0)
82
82
  webmock (3.8.3)
data/lib/belvo/options.rb CHANGED
@@ -13,7 +13,9 @@ module Belvo
13
13
  :access_mode,
14
14
  :token,
15
15
  :encryption_key,
16
- :username_type
16
+ :username_type,
17
+ :certificate,
18
+ :private_key
17
19
  )
18
20
  end
19
21
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'date'
4
4
  require 'belvo/options'
5
+ require 'belvo/utils'
5
6
 
6
7
  module Belvo
7
8
  # Represents a consumable REST resource from Belvo API
@@ -88,6 +89,8 @@ module Belvo
88
89
  options: nil
89
90
  )
90
91
  options = LinkOptions.from(options)
92
+ options.certificate = Utils.read_file_to_b64(options.certificate)
93
+ options.private_key = Utils.read_file_to_b64(options.private_key)
91
94
  body = {
92
95
  institution: institution,
93
96
  username: username,
@@ -96,7 +99,9 @@ module Belvo
96
99
  token: options.token,
97
100
  encryption_key: options.encryption_key,
98
101
  access_mode: options.access_mode || AccessMode::SINGLE,
99
- username_type: options.username_type
102
+ username_type: options.username_type,
103
+ certificate: options.certificate,
104
+ private_key: options.private_key
100
105
  }.merge(options)
101
106
  body = clean body: body
102
107
  @session.post(@endpoint, body)
@@ -109,13 +114,18 @@ module Belvo
109
114
  # @param options [LinkOptions] Configurable properties
110
115
  # @return [Hash] link details
111
116
  # @raise [RequestError] If response code is different than 2XX
112
- def update(id:, password:, password2: nil, options: nil)
117
+ def update(id:, password: nil, password2: nil, options: nil)
113
118
  options = LinkOptions.from(options)
119
+ options.certificate = Utils.read_file_to_b64(options.certificate)
120
+ options.private_key = Utils.read_file_to_b64(options.private_key)
114
121
  body = {
115
122
  password: password,
116
123
  password2: password2,
117
124
  token: options.token,
118
- encryption_key: options.encryption_key
125
+ encryption_key: options.encryption_key,
126
+ username_type: options.username_type,
127
+ certificate: options.certificate,
128
+ private_key: options.private_key
119
129
  }.merge(options)
120
130
  body = clean body: body
121
131
  @session.put(@endpoint, id, body)
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'base64'
4
+
5
+ # Class with helper functions
6
+ class Utils
7
+ def self.read_file_to_b64(path)
8
+ return if path.nil? || !File.file?(path)
9
+
10
+ data = File.open(path).read
11
+ Base64.encode64(data)
12
+ end
13
+ 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.4.1'
5
+ VERSION = '0.5.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.4.1
4
+ version: 0.5.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: 2020-04-28 00:00:00.000000000 Z
11
+ date: 2020-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -167,6 +167,7 @@ files:
167
167
  - lib/belvo/http.rb
168
168
  - lib/belvo/options.rb
169
169
  - lib/belvo/resources.rb
170
+ - lib/belvo/utils.rb
170
171
  - lib/belvo/version.rb
171
172
  homepage: https://github.com/belvo-finance/belvo-ruby
172
173
  licenses: