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.
@@ -0,0 +1,79 @@
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
@@ -0,0 +1,64 @@
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
@@ -0,0 +1,66 @@
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
@@ -0,0 +1,94 @@
1
+ # require 'spec_helper'
2
+
3
+ # describe 'usps electronic merchandise return service' 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
+ # :is_return => true
10
+ # )
11
+ # @first.buy(:rate => @first.lowest_rate("USPSElectronicMerchandiseReturn",
12
+ # "First"))
13
+
14
+ # @priority = EasyPost::Shipment.create(
15
+ # :to_address => ADDRESS[:california],
16
+ # :from_address => ADDRESS[:missouri],
17
+ # :parcel => PARCEL[:dimensions],
18
+ # :is_return => true
19
+ # )
20
+ # @priority.buy(:rate => @priority.lowest_rate("USPSElectronicMerchandiseReturn",
21
+ # "Priority"))
22
+
23
+ # @bpm = EasyPost::Shipment.create(
24
+ # :to_address => ADDRESS[:california],
25
+ # :from_address => ADDRESS[:missouri],
26
+ # :parcel => PARCEL[:dimensions_light],
27
+ # :is_return => true
28
+ # )
29
+ # @bpm.buy(:rate => @bpm.lowest_rate("USPSElectronicMerchandiseReturn",
30
+ # "BoundPrintedMatter"))
31
+
32
+ # @media = EasyPost::Shipment.create(
33
+ # :to_address => ADDRESS[:california],
34
+ # :from_address => ADDRESS[:missouri],
35
+ # :parcel => PARCEL[:dimensions],
36
+ # :is_return => true
37
+ # )
38
+ # @media.buy(:rate => @media.lowest_rate("USPSElectronicMerchandiseReturn",
39
+ # "MediaMail"))
40
+
41
+ # @library = EasyPost::Shipment.create(
42
+ # :to_address => ADDRESS[:california],
43
+ # :from_address => ADDRESS[:missouri],
44
+ # :parcel => PARCEL[:dimensions],
45
+ # :is_return => true
46
+ # )
47
+ # @library.buy(:rate => @library.lowest_rate("USPSElectronicMerchandiseReturn",
48
+ # "LibraryMail"))
49
+ # end
50
+
51
+ # it 'buys a first label' do
52
+ # expect(@first).to be_an_instance_of(EasyPost::Shipment)
53
+ # expect(@first.selected_rate).to be_an_instance_of(EasyPost::Rate)
54
+ # expect(@first.selected_rate.service).to eq("First")
55
+ # expect(@first.postage_label.label_url).to end_with(".png")
56
+ # expect(@first.tracking_code).to eq("9499907123456123456781")
57
+
58
+ # label = open(@first.postage_label.label_url)
59
+ # expect(label.size).to be > 30000
60
+ # end
61
+
62
+ # it 'buys a priority label' do
63
+ # expect(@priority.selected_rate.service).to eq("Priority")
64
+ # expect(@priority.tracking_code).to eq("9499907123456123456781")
65
+
66
+ # label = open(@priority.postage_label.label_url)
67
+ # expect(label.size).to be > 30000
68
+ # end
69
+
70
+ # it 'buys a bpm label' do
71
+ # expect(@bpm.selected_rate.service).to eq("BoundPrintedMatter")
72
+ # expect(@bpm.tracking_code).to eq("9499907123456123456781")
73
+
74
+ # label = open(@bpm.postage_label.label_url)
75
+ # expect(label.size).to be > 30000
76
+ # end
77
+
78
+ # it 'buys a media mail label' do
79
+ # expect(@media.selected_rate.service).to eq("MediaMail")
80
+ # expect(@media.tracking_code).to eq("9499907123456123456781")
81
+
82
+ # label = open(@media.postage_label.label_url)
83
+ # expect(label.size).to be > 30000
84
+ # end
85
+
86
+ # it 'buys a library mail label' do
87
+ # expect(@library.selected_rate.service).to eq("LibraryMail")
88
+ # expect(@library.tracking_code).to eq("9499907123456123456781")
89
+
90
+ # label = open(@library.postage_label.label_url)
91
+ # expect(label.size).to be > 30000
92
+ # end
93
+
94
+ # end
File without changes
metadata CHANGED
@@ -1,89 +1,89 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easypost
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.15
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sawyer Bateman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-15 00:00:00.000000000 Z
11
+ date: 2014-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.4'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.4'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: multi_json
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - ! '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.0.4
34
- - - "<"
34
+ - - <
35
35
  - !ruby/object:Gem::Version
36
36
  version: '2'
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
- - - ">="
41
+ - - ! '>='
42
42
  - !ruby/object:Gem::Version
43
43
  version: 1.0.4
44
- - - "<"
44
+ - - <
45
45
  - !ruby/object:Gem::Version
46
46
  version: '2'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - "~>"
51
+ - - ~>
52
52
  - !ruby/object:Gem::Version
53
53
  version: '1.7'
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - "~>"
58
+ - - ~>
59
59
  - !ruby/object:Gem::Version
60
60
  version: '1.7'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rake
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - "~>"
65
+ - - ~>
66
66
  - !ruby/object:Gem::Version
67
67
  version: '10.0'
68
68
  type: :development
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - "~>"
72
+ - - ~>
73
73
  - !ruby/object:Gem::Version
74
74
  version: '10.0'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: rspec
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - "~>"
79
+ - - ~>
80
80
  - !ruby/object:Gem::Version
81
81
  version: 2.13.0
82
82
  type: :development
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
- - - "~>"
86
+ - - ~>
87
87
  - !ruby/object:Gem::Version
88
88
  version: 2.13.0
89
89
  description: Client library for accessing the EasyPost shipping API via Ruby.
@@ -93,7 +93,7 @@ executables:
93
93
  extensions: []
94
94
  extra_rdoc_files: []
95
95
  files:
96
- - ".gitignore"
96
+ - .gitignore
97
97
  - CHANGELOG
98
98
  - Gemfile
99
99
  - LICENSE
@@ -105,7 +105,6 @@ files:
105
105
  - lib/easypost.rb
106
106
  - lib/easypost/address.rb
107
107
  - lib/easypost/batch.rb
108
- - lib/easypost/carrier_account.rb
109
108
  - lib/easypost/container.rb
110
109
  - lib/easypost/customs_info.rb
111
110
  - lib/easypost/customs_item.rb
@@ -124,21 +123,23 @@ files:
124
123
  - lib/easypost/scan_form.rb
125
124
  - lib/easypost/shipment.rb
126
125
  - lib/easypost/tracker.rb
127
- - lib/easypost/user.rb
128
126
  - lib/easypost/util.rb
129
127
  - lib/easypost/version.rb
130
128
  - spec/address_spec.rb
131
129
  - spec/batch_spec.rb
132
- - spec/carrier_account_spec.rb
133
130
  - spec/container_spec.rb
131
+ - spec/fedex/domestic_spec.rb
132
+ - spec/fedex/international_spec.rb
134
133
  - spec/item_spec.rb
135
134
  - spec/order_spec.rb
136
135
  - spec/pickup_spec.rb
137
136
  - spec/shipment_spec.rb
138
137
  - spec/spec_helper.rb
139
- - spec/support/constant.rb
140
- - spec/tracker_spec.rb
141
- - spec/user_spec.rb
138
+ - spec/ups/domestic_spec.rb
139
+ - spec/ups/international_spec.rb
140
+ - spec/usps/domestic_spec.rb
141
+ - spec/usps/electronic_merchandise_returns.rb
142
+ - spec/usps/merchant_returns.rb
142
143
  homepage: https://www.easypost.com/docs
143
144
  licenses: []
144
145
  metadata: {}
@@ -148,12 +149,12 @@ require_paths:
148
149
  - lib
149
150
  required_ruby_version: !ruby/object:Gem::Requirement
150
151
  requirements:
151
- - - ">="
152
+ - - ! '>='
152
153
  - !ruby/object:Gem::Version
153
154
  version: '0'
154
155
  required_rubygems_version: !ruby/object:Gem::Requirement
155
156
  requirements:
156
- - - ">="
157
+ - - ! '>='
157
158
  - !ruby/object:Gem::Version
158
159
  version: '0'
159
160
  requirements: []
@@ -165,13 +166,16 @@ summary: EasyPost Ruby Client Library
165
166
  test_files:
166
167
  - spec/address_spec.rb
167
168
  - spec/batch_spec.rb
168
- - spec/carrier_account_spec.rb
169
169
  - spec/container_spec.rb
170
+ - spec/fedex/domestic_spec.rb
171
+ - spec/fedex/international_spec.rb
170
172
  - spec/item_spec.rb
171
173
  - spec/order_spec.rb
172
174
  - spec/pickup_spec.rb
173
175
  - spec/shipment_spec.rb
174
176
  - spec/spec_helper.rb
175
- - spec/support/constant.rb
176
- - spec/tracker_spec.rb
177
- - spec/user_spec.rb
177
+ - spec/ups/domestic_spec.rb
178
+ - spec/ups/international_spec.rb
179
+ - spec/usps/domestic_spec.rb
180
+ - spec/usps/electronic_merchandise_returns.rb
181
+ - spec/usps/merchant_returns.rb