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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c4cdf8c957478f42068e095c2c3a84f6ec141c4
4
- data.tar.gz: a44a1d79a8e7c2343038f95e0cc933298e03f837
3
+ metadata.gz: 9db550826374cb288e281d0e978fde363528ce88
4
+ data.tar.gz: e7d5c09d44c1c0a6d95c14ebfb82a4190fd7593a
5
5
  SHA512:
6
- metadata.gz: eb9664b47721a6f14be45a0d7042875990e3454d7c21cde4be66d104dc7e9b8358be8ddf9106b1212086aa4cdc80d4a3bc1c32a9a2ca339edf2685112a322e52
7
- data.tar.gz: a7956f59bd5ba39691e597486fc5fbad1aa2d90d3357cc63d5f3373177f2ba34fbb3d60f9aaa0f28b5e82d6187df2f5eec5747bb97c83cb0c3130e3b0f188565
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
1
+ 2.7.2
@@ -23,7 +23,6 @@ require 'easypost/event'
23
23
  require 'easypost/batch'
24
24
  require 'easypost/tracker'
25
25
  require 'easypost/item'
26
- require 'easypost/container'
27
26
  require 'easypost/order'
28
27
  require 'easypost/pickup'
29
28
  require 'easypost/pickup_rate'
@@ -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
 
@@ -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] && cls_prefix = response[:id][0..response[:id].index('_')]
85
- cls = prefixes[cls_prefix[0..-2]]
86
- elsif response['id'] && cls_prefix = response['id'][0..response['id'].index('_')]
87
- cls = prefixes[cls_prefix[0..-2]]
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
@@ -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
@@ -95,3 +95,12 @@ CUSTOMS_INFO = {
95
95
  restriction_comments: ''
96
96
  }
97
97
  }
98
+
99
+ OPTIONS = {
100
+ mws: {
101
+ fulfiller_order_items: [{
102
+ id: '12345678901234',
103
+ quantity: 1
104
+ }]
105
+ }
106
+ }
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.1
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: 2017-05-25 00:00:00.000000000 Z
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
@@ -1,4 +0,0 @@
1
- module EasyPost
2
- class Container < Resource
3
- end
4
- end
@@ -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