easypost 2.0.13 → 2.0.15

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,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe EasyPost::Tracker do
4
+ describe '#create' do
5
+ it 'tracks' do
6
+ tracking_code = 'EZ2000000002'
7
+ carrier = 'usps'
8
+
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
+ end
data/spec/user_spec.rb ADDED
@@ -0,0 +1,72 @@
1
+ require 'spec_helper'
2
+
3
+ describe EasyPost::User do
4
+ before do
5
+ EasyPost.api_key = "PRODUCTION API KEY"
6
+ end
7
+
8
+ # Uncomment these tests to test CRUD operations on the User model
9
+ # Note: You must provide a Production Api Key in order to run these tests
10
+
11
+ # it 'performs all basic CRUD actions on a User' do
12
+ # me = EasyPost::User.retrieve_me
13
+ # original_children_count = me.children.count
14
+
15
+ # name = 'Ruby All-Things-Testing'
16
+
17
+ # sub_user = EasyPost::User.create(
18
+ # name: name,
19
+ # password: 'password1',
20
+ # password_confirmation: 'password1',
21
+ # phone_number: '7778675309'
22
+ # )
23
+
24
+ # id = sub_user.id
25
+ # email = sub_user.email
26
+
27
+ # retrieved_user = EasyPost::User.retrieve(id)
28
+ # expect(retrieved_user.id).to eq(id)
29
+ # expect(retrieved_user.email).to eq(email)
30
+ # expect(retrieved_user.name).to eq(name)
31
+
32
+ # new_me = EasyPost::User.retrieve_me
33
+ # interm_children_count = new_me.children.count
34
+ # expect(interm_children_count).to eq(original_children_count + 1)
35
+
36
+ # new_name = 'Ruby All-Things-Tested'
37
+ # retrieved_user.name = new_name
38
+ # retrieved_user.save
39
+
40
+ # updated_user = EasyPost::User.retrieve(id)
41
+ # expect(updated_user.id).to eq(id)
42
+ # expect(updated_user.email).to eq(email)
43
+ # expect(updated_user.name).to eq(new_name)
44
+ # end
45
+
46
+ # describe '#all_api_keys' do
47
+ # it 'returns the correct set of api_keys' do
48
+ # api_keys = EasyPost::User.all_api_keys
49
+
50
+ # my_keys = api_keys.keys
51
+ # expect(my_keys.first.mode).to eq("production")
52
+ # expect(my_keys.last.mode).to eq("test")
53
+
54
+ # me = EasyPost::User.retrieve_me
55
+ # children_count = me.children.count
56
+
57
+ # expect(api_keys.children.count).to eq(children_count)
58
+ # end
59
+ # end
60
+
61
+ # describe '#api_keys' do
62
+ # it 'returns different keys for the parent and child users' do
63
+ # me = EasyPost::User.retrieve_me
64
+ # my_keys = me.api_keys
65
+
66
+ # child = me.children.first
67
+ # child_keys = child.api_keys
68
+
69
+ # expect(my_keys).not_to eq(child_keys)
70
+ # end
71
+ # end
72
+ end
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.0.15
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