easypost 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -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,89 +1,89 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easypost
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sawyer Bateman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-11 00:00:00.000000000 Z
11
+ date: 2015-04-15 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,6 +105,7 @@ files:
105
105
  - lib/easypost.rb
106
106
  - lib/easypost/address.rb
107
107
  - lib/easypost/batch.rb
108
+ - lib/easypost/carrier_account.rb
108
109
  - lib/easypost/container.rb
109
110
  - lib/easypost/customs_info.rb
110
111
  - lib/easypost/customs_item.rb
@@ -123,23 +124,21 @@ files:
123
124
  - lib/easypost/scan_form.rb
124
125
  - lib/easypost/shipment.rb
125
126
  - lib/easypost/tracker.rb
127
+ - lib/easypost/user.rb
126
128
  - lib/easypost/util.rb
127
129
  - lib/easypost/version.rb
128
130
  - spec/address_spec.rb
129
131
  - spec/batch_spec.rb
132
+ - spec/carrier_account_spec.rb
130
133
  - spec/container_spec.rb
131
- - spec/fedex/domestic_spec.rb
132
- - spec/fedex/international_spec.rb
133
134
  - spec/item_spec.rb
134
135
  - spec/order_spec.rb
135
136
  - spec/pickup_spec.rb
136
137
  - spec/shipment_spec.rb
137
138
  - spec/spec_helper.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
139
+ - spec/support/constant.rb
140
+ - spec/tracker_spec.rb
141
+ - spec/user_spec.rb
143
142
  homepage: https://www.easypost.com/docs
144
143
  licenses: []
145
144
  metadata: {}
@@ -149,12 +148,12 @@ require_paths:
149
148
  - lib
150
149
  required_ruby_version: !ruby/object:Gem::Requirement
151
150
  requirements:
152
- - - ! '>='
151
+ - - ">="
153
152
  - !ruby/object:Gem::Version
154
153
  version: '0'
155
154
  required_rubygems_version: !ruby/object:Gem::Requirement
156
155
  requirements:
157
- - - ! '>='
156
+ - - ">="
158
157
  - !ruby/object:Gem::Version
159
158
  version: '0'
160
159
  requirements: []
@@ -166,16 +165,13 @@ summary: EasyPost Ruby Client Library
166
165
  test_files:
167
166
  - spec/address_spec.rb
168
167
  - 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
172
170
  - spec/item_spec.rb
173
171
  - spec/order_spec.rb
174
172
  - spec/pickup_spec.rb
175
173
  - spec/shipment_spec.rb
176
174
  - spec/spec_helper.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
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