bayonet_client 2.2.1 → 2.3.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 +4 -4
- data/README.md +11 -3
- data/lib/bayonet_client.rb +8 -1
- data/lib/bayonet_client/api_helper.rb +9 -4
- data/lib/bayonet_client/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9898dceba28ecd8d1841f018a66ce1246597c890
|
4
|
+
data.tar.gz: 630c301aa4d1df67c9adc7025fe7cbf40099f386
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c0993fc89e3dffa6060ce26466b39def4ff94c7ff4a4c487c51cb440b3224fd885712fb55f9b83edaa55dd56284e17fef4ce850eee9400f81e23a7c8e31afa1
|
7
|
+
data.tar.gz: 48bc50a9289d1677e7e7e497f22c98e41bf888b63e96e53a315e87cf98f238d447e22fbb371a4735998ba24eceea198e3deb03c6dbf76f8347fca7bc11de6c00
|
data/README.md
CHANGED
@@ -38,9 +38,13 @@ To use this SDK, please make sure:
|
|
38
38
|
```ruby
|
39
39
|
BayonetClient.configure(api_key, api_version)
|
40
40
|
```
|
41
|
+
You can also set a timeout value (in seconds):
|
42
|
+
```ruby
|
43
|
+
BayonetClient.configure(api_key, api_version, timeout)
|
44
|
+
```
|
41
45
|
|
42
46
|
## Usage
|
43
|
-
Once you have Bayonet's SDK configured, you can call the APIs with the following syntax.Follow the guidelines specific to the product you are integrating:
|
47
|
+
Once you have Bayonet's SDK configured, you can call the APIs with the following syntax. Follow the guidelines specific to the product you are integrating:
|
44
48
|
|
45
49
|
* [Ecommerce](#ecommerce)
|
46
50
|
|
@@ -78,7 +82,8 @@ Once you have Bayonet's SDK configured, you can call the APIs with the following
|
|
78
82
|
zip_code: '64000'
|
79
83
|
},
|
80
84
|
payment_method: 'card',
|
81
|
-
|
85
|
+
order_id: '<your internal ID for this order (mandatory)>',
|
86
|
+
transaction_id: '<your internal ID for this transaction (optional)>',
|
82
87
|
payment_gateway: 'stripe',
|
83
88
|
coupon: 'discount_buen_fin',
|
84
89
|
expedited_shipping: true,
|
@@ -103,10 +108,13 @@ Once you have Bayonet's SDK configured, you can call the APIs with the following
|
|
103
108
|
|
104
109
|
```ruby
|
105
110
|
BayonetClient::Ecommerce.update-transaction({
|
111
|
+
order_id: '<your internal ID for this order (as sent in the consult step)>',
|
106
112
|
transaction_id: '<your internal ID for this transaction (as sent in the consult step)>',
|
113
|
+
bayonet_tracking_id: '<tracking ID returned by the API in the consult step>',
|
107
114
|
transaction_status: 'success',
|
108
115
|
...
|
109
116
|
})
|
117
|
+
# please note that you can use either one of 'order_id', 'transaction_id', or 'bayonet_tracking_id' to update the status of a transaction
|
110
118
|
```
|
111
119
|
* Feedback-historical API
|
112
120
|
|
@@ -292,7 +300,7 @@ rescue BayonetClient::BayonetError => e
|
|
292
300
|
end
|
293
301
|
|
294
302
|
begin
|
295
|
-
BayonetClient::Ecommerce.
|
303
|
+
BayonetClient::Ecommerce.consult(params)
|
296
304
|
rescue BayonetClient::BayonetError => e
|
297
305
|
puts e.reason_code
|
298
306
|
puts e.reason_message
|
data/lib/bayonet_client.rb
CHANGED
@@ -7,8 +7,9 @@ require_relative './bayonet_client/lending.rb'
|
|
7
7
|
require_relative './bayonet_client/device_fingerprint.rb'
|
8
8
|
|
9
9
|
module BayonetClient
|
10
|
+
DEFAULT_HTTP_TIMEOUT = 10
|
10
11
|
|
11
|
-
def self.configure(api_key, version)
|
12
|
+
def self.configure(api_key, version, timeout = DEFAULT_HTTP_TIMEOUT)
|
12
13
|
if version.nil? || version.empty?
|
13
14
|
message = 'Please specify Api version'
|
14
15
|
raise BayonetClient::BayonetError.new(nil, nil, nil, nil, -1, message)
|
@@ -17,6 +18,10 @@ module BayonetClient
|
|
17
18
|
message = 'Please specify Api key'
|
18
19
|
raise BayonetClient::BayonetError.new(nil, nil, nil, nil, -1, message)
|
19
20
|
end
|
21
|
+
unless timeout.is_a? Numeric
|
22
|
+
message = 'Please specify a valid timeout value'
|
23
|
+
raise BayonetClient::BayonetError.new(nil, nil, nil, nil, -1, message)
|
24
|
+
end
|
20
25
|
unless BayonetClient::SUPPORTED_API_VERSIONS.include?(version)
|
21
26
|
message = 'This library does not support the version specified. Please consider updating your dependencies'
|
22
27
|
raise BayonetClient::BayonetError.new(nil, nil, nil, nil, -1, message)
|
@@ -24,11 +29,13 @@ module BayonetClient
|
|
24
29
|
|
25
30
|
@api_key = api_key
|
26
31
|
@version = version
|
32
|
+
@timeout = timeout
|
27
33
|
end
|
28
34
|
|
29
35
|
class << self
|
30
36
|
attr_reader :api_key
|
31
37
|
attr_reader :version
|
38
|
+
attr_reader :timeout
|
32
39
|
end
|
33
40
|
|
34
41
|
end
|
@@ -30,10 +30,15 @@ module BayonetClient
|
|
30
30
|
url = "#{fq_hostname}#{route}"
|
31
31
|
|
32
32
|
headers = {'User-Agent' => 'OfficialBayonetRubySDK',
|
33
|
-
'Content-Type' => 'application/json',
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
'Content-Type' => 'application/json',
|
34
|
+
'Accept' => 'application/json'}
|
35
|
+
|
36
|
+
begin
|
37
|
+
raw_resp = HTTParty.post(
|
38
|
+
url, body: request_json_args, headers: headers, verify: false, timeout: BayonetClient.timeout)
|
39
|
+
rescue Net::ReadTimeout => e
|
40
|
+
raise BayonetClient::BayonetError.new(request_json_args, headers, nil, nil, -1, 'Request timed out. If you explicitly set a timeout, consider raising the timeout value')
|
41
|
+
end
|
37
42
|
|
38
43
|
if raw_resp.code == 200
|
39
44
|
BayonetClient::BayonetResponse.new(raw_resp)
|
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: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bayonet
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|