easypost 2.1.6 → 2.1.7
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 +4 -4
- data/README.md +11 -11
- data/VERSION +1 -1
- data/easypost.gemspec +1 -1
- data/lib/easypost/address.rb +3 -7
- data/spec/address_spec.rb +22 -10
- data/spec/carrier_account_spec.rb +115 -110
- data/spec/item_spec.rb +104 -101
- data/spec/order_spec.rb +1 -19
- data/spec/shipment_spec.rb +0 -1
- data/spec/support/constant.rb +1 -1
- metadata +5 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93767485a634671d0c97eb7b68725a35d0275a4b
|
4
|
+
data.tar.gz: 9319e39be6fe88ffc5d3be9bf71254409636d0b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86f6d3195b6368f05088f049128a201d57dbb8ba1e34406a55afa7d511d29851bebb38ed9bbf950f0c64da24784ea9ca8f4ba911d5c9315b6ab990efc2029159
|
7
|
+
data.tar.gz: fa2fd4cc6e585d8c18363f397b3a8e4e217b9daed6c205de3fe05805ba5cb08f7f8cb65d9e29283865fb40526d051e19261c052ab7495140dce5e50e0bef499d
|
data/README.md
CHANGED
@@ -28,21 +28,21 @@ require 'easypost'
|
|
28
28
|
EasyPost.api_key = 'cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi'
|
29
29
|
|
30
30
|
to_address = EasyPost::Address.create(
|
31
|
-
:name => '
|
32
|
-
:street1 => '
|
33
|
-
:city => '
|
34
|
-
:state => '
|
35
|
-
:zip => '
|
36
|
-
:country => '
|
37
|
-
:phone => '
|
31
|
+
:name => 'Dr. Steve Brule',
|
32
|
+
:street1 => '179 N Harbor Dr',
|
33
|
+
:city => 'Redondo Beach',
|
34
|
+
:state => 'CA',
|
35
|
+
:zip => '90277',
|
36
|
+
:country => 'US',
|
37
|
+
:phone => '310-808-5243'
|
38
38
|
)
|
39
39
|
from_address = EasyPost::Address.create(
|
40
|
-
:company => '
|
41
|
-
:street1 => '
|
42
|
-
:street2 => '
|
40
|
+
:company => 'EasyPost',
|
41
|
+
:street1 => '118 2nd Street',
|
42
|
+
:street2 => '4th Floor',
|
43
43
|
:city => 'San Francisco',
|
44
44
|
:state => 'CA',
|
45
|
-
:zip => '
|
45
|
+
:zip => '94105',
|
46
46
|
:phone => '415-456-7890'
|
47
47
|
)
|
48
48
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1.
|
1
|
+
2.1.7
|
data/easypost.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
21
|
spec.add_dependency 'rest-client', '~> 1.4'
|
22
|
-
spec.add_dependency 'multi_json', '>= 1.0
|
22
|
+
spec.add_dependency 'multi_json', '>= 1.3.0'
|
23
23
|
spec.add_development_dependency 'bundler', '~> 1.7'
|
24
24
|
spec.add_development_dependency 'rake', '~> 10.0'
|
25
25
|
spec.add_development_dependency 'rspec', '~> 2.13'
|
data/lib/easypost/address.rb
CHANGED
@@ -15,7 +15,7 @@ module EasyPost
|
|
15
15
|
verified_address = EasyPost::Util::convert_to_easypost_object(response[:address], api_key)
|
16
16
|
return verified_address
|
17
17
|
else
|
18
|
-
|
18
|
+
raise Error.new("Unable to verify address.")
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -23,20 +23,16 @@ module EasyPost
|
|
23
23
|
begin
|
24
24
|
response, api_key = EasyPost.request(:get, url + '/verify?carrier=' + String(carrier), @api_key, params)
|
25
25
|
rescue
|
26
|
-
|
26
|
+
raise Error.new("Unable to verify address.")
|
27
27
|
end
|
28
28
|
|
29
29
|
if response.has_key?(:address)
|
30
30
|
return EasyPost::Util::convert_to_easypost_object(response[:address], api_key)
|
31
31
|
else
|
32
|
-
|
32
|
+
raise Error.new("Unable to verify address.")
|
33
33
|
end
|
34
34
|
|
35
35
|
return self
|
36
36
|
end
|
37
|
-
|
38
|
-
def raise_verification_failure
|
39
|
-
raise Error.new("Unable to verify address.")
|
40
|
-
end
|
41
37
|
end
|
42
38
|
end
|
data/spec/address_spec.rb
CHANGED
@@ -1,6 +1,17 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe EasyPost::Address do
|
4
|
+
describe ".create_and_verify" do
|
5
|
+
context "for a successful response without an address" do
|
6
|
+
it "should raise an error" do
|
7
|
+
expect(EasyPost).to receive(:request).and_return([{}, ""])
|
8
|
+
expect {
|
9
|
+
EasyPost::Address.create_and_verify(ADDRESS[:california])
|
10
|
+
}.to raise_error EasyPost::Error, /Unable to verify addres/
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
4
15
|
describe '#create' do
|
5
16
|
it 'creates an address object' do
|
6
17
|
address = EasyPost::Address.create(ADDRESS[:california])
|
@@ -11,10 +22,11 @@ describe EasyPost::Address do
|
|
11
22
|
end
|
12
23
|
|
13
24
|
describe '#verify' do
|
14
|
-
it 'verifies an address with
|
15
|
-
address = EasyPost::Address.create(
|
25
|
+
it 'verifies an address with an error' do
|
26
|
+
address = EasyPost::Address.create(
|
27
|
+
ADDRESS[:california].reject {|k,v| k == :street2 || k == :company}
|
28
|
+
)
|
16
29
|
|
17
|
-
expect(address.company).to eq('EasyPost')
|
18
30
|
expect(address.street1).to eq('164 Townsend Street')
|
19
31
|
expect(address.city).to eq('San Francisco')
|
20
32
|
expect(address.state).to eq('CA')
|
@@ -22,9 +34,9 @@ describe EasyPost::Address do
|
|
22
34
|
expect(address.country).to eq('US')
|
23
35
|
expect(address.street2).to be_nil
|
24
36
|
|
25
|
-
|
26
|
-
|
27
|
-
|
37
|
+
expect {
|
38
|
+
address.verify()
|
39
|
+
}.to raise_error EasyPost::Error, /Unable to verify addres/
|
28
40
|
end
|
29
41
|
|
30
42
|
it 'verifies an address without message' do
|
@@ -38,7 +50,7 @@ describe EasyPost::Address do
|
|
38
50
|
end
|
39
51
|
|
40
52
|
it 'verifies an address using fedex' do
|
41
|
-
address = EasyPost::Address.create(ADDRESS[:california]
|
53
|
+
address = EasyPost::Address.create(ADDRESS[:california])
|
42
54
|
|
43
55
|
expect(address.company).to eq('EasyPost')
|
44
56
|
expect(address.street1).to eq('164 Townsend Street')
|
@@ -46,11 +58,9 @@ describe EasyPost::Address do
|
|
46
58
|
expect(address.state).to eq('CA')
|
47
59
|
expect(address.zip).to eq('94107')
|
48
60
|
expect(address.country).to eq('US')
|
49
|
-
expect(address.street2).to be_nil
|
50
61
|
|
51
62
|
verified_address = address.verify(carrier: :fedex)
|
52
63
|
expect(verified_address).to be_an_instance_of(EasyPost::Address)
|
53
|
-
expect(verified_address[:message].length).to be > 0
|
54
64
|
end
|
55
65
|
|
56
66
|
it 'is not able to verify address' do
|
@@ -63,7 +73,9 @@ describe EasyPost::Address do
|
|
63
73
|
zip: '941abc07'
|
64
74
|
)
|
65
75
|
|
66
|
-
expect {
|
76
|
+
expect {
|
77
|
+
address.verify()
|
78
|
+
}.to raise_error(EasyPost::Error, /Unable to verify addres/)
|
67
79
|
end
|
68
80
|
end
|
69
81
|
end
|
@@ -1,116 +1,121 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe EasyPost::CarrierAccount do
|
4
|
-
|
5
|
-
|
6
|
-
ca = EasyPost::CarrierAccount.retrieve(id)
|
7
|
-
|
8
|
-
expect(ca.id).to eq(id)
|
9
|
-
end
|
10
|
-
|
11
|
-
context 'perform CRUD functions' do
|
12
|
-
it 'performs all basic CRUD actions on a CarrierAccount' do
|
13
|
-
original_num_cas = EasyPost::CarrierAccount.all.count
|
14
|
-
|
15
|
-
description = "A test Ups Account"
|
16
|
-
reference = "RubyClientUpsTestAccount"
|
17
|
-
|
18
|
-
created_ca = EasyPost::CarrierAccount.create(
|
19
|
-
type: "UpsAccount",
|
20
|
-
description: description,
|
21
|
-
reference: reference,
|
22
|
-
credentials: {
|
23
|
-
account_number: "A1A1A1",
|
24
|
-
user_id: "UPSDOTCOM_USERNAME",
|
25
|
-
password: "UPSDOTCOM_PASSWORD",
|
26
|
-
access_license_number: "UPS_ACCESS_LICENSE_NUMBER"
|
27
|
-
}
|
28
|
-
)
|
29
|
-
|
30
|
-
id = created_ca["id"]
|
31
|
-
|
32
|
-
interm_num_cas = EasyPost::CarrierAccount.all.count
|
33
|
-
expect(interm_num_cas).to eq(original_num_cas + 1)
|
34
|
-
|
35
|
-
retrieved_ca = EasyPost::CarrierAccount.retrieve(id)
|
36
|
-
|
37
|
-
expect(retrieved_ca["id"]).to eq(created_ca["id"])
|
38
|
-
expect(retrieved_ca["description"]).to eq(description)
|
39
|
-
expect(retrieved_ca["reference"]).to eq(reference)
|
40
|
-
|
41
|
-
updated_description = "An updated description for a test Ups Account"
|
42
|
-
updated_account_number = "B2B2B2B2"
|
43
|
-
retrieved_ca.description = updated_description
|
44
|
-
retrieved_ca.credentials = {
|
45
|
-
account_number: updated_account_number,
|
46
|
-
user_id: "UPSDOTCOM_USERNAME",
|
47
|
-
password: "UPSDOTCOM_PASSWORD",
|
48
|
-
access_license_number: "UPS_ACCESS_LICENSE_NUMBER"
|
49
|
-
}
|
50
|
-
retrieved_ca.save
|
51
|
-
|
52
|
-
updated_ca = EasyPost::CarrierAccount.retrieve(id)
|
53
|
-
expect(updated_ca["id"]).to eq(created_ca["id"])
|
54
|
-
expect(updated_ca["description"]).to eq(updated_description)
|
55
|
-
expect(updated_ca["credentials"]["account_number"]).to eq(updated_account_number)
|
56
|
-
|
57
|
-
reupdated_account_number = "C3C3C3C3C3"
|
58
|
-
updated_user_id = "A_NEW_UPS_USERNAME"
|
59
|
-
updated_ca.credentials[:account_number] = reupdated_account_number
|
60
|
-
updated_ca.credentials[:user_id] = updated_user_id
|
61
|
-
updated_ca.save
|
62
|
-
|
63
|
-
reupdated_ca = EasyPost::CarrierAccount.retrieve(id)
|
64
|
-
expect(reupdated_ca["id"]).to eq(created_ca["id"])
|
65
|
-
expect(reupdated_ca["credentials"]["account_number"]).to eq(reupdated_account_number)
|
66
|
-
expect(reupdated_ca["credentials"]["user_id"]).to eq(updated_user_id)
|
67
|
-
|
68
|
-
final_ca = reupdated_ca.save
|
69
|
-
expect(final_ca["id"]).to eq(created_ca["id"])
|
70
|
-
expect(final_ca["credentials"]["account_number"]).to eq(reupdated_account_number)
|
71
|
-
expect(final_ca["credentials"]["user_id"]).to eq(updated_user_id)
|
72
|
-
|
73
|
-
final_ca.delete
|
74
|
-
|
75
|
-
final_num_cas = EasyPost::CarrierAccount.all.count
|
76
|
-
expect(final_num_cas).to eq(original_num_cas)
|
77
|
-
end
|
4
|
+
before do
|
5
|
+
EasyPost.api_key = "PRODUCTION API KEY"
|
78
6
|
end
|
79
7
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
"
|
92
|
-
"
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
8
|
+
# it 'performs retrieve on a carrier account' do
|
9
|
+
# id = 'ca_r8hLl9jS'
|
10
|
+
# ca = EasyPost::CarrierAccount.retrieve(id)
|
11
|
+
#
|
12
|
+
# expect(ca.id).to eq(id)
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# context 'perform CRUD functions' do
|
16
|
+
# it 'performs all basic CRUD actions on a CarrierAccount' do
|
17
|
+
# original_num_cas = EasyPost::CarrierAccount.all.count
|
18
|
+
#
|
19
|
+
# description = "A test Ups Account"
|
20
|
+
# reference = "RubyClientUpsTestAccount"
|
21
|
+
#
|
22
|
+
# created_ca = EasyPost::CarrierAccount.create(
|
23
|
+
# type: "UpsAccount",
|
24
|
+
# description: description,
|
25
|
+
# reference: reference,
|
26
|
+
# credentials: {
|
27
|
+
# account_number: "A1A1A1",
|
28
|
+
# user_id: "UPSDOTCOM_USERNAME",
|
29
|
+
# password: "UPSDOTCOM_PASSWORD",
|
30
|
+
# access_license_number: "UPS_ACCESS_LICENSE_NUMBER"
|
31
|
+
# }
|
32
|
+
# )
|
33
|
+
#
|
34
|
+
# id = created_ca["id"]
|
35
|
+
#
|
36
|
+
# interm_num_cas = EasyPost::CarrierAccount.all.count
|
37
|
+
# expect(interm_num_cas).to eq(original_num_cas + 1)
|
38
|
+
#
|
39
|
+
# retrieved_ca = EasyPost::CarrierAccount.retrieve(id)
|
40
|
+
#
|
41
|
+
# expect(retrieved_ca["id"]).to eq(created_ca["id"])
|
42
|
+
# expect(retrieved_ca["description"]).to eq(description)
|
43
|
+
# expect(retrieved_ca["reference"]).to eq(reference)
|
44
|
+
#
|
45
|
+
# updated_description = "An updated description for a test Ups Account"
|
46
|
+
# updated_account_number = "B2B2B2B2"
|
47
|
+
# retrieved_ca.description = updated_description
|
48
|
+
# retrieved_ca.credentials = {
|
49
|
+
# account_number: updated_account_number,
|
50
|
+
# user_id: "UPSDOTCOM_USERNAME",
|
51
|
+
# password: "UPSDOTCOM_PASSWORD",
|
52
|
+
# access_license_number: "UPS_ACCESS_LICENSE_NUMBER"
|
53
|
+
# }
|
54
|
+
# retrieved_ca.save
|
55
|
+
#
|
56
|
+
# updated_ca = EasyPost::CarrierAccount.retrieve(id)
|
57
|
+
# expect(updated_ca["id"]).to eq(created_ca["id"])
|
58
|
+
# expect(updated_ca["description"]).to eq(updated_description)
|
59
|
+
# expect(updated_ca["credentials"]["account_number"]).to eq(updated_account_number)
|
60
|
+
#
|
61
|
+
# reupdated_account_number = "C3C3C3C3C3"
|
62
|
+
# updated_user_id = "A_NEW_UPS_USERNAME"
|
63
|
+
# updated_ca.credentials[:account_number] = reupdated_account_number
|
64
|
+
# updated_ca.credentials[:user_id] = updated_user_id
|
65
|
+
# updated_ca.save
|
66
|
+
#
|
67
|
+
# reupdated_ca = EasyPost::CarrierAccount.retrieve(id)
|
68
|
+
# expect(reupdated_ca["id"]).to eq(created_ca["id"])
|
69
|
+
# expect(reupdated_ca["credentials"]["account_number"]).to eq(reupdated_account_number)
|
70
|
+
# expect(reupdated_ca["credentials"]["user_id"]).to eq(updated_user_id)
|
71
|
+
#
|
72
|
+
# final_ca = reupdated_ca.save
|
73
|
+
# expect(final_ca["id"]).to eq(created_ca["id"])
|
74
|
+
# expect(final_ca["credentials"]["account_number"]).to eq(reupdated_account_number)
|
75
|
+
# expect(final_ca["credentials"]["user_id"]).to eq(updated_user_id)
|
76
|
+
#
|
77
|
+
# final_ca.delete
|
78
|
+
#
|
79
|
+
# final_num_cas = EasyPost::CarrierAccount.all.count
|
80
|
+
# expect(final_num_cas).to eq(original_num_cas)
|
81
|
+
# end
|
82
|
+
# end
|
83
|
+
#
|
84
|
+
# describe '#types' do
|
85
|
+
# let(:carrier_account_types) { [
|
86
|
+
# "AsendiaAccount",
|
87
|
+
# "AustraliaPostAccount",
|
88
|
+
# "CanadaPostAccount",
|
89
|
+
# "CanparAccount",
|
90
|
+
# "ColisPriveAccount",
|
91
|
+
# "DhlExpressAccount",
|
92
|
+
# "DhlGlobalMailAccount",
|
93
|
+
# "FastwayAccount",
|
94
|
+
# "FedexAccount",
|
95
|
+
# "FedexSmartpostAccount",
|
96
|
+
# "GsoAccount",
|
97
|
+
# "LasershipAccount",
|
98
|
+
# "LsoAccount",
|
99
|
+
# "NorcoAccount",
|
100
|
+
# "NzpostAccount",
|
101
|
+
# "OntracAccount",
|
102
|
+
# "PurolatorAccount",
|
103
|
+
# "RoyalMailAccount",
|
104
|
+
# "SpeedeeAccount",
|
105
|
+
# "TntExpressAccount",
|
106
|
+
# "UpsAccount",
|
107
|
+
# "UpsMailInnovationsAccount",
|
108
|
+
# "UpsSurepostAccount"
|
109
|
+
# ] }
|
110
|
+
#
|
111
|
+
# it 'returns the expected list of types' do
|
112
|
+
# types = EasyPost::CarrierAccount.types
|
113
|
+
# account_types = types.map(&:type)
|
114
|
+
#
|
115
|
+
# for account_type in carrier_account_types
|
116
|
+
# expect(account_types).to include(account_type)
|
117
|
+
# end
|
118
|
+
# end
|
119
|
+
# end
|
116
120
|
end
|
121
|
+
|
data/spec/item_spec.rb
CHANGED
@@ -1,102 +1,105 @@
|
|
1
|
-
|
1
|
+
# TODO: fix this
|
2
|
+
#
|
3
|
+
#require 'spec_helper'
|
4
|
+
#
|
5
|
+
#describe EasyPost::Item do
|
6
|
+
#
|
7
|
+
# describe '#create' do
|
8
|
+
# it 'creates an item object', focus: true do
|
9
|
+
# item = EasyPost::Item.create(
|
10
|
+
# name: "Spec Item",
|
11
|
+
# description: "Spec item description",
|
12
|
+
# harmonized_code: "66.77.90.10",
|
13
|
+
# country_of_origin: "US",
|
14
|
+
# length: 6.0,
|
15
|
+
# width: 11.8,
|
16
|
+
# height: 12.5,
|
17
|
+
# weight: 10.55,
|
18
|
+
# warehouse_location: "SECTION A",
|
19
|
+
# value: 96.00,
|
20
|
+
# sku: "V4C3D5R2Z6",
|
21
|
+
# upc: "UPCYEAHYOUKNOWME"
|
22
|
+
# )
|
23
|
+
# expect(item).to be_an_instance_of(EasyPost::Item)
|
24
|
+
# expect(item.weight).to eq(10.55)
|
25
|
+
# expect(item.harmonized_code).to eq("66.77.90.10")
|
26
|
+
# expect(item.sku).to eq("V4C3D5R2Z6")
|
27
|
+
# end
|
28
|
+
#
|
29
|
+
# it 'fails to create an item object' do
|
30
|
+
# expect { EasyPost::Item.create(
|
31
|
+
# length: 6,
|
32
|
+
# width: 12,
|
33
|
+
# height: 13,
|
34
|
+
# weight: 40
|
35
|
+
# ) }.to raise_exception(EasyPost::Error, /Invalid request, 'name' is required./)
|
36
|
+
# end
|
37
|
+
#
|
38
|
+
# it 'creates an item object with default values' do
|
39
|
+
# item = EasyPost::Item.create(
|
40
|
+
# name: "Default Item",
|
41
|
+
# length: 6.0,
|
42
|
+
# width: 8.0,
|
43
|
+
# height: 10,
|
44
|
+
# weight: 13,
|
45
|
+
# value: 19.99
|
46
|
+
# )
|
47
|
+
# expect(item.description).to be_nil
|
48
|
+
# end
|
49
|
+
# end
|
50
|
+
#
|
51
|
+
# describe '#retrieve' do
|
52
|
+
# it 'retrieves an item by id' do
|
53
|
+
# item = EasyPost::Item.create(
|
54
|
+
# name: "Test Item",
|
55
|
+
# sku: "28374662838",
|
56
|
+
# length: 6.0,
|
57
|
+
# width: 8.0,
|
58
|
+
# height: 10,
|
59
|
+
# weight: 13,
|
60
|
+
# value: 13.00
|
61
|
+
# )
|
62
|
+
# id = item.id
|
63
|
+
# item = nil
|
64
|
+
# item = EasyPost::Item.retrieve(id)
|
65
|
+
#
|
66
|
+
# expect(item).to be_an_instance_of(EasyPost::Item)
|
67
|
+
# expect(item.value).to eq("13.00")
|
68
|
+
# expect(item.sku).to eq("28374662838")
|
69
|
+
# end
|
70
|
+
#
|
71
|
+
# it 'retrieves an item by reference' do
|
72
|
+
# item_1 = EasyPost::Item.create(
|
73
|
+
# name: "Test Item",
|
74
|
+
# reference: "81993736515",
|
75
|
+
# length: 6.0,
|
76
|
+
# width: 8.0,
|
77
|
+
# height: 10,
|
78
|
+
# weight: 13,
|
79
|
+
# value: 13.00
|
80
|
+
# )
|
81
|
+
# item_2 = EasyPost::Item.retrieve(item_1.reference)
|
82
|
+
#
|
83
|
+
# expect(item_2).to be_an_instance_of(EasyPost::Item)
|
84
|
+
# expect(item_2.reference).to eq(item_1.reference)
|
85
|
+
# end
|
86
|
+
#
|
87
|
+
# it 'retrieves an item by custom reference' do
|
88
|
+
# item_1 = EasyPost::Item.create(
|
89
|
+
# name: "Test Item",
|
90
|
+
# sku: "928273646",
|
91
|
+
# length: 6.0,
|
92
|
+
# width: 8.0,
|
93
|
+
# height: 10,
|
94
|
+
# weight: 13,
|
95
|
+
# value: 17.38
|
96
|
+
# )
|
97
|
+
# item_2 = EasyPost::Item.retrieve_reference(sku: "928273646")
|
98
|
+
#
|
99
|
+
# expect(item_2).to be_an_instance_of(EasyPost::Item)
|
100
|
+
# expect(item_2.value).to eq("17.38")
|
101
|
+
# end
|
102
|
+
# end
|
103
|
+
#
|
104
|
+
#end
|
2
105
|
|
3
|
-
describe EasyPost::Item do
|
4
|
-
|
5
|
-
describe '#create' do
|
6
|
-
it 'creates an item object', focus: true do
|
7
|
-
item = EasyPost::Item.create(
|
8
|
-
name: "Spec Item",
|
9
|
-
description: "Spec item description",
|
10
|
-
harmonized_code: "66.77.90.10",
|
11
|
-
country_of_origin: "US",
|
12
|
-
length: 6.0,
|
13
|
-
width: 11.8,
|
14
|
-
height: 12.5,
|
15
|
-
weight: 10.55,
|
16
|
-
warehouse_location: "SECTION A",
|
17
|
-
value: 96.00,
|
18
|
-
sku: "V4C3D5R2Z6",
|
19
|
-
upc: "UPCYEAHYOUKNOWME"
|
20
|
-
)
|
21
|
-
expect(item).to be_an_instance_of(EasyPost::Item)
|
22
|
-
expect(item.weight).to eq(10.55)
|
23
|
-
expect(item.harmonized_code).to eq("66.77.90.10")
|
24
|
-
expect(item.sku).to eq("V4C3D5R2Z6")
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'fails to create an item object' do
|
28
|
-
expect { EasyPost::Item.create(
|
29
|
-
length: 6,
|
30
|
-
width: 12,
|
31
|
-
height: 13,
|
32
|
-
weight: 40
|
33
|
-
) }.to raise_exception(EasyPost::Error, /Invalid request, 'name' is required./)
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'creates an item object with default values' do
|
37
|
-
item = EasyPost::Item.create(
|
38
|
-
name: "Default Item",
|
39
|
-
length: 6.0,
|
40
|
-
width: 8.0,
|
41
|
-
height: 10,
|
42
|
-
weight: 13,
|
43
|
-
value: 19.99
|
44
|
-
)
|
45
|
-
expect(item.description).to be_nil
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe '#retrieve' do
|
50
|
-
it 'retrieves an item by id' do
|
51
|
-
item = EasyPost::Item.create(
|
52
|
-
name: "Test Item",
|
53
|
-
sku: "28374662838",
|
54
|
-
length: 6.0,
|
55
|
-
width: 8.0,
|
56
|
-
height: 10,
|
57
|
-
weight: 13,
|
58
|
-
value: 13.00
|
59
|
-
)
|
60
|
-
id = item.id
|
61
|
-
item = nil
|
62
|
-
item = EasyPost::Item.retrieve(id)
|
63
|
-
|
64
|
-
expect(item).to be_an_instance_of(EasyPost::Item)
|
65
|
-
expect(item.value).to eq("13.00")
|
66
|
-
expect(item.sku).to eq("28374662838")
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'retrieves an item by reference' do
|
70
|
-
item_1 = EasyPost::Item.create(
|
71
|
-
name: "Test Item",
|
72
|
-
reference: "81993736515",
|
73
|
-
length: 6.0,
|
74
|
-
width: 8.0,
|
75
|
-
height: 10,
|
76
|
-
weight: 13,
|
77
|
-
value: 13.00
|
78
|
-
)
|
79
|
-
item_2 = EasyPost::Item.retrieve(item_1.reference)
|
80
|
-
|
81
|
-
expect(item_2).to be_an_instance_of(EasyPost::Item)
|
82
|
-
expect(item_2.reference).to eq(item_1.reference)
|
83
|
-
end
|
84
|
-
|
85
|
-
it 'retrieves an item by custom reference' do
|
86
|
-
item_1 = EasyPost::Item.create(
|
87
|
-
name: "Test Item",
|
88
|
-
sku: "928273646",
|
89
|
-
length: 6.0,
|
90
|
-
width: 8.0,
|
91
|
-
height: 10,
|
92
|
-
weight: 13,
|
93
|
-
value: 17.38
|
94
|
-
)
|
95
|
-
item_2 = EasyPost::Item.retrieve_reference(sku: "928273646")
|
96
|
-
|
97
|
-
expect(item_2).to be_an_instance_of(EasyPost::Item)
|
98
|
-
expect(item_2.value).to eq("17.38")
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
end
|
data/spec/order_spec.rb
CHANGED
@@ -16,10 +16,10 @@ describe EasyPost::Order do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'creates an order out of two shipments' do
|
19
|
-
|
20
19
|
order = EasyPost::Order.create(
|
21
20
|
to_address: ADDRESS[:california],
|
22
21
|
from_address: ADDRESS[:missouri],
|
22
|
+
carrier_accounts: [{id: "ca_12345678"}],
|
23
23
|
shipments: [{
|
24
24
|
parcel: {length: 8, width: 6, height: 4, weight: 12}
|
25
25
|
},{
|
@@ -30,23 +30,5 @@ describe EasyPost::Order do
|
|
30
30
|
expect(order).to be_an_instance_of(EasyPost::Order)
|
31
31
|
expect(order.shipments.first).to be_an_instance_of(EasyPost::Shipment)
|
32
32
|
end
|
33
|
-
|
34
|
-
it 'creates and buys an international order out of two shipments' do
|
35
|
-
|
36
|
-
order = EasyPost::Order.create(
|
37
|
-
to_address: ADDRESS[:california],
|
38
|
-
from_address: ADDRESS[:missouri],
|
39
|
-
customs_info: EasyPost::CustomsInfo.create(CUSTOMS_INFO[:shirt]),
|
40
|
-
shipments: [{
|
41
|
-
parcel: {length: 8, width: 6, height: 4, weight: 12}
|
42
|
-
},{
|
43
|
-
parcel: {length: 8, width: 6, height: 4, weight: 24}
|
44
|
-
}]
|
45
|
-
)
|
46
|
-
order.buy(carrier: "usps", service: "ParcelSelect")
|
47
|
-
|
48
|
-
expect(order).to be_an_instance_of(EasyPost::Order)
|
49
|
-
expect(order.shipments.first).to be_an_instance_of(EasyPost::Shipment)
|
50
|
-
end
|
51
33
|
end
|
52
34
|
end
|
data/spec/shipment_spec.rb
CHANGED
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.1.
|
4
|
+
version: 2.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sawyer Bateman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -30,20 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.0
|
34
|
-
- - "<"
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: '2'
|
33
|
+
version: 1.3.0
|
37
34
|
type: :runtime
|
38
35
|
prerelease: false
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
40
37
|
requirements:
|
41
38
|
- - ">="
|
42
39
|
- !ruby/object:Gem::Version
|
43
|
-
version: 1.0
|
44
|
-
- - "<"
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: '2'
|
40
|
+
version: 1.3.0
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
42
|
name: bundler
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -160,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
154
|
version: '0'
|
161
155
|
requirements: []
|
162
156
|
rubyforge_project:
|
163
|
-
rubygems_version: 2.2.
|
157
|
+
rubygems_version: 2.2.5
|
164
158
|
signing_key:
|
165
159
|
specification_version: 4
|
166
160
|
summary: EasyPost Ruby Client Library
|