carrierbot_api 0.3.0 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/Gemfile.lock +2 -2
- data/{carrierbot_rates.gemspec → carrierbot_api.gemspec} +0 -0
- data/lib/carrierbot_api/fulfillment.rb +5 -1
- data/lib/carrierbot_api/rates_request.rb +20 -3
- data/lib/carrierbot_api/version.rb +1 -1
- metadata +8 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb4d4e63fd74de21dc372de5509a1a5c29464b8065068d7f1cbc10406e84955c
|
4
|
+
data.tar.gz: 1e9d7becf42f3f5843e4856f24011ef474c105671bb18ccc012cb6d8dc4a82a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac47973027942b2b400bff720ef059496a5e80dd729bef046e50e6bfad1063d1977dd21cc6cf672accb748c385a5639f6f8a0ffde6256f50b154d325c6f5571e
|
7
|
+
data.tar.gz: 1dd3f8f8eee6265d834f835d1475cb709db830c3b3686241ce7a149ee1a673b396c16a501f12b7b5620f6d9b1fb29b5e1be9cdf6a3bfb4ebaf97183c478a0dfd
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
File without changes
|
@@ -1,14 +1,16 @@
|
|
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, :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]
|
13
|
+
@destination = data[:destination]
|
12
14
|
@items = data[:items]
|
13
15
|
end
|
14
16
|
|
@@ -18,8 +20,10 @@ module CarrierBotAPI
|
|
18
20
|
'fulfilled_at': self.fulfilled_at,
|
19
21
|
'total_price': self.total_price,
|
20
22
|
'service_code': self.service_code,
|
23
|
+
'shipping_code': self.shipping_code,
|
21
24
|
'order_id': self.order_id,
|
22
25
|
'fulfillment_id': self.fulfillment_id,
|
26
|
+
'destination': self.destination&.to_json,
|
23
27
|
'items': self.items.map(&:to_json)
|
24
28
|
}
|
25
29
|
end
|
@@ -35,25 +35,42 @@ 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
43
|
'origin': @origin.to_json,
|
44
|
-
'destination': destination
|
44
|
+
'destination': destination&.to_json,
|
45
45
|
'items': items.map(&:to_json),
|
46
46
|
'fulfillments': fulfillments.map(&:to_json),
|
47
47
|
'currency': 'JPY', 'locale': 'en'
|
48
48
|
}
|
49
49
|
}
|
50
50
|
|
51
|
-
response = conn.post
|
51
|
+
response = conn.post @url, request
|
52
52
|
raise "could not retrieve shipping rates - #{response.reason_phrase}\nrequest: #{request}" \
|
53
53
|
unless response.success?
|
54
54
|
|
55
55
|
rates = JSON.parse(response.body)['rates']
|
56
56
|
rates
|
57
57
|
end
|
58
|
+
|
59
|
+
def batch_get(fulfillments: [])
|
60
|
+
conn = Faraday.new(url: @url)
|
61
|
+
|
62
|
+
request = {
|
63
|
+
'origin': @origin.to_json,
|
64
|
+
'fulfillments': fulfillments.map(&:to_json),
|
65
|
+
'currency': 'JPY', 'locale': 'en'
|
66
|
+
}
|
67
|
+
|
68
|
+
response = conn.post '/api/v1/batch_requests', request
|
69
|
+
raise "could not retrieve shipping rates - #{response.reason_phrase}\nrequest: #{request}" \
|
70
|
+
unless response.success?
|
71
|
+
|
72
|
+
JSON.parse(response.body)
|
73
|
+
end
|
74
|
+
|
58
75
|
end
|
59
76
|
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.5.2
|
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-15 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: []
|
@@ -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
|
@@ -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: []
|