easypost 3.4.0 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +19 -5
- data/.gitignore +2 -0
- data/.rubocop.yml +5 -0
- data/CHANGELOG.md +149 -138
- data/Gemfile +2 -0
- data/README.md +51 -8
- data/Rakefile +2 -1
- data/UPGRADE_GUIDE.md +62 -0
- data/VERSION +1 -1
- data/bin/easypost-irb +5 -3
- data/easycop.yml +180 -0
- data/easypost.gemspec +21 -19
- data/lib/easypost/address.rb +26 -26
- data/lib/easypost/api_key.rb +3 -0
- data/lib/easypost/batch.rb +31 -30
- data/lib/easypost/brand.rb +13 -0
- data/lib/easypost/carrier_account.rb +4 -0
- data/lib/easypost/carrier_type.rb +3 -0
- data/lib/easypost/connection.rb +67 -0
- data/lib/easypost/customs_info.rb +5 -1
- data/lib/easypost/customs_item.rb +5 -1
- data/lib/easypost/error.rb +7 -7
- data/lib/easypost/event.rb +5 -1
- data/lib/easypost/insurance.rb +4 -0
- data/lib/easypost/object.rb +44 -28
- data/lib/easypost/order.rb +15 -11
- data/lib/easypost/parcel.rb +7 -0
- data/lib/easypost/pickup.rb +15 -9
- data/lib/easypost/pickup_rate.rb +3 -1
- data/lib/easypost/postage_label.rb +3 -0
- data/lib/easypost/rate.rb +7 -0
- data/lib/easypost/refund.rb +3 -0
- data/lib/easypost/report.rb +9 -16
- data/lib/easypost/resource.rb +55 -25
- data/lib/easypost/scan_form.rb +8 -3
- data/lib/easypost/shipment.rb +47 -51
- data/lib/easypost/tax_identifier.rb +6 -0
- data/lib/easypost/tracker.rb +9 -4
- data/lib/easypost/user.rb +31 -10
- data/lib/easypost/util.rb +22 -17
- data/lib/easypost/version.rb +3 -1
- data/lib/easypost/webhook.rb +18 -12
- data/lib/easypost.rb +99 -107
- metadata +80 -22
- data/lib/easypost/print_job.rb +0 -2
- data/lib/easypost/printer.rb +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1b008c0a117ef6b7ad4082b45e0ca94b723e14601b24c8732da23166acb1996
|
4
|
+
data.tar.gz: 52057de46c2642e4896c81a1d866e0b47fe4ec20fbad91ca5d0814a7c9fa6ea1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41f82883c0831354a2c517910a35b6fdb0a3335ec3e86fb7038ffd2660b56523819c2181f45b97814445fb62781a749009cc0a936a9011a80a93600817a1ecfc
|
7
|
+
data.tar.gz: 7000cae174dd8b99bc5e6608a922d68692f1586afe370c2daa97ee854c0540766ada8cb84fa53c1d3ae389c23a1fbf813d046bf91519c0262bd5226565f6e535
|
data/.github/workflows/ci.yml
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
name:
|
1
|
+
name: "CI"
|
2
2
|
|
3
3
|
on:
|
4
4
|
push:
|
5
|
-
branches: [
|
5
|
+
branches: [master]
|
6
6
|
pull_request: ~
|
7
7
|
|
8
8
|
jobs:
|
@@ -10,13 +10,27 @@ jobs:
|
|
10
10
|
runs-on: ubuntu-latest
|
11
11
|
strategy:
|
12
12
|
matrix:
|
13
|
-
rubyversion: [
|
13
|
+
rubyversion: ["2.5", "2.6", "2.7", "3.0", "3.1"]
|
14
14
|
steps:
|
15
|
-
-
|
16
|
-
|
15
|
+
- name: Checkout Repository
|
16
|
+
uses: actions/checkout@v2
|
17
|
+
- name: Set up Ruby
|
17
18
|
uses: ruby/setup-ruby@v1
|
18
19
|
with:
|
19
20
|
ruby-version: ${{ matrix.rubyversion }}
|
20
21
|
bundler-cache: true
|
21
22
|
- name: run tests
|
22
23
|
run: bundle exec rspec
|
24
|
+
lint:
|
25
|
+
runs-on: ubuntu-latest
|
26
|
+
steps:
|
27
|
+
- name: Checkout Repository
|
28
|
+
uses: actions/checkout@v2
|
29
|
+
- name: Set up Ruby
|
30
|
+
uses: ruby/setup-ruby@v1
|
31
|
+
with:
|
32
|
+
ruby-version: "3.0"
|
33
|
+
- name: Install Dependencies
|
34
|
+
run: bundle install
|
35
|
+
- name: Lint Project
|
36
|
+
run: rubocop
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,245 +1,256 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## v4.1.0 (2022-03-09)
|
3
4
|
|
4
|
-
|
5
|
+
- Adds support for custom client connections (#142)
|
6
|
+
- Reduces memory usage by reusing connections
|
7
|
+
- Extends all objects with `Enumerable` allowing for iterator patterns (#143)
|
5
8
|
|
6
|
-
|
7
|
-
* Sorted EasyPost Resources list
|
8
|
-
* Remove 2015-vintage experimental `all_updated` method on Tracker
|
9
|
-
* Fixes API key retrieval (#120, thanks @andychongyz)
|
10
|
-
* Adds `regenerate_rates` method for new rerate API
|
11
|
-
* Adds `deconstruct_keys` method to allow for pattern matching on EasyPost objects
|
9
|
+
## v4.0.0 (2022-02-25)
|
12
10
|
|
11
|
+
- Bumps minimum Ruby version from `2.2` to `2.5`
|
12
|
+
- Bumps dev dependencies
|
13
|
+
- Documents each interface of the project in code
|
14
|
+
- Overhauls the test suite with full coverage
|
15
|
+
- Introduces `Rubocop` and lints the entire project
|
16
|
+
- Removes the unusable `Print` and `PrintJob` objects
|
17
|
+
- Removes deprecated and unusable `stamp_and_barcode_by_reference` method on the Batch object
|
18
|
+
- Explicitly returns an error of "not implemented" for `Rate.all` and `Parcel.all`
|
19
|
+
- Removes the `Shipment.get_rates` function as shipments already contain rates. If you need to get new rates for a shipment, use the `Shipment.regenerate_rates` function instead
|
20
|
+
- Removes the parameters from `Address.verify` as they are unusable
|
21
|
+
- Removes the deprecated `http_status` property of the `EasyPost::Error` object as it was replaced with `status`
|
22
|
+
- Fixes a bug that would append an extra `id` field to each retrieved object
|
23
|
+
- Various other small improvements and bug fixes
|
13
24
|
|
14
|
-
##
|
25
|
+
## v3.5.0 (2021-12-06)
|
15
26
|
|
16
|
-
|
17
|
-
* Fix bug where `EasyPost::CarrierAccount.types` was hitting the wrong endpoint
|
27
|
+
- Adds the `update_brand` method to the user object (closes #122)
|
18
28
|
|
29
|
+
## v3.4.0 (2021-07-13)
|
19
30
|
|
20
|
-
|
31
|
+
- Removed deprecated `Item` object
|
32
|
+
- Sorted EasyPost Resources list
|
33
|
+
- Remove 2015-vintage experimental `all_updated` method on Tracker
|
34
|
+
- Fixes API key retrieval (#120, thanks @andychongyz)
|
35
|
+
- Adds `regenerate_rates` method for new rerate API
|
36
|
+
- Adds `deconstruct_keys` method to allow for pattern matching on EasyPost objects
|
21
37
|
|
22
|
-
|
23
|
-
* Add Ruby 3.0 to supported platforms (#110; thanks @maxwell)
|
38
|
+
## v3.3.0 (2021-06-10)
|
24
39
|
|
40
|
+
- Adds `SmartRate` functionality to the `Shipments` object (available by calling `get_smartrates` on a shipment)
|
41
|
+
- Fix bug where `EasyPost::CarrierAccount.types` was hitting the wrong endpoint
|
25
42
|
|
26
|
-
##
|
43
|
+
## v3.2.0 (2021-01-14)
|
27
44
|
|
28
|
-
|
29
|
-
|
30
|
-
* Fix `EasyPost::Address.create_and_verify`, broken since 3.1.0 (#108; thanks @rajbirverma)
|
45
|
+
- Replace Travis CI with Github Actions
|
46
|
+
- Add Ruby 3.0 to supported platforms (#110; thanks @maxwell)
|
31
47
|
|
48
|
+
## v3.1.5 (2020-12-16)
|
32
49
|
|
33
|
-
|
50
|
+
- Fix attribute lookup when manually constructing objects (#105; thanks @drewtempelmeyer)
|
51
|
+
- Flatten class names and clean up some other style issues
|
52
|
+
- Fix `EasyPost::Address.create_and_verify`, broken since 3.1.0 (#108; thanks @rajbirverma)
|
34
53
|
|
35
|
-
|
36
|
-
* Don't modify `carriers` and `services` parameters to `Shipment.lowest_rate` (#71 / #103, thanks @vladvinnikov and @jurisgalang)
|
37
|
-
* When constructing an easypost object, convert the key to a string (#102; thanks @Geesu)
|
38
|
-
* Expose the raw HTTP response as `#http_body` on `EasyPost::Error` objects (#101; thanks @Geesu)
|
54
|
+
## v3.1.4 (2020-09-29)
|
39
55
|
|
56
|
+
- Don't modify params passed into Address#create (#78; thanks @TheRusskiy)
|
57
|
+
- Don't modify `carriers` and `services` parameters to `Shipment.lowest_rate` (#71 / #103, thanks @vladvinnikov and @jurisgalang)
|
58
|
+
- When constructing an easypost object, convert the key to a string (#102; thanks @Geesu)
|
59
|
+
- Expose the raw HTTP response as `#http_body` on `EasyPost::Error` objects (#101; thanks @Geesu)
|
40
60
|
|
41
|
-
##
|
61
|
+
## v3.1.3 (2020-06-26)
|
42
62
|
|
43
|
-
|
63
|
+
- Fix bug causing Authorization header to be included in User-Agent header. All users must upgrade.
|
44
64
|
|
65
|
+
## v3.1.2 (2020-06-24)
|
45
66
|
|
46
|
-
|
67
|
+
- Bad gem push. New version required.
|
47
68
|
|
48
|
-
|
69
|
+
## v3.1.1 (2020-06-23)
|
49
70
|
|
71
|
+
- Fix bug where EasyPost.http_config was invalid when not explicitly initialized.
|
50
72
|
|
51
|
-
##
|
73
|
+
## v3.1.0 (2020-06-23)
|
52
74
|
|
53
|
-
|
75
|
+
- Add Shipment Invoice and Refund Report
|
76
|
+
- Remove dependencies on `RestClient` and `MultiJson`
|
77
|
+
- Remove some deprecated endpoints
|
54
78
|
|
79
|
+
## v3.0.1 (2018-05-17)
|
55
80
|
|
56
|
-
|
81
|
+
- Enforce TLS certificate validity by default
|
57
82
|
|
58
|
-
|
59
|
-
* Remove dependencies on `RestClient` and `MultiJson`
|
60
|
-
* Remove some deprecated endpoints
|
83
|
+
## v3.0.0 (2018-02-15)
|
61
84
|
|
85
|
+
- Require use of ruby ~> 2.0 and TLSv1.2
|
62
86
|
|
63
|
-
##
|
87
|
+
## v2.7.3 (2018-02-05)
|
64
88
|
|
65
|
-
|
89
|
+
- Fix bug with introduced around certain JSON objects with IDs (thanks vladvinnikov!)
|
66
90
|
|
91
|
+
## v2.7.2 (2018-02-01)
|
67
92
|
|
68
|
-
|
93
|
+
- Removed unused and unsupported code paths for Container model
|
94
|
+
- Removed unused and unsupported code path for Stamp and Barcode methods on the Shipment model
|
95
|
+
- Fixed a bug with non-model JSON object with an "id" key being treated as models and raising errors
|
69
96
|
|
70
|
-
|
97
|
+
## v2.7.1 (2017-05-25)
|
71
98
|
|
99
|
+
- Allow reports to be retrieved without passing a type
|
72
100
|
|
73
|
-
##
|
101
|
+
## v2.7.0 (2017-04-04)
|
74
102
|
|
75
|
-
|
103
|
+
- Changed Report CRUD signatures. requires report type to be passed
|
76
104
|
|
105
|
+
## v2.6.2 (2017-02-14)
|
77
106
|
|
78
|
-
|
107
|
+
- Added get_rates method for Orders
|
79
108
|
|
80
|
-
|
81
|
-
* Removed unused and unsupported code path for Stamp and Barcode methods on the Shipment model
|
82
|
-
* Fixed a bug with non-model JSON object with an "id" key being treated as models and raising errors
|
109
|
+
## v2.6.1 (2017-01-19)
|
83
110
|
|
111
|
+
- Updated create method for ScanForms
|
84
112
|
|
85
|
-
##
|
113
|
+
## v2.6.0 (2017-01-17)
|
86
114
|
|
87
|
-
|
115
|
+
- Add basic CRUD methods for Webhooks
|
88
116
|
|
117
|
+
## v2.5.0 (2016-12-19)
|
89
118
|
|
90
|
-
|
119
|
+
- Add prefixes to report in utils
|
91
120
|
|
92
|
-
|
121
|
+
## v2.4.0 (2016-12-08)
|
93
122
|
|
123
|
+
- Add report resource to ruby client
|
94
124
|
|
95
|
-
##
|
125
|
+
## v2.3.0 (2016-11-25)
|
96
126
|
|
97
|
-
|
127
|
+
- Updated dependencies to allow rest-client 2.0.0 and above
|
98
128
|
|
129
|
+
## v2.2.0 (2016-07-260
|
99
130
|
|
100
|
-
|
131
|
+
- Added standalone Insurance model
|
101
132
|
|
102
|
-
|
133
|
+
## v2.1.11 (2016-02-04)
|
103
134
|
|
135
|
+
- Allowed user creation for top-level users
|
104
136
|
|
105
|
-
##
|
137
|
+
## v2.1.10 (2015-12-23)
|
106
138
|
|
107
|
-
|
139
|
+
- Added verify and verify_strict params to Address.create
|
140
|
+
- Added Tracker.create_list and Tracker.all_updated for working with large
|
141
|
+
numbers of Trackers.
|
108
142
|
|
143
|
+
## v2.1.9 (2015-11-04)
|
109
144
|
|
110
|
-
|
145
|
+
- Added new tests for Tracker.all
|
146
|
+
- Updated some old examples
|
111
147
|
|
112
|
-
|
148
|
+
## v2.1.8 (2015-10-21)
|
113
149
|
|
150
|
+
- Added Cancel method for Pickups (thanks Ramie Blatt!)
|
114
151
|
|
115
|
-
##
|
152
|
+
## v2.1.7 (2015-10-05)
|
116
153
|
|
117
|
-
|
154
|
+
- Fixed Address.create_and_verify and changed how errors are raised (thanks Dimitri Roche!)
|
155
|
+
- Require newer version of the multi_json package
|
118
156
|
|
157
|
+
## v2.1.6 (2015-06-10)
|
119
158
|
|
120
|
-
|
159
|
+
- Added Address message accessor for backwards compatability
|
121
160
|
|
122
|
-
|
161
|
+
## v2.1.5 (2015-06-10)
|
123
162
|
|
163
|
+
- Removed Address.message
|
124
164
|
|
125
|
-
##
|
165
|
+
## v2.1.4 (2015-06-03)
|
126
166
|
|
127
|
-
|
167
|
+
- Add Printer and PrintJob resources.
|
128
168
|
|
169
|
+
## v2.1.3 (2015-04-30)
|
129
170
|
|
130
|
-
|
171
|
+
- Bux fix, EasyPost::Errors no longer break with a nil json body.
|
131
172
|
|
132
|
-
|
173
|
+
## v2.1.2 (2015-04-29)
|
133
174
|
|
175
|
+
- EasyPost::Errors now correctly parse field errors and error codes.
|
134
176
|
|
135
|
-
##
|
177
|
+
## v2.1.1 (2015-04-15)
|
136
178
|
|
137
|
-
|
138
|
-
|
139
|
-
|
179
|
+
- CarrierAccount will now correctly save in-place modifications to credentials
|
180
|
+
- Nested variables should now be saved correctly across all models
|
181
|
+
- Fixed version numbering confusion (the previous version was 2.0.15, not 2.1.0)
|
140
182
|
|
183
|
+
## v2.0.15 (2015-04-15)
|
141
184
|
|
142
|
-
|
185
|
+
- Added tracker to shipment buy response
|
186
|
+
- Updated tracker tests
|
143
187
|
|
144
|
-
|
145
|
-
* Updated some old examples
|
188
|
+
## v2.0.14 (2015-04-15)
|
146
189
|
|
190
|
+
- Added User and CarrierAccount models with CRUD functionality
|
147
191
|
|
148
|
-
##
|
192
|
+
## v2.0.13 (2014-10-30)
|
149
193
|
|
150
|
-
|
194
|
+
- Added Pickup, PickupRate resources.
|
195
|
+
- Added ability to pass api_key to a few resources that were missing it.
|
151
196
|
|
197
|
+
## v2.0.12 (2014-07-07)
|
152
198
|
|
153
|
-
|
199
|
+
- Added Item, Container, and Order resources.
|
200
|
+
- Fixed and added a lot of tests.
|
154
201
|
|
155
|
-
|
156
|
-
* Require newer version of the multi_json package
|
202
|
+
## v2.0.11 (2013-12-16)
|
157
203
|
|
204
|
+
- Added Event.receive method for parsing events sent by webhook.
|
205
|
+
- Fixed tests to account for the tracking code returning and array of details instead of a Hash
|
158
206
|
|
159
|
-
##
|
207
|
+
## v2.0.10 (2013-10-03)
|
160
208
|
|
161
|
-
|
209
|
+
- API Addition: Event resource added for webhook consumption.
|
162
210
|
|
211
|
+
## v2.0.9 (2013-09-19)
|
163
212
|
|
164
|
-
|
213
|
+
- Interface Change: Changed batch.scan_form to batch.create_scan_form to support the ability to refer to scan forms associated to batches.
|
165
214
|
|
166
|
-
|
215
|
+
## v2.0.3 (2013-07-31)
|
167
216
|
|
217
|
+
- API Addition: Tracker resource added. Trackers can be used to register any tracking code with EasyPost webhooks.
|
168
218
|
|
169
|
-
##
|
219
|
+
## v2.0.2 (2013-07-23)
|
170
220
|
|
171
|
-
|
221
|
+
- API Addition: Shipment.track_with_code returns tracking details for any tracking code.
|
172
222
|
|
223
|
+
## v2.0.1 (2013-07-07)
|
173
224
|
|
174
|
-
|
225
|
+
- API Addition: Address.create_and_verify returns a verified address in one step.
|
226
|
+
- API Addition: Shipment.label forces the creation of additional label formats (pdf, epl2, zpl).
|
227
|
+
- API Addition: Shipment.insure purchases insurance for a shipment.
|
228
|
+
- Library Update: Added the ability to negatively filter carriers and services with Shipment.lowest_rate (e.g. '!usps').
|
175
229
|
|
176
|
-
|
230
|
+
## v2.0.0 (2013-06-25)
|
177
231
|
|
232
|
+
## v1.1.3 (2013-06-05)
|
178
233
|
|
179
|
-
##
|
234
|
+
## v1.1.2 (2013-06-05)
|
180
235
|
|
181
|
-
|
236
|
+
## v1.1.1 (2013-02-12)
|
182
237
|
|
238
|
+
## v1.1.0 (2013-01-29)
|
183
239
|
|
184
|
-
##
|
240
|
+
## v1.0.8 (2012-11-19)
|
185
241
|
|
186
|
-
|
187
|
-
* Nested variables should now be saved correctly across all models
|
188
|
-
* Fixed version numbering confusion (the previous version was 2.0.15, not 2.1.0)
|
242
|
+
## v1.0.7 (2012-11-19)
|
189
243
|
|
244
|
+
## v1.0.6 (2012-11-19)
|
190
245
|
|
191
|
-
##
|
246
|
+
## v1.0.5 (2012-11-19)
|
192
247
|
|
193
|
-
|
194
|
-
* Updated tracker tests
|
248
|
+
## v1.0.4 (2012-11-14)
|
195
249
|
|
250
|
+
## v1.0.3 (2012-11-13)
|
196
251
|
|
197
|
-
##
|
252
|
+
## v1.0.2 (2012-11-13)
|
198
253
|
|
199
|
-
|
254
|
+
## v1.0.1 (2012-11-13)
|
200
255
|
|
201
|
-
|
202
|
-
## 2.0.13 2014-10-30
|
203
|
-
|
204
|
-
* Added Pickup, PickupRate resources.
|
205
|
-
* Added ability to pass api_key to a few resources that were missing it.
|
206
|
-
|
207
|
-
|
208
|
-
## 2.0.12 2014-07-07
|
209
|
-
|
210
|
-
* Added Item, Container, and Order resources.
|
211
|
-
* Fixed and added a lot of tests.
|
212
|
-
|
213
|
-
|
214
|
-
## 2.0.11 2013-12-16
|
215
|
-
|
216
|
-
* Added Event.receive method for parsing events sent by webhook.
|
217
|
-
* Fixed tests to account for the tracking code returning and array of details instead of a Hash
|
218
|
-
|
219
|
-
|
220
|
-
## 2.0.10 2013-10-03
|
221
|
-
|
222
|
-
* API Addition: Event resource added for webhook consumption.
|
223
|
-
|
224
|
-
|
225
|
-
## 2.0.9 2013-09-19
|
226
|
-
|
227
|
-
* Interface Change: Changed batch.scan_form to batch.create_scan_form to support the ability to refer to scan forms associated to batches.
|
228
|
-
|
229
|
-
|
230
|
-
## 2.0.3 2013-07-31
|
231
|
-
|
232
|
-
* API Addition: Tracker resource added. Trackers can be used to register any tracking code with EasyPost webhooks.
|
233
|
-
|
234
|
-
|
235
|
-
## 2.0.2 2013-07-23
|
236
|
-
|
237
|
-
* API Addition: Shipment.track_with_code returns tracking details for any tracking code.
|
238
|
-
|
239
|
-
|
240
|
-
## 2.0.1 2013-07-07
|
241
|
-
|
242
|
-
* API Addition: Address.create_and_verify returns a verified address in one step.
|
243
|
-
* API Addition: Shipment.label forces the creation of additional label formats (pdf, epl2, zpl).
|
244
|
-
* API Addition: Shipment.insure purchases insurance for a shipment.
|
245
|
-
* Library Update: Added the ability to negatively filter carriers and services with Shipment.lowest_rate (e.g. '!usps').
|
256
|
+
## v1.0.0 (2012-11-02)
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -100,14 +100,57 @@ Up-to-date documentation at: https://easypost.com/docs
|
|
100
100
|
## Development
|
101
101
|
|
102
102
|
```bash
|
103
|
-
# Run tests
|
104
|
-
bundle exec rspec
|
103
|
+
# Run tests (coverage is generated on a successful test suite run)
|
104
|
+
EASYPOST_TEST_API_KEY=123... EASYPOST_PROD_API_KEY=123... bundle exec rspec
|
105
105
|
```
|
106
106
|
|
107
|
-
##
|
107
|
+
## Custom connections
|
108
108
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
109
|
+
Set `EasyPost.default_connection` to an object that responds to `call(method, path, api_key = nil, body = nil)`
|
110
|
+
|
111
|
+
### Faraday
|
112
|
+
|
113
|
+
```ruby
|
114
|
+
require 'faraday'
|
115
|
+
require 'faraday/response/logger'
|
116
|
+
require 'logger'
|
117
|
+
|
118
|
+
EasyPost.default_connection = lambda do |method, path, api_key = nil, body = nil|
|
119
|
+
Faraday
|
120
|
+
.new(url: EasyPost.api_base, headers: EasyPost.default_headers) { |builder|
|
121
|
+
builder.use Faraday::Response::Logger, Logger.new(STDOUT), {bodies: true, headers: true}
|
122
|
+
builder.adapter :net_http
|
123
|
+
}
|
124
|
+
.public_send(method, path) { |request|
|
125
|
+
request.headers['Authorization'] = EasyPost.authorization(api_key)
|
126
|
+
request.body = JSON.dump(EasyPost::Util.objects_to_ids(body)) if body
|
127
|
+
}.yield_self { |response|
|
128
|
+
EasyPost.parse_response(
|
129
|
+
status: response.status,
|
130
|
+
body: response.body,
|
131
|
+
json: response.headers['Content-Type'].start_with?('application/json'),
|
132
|
+
)
|
133
|
+
}
|
134
|
+
end
|
135
|
+
```
|
136
|
+
|
137
|
+
### Typhoeus
|
138
|
+
|
139
|
+
```ruby
|
140
|
+
require 'typhoeus'
|
141
|
+
|
142
|
+
EasyPost.default_connection = lambda do |method, path, api_key = nil, body = nil|
|
143
|
+
Typhoeus.public_send(
|
144
|
+
method,
|
145
|
+
File.join(EasyPost.api_base, path),
|
146
|
+
headers: EasyPost.default_headers.merge('Authorization' => EasyPost.authorization(api_key)),
|
147
|
+
body: body.nil? ? nil : JSON.dump(EasyPost::Util.objects_to_ids(body)),
|
148
|
+
).yield_self { |response|
|
149
|
+
EasyPost.parse_response(
|
150
|
+
status: response.code,
|
151
|
+
body: response.body,
|
152
|
+
json: response.headers['Content-Type'].start_with?('application/json'),
|
153
|
+
)
|
154
|
+
}
|
155
|
+
end
|
156
|
+
```
|
data/Rakefile
CHANGED
data/UPGRADE_GUIDE.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# Upgrade Guide
|
2
|
+
|
3
|
+
Use the following guide to assist in the upgrade process of the `easypost-ruby` library between major versions.
|
4
|
+
|
5
|
+
## Upgrading from 3.x to 4.0
|
6
|
+
|
7
|
+
### 4.0 High Impact Changes
|
8
|
+
|
9
|
+
* [Updating Dependencies](#40-updating-dependencies)
|
10
|
+
|
11
|
+
### 4.0 Medium Impact Changes
|
12
|
+
|
13
|
+
* [Removal of `get_rates` Shipment Method](#40-removal-of-getrates-shipment-method)
|
14
|
+
|
15
|
+
### 4.0 Low Impact Changes
|
16
|
+
|
17
|
+
* [Removal of `Print` and `PrintJob` Objects](#40-removal-of-print-and-printjob-objects)
|
18
|
+
* [Removal of `stamp_and_barcode_by_reference` Batch Method](#40-removal-of-stampandbarcodebyreference-batch-method)
|
19
|
+
* [Removal of `Address.verify` Parameters](#40-removal-of-addressverify-parameters)
|
20
|
+
* [Removal of the `http_status` Property on EasyPost::Error](#40-removal-of-httpstatus-property-on-easyposterror)
|
21
|
+
|
22
|
+
## 4.0 Updating Dependencies
|
23
|
+
|
24
|
+
Likelihood of Impact: High
|
25
|
+
|
26
|
+
**Ruby 2.5 Required**
|
27
|
+
|
28
|
+
easypost-ruby now requires Ruby 2.5 or greater.
|
29
|
+
|
30
|
+
**Dependencies**
|
31
|
+
|
32
|
+
No production dependencies were altered. Development dependencies were all bumped and `simplecov` and `rubocop` were introduced.
|
33
|
+
|
34
|
+
## 4.0 Removal of get_rates Shipment Method
|
35
|
+
|
36
|
+
Likelihood of Impact: Medium
|
37
|
+
|
38
|
+
The HTTP method used for the `get_rates` endpoint at the API level has changed from `POST` to `GET` and will only retrieve rates for a shipment instead of regenerating them. A new `/rerate` endpoint has been introduced to replace this functionality; In this library, you can now call the `Shipment.regenerate_rates` method to regenerate rates. Due to the logic change, the `get_rates` method has been removed since a Shipment inherently already has rates associated.
|
39
|
+
|
40
|
+
## 4.0 Removal of Print and PrintJob Objects
|
41
|
+
|
42
|
+
Likelihood of Impact: Low
|
43
|
+
|
44
|
+
The `Print` and `PrintJob` objects have been removed as they are no longer usable with the current version of the API.
|
45
|
+
|
46
|
+
## 4.0 Removal of stamp_and_barcode_by_reference Batch Method
|
47
|
+
|
48
|
+
Likelihood of Impact: Low
|
49
|
+
|
50
|
+
The `stamp_and_barcode_by_reference` Batch method has been removed as it is no longer usable with the current version of the API.
|
51
|
+
|
52
|
+
## 4.0 Removal of Address.verify Parameters
|
53
|
+
|
54
|
+
Likelihood of Impact: Low
|
55
|
+
|
56
|
+
The parameters for the `Address.verify` method were removed as they were unusable, the current version of the API does not allow you to verify an address by specifying a carrier.
|
57
|
+
|
58
|
+
## 4.0 Removal of http_status Property on EasyPost::Error
|
59
|
+
|
60
|
+
Likelihood of Impact: Low
|
61
|
+
|
62
|
+
The deprecated `http_status` property has been removed in favor of the `status` property on the EasyPost::Error object.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
4.1.0
|
data/bin/easypost-irb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
2
4
|
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
3
5
|
|
4
|
-
libs =
|
5
|
-
libs <<
|
6
|
-
puts
|
6
|
+
libs = ' -r irb/completion'
|
7
|
+
libs << " -r #{"#{File.dirname(__FILE__)}/../lib/easypost"}"
|
8
|
+
puts 'Initializing EasyPost...'
|
7
9
|
exec "#{irb} #{libs} --simple-prompt"
|