|
2 | 2 |
|
3 | 3 | Use the following guide to assist in the upgrade process of the `easypost-ruby` library between major versions.
|
4 | 4 |
|
| 5 | +- [Upgrading from 4.x to 5.0](#upgrading-from-4x-to-50) |
| 6 | +- [Upgrading from 3.x to 4.0](#upgrading-from-3x-to-40) |
| 7 | + |
| 8 | +## Upgrading from 4.x to 5.0 |
| 9 | + |
| 10 | +### 5.0 High Impact Changes |
| 11 | + |
| 12 | +- [New Client object](#50-thread-safe-with-client-object) |
| 13 | +- [Updated Dependencies](#50-updated-dependencies) |
| 14 | +- [Improved Error Handling](#50-improved-error-handling) |
| 15 | + |
| 16 | +### 5.0 Medium Impact Changes |
| 17 | + |
| 18 | +- [Corrected Naming Conventions](#50-corrected-naming-conventions) |
| 19 | + |
| 20 | +### 5.0 Low Impact Changes |
| 21 | + |
| 22 | +- [Beta Namespace Changed](#50-beta-namespace-changed) |
| 23 | + |
| 24 | +## 5.0 Thread-Safe with Client Object |
| 25 | + |
| 26 | +Likelihood of Impact: High |
| 27 | + |
| 28 | +This library is now thread-safe with the introduction of a new `Client` object. Instead of defining a global API key that all requests use, you now create an `Client` object and pass your API key to it with optional open and read timeout params. You then call your desired functions against a `service` which are called against a `Client` object: |
| 29 | + |
| 30 | +```ruby |
| 31 | +# Old way |
| 32 | +EasyPost.api_key = ENV['EASYPOST_API_KEY'] |
| 33 | +shipment = EasyPost::Shipment.retrieve('shp_...') |
| 34 | + |
| 35 | +# New way |
| 36 | +client = EasyPost::Client.new(api_key: ENV['EASYPOST_TEST_API_KEY']) |
| 37 | +shipment = client.shipment.retrieve('shp_...') |
| 38 | +``` |
| 39 | + |
| 40 | +All instance methods are now static with the exception of `lowest_rate` as these make API calls and require the Client object(EasyPost objects do not contain an API key to make API calls with). |
| 41 | + |
| 42 | +Previously used `.save()` instance methods are now static `.update()` functions where you specify first the ID of the object you are updating and second, the parameters that need updating. |
| 43 | + |
| 44 | +## 5.0 Updated Dependencies |
| 45 | + |
| 46 | +Likelihood of Impact: High |
| 47 | + |
| 48 | +**Ruby 2.6 Required** |
| 49 | + |
| 50 | +easypost-ruby now requires Ruby 2.6 or greater. |
| 51 | + |
| 52 | +**Dependencies** |
| 53 | + |
| 54 | +All dependencies had minor version bumps. |
| 55 | + |
| 56 | +## 5.0 Improved Error Handling |
| 57 | + |
| 58 | +Likelihood of Impact: High |
| 59 | + |
| 60 | +There are ~2 dozen new error types that extend either `ApiError` or `EasyPostError`. |
| 61 | + |
| 62 | +New ApiErrors (extends EasyPostError): |
| 63 | + |
| 64 | +- `ApiError` |
| 65 | +- `ConnectionError` |
| 66 | +- `ExternalApiError` |
| 67 | +- `ForbiddenError` |
| 68 | +- `GatewayTimeoutError` |
| 69 | +- `InternalServerError` |
| 70 | +- `InvalidRequestError` |
| 71 | +- `MethodNotAllowedError` |
| 72 | +- `NotFoundError` |
| 73 | +- `PaymentError` |
| 74 | +- `ProxyError` |
| 75 | +- `RateLimitError` |
| 76 | +- `RedirectError` |
| 77 | +- `RetryError` |
| 78 | +- `ServiceUnavailableError` |
| 79 | +- `SSLError` |
| 80 | +- `TimeoutError` |
| 81 | +- `UnauthorizedError` |
| 82 | +- `UnknownApiError` |
| 83 | + |
| 84 | +New EasyPostErrors (extends builtin Exception): |
| 85 | + |
| 86 | +- `EasyPostError` |
| 87 | +- `EndOfPaginationError` |
| 88 | +- `FilteringError` |
| 89 | +- `InvalidObjectError` |
| 90 | +- `InvalidParameterError` |
| 91 | +- `MissingParameterError` |
| 92 | +- `SignatureVerificationError` |
| 93 | + |
| 94 | +ApiErrors will behave like the previous Error class did. They will include a `message`, `http_status`, and `http_body`. Additionally, a new `code` and `errors` keys are present and populate when available. This class extends the more generic `EasyPostError` which only contains a message, used for errors thrown directly from this library. |
| 95 | + |
| 96 | +## 5.0 Corrected Naming Conventions |
| 97 | + |
| 98 | +Likelihood of Impact: Medium |
| 99 | + |
| 100 | +Occurances of `referral` are now `referral_customer` and `Referral` are now `ReferralCustomer` to match the documentation and API. |
| 101 | + |
| 102 | +Occurances of `smartrate` are now `smart_rate` and `Smartrate` are now `SmartRate` to match the documentation and API. |
| 103 | + |
| 104 | +Occurances of `scanform` are now `scan_form` and `Scanform` are now `ScanForm` to match the documentation and API. |
| 105 | + |
| 106 | +Rename function `get_smartrates` to `get_smart_rates` |
| 107 | + |
| 108 | +Rename function `get_lowest_smartrate` to `get_lowest_smart_rate` |
| 109 | + |
| 110 | +## 5.0 Beta Namespace Changed |
| 111 | + |
| 112 | +Likelihood of Impact: Low |
| 113 | + |
| 114 | +Previously, the beta namespace was found at `easypost.beta.x` where `x` is the name of your model. Now, the beta namespace is simply prepended to the name of your service: `client.beta_x`. for instance, you can call `client.beta_referral_customer.add_payment_method()`. |
| 115 | + |
| 116 | +## 5.0 Return True For Empty API Response |
| 117 | + |
| 118 | +Likelihood of Impact: Low |
| 119 | + |
| 120 | +Empty API response functions for `delete` return `true` instead of empty object |
| 121 | + |
5 | 122 | ## Upgrading from 3.x to 4.0
|
6 | 123 |
|
| 124 | +**NOTICE:** v4 is deprecated. |
| 125 | + |
7 | 126 | ### 4.0 High Impact Changes
|
8 | 127 |
|
9 | 128 | * [Updating Dependencies](#40-updating-dependencies)
|
|
0 commit comments