easypost 2.0.15 → 2.1.0
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 +13 -5
- data/.gitignore +1 -2
- data/CHANGELOG +0 -17
- data/README.md +0 -3
- data/VERSION +1 -1
- data/lib/easypost.rb +1 -4
- data/lib/easypost/address.rb +3 -10
- data/lib/easypost/object.rb +2 -2
- data/lib/easypost/util.rb +2 -6
- data/spec/address_spec.rb +7 -7
- data/spec/batch_spec.rb +33 -20
- data/spec/container_spec.rb +11 -0
- data/spec/fedex/domestic_spec.rb +180 -0
- data/spec/fedex/international_spec.rb +64 -0
- data/spec/order_spec.rb +70 -2
- data/spec/pickup_spec.rb +14 -13
- data/spec/shipment_spec.rb +23 -38
- data/spec/spec_helper.rb +92 -6
- data/spec/ups/domestic_spec.rb +79 -0
- data/spec/ups/international_spec.rb +64 -0
- data/spec/usps/domestic_spec.rb +66 -0
- data/spec/usps/electronic_merchandise_returns.rb +94 -0
- data/spec/usps/merchant_returns.rb +0 -0
- metadata +31 -27
- data/lib/easypost/carrier_account.rb +0 -21
- data/lib/easypost/user.rb +0 -42
- data/spec/carrier_account_spec.rb +0 -83
- data/spec/support/constant.rb +0 -87
- data/spec/tracker_spec.rb +0 -20
- data/spec/user_spec.rb +0 -72
@@ -1,21 +0,0 @@
|
|
1
|
-
module EasyPost
|
2
|
-
class CarrierAccount < Resource
|
3
|
-
def save
|
4
|
-
if @unsaved_values.length > 0
|
5
|
-
values = {}
|
6
|
-
@unsaved_values.each { |k| values[k] = @values[k] }
|
7
|
-
|
8
|
-
wrapped_params = {carrier_account: values}
|
9
|
-
|
10
|
-
response, api_key = EasyPost.request(:put, url, @api_key, wrapped_params)
|
11
|
-
refresh_from(response, api_key)
|
12
|
-
end
|
13
|
-
return self
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.types
|
17
|
-
response, api_key = EasyPost.request(:get, "/carrier_types", @api_key)
|
18
|
-
return Util.convert_to_easypost_object(response, api_key)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
data/lib/easypost/user.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
module EasyPost
|
2
|
-
class User < Resource
|
3
|
-
def save
|
4
|
-
if @unsaved_values.length > 0
|
5
|
-
values = {}
|
6
|
-
@unsaved_values.each { |k| values[k] = @values[k] }
|
7
|
-
|
8
|
-
wrapped_params = {user: values}
|
9
|
-
|
10
|
-
response, api_key = EasyPost.request(:put, url, @api_key, wrapped_params)
|
11
|
-
refresh_from(response, api_key)
|
12
|
-
end
|
13
|
-
return self
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.retrieve_me
|
17
|
-
self.all
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.all_api_keys
|
21
|
-
response, api_key = EasyPost.request(:get, "/api_keys", @api_key)
|
22
|
-
return Util.convert_to_easypost_object(response, api_key)
|
23
|
-
end
|
24
|
-
|
25
|
-
def api_keys
|
26
|
-
api_keys = EasyPost::User.all_api_keys
|
27
|
-
|
28
|
-
if api_keys.id == self.id
|
29
|
-
my_api_keys = api_keys.keys
|
30
|
-
else
|
31
|
-
for child in api_keys.children
|
32
|
-
if child.id == self.id
|
33
|
-
my_api_keys = child.keys
|
34
|
-
break
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
my_api_keys
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,83 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe EasyPost::CarrierAccount do
|
4
|
-
it 'performs all basic CRUD actions on a CarrierAccount' do
|
5
|
-
original_num_cas = EasyPost::CarrierAccount.all.count
|
6
|
-
|
7
|
-
description = "A test Ups Account"
|
8
|
-
reference = "RubyClientUpsTestAccount"
|
9
|
-
|
10
|
-
created_ca = EasyPost::CarrierAccount.create(
|
11
|
-
type: "UpsAccount",
|
12
|
-
description: description,
|
13
|
-
reference: reference,
|
14
|
-
credentials: {
|
15
|
-
account_number: "A1A1A1",
|
16
|
-
user_id: "UPSDOTCOM_USERNAME",
|
17
|
-
password: "UPSDOTCOM_PASSWORD",
|
18
|
-
access_license_number: "UPS_ACCESS_LICENSE_NUMBER"
|
19
|
-
}
|
20
|
-
)
|
21
|
-
|
22
|
-
id = created_ca["id"]
|
23
|
-
|
24
|
-
interm_num_cas = EasyPost::CarrierAccount.all.count
|
25
|
-
expect(interm_num_cas).to eq(original_num_cas + 1)
|
26
|
-
|
27
|
-
retrieved_ca = EasyPost::CarrierAccount.retrieve(id)
|
28
|
-
|
29
|
-
expect(retrieved_ca["id"]).to eq(created_ca["id"])
|
30
|
-
expect(retrieved_ca["description"]).to eq(description)
|
31
|
-
expect(retrieved_ca["reference"]).to eq(reference)
|
32
|
-
|
33
|
-
updated_description = "An updated description for a test Ups Account"
|
34
|
-
retrieved_ca.description = updated_description
|
35
|
-
retrieved_ca.save
|
36
|
-
|
37
|
-
updated_ca = EasyPost::CarrierAccount.retrieve(id)
|
38
|
-
expect(updated_ca["id"]).to eq(created_ca["id"])
|
39
|
-
expect(updated_ca["description"]).to eq(updated_description)
|
40
|
-
|
41
|
-
updated_ca.delete
|
42
|
-
|
43
|
-
final_num_cas = EasyPost::CarrierAccount.all.count
|
44
|
-
expect(final_num_cas).to eq(original_num_cas)
|
45
|
-
end
|
46
|
-
|
47
|
-
describe '#types' do
|
48
|
-
let(:carrier_account_types) { [
|
49
|
-
"AsendiaAccount",
|
50
|
-
"AustraliaPostAccount",
|
51
|
-
"CanadaPostAccount",
|
52
|
-
"CanparAccount",
|
53
|
-
"ColisPriveAccount",
|
54
|
-
"DhlExpressAccount",
|
55
|
-
"DhlGlobalMailAccount",
|
56
|
-
"FastwayAccount",
|
57
|
-
"FedexAccount",
|
58
|
-
"FedexSmartpostAccount",
|
59
|
-
"GsoAccount",
|
60
|
-
"LasershipAccount",
|
61
|
-
"LsoAccount",
|
62
|
-
"NorcoAccount",
|
63
|
-
"NzpostAccount",
|
64
|
-
"OntracAccount",
|
65
|
-
"PurolatorAccount",
|
66
|
-
"RoyalMailAccount",
|
67
|
-
"SpeedeeAccount",
|
68
|
-
"TntExpressAccount",
|
69
|
-
"UpsAccount",
|
70
|
-
"UpsMailInnovationsAccount",
|
71
|
-
"UpsSurepostAccount"
|
72
|
-
] }
|
73
|
-
|
74
|
-
it 'returns the expected list of types' do
|
75
|
-
types = EasyPost::CarrierAccount.types
|
76
|
-
account_types = types.map(&:type)
|
77
|
-
|
78
|
-
for account_type in carrier_account_types
|
79
|
-
expect(account_types).to include(account_type)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
data/spec/support/constant.rb
DELETED
@@ -1,87 +0,0 @@
|
|
1
|
-
ADDRESS = {
|
2
|
-
california: {
|
3
|
-
company: 'EasyPost',
|
4
|
-
street1: '164 Townsend Street',
|
5
|
-
street2: 'Unit 1',
|
6
|
-
city: 'San Francisco',
|
7
|
-
state: 'CA',
|
8
|
-
zip: '94107',
|
9
|
-
phone: '415-123-4567'
|
10
|
-
},
|
11
|
-
california_no_phone: {
|
12
|
-
company: 'EasyPost',
|
13
|
-
street1: '164 Townsend Street',
|
14
|
-
street2: 'Unit 1',
|
15
|
-
city: 'San Francisco',
|
16
|
-
state: 'CA',
|
17
|
-
zip: '94107'
|
18
|
-
},
|
19
|
-
missouri: {
|
20
|
-
company: 'Airport Shipping',
|
21
|
-
street1: '601 Brasilia Avenue',
|
22
|
-
city: 'Kansas City',
|
23
|
-
state: 'MO',
|
24
|
-
zip: '64153',
|
25
|
-
phone: '314-924-0383',
|
26
|
-
email: 'kansas_shipping@example.com'
|
27
|
-
},
|
28
|
-
canada: {
|
29
|
-
name: 'Sawyer Bateman',
|
30
|
-
street1: '58 Larkspur Cres.',
|
31
|
-
city: 'St. Albert',
|
32
|
-
state: 'AB',
|
33
|
-
zip: 'T8N2M4',
|
34
|
-
country: 'CA',
|
35
|
-
phone: '780-123-4567'
|
36
|
-
},
|
37
|
-
canada_no_phone: {
|
38
|
-
name: 'Sawyer Bateman',
|
39
|
-
street1: '58 Larkspur Cres.',
|
40
|
-
city: 'St. Albert',
|
41
|
-
state: 'AB',
|
42
|
-
zip: 't8n2m4',
|
43
|
-
country: 'CA',
|
44
|
-
phone: '780-273-8374'
|
45
|
-
}
|
46
|
-
}
|
47
|
-
|
48
|
-
PARCEL = {
|
49
|
-
dimensions: {
|
50
|
-
width: 12,
|
51
|
-
length: 16.5,
|
52
|
-
height: 9.5,
|
53
|
-
weight: 40.1
|
54
|
-
},
|
55
|
-
dimensions_light: {
|
56
|
-
width: 15.2,
|
57
|
-
length: 18,
|
58
|
-
height: 9.5,
|
59
|
-
weight: 3
|
60
|
-
},
|
61
|
-
predefined_medium_flat_rate_box: {
|
62
|
-
predefined_package: 'MediumFlatRateBox',
|
63
|
-
weight: 17
|
64
|
-
}
|
65
|
-
}
|
66
|
-
|
67
|
-
CUSTOMS_INFO = {
|
68
|
-
shirt: {
|
69
|
-
integrated_form_type: 'form_2976',
|
70
|
-
customs_certify: true,
|
71
|
-
customs_signer: 'Dr. Pepper',
|
72
|
-
contents_type: 'gift',
|
73
|
-
contents_explanation: '', # only required when contents_type: 'other'
|
74
|
-
eel_pfc: 'NOEEI 30.37(a)',
|
75
|
-
non_delivery_option: 'abandon',
|
76
|
-
restriction_type: 'none',
|
77
|
-
restriction_comments: '',
|
78
|
-
customs_items: [{
|
79
|
-
description: 'EasyPost T-shirts',
|
80
|
-
quantity: 2,
|
81
|
-
value: 23.56,
|
82
|
-
weight: 20,
|
83
|
-
origin_country: 'us',
|
84
|
-
hs_tariff_number: 123456
|
85
|
-
}]
|
86
|
-
}
|
87
|
-
}
|
data/spec/tracker_spec.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe EasyPost::Tracker do
|
4
|
-
describe '#create' do
|
5
|
-
it 'tracks' do
|
6
|
-
tracking_code = 'EZ2000000002'
|
7
|
-
carrier = 'usps'
|
8
|
-
|
9
|
-
tracker = EasyPost::Tracker.create({
|
10
|
-
tracking_code: tracking_code,
|
11
|
-
carrier: carrier
|
12
|
-
})
|
13
|
-
|
14
|
-
expect(tracker.carrier).to eq(carrier.upcase)
|
15
|
-
expect(tracker.tracking_code).to eq(tracking_code)
|
16
|
-
expect(tracker.status).to eq("in_transit")
|
17
|
-
expect(tracker.tracking_details.length).to be > 0
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
data/spec/user_spec.rb
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe EasyPost::User do
|
4
|
-
before do
|
5
|
-
EasyPost.api_key = "PRODUCTION API KEY"
|
6
|
-
end
|
7
|
-
|
8
|
-
# Uncomment these tests to test CRUD operations on the User model
|
9
|
-
# Note: You must provide a Production Api Key in order to run these tests
|
10
|
-
|
11
|
-
# it 'performs all basic CRUD actions on a User' do
|
12
|
-
# me = EasyPost::User.retrieve_me
|
13
|
-
# original_children_count = me.children.count
|
14
|
-
|
15
|
-
# name = 'Ruby All-Things-Testing'
|
16
|
-
|
17
|
-
# sub_user = EasyPost::User.create(
|
18
|
-
# name: name,
|
19
|
-
# password: 'password1',
|
20
|
-
# password_confirmation: 'password1',
|
21
|
-
# phone_number: '7778675309'
|
22
|
-
# )
|
23
|
-
|
24
|
-
# id = sub_user.id
|
25
|
-
# email = sub_user.email
|
26
|
-
|
27
|
-
# retrieved_user = EasyPost::User.retrieve(id)
|
28
|
-
# expect(retrieved_user.id).to eq(id)
|
29
|
-
# expect(retrieved_user.email).to eq(email)
|
30
|
-
# expect(retrieved_user.name).to eq(name)
|
31
|
-
|
32
|
-
# new_me = EasyPost::User.retrieve_me
|
33
|
-
# interm_children_count = new_me.children.count
|
34
|
-
# expect(interm_children_count).to eq(original_children_count + 1)
|
35
|
-
|
36
|
-
# new_name = 'Ruby All-Things-Tested'
|
37
|
-
# retrieved_user.name = new_name
|
38
|
-
# retrieved_user.save
|
39
|
-
|
40
|
-
# updated_user = EasyPost::User.retrieve(id)
|
41
|
-
# expect(updated_user.id).to eq(id)
|
42
|
-
# expect(updated_user.email).to eq(email)
|
43
|
-
# expect(updated_user.name).to eq(new_name)
|
44
|
-
# end
|
45
|
-
|
46
|
-
# describe '#all_api_keys' do
|
47
|
-
# it 'returns the correct set of api_keys' do
|
48
|
-
# api_keys = EasyPost::User.all_api_keys
|
49
|
-
|
50
|
-
# my_keys = api_keys.keys
|
51
|
-
# expect(my_keys.first.mode).to eq("production")
|
52
|
-
# expect(my_keys.last.mode).to eq("test")
|
53
|
-
|
54
|
-
# me = EasyPost::User.retrieve_me
|
55
|
-
# children_count = me.children.count
|
56
|
-
|
57
|
-
# expect(api_keys.children.count).to eq(children_count)
|
58
|
-
# end
|
59
|
-
# end
|
60
|
-
|
61
|
-
# describe '#api_keys' do
|
62
|
-
# it 'returns different keys for the parent and child users' do
|
63
|
-
# me = EasyPost::User.retrieve_me
|
64
|
-
# my_keys = me.api_keys
|
65
|
-
|
66
|
-
# child = me.children.first
|
67
|
-
# child_keys = child.api_keys
|
68
|
-
|
69
|
-
# expect(my_keys).not_to eq(child_keys)
|
70
|
-
# end
|
71
|
-
# end
|
72
|
-
end
|