|
2 | 2 |
|
3 | 3 | Use the following guide to assist in the upgrade process of the `easypost-python` library between major versions. |
4 | 4 |
|
| 5 | +- [Upgrading from 7.x to 8.0](#upgrading-from-7x-to-80) |
5 | 6 | - [Upgrading from 6.x to 7.0](#upgrading-from-6x-to-70) |
6 | 7 | - [Upgrading from 5.x to 6.0](#upgrading-from-5x-to-60) |
7 | 8 |
|
| 9 | +## Upgrading from 7.x to 8.0 |
| 10 | + |
| 11 | +### 8.0 High Impact Changes |
| 12 | + |
| 13 | +- [Updating Dependencies](#80-updating-dependencies) |
| 14 | +- [EasyPostClient](#80-easypostclient) |
| 15 | +- [Improved Error Handling](#80-improved-error-handling) |
| 16 | + |
| 17 | +### 8.0 Medium Impact Changes |
| 18 | + |
| 19 | +- [Corrected Naming Conventions](#80-corrected-naming-conventions) |
| 20 | + |
| 21 | +### 8.0 Low Impact Changes |
| 22 | + |
| 23 | +- [Beta Namespace Changed](#80-beta-namespace-changed) |
| 24 | +- [Changed Function Parameter Order and Return Types](#80-changed-function-parameter-order-and-return-types) |
| 25 | + |
| 26 | +## 8.0 Updating Dependencies |
| 27 | + |
| 28 | +Likelihood of Impact: High |
| 29 | + |
| 30 | +**Python 3.7 Required** |
| 31 | + |
| 32 | +easypost-python now requires Python 3.7 or greater. |
| 33 | + |
| 34 | +**Dependencies** |
| 35 | + |
| 36 | +All dependencies had minor version bumps. |
| 37 | + |
| 38 | +## 8.0 EasyPostClient |
| 39 | + |
| 40 | +Likelihood of Impact: High |
| 41 | + |
| 42 | +This library is now thread-safe with the introduction of a new `EasyPostClient` object. Instead of defining a global API key that all requests use, you create an `EasyPostClient` object and pass your API key to it. You then call your desired functions against a "service" which coincide with EasyPost objects: |
| 43 | + |
| 44 | +```python |
| 45 | +# Old method |
| 46 | +easypost.api_key = os.getenv('EASYPOST_API_KEY') |
| 47 | +shipment = easypost.Shipment.create({'data': 'here'}) |
| 48 | + |
| 49 | +# New method |
| 50 | +client = easypost.EasyPostClient(api_key=os.getenv('EASYPOST_API_KEY')) |
| 51 | +shipment = client.shipment.create({'data': 'here'}) |
| 52 | +``` |
| 53 | + |
| 54 | +All instance methods are now static with the exception of `lowest_rate` as these make API calls and require the EasyPostClient (EasyPost objects do not contain an API key to make API calls with). |
| 55 | + |
| 56 | +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. |
| 57 | + |
| 58 | +Functions no longer accept an API key as an optional parameter. If you need per-function API key changes, create a new EasyPostClient object and call the function on the new client that uses the API key you need. |
| 59 | + |
| 60 | +### 8.0 Improved Error Handling |
| 61 | + |
| 62 | +Likelihood of Impact: High |
| 63 | + |
| 64 | +There are ~2 dozen new error types that extend either `ApiError` or `EasyPostError`. |
| 65 | + |
| 66 | +New ApiErrors (extends EasyPostError): |
| 67 | + |
| 68 | +- `ApiError` |
| 69 | +- `EncodingError` |
| 70 | +- `ExternalApiError` |
| 71 | +- `ForbiddenError` |
| 72 | +- `GatewayTimeoutError` |
| 73 | +- `HttpError` |
| 74 | +- `InternalServerError` |
| 75 | +- `InvalidRequestError` |
| 76 | +- `JsonError` |
| 77 | +- `MethodNotAllowedError` |
| 78 | +- `NotFoundError` |
| 79 | +- `PaymentError` |
| 80 | +- `RateLimitError` |
| 81 | +- `RedirectError` |
| 82 | +- `ServiceUnavailableError` |
| 83 | +- `TimeoutError` |
| 84 | +- `UnauthorizedError` |
| 85 | +- `UnknownApiError` |
| 86 | + |
| 87 | +New EasyPostErrors (extends builtin Exception): |
| 88 | + |
| 89 | +- `EasyPostError` |
| 90 | +- `EndOfPaginationError` |
| 91 | +- `FilteringError` |
| 92 | +- `InvalidObjectError` |
| 93 | +- `InvalidParameterError` |
| 94 | +- `MissingParameterError` |
| 95 | +- `SignatureVerificationError` |
| 96 | + |
| 97 | +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. |
| 98 | + |
| 99 | +The `original_exception` property has been removed and is now returned directly in the error message if present. |
| 100 | + |
| 101 | +### 8.0 Corrected Naming Conventions |
| 102 | + |
| 103 | +Likelihood of Impact: Medium |
| 104 | + |
| 105 | +Occurances of `referral` are now `referral_customer` and `Referral` are now `ReferralCustomer` to match the documentation and API. |
| 106 | + |
| 107 | +Occurances of `smartrate` are now `smart_rate` and `Smartrate` are now `SmartRate` to match the documentation and API. |
| 108 | + |
| 109 | +Occurances of `scanform` are now `scan_form` and `Scanform` are now `ScanForm` to match the documentation and API. |
| 110 | + |
| 111 | +The `primary_or_secondary` parameter name for billing functions is now called `priority` to match the documentation and API. |
| 112 | + |
| 113 | +## 8.0 Beta Namespace Changed |
| 114 | + |
| 115 | +Likelihood of Impact: Low |
| 116 | + |
| 117 | +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()`. |
| 118 | + |
| 119 | +## 8.0 Changed Function Parameter Order and Return Types |
| 120 | + |
| 121 | +Likelihood of Impact: Low |
| 122 | + |
| 123 | +The `update_email` function of the `referral_customer` service had the parameter order switched and name changed. Previously, you would pass the email and then the id, Now, you pass the `id` of the user first, then the email. This change matches the rest of the library where an ID always comes first. |
| 124 | + |
| 125 | +Functions that previously returned `True` now do not return anything as there is no response body from the API (eg: `fund_wallet`, `delete_payment_method`, `update_email`, `create_list`) |
| 126 | + |
8 | 127 | ## Upgrading from 6.x to 7.0 |
9 | 128 |
|
| 129 | +**NOTICE:** v7 is deprecated. |
| 130 | + |
10 | 131 | ### 7.0 High Impact Changes |
11 | 132 |
|
12 | 133 | - [Updating Dependencies](#70-updating-dependencies) |
|
0 commit comments