revo-loans_api 0.0.22 → 0.0.23

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: b22a17191cb89626c8154dd07b0107759b63be2332db44d2503e893de6957526
4
- data.tar.gz: 6992b4c9fe45d9f0d157c13f2172b43d21c3b31695e1d736e946160eeaf3715f
3
+ metadata.gz: fa50f24dd72aa71f069c3bcc3a8b72f3e17701ff4ade63d483f789016be694ac
4
+ data.tar.gz: 2383424184de27752a8b89505a97985c4772d9c608f49ce17a5642c5fe8010d2
5
5
  SHA512:
6
- metadata.gz: 1d708089a15e9ba53930ca4c2299032e1101a2b41f9395719ccc98931d347f1b2023d086525eee737b31c5b348fa6a73848efb590024e81d06e38d19870d3622
7
- data.tar.gz: 8d93f4a6e86ef69612d12a8e34723c8b8674f78220209fa0f7bbf6512e8883b5b3dc39371c3ea60c9db5078173559ef5ffa6103b8a34911275e2568a6a2bd10d
6
+ metadata.gz: bf0b0126ac8abdb2c67f84b2737e7532fa086a25e6474e8ea829004a045c9f395cee434ce56523ee872982c1c4ab6fd3a54a672fdf8f7308e9c95ec5fbfbdfb5
7
+ data.tar.gz: a156f89429045bb046eae8baa4e8859bd136b6c3cb92679e076547156eb2d5dcb68339c7d25b86181deced28d2507a140c2013c18eb20fc355961e95533fe04f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- revo-loans_api (0.0.22)
4
+ revo-loans_api (0.0.23)
5
5
  activesupport
6
6
  http
7
7
 
@@ -16,6 +16,7 @@ GEM
16
16
  zeitwerk (~> 2.2)
17
17
  addressable (2.7.0)
18
18
  public_suffix (>= 2.0.2, < 5.0)
19
+ byebug (11.0.1)
19
20
  concurrent-ruby (1.1.6)
20
21
  crack (0.4.3)
21
22
  safe_yaml (~> 1.0.0)
@@ -74,6 +75,7 @@ PLATFORMS
74
75
 
75
76
  DEPENDENCIES
76
77
  bundler (~> 1.17)
78
+ byebug
77
79
  rake (~> 10.0)
78
80
  revo-loans_api!
79
81
  rspec (~> 3.0)
data/README.md CHANGED
@@ -509,6 +509,11 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
509
509
 
510
510
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
511
511
 
512
+ ## Docker
513
+
514
+ `docker-compose run specs bundle`
515
+ `docker-compose run specs rspec`
516
+
512
517
  ## Contributing
513
518
 
514
519
  Bug reports and pull requests are welcome on GitHub at https://github.com/RevoTechnology/LoansClient.rb.
@@ -0,0 +1,8 @@
1
+ version: "3"
2
+ services:
3
+ specs:
4
+ image: ruby:2.6.4
5
+ working_dir: /app
6
+ volumes:
7
+ - .:/app
8
+ - .bundle:/usr/local/bundle
@@ -12,24 +12,35 @@ class Revo::LoansApi::Client
12
12
 
13
13
  Result = Struct.new(:success?, :response, keyword_init: true)
14
14
 
15
- def initialize(base_url:, login: nil, password: nil, session_token: nil)
15
+ def initialize(
16
+ base_url:,
17
+ login: nil,
18
+ password: nil,
19
+ session_token: nil,
20
+ application_source: nil
21
+ )
16
22
  @base_url = base_url
17
23
  @login = login
18
24
  @password = password
19
25
  @session_token = session_token
26
+ @application_source = application_source
20
27
  end
21
28
 
22
29
  def create_session
23
30
  make_request(
24
31
  :post, 'sessions',
25
- user: { login: login, password: password }
32
+ params: { user: { login: login, password: password } }
26
33
  ).tap do |result|
27
34
  @session_token = result.response.dig(:user, :authentication_token) if result&.success?
28
35
  end
29
36
  end
30
37
 
31
38
  def create_loan_request(options)
32
- response = make_request(:post, 'loan_requests', loan_request_params(options))
39
+ response = make_request(
40
+ :post,
41
+ 'loan_requests',
42
+ params: loan_request_params(options)
43
+ )
33
44
  return response unless response.success?
34
45
 
35
46
  @loan_request_token = response.response.dig(:loan_request, :token)
@@ -46,7 +57,11 @@ class Revo::LoansApi::Client
46
57
 
47
58
  def update_loan_request(token:, options:)
48
59
  update_params = { loan_request: options }
49
- response = make_request(:put, "loan_requests/#{token}", update_params)
60
+ response = make_request(
61
+ :put,
62
+ "loan_requests/#{token}",
63
+ params: update_params
64
+ )
50
65
 
51
66
  return response unless response.success?
52
67
 
@@ -78,11 +93,20 @@ class Revo::LoansApi::Client
78
93
  end
79
94
 
80
95
  def complete_loan_request(token:, code:)
81
- make_request(:post, "loan_requests/#{token}/confirmation", code: code)
96
+ make_request(
97
+ :post,
98
+ "loan_requests/#{token}/confirmation",
99
+ params: { code: code }
100
+ )
82
101
  end
83
102
 
84
103
  def create_loan(token:, term_id:)
85
- make_request(:post, "loan_requests/#{token}/loan", term_id: term_id)
104
+ make_request(
105
+ :post,
106
+ "loan_requests/#{token}/loan",
107
+ params: { term_id: term_id },
108
+ headers: { 'Application-Source': application_source }
109
+ )
86
110
  end
87
111
 
88
112
  def finalize_loan(token:, code:, sms_info: '0', skip_confirmation: false)
@@ -97,12 +121,19 @@ class Revo::LoansApi::Client
97
121
  loan_params.delete(:confirmation_code)
98
122
  end
99
123
 
100
- make_request(:post, "loan_requests/#{token}/loan/finalization", loan: loan_params)
124
+ make_request(
125
+ :post,
126
+ "loan_requests/#{token}/loan/finalization",
127
+ params: { loan: loan_params }
128
+ )
101
129
  end
102
130
 
103
131
  def confirm_loan(token:, bill:)
104
- params = { loan: { bill: bill } }
105
- response = make_request(:put, "loan_requests/#{token}/loan/bill", params)
132
+ response = make_request(
133
+ :put,
134
+ "loan_requests/#{token}/loan/bill",
135
+ params: { loan: { bill: bill } }
136
+ )
106
137
 
107
138
  return response unless response.success?
108
139
 
@@ -111,7 +142,11 @@ class Revo::LoansApi::Client
111
142
 
112
143
  # returns
113
144
  def orders(store_id:, filters: {})
114
- make_request(:get, 'orders', store_id: store_id, filters: filters)
145
+ make_request(
146
+ :get,
147
+ 'orders',
148
+ params: { store_id: store_id, filters: filters }
149
+ )
115
150
  end
116
151
 
117
152
  def send_return_confirmation_code(order_id:)
@@ -127,7 +162,7 @@ class Revo::LoansApi::Client
127
162
  store_id: store_id
128
163
  }
129
164
  }
130
- make_request(:post, 'returns', params)
165
+ make_request(:post, 'returns', params: params)
131
166
  end
132
167
 
133
168
  def confirm_return(return_id:)
@@ -139,33 +174,53 @@ class Revo::LoansApi::Client
139
174
  end
140
175
 
141
176
  def start_self_registration(token:, mobile_phone:, skip_message: false)
142
- make_request(:post, "loan_requests/#{token}/client/self_registration",
143
- mobile_phone: mobile_phone, skip_message: skip_message)
177
+ make_request(
178
+ :post,
179
+ "loan_requests/#{token}/client/self_registration",
180
+ params: { mobile_phone: mobile_phone, skip_message: skip_message }
181
+ )
144
182
  end
145
183
 
146
184
  def check_client_code(token:, code:)
147
- make_request(:post, "loan_requests/#{token}/client/check_code", code: code)
185
+ make_request(
186
+ :post,
187
+ "loan_requests/#{token}/client/check_code",
188
+ params: { code: code }
189
+ )
148
190
  end
149
191
 
150
192
  def create_client(token:, client_params:, provider_data: {})
151
- make_request(:post, "loan_requests/#{token}/client",
152
- client: client_params, provider_data: provider_data)
193
+ make_request(
194
+ :post,
195
+ "loan_requests/#{token}/client",
196
+ params: { client: client_params, provider_data: provider_data }
197
+ )
153
198
  end
154
199
 
155
200
  def update_client(id:, client_params:)
156
- make_request(:patch, "/clients/#{id}", client: client_params)
201
+ make_request(:patch, "clients/#{id}", params: { client: client_params })
157
202
  end
158
203
 
159
204
  def get_client(guid:)
160
- make_request(:get, "/clients/#{guid}")
205
+ make_request(:get, "clients/#{guid}")
161
206
  end
162
207
 
163
208
  def create_virtual_card(token:, term_id:)
164
- make_request(:post, "loan_requests/#{token}/virtual_card", term_id: term_id)
209
+ make_request(
210
+ :post,
211
+ "loan_requests/#{token}/virtual_card",
212
+ params: { term_id: term_id },
213
+ headers: { 'Application-Source': application_source }
214
+ )
165
215
  end
166
216
 
167
217
  def create_card_loan(token:, term_id:)
168
- make_request(:post, "loan_requests/#{token}/card_loan", term_id: term_id)
218
+ make_request(
219
+ :post,
220
+ "loan_requests/#{token}/card_loan",
221
+ params: { term_id: term_id },
222
+ headers: { 'Application-Source': application_source }
223
+ )
169
224
  end
170
225
 
171
226
  def send_billing_shift_confirmation_code(client_id:)
@@ -177,12 +232,19 @@ class Revo::LoansApi::Client
177
232
  end
178
233
 
179
234
  def confirm_billing_shift(client_id:, code:, billing_chain:)
180
- make_request(:post, "clients/#{client_id}/billing_shift/confirmation",
181
- code: code, billing_chain: billing_chain)
235
+ make_request(
236
+ :post,
237
+ "clients/#{client_id}/billing_shift/confirmation",
238
+ params: { code: code, billing_chain: billing_chain }
239
+ )
182
240
  end
183
241
 
184
242
  def increase_client_limit(client_id:, amount:)
185
- make_request(:patch, "clients/#{client_id}/limit", amount: amount)
243
+ make_request(
244
+ :patch,
245
+ "clients/#{client_id}/limit",
246
+ params: { amount: amount }
247
+ )
186
248
  end
187
249
 
188
250
  def client_loan_documents(client_id:, loan_application_id:)
@@ -194,14 +256,18 @@ class Revo::LoansApi::Client
194
256
  end
195
257
 
196
258
  def update_client_additional_services(client_id:, additional_services:)
197
- make_request(:patch, "clients/#{client_id}/additional_services", additional_services)
259
+ make_request(
260
+ :patch,
261
+ "clients/#{client_id}/additional_services",
262
+ params: additional_services
263
+ )
198
264
  end
199
265
 
200
266
  private
201
267
 
202
268
  API_CONTENT_TYPE = 'application/json'.freeze
203
269
 
204
- attr_reader :base_url, :login, :password
270
+ attr_reader :base_url, :login, :password, :application_source
205
271
 
206
272
  def connection
207
273
  @connection ||= HTTP.persistent(base_url)
@@ -214,9 +280,14 @@ class Revo::LoansApi::Client
214
280
  Result.new(success?: false, response: { errors: { base: [:cant_fetch_loan_request_terms] } })
215
281
  end
216
282
 
217
- def make_request(method, endpoint, params = {}, &block)
218
- headers = { Authorization: session_token }.compact
219
- response = connection.public_send(method, url_for(endpoint), json: params, headers: headers)
283
+ def make_request(method, endpoint, params: {}, headers: {}, &block)
284
+ headers = { 'Authorization': session_token }.merge(headers).compact
285
+ response = connection.public_send(
286
+ method,
287
+ url_for(endpoint),
288
+ json: params,
289
+ headers: headers
290
+ )
220
291
  handle_response(response, &block)
221
292
  rescue HTTP::Error => e
222
293
  handle_error(e)
@@ -1,5 +1,5 @@
1
1
  module Revo
2
2
  module LoansApi
3
- VERSION = '0.0.22'.freeze
3
+ VERSION = '0.0.23'.freeze
4
4
  end
5
5
  end
@@ -34,8 +34,9 @@ Gem::Specification.new do |spec|
34
34
  spec.add_dependency 'http'
35
35
  spec.add_dependency 'activesupport'
36
36
  spec.add_development_dependency 'bundler', '~> 1.17'
37
+ spec.add_development_dependency 'byebug'
37
38
  spec.add_development_dependency 'rake', '~> 10.0'
38
39
  spec.add_development_dependency 'rspec', '~> 3.0'
39
- spec.add_development_dependency 'webmock'
40
40
  spec.add_development_dependency 'vcr'
41
+ spec.add_development_dependency 'webmock'
41
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: revo-loans_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22
4
+ version: 0.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Revo Developers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-22 00:00:00.000000000 Z
11
+ date: 2020-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.17'
55
+ - !ruby/object:Gem::Dependency
56
+ name: byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rake
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -81,7 +95,7 @@ dependencies:
81
95
  - !ruby/object:Gem::Version
82
96
  version: '3.0'
83
97
  - !ruby/object:Gem::Dependency
84
- name: webmock
98
+ name: vcr
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
101
  - - ">="
@@ -95,7 +109,7 @@ dependencies:
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
- name: vcr
112
+ name: webmock
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
115
  - - ">="
@@ -126,6 +140,7 @@ files:
126
140
  - Rakefile
127
141
  - bin/console
128
142
  - bin/setup
143
+ - docker-compose.yml
129
144
  - lib/revo/loans_api.rb
130
145
  - lib/revo/loans_api/client.rb
131
146
  - lib/revo/loans_api/version.rb