easypost 2.0.13 → 2.1.1

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.
metadata CHANGED
@@ -1,68 +1,89 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easypost
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.13
5
- prerelease:
4
+ version: 2.1.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Sawyer Bateman
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-10-30 00:00:00.000000000 Z
11
+ date: 2015-04-15 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rest-client
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1.4'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '1.4'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: multi_json
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: 1.0.4
38
- - - <
34
+ - - "<"
39
35
  - !ruby/object:Gem::Version
40
36
  version: '2'
41
37
  type: :runtime
42
38
  prerelease: false
43
39
  version_requirements: !ruby/object:Gem::Requirement
44
- none: false
45
40
  requirements:
46
- - - ! '>='
41
+ - - ">="
47
42
  - !ruby/object:Gem::Version
48
43
  version: 1.0.4
49
- - - <
44
+ - - "<"
50
45
  - !ruby/object:Gem::Version
51
46
  version: '2'
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.7'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.7'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rake
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '10.0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '10.0'
52
75
  - !ruby/object:Gem::Dependency
53
76
  name: rspec
54
77
  requirement: !ruby/object:Gem::Requirement
55
- none: false
56
78
  requirements:
57
- - - ~>
79
+ - - "~>"
58
80
  - !ruby/object:Gem::Version
59
81
  version: 2.13.0
60
82
  type: :development
61
83
  prerelease: false
62
84
  version_requirements: !ruby/object:Gem::Requirement
63
- none: false
64
85
  requirements:
65
- - - ~>
86
+ - - "~>"
66
87
  - !ruby/object:Gem::Version
67
88
  version: 2.13.0
68
89
  description: Client library for accessing the EasyPost shipping API via Ruby.
@@ -72,7 +93,7 @@ executables:
72
93
  extensions: []
73
94
  extra_rdoc_files: []
74
95
  files:
75
- - .gitignore
96
+ - ".gitignore"
76
97
  - CHANGELOG
77
98
  - Gemfile
78
99
  - LICENSE
@@ -84,6 +105,7 @@ files:
84
105
  - lib/easypost.rb
85
106
  - lib/easypost/address.rb
86
107
  - lib/easypost/batch.rb
108
+ - lib/easypost/carrier_account.rb
87
109
  - lib/easypost/container.rb
88
110
  - lib/easypost/customs_info.rb
89
111
  - lib/easypost/customs_item.rb
@@ -102,45 +124,54 @@ files:
102
124
  - lib/easypost/scan_form.rb
103
125
  - lib/easypost/shipment.rb
104
126
  - lib/easypost/tracker.rb
127
+ - lib/easypost/user.rb
105
128
  - lib/easypost/util.rb
106
129
  - lib/easypost/version.rb
107
130
  - spec/address_spec.rb
108
131
  - spec/batch_spec.rb
132
+ - spec/carrier_account_spec.rb
109
133
  - spec/container_spec.rb
110
- - spec/fedex/domestic_spec.rb
111
- - spec/fedex/international_spec.rb
112
134
  - spec/item_spec.rb
113
135
  - spec/order_spec.rb
114
136
  - spec/pickup_spec.rb
115
137
  - spec/shipment_spec.rb
116
138
  - spec/spec_helper.rb
117
- - spec/ups/domestic_spec.rb
118
- - spec/ups/international_spec.rb
119
- - spec/usps/domestic_spec.rb
120
- - spec/usps/electronic_merchandise_returns.rb
121
- - spec/usps/merchant_returns.rb
139
+ - spec/support/constant.rb
140
+ - spec/tracker_spec.rb
141
+ - spec/user_spec.rb
122
142
  homepage: https://www.easypost.com/docs
123
143
  licenses: []
144
+ metadata: {}
124
145
  post_install_message:
125
146
  rdoc_options: []
126
147
  require_paths:
127
148
  - lib
128
149
  required_ruby_version: !ruby/object:Gem::Requirement
129
- none: false
130
150
  requirements:
131
- - - ! '>='
151
+ - - ">="
132
152
  - !ruby/object:Gem::Version
133
153
  version: '0'
134
154
  required_rubygems_version: !ruby/object:Gem::Requirement
135
- none: false
136
155
  requirements:
137
- - - ! '>='
156
+ - - ">="
138
157
  - !ruby/object:Gem::Version
139
158
  version: '0'
140
159
  requirements: []
141
160
  rubyforge_project:
142
- rubygems_version: 1.8.25
161
+ rubygems_version: 2.2.2
143
162
  signing_key:
144
- specification_version: 3
163
+ specification_version: 4
145
164
  summary: EasyPost Ruby Client Library
146
- test_files: []
165
+ test_files:
166
+ - spec/address_spec.rb
167
+ - spec/batch_spec.rb
168
+ - spec/carrier_account_spec.rb
169
+ - spec/container_spec.rb
170
+ - spec/item_spec.rb
171
+ - spec/order_spec.rb
172
+ - spec/pickup_spec.rb
173
+ - spec/shipment_spec.rb
174
+ - spec/spec_helper.rb
175
+ - spec/support/constant.rb
176
+ - spec/tracker_spec.rb
177
+ - spec/user_spec.rb
@@ -1,180 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'fedex domestic' do
4
- before(:all) do
5
- @rates = {}
6
- end
7
-
8
- it 'buys a commercial ground label' do
9
- shipment = EasyPost::Shipment.create(
10
- :to_address => ADDRESS[:california],
11
- :from_address => ADDRESS[:missouri],
12
- :parcel => PARCEL[:dimensions]
13
- )
14
- shipment.buy(:rate => shipment.lowest_rate("fedex", "FEDEX_GROUND"))
15
- label = open(shipment.postage_label.label_url)
16
-
17
- expect(shipment).to be_an_instance_of(EasyPost::Shipment)
18
- expect(shipment.selected_rate).to be_an_instance_of(EasyPost::Rate)
19
- expect(shipment.selected_rate.service).to eq("FEDEX_GROUND")
20
- expect(shipment.postage_label.label_url).to end_with(".png")
21
- expect(shipment.tracking_code).to start_with("8000")
22
- expect(label.size).to be > 5000
23
-
24
- @rates[:commercial] = shipment.selected_rate
25
- end
26
-
27
- it 'buys a residential ground label' do
28
- shipment = EasyPost::Shipment.create(
29
- :to_address => ADDRESS[:california],
30
- :from_address => ADDRESS[:missouri],
31
- :parcel => PARCEL[:dimensions],
32
- :options => {:residential_to_address => true}
33
- )
34
- shipment.buy(:rate => shipment.lowest_rate("fedex", "GROUND_HOME_DELIVERY"))
35
- label = open(shipment.postage_label.label_url)
36
-
37
- expect(shipment.selected_rate.service).to eq("GROUND_HOME_DELIVERY")
38
- expect(shipment.tracking_code).to start_with("8000")
39
- expect(label.size).to be > 5000
40
-
41
- @rates[:residential] = shipment.selected_rate
42
- end
43
-
44
- it 'buys a ground evening delivery label' do
45
- shipment = EasyPost::Shipment.create(
46
- :to_address => ADDRESS[:california],
47
- :from_address => ADDRESS[:missouri],
48
- :parcel => PARCEL[:dimensions],
49
- :options => {:residential_to_address => true,
50
- :delivery_time_preference => "evening"}
51
- )
52
- shipment.buy(:rate => shipment.lowest_rate("fedex", "GROUND_HOME_DELIVERY"))
53
-
54
- expect(shipment.postage_label.label_url).to end_with(".png")
55
-
56
- @rates[:residential_evening] = shipment.selected_rate
57
- end
58
-
59
- it 'raises error without recipient phone number' do
60
- shipment = EasyPost::Shipment.create(
61
- :to_address => ADDRESS[:california_no_phone],
62
- :from_address => ADDRESS[:missouri],
63
- :parcel => PARCEL[:dimensions]
64
- )
65
-
66
- expect { shipment.buy(rate: shipment.lowest_rate("fedex")) }.to raise_error(EasyPost::Error, /Unable to buy FedEx shipment without recipient phone number./)
67
- end
68
-
69
- it 'buys a label for an alcoholic shipment with epl2 label' do
70
- shipment = EasyPost::Shipment.create(
71
- :to_address => ADDRESS[:california],
72
- :from_address => ADDRESS[:missouri],
73
- :parcel => PARCEL[:dimensions],
74
- :options => {
75
- :alcohol => 1,
76
- :label_format => "epl2"
77
- }
78
- )
79
- shipment.buy(:rate => shipment.lowest_rate("fedex", "PRIORITY_OVERNIGHT"))
80
-
81
- expect(shipment.postage_label.label_url).to end_with(".epl2")
82
- end
83
-
84
- it 'buys a label for a ground cod shipment' do
85
- shipment = EasyPost::Shipment.create(
86
- :to_address => ADDRESS[:california],
87
- :from_address => ADDRESS[:missouri],
88
- :parcel => PARCEL[:dimensions]
89
- )
90
- shipment_cod = EasyPost::Shipment.create(
91
- :to_address => ADDRESS[:california],
92
- :from_address => ADDRESS[:missouri],
93
- :parcel => PARCEL[:dimensions],
94
- :options => {cod_amount: 19.99}
95
- )
96
- shipment_cod.buy(rate: shipment_cod.lowest_rate("fedex", "FEDEX_GROUND"))
97
-
98
- expect(shipment.lowest_rate("fedex", "FEDEX_GROUND").rate.to_f).to be < (shipment_cod.lowest_rate("fedex", "FEDEX_GROUND").rate.to_f)
99
- expect(shipment.lowest_rate("fedex", "PRIORITY_OVERNIGHT").rate.to_f).to be < (shipment_cod.lowest_rate("fedex", "PRIORITY_OVERNIGHT").rate.to_f)
100
- expect(shipment_cod.postage_label.label_url).to be
101
- end
102
-
103
- it 'buys a label for a ground multi-parcel cod shipment' do
104
- order = EasyPost::Order.create(
105
- to_address: ADDRESS[:california],
106
- from_address: ADDRESS[:missouri],
107
- shipments: [{
108
- parcel: {length: 8, width: 6, height: 4, weight: 12},
109
- options: {cod_amount: 14.99}
110
- },{
111
- parcel: {length: 8, width: 6, height: 4, weight: 12},
112
- options: {cod_amount: 18.75}
113
- }]
114
- )
115
- order.buy(carrier: "fedex", service: "FEDEX_GROUND")
116
-
117
- expect(order).to be_an_instance_of(EasyPost::Order)
118
- expect(order.shipments.first).to be_an_instance_of(EasyPost::Shipment)
119
- expect(order.shipments[0].postage_label.label_url).to be
120
- expect(order.shipments[1].postage_label.label_url).to be
121
- end
122
-
123
- it 'buys a label for an express cod shipment' do
124
- shipment = EasyPost::Shipment.create(
125
- :to_address => ADDRESS[:california],
126
- :from_address => ADDRESS[:missouri],
127
- :parcel => PARCEL[:dimensions]
128
- )
129
- shipment_cod = EasyPost::Shipment.create(
130
- :to_address => ADDRESS[:california],
131
- :from_address => ADDRESS[:missouri],
132
- :parcel => PARCEL[:dimensions],
133
- :options => {cod_amount: 19.99}
134
- )
135
- shipment_cod.buy(rate: shipment_cod.lowest_rate("fedex", "PRIORITY_OVERNIGHT"))
136
-
137
- expect(shipment.lowest_rate("fedex", "FEDEX_GROUND").rate.to_f).to be < (shipment_cod.lowest_rate("fedex", "FEDEX_GROUND").rate.to_f)
138
- expect(shipment.lowest_rate("fedex", "PRIORITY_OVERNIGHT").rate.to_f).to be < (shipment_cod.lowest_rate("fedex", "PRIORITY_OVERNIGHT").rate.to_f)
139
- expect(shipment_cod.postage_label.label_url).to be
140
- end
141
-
142
- it 'buys a label for an express multi-parcel cod shipment' do
143
- order = EasyPost::Order.create(
144
- to_address: ADDRESS[:california],
145
- from_address: ADDRESS[:missouri],
146
- shipments: [{
147
- parcel: {length: 8, width: 6, height: 4, weight: 12},
148
- options: {cod_amount: 14.99}
149
- },{
150
- parcel: {length: 8, width: 6, height: 4, weight: 12},
151
- options: {cod_amount: 18.75}
152
- }]
153
- )
154
- order.buy(carrier: "fedex", service: "PRIORITY_OVERNIGHT")
155
-
156
- expect(order).to be_an_instance_of(EasyPost::Order)
157
- expect(order.shipments.first).to be_an_instance_of(EasyPost::Shipment)
158
- expect(order.shipments[0].postage_label.label_url).to be
159
- expect(order.shipments[1].postage_label.label_url).to be
160
- end
161
-
162
- it 'buys a label using a thid party account number' do
163
- shipment = EasyPost::Shipment.create(
164
- :to_address => ADDRESS[:california],
165
- :from_address => ADDRESS[:missouri],
166
- :parcel => PARCEL[:dimensions],
167
- :options => {:bill_third_party_account => "12345678"}
168
- )
169
- expect { shipment.buy(rate: shipment.lowest_rate("fedex")) }.to raise_error(EasyPost::Error, /ShippingChargesPayment Payor - The payor's account number is invalid/)
170
- end
171
-
172
- after(:all) do
173
- begin
174
- expect(@rates[:residential_evening].rate.to_i).to be > @rates[:residential].rate.to_i
175
- expect(@rates[:residential].rate.to_i).to be > @rates[:commercial].rate.to_i
176
- rescue
177
- end
178
- end
179
-
180
- end
@@ -1,64 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'fedex international' do
4
- before(:all) do
5
- @rates = {}
6
- end
7
-
8
- it 'buys a ground label' do
9
- shipment = EasyPost::Shipment.create(
10
- :to_address => ADDRESS[:canada],
11
- :from_address => ADDRESS[:california],
12
- :parcel => PARCEL[:dimensions],
13
- :customs_info => CUSTOMS_INFO[:shirt]
14
- )
15
- shipment.buy(:rate => shipment.lowest_rate("fedex", "FEDEX_GROUND"))
16
- label = open(shipment.postage_label.label_url)
17
-
18
- expect(shipment).to be_an_instance_of(EasyPost::Shipment)
19
- expect(shipment.selected_rate).to be_an_instance_of(EasyPost::Rate)
20
- expect(shipment.selected_rate.service).to eq("FEDEX_GROUND")
21
- expect(shipment.postage_label.label_url).to end_with(".png")
22
- expect(shipment.tracking_code).to start_with("8000")
23
- expect(label.size).to be > 5000
24
-
25
- @rates[:ground] = shipment.selected_rate
26
- end
27
-
28
- it 'buys an air label' do
29
- shipment = EasyPost::Shipment.create(
30
- :to_address => ADDRESS[:canada],
31
- :from_address => ADDRESS[:california],
32
- :parcel => PARCEL[:dimensions],
33
- :customs_info => CUSTOMS_INFO[:shirt]
34
- )
35
- shipment.buy(:rate => shipment.lowest_rate("fedex", "INTERNATIONAL_PRIORITY"))
36
- label = open(shipment.postage_label.label_url)
37
-
38
- expect(shipment.selected_rate.service).to eq("INTERNATIONAL_PRIORITY")
39
- expect(shipment.tracking_code).to start_with("794")
40
- expect(label.size).to be > 20000
41
-
42
- @rates[:air] = shipment.selected_rate
43
- end
44
-
45
- it 'returns no rates for an alcohol shipment', focus: true do
46
- shipment = EasyPost::Shipment.create(
47
- :to_address => ADDRESS[:canada],
48
- :from_address => ADDRESS[:california],
49
- :parcel => PARCEL[:dimensions],
50
- :customs_info => CUSTOMS_INFO[:shirt],
51
- :options => {:alcohol => true}
52
- )
53
-
54
- expect { shipment.lowest_rate("fedex") }.to raise_exception(EasyPost::Error, /No rates found/)
55
- end
56
-
57
- after(:all) do
58
- begin
59
- expect(@rates[:air].rate.to_i).to be > @rates[:ground].rate.to_i
60
- rescue
61
- end
62
- end
63
-
64
- end
@@ -1,79 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'ups domestic' do
4
- before(:all) do
5
- @rates = {}
6
- end
7
-
8
- it 'buys an air label' do
9
- shipment = EasyPost::Shipment.create(
10
- :to_address => ADDRESS[:california],
11
- :from_address => ADDRESS[:missouri],
12
- :parcel => PARCEL[:dimensions]
13
- )
14
- shipment.buy(:rate => shipment.lowest_rate("ups", "NextDayAir"))
15
- label = open(shipment.postage_label.label_url)
16
-
17
-
18
- expect(shipment).to be_an_instance_of(EasyPost::Shipment)
19
- expect(shipment.selected_rate).to be_an_instance_of(EasyPost::Rate)
20
- expect(shipment.selected_rate.service).to eq("NextDayAir")
21
- expect(shipment.postage_label.label_url).to end_with(".png")
22
- expect(shipment.tracking_code).to start_with("1Z")
23
- expect(label.size).to be > 5000
24
-
25
- @rates[:next_day_air] = shipment.selected_rate
26
- end
27
-
28
- it 'buys a residential ground label' do
29
- shipment = EasyPost::Shipment.create(
30
- :to_address => ADDRESS[:california],
31
- :from_address => ADDRESS[:missouri],
32
- :parcel => PARCEL[:dimensions],
33
- :options => {:residential_to_address => true}
34
- )
35
- shipment.buy(:rate => shipment.lowest_rate("ups", "Ground"))
36
- label = open(shipment.postage_label.label_url)
37
-
38
- expect(shipment.selected_rate.service).to eq("Ground")
39
- expect(shipment.tracking_code).to start_with("1Z")
40
- expect(label.size).to be > 5000
41
-
42
- @rates[:ground] = shipment.selected_rate
43
- end
44
-
45
- it 'buys a label for an alcoholic shipment and epl2 label' do
46
- shipment = EasyPost::Shipment.create(
47
- :to_address => ADDRESS[:california],
48
- :from_address => ADDRESS[:missouri],
49
- :parcel => PARCEL[:dimensions],
50
- :options => {alcohol: true, label_format: "epl2"}
51
- )
52
- shipment.buy(:rate => shipment.lowest_rate("ups", "Ground"))
53
-
54
- expect(shipment.postage_label.label_url).to end_with(".epl2")
55
- end
56
-
57
- # it 'buys an order with shipment level cod', focus: true do
58
- # order = EasyPost::Order.create(
59
- # to_address: ADDRESS[:california],
60
- # from_address: ADDRESS[:missouri],
61
- # options: {cod_amount: 19.99},
62
- # shipments: [{
63
- # parcel: {length: 8, width: 6, height: 4, weight: 12}
64
- # },{
65
- # parcel: {length: 8, width: 6, height: 4, weight: 12}
66
- # }]
67
- # )
68
- # p order
69
- # # order.buy(carrier: "ups", service: "Ground")
70
- # end
71
-
72
- after(:all) do
73
- begin
74
- expect(@rates[:next_day_air].rate.to_i).to be > @rates[:ground].rate.to_i
75
- rescue
76
- end
77
- end
78
-
79
- end
@@ -1,64 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'ups international' do
4
- before(:all) do
5
- @rates = {}
6
- end
7
-
8
- it 'buys a UPSStandard label' do
9
- shipment = EasyPost::Shipment.create(
10
- :to_address => ADDRESS[:canada],
11
- :from_address => ADDRESS[:california],
12
- :parcel => PARCEL[:dimensions],
13
- :customs_info => CUSTOMS_INFO[:shirt]
14
- )
15
- shipment.buy(:rate => shipment.lowest_rate("ups", "UPSStandard"))
16
- label = open(shipment.postage_label.label_url)
17
-
18
- expect(shipment).to be_an_instance_of(EasyPost::Shipment)
19
- expect(shipment.selected_rate).to be_an_instance_of(EasyPost::Rate)
20
- expect(shipment.selected_rate.service).to eq("UPSStandard")
21
- expect(shipment.postage_label.label_url).to end_with(".png")
22
- expect(shipment.tracking_code).to start_with("1Z")
23
- expect(label.size).to be > 5000
24
-
25
- @rates[:ground] = shipment.selected_rate
26
- end
27
-
28
- it 'buys an air label' do
29
- shipment = EasyPost::Shipment.create(
30
- :to_address => ADDRESS[:canada],
31
- :from_address => ADDRESS[:california],
32
- :parcel => PARCEL[:dimensions],
33
- :customs_info => CUSTOMS_INFO[:shirt]
34
- )
35
- shipment.buy(:rate => shipment.lowest_rate("ups", "Expedited"))
36
- label = open(shipment.postage_label.label_url)
37
-
38
- expect(shipment.selected_rate.service).to eq("Expedited")
39
- expect(shipment.tracking_code).to start_with("1Z")
40
- expect(label.size).to be > 20000
41
-
42
- @rates[:express] = shipment.selected_rate
43
- end
44
-
45
- it 'returns no rates for an alcohol shipment' do
46
- shipment = EasyPost::Shipment.create(
47
- :to_address => ADDRESS[:canada],
48
- :from_address => ADDRESS[:california],
49
- :parcel => PARCEL[:dimensions],
50
- :customs_info => CUSTOMS_INFO[:shirt],
51
- :options => {:alcohol => true}
52
- )
53
-
54
- expect { shipment.lowest_rate("ups") }.to raise_exception(EasyPost::Error, /No rates found/)
55
- end
56
-
57
- after(:all) do
58
- begin
59
- expect(@rates[:air].rate.to_i).to be > @rates[:ground].rate.to_i
60
- rescue
61
- end
62
- end
63
-
64
- end
@@ -1,66 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'usps domestic' do
4
- before(:all) do
5
- @first = EasyPost::Shipment.create(
6
- :to_address => ADDRESS[:california],
7
- :from_address => ADDRESS[:missouri],
8
- :parcel => PARCEL[:dimensions_light]
9
- )
10
- @first.buy(:rate => @first.lowest_rate("usps", "first"))
11
-
12
- @priority = EasyPost::Shipment.create(
13
- :to_address => ADDRESS[:california],
14
- :from_address => ADDRESS[:missouri],
15
- :parcel => PARCEL[:dimensions]
16
- )
17
- @priority.buy(:rate => @priority.lowest_rate("usps", "priority"))
18
-
19
- @return = EasyPost::Shipment.create(
20
- :to_address => ADDRESS[:california],
21
- :from_address => ADDRESS[:missouri],
22
- :parcel => PARCEL[:dimensions],
23
- :is_return => true
24
- )
25
- @return.buy(:rate => @return.lowest_rate("usps", "priority"))
26
-
27
- end
28
-
29
- it 'buys a first label' do
30
- expect(@first).to be_an_instance_of(EasyPost::Shipment)
31
- expect(@first.selected_rate).to be_an_instance_of(EasyPost::Rate)
32
- expect(@first.selected_rate.service).to eq("First")
33
- expect(@first.postage_label.label_url).to end_with(".png")
34
- expect(@first.tracking_code).to eq("9499907123456123456781")
35
-
36
- label = open(@first.postage_label.label_url)
37
- expect(label.size).to be > 30000
38
- end
39
-
40
- it 'buys a priority label' do
41
- expect(@priority.selected_rate.service).to eq("Priority")
42
- expect(@priority.tracking_code).to eq("9499907123456123456781")
43
-
44
- label = open(@priority.postage_label.label_url)
45
- expect(label.size).to be > 30000
46
- end
47
-
48
- it 'buys a return label' do
49
- expect(@priority.selected_rate.service).to eq("Priority")
50
- expect(@priority.tracking_code).to eq("9499907123456123456781")
51
-
52
- label = open(@priority.postage_label.label_url)
53
- expect(label.size).to be > 30000
54
- end
55
-
56
- it 'omits rates for alcohol shipments' do
57
- shipment = EasyPost::Shipment.create(
58
- :to_address => ADDRESS[:california],
59
- :from_address => ADDRESS[:missouri],
60
- :parcel => PARCEL[:dimensions],
61
- :options => {:alcohol => true}
62
- )
63
- expect { shipment.buy(rate: shipment.lowest_rate('usps')) }.to raise_exception
64
- end
65
-
66
- end