bridge_bankin 0.1.4 → 0.1.7

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: 4a9b2d23a566212f859c98a3d51351c3b66ed9ce1cc726e6b6529cbbaa7d00cc
4
- data.tar.gz: cabf9ebc60c09b0aad07bd3138581f8f0dfbeeeb82009486b9f47ff7f1cde324
3
+ metadata.gz: 884db3467ecb63e74c6ac601952f87f4c33296643fa841ba79ed89dac2c93e05
4
+ data.tar.gz: f0c85a9c23a113ca0832f10448b6dcdf5b2c908c4787d65a19bf1e6be2fb722d
5
5
  SHA512:
6
- metadata.gz: cc8f0d7735714f22fb50db94d29a6056659dc44bf3de4df4fc9dde283061f81be9c3bd23d8c2cc5ce4640beb13c69f172e0056d3ff16e8f3dd93ccffcbb45fd6
7
- data.tar.gz: d688ca09401e5e1fdbb80245f2774b84568b198b5eeb0cff2dc011daa831077406fbe9578361f95bef6571c59f484dde1d2dc67f738cc75ad6b98a53412aaaa4
6
+ metadata.gz: 693ba76df3b7556fd0da4f716da6a595daf73cae4d87e0764efd33a10a81c03c3596f3606e0f2340a5255e9aac89eedf73376def58f5e4e73a7544b8895a364e
7
+ data.tar.gz: b32cdb23ebcb200cc407aa848e5a5be8d17679c23d6fd58c626984a88cec8d24ed5c1a16ff04dbf2d6cdd1136bee130a25a4b0a9b444a465cf1b1936ff54de69
data/.rubocop.yml CHANGED
@@ -46,3 +46,6 @@ RSpec/StubbedMock:
46
46
 
47
47
  RSpec/MultipleExpectations:
48
48
  Enabled: false
49
+
50
+ Metrics/ClassLength:
51
+ Enabled: false
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bridge_bankin (0.1.4)
4
+ bridge_bankin (0.1.7)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -58,6 +58,7 @@ One you have your valid API credential you can now create an initializer in your
58
58
  BridgeBankin.configure do |config|
59
59
  config.api_client_id = ENV["BRIDGE_API_CLIENT_ID"]
60
60
  config.api_client_secret = ENV["BRIDGE_API_CLIENT_SECRET"]
61
+ config.follow_pages = true
61
62
  end
62
63
  ```
63
64
 
@@ -5,8 +5,8 @@ require_relative "lib/bridge_bankin/version"
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "bridge_bankin"
7
7
  spec.version = BridgeBankin::VERSION
8
- spec.authors = ["Olivier Buffon"]
9
- spec.email = ["olivier@buffon.dev"]
8
+ spec.authors = ["Olivier Buffon", "Thomas Andrieu"]
9
+ spec.email = ["olivier@buffon.dev", "t.andrieu@gmail.com"]
10
10
 
11
11
  spec.summary = "Unofficial Ruby client to consume Bridge by Bankin’ API"
12
12
 
@@ -91,7 +91,13 @@ module BridgeBankin
91
91
 
92
92
  case api_response.code
93
93
  when "200", "201"
94
- parse_response_body(api_response.body)
94
+ data = parse_response_body(api_response.body)
95
+
96
+ if data.dig(:pagination, :next_uri) && follow_pages
97
+ handle_paging(data)
98
+ else
99
+ data
100
+ end
95
101
  when "204", "202"
96
102
  {}
97
103
  else
@@ -108,6 +114,25 @@ module BridgeBankin
108
114
  @uri ||= URI.parse(BridgeBankin.configuration.api_base_url)
109
115
  end
110
116
 
117
+ def follow_pages
118
+ BridgeBankin.configuration.follow_pages
119
+ end
120
+
121
+ def handle_paging(data)
122
+ if follow_pages && data[:pagination][:next_uri]
123
+ page_uri = URI.parse(data[:pagination][:next_uri])
124
+
125
+ params = URI.decode_www_form(page_uri.query).to_h
126
+
127
+ next_page_data = get(page_uri.path, **params)
128
+ end
129
+
130
+ next_page_data[:resources] << data[:resources]
131
+ next_page_data[:resources] = next_page_data[:resources].flatten
132
+
133
+ next_page_data
134
+ end
135
+
111
136
  def headers
112
137
  headers =
113
138
  {
@@ -21,16 +21,17 @@ module BridgeBankin
21
21
  #
22
22
  class Configuration
23
23
  attr_reader :api_base_url, :api_version
24
- attr_accessor :api_client_id, :api_client_secret
24
+ attr_accessor :api_client_id, :api_client_secret, :follow_pages
25
25
 
26
26
  #
27
27
  # Initializes Configuration
28
28
  #
29
29
  def initialize
30
- @api_base_url = "https://sync.bankin.com"
30
+ @api_base_url = "https://api.bridgeapi.io"
31
31
  @api_version = "2019-02-18"
32
- @api_client_id = "d16099aec29e445dbb31cf3966b3821e"
33
- @api_client_secret = "HEb73vHEGB4Hunv5OMXFUDNIgNonYJ89YaHHRSyidVgCPbCtFWqtED5fZYObA0lm"
32
+ @api_client_id = ""
33
+ @api_client_secret = ""
34
+ @follow_pages = false
34
35
  end
35
36
  end
36
37
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BridgeBankin
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.7"
5
5
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bridge_bankin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Olivier Buffon
8
+ - Thomas Andrieu
8
9
  autorequire:
9
10
  bindir: exe
10
11
  cert_chain: []
11
- date: 2021-08-23 00:00:00.000000000 Z
12
+ date: 2022-10-14 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: awesome_print
@@ -155,6 +156,7 @@ description: Thanks to a safe and automated access to bank data, Bridge powered
155
156
  services.
156
157
  email:
157
158
  - olivier@buffon.dev
159
+ - t.andrieu@gmail.com
158
160
  executables: []
159
161
  extensions: []
160
162
  extra_rdoc_files: []
@@ -214,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
216
  - !ruby/object:Gem::Version
215
217
  version: '0'
216
218
  requirements: []
217
- rubygems_version: 3.1.4
219
+ rubygems_version: 3.2.22
218
220
  signing_key:
219
221
  specification_version: 4
220
222
  summary: Unofficial Ruby client to consume Bridge by Bankin’ API