easypost 2.1.11 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +5 -0
- data/VERSION +1 -1
- data/lib/easypost.rb +1 -0
- data/lib/easypost/insurance.rb +4 -0
- data/lib/easypost/util.rb +10 -4
- data/spec/address_spec.rb +5 -5
- data/spec/insurance_spec.rb +69 -0
- data/spec/tracker_spec.rb +4 -4
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8deaad3af93387997d1bd5b4c3112ec58628a6bb
|
4
|
+
data.tar.gz: 16fef7e30f4b5de916e6057ef31b901a6d9c47ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e3442b420f010160a89409c46893793949b993510d9807bdea7a5faed1eb806ee5ed7895d81c2fee6cc599090ffce3c4f2c0104ee49ec0ec2af1517b310bf0b
|
7
|
+
data.tar.gz: b07d522882ee05908622130530b9ae2820c65f79be71887ad380499bc7e72be62065376888f0ccb68ef9d79c2995ea1088d68b6ebb606d136e6295bbe7e39718
|
data/CHANGELOG
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.2.0
|
data/lib/easypost.rb
CHANGED
data/lib/easypost/util.rb
CHANGED
@@ -16,7 +16,8 @@ module EasyPost
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.convert_to_easypost_object(response, api_key, parent=nil, name=nil)
|
19
|
-
types = {
|
19
|
+
types = {
|
20
|
+
'Address' => Address,
|
20
21
|
'ScanForm' => ScanForm,
|
21
22
|
'CustomsItem' => CustomsItem,
|
22
23
|
'CustomsInfo' => CustomsInfo,
|
@@ -28,6 +29,7 @@ module EasyPost
|
|
28
29
|
'Batch' => Batch,
|
29
30
|
'Tracker' => Tracker,
|
30
31
|
'Item' => Item,
|
32
|
+
'Insurance' => Insurance,
|
31
33
|
'Container' => Container,
|
32
34
|
'Order' => Order,
|
33
35
|
'Pickup' => Pickup,
|
@@ -36,9 +38,11 @@ module EasyPost
|
|
36
38
|
'Printer' => Printer,
|
37
39
|
'PrintJob' => PrintJob,
|
38
40
|
'CarrierAccount' => CarrierAccount,
|
39
|
-
'User' => User
|
41
|
+
'User' => User
|
42
|
+
}
|
40
43
|
|
41
|
-
prefixes = {
|
44
|
+
prefixes = {
|
45
|
+
'adr' => Address,
|
42
46
|
'sf' => ScanForm,
|
43
47
|
'cstitem' => CustomsItem,
|
44
48
|
'cstinfo' => CustomsInfo,
|
@@ -50,6 +54,7 @@ module EasyPost
|
|
50
54
|
'batch' => Batch,
|
51
55
|
'trk' => Tracker,
|
52
56
|
'item' => Item,
|
57
|
+
'ins' => Insurance,
|
53
58
|
'container' => Container,
|
54
59
|
'order' => Order,
|
55
60
|
'pickup' => Pickup,
|
@@ -58,7 +63,8 @@ module EasyPost
|
|
58
63
|
'printer' => Printer,
|
59
64
|
'printjob' => PrintJob,
|
60
65
|
'ca' => CarrierAccount,
|
61
|
-
'user' => User
|
66
|
+
'user' => User
|
67
|
+
}
|
62
68
|
|
63
69
|
case response
|
64
70
|
when Array
|
data/spec/address_spec.rb
CHANGED
@@ -24,15 +24,15 @@ describe EasyPost::Address do
|
|
24
24
|
describe '#verify' do
|
25
25
|
it 'verifies an address with an error' do
|
26
26
|
address = EasyPost::Address.create(
|
27
|
-
ADDRESS[:california].reject {|k,v| k == :
|
27
|
+
ADDRESS[:california].reject {|k,v| k == :street1 || k == :company}
|
28
28
|
)
|
29
29
|
|
30
|
-
expect(address.street1).to
|
30
|
+
expect(address.street1).to be_nil
|
31
|
+
expect(address.street2).to eq('Unit 1')
|
31
32
|
expect(address.city).to eq('San Francisco')
|
32
33
|
expect(address.state).to eq('CA')
|
33
34
|
expect(address.zip).to eq('94107')
|
34
35
|
expect(address.country).to eq('US')
|
35
|
-
expect(address.street2).to be_nil
|
36
36
|
|
37
37
|
expect {
|
38
38
|
address.verify()
|
@@ -49,7 +49,7 @@ describe EasyPost::Address do
|
|
49
49
|
expect(verified_address[:message]).to be_nil
|
50
50
|
end
|
51
51
|
|
52
|
-
it 'verifies an address using
|
52
|
+
it 'verifies an address using a carrier' do
|
53
53
|
address = EasyPost::Address.create(ADDRESS[:california])
|
54
54
|
|
55
55
|
expect(address.company).to eq('EasyPost')
|
@@ -59,7 +59,7 @@ describe EasyPost::Address do
|
|
59
59
|
expect(address.zip).to eq('94107')
|
60
60
|
expect(address.country).to eq('US')
|
61
61
|
|
62
|
-
verified_address = address.verify(carrier: :
|
62
|
+
verified_address = address.verify(carrier: :usps)
|
63
63
|
expect(verified_address).to be_an_instance_of(EasyPost::Address)
|
64
64
|
end
|
65
65
|
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe EasyPost::Insurance do
|
4
|
+
let(:tracking_code) { 'EZ2000000002' }
|
5
|
+
let(:carrier) { 'usps' }
|
6
|
+
let(:amount) { 101.00 }
|
7
|
+
|
8
|
+
describe '#create' do
|
9
|
+
it 'creates an insurance object' do
|
10
|
+
insurance = EasyPost::Insurance.create(
|
11
|
+
to_address: ADDRESS[:california],
|
12
|
+
from_address: ADDRESS[:missouri],
|
13
|
+
amount: amount,
|
14
|
+
tracking_code: tracking_code,
|
15
|
+
carrier: carrier
|
16
|
+
)
|
17
|
+
|
18
|
+
expect(insurance).to be_a(EasyPost::Insurance)
|
19
|
+
expect(insurance.id).not_to be_nil
|
20
|
+
expect(insurance.amount).to eq("101.00000")
|
21
|
+
expect(insurance.tracking_code).to eq(tracking_code)
|
22
|
+
expect(insurance.tracker).to be_a(EasyPost::Tracker)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#retrieve' do
|
27
|
+
it 'creates an insurance object' do
|
28
|
+
id = EasyPost::Insurance.create(
|
29
|
+
to_address: ADDRESS[:california],
|
30
|
+
from_address: ADDRESS[:missouri],
|
31
|
+
amount: amount,
|
32
|
+
tracking_code: tracking_code,
|
33
|
+
carrier: carrier
|
34
|
+
).id
|
35
|
+
|
36
|
+
insurance = EasyPost::Insurance.retrieve(id)
|
37
|
+
|
38
|
+
expect(insurance).to be_a(EasyPost::Insurance)
|
39
|
+
expect(insurance.id).to eq(id)
|
40
|
+
expect(insurance.amount).to eq("101.00000")
|
41
|
+
expect(insurance.tracking_code).to eq(tracking_code)
|
42
|
+
expect(insurance.tracker).to be_a(EasyPost::Tracker)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
describe '#index' do
|
48
|
+
it 'retrieves a full page of insurances' do
|
49
|
+
insurances = EasyPost::Insurance.all(page_size: 5)
|
50
|
+
|
51
|
+
expect(insurances["insurances"].count).to eq(5)
|
52
|
+
expect(insurances["has_more"]).to eq(true)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'retrieves all insurances with given tracking code, up to a page' do
|
56
|
+
insurances = EasyPost::Insurance.all(tracking_code: tracking_code, page_size: 5)
|
57
|
+
|
58
|
+
expect(insurances["insurances"].count).to eq(5)
|
59
|
+
expect(insurances["has_more"]).to eq(true)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'retrieves all insurances with given tracking code and carrier, up to a page' do
|
63
|
+
insurances = EasyPost::Insurance.all(tracking_code: tracking_code, carrier: carrier, page_size: 5)
|
64
|
+
|
65
|
+
expect(insurances["insurances"].count).to eq(5)
|
66
|
+
expect(insurances["has_more"]).to eq(true)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
data/spec/tracker_spec.rb
CHANGED
@@ -48,13 +48,13 @@ describe EasyPost::Tracker do
|
|
48
48
|
carrier: carrier
|
49
49
|
})
|
50
50
|
|
51
|
-
trackers = EasyPost::Tracker.all(start_datetime: datetime)
|
51
|
+
trackers = EasyPost::Tracker.all(start_datetime: datetime, tracking_code: tracking_code)
|
52
52
|
|
53
53
|
expect(trackers["trackers"].count).to eq(1)
|
54
54
|
expect(trackers["trackers"].first.id).to eq(tracker.id)
|
55
55
|
expect(trackers["has_more"]).to eq(false)
|
56
56
|
|
57
|
-
trackers = EasyPost::Tracker.all(end_datetime: datetime)
|
57
|
+
trackers = EasyPost::Tracker.all(end_datetime: datetime, tracking_code: tracking_code)
|
58
58
|
|
59
59
|
expect(trackers["trackers"].count).to eq(30)
|
60
60
|
trackers["trackers"].each do |trk|
|
@@ -74,14 +74,14 @@ describe EasyPost::Tracker do
|
|
74
74
|
carrier: carrier
|
75
75
|
})
|
76
76
|
|
77
|
-
trackers = EasyPost::Tracker.all(after_id: tracker.id)
|
77
|
+
trackers = EasyPost::Tracker.all(after_id: tracker.id, tracking_code: tracking_code)
|
78
78
|
|
79
79
|
expect(trackers["trackers"].count).to eq(1)
|
80
80
|
expect(trackers["trackers"].first.id).to eq(tracker2.id)
|
81
81
|
expect(trackers["trackers"].first.id).not_to eq(tracker.id)
|
82
82
|
expect(trackers["has_more"]).to eq(false)
|
83
83
|
|
84
|
-
trackers = EasyPost::Tracker.all(before_id: tracker.id)
|
84
|
+
trackers = EasyPost::Tracker.all(before_id: tracker.id, tracking_code: tracking_code)
|
85
85
|
|
86
86
|
expect(trackers["trackers"].count).to eq(30)
|
87
87
|
trackers["trackers"].each do |trk|
|
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.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sawyer Bateman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -105,6 +105,7 @@ files:
|
|
105
105
|
- lib/easypost/customs_item.rb
|
106
106
|
- lib/easypost/error.rb
|
107
107
|
- lib/easypost/event.rb
|
108
|
+
- lib/easypost/insurance.rb
|
108
109
|
- lib/easypost/item.rb
|
109
110
|
- lib/easypost/object.rb
|
110
111
|
- lib/easypost/order.rb
|
@@ -127,6 +128,7 @@ files:
|
|
127
128
|
- spec/batch_spec.rb
|
128
129
|
- spec/carrier_account_spec.rb
|
129
130
|
- spec/container_spec.rb
|
131
|
+
- spec/insurance_spec.rb
|
130
132
|
- spec/item_spec.rb
|
131
133
|
- spec/order_spec.rb
|
132
134
|
- spec/pickup_spec.rb
|
@@ -154,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
156
|
version: '0'
|
155
157
|
requirements: []
|
156
158
|
rubyforge_project:
|
157
|
-
rubygems_version: 2.0.14
|
159
|
+
rubygems_version: 2.0.14.1
|
158
160
|
signing_key:
|
159
161
|
specification_version: 4
|
160
162
|
summary: EasyPost Ruby Client Library
|
@@ -163,6 +165,7 @@ test_files:
|
|
163
165
|
- spec/batch_spec.rb
|
164
166
|
- spec/carrier_account_spec.rb
|
165
167
|
- spec/container_spec.rb
|
168
|
+
- spec/insurance_spec.rb
|
166
169
|
- spec/item_spec.rb
|
167
170
|
- spec/order_spec.rb
|
168
171
|
- spec/pickup_spec.rb
|