shippo 2.0.8 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -3
- data/README.md +75 -73
- data/bin/address_validation_example +1 -3
- data/bin/basic_shipment_example +3 -7
- data/bin/batch_example +3 -35
- data/bin/config.rb +9 -0
- data/bin/track_example +2 -14
- data/lib/shippo/api.rb +1 -1
- data/lib/shippo/api/api_object.rb +2 -6
- data/lib/shippo/api/transformers/list.rb +1 -1
- data/lib/shippo/api/version.rb +1 -1
- data/shippo.gemspec +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 393dfce62838fc0a561ca7fb4dd8288d4edaa6ff
|
4
|
+
data.tar.gz: 9c2079d2a39600fc48aa5f339514a1396be92624
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33057b1a620e09ca1121fe23cdbc3810487e89319e8c33c32d400bfffa6a84dc2aee6ff7df8d7c7a3e1a4b291ac53b0058bb46ea6dc5d50b30bdf955c0664aa0
|
7
|
+
data.tar.gz: ef92a6f81a4e72eabfd9ce7b127be2fc3a00c900a4e0ee127aacca46f2d1263be580e277ff2ac5a15b706d96ff54e993e0c85e975568ebf0e4f7f7ab84a52227
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
|
1
|
+
#### 3.0.0 release, Mar 31st, 2017
|
2
|
+
- Version 3 changes
|
3
|
+
- Object fields removed/updated
|
4
|
+
- Credentials inserted for tests
|
5
|
+
|
6
|
+
#### 2.0.8 release, Feb 15th, 2017
|
2
7
|
- Add Batch API with example code
|
3
8
|
- Creation
|
4
9
|
- Retrieval
|
@@ -11,12 +16,12 @@
|
|
11
16
|
- Add mock tests using VCR (for Batch and Track API)
|
12
17
|
- https://github.com/vcr/vcr
|
13
18
|
|
14
|
-
|
19
|
+
#### 2.0.7 release, Jan 2nd, 2017
|
15
20
|
- Fixed bug preventing address validation
|
16
21
|
- Removed trailing slash from base URL, added spec test to ensure this configuration
|
17
22
|
- Added address validation example
|
18
23
|
- Updated basic shipment example to include how to access the Shippo object id
|
19
|
-
|
24
|
+
#### 2.0.6 release, Nov 22nd, 2016
|
20
25
|
- Fixed bug to send request with correct API version header
|
21
26
|
|
22
27
|
#### 2.0.5 release, Oct 24th, 2016
|
data/README.md
CHANGED
@@ -45,10 +45,8 @@ require 'shippo'
|
|
45
45
|
Shippo::API.token = 'aff988f77afa0fdfdfadf' # not an actual valid token
|
46
46
|
|
47
47
|
# Setup query parameter hash
|
48
|
-
params = {
|
49
|
-
async: false,
|
48
|
+
params = { async: false,
|
50
49
|
address_from: {
|
51
|
-
object_purpose: 'PURCHASE',
|
52
50
|
name: 'Mr Hippo',
|
53
51
|
company: 'Shippo',
|
54
52
|
street1: '215 Clayton St.',
|
@@ -57,10 +55,8 @@ params = { object_purpose: 'PURCHASE',
|
|
57
55
|
state: 'CA',
|
58
56
|
zip: '94117',
|
59
57
|
country: 'US',
|
60
|
-
phone: '+1 555 341 9393',
|
61
|
-
email: 'support@goshippo.com' },
|
58
|
+
phone: '+1 555 341 9393' },
|
62
59
|
address_to: {
|
63
|
-
object_purpose: 'PURCHASE',
|
64
60
|
name: 'Mrs Hippo"',
|
65
61
|
company: 'San Diego Zoo',
|
66
62
|
street1: '2920 Zoo Drive',
|
@@ -70,7 +66,7 @@ params = { object_purpose: 'PURCHASE',
|
|
70
66
|
country: 'US',
|
71
67
|
phone: '+1 555 341 9393',
|
72
68
|
email: 'hippo@goshippo.com' },
|
73
|
-
|
69
|
+
parcels: {
|
74
70
|
length: 5,
|
75
71
|
width: 2,
|
76
72
|
height: 5,
|
@@ -83,12 +79,8 @@ params = { object_purpose: 'PURCHASE',
|
|
83
79
|
@shipment = Shippo::Shipment.create(params)
|
84
80
|
@shipment.success?
|
85
81
|
# => true
|
86
|
-
@shipment.
|
87
|
-
# => 'SUCCESS'
|
88
|
-
@shipment.status # forwarded to #object
|
82
|
+
@shipment.status
|
89
83
|
# => 'SUCCESS'
|
90
|
-
@shipment.state
|
91
|
-
# => 'VALID'
|
92
84
|
```
|
93
85
|
|
94
86
|
Let's take a quick look at what the `Shipment` object looks like:
|
@@ -97,22 +89,43 @@ Let's take a quick look at what the `Shipment` object looks like:
|
|
97
89
|
require 'awesome_print'
|
98
90
|
ap @shipment
|
99
91
|
# {
|
100
|
-
#
|
101
|
-
#
|
102
|
-
#
|
103
|
-
#
|
104
|
-
#
|
105
|
-
#
|
106
|
-
#
|
107
|
-
# "
|
108
|
-
#
|
109
|
-
#
|
110
|
-
#
|
111
|
-
#
|
112
|
-
#
|
113
|
-
#
|
114
|
-
#
|
115
|
-
#
|
92
|
+
# "carrier_accounts" => [],
|
93
|
+
# "address_from" => {
|
94
|
+
# "name" => "Mr Hippo",
|
95
|
+
# "company" => "Shippo",
|
96
|
+
# "street1" => "215 Clayton St.",
|
97
|
+
# "street2" => "",
|
98
|
+
# "city" => "San Francisco",
|
99
|
+
# "state" => "CA",
|
100
|
+
# "zip" => "94117",
|
101
|
+
# "country" => "US",
|
102
|
+
# "phone" => "+1 555 341 9393"
|
103
|
+
# },
|
104
|
+
# "address_to" => { ... }, # omitted for brevity
|
105
|
+
# "address_return" => { ... },
|
106
|
+
# "parcels" => [{
|
107
|
+
# "length" => 5,
|
108
|
+
# "width" => 2,
|
109
|
+
# "height" => 5,
|
110
|
+
# "distance_unit" => in,
|
111
|
+
# "weight" => 2,
|
112
|
+
# "mass_unit" => lb,
|
113
|
+
# }],
|
114
|
+
# "shipment_date" => "2016-07-06T20:33:02.211Z",
|
115
|
+
# "customs_declaration" => nil,
|
116
|
+
# "extra" => {
|
117
|
+
# "insurance" => {
|
118
|
+
# "amount" => 10,
|
119
|
+
# "currency" => "USD",
|
120
|
+
# "content" => "",
|
121
|
+
# "provider" => "FEDEX"
|
122
|
+
# },
|
123
|
+
# "is_return" => false,
|
124
|
+
# "reference_1" => "",
|
125
|
+
# "reference_2" => "",
|
126
|
+
# },
|
127
|
+
# "messages" => [ ... ],
|
128
|
+
# "rates" => [ ... ]
|
116
129
|
# }
|
117
130
|
```
|
118
131
|
|
@@ -120,40 +133,32 @@ ap @shipment
|
|
120
133
|
|
121
134
|
In the case when the API returns a hash with one of the hash values being an array of entities, and if the corresponding key can be mapped into one of the existing API models, then each of the members of the array is coerced from a hash into an object of the model's type.
|
122
135
|
|
123
|
-
In the example below we are showing the result of such transformation where
|
136
|
+
In the example below we are showing the result of such transformation where `rates` contains a list of fully constructed objects of type `Shippo::Rate` after being coerced from a hash.
|
124
137
|
|
125
138
|
```ruby
|
126
|
-
ap @shipment.
|
139
|
+
ap @shipment.rates.first
|
127
140
|
# =>
|
128
|
-
# {
|
129
|
-
#
|
130
|
-
#
|
131
|
-
#
|
132
|
-
#
|
133
|
-
#
|
134
|
-
#
|
135
|
-
#
|
136
|
-
#
|
137
|
-
#
|
138
|
-
#
|
139
|
-
#
|
140
|
-
#
|
141
|
-
#
|
142
|
-
#
|
143
|
-
#
|
144
|
-
#
|
145
|
-
#
|
146
|
-
#
|
147
|
-
#
|
148
|
-
#
|
149
|
-
# "insurance_amount" => "0.00",
|
150
|
-
# "insurance_currency" => nil,
|
151
|
-
# "delivery_attempts" => nil,
|
152
|
-
# "outbound_endpoint" => "door",
|
153
|
-
# "inbound_endpoint" => "door",
|
154
|
-
# "messages" => [],
|
155
|
-
# "carrier_account" => "4b1940bc69524163b669asd361842db",
|
156
|
-
# "test" => true
|
141
|
+
# {
|
142
|
+
# "shipment" => "20f25e44b16b4051b6dd910cb66fd27b",
|
143
|
+
# "attributes" => [],
|
144
|
+
# "amount" => "8.51",
|
145
|
+
# "currency" => "USD",
|
146
|
+
# "amount_local" => "8.51",
|
147
|
+
# "currency_local" => "USD",
|
148
|
+
# "provider" => "FedEx",
|
149
|
+
# "provider_image_75" => "https://shippo-static.s3.amazonaws.com/providers/75/FedEx.png",
|
150
|
+
# "provider_image_200" => "https://shippo-static.s3.amazonaws.com/providers/200/FedEx.png",
|
151
|
+
# "servicelevel" => {
|
152
|
+
# "name" => "Ground",
|
153
|
+
# "token" => "fedex_ground",
|
154
|
+
# "terms" => ""
|
155
|
+
# }
|
156
|
+
# "days" => 2,
|
157
|
+
# "arrives_by" => nil,
|
158
|
+
# "duration_terms" => "",
|
159
|
+
# "messages" => [],
|
160
|
+
# "carrier_account" => "4b1940bc69524163b669asd361842db",
|
161
|
+
# "test" => true
|
157
162
|
# }
|
158
163
|
@shipment.rates.first.owner
|
159
164
|
# ⤷ unittest@gmail.com
|
@@ -170,10 +175,10 @@ You can retrieve a list of objects for many endpoints (e.g. Transactions, Shipme
|
|
170
175
|
@transactions
|
171
176
|
# =>
|
172
177
|
# {
|
173
|
-
#
|
174
|
-
#
|
175
|
-
#
|
176
|
-
#
|
178
|
+
# "count" => 3055,
|
179
|
+
# "next" => "https://api.goshippo.com/v1/transactions/?page=2",
|
180
|
+
# "previous" => nil,
|
181
|
+
# "results" => [ ... list of Transaction objects ... ]
|
177
182
|
# }
|
178
183
|
```
|
179
184
|
|
@@ -213,18 +218,15 @@ Finally, here is how we access the rest of the `object_` fields:
|
|
213
218
|
# ⤷ valued_customer@gmail.com
|
214
219
|
```
|
215
220
|
|
216
|
-
Here is the fully
|
221
|
+
Here is the fully constructed `ApiObject` instance, attached to our `@shipment`:
|
217
222
|
|
218
223
|
```ruby
|
219
224
|
ap @shipment.object
|
220
225
|
# {
|
221
|
-
#
|
222
|
-
#
|
223
|
-
#
|
224
|
-
#
|
225
|
-
# :status => #<Shippo::API::Category::Status:0x007fd88be82e28 @name=:status, @value=:success>,
|
226
|
-
# :purpose => #<Shippo::API::Category::Purpose:0x007fd88be985e8 @name=:purpose, @value=:purchase>,
|
227
|
-
# :id => "20f25e44b16b4051b6dd910cb66fd27b"
|
226
|
+
# :created => 2016-07-06 20:44:47 UTC,
|
227
|
+
# :updated => 2016-07-06 20:44:47 UTC,
|
228
|
+
# :owner => "valued_customer@gmail.com",
|
229
|
+
# :id => "20f25e44b16b4051b6dd910cb66fd27b"
|
228
230
|
# }
|
229
231
|
```
|
230
232
|
|
@@ -247,9 +249,9 @@ NOTE: this environment variable is only used by the included `bin/example` scrip
|
|
247
249
|
|
248
250
|
## Gem Versioning Notes
|
249
251
|
|
250
|
-
Version
|
252
|
+
Version 3 and up of this library works with Ruby 2.2 and later, and is not backwards compatible. __Version 1.0.4__ of this library is the last version supporting ruby 1.8 and 1.9.
|
251
253
|
|
252
|
-
__Warning:__ Version
|
254
|
+
__Warning:__ Version 3 brings potential backwards incompatibility issues. Please be prepared to update your usages (if necessary) when you migrate.
|
253
255
|
|
254
256
|
### If you are still using Ruby 1.8 or 1.9
|
255
257
|
|
@@ -14,6 +14,7 @@
|
|
14
14
|
lib = File.expand_path('../../lib', __FILE__)
|
15
15
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
16
16
|
|
17
|
+
require_relative 'config'
|
17
18
|
require 'bundler/setup'
|
18
19
|
require 'shippo'
|
19
20
|
require 'shippo/api/category'
|
@@ -21,8 +22,6 @@ require 'shippo/exceptions/api_error'
|
|
21
22
|
require 'awesome_print'
|
22
23
|
require 'json'
|
23
24
|
|
24
|
-
Shippo::API.token = ENV['SHIPPO_TOKEN']
|
25
|
-
|
26
25
|
# Simple wrapper class to help us print objects to the STDOUT
|
27
26
|
class ExampleHelper
|
28
27
|
def self.log_operation(msg)
|
@@ -53,7 +52,6 @@ end
|
|
53
52
|
|
54
53
|
# Create address object
|
55
54
|
address = {
|
56
|
-
:object_purpose => 'PURCHASE',
|
57
55
|
:name => 'Mr Hippo',
|
58
56
|
:company => 'Shippo',
|
59
57
|
:street1 => '215 Clayton St.',
|
data/bin/basic_shipment_example
CHANGED
@@ -14,6 +14,7 @@
|
|
14
14
|
lib = File.expand_path('../../lib', __FILE__)
|
15
15
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
16
16
|
|
17
|
+
require_relative 'config'
|
17
18
|
require 'bundler/setup'
|
18
19
|
require 'shippo'
|
19
20
|
require 'shippo/api/category'
|
@@ -21,8 +22,6 @@ require 'shippo/exceptions/api_error'
|
|
21
22
|
require 'awesome_print'
|
22
23
|
require 'json'
|
23
24
|
|
24
|
-
Shippo::API.token = ENV['SHIPPO_TOKEN']
|
25
|
-
|
26
25
|
# Simple wrapper class to help us print objects to the STDOUT
|
27
26
|
class ExampleHelper
|
28
27
|
def self.log_operation(msg)
|
@@ -53,7 +52,6 @@ end
|
|
53
52
|
|
54
53
|
# Create address_from object
|
55
54
|
address_from = {
|
56
|
-
:object_purpose => 'PURCHASE',
|
57
55
|
:name => 'Mr Hippo',
|
58
56
|
:company => 'Shippo',
|
59
57
|
:street1 => '215 Clayton St.',
|
@@ -67,7 +65,6 @@ address_from = {
|
|
67
65
|
|
68
66
|
# Create address_to object
|
69
67
|
address_to = {
|
70
|
-
:object_purpose => 'PURCHASE',
|
71
68
|
:name => 'Mrs Hippo"',
|
72
69
|
:company => 'San Diego Zoo',
|
73
70
|
:street1 => '2920 Zoo Drive',
|
@@ -87,8 +84,7 @@ parcel = {
|
|
87
84
|
:weight => 2,
|
88
85
|
:mass_unit => :lb }
|
89
86
|
|
90
|
-
hash = { :
|
91
|
-
:address_from => address_from,
|
87
|
+
hash = { :address_from => address_from,
|
92
88
|
:address_to => address_to,
|
93
89
|
:parcel => parcel,
|
94
90
|
:async => false }
|
@@ -121,7 +117,7 @@ end
|
|
121
117
|
|
122
118
|
# Get the desired rate according to your business logic
|
123
119
|
# We select the first rate in this example
|
124
|
-
rate = shipment.
|
120
|
+
rate = shipment.rates.first
|
125
121
|
ExampleHelper.dump_object(rate, 'First rate returned')
|
126
122
|
|
127
123
|
transaction = ExampleHelper.log_operation 'Creating a label with the first rate in the list... ' do
|
data/bin/batch_example
CHANGED
@@ -4,9 +4,6 @@
|
|
4
4
|
#
|
5
5
|
# License: MIT
|
6
6
|
#
|
7
|
-
# This example demonstrates how to get the tracking status of a shipment
|
8
|
-
# Please set +SHIPPO_TOKEN+ in the environment before running it.
|
9
|
-
#
|
10
7
|
# You can also set +SHIPPO_DEBUG+ to see detailed printouts of objects returned.
|
11
8
|
#
|
12
9
|
#
|
@@ -14,6 +11,7 @@
|
|
14
11
|
lib = File.expand_path('../../lib', __FILE__)
|
15
12
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
16
13
|
|
14
|
+
require_relative 'config'
|
17
15
|
require 'bundler/setup'
|
18
16
|
require 'shippo'
|
19
17
|
require 'shippo/api/category'
|
@@ -21,9 +19,6 @@ require 'shippo/exceptions/api_error'
|
|
21
19
|
require 'awesome_print'
|
22
20
|
require 'json'
|
23
21
|
|
24
|
-
Shippo::API.token = ENV['SHIPPO_TOKEN']
|
25
|
-
Hashie.logger = Logger.new(nil)
|
26
|
-
|
27
22
|
# Simple wrapper class to help us print objects to the STDOUT
|
28
23
|
class ExampleHelper
|
29
24
|
def self.log_operation(msg)
|
@@ -70,7 +65,6 @@ end
|
|
70
65
|
|
71
66
|
# Create address_from object
|
72
67
|
address_from = {
|
73
|
-
:object_purpose => 'PURCHASE',
|
74
68
|
:name => 'Mr Hippo',
|
75
69
|
:company => 'Shippo',
|
76
70
|
:street1 => '215 Clayton St.',
|
@@ -84,7 +78,6 @@ address_from = {
|
|
84
78
|
|
85
79
|
# Create address_to object
|
86
80
|
address_to = {
|
87
|
-
:object_purpose => 'PURCHASE',
|
88
81
|
:name => 'Mrs Hippo"',
|
89
82
|
:company => 'San Diego Zoo',
|
90
83
|
:street1 => '2920 Zoo Drive',
|
@@ -104,33 +97,13 @@ parcel = {
|
|
104
97
|
:weight => 2,
|
105
98
|
:mass_unit => :lb }
|
106
99
|
|
107
|
-
|
108
|
-
if !default_carrier_account
|
109
|
-
STDERR.puts 'Please set your SHIPPO_TEST_CARRIER_ACCOUNT environment variable.'
|
110
|
-
STDERR.puts
|
111
|
-
STDERR.puts 'You can do this by setting it to your USPS carrier account object ID:
|
112
|
-
|
113
|
-
Steps
|
114
|
-
--------------------------------------------------------------
|
115
|
-
1. curl https://api.goshippo.com/carrier_accounts/ \
|
116
|
-
-H "Authorization: ShippoToken <TEST_API_TOKEN>"
|
117
|
-
|
118
|
-
2. Look for {"carrier": "usps"} and find its "object_id"
|
119
|
-
|
120
|
-
3. export SHIPPO_TEST_CARRIER_ACCOUNT=<USPS_CARRIER_OBJECT_ID>
|
121
|
-
--------------------------------------------------------------
|
122
|
-
'
|
123
|
-
STDERR.puts
|
124
|
-
exit 1
|
125
|
-
end
|
126
|
-
hash = { :default_carrier_account => default_carrier_account,
|
100
|
+
hash = { :default_carrier_account => DEFAULT_CARRIER_ACCOUNT,
|
127
101
|
:default_servicelevel_token => 'usps_priority',
|
128
102
|
:label_filetype => 'ZPLII',
|
129
103
|
:metadata => 'BATCH #170',
|
130
104
|
:batch_shipments => [
|
131
105
|
{
|
132
106
|
:shipment => {
|
133
|
-
:object_purpose => 'PURCHASE',
|
134
107
|
:address_from => address_from,
|
135
108
|
:address_to => address_to,
|
136
109
|
:parcel => parcel,
|
@@ -140,8 +113,7 @@ hash = { :default_carrier_account => default_carrier_account,
|
|
140
113
|
]
|
141
114
|
}
|
142
115
|
|
143
|
-
shipment_params = { :
|
144
|
-
:address_from => address_from,
|
116
|
+
shipment_params = { :address_from => address_from,
|
145
117
|
:address_to => address_to,
|
146
118
|
:parcel => parcel,
|
147
119
|
:async => false }
|
@@ -202,10 +174,6 @@ rescue Shippo::Exceptions::AuthenticationError
|
|
202
174
|
if Shippo::API.token
|
203
175
|
puts "Token '#{Shippo::API.token}' does not appear to be valid."
|
204
176
|
puts 'Access denied.'
|
205
|
-
else
|
206
|
-
puts 'Please set authentication token in the environment:'
|
207
|
-
puts 'export SHIPPO_TOKEN="<your token here>"'
|
208
|
-
puts 'and re-run the example.'
|
209
177
|
end
|
210
178
|
exit 1
|
211
179
|
end
|
data/bin/config.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
lib = File.expand_path('../../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
require 'shippo'
|
5
|
+
|
6
|
+
Hashie.logger = Logger.new(nil)
|
7
|
+
|
8
|
+
Shippo::API.token = 'shippo_test_09e74f332aa839940e6c241bb008157c19428339'
|
9
|
+
DEFAULT_CARRIER_ACCOUNT = '903074429eab4954b72df8a70defdfe3'
|
data/bin/track_example
CHANGED
@@ -4,9 +4,6 @@
|
|
4
4
|
#
|
5
5
|
# License: MIT
|
6
6
|
#
|
7
|
-
# This example demonstrates how to get the tracking status of a shipment
|
8
|
-
# Please set +SHIPPO_TOKEN+ in the environment before running it.
|
9
|
-
#
|
10
7
|
# You can also set +SHIPPO_DEBUG+ to see detailed printouts of objects returned.
|
11
8
|
#
|
12
9
|
#
|
@@ -14,6 +11,7 @@
|
|
14
11
|
lib = File.expand_path('../../lib', __FILE__)
|
15
12
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
16
13
|
|
14
|
+
require_relative 'config'
|
17
15
|
require 'bundler/setup'
|
18
16
|
require 'shippo'
|
19
17
|
require 'shippo/api/category'
|
@@ -21,9 +19,6 @@ require 'shippo/exceptions/api_error'
|
|
21
19
|
require 'awesome_print'
|
22
20
|
require 'json'
|
23
21
|
|
24
|
-
Shippo::API.token = ENV['SHIPPO_TOKEN']
|
25
|
-
Hashie.logger = Logger.new(nil)
|
26
|
-
|
27
22
|
# Simple wrapper class to help us print objects to the STDOUT
|
28
23
|
class ExampleHelper
|
29
24
|
def self.log_operation(msg)
|
@@ -54,7 +49,6 @@ end
|
|
54
49
|
|
55
50
|
# Create address_from object
|
56
51
|
address_from = {
|
57
|
-
:object_purpose => 'PURCHASE',
|
58
52
|
:name => 'Mr Hippo',
|
59
53
|
:company => 'Shippo',
|
60
54
|
:street1 => '215 Clayton St.',
|
@@ -68,7 +62,6 @@ address_from = {
|
|
68
62
|
|
69
63
|
# Create address_to object
|
70
64
|
address_to = {
|
71
|
-
:object_purpose => 'PURCHASE',
|
72
65
|
:name => 'Mrs Hippo"',
|
73
66
|
:company => 'San Diego Zoo',
|
74
67
|
:street1 => '2920 Zoo Drive',
|
@@ -88,8 +81,7 @@ parcel = {
|
|
88
81
|
:weight => 2,
|
89
82
|
:mass_unit => :lb }
|
90
83
|
|
91
|
-
hash = { :
|
92
|
-
:address_from => address_from,
|
84
|
+
hash = { :address_from => address_from,
|
93
85
|
:address_to => address_to,
|
94
86
|
:parcel => parcel,
|
95
87
|
:async => false }
|
@@ -115,10 +107,6 @@ rescue Shippo::Exceptions::AuthenticationError
|
|
115
107
|
if Shippo::API.token
|
116
108
|
puts "Token '#{Shippo::API.token}' does not appear to be valid."
|
117
109
|
puts 'Access denied.'
|
118
|
-
else
|
119
|
-
puts 'Please set authentication token in the environment:'
|
120
|
-
puts 'export SHIPPO_TOKEN="<your token here>"'
|
121
|
-
puts 'and re-run the example.'
|
122
110
|
end
|
123
111
|
exit 1
|
124
112
|
end
|
data/lib/shippo/api.rb
CHANGED
@@ -21,9 +21,7 @@ module Shippo
|
|
21
21
|
#
|
22
22
|
# ```ruby
|
23
23
|
# response = {
|
24
|
-
# "object_state" => "VALID",
|
25
|
-
# "object_purpose" => "PURCHASE",
|
26
|
-
# "object_source" => "FULLY_ENTERED",
|
24
|
+
# "object_state" => "VALID", # not available for address, shipment or rates
|
27
25
|
# "object_created" => "2014-07-16T23:20:31.089Z",
|
28
26
|
# "object_updated" => "2014-07-16T23:20:31.089Z",
|
29
27
|
# "object_id" => "747207de2ba64443b645d08388d0309c",
|
@@ -49,8 +47,6 @@ module Shippo
|
|
49
47
|
# # ⤷
|
50
48
|
# {
|
51
49
|
# :state => #<Shippo::API::Category::State:0x007fd374b4d0d0 @name=:state, @value=:valid>,
|
52
|
-
# :purpose => #<Shippo::API::Category::Purpose:0x007fd373df2070 @name=:purpose, @value=:purchase>,
|
53
|
-
# :source => #<Shippo::API::Category::Source:0x007fd374b4fbf0 @name=:source, @value=:fully_entered>,
|
54
50
|
# :created => 2014-07-16 23:20:31 UTC,
|
55
51
|
# :updated => 2014-07-16 23:20:31 UTC,
|
56
52
|
# :id => "747207de2ba64443b645d08388d0309c",
|
@@ -78,7 +74,7 @@ module Shippo
|
|
78
74
|
|
79
75
|
# list of allowed properties, of a given type.
|
80
76
|
PROPS_ID = %i(id).freeze
|
81
|
-
PROPS_CATEG = %i(state
|
77
|
+
PROPS_CATEG = %i(state status results).freeze
|
82
78
|
PROPS_EMAIL = %i(owner).freeze
|
83
79
|
PROPS_TIMED = %i(created updated).freeze
|
84
80
|
|
@@ -13,7 +13,7 @@ module Shippo
|
|
13
13
|
# mapped to an array of hashes, into a word that represents an existing model.
|
14
14
|
#
|
15
15
|
# Each matcher receives a key as a parameter, and (if matches) it extracts the candidate word to be
|
16
|
-
# attempted to +constantize+. For example, +
|
16
|
+
# attempted to +constantize+. For example, +rates+ matcher will return +rates+ as output.
|
17
17
|
|
18
18
|
MATCHERS = [
|
19
19
|
->(key) {
|
data/lib/shippo/api/version.rb
CHANGED
data/shippo.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
|
19
19
|
spec.add_dependency 'rest-client', '~> 1.8'
|
20
20
|
spec.add_dependency 'json', '~> 1.8'
|
21
|
-
spec.add_dependency 'hashie', '
|
21
|
+
spec.add_dependency 'hashie', '>= 3.5.2'
|
22
22
|
spec.add_dependency 'activesupport', '>= 4'
|
23
23
|
spec.add_dependency 'awesome_print'
|
24
24
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shippo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shippo & Contributors
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-03-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
@@ -43,16 +43,16 @@ dependencies:
|
|
43
43
|
name: hashie
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - "
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version:
|
48
|
+
version: 3.5.2
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- - "
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
55
|
+
version: 3.5.2
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: activesupport
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -225,6 +225,7 @@ files:
|
|
225
225
|
- bin/address_validation_example
|
226
226
|
- bin/basic_shipment_example
|
227
227
|
- bin/batch_example
|
228
|
+
- bin/config.rb
|
228
229
|
- bin/console
|
229
230
|
- bin/track_example
|
230
231
|
- lib/shippo.rb
|
@@ -290,7 +291,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
290
291
|
version: '0'
|
291
292
|
requirements: []
|
292
293
|
rubyforge_project:
|
293
|
-
rubygems_version: 2.6.
|
294
|
+
rubygems_version: 2.6.11
|
294
295
|
signing_key:
|
295
296
|
specification_version: 4
|
296
297
|
summary: API client for Shippo® APIs. Shippo helps you connect with multiple carriers
|