carrierbot_api 0.4.0 → 0.5.3

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: 7102e4cf0afd6571dd4729cb73e74aad463ed44eb3739015cdd2c0c30d12fa04
4
- data.tar.gz: 1c9818bfaa3ce9a3b85e892fa4389a8f61b0186b5782c0fc473ce229bf4bd60f
3
+ metadata.gz: d1664b12b8dec670f218635b7f954cc4a18ef2039020106da938a614b99bdf09
4
+ data.tar.gz: d4936317ef04de6493c80a894a4ca2be7a82614190e8ddb3f19c741ad0f4fcb3
5
5
  SHA512:
6
- metadata.gz: 889627e2ab2f28ac41d11515cb93479b13fd838cfe7adf9115ad5a504ea9402386024652bb81637bdb7ee67943cc757669a5567df7d4f84558c4e1458b718880
7
- data.tar.gz: 306d403433f11642e2d08f1bc5b912e4e92d1e6a5f0e5426a8e5691622d54ff5707c776c248a701a6c3659bc36e00374e5125d3fb9116f76ca4a9eb761e54ac2
6
+ metadata.gz: 427fef2216b9162b9ef5ca302305c716669b7386458269931c714dc0cc3aec43156f5ca3c19e8fbb97be1fb528d38a451e6cb6cb3e6737d1aa6337fd0bc5bcda
7
+ data.tar.gz: df327d32fc1bf2a9ae94061249839fe8bc9a516c0602bec8c3d86fd57062f9e0483ba0517c38c91e1d85cf9286ab639388308f27551bd4abfe67e606f2c4f73c
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.2)
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.3
@@ -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
- response = conn.post '/api/v1/requests', request
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
- rates = JSON.parse(response.body)['rates']
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/requests', request
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
 
@@ -1,3 +1,3 @@
1
1
  module CarrierBotAPI
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.3"
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.4.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: 2020-06-16 00:00:00.000000000 Z
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
- 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: []