bayonet_client 1.1.0 → 2.1.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
  SHA1:
3
- metadata.gz: d9dc8054d56b32cbc00ebffb3b7755184dde57cd
4
- data.tar.gz: ef8f64fbae12dc12c17530e70f344f44569a369e
3
+ metadata.gz: 84634edd54c519cb0121328a24020bfadc224865
4
+ data.tar.gz: 2b2534a69f942cab18f9b3940788c31cf7c9d591
5
5
  SHA512:
6
- metadata.gz: 1abdb5c3177ea521344bc8011a47edcb2f24470e1c1969ddacc89f0a71303568431b658f74ad823b346c4eeb0a2607929213272972519025623d293f7a226b9c
7
- data.tar.gz: d0d6b3a7f853e30bc905a8a5026bec26089ebec696b06fb0be21e25e391e6ed2dcc80f0776304d823d7712ed6821aa36703af3b4522ce7594b4192a9cdc009d2
6
+ metadata.gz: 584aba3e625e946fedce39d3ce8663c0c0c42397be385ca1a08a909872cb6be8efafa224e06b3a7f411ef8975ebc83e00ae85dde7180c0e08545e181d7c0822d
7
+ data.tar.gz: cf8750d5a9d6bffe5ca10273d517eae8886e12a1f07e8b6a9259e1fef4b46985c2ff9f410e798d0a6164a8de2df496d4c7558a8139b17f84b603083a38bb0d20
data/.travis.yml CHANGED
@@ -8,3 +8,8 @@ rvm:
8
8
  - 2.4.0
9
9
 
10
10
  dist: trusty
11
+
12
+ branches:
13
+ only:
14
+ - master
15
+ - develop
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- ## Bayonet [![Build Status](https://travis-ci.org/Bayonet-Client/bayonet-ruby.svg?branch=master)](https://travis-ci.org/Bayonet-Client/bayonet-ruby)
1
+ ## Bayonet [![Build Status](https://travis-ci.org/bayonetio/bayonet-ruby.svg)](https://travis-ci.org/bayonetio/bayonet-ruby)
2
2
  Bayonet enables companies to feed and consult a global database about online consumers’ reputation, based on historic payments. Start making smarter business decisions today.
3
3
 
4
4
  ### Introduction
@@ -8,12 +8,12 @@ Bayonet’s API is organized around REST and exposes endpoints for HTTP requests
8
8
  Bayonet provides an Ecosystem of Trust and Protection where companies can colaborate with each other to combat online fraud together. We provide a secure platform to share and consult data to understand when a consumer is related to fraudulent activity or has a fraud-free record. Different technologies that run algorithms to link parameters seen in different transactions, fed by companies connected to the ecosystem are employed in order to build consumer profiles. By consulting Bayonet’s API, a response with data provided by companies themselves is available in real-time for your risk assesment process to analyze it and take better decisions.
9
9
 
10
10
  ### Bayonet's API details
11
- To know more about Bayonet's API and its domain and technical details, please see the "Integration Specs V 1.0" document provided by the Bayonet team.
11
+ The examples shown in this README are only for demonstration of the functionality of this SDK. For the detailed integration flow, and when to send which API call, please refer to the Bayonet [API documentation](https://bayonet.io/console/docs).
12
12
 
13
13
  ## Getting started
14
14
  To use this SDK, please make sure:
15
15
  * You have Ruby 2.0 or superior installed on your system.
16
- * You have an API KEY (sandbox and/or live) provided by Bayonet's team.
16
+ * You have an API KEY (sandbox and/or live) generated on your Bayonet console.
17
17
  * Install the 'bayonet_client' package on your system
18
18
 
19
19
  ```sh
@@ -24,109 +24,280 @@ To use this SDK, please make sure:
24
24
  ```sh
25
25
  gem build bayonet_client.gemspec
26
26
  ```
27
+ If you are using Bundler, add this to your Gemfile:
28
+ ```sh
29
+ gem 'bayonet_client'
30
+ ```
27
31
  * Require 'bayonet_client' in your file
28
32
 
29
33
  ```ruby
30
34
  require 'bayonet_client'
31
35
  ```
32
- * Create config options, with parameters (api_key, api_version).
36
+ * Set up your configuration, with parameters (api_key, api_version). The latest stable API version is '2'
33
37
 
34
38
  ```ruby
35
- client = BayonetClient::Client.new(api_key, api_version)
39
+ BayonetClient.configure(api_key, api_version)
36
40
  ```
37
41
 
38
42
  ## Usage
39
- Once you have Bayonet's SDK configured, you can call the three APIs with the following syntax:
40
- * Consulting API
43
+ Once you have Bayonet's SDK configured, you can call the APIs with the following syntax (depending on whether you are integrating for the Ecommerce product or the Lending product):
44
+
45
+ ### Ecommerce
46
+
47
+ * Consulting API
41
48
 
42
49
  ```ruby
43
- client.consulting({
44
- channel: 'mpos',
50
+ BayonetClient::Ecommerce.consulting({
51
+ channel: 'ecommerce',
45
52
  email: 'example@bayonet.io',
46
53
  consumer_name: 'Example name',
54
+ consumer_internal_id: '<your internal ID for this consumer>',
47
55
  cardholder_name: 'Example name',
48
- payment_method: 'card',
56
+ telephone: '1234567890',
49
57
  card_number: '4111111111111111',
50
- transaction_amount: '999',
58
+ transaction_amount: 999.00,
51
59
  currency_code: 'MXN',
52
- transaction_time: '1476012879',
53
- coupon: false,
54
- payment_gateway: 'stripe',
55
60
  shipping_address: {
56
- address_line_1: 'example line 1',
57
- address_line_2: 'example line 2',
61
+ line_1: 'example line 1',
62
+ line_2: 'example line 2',
58
63
  city: 'Mexico City',
59
64
  state: 'Mexico DF',
60
65
  country: 'MEX',
61
66
  zip_code: '64000'
62
- }
67
+ },
68
+ billing_address: {
69
+ line_1: 'example line 1',
70
+ line_2: 'example line 2',
71
+ city: 'Mexico City',
72
+ state: 'Mexico DF',
73
+ country: 'MEX',
74
+ zip_code: '64000'
75
+ },
76
+ payment_method: 'card',
77
+ transaction_time: 1476012879,
78
+ payment_gateway: 'stripe',
79
+ coupon: 'discount_buen_fin',
80
+ expedited_shipping: true,
81
+ products: [
82
+ {
83
+ "product_id": "1",
84
+ "product_name": "product_1",
85
+ "product_price": 500.00,
86
+ "product_category":"example category"
87
+ },
88
+ {
89
+ "product_id": "2",
90
+ "product_name": "product_2",
91
+ "product_price": 499.00,
92
+ "product_category":"example category"
93
+ }
94
+ ],
95
+ bayonet_fingerprint_token: '<token generated by Bayonet fingerprinting JS'
63
96
  })
64
97
  ```
65
- * Feedback API
98
+ * Feedback API
66
99
 
67
100
  ```ruby
68
- client.feedback({
101
+ BayonetClient::Ecommerce.feedback({
102
+ feedback_api_trans_code: '<code returned by the previous consulting response>'
69
103
  transaction_status: 'success',
70
- transaction_id: 'uhffytd65rds56yt',
104
+ transaction_id: '<your internal ID for this transaction>',
71
105
  ...
72
106
  })
73
107
  ```
74
- * Feedback-historical API
108
+ * Feedback-historical API
75
109
 
76
110
  ```ruby
77
- client.feedback_historical({
78
- channel: 'mpos',
79
- type: 'transaction',
111
+ BayonetClient::Ecommerce.feedback_historical({
112
+ channel: 'ecommerce',
80
113
  email: 'example@bayonet.io',
81
114
  consumer_name: 'Example name',
82
- payment_method: 'card',
115
+ consumer_internal_id: '<your internal ID for this consumer>',
116
+ cardholder_name: 'Example name',
117
+ telephone: '1234567890',
83
118
  card_number: '4111111111111111',
84
- transaction_amount: '999',
119
+ transaction_amount: 999.00,
85
120
  currency_code: 'MXN',
86
- transaction_time: '1423823404',
87
- transaction_status: 'bank_decline',
88
- transaction_id: 'uhffytd65rds56yt',
89
- coupon: false,
90
- payment_gateway: 'stripe',
91
- device_fingerprint: 'AF567GHGJJJ87JH',
92
- bank_auth_code: '5353888',
93
- telephone: '0000000000',
94
- expedited_shipping: false,
95
- bank_decline_reason: 'stolen_card',
96
121
  shipping_address: {
97
- address_line_1: 'example line 1',
98
- address_line_2: 'example line 2',
122
+ line_1: 'example line 1',
123
+ line_2: 'example line 2',
99
124
  city: 'Mexico City',
100
125
  state: 'Mexico DF',
101
126
  country: 'MEX',
102
127
  zip_code: '64000'
128
+ },
129
+ billing_address: {
130
+ line_1: 'example line 1',
131
+ line_2: 'example line 2',
132
+ city: 'Mexico City',
133
+ state: 'Mexico DF',
134
+ country: 'MEX',
135
+ zip_code: '64000'
136
+ },
137
+ payment_method: 'card',
138
+ transaction_time: 1476012879,
139
+ payment_gateway: 'stripe',
140
+ coupon: 'discount_buen_fin',
141
+ expedited_shipping: true,
142
+ products: [
143
+ {
144
+ "product_id": "1",
145
+ "product_name": "product_1",
146
+ "product_price": 500.00,
147
+ "product_category":"example category"
148
+ },
149
+ {
150
+ "product_id": "2",
151
+ "product_name": "product_2",
152
+ "product_price": 499.00,
153
+ "product_category":"example category"
154
+ }
155
+ ],
156
+ transaction_status: 'success',
157
+ transaction_id: '<your internal ID for this transaction>'
158
+ })
159
+ ```
160
+
161
+ ### Lending
162
+ * Report Transaction (Request for loan received)
163
+
164
+ ```ruby
165
+ BayonetClient::Lending.report_transaction({
166
+ email: 'example@bayonet.io',
167
+ consumer_name: 'Example name',
168
+ consumer_internal_id: '<your internal ID for this consumer>',
169
+ telephone_fixed: '1234567890',
170
+ telephone_mobile: '1234567891',
171
+ telephone_reference_1: '1234567892',
172
+ telephone_reference_2: '1234567893',
173
+ telephone_reference_3: '1234567894',
174
+ rfc: 'Example RFC',
175
+ curp: 'Example CURP',
176
+ address: {
177
+ line_1: 'example line 1',
178
+ line_2: 'example line 2',
179
+ city: 'Mexico City',
180
+ state: 'Mexico DF',
181
+ country: 'MEX',
182
+ zip_code: '64000'
183
+ },
184
+ transaction_category: 'p2p_lending',
185
+ transaction_id: '<your internal ID for this transaction>',
186
+ transaction_time: 1476012879
187
+ })
188
+ ```
189
+
190
+ * Report Transaction (Request for loan received) + Consult
191
+
192
+ This lets you report a transaction (solicitud) and consult Bayonet at the same time. The only difference from the above method (Report Transaction) is that this method will also return a consult response
193
+
194
+ ```ruby
195
+ BayonetClient::Lending.report_transaction_and_consult({
196
+ email: 'example@bayonet.io',
197
+ consumer_name: 'Example name',
198
+ consumer_internal_id: '<your internal ID for this consumer>',
199
+ telephone_fixed: '1234567890',
200
+ telephone_mobile: '1234567891',
201
+ telephone_reference_1: '1234567892',
202
+ telephone_reference_2: '1234567893',
203
+ telephone_reference_3: '1234567894',
204
+ rfc: 'Example RFC',
205
+ curp: 'Example CURP',
206
+ address: {
207
+ line_1: 'example line 1',
208
+ line_2: 'example line 2',
209
+ city: 'Mexico City',
210
+ state: 'Mexico DF',
211
+ country: 'MEX',
212
+ zip_code: '64000'
213
+ },
214
+ transaction_category: 'p2p_lending',
215
+ transaction_id: '<your internal ID for this transaction>',
216
+ transaction_time: 1476012879
217
+ })
218
+ ```
219
+ * Consult (consult the persona present in the transaction)
220
+
221
+ ```ruby
222
+ BayonetClient::Lending.consult({
223
+ transaction_id: '<transaction ID that you used when reporting the transaction or solicitud>'
224
+ })
225
+ ```
226
+ * Feedback (send feedback regarding a transaction - raise alert or block the user)
227
+
228
+ ```ruby
229
+ BayonetClient::Lending.feedback({
230
+ transaction_id: '<transaction ID that you used when reporting the transaction or solicitud>',
231
+ actions: {
232
+ alert: true,
233
+ block: true
234
+ }
235
+ })
236
+ ```
237
+ * Feedback historical (for reporting historical transactions that were not sent to Bayonet)
238
+
239
+ ```ruby
240
+ BayonetClient::Lending.feedback_historical({
241
+ email: 'example@bayonet.io',
242
+ consumer_name: 'Example name',
243
+ consumer_internal_id: '<your internal ID for this consumer>',
244
+ telephone_fixed: '1234567890',
245
+ telephone_mobile: '1234567891',
246
+ telephone_reference_1: '1234567892',
247
+ telephone_reference_2: '1234567893',
248
+ telephone_reference_3: '1234567894',
249
+ rfc: 'Example RFC',
250
+ curp: 'Example CURP',
251
+ address: {
252
+ line_1: 'example line 1',
253
+ line_2: 'example line 2',
254
+ city: 'Mexico City',
255
+ state: 'Mexico DF',
256
+ country: 'MEX',
257
+ zip_code: '64000'
258
+ },
259
+ transaction_category: 'p2p_lending',
260
+ transaction_id: '<your internal ID for this transaction>',
261
+ transaction_time: 1476012879,
262
+ actions: {
263
+ alert: true,
264
+ block: false
103
265
  }
104
266
  })
105
267
  ```
268
+ ### Device Fingerprint
269
+ * Get-fingerprint-data API
270
+
271
+ You can use this endpoint to get detailed information about a fingerprint generated by the Bayonet fingerprinting JS installed on your front-end
272
+
273
+ ```ruby
274
+ BayonetClient::DeviceFingerprint.get_fingerprint_data({
275
+ bayonet_fingerprint_token: '<fingerprint-token-generated-by-JS-snippet>'
276
+ })
277
+ ```
106
278
 
107
279
  ## Error handling
108
- Bayonet's SDK raises exceptions both when setting up the client object and executing functions:
280
+ Bayonet's SDK raises exceptions both when confguring the client object and executing functions:
109
281
  ```ruby
110
282
  begin
111
- client = bayonet.BayonetClient(api_key, api_version)
112
- rescue BayonetClient::InvalidClientSetupError => e
113
- puts e.message
283
+ BayonetClient.configure(api_key, api_version)
284
+ rescue BayonetClient::BayonetError => e
285
+ puts e.reason_code
286
+ puts e.reason_message
114
287
  end
115
- ```
116
288
 
117
- ```ruby
118
289
  begin
119
- client.consulting(params) # Or, client.feedback(params) Or, client.feedback_historical(params)
290
+ BayonetClient::Ecommerce.consulting(params)
120
291
  rescue BayonetClient::BayonetError => e
121
292
  puts e.reason_code
122
293
  puts e.reason_message
123
294
  end
124
295
  ```
125
296
 
126
- For a full list of error codes and their messages, please refer to the Bayonet API documentation.
297
+ For a full list of error codes and their messages, please refer to the Bayonet [API documentation](https://bayonet.io/console/docs).
127
298
 
128
299
  ## Testing
129
- You can run the test suite with the following command:
300
+ You can run the test suite with the following command (Make sure you set `api_key` and `api_version` environment variables):
130
301
  ```sh
131
302
  bundle exec rake
132
303
  ```
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ['lib']
23
23
 
24
- spec.add_dependency 'httparty', '~> 0.11.0'
24
+ spec.add_dependency 'httparty', '~> 0.15.6'
25
25
 
26
26
  spec.add_development_dependency 'rspec', '~> 3.5'
27
27
  spec.add_development_dependency 'rake'
@@ -2,88 +2,33 @@ require 'httparty'
2
2
  require_relative './bayonet_client/version'
3
3
  require_relative './bayonet_client/response.rb'
4
4
  require_relative './bayonet_client/exceptions.rb'
5
+ require_relative './bayonet_client/ecommerce.rb'
6
+ require_relative './bayonet_client/lending.rb'
7
+ require_relative './bayonet_client/device_fingerprint.rb'
5
8
 
6
9
  module BayonetClient
7
10
 
8
- class Client
9
-
10
- def initialize(api_key, version)
11
-
12
- if version.nil? || version.empty?
13
- message = 'Please specify Api version'
14
- raise BayonetClient::InvalidClientSetupError.new message
15
- elsif !BayonetClient::SUPPORTED_API_VERSIONS.include?(version)
16
- message = 'This library does not support version specified. Consider updating your dependencies'
17
- raise BayonetClient::InvalidClientSetupError.new message
18
- end
19
-
20
- @api_key = api_key
21
- @version = version
11
+ def self.configure(api_key, version)
12
+ if version.nil? || version.empty?
13
+ message = 'Please specify Api version'
14
+ raise BayonetClient::BayonetError.new(nil, nil, nil, nil, -1, message)
22
15
  end
23
-
24
- def consulting(params)
25
- if validate_params(params)
26
- serialized = json_from_params(params)
27
- request('/consulting', serialized)
28
- else
29
- raise BayonetClient::BayonetError.new(params, '', '', 'Invalid params. Please make sure you pass a params hash')
30
- end
31
- end
32
-
33
- def feedback(params)
34
- serialized = json_from_params(params)
35
- request('/feedback', serialized)
16
+ if api_key.nil? || api_key.empty?
17
+ message = 'Please specify Api key'
18
+ raise BayonetClient::BayonetError.new(nil, nil, nil, nil, -1, message)
36
19
  end
37
-
38
- def feedback_historical(params)
39
- serialized = json_from_params(params)
40
- request('/feedback-historical', serialized)
41
- end
42
-
43
- def get_fingerprint_data(params)
44
- serialized = json_from_params(params)
45
- request('/get-fingerprint-data', serialized)
46
- end
47
-
48
- def validate_params(params)
49
- params.class == Hash
20
+ unless BayonetClient::SUPPORTED_API_VERSIONS.include?(version)
21
+ message = 'This library does not support the version specified. Please consider updating your dependencies'
22
+ raise BayonetClient::BayonetError.new(nil, nil, nil, nil, -1, message)
50
23
  end
51
24
 
52
- def json_from_params(params)
53
- # Add api_key to params
54
- params[:api_key] = @api_key
55
- params.to_json
56
- end
57
-
58
- def request(route, json_params)
59
- request_json_string(route, json_params)
60
- end
61
-
62
- def request_json_string(route, request_json_args)
63
- fq_hostname = fully_qualified_api_host_name(route)
64
- url = "#{fq_hostname}#{route}"
65
-
66
- headers = {'User-Agent' => 'OfficialBayonetRubySDK',
67
- 'Content-Type' => 'application/json', 'Accept' => 'application/json'}
68
-
69
- raw_resp = HTTParty.post(
70
- url, body: request_json_args, headers: headers, verify: false)
71
-
72
- if raw_resp.code == 200
73
- BayonetClient::BayonetResponse.new(raw_resp)
74
- else
75
- raise BayonetClient::BayonetError.new(request_json_args, headers, raw_resp.code, raw_resp)
76
- end
77
- end
25
+ @api_key = api_key
26
+ @version = version
27
+ end
78
28
 
79
- def fully_qualified_api_host_name(route)
80
- default_domain = 'api.bayonet.io'
81
- if route == '/get-fingerprint-data'
82
- default_domain = 'fingerprinting.bayonet.io'
83
- end
84
- api_version_namespace = 'v' + @version
85
- "https://#{default_domain}/#{api_version_namespace}"
86
- end
29
+ class << self
30
+ attr_reader :api_key
31
+ attr_reader :version
87
32
  end
88
33
 
89
34
  end
@@ -0,0 +1,57 @@
1
+ require_relative '../bayonet_client.rb'
2
+
3
+ module BayonetClient
4
+ class ApiHelper
5
+ def self.validate_params(params)
6
+ params.class == Hash
7
+ end
8
+
9
+ def self.json_from_params(params, route)
10
+ # Add api_key to params
11
+ if route == '/get-fingerprint-data'
12
+ params[:api_key] = BayonetClient.api_key
13
+ else
14
+ params[:auth] = {}
15
+ params[:auth][:api_key] = BayonetClient.api_key
16
+ end
17
+ params.to_json
18
+ end
19
+
20
+ def self.request(route, params)
21
+ unless validate_params(params)
22
+ raise BayonetClient::BayonetError.new(params, '', '', 'Invalid params. Please make sure you pass a params hash')
23
+ end
24
+ json_params = json_from_params(params, route)
25
+ request_json_string(route, json_params)
26
+ end
27
+
28
+ def self.request_json_string(route, request_json_args)
29
+ fq_hostname = fully_qualified_api_host_name(route)
30
+ url = "#{fq_hostname}#{route}"
31
+
32
+ headers = {'User-Agent' => 'OfficialBayonetRubySDK',
33
+ 'Content-Type' => 'application/json', 'Accept' => 'application/json'}
34
+
35
+ raw_resp = HTTParty.post(
36
+ url, body: request_json_args, headers: headers, verify: false)
37
+
38
+ if raw_resp.code == 200
39
+ BayonetClient::BayonetResponse.new(raw_resp)
40
+ else
41
+ raise BayonetClient::BayonetError.new(request_json_args, headers, raw_resp.code, raw_resp)
42
+ end
43
+ end
44
+
45
+ def self.fully_qualified_api_host_name(route)
46
+ default_domain = 'api.bayonet.io'
47
+ api_version_namespace = 'v' + BayonetClient.version
48
+ if route == '/get-fingerprint-data'
49
+ default_domain = 'fingerprinting.bayonet.io'
50
+ if BayonetClient.version == '2'
51
+ api_version_namespace = 'v1'
52
+ end
53
+ end
54
+ "https://#{default_domain}/#{api_version_namespace}"
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,11 @@
1
+ require_relative './api_helper.rb'
2
+
3
+ module BayonetClient
4
+
5
+ class DeviceFingerprint
6
+ def self.get_fingerprint_data(params)
7
+ BayonetClient::ApiHelper.request('/get-fingerprint-data', params)
8
+ end
9
+ end
10
+
11
+ end
@@ -0,0 +1,39 @@
1
+ require_relative './api_helper.rb'
2
+
3
+ module BayonetClient
4
+
5
+ class Ecommerce
6
+ def self.consulting(params)
7
+ BayonetClient::ApiHelper.request('/consulting', params)
8
+ end
9
+
10
+ def self.feedback(params)
11
+ BayonetClient::ApiHelper.request('/feedback', params)
12
+ end
13
+
14
+ def self.feedback_historical(params)
15
+ BayonetClient::ApiHelper.request('/feedback-historical', params)
16
+ end
17
+
18
+ def self.update_transaction(params)
19
+ BayonetClient::ApiHelper.request('/update-transaction', params)
20
+ end
21
+
22
+ def self.whitelist(params)
23
+ BayonetClient::ApiHelper.request('/labels/whitelist/add', params)
24
+ end
25
+
26
+ def self.remove_from_whitelist(params)
27
+ BayonetClient::ApiHelper.request('/labels/whitelist/remove', params)
28
+ end
29
+
30
+ def self.block(params)
31
+ BayonetClient::ApiHelper.request('/labels/block/add', params)
32
+ end
33
+
34
+ def self.remove_from_block(params)
35
+ BayonetClient::ApiHelper.request('/labels/block/remove', params)
36
+ end
37
+ end
38
+
39
+ end
@@ -4,14 +4,16 @@ module BayonetClient
4
4
 
5
5
  class BayonetError < Exception
6
6
  attr_accessor :request_body, :request_headers, :http_response_code, :http_response_json,
7
- :reason_code, :reason_message, :status
7
+ :reason_code, :reason_message
8
8
 
9
9
  def initialize(request_body, request_headers,
10
- http_response_code, http_response_json)
10
+ http_response_code, http_response_json, reason_code = nil, reason_message = nil)
11
11
  self.request_body = request_body
12
12
  self.request_headers = request_headers
13
13
  self.http_response_code = http_response_code
14
14
  self.http_response_json = http_response_json
15
+ self.reason_code = reason_code
16
+ self.reason_message = reason_message
15
17
 
16
18
  # Get reason_code and reason_message from response
17
19
  if http_response_json.class == HTTParty::Response && http_response_json.key?('reason_code')
@@ -19,16 +21,12 @@ module BayonetClient
19
21
  end
20
22
  if http_response_json.class == HTTParty::Response && http_response_json.key?('reason_message')
21
23
  self.reason_message = http_response_json['reason_message']
22
- else
23
- self.reason_message = http_response_json
24
24
  end
25
25
  if http_response_json.class == HTTParty::Response && http_response_json.key?('status')
26
- self.status = http_response_json['status']
26
+ self.reason_message = http_response_json['status']
27
+ self.reason_code = -1
27
28
  end
28
29
  end
29
30
  end
30
31
 
31
- class InvalidClientSetupError < Exception
32
- end
33
-
34
32
  end
@@ -0,0 +1,27 @@
1
+ require_relative './api_helper.rb'
2
+
3
+ module BayonetClient
4
+
5
+ class Lending
6
+ def self.report_transaction(params)
7
+ BayonetClient::ApiHelper.request('/lending/transaction/report', params)
8
+ end
9
+
10
+ def self.report_transaction_and_consult(params)
11
+ BayonetClient::ApiHelper.request('/lending/transaction/report?consult=true', params)
12
+ end
13
+
14
+ def self.consult(params)
15
+ BayonetClient::ApiHelper.request('/lending/consult', params)
16
+ end
17
+
18
+ def self.feedback(params)
19
+ BayonetClient::ApiHelper.request('/lending/feedback', params)
20
+ end
21
+
22
+ def self.feedback_historical(params)
23
+ BayonetClient::ApiHelper.request('/lending/feedback-historical', params)
24
+ end
25
+ end
26
+
27
+ end
@@ -1,4 +1,4 @@
1
1
  module BayonetClient
2
- VERSION = '1.1.0'
3
- SUPPORTED_API_VERSIONS = ['1']
2
+ VERSION = '2.1.0'
3
+ SUPPORTED_API_VERSIONS = ['2']
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bayonet_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bayonet
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-05 00:00:00.000000000 Z
11
+ date: 2017-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.11.0
19
+ version: 0.15.6
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.11.0
26
+ version: 0.15.6
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -69,7 +69,11 @@ files:
69
69
  - bin/console
70
70
  - bin/setup
71
71
  - lib/bayonet_client.rb
72
+ - lib/bayonet_client/api_helper.rb
73
+ - lib/bayonet_client/device_fingerprint.rb
74
+ - lib/bayonet_client/ecommerce.rb
72
75
  - lib/bayonet_client/exceptions.rb
76
+ - lib/bayonet_client/lending.rb
73
77
  - lib/bayonet_client/response.rb
74
78
  - lib/bayonet_client/version.rb
75
79
  homepage: https://bayonet.io