carrierbot_api 0.4.0 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/carrierbot_api/fulfillment.rb +3 -1
- data/lib/carrierbot_api/rates_request.rb +8 -10
- data/lib/carrierbot_api/version.rb +1 -1
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1664b12b8dec670f218635b7f954cc4a18ef2039020106da938a614b99bdf09
|
4
|
+
data.tar.gz: d4936317ef04de6493c80a894a4ca2be7a82614190e8ddb3f19c741ad0f4fcb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 427fef2216b9162b9ef5ca302305c716669b7386458269931c714dc0cc3aec43156f5ca3c19e8fbb97be1fb528d38a451e6cb6cb3e6737d1aa6337fd0bc5bcda
|
7
|
+
data.tar.gz: df327d32fc1bf2a9ae94061249839fe8bc9a516c0602bec8c3d86fd57062f9e0483ba0517c38c91e1d85cf9286ab639388308f27551bd4abfe67e606f2c4f73c
|
data/Gemfile.lock
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
module CarrierBotAPI
|
2
2
|
class Fulfillment
|
3
|
-
attr_reader :ordered_at, :fulfilled_at, :total_price, :service_code, :order_id, :fulfillment_id, :destination, :items
|
3
|
+
attr_reader :ordered_at, :fulfilled_at, :total_price, :service_code, :shipping_code, :order_id, :fulfillment_id, :destination, :items
|
4
4
|
|
5
5
|
def initialize(data)
|
6
6
|
@ordered_at = data[:ordered_at]
|
7
7
|
@fulfilled_at = data[:fulfilled_at]
|
8
8
|
@total_price = data[:total_price]
|
9
|
+
@shipping_code = data[:shipping_code]
|
9
10
|
@service_code = data[:service_code]
|
10
11
|
@order_id = data[:order_id]
|
11
12
|
@fulfillment_id = data[:fulfillment_id]
|
@@ -19,6 +20,7 @@ module CarrierBotAPI
|
|
19
20
|
'fulfilled_at': self.fulfilled_at,
|
20
21
|
'total_price': self.total_price,
|
21
22
|
'service_code': self.service_code,
|
23
|
+
'shipping_code': self.shipping_code,
|
22
24
|
'order_id': self.order_id,
|
23
25
|
'fulfillment_id': self.fulfillment_id,
|
24
26
|
'destination': self.destination&.to_json,
|
@@ -36,11 +36,8 @@ module CarrierBotAPI
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def get(destination: nil, items: [], fulfillments: [])
|
39
|
-
conn = Faraday.new(url: @url)
|
40
|
-
|
41
39
|
request = {
|
42
40
|
'rate': {
|
43
|
-
'is_batch': is_batch,
|
44
41
|
'origin': @origin.to_json,
|
45
42
|
'destination': destination&.to_json,
|
46
43
|
'items': items.map(&:to_json),
|
@@ -49,27 +46,28 @@ module CarrierBotAPI
|
|
49
46
|
}
|
50
47
|
}
|
51
48
|
|
52
|
-
|
49
|
+
get_raw(request)
|
50
|
+
end
|
51
|
+
|
52
|
+
def get_raw(request)
|
53
|
+
conn = Faraday.new(url: @url)
|
54
|
+
response = conn.post @url, request
|
53
55
|
raise "could not retrieve shipping rates - #{response.reason_phrase}\nrequest: #{request}" \
|
54
56
|
unless response.success?
|
55
57
|
|
56
|
-
|
57
|
-
rates
|
58
|
+
JSON.parse(response.body)['rates']
|
58
59
|
end
|
59
60
|
|
60
61
|
def batch_get(fulfillments: [])
|
61
62
|
conn = Faraday.new(url: @url)
|
62
63
|
|
63
64
|
request = {
|
64
|
-
'rate': {
|
65
|
-
'is_batch': true,
|
66
65
|
'origin': @origin.to_json,
|
67
66
|
'fulfillments': fulfillments.map(&:to_json),
|
68
67
|
'currency': 'JPY', 'locale': 'en'
|
69
|
-
}
|
70
68
|
}
|
71
69
|
|
72
|
-
response = conn.post '/api/v1/
|
70
|
+
response = conn.post '/api/v1/batch_requests', request
|
73
71
|
raise "could not retrieve shipping rates - #{response.reason_phrase}\nrequest: #{request}" \
|
74
72
|
unless response.success?
|
75
73
|
|
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.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shaun
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '5.0'
|
55
|
-
description:
|
55
|
+
description:
|
56
56
|
email:
|
57
57
|
- shaun@brewkeeper.com.au
|
58
58
|
executables: []
|
@@ -84,7 +84,7 @@ metadata:
|
|
84
84
|
homepage_uri: https://gitlab.com/brewkeeper/carrierbot_api
|
85
85
|
source_code_uri: https://gitlab.com/brewkeeper/carrierbot_api
|
86
86
|
changelog_uri: https://gitlab.com/brewkeeper/carrierbot_api/-/blob/master/CHANGELOG.md
|
87
|
-
post_install_message:
|
87
|
+
post_install_message:
|
88
88
|
rdoc_options: []
|
89
89
|
require_paths:
|
90
90
|
- lib
|
@@ -99,9 +99,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
99
|
- !ruby/object:Gem::Version
|
100
100
|
version: '0'
|
101
101
|
requirements: []
|
102
|
-
|
103
|
-
|
104
|
-
signing_key:
|
102
|
+
rubygems_version: 3.0.8
|
103
|
+
signing_key:
|
105
104
|
specification_version: 4
|
106
105
|
summary: Connect to CarrierBot API
|
107
106
|
test_files: []
|