easypost 2.1.0 → 2.2.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.
data/spec/order_spec.rb CHANGED
@@ -1,11 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe EasyPost::Order do
4
-
5
4
  describe '#create' do
6
-
7
5
  it 'creates an order out of a single shipment' do
8
-
9
6
  order = EasyPost::Order.create(
10
7
  to_address: ADDRESS[:california],
11
8
  from_address: ADDRESS[:missouri],
@@ -19,10 +16,10 @@ describe EasyPost::Order do
19
16
  end
20
17
 
21
18
  it 'creates an order out of two shipments' do
22
-
23
19
  order = EasyPost::Order.create(
24
20
  to_address: ADDRESS[:california],
25
21
  from_address: ADDRESS[:missouri],
22
+ carrier_accounts: [{id: "ca_12345678"}],
26
23
  shipments: [{
27
24
  parcel: {length: 8, width: 6, height: 4, weight: 12}
28
25
  },{
@@ -33,88 +30,5 @@ describe EasyPost::Order do
33
30
  expect(order).to be_an_instance_of(EasyPost::Order)
34
31
  expect(order.shipments.first).to be_an_instance_of(EasyPost::Shipment)
35
32
  end
36
-
37
- it 'creates and buys an international order out of two shipments' do
38
-
39
- order = EasyPost::Order.create(
40
- # to_address: ADDRESS[:canada],
41
- to_address: ADDRESS[:california],
42
- from_address: ADDRESS[:missouri],
43
- customs_info: CUSTOMS_INFO[:shirt],
44
- shipments: [{
45
- parcel: {length: 8, width: 6, height: 4, weight: 12}
46
- },{
47
- parcel: {length: 8, width: 6, height: 4, weight: 24}
48
- }]
49
- )
50
- order.buy(carrier: "fedex", service: "FEDEX_GROUND")
51
-
52
- expect(order).to be_an_instance_of(EasyPost::Order)
53
- expect(order.shipments.first).to be_an_instance_of(EasyPost::Shipment)
54
- end
55
-
56
-
57
- # it 'creates an order object out of a single item' do
58
- # order = EasyPost::Order.create(
59
- # :to_address => ADDRESS[:california],
60
- # :from_address => ADDRESS[:missouri],
61
- # :containers => "*", # only uses your containers
62
- # :items => [ITEM[:shirt]]
63
- # )
64
- # expect(order).to be_an_instance_of(EasyPost::Order)
65
- # expect(order.shiments.first).to be_an_instance_of(EasyPost::Shipment)
66
- # expect(order.shiments.first.from_address).to be_an_instance_of(EasyPost::Address)
67
- # expect(order.shiments.length).to eq(1)
68
- # end
69
-
70
- # it 'creates an order object out of multiple items' do
71
- # order = EasyPost::Order.create(
72
- # :to_address => ADDRESS[:california],
73
- # :from_address => ADDRESS[:missouri],
74
- # :containers => ["USPS.FLAT_RATE.*", "USPS.REGIONAL_RATE.*"],
75
- # :items => [ITEM[:shirt], ITEM[:pants]]
76
- # )
77
- # expect(order).to be_an_instance_of(EasyPost::Order)
78
- # expect(order.shiments.first).to be_an_instance_of(EasyPost::Shipment)
79
- # expect(order.shiments.first.from_address).to be_an_instance_of(EasyPost::Address)
80
- # end
81
-
82
- # it 'creates an order object with options' do
83
- # order = EasyPost::Order.create(
84
- # :to_address => ADDRESS[:california],
85
- # :from_address => ADDRESS[:missouri],
86
- # :containers => [{id: "container_USPSFR01"}, "USPS.REGIONAL_RATE.*"],
87
- # :items => [ITEM[:shirt], ITEM[:pants]],
88
- # :options => {alcohol: true}
89
- # )
90
- # expect(order).to be_an_instance_of(EasyPost::Order)
91
- # expect(order.shiments.first).to be_an_instance_of(EasyPost::Shipment)
92
- # expect(order.shiments.first.options[:alcohol]).to be_true
93
- # end
94
-
95
- # it 'creates an order object with custom item and passed without array' do
96
- # item = EasyPost::Item.create(
97
- # name: "Test Item",
98
- # sku: "1234567890",
99
- # length: 6.0,
100
- # width: 8.0,
101
- # height: 10,
102
- # weight: 13,
103
- # value: 13.00
104
- # ))
105
- # item.value = 9.99
106
-
107
- # order = EasyPost::Order.create(
108
- # :to_address => ADDRESS[:california],
109
- # :from_address => ADDRESS[:missouri],
110
- # :containers => EasyPost::Container::ALL,
111
- # :items => item
112
- # )
113
- # expect(order.shiments.first.item).to be_an_instance_of(EasyPost::Item)
114
- # expect(order.shiments.first.item.value).to eq(9.99)
115
- # expect(order.shiments.first.item.sku).to eq("1234567890")
116
-
117
- # end
118
33
  end
119
-
120
34
  end
data/spec/pickup_spec.rb CHANGED
@@ -1,15 +1,19 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe EasyPost::Pickup do
4
+ before { EasyPost.api_key = "cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi" }
5
+
6
+ let(:shipment) do
7
+ shipment = EasyPost::Shipment.create(
8
+ to_address: ADDRESS[:california],
9
+ from_address: ADDRESS[:missouri],
10
+ parcel: PARCEL[:dimensions]
11
+ )
12
+ end
4
13
 
5
14
  describe '#create' do
6
15
  it 'creates a pickup and returns rates' do
7
- shipment = EasyPost::Shipment.create(
8
- :to_address => ADDRESS[:california],
9
- :from_address => ADDRESS[:missouri],
10
- :parcel => PARCEL[:dimensions]
11
- )
12
- shipment.buy(:rate => shipment.lowest_rate("ups", "ground"))
16
+ shipment.buy(rate: shipment.lowest_rate("ups", "NextDayAirEarlyAM"))
13
17
  pickup = EasyPost::Pickup.create(
14
18
  address: ADDRESS[:missouri],
15
19
  reference: "12345678",
@@ -22,16 +26,10 @@ describe EasyPost::Pickup do
22
26
 
23
27
  expect(pickup).to be_an_instance_of(EasyPost::Pickup)
24
28
  expect(pickup.pickup_rates.first).to be_an_instance_of(EasyPost::PickupRate)
25
-
26
29
  end
27
30
 
28
31
  it 'fails to create a pickup' do
29
- shipment = EasyPost::Shipment.create(
30
- :to_address => ADDRESS[:california],
31
- :from_address => ADDRESS[:missouri],
32
- :parcel => PARCEL[:dimensions]
33
- )
34
- shipment.buy(:rate => shipment.lowest_rate("ups", "ground"))
32
+ shipment.buy(rate: shipment.lowest_rate("ups", "NextDayAirEarlyAM"))
35
33
  expect { pickup = EasyPost::Pickup.create(
36
34
  address: ADDRESS[:california],
37
35
  reference: "12345678",
@@ -45,12 +43,7 @@ describe EasyPost::Pickup do
45
43
 
46
44
  describe '#buy' do
47
45
  it 'buys a pickup rate' do
48
- shipment = EasyPost::Shipment.create(
49
- :to_address => ADDRESS[:california],
50
- :from_address => ADDRESS[:missouri],
51
- :parcel => PARCEL[:dimensions]
52
- )
53
- shipment.buy(:rate => shipment.lowest_rate("ups", "ground"))
46
+ shipment.buy(rate: shipment.lowest_rate("ups", "NextDayAirEarlyAM"))
54
47
  pickup = EasyPost::Pickup.create(
55
48
  address: ADDRESS[:california],
56
49
  reference: "buy12345678",
@@ -66,4 +59,25 @@ describe EasyPost::Pickup do
66
59
  end
67
60
  end
68
61
 
62
+ describe '#cancel' do
63
+ it 'cancels a pickup' do
64
+ shipment.buy(rate: shipment.lowest_rate("ups", "NextDayAirEarlyAM"))
65
+ pickup = EasyPost::Pickup.create(
66
+ address: ADDRESS[:california],
67
+ reference: "buy12345678",
68
+ min_datetime: DateTime.now(),
69
+ max_datetime: DateTime.now() + 14400,
70
+ is_account_address: false,
71
+ instructions: "",
72
+ shipment: shipment
73
+ )
74
+ pickup.buy(pickup.pickup_rates.first)
75
+
76
+ expect(pickup.status).to eq("scheduled")
77
+
78
+ pickup.cancel
79
+
80
+ expect(pickup.status).to eq("canceled")
81
+ end
82
+ end
69
83
  end
@@ -1,14 +1,13 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe EasyPost::Shipment do
4
-
5
4
  describe '#create' do
6
5
  it 'creates a shipment object' do
7
6
 
8
7
  shipment = EasyPost::Shipment.create(
9
- :to_address => ADDRESS[:california],
10
- :from_address => ADDRESS[:missouri],
11
- :parcel => PARCEL[:dimensions]
8
+ to_address: ADDRESS[:california],
9
+ from_address: EasyPost::Address.create(ADDRESS[:missouri]),
10
+ parcel: EasyPost::Parcel.create(PARCEL[:dimensions])
12
11
  )
13
12
  expect(shipment).to be_an_instance_of(EasyPost::Shipment)
14
13
  expect(shipment.from_address).to be_an_instance_of(EasyPost::Address)
@@ -20,20 +19,35 @@ describe EasyPost::Shipment do
20
19
  it 'purchases postage for an international shipment' do
21
20
 
22
21
  shipment = EasyPost::Shipment.create(
23
- :to_address => ADDRESS[:canada],
24
- :from_address => ADDRESS[:california],
25
- :parcel => PARCEL[:dimensions],
26
- :customs_info => CUSTOMS_INFO[:shirt]
22
+ to_address: EasyPost::Address.create(ADDRESS[:canada]),
23
+ from_address: ADDRESS[:california],
24
+ parcel: EasyPost::Parcel.create(PARCEL[:dimensions]),
25
+ customs_info: EasyPost::CustomsInfo.create(CUSTOMS_INFO[:shirt])
27
26
  )
28
27
  expect(shipment).to be_an_instance_of(EasyPost::Shipment)
29
28
 
30
29
  shipment.buy(
31
- :rate => shipment.lowest_rate("usps")
30
+ rate: shipment.lowest_rate("usps")
32
31
  )
33
32
  expect(shipment.postage_label.label_url.length).to be > 0
34
33
  end
35
34
 
36
35
  it 'purchases postage for a domestic shipment' do
36
+ shipment = EasyPost::Shipment.create(
37
+ to_address: EasyPost::Address.create(ADDRESS[:missouri]),
38
+ from_address: ADDRESS[:california],
39
+ parcel: EasyPost::Parcel.create(PARCEL[:dimensions])
40
+ )
41
+ expect(shipment).to be_an_instance_of(EasyPost::Shipment)
42
+
43
+ shipment.buy(
44
+ rate: shipment.lowest_rate("usps")
45
+ )
46
+ expect(shipment.postage_label.label_url.length).to be > 0
47
+ end
48
+ end
49
+
50
+ it 'creates and returns a tracker with shipment purchase' do
37
51
  shipment = EasyPost::Shipment.create(
38
52
  :to_address => ADDRESS[:missouri],
39
53
  :from_address => ADDRESS[:california],
@@ -44,12 +58,13 @@ describe EasyPost::Shipment do
44
58
  shipment.buy(
45
59
  :rate => shipment.lowest_rate("usps")
46
60
  )
47
- expect(shipment.postage_label.label_url.length).to be > 0
48
- end
61
+
62
+ tracker = shipment.tracker
63
+ expect(tracker.shipment_id).to eq(shipment.id)
49
64
  end
50
65
 
51
- describe '#stamp' do
52
- it 'returns a stamp for a domestic shipment' do
66
+ describe '#insure' do
67
+ it 'buys and insures a shipments' do
53
68
  shipment = EasyPost::Shipment.create(
54
69
  :to_address => ADDRESS[:missouri],
55
70
  :from_address => ADDRESS[:california],
@@ -58,7 +73,26 @@ describe EasyPost::Shipment do
58
73
  expect(shipment).to be_an_instance_of(EasyPost::Shipment)
59
74
 
60
75
  shipment.buy(
61
- :rate => shipment.lowest_rate(['USPS', 'UPS'], 'priority, express')
76
+ :rate => shipment.lowest_rate("usps")
77
+ )
78
+
79
+ shipment.insure(amount: 100)
80
+
81
+ expect(shipment.insurance).to eq("100.00")
82
+ end
83
+ end
84
+
85
+ describe '#stamp' do
86
+ it 'returns a stamp for a domestic shipment' do
87
+ shipment = EasyPost::Shipment.create(
88
+ to_address: EasyPost::Address.create(ADDRESS[:missouri]),
89
+ from_address: ADDRESS[:california],
90
+ parcel: EasyPost::Parcel.create(PARCEL[:dimensions])
91
+ )
92
+ expect(shipment).to be_an_instance_of(EasyPost::Shipment)
93
+
94
+ shipment.buy(
95
+ rate: shipment.lowest_rate(['USPS', 'UPS'], 'priority, express')
62
96
  )
63
97
 
64
98
  stamp_url = shipment.stamp
@@ -70,14 +104,14 @@ describe EasyPost::Shipment do
70
104
  describe '#barcode' do
71
105
  it 'returns a barcode for a domestic shipment' do
72
106
  shipment = EasyPost::Shipment.create(
73
- :to_address => ADDRESS[:missouri],
74
- :from_address => ADDRESS[:california],
75
- :parcel => PARCEL[:dimensions]
107
+ to_address: EasyPost::Address.create(ADDRESS[:missouri]),
108
+ from_address: ADDRESS[:california],
109
+ parcel: EasyPost::Parcel.create(PARCEL[:dimensions])
76
110
  )
77
111
  expect(shipment).to be_an_instance_of(EasyPost::Shipment)
78
112
 
79
113
  shipment.buy(
80
- :rate => shipment.lowest_rate('usps', ['Priority'])
114
+ rate: shipment.lowest_rate('usps', ['Priority'])
81
115
  )
82
116
 
83
117
  barcode_url = shipment.barcode
@@ -90,9 +124,9 @@ describe EasyPost::Shipment do
90
124
  context 'domestic shipment' do
91
125
  before :all do
92
126
  @shipment = EasyPost::Shipment.create(
93
- :to_address => ADDRESS[:missouri],
94
- :from_address => ADDRESS[:california],
95
- :parcel => PARCEL[:dimensions]
127
+ to_address: EasyPost::Address.create(ADDRESS[:missouri]),
128
+ from_address: ADDRESS[:california],
129
+ parcel: EasyPost::Parcel.create(PARCEL[:dimensions])
96
130
  )
97
131
  end
98
132
 
@@ -104,4 +138,12 @@ describe EasyPost::Shipment do
104
138
  end
105
139
  end
106
140
 
141
+ describe '#retrieve' do
142
+ it 'retrieves shipment by tracking_code and correctly sets ID field (this was a bug in python)' do
143
+ tracking_code = "LN123456789US"
144
+ shipment = EasyPost::Shipment.retrieve(tracking_code)
145
+
146
+ expect(shipment.id).not_to eq(tracking_code)
147
+ end
148
+ end
107
149
  end
data/spec/spec_helper.rb CHANGED
@@ -1,96 +1,10 @@
1
1
  require 'open-uri'
2
2
  require 'easypost'
3
- EasyPost.api_key = 'cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi'
4
- EasyPost.api_base = 'http://ep-vm-whatever:5000/v2'
5
3
 
6
- ADDRESS = {}
7
- ADDRESS[:california] = {
8
- :company => 'EasyPost',
9
- :street1 => '164 Townsend Street',
10
- :street2 => 'Unit 1',
11
- :city => 'San Francisco',
12
- :state => 'CA',
13
- :zip => '94107',
14
- :phone => '415-123-4567'
15
- }
4
+ Dir["./spec/support/**/*.rb"].each { |f| require f }
16
5
 
17
- ADDRESS[:california_no_phone] = {
18
- :company => 'EasyPost',
19
- :street1 => '164 Townsend Street',
20
- :street2 => 'Unit 1',
21
- :city => 'San Francisco',
22
- :state => 'CA',
23
- :zip => '94107'
24
- }
25
-
26
-
27
- ADDRESS[:missouri] = EasyPost::Address.create(
28
- :company => 'Airport Shipping',
29
- :street1 => '601 Brasilia Avenue',
30
- :city => 'Kansas City',
31
- :state => 'MO',
32
- :zip => '64153',
33
- :phone => '314-924-0383',
34
- :email => 'kansas_shipping@example.com'
35
- )
36
-
37
- ADDRESS[:canada] = EasyPost::Address.create(
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-123-4567'
45
- )
46
-
47
- ADDRESS[:canada_no_phone] = {
48
- :name => 'Sawyer Bateman',
49
- :street1 => '58 Larkspur Cres.',
50
- :city => 'St. Albert',
51
- :state => 'AB',
52
- :zip => 't8n2m4',
53
- :country => 'CA',
54
- :phone => '780-273-8374'
55
- }
56
-
57
- PARCEL = {}
58
- PARCEL[:dimensions] = EasyPost::Parcel.create(
59
- :width => 12,
60
- :length => 16.5,
61
- :height => 9.5,
62
- :weight => 40.1
63
- )
64
-
65
- PARCEL[:dimensions_light] = EasyPost::Parcel.create(
66
- :width => 15.2,
67
- :length => 18,
68
- :height => 9.5,
69
- :weight => 3
70
- )
71
-
72
- PARCEL[:predefined_medium_flat_rate_box] = EasyPost::Parcel.create(
73
- :predefined_package => 'MediumFlatRateBox',
74
- :weight => 17
75
- )
76
-
77
- CUSTOMS_INFO = {}
78
- CUSTOMS_INFO[:shirt] = EasyPost::CustomsInfo.create(
79
- :integrated_form_type => 'form_2976',
80
- :customs_certify => true,
81
- :customs_signer => 'Dr. Pepper',
82
- :contents_type => 'gift',
83
- :contents_explanation => '', # only required when contents_type => 'other'
84
- :eel_pfc => 'NOEEI 30.37(a)',
85
- :non_delivery_option => 'abandon',
86
- :restriction_type => 'none',
87
- :restriction_comments => '',
88
- :customs_items => [{
89
- :description => 'EasyPost T-shirts',
90
- :quantity => 2,
91
- :value => 23.56,
92
- :weight => 20,
93
- :origin_country => 'us',
94
- :hs_tariff_number => 123456
95
- }]
96
- )
6
+ RSpec.configure do |config|
7
+ config.before(:each) do
8
+ EasyPost.api_key = 'cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi'
9
+ end
10
+ end
@@ -0,0 +1,97 @@
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
+ }
@@ -0,0 +1,94 @@
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