carrierbot_api 0.3.0 → 0.5.2

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
  SHA256:
3
- metadata.gz: 4ae635e5b60396c6231e800ee2cabe3a843cbc3d0dfa3b7813d461d21e1c4449
4
- data.tar.gz: ff7879ded0c91b72bd17d85a271a359ea29d607a62f25a4b4a2a1d8d0a401fe1
3
+ metadata.gz: eb4d4e63fd74de21dc372de5509a1a5c29464b8065068d7f1cbc10406e84955c
4
+ data.tar.gz: 1e9d7becf42f3f5843e4856f24011ef474c105671bb18ccc012cb6d8dc4a82a0
5
5
  SHA512:
6
- metadata.gz: 6face818d25fc426a22d618a7870f31cae20b20b6a8ccb5c0296f7ebe838eab9bcbe26689e329667e4aff0a39f9d06674de1f864a47acfee09e57c181cb58467
7
- data.tar.gz: 3f74e0091b41d14d918c5b0e85d2ce8e9ade22d1998411eb05b9dd6946e56d0770c5073ce7c6d6649660439d3abaf635e9829b7c1ee8f9b2354ed1746ebe80d3
6
+ metadata.gz: ac47973027942b2b400bff720ef059496a5e80dd729bef046e50e6bfad1063d1977dd21cc6cf672accb748c385a5639f6f8a0ffde6256f50b154d325c6f5571e
7
+ data.tar.gz: 1dd3f8f8eee6265d834f835d1475cb709db830c3b3686241ce7a149ee1a673b396c16a501f12b7b5620f6d9b1fb29b5e1be9cdf6a3bfb4ebaf97183c478a0dfd
data/.gitignore CHANGED
@@ -6,4 +6,3 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
- carrierbot_api-0.1.0.gem
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- carrierbot_api (0.3.0)
4
+ carrierbot_api (0.5.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -19,4 +19,4 @@ DEPENDENCIES
19
19
  rake (~> 10.0)
20
20
 
21
21
  BUNDLED WITH
22
- 1.16.6
22
+ 1.17.2
@@ -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:, items: [], fulfillments: [])
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.to_json,
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 '/api/v1/requests', request
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
@@ -1,3 +1,3 @@
1
1
  module CarrierBotAPI
2
- VERSION = "0.3.0"
2
+ VERSION = "0.5.2"
3
3
  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.3.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: 2020-06-15 00:00:00.000000000 Z
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
- - carrierbot_rates.gemspec
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
- rubyforge_project:
103
- rubygems_version: 2.7.8
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: []