easypost 3.0.1 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +22 -0
- data/CHANGELOG +44 -3
- data/README.md +2 -1
- data/VERSION +1 -1
- data/easypost.gemspec +24 -20
- data/lib/easypost.rb +109 -118
- data/lib/easypost/address.rb +47 -47
- data/lib/easypost/batch.rb +34 -38
- data/lib/easypost/carrier_account.rb +3 -6
- data/lib/easypost/carrier_type.rb +2 -0
- data/lib/easypost/customs_info.rb +3 -2
- data/lib/easypost/customs_item.rb +3 -2
- data/lib/easypost/error.rb +25 -33
- data/lib/easypost/event.rb +3 -6
- data/lib/easypost/insurance.rb +1 -3
- data/lib/easypost/item.rb +4 -8
- data/lib/easypost/object.rb +111 -113
- data/lib/easypost/order.rb +20 -18
- data/lib/easypost/parcel.rb +1 -3
- data/lib/easypost/pickup.rb +19 -18
- data/lib/easypost/pickup_rate.rb +1 -3
- data/lib/easypost/postage_label.rb +1 -3
- data/lib/easypost/print_job.rb +1 -5
- data/lib/easypost/printer.rb +18 -22
- data/lib/easypost/rate.rb +1 -3
- data/lib/easypost/refund.rb +1 -3
- data/lib/easypost/report.rb +22 -24
- data/lib/easypost/resource.rb +58 -60
- data/lib/easypost/scan_form.rb +4 -6
- data/lib/easypost/shipment.rb +90 -92
- data/lib/easypost/tracker.rb +10 -12
- data/lib/easypost/user.rb +33 -37
- data/lib/easypost/util.rb +99 -136
- data/lib/easypost/webhook.rb +22 -21
- metadata +35 -62
- data/circle.yml +0 -3
- data/spec/address_spec.rb +0 -81
- data/spec/batch_spec.rb +0 -48
- data/spec/carrier_account_spec.rb +0 -121
- data/spec/insurance_spec.rb +0 -69
- data/spec/item_spec.rb +0 -105
- data/spec/order_spec.rb +0 -58
- data/spec/pickup_spec.rb +0 -83
- data/spec/report_spec.rb +0 -59
- data/spec/scan_form_spec.rb +0 -46
- data/spec/shipment_spec.rb +0 -144
- data/spec/spec_helper.rb +0 -10
- data/spec/support/constant.rb +0 -106
- data/spec/tracker_spec.rb +0 -94
- data/spec/user_spec.rb +0 -88
- data/spec/webhook_spec.rb +0 -75
data/spec/tracker_spec.rb
DELETED
@@ -1,94 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe EasyPost::Tracker do
|
4
|
-
let(:tracking_code) { 'EZ2000000002' }
|
5
|
-
let(:carrier) { 'usps' }
|
6
|
-
|
7
|
-
describe '#create' do
|
8
|
-
it 'tracks' do
|
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
|
-
|
21
|
-
describe '#index' do
|
22
|
-
it 'retrieves a full page of trackers' do
|
23
|
-
trackers = EasyPost::Tracker.all
|
24
|
-
|
25
|
-
expect(trackers["trackers"].count).to eq(30)
|
26
|
-
expect(trackers["has_more"]).to eq(true)
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'retrieves all trackers with given tracking code, up to a page' do
|
30
|
-
trackers = EasyPost::Tracker.all(tracking_code: tracking_code)
|
31
|
-
|
32
|
-
expect(trackers["trackers"].count).to eq(30)
|
33
|
-
expect(trackers["has_more"]).to eq(true)
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'retrieves all trackers with given tracking code and carrier, up to a page' do
|
37
|
-
trackers = EasyPost::Tracker.all(tracking_code: tracking_code, carrier: carrier)
|
38
|
-
|
39
|
-
expect(trackers["trackers"].count).to eq(30)
|
40
|
-
expect(trackers["has_more"]).to eq(true)
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'retrieves trackers correctly based on datetime' do
|
44
|
-
datetime = Time.now.utc
|
45
|
-
|
46
|
-
tracker = EasyPost::Tracker.create({
|
47
|
-
tracking_code: tracking_code,
|
48
|
-
carrier: carrier
|
49
|
-
})
|
50
|
-
|
51
|
-
trackers = EasyPost::Tracker.all(start_datetime: datetime, tracking_code: tracking_code)
|
52
|
-
|
53
|
-
expect(trackers["trackers"].count).to eq(1)
|
54
|
-
expect(trackers["trackers"].first.id).to eq(tracker.id)
|
55
|
-
expect(trackers["has_more"]).to eq(false)
|
56
|
-
|
57
|
-
trackers = EasyPost::Tracker.all(end_datetime: datetime, tracking_code: tracking_code)
|
58
|
-
|
59
|
-
expect(trackers["trackers"].count).to eq(30)
|
60
|
-
trackers["trackers"].each do |trk|
|
61
|
-
expect(trk.id).not_to eq(tracker.id)
|
62
|
-
end
|
63
|
-
expect(trackers["has_more"]).to eq(true)
|
64
|
-
end
|
65
|
-
|
66
|
-
it 'retrieves trackers correctly based on id' do
|
67
|
-
tracker = EasyPost::Tracker.create({
|
68
|
-
tracking_code: tracking_code,
|
69
|
-
carrier: carrier
|
70
|
-
})
|
71
|
-
|
72
|
-
tracker2 = EasyPost::Tracker.create({
|
73
|
-
tracking_code: tracking_code,
|
74
|
-
carrier: carrier
|
75
|
-
})
|
76
|
-
|
77
|
-
trackers = EasyPost::Tracker.all(after_id: tracker.id, tracking_code: tracking_code)
|
78
|
-
|
79
|
-
expect(trackers["trackers"].count).to eq(1)
|
80
|
-
expect(trackers["trackers"].first.id).to eq(tracker2.id)
|
81
|
-
expect(trackers["trackers"].first.id).not_to eq(tracker.id)
|
82
|
-
expect(trackers["has_more"]).to eq(false)
|
83
|
-
|
84
|
-
trackers = EasyPost::Tracker.all(before_id: tracker.id, tracking_code: tracking_code)
|
85
|
-
|
86
|
-
expect(trackers["trackers"].count).to eq(30)
|
87
|
-
trackers["trackers"].each do |trk|
|
88
|
-
expect(trk.id).not_to eq(tracker.id)
|
89
|
-
expect(trk.id).not_to eq(tracker2.id)
|
90
|
-
end
|
91
|
-
expect(trackers["has_more"]).to eq(true)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
data/spec/user_spec.rb
DELETED
@@ -1,88 +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
|
-
# This test requires APIKEY to be nil
|
9
|
-
# it 'creates a new user' do
|
10
|
-
# EasyPost.api_key = nil
|
11
|
-
|
12
|
-
# user = EasyPost::User.create({
|
13
|
-
# name: "Chad Vader",
|
14
|
-
# email: 'c.vader3@example.com',
|
15
|
-
# password: "4theempire",
|
16
|
-
# password_confirmation: "4theempire",
|
17
|
-
# phone_number: '555-123-4321'
|
18
|
-
# })
|
19
|
-
|
20
|
-
# expect(user.id).not_to be_nil
|
21
|
-
# end
|
22
|
-
|
23
|
-
|
24
|
-
# Uncomment these tests to test CRUD operations on the User model
|
25
|
-
# Note: You must provide a Production Api Key in order to run these tests
|
26
|
-
|
27
|
-
# it 'performs all basic CRUD actions on a User' do
|
28
|
-
# me = EasyPost::User.retrieve_me
|
29
|
-
# original_children_count = me.children.count
|
30
|
-
|
31
|
-
# name = 'Ruby All-Things-Testing'
|
32
|
-
|
33
|
-
# sub_user = EasyPost::User.create(
|
34
|
-
# name: name,
|
35
|
-
# password: 'password1',
|
36
|
-
# password_confirmation: 'password1',
|
37
|
-
# phone_number: '7778675309'
|
38
|
-
# )
|
39
|
-
|
40
|
-
# id = sub_user.id
|
41
|
-
# email = sub_user.email
|
42
|
-
|
43
|
-
# retrieved_user = EasyPost::User.retrieve(id)
|
44
|
-
# expect(retrieved_user.id).to eq(id)
|
45
|
-
# expect(retrieved_user.email).to eq(email)
|
46
|
-
# expect(retrieved_user.name).to eq(name)
|
47
|
-
|
48
|
-
# new_me = EasyPost::User.retrieve_me
|
49
|
-
# interm_children_count = new_me.children.count
|
50
|
-
# expect(interm_children_count).to eq(original_children_count + 1)
|
51
|
-
|
52
|
-
# new_name = 'Ruby All-Things-Tested'
|
53
|
-
# retrieved_user.name = new_name
|
54
|
-
# retrieved_user.save
|
55
|
-
|
56
|
-
# updated_user = EasyPost::User.retrieve(id)
|
57
|
-
# expect(updated_user.id).to eq(id)
|
58
|
-
# expect(updated_user.email).to eq(email)
|
59
|
-
# expect(updated_user.name).to eq(new_name)
|
60
|
-
# end
|
61
|
-
|
62
|
-
# describe '#all_api_keys' do
|
63
|
-
# it 'returns the correct set of api_keys' do
|
64
|
-
# api_keys = EasyPost::User.all_api_keys
|
65
|
-
|
66
|
-
# my_keys = api_keys.keys
|
67
|
-
# expect(my_keys.first.mode).to eq("test")
|
68
|
-
# expect(my_keys.last.mode).to eq("production")
|
69
|
-
|
70
|
-
# me = EasyPost::User.retrieve_me
|
71
|
-
# children_count = me.children.count
|
72
|
-
|
73
|
-
# expect(api_keys.children.count).to eq(children_count)
|
74
|
-
# end
|
75
|
-
# end
|
76
|
-
|
77
|
-
# describe '#api_keys' do
|
78
|
-
# it 'returns different keys for the parent and child users' do
|
79
|
-
# me = EasyPost::User.retrieve_me
|
80
|
-
# my_keys = me.api_keys
|
81
|
-
|
82
|
-
# child = me.children.first
|
83
|
-
# child_keys = child.api_keys
|
84
|
-
|
85
|
-
# expect(my_keys).not_to eq(child_keys)
|
86
|
-
# end
|
87
|
-
# end
|
88
|
-
end
|
data/spec/webhook_spec.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe EasyPost::Webhook do
|
4
|
-
let(:url) { "http://example.com" }
|
5
|
-
let(:webhook) { EasyPost::Webhook.create({url: url}) }
|
6
|
-
|
7
|
-
context 'with automated cleanup' do
|
8
|
-
after do
|
9
|
-
webhook.delete()
|
10
|
-
end
|
11
|
-
|
12
|
-
describe '#create' do
|
13
|
-
it 'creates' do
|
14
|
-
expect(webhook.id).not_to be_nil
|
15
|
-
expect(webhook.url).to eq(url)
|
16
|
-
expect(webhook.mode).to eq("test")
|
17
|
-
expect(webhook.disabled_at).to be_nil
|
18
|
-
expect(webhook.class).to eq(EasyPost::Webhook)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe '#retrieve' do
|
23
|
-
it 'retrieves' do
|
24
|
-
hook = EasyPost::Webhook.retrieve(webhook.id)
|
25
|
-
|
26
|
-
expect(hook.id).to eq(webhook.id)
|
27
|
-
expect(hook.url).to eq(url)
|
28
|
-
expect(hook.mode).to eq("test")
|
29
|
-
expect(hook.disabled_at).to be_nil
|
30
|
-
expect(hook.class).to eq(EasyPost::Webhook)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe '#index' do
|
35
|
-
it 'indexes with the recently created webhook as the last one' do
|
36
|
-
webhook
|
37
|
-
webhooks = EasyPost::Webhook.all()
|
38
|
-
|
39
|
-
hook = webhooks["webhooks"].last
|
40
|
-
|
41
|
-
expect(hook.id).to eq(webhook.id)
|
42
|
-
expect(hook.url).to eq(url)
|
43
|
-
expect(hook.mode).to eq("test")
|
44
|
-
expect(hook.disabled_at).to be_nil
|
45
|
-
expect(hook.class).to eq(EasyPost::Webhook)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe '#retrieve' do
|
50
|
-
it 'retrieves' do
|
51
|
-
hook = webhook.update()
|
52
|
-
|
53
|
-
expect(hook.id).to eq(webhook.id)
|
54
|
-
expect(hook.url).to eq(url)
|
55
|
-
expect(hook.mode).to eq("test")
|
56
|
-
expect(hook.disabled_at).to be_nil
|
57
|
-
expect(hook.class).to eq(EasyPost::Webhook)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
describe '#delete' do
|
63
|
-
it 'deletes the tracker' do
|
64
|
-
webhook.delete()
|
65
|
-
|
66
|
-
begin
|
67
|
-
EasyPost::Webhook.retrieve(webhook.id)
|
68
|
-
rescue EasyPost::Error => e
|
69
|
-
expect(e.http_status).to eq(404)
|
70
|
-
expect(e.code).to eq("NOT_FOUND")
|
71
|
-
expect(e.message).to eq("The requested resource could not be found.")
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|