bridge_bankin 0.1.4 → 0.1.6

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: 576c19dcf1c1f0187d6e86ff45a731415120f261e9a2495013b845b338ee0c3c
4
+ data.tar.gz: 41d2aba812b11af49117b1cfef28e338f067cb5c296bdaa0090886c74414f61c
5
5
  SHA512:
6
- metadata.gz: cc8f0d7735714f22fb50db94d29a6056659dc44bf3de4df4fc9dde283061f81be9c3bd23d8c2cc5ce4640beb13c69f172e0056d3ff16e8f3dd93ccffcbb45fd6
7
- data.tar.gz: d688ca09401e5e1fdbb80245f2774b84568b198b5eeb0cff2dc011daa831077406fbe9578361f95bef6571c59f484dde1d2dc67f738cc75ad6b98a53412aaaa4
6
+ metadata.gz: a029a5962a1296a8ce4b40463e08091456771bfef0b2659f16add6e2c92f9b045150d4c39b55f2851e282ba28dde130d2bb51e51c077b930a567ad533b06293f
7
+ data.tar.gz: fb4bea9560b48b5f1aa563140fadf9032dbaa2d62012ecd7276190de922a709031bf0e2a33d51db81ac463669d73f2d38f0efe3a263c1b56b41285bff914017a
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.6)
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
 
@@ -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,7 +21,7 @@ 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
@@ -29,8 +29,9 @@ module BridgeBankin
29
29
  def initialize
30
30
  @api_base_url = "https://sync.bankin.com"
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.6"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
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.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Olivier Buffon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-23 00:00:00.000000000 Z
11
+ date: 2021-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print
@@ -214,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
214
  - !ruby/object:Gem::Version
215
215
  version: '0'
216
216
  requirements: []
217
- rubygems_version: 3.1.4
217
+ rubygems_version: 3.2.3
218
218
  signing_key:
219
219
  specification_version: 4
220
220
  summary: Unofficial Ruby client to consume Bridge by Bankin’ API