easypost 3.0.1 → 3.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +0,0 @@
1
- require 'open-uri'
2
- require 'easypost'
3
-
4
- Dir["./spec/support/**/*.rb"].each { |f| require f }
5
-
6
- RSpec.configure do |config|
7
- config.before(:each) do
8
- EasyPost.api_key = 'cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi'
9
- end
10
- end
@@ -1,106 +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
- merchandise: {
88
- customs_certify: true,
89
- customs_signer: 'Dr. Pepper',
90
- contents_type: 'merchandise',
91
- contents_explanation: '', # only required when contents_type: 'other'
92
- eel_pfc: 'NOEEI 30.37(a)',
93
- non_delivery_option: 'abandon',
94
- restriction_type: 'none',
95
- restriction_comments: ''
96
- }
97
- }
98
-
99
- OPTIONS = {
100
- mws: {
101
- fulfiller_order_items: [{
102
- id: '12345678901234',
103
- quantity: 1
104
- }]
105
- }
106
- }
@@ -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
@@ -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
@@ -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