carrierbot_api 0.3.0 → 0.4.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7102e4cf0afd6571dd4729cb73e74aad463ed44eb3739015cdd2c0c30d12fa04
|
4
|
+
data.tar.gz: 1c9818bfaa3ce9a3b85e892fa4389a8f61b0186b5782c0fc473ce229bf4bd60f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 889627e2ab2f28ac41d11515cb93479b13fd838cfe7adf9115ad5a504ea9402386024652bb81637bdb7ee67943cc757669a5567df7d4f84558c4e1458b718880
|
7
|
+
data.tar.gz: 306d403433f11642e2d08f1bc5b912e4e92d1e6a5f0e5426a8e5691622d54ff5707c776c248a701a6c3659bc36e00374e5125d3fb9116f76ca4a9eb761e54ac2
|
data/.gitignore
CHANGED
File without changes
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module CarrierBotAPI
|
2
2
|
class Fulfillment
|
3
|
-
attr_reader :ordered_at, :fulfilled_at, :total_price, :service_code, :order_id, :fulfillment_id, :items
|
3
|
+
attr_reader :ordered_at, :fulfilled_at, :total_price, :service_code, :order_id, :fulfillment_id, :destination, :items
|
4
4
|
|
5
5
|
def initialize(data)
|
6
6
|
@ordered_at = data[:ordered_at]
|
@@ -9,6 +9,7 @@ module CarrierBotAPI
|
|
9
9
|
@service_code = data[:service_code]
|
10
10
|
@order_id = data[:order_id]
|
11
11
|
@fulfillment_id = data[:fulfillment_id]
|
12
|
+
@destination = data[:destination]
|
12
13
|
@items = data[:items]
|
13
14
|
end
|
14
15
|
|
@@ -20,6 +21,7 @@ module CarrierBotAPI
|
|
20
21
|
'service_code': self.service_code,
|
21
22
|
'order_id': self.order_id,
|
22
23
|
'fulfillment_id': self.fulfillment_id,
|
24
|
+
'destination': self.destination&.to_json,
|
23
25
|
'items': self.items.map(&:to_json)
|
24
26
|
}
|
25
27
|
end
|
@@ -35,13 +35,14 @@ module CarrierBotAPI
|
|
35
35
|
company_name: origin_company_name)
|
36
36
|
end
|
37
37
|
|
38
|
-
def get(destination
|
38
|
+
def get(destination: nil, items: [], fulfillments: [])
|
39
39
|
conn = Faraday.new(url: @url)
|
40
40
|
|
41
41
|
request = {
|
42
42
|
'rate': {
|
43
|
+
'is_batch': is_batch,
|
43
44
|
'origin': @origin.to_json,
|
44
|
-
'destination': destination
|
45
|
+
'destination': destination&.to_json,
|
45
46
|
'items': items.map(&:to_json),
|
46
47
|
'fulfillments': fulfillments.map(&:to_json),
|
47
48
|
'currency': 'JPY', 'locale': 'en'
|
@@ -55,5 +56,25 @@ module CarrierBotAPI
|
|
55
56
|
rates = JSON.parse(response.body)['rates']
|
56
57
|
rates
|
57
58
|
end
|
59
|
+
|
60
|
+
def batch_get(fulfillments: [])
|
61
|
+
conn = Faraday.new(url: @url)
|
62
|
+
|
63
|
+
request = {
|
64
|
+
'rate': {
|
65
|
+
'is_batch': true,
|
66
|
+
'origin': @origin.to_json,
|
67
|
+
'fulfillments': fulfillments.map(&:to_json),
|
68
|
+
'currency': 'JPY', 'locale': 'en'
|
69
|
+
}
|
70
|
+
}
|
71
|
+
|
72
|
+
response = conn.post '/api/v1/requests', request
|
73
|
+
raise "could not retrieve shipping rates - #{response.reason_phrase}\nrequest: #{request}" \
|
74
|
+
unless response.success?
|
75
|
+
|
76
|
+
JSON.parse(response.body)
|
77
|
+
end
|
78
|
+
|
58
79
|
end
|
59
80
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierbot_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shaun
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -69,7 +69,7 @@ files:
|
|
69
69
|
- Rakefile
|
70
70
|
- bin/console
|
71
71
|
- bin/setup
|
72
|
-
-
|
72
|
+
- carrierbot_api.gemspec
|
73
73
|
- lib/carrierbot_api.rb
|
74
74
|
- lib/carrierbot_api/.DS_Store
|
75
75
|
- lib/carrierbot_api/address.rb
|