easypost 2.7.1 → 2.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +7 -0
- data/VERSION +1 -1
- data/lib/easypost.rb +0 -1
- data/lib/easypost/shipment.rb +0 -12
- data/lib/easypost/util.rb +12 -6
- data/spec/shipment_spec.rb +13 -38
- data/spec/support/constant.rb +9 -0
- metadata +2 -5
- data/lib/easypost/container.rb +0 -4
- data/spec/container_spec.rb +0 -76
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9db550826374cb288e281d0e978fde363528ce88
|
4
|
+
data.tar.gz: e7d5c09d44c1c0a6d95c14ebfb82a4190fd7593a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f40477ffd0190c181eb87b44ef6f0671ff2e83a0f63a9cf6564beb5259be875a6974e4bb3d3c9b4c00d23b4566ad700e556defedf3672be7b2e1917e303639be
|
7
|
+
data.tar.gz: 7879029aa4c3085e6b324c9fec65f0fbe7ff050eff1aacf60804b0eaccee4f13c8b37645544b9e5259f13dc774984b0b95482140f637642c2fe1e082a82d65ff
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
=== 2.7.2 2018-01-31
|
2
|
+
|
3
|
+
* Removed unused and unsupported code paths for Container model
|
4
|
+
* Removed unused and unsupported code path for Stamp and Barcode methods on the Shipment model
|
5
|
+
* Fixed a bug with non-model JSON object with an "id" key being treated as models and raising errors
|
6
|
+
|
7
|
+
|
1
8
|
=== 2.7.1 2017-05-25
|
2
9
|
|
3
10
|
* Allow reports to be retrieved without passing a type
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.7.
|
1
|
+
2.7.2
|
data/lib/easypost.rb
CHANGED
data/lib/easypost/shipment.rb
CHANGED
@@ -61,18 +61,6 @@ module EasyPost
|
|
61
61
|
return self
|
62
62
|
end
|
63
63
|
|
64
|
-
def stamp(params={})
|
65
|
-
response, api_key = EasyPost.request(:get, url + '/stamp', @api_key, params)
|
66
|
-
|
67
|
-
return response[:stamp_url]
|
68
|
-
end
|
69
|
-
|
70
|
-
def barcode(params={})
|
71
|
-
response, api_key = EasyPost.request(:get, url + '/barcode', @api_key, params)
|
72
|
-
|
73
|
-
return response[:barcode_url]
|
74
|
-
end
|
75
|
-
|
76
64
|
def lowest_rate(carriers=[], services=[])
|
77
65
|
lowest = nil
|
78
66
|
|
data/lib/easypost/util.rb
CHANGED
@@ -30,7 +30,6 @@ module EasyPost
|
|
30
30
|
'Tracker' => Tracker,
|
31
31
|
'Item' => Item,
|
32
32
|
'Insurance' => Insurance,
|
33
|
-
'Container' => Container,
|
34
33
|
'Order' => Order,
|
35
34
|
'Pickup' => Pickup,
|
36
35
|
'PickupRate' => PickupRate,
|
@@ -60,7 +59,6 @@ module EasyPost
|
|
60
59
|
'trk' => Tracker,
|
61
60
|
'item' => Item,
|
62
61
|
'ins' => Insurance,
|
63
|
-
'container' => Container,
|
64
62
|
'order' => Order,
|
65
63
|
'pickup' => Pickup,
|
66
64
|
'pickuprate' => PickupRate,
|
@@ -81,10 +79,18 @@ module EasyPost
|
|
81
79
|
when Hash
|
82
80
|
if cls_name = response[:object]
|
83
81
|
cls = types[cls_name]
|
84
|
-
elsif response[:id]
|
85
|
-
|
86
|
-
|
87
|
-
|
82
|
+
elsif response[:id]
|
83
|
+
if response[:id].index('_').nil?
|
84
|
+
cls = EasyPostObject
|
85
|
+
elsif cls_prefix = response[:id][0..response[:id].index('_')]
|
86
|
+
cls = prefixes[cls_prefix[0..-2]]
|
87
|
+
end
|
88
|
+
elsif response['id']
|
89
|
+
if response[:id].index('_').nil?
|
90
|
+
cls = EasyPostObject
|
91
|
+
elsif cls_prefix = response['id'][0..response['id'].index('_')]
|
92
|
+
cls = prefixes[cls_prefix[0..-2]]
|
93
|
+
end
|
88
94
|
end
|
89
95
|
|
90
96
|
cls ||= EasyPostObject
|
data/spec/shipment_spec.rb
CHANGED
@@ -13,6 +13,19 @@ describe EasyPost::Shipment do
|
|
13
13
|
expect(shipment.from_address).to be_an_instance_of(EasyPost::Address)
|
14
14
|
|
15
15
|
end
|
16
|
+
|
17
|
+
it 'creates a shipment object when options hash contains id' do
|
18
|
+
|
19
|
+
shipment = EasyPost::Shipment.create(
|
20
|
+
to_address: ADDRESS[:california],
|
21
|
+
from_address: EasyPost::Address.create(ADDRESS[:missouri]),
|
22
|
+
parcel: EasyPost::Parcel.create(PARCEL[:dimensions]),
|
23
|
+
options: OPTIONS[:mws]
|
24
|
+
)
|
25
|
+
expect(shipment).to be_an_instance_of(EasyPost::Shipment)
|
26
|
+
expect(shipment.options.fulfiller_order_items.first).to be_an_instance_of(EasyPost::EasyPostObject)
|
27
|
+
|
28
|
+
end
|
16
29
|
end
|
17
30
|
|
18
31
|
describe '#buy' do
|
@@ -102,44 +115,6 @@ describe EasyPost::Shipment do
|
|
102
115
|
end
|
103
116
|
end
|
104
117
|
|
105
|
-
describe '#stamp' do
|
106
|
-
it 'returns a stamp for a domestic shipment' do
|
107
|
-
shipment = EasyPost::Shipment.create(
|
108
|
-
to_address: EasyPost::Address.create(ADDRESS[:missouri]),
|
109
|
-
from_address: ADDRESS[:california],
|
110
|
-
parcel: EasyPost::Parcel.create(PARCEL[:dimensions])
|
111
|
-
)
|
112
|
-
expect(shipment).to be_an_instance_of(EasyPost::Shipment)
|
113
|
-
|
114
|
-
shipment.buy(
|
115
|
-
rate: shipment.lowest_rate(['USPS', 'UPS'], 'priority, express')
|
116
|
-
)
|
117
|
-
|
118
|
-
stamp_url = shipment.stamp
|
119
|
-
|
120
|
-
expect(stamp_url.length).to be > 0
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
describe '#barcode' do
|
125
|
-
it 'returns a barcode for a domestic shipment' do
|
126
|
-
shipment = EasyPost::Shipment.create(
|
127
|
-
to_address: EasyPost::Address.create(ADDRESS[:missouri]),
|
128
|
-
from_address: ADDRESS[:california],
|
129
|
-
parcel: EasyPost::Parcel.create(PARCEL[:dimensions])
|
130
|
-
)
|
131
|
-
expect(shipment).to be_an_instance_of(EasyPost::Shipment)
|
132
|
-
|
133
|
-
shipment.buy(
|
134
|
-
rate: shipment.lowest_rate('usps', ['Priority'])
|
135
|
-
)
|
136
|
-
|
137
|
-
barcode_url = shipment.barcode
|
138
|
-
|
139
|
-
expect(barcode_url.length).to be > 0
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
118
|
describe '#lowest_rate' do
|
144
119
|
context 'domestic shipment' do
|
145
120
|
before :all do
|
data/spec/support/constant.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easypost
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.7.
|
4
|
+
version: 2.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sawyer Bateman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -101,7 +101,6 @@ files:
|
|
101
101
|
- lib/easypost/address.rb
|
102
102
|
- lib/easypost/batch.rb
|
103
103
|
- lib/easypost/carrier_account.rb
|
104
|
-
- lib/easypost/container.rb
|
105
104
|
- lib/easypost/customs_info.rb
|
106
105
|
- lib/easypost/customs_item.rb
|
107
106
|
- lib/easypost/error.rb
|
@@ -130,7 +129,6 @@ files:
|
|
130
129
|
- spec/address_spec.rb
|
131
130
|
- spec/batch_spec.rb
|
132
131
|
- spec/carrier_account_spec.rb
|
133
|
-
- spec/container_spec.rb
|
134
132
|
- spec/insurance_spec.rb
|
135
133
|
- spec/item_spec.rb
|
136
134
|
- spec/order_spec.rb
|
@@ -170,7 +168,6 @@ test_files:
|
|
170
168
|
- spec/address_spec.rb
|
171
169
|
- spec/batch_spec.rb
|
172
170
|
- spec/carrier_account_spec.rb
|
173
|
-
- spec/container_spec.rb
|
174
171
|
- spec/insurance_spec.rb
|
175
172
|
- spec/item_spec.rb
|
176
173
|
- spec/order_spec.rb
|
data/lib/easypost/container.rb
DELETED
data/spec/container_spec.rb
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe EasyPost::Container do
|
4
|
-
describe '#create' do
|
5
|
-
it 'creates a container object' do
|
6
|
-
container = EasyPost::Container.create(
|
7
|
-
name: "Spec Box 1",
|
8
|
-
length: 6.2,
|
9
|
-
width: 12.8,
|
10
|
-
height: 13.5,
|
11
|
-
max_weight: 40.55,
|
12
|
-
reference: "SPECBOX",
|
13
|
-
)
|
14
|
-
expect(container).to be_an_instance_of(EasyPost::Container)
|
15
|
-
expect(container.max_weight).to eq(40.55)
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'fails to create a container object' do
|
19
|
-
expect { EasyPost::Container.create(
|
20
|
-
name: "Missing dimension",
|
21
|
-
length: 6,
|
22
|
-
width: 12,
|
23
|
-
max_weight: 40
|
24
|
-
) }.to raise_exception(EasyPost::Error, /Invalid request, if one dimension is provided all three are required./)
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'creates a container object with default values' do
|
28
|
-
container = EasyPost::Container.create(name: "Defaults Box")
|
29
|
-
expect(container).to be_an_instance_of(EasyPost::Container)
|
30
|
-
expect(container.id).to be
|
31
|
-
expect(container.name).to eq("Defaults Box")
|
32
|
-
expect(container.length).to eq(0.0)
|
33
|
-
expect(container.width).to eq(0.0)
|
34
|
-
expect(container.height).to eq(0.0)
|
35
|
-
expect(container.max_weight).to eq(0.0)
|
36
|
-
expect(container.type).to eq("BOX")
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe '#retrieve' do
|
41
|
-
it 'retrieves a user created container by public_id' do
|
42
|
-
container_1 = EasyPost::Container.create(
|
43
|
-
name: "My Box",
|
44
|
-
length: 6.2,
|
45
|
-
width: 12.8,
|
46
|
-
height: 13.5,
|
47
|
-
max_weight: 40.55,
|
48
|
-
reference: "SPECBOX",
|
49
|
-
type: "BAG",
|
50
|
-
)
|
51
|
-
container_2 = EasyPost::Container.retrieve(container_1.id)
|
52
|
-
|
53
|
-
expect(container_1).to be_an_instance_of(EasyPost::Container)
|
54
|
-
expect(container_2).to be_an_instance_of(EasyPost::Container)
|
55
|
-
expect(container_2.id).to eq(container_1.id)
|
56
|
-
expect(container_1.type).to eq("BAG")
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'retrieves a user created container by reference' do
|
60
|
-
container_1 = EasyPost::Container.create(
|
61
|
-
name: "Spec Box 2",
|
62
|
-
length: 6.2,
|
63
|
-
width: 12.8,
|
64
|
-
height: 133.94,
|
65
|
-
max_weight: 40.55,
|
66
|
-
reference: "SPECBOX4",
|
67
|
-
)
|
68
|
-
container_2 = EasyPost::Container.retrieve("SPECBOX4")
|
69
|
-
|
70
|
-
expect(container_1).to be_an_instance_of(EasyPost::Container)
|
71
|
-
expect(container_2).to be_an_instance_of(EasyPost::Container)
|
72
|
-
expect(container_2.height).to eq(container_1.height)
|
73
|
-
expect(container_1.type).to eq("BOX")
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|