From 82973e1859cd732a1b97bd1f9d6fe513caca8265 Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Thu, 15 Oct 2026 14:28:34 -0600 Subject: [PATCH 1/2] feat: add carrier open endpoint routing Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- CHANGELOG.md | 1 + src/constants.ts | 29 +- src/services/carrier_account_service.ts | 11 +- .../recording.har | 301 +++++++++++++++++ .../recording.har | 162 ++++++++++ .../recording.har | 162 ++++++++++ .../recording.har | 162 ++++++++++ .../recording.har | 301 +++++++++++++++++ .../recording.har | 301 +++++++++++++++++ .../recording.har | 162 ++++++++++ .../recording.har | 162 ++++++++++ .../recording.har | 162 ++++++++++ .../recording.har | 162 ++++++++++ .../recording.har | 301 +++++++++++++++++ .../recording.har | 305 ++++++++++++++++++ test/services/carrier_account.test.ts | 107 +++--- 16 files changed, 2721 insertions(+), 70 deletions(-) create mode 100644 test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-AmazonShippingAccount_3728507907/recording.har create mode 100644 test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-FedexAccount_3929716835/recording.har create mode 100644 test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-FedexDefaultAccount_3184290240/recording.har create mode 100644 test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-FedexSmartpostAccount_2184701378/recording.har create mode 100644 test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-GofoWalletAccount_1580134849/recording.har create mode 100644 test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-UniUniWalletAccount_822918534/recording.har create mode 100644 test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-UpsAccount_816002135/recording.har create mode 100644 test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-UpsDapAccount_1475169828/recording.har create mode 100644 test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-UpsMailInnovationsAccount_3939531772/recording.har create mode 100644 test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-UpsSurepostAccount_488621050/recording.har create mode 100644 test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-UspsShipAccount_2253578256/recording.har create mode 100644 test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-VehoWalletAccount_2925149370/recording.har diff --git a/CHANGELOG.md b/CHANGELOG.md index ece64cf7f..a03da672f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Removes the deprecated, unusable `addCreditCard` function - Stripe has disabled the ability to pass plain credit card details over the wire and now requires using [Stripe.js/Elements/Checkout](https://support.stripe.com/questions/card-tokenization-restrictions-using-publishable-keys). Follow the [Decentralized (EasyPost-Manage Billing) Guide](https://docs.easypost.com/guides/get-started-with-forge/easypost-managed-billing-guide#referralcustomer-billing-management) for more details on the new flow to use. - Makes `referralCustomer.retrieveEasyPostStripeApiKey` public to help facilitate adding credit cards using Stripe.js +- Adds support for `FedexDefaultAccount`, `GofoWalletAccount`, `UpsDapAccount`, `UniUniWalletAccount`, and `VehoWalletAccount` by properly routing carrier-account create requests to the `/carrier_accounts/open` endpoint. ## v9.0.0-rc.1 (2026-09-08) diff --git a/src/constants.ts b/src/constants.ts index 893119ce1..54a5eab93 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -4,17 +4,24 @@ import Utils from './utils/util'; * A class containing constants used throughout the EasyPost Node.js client library. */ export default class Constants { - static get CARRIER_ACCOUNTS_WITH_CUSTOM_CREATE_WORKFLOWS() { - return ['FedexAccount', 'FedexSmartpostAccount']; - } - static get CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH() { - return [ - 'AmazonShippingAccount', - 'UpsAccount', - 'UpsMailInnovationsAccount', - 'UpsSurepostAccount', - 'UspsShipAccount', - ]; + static get CARRIER_ACCOUNT_CREATE_ENDPOINT_TYPES() { + return { + 'carrier_accounts/open': [ + 'FedexDefaultAccount', + 'GofoWalletAccount', + 'UpsDapAccount', + 'UniUniWalletAccount', + 'VehoWalletAccount', + ], + 'carrier_accounts/register': ['FedexAccount', 'FedexSmartpostAccount'], + 'carrier_accounts/register_oauth': [ + 'AmazonShippingAccount', + 'UpsAccount', + 'UpsMailInnovationsAccount', + 'UpsSurepostAccount', + 'UspsShipAccount', + ], + }; } static EXTERNAL_API_CALL_FAILED = 'Communication with %s failed, please try again later'; static INVALID_API_KEY_TYPE = 'Invalid API key type.'; diff --git a/src/services/carrier_account_service.ts b/src/services/carrier_account_service.ts index 3eaa216f9..5709e63d0 100644 --- a/src/services/carrier_account_service.ts +++ b/src/services/carrier_account_service.ts @@ -89,10 +89,10 @@ export default (easypostClient: EasyPostClient) => * @returns {string} - The endpoint to be used for the carrier account creation request. */ static _selectCarrierAccountCreationEndpoint(carrierAccountType: string): string { - if (Constants.CARRIER_ACCOUNTS_WITH_CUSTOM_CREATE_WORKFLOWS.includes(carrierAccountType)) { - return 'carrier_accounts/register'; - } else if (Constants.CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH.includes(carrierAccountType)) { - return 'carrier_accounts/register_oauth'; + for (const [endpoint, carrierAccountTypes] of Object.entries(Constants.CARRIER_ACCOUNT_CREATE_ENDPOINT_TYPES)) { + if (carrierAccountTypes.includes(carrierAccountType)) { + return endpoint; + } } return 'carrier_accounts'; @@ -109,7 +109,8 @@ export default (easypostClient: EasyPostClient) => carrierAccountType: string, params: Record, ): Record { - if (Constants.CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH.includes(carrierAccountType)) { + const endpoint = this._selectCarrierAccountCreationEndpoint(carrierAccountType); + if (endpoint === 'carrier_accounts/register_oauth') { return { carrier_account_oauth_registrations: params }; } diff --git a/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-AmazonShippingAccount_3728507907/recording.har b/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-AmazonShippingAccount_3728507907/recording.har new file mode 100644 index 000000000..5bdeeb342 --- /dev/null +++ b/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-AmazonShippingAccount_3728507907/recording.har @@ -0,0 +1,301 @@ +{ + "log": { + "_recordingName": "CarrierAccount Service/routes create URL correctly for AmazonShippingAccount", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.6" + }, + "entries": [ + { + "_id": "d55a133132db5170164145dac80f93b8", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 72, + "cookies": [], + "headers": [ + { + "name": "accept", + "value": "application/json" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "accept-encoding", + "value": "gzip, deflate" + }, + { + "name": "host", + "value": "api.easypost.com" + }, + { + "name": "content-length", + "value": 72 + } + ], + "headersSize": 419, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\"carrier_account_oauth_registrations\":{\"type\":\"AmazonShippingAccount\"}}" + }, + "queryString": [], + "url": "https://api.easypost.com/v2/carrier_accounts/register_oauth" + }, + "response": { + "bodySize": 1721, + "content": { + "mimeType": "application/json; charset=utf-8", + "size": 1721, + "text": "{\"id\":\"ca_7bf231c2cd9d4eca8c7c77e977a4fe16\",\"object\":\"CarrierAccount\",\"type\":\"AmazonShippingAccount\",\"clone\":false,\"created_at\":\"2026-10-15T20:28:15Z\",\"updated_at\":\"2026-10-15T20:28:15Z\",\"description\":null,\"reference\":null,\"billing_type\":\"carrier\",\"readable\":\"Amazon Shipping\",\"logo\":null,\"fields\":[],\"credentials\":{},\"test_credentials\":{}}" + }, + "cookies": [], + "headers": [ + { + "name": "cache-control", + "value": "private, no-cache, no-store" + }, + { + "name": "content-encoding", + "value": "gzip" + }, + { + "name": "content-type", + "value": "application/json; charset=utf-8" + }, + { + "name": "easypost-api-version", + "value": "2015-01-01" + }, + { + "name": "expires", + "value": "0" + }, + { + "name": "pragma", + "value": "no-cache" + }, + { + "name": "referrer-policy", + "value": "strict-origin-when-cross-origin" + }, + { + "name": "strict-transport-security", + "value": "max-age=31536000; includeSubDomains; preload" + }, + { + "name": "vary", + "value": "EasyPost-Api-Version" + }, + { + "name": "x-backend", + "value": "easypost" + }, + { + "name": "x-content-type-options", + "value": "nosniff" + }, + { + "name": "x-download-options", + "value": "noopen" + }, + { + "name": "x-ep-request-uuid", + "value": "2cb8c6476ad1375fe2bc397a0008587c" + }, + { + "name": "x-frame-options", + "value": "SAMEORIGIN" + }, + { + "name": "x-node", + "value": "web109azw" + }, + { + "name": "x-permitted-cross-domain-policies", + "value": "none" + }, + { + "name": "x-proxied", + "value": "intlb2azw f29267e751, extlb2azw ff4cfe6eb5" + }, + { + "name": "x-runtime", + "value": "0.109660" + }, + { + "name": "x-version-label", + "value": "easypost-202610151955-b13716d895-main" + }, + { + "name": "x-xss-protection", + "value": "1; mode=block" + } + ], + "headersSize": 721, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 201, + "statusText": "Created" + }, + "startedDateTime": "2026-10-15T20:28:15.828Z", + "time": 142, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 142 + } + }, + { + "_id": "5324f66482126a0fc39cfc343fe555f4", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 0, + "cookies": [], + "headers": [ + { + "name": "accept", + "value": "application/json" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "accept-encoding", + "value": "gzip, deflate" + }, + { + "name": "host", + "value": "api.easypost.com" + } + ], + "headersSize": 422, + "httpVersion": "HTTP/1.1", + "method": "DELETE", + "queryString": [], + "url": "https://api.easypost.com/v2/carrier_accounts/ca_7bf231c2cd9d4eca8c7c77e977a4fe16" + }, + "response": { + "bodySize": 2, + "content": { + "mimeType": "application/json; charset=utf-8", + "size": 2, + "text": "{}" + }, + "cookies": [], + "headers": [ + { + "name": "cache-control", + "value": "private, no-cache, no-store" + }, + { + "name": "content-encoding", + "value": "gzip" + }, + { + "name": "content-type", + "value": "application/json; charset=utf-8" + }, + { + "name": "easypost-api-version", + "value": "2015-01-01" + }, + { + "name": "expires", + "value": "0" + }, + { + "name": "pragma", + "value": "no-cache" + }, + { + "name": "referrer-policy", + "value": "strict-origin-when-cross-origin" + }, + { + "name": "strict-transport-security", + "value": "max-age=31536000; includeSubDomains; preload" + }, + { + "name": "vary", + "value": "EasyPost-Api-Version" + }, + { + "name": "x-backend", + "value": "easypost" + }, + { + "name": "x-content-type-options", + "value": "nosniff" + }, + { + "name": "x-download-options", + "value": "noopen" + }, + { + "name": "x-ep-request-uuid", + "value": "2cb8c6476ad1375fe2bc397a000858ad" + }, + { + "name": "x-frame-options", + "value": "SAMEORIGIN" + }, + { + "name": "x-node", + "value": "web113azw" + }, + { + "name": "x-permitted-cross-domain-policies", + "value": "none" + }, + { + "name": "x-proxied", + "value": "intlb2azw f29267e751, extlb2azw ff4cfe6eb5" + }, + { + "name": "x-runtime", + "value": "0.068069" + }, + { + "name": "x-version-label", + "value": "easypost-202610151955-b13716d895-main" + }, + { + "name": "x-xss-protection", + "value": "1; mode=block" + } + ], + "headersSize": 721, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2026-10-15T20:28:15.970Z", + "time": 99, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 99 + } + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-FedexAccount_3929716835/recording.har b/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-FedexAccount_3929716835/recording.har new file mode 100644 index 000000000..fd4a7dd06 --- /dev/null +++ b/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-FedexAccount_3929716835/recording.har @@ -0,0 +1,162 @@ +{ + "log": { + "_recordingName": "CarrierAccount Service/routes create URL correctly for FedexAccount", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.6" + }, + "entries": [ + { + "_id": "c1e3fb437d6b0627cb5ccf390c64114c", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 66, + "cookies": [], + "headers": [ + { + "name": "accept", + "value": "application/json" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "accept-encoding", + "value": "gzip, deflate" + }, + { + "name": "host", + "value": "api.easypost.com" + }, + { + "name": "content-length", + "value": 66 + } + ], + "headersSize": 413, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\"carrier_account\":{\"type\":\"FedexAccount\",\"registration_data\":{}}}" + }, + "queryString": [], + "url": "https://api.easypost.com/v2/carrier_accounts/register" + }, + "response": { + "bodySize": 357, + "content": { + "mimeType": "application/json; charset=utf-8", + "size": 357, + "text": "{\"error\":{\"code\":\"GONE\",\"message\":\"The requested resource is no longer available at the server and no forwarding address is known.\",\"errors\":[{\"message\":\"FedEx account registrations must use the multi-factor authentication (MFA) registration workflow. See: https://support.easypost.com/hc/en-us/articles/35262738410253-FedEx-Multi-Factor-Authentication\"}]}}" + }, + "cookies": [], + "headers": [ + { + "name": "cache-control", + "value": "private, no-cache, no-store" + }, + { + "name": "content-encoding", + "value": "gzip" + }, + { + "name": "content-type", + "value": "application/json; charset=utf-8" + }, + { + "name": "easypost-api-version", + "value": "2015-01-01" + }, + { + "name": "expires", + "value": "0" + }, + { + "name": "pragma", + "value": "no-cache" + }, + { + "name": "referrer-policy", + "value": "strict-origin-when-cross-origin" + }, + { + "name": "strict-transport-security", + "value": "max-age=31536000; includeSubDomains; preload" + }, + { + "name": "vary", + "value": "EasyPost-Api-Version" + }, + { + "name": "x-backend", + "value": "easypost" + }, + { + "name": "x-content-type-options", + "value": "nosniff" + }, + { + "name": "x-download-options", + "value": "noopen" + }, + { + "name": "x-ep-request-uuid", + "value": "2cb8c6476ad1375fe2bc397a00085832" + }, + { + "name": "x-frame-options", + "value": "SAMEORIGIN" + }, + { + "name": "x-node", + "value": "web118azw" + }, + { + "name": "x-permitted-cross-domain-policies", + "value": "none" + }, + { + "name": "x-proxied", + "value": "intlb1azw f29267e751, extlb2azw ff4cfe6eb5" + }, + { + "name": "x-runtime", + "value": "0.045282" + }, + { + "name": "x-version-label", + "value": "easypost-202610151955-b13716d895-main" + }, + { + "name": "x-xss-protection", + "value": "1; mode=block" + } + ], + "headersSize": 721, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 410, + "statusText": "Gone" + }, + "startedDateTime": "2026-10-15T20:28:15.639Z", + "time": 103, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 103 + } + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-FedexDefaultAccount_3184290240/recording.har b/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-FedexDefaultAccount_3184290240/recording.har new file mode 100644 index 000000000..376ad3b1f --- /dev/null +++ b/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-FedexDefaultAccount_3184290240/recording.har @@ -0,0 +1,162 @@ +{ + "log": { + "_recordingName": "CarrierAccount Service/routes create URL correctly for FedexDefaultAccount", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.6" + }, + "entries": [ + { + "_id": "7ca5c5338b08fd60767da9c6f8104fb7", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 73, + "cookies": [], + "headers": [ + { + "name": "accept", + "value": "application/json" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "accept-encoding", + "value": "gzip, deflate" + }, + { + "name": "host", + "value": "api.easypost.com" + }, + { + "name": "content-length", + "value": 73 + } + ], + "headersSize": 409, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\"carrier_account\":{\"type\":\"FedexDefaultAccount\",\"registration_data\":{}}}" + }, + "queryString": [], + "url": "https://api.easypost.com/v2/carrier_accounts/open" + }, + "response": { + "bodySize": 453, + "content": { + "mimeType": "application/json; charset=utf-8", + "size": 453, + "text": "{\"error\":{\"code\":\"UNPROCESSABLE_ENTITY\",\"message\":\"The request was understood, but cannot be processed.\",\"errors\":[{\"field\":\"name\",\"message\":\"is missing\"},{\"field\":\"street1\",\"message\":\"is missing\"},{\"field\":\"city\",\"message\":\"is missing\"},{\"field\":\"state\",\"message\":\"is missing\"},{\"field\":\"postal_code\",\"message\":\"is missing\"},{\"field\":\"country\",\"message\":\"is missing\"},{\"field\":\"phone\",\"message\":\"is missing\"},{\"field\":\"email\",\"message\":\"is missing\"}]}}" + }, + "cookies": [], + "headers": [ + { + "name": "cache-control", + "value": "private, no-cache, no-store" + }, + { + "name": "content-encoding", + "value": "gzip" + }, + { + "name": "content-type", + "value": "application/json; charset=utf-8" + }, + { + "name": "easypost-api-version", + "value": "2015-01-01" + }, + { + "name": "expires", + "value": "0" + }, + { + "name": "pragma", + "value": "no-cache" + }, + { + "name": "referrer-policy", + "value": "strict-origin-when-cross-origin" + }, + { + "name": "strict-transport-security", + "value": "max-age=31536000; includeSubDomains; preload" + }, + { + "name": "vary", + "value": "EasyPost-Api-Version" + }, + { + "name": "x-backend", + "value": "easypost" + }, + { + "name": "x-content-type-options", + "value": "nosniff" + }, + { + "name": "x-download-options", + "value": "noopen" + }, + { + "name": "x-ep-request-uuid", + "value": "2cb8c6476ad1375ee2bc397a00085728" + }, + { + "name": "x-frame-options", + "value": "SAMEORIGIN" + }, + { + "name": "x-node", + "value": "web103azw" + }, + { + "name": "x-permitted-cross-domain-policies", + "value": "none" + }, + { + "name": "x-proxied", + "value": "intlb3azw f29267e751, extlb2azw ff4cfe6eb5" + }, + { + "name": "x-runtime", + "value": "0.034508" + }, + { + "name": "x-version-label", + "value": "easypost-202610151955-b13716d895-main" + }, + { + "name": "x-xss-protection", + "value": "1; mode=block" + } + ], + "headersSize": 721, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 422, + "statusText": "Unprocessable Entity" + }, + "startedDateTime": "2026-10-15T20:28:14.669Z", + "time": 197, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 197 + } + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-FedexSmartpostAccount_2184701378/recording.har b/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-FedexSmartpostAccount_2184701378/recording.har new file mode 100644 index 000000000..630a72ec2 --- /dev/null +++ b/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-FedexSmartpostAccount_2184701378/recording.har @@ -0,0 +1,162 @@ +{ + "log": { + "_recordingName": "CarrierAccount Service/routes create URL correctly for FedexSmartpostAccount", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.6" + }, + "entries": [ + { + "_id": "84458a0f5da6ee8354a6d7b8962b0564", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 75, + "cookies": [], + "headers": [ + { + "name": "accept", + "value": "application/json" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "accept-encoding", + "value": "gzip, deflate" + }, + { + "name": "host", + "value": "api.easypost.com" + }, + { + "name": "content-length", + "value": 75 + } + ], + "headersSize": 413, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\"carrier_account\":{\"type\":\"FedexSmartpostAccount\",\"registration_data\":{}}}" + }, + "queryString": [], + "url": "https://api.easypost.com/v2/carrier_accounts/register" + }, + "response": { + "bodySize": 357, + "content": { + "mimeType": "application/json; charset=utf-8", + "size": 357, + "text": "{\"error\":{\"code\":\"GONE\",\"message\":\"The requested resource is no longer available at the server and no forwarding address is known.\",\"errors\":[{\"message\":\"FedEx account registrations must use the multi-factor authentication (MFA) registration workflow. See: https://support.easypost.com/hc/en-us/articles/35262738410253-FedEx-Multi-Factor-Authentication\"}]}}" + }, + "cookies": [], + "headers": [ + { + "name": "cache-control", + "value": "private, no-cache, no-store" + }, + { + "name": "content-encoding", + "value": "gzip" + }, + { + "name": "content-type", + "value": "application/json; charset=utf-8" + }, + { + "name": "easypost-api-version", + "value": "2015-01-01" + }, + { + "name": "expires", + "value": "0" + }, + { + "name": "pragma", + "value": "no-cache" + }, + { + "name": "referrer-policy", + "value": "strict-origin-when-cross-origin" + }, + { + "name": "strict-transport-security", + "value": "max-age=31536000; includeSubDomains; preload" + }, + { + "name": "vary", + "value": "EasyPost-Api-Version" + }, + { + "name": "x-backend", + "value": "easypost" + }, + { + "name": "x-content-type-options", + "value": "nosniff" + }, + { + "name": "x-download-options", + "value": "noopen" + }, + { + "name": "x-ep-request-uuid", + "value": "2cb8c6476ad1375fe2bc397a00085864" + }, + { + "name": "x-frame-options", + "value": "SAMEORIGIN" + }, + { + "name": "x-node", + "value": "web115azw" + }, + { + "name": "x-permitted-cross-domain-policies", + "value": "none" + }, + { + "name": "x-proxied", + "value": "intlb3azw f29267e751, extlb2azw ff4cfe6eb5" + }, + { + "name": "x-runtime", + "value": "0.048017" + }, + { + "name": "x-version-label", + "value": "easypost-202610151955-b13716d895-main" + }, + { + "name": "x-xss-protection", + "value": "1; mode=block" + } + ], + "headersSize": 721, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 410, + "statusText": "Gone" + }, + "startedDateTime": "2026-10-15T20:28:15.744Z", + "time": 82, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 82 + } + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-GofoWalletAccount_1580134849/recording.har b/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-GofoWalletAccount_1580134849/recording.har new file mode 100644 index 000000000..1d409409f --- /dev/null +++ b/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-GofoWalletAccount_1580134849/recording.har @@ -0,0 +1,301 @@ +{ + "log": { + "_recordingName": "CarrierAccount Service/routes create URL correctly for GofoWalletAccount", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.6" + }, + "entries": [ + { + "_id": "b927f6cd08112932831dc0ae3287af0c", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 71, + "cookies": [], + "headers": [ + { + "name": "accept", + "value": "application/json" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "accept-encoding", + "value": "gzip, deflate" + }, + { + "name": "host", + "value": "api.easypost.com" + }, + { + "name": "content-length", + "value": 71 + } + ], + "headersSize": 409, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\"carrier_account\":{\"type\":\"GofoWalletAccount\",\"registration_data\":{}}}" + }, + "queryString": [], + "url": "https://api.easypost.com/v2/carrier_accounts/open" + }, + "response": { + "bodySize": 460, + "content": { + "mimeType": "application/json; charset=utf-8", + "size": 460, + "text": "{\"id\":\"ca_f2d2c195eef544b893b90e5db8a40649\",\"object\":\"CarrierAccount\",\"type\":\"GofoWalletAccount\",\"clone\":false,\"created_at\":\"2026-10-15T20:28:14Z\",\"updated_at\":\"2026-10-15T20:28:14Z\",\"description\":\"GOFO Wallet Account\",\"reference\":null,\"billing_type\":\"easypost\",\"readable\":\"GOFO Wallet\",\"logo\":null,\"fields\":[],\"credentials\":{},\"test_credentials\":{}}" + }, + "cookies": [], + "headers": [ + { + "name": "cache-control", + "value": "private, no-cache, no-store" + }, + { + "name": "content-encoding", + "value": "gzip" + }, + { + "name": "content-type", + "value": "application/json; charset=utf-8" + }, + { + "name": "easypost-api-version", + "value": "2015-01-01" + }, + { + "name": "expires", + "value": "0" + }, + { + "name": "pragma", + "value": "no-cache" + }, + { + "name": "referrer-policy", + "value": "strict-origin-when-cross-origin" + }, + { + "name": "strict-transport-security", + "value": "max-age=31536000; includeSubDomains; preload" + }, + { + "name": "vary", + "value": "EasyPost-Api-Version" + }, + { + "name": "x-backend", + "value": "easypost" + }, + { + "name": "x-content-type-options", + "value": "nosniff" + }, + { + "name": "x-download-options", + "value": "noopen" + }, + { + "name": "x-ep-request-uuid", + "value": "2cb8c6476ad1375ee2bc397a00085746" + }, + { + "name": "x-frame-options", + "value": "SAMEORIGIN" + }, + { + "name": "x-node", + "value": "web114azw" + }, + { + "name": "x-permitted-cross-domain-policies", + "value": "none" + }, + { + "name": "x-proxied", + "value": "intlb1azw f29267e751, extlb2azw ff4cfe6eb5" + }, + { + "name": "x-runtime", + "value": "0.077727" + }, + { + "name": "x-version-label", + "value": "easypost-202610151955-b13716d895-main" + }, + { + "name": "x-xss-protection", + "value": "1; mode=block" + } + ], + "headersSize": 721, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 201, + "statusText": "Created" + }, + "startedDateTime": "2026-10-15T20:28:14.877Z", + "time": 146, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 146 + } + }, + { + "_id": "19dc65b637b28c7ce1e09bf6abb590b4", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 0, + "cookies": [], + "headers": [ + { + "name": "accept", + "value": "application/json" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "accept-encoding", + "value": "gzip, deflate" + }, + { + "name": "host", + "value": "api.easypost.com" + } + ], + "headersSize": 422, + "httpVersion": "HTTP/1.1", + "method": "DELETE", + "queryString": [], + "url": "https://api.easypost.com/v2/carrier_accounts/ca_f2d2c195eef544b893b90e5db8a40649" + }, + "response": { + "bodySize": 2, + "content": { + "mimeType": "application/json; charset=utf-8", + "size": 2, + "text": "{}" + }, + "cookies": [], + "headers": [ + { + "name": "cache-control", + "value": "private, no-cache, no-store" + }, + { + "name": "content-encoding", + "value": "gzip" + }, + { + "name": "content-type", + "value": "application/json; charset=utf-8" + }, + { + "name": "easypost-api-version", + "value": "2015-01-01" + }, + { + "name": "expires", + "value": "0" + }, + { + "name": "pragma", + "value": "no-cache" + }, + { + "name": "referrer-policy", + "value": "strict-origin-when-cross-origin" + }, + { + "name": "strict-transport-security", + "value": "max-age=31536000; includeSubDomains; preload" + }, + { + "name": "vary", + "value": "EasyPost-Api-Version" + }, + { + "name": "x-backend", + "value": "easypost" + }, + { + "name": "x-content-type-options", + "value": "nosniff" + }, + { + "name": "x-download-options", + "value": "noopen" + }, + { + "name": "x-ep-request-uuid", + "value": "2cb8c6476ad1375fe2bc397a00085774" + }, + { + "name": "x-frame-options", + "value": "SAMEORIGIN" + }, + { + "name": "x-node", + "value": "web115azw" + }, + { + "name": "x-permitted-cross-domain-policies", + "value": "none" + }, + { + "name": "x-proxied", + "value": "intlb3azw f29267e751, extlb2azw ff4cfe6eb5" + }, + { + "name": "x-runtime", + "value": "0.067762" + }, + { + "name": "x-version-label", + "value": "easypost-202610151955-b13716d895-main" + }, + { + "name": "x-xss-protection", + "value": "1; mode=block" + } + ], + "headersSize": 721, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2026-10-15T20:28:15.024Z", + "time": 99, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 99 + } + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-UniUniWalletAccount_822918534/recording.har b/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-UniUniWalletAccount_822918534/recording.har new file mode 100644 index 000000000..84c4ba1a9 --- /dev/null +++ b/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-UniUniWalletAccount_822918534/recording.har @@ -0,0 +1,301 @@ +{ + "log": { + "_recordingName": "CarrierAccount Service/routes create URL correctly for UniUniWalletAccount", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.6" + }, + "entries": [ + { + "_id": "3a58440d5a49c43302bb2915dead90e4", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 73, + "cookies": [], + "headers": [ + { + "name": "accept", + "value": "application/json" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "accept-encoding", + "value": "gzip, deflate" + }, + { + "name": "host", + "value": "api.easypost.com" + }, + { + "name": "content-length", + "value": 73 + } + ], + "headersSize": 409, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\"carrier_account\":{\"type\":\"UniUniWalletAccount\",\"registration_data\":{}}}" + }, + "queryString": [], + "url": "https://api.easypost.com/v2/carrier_accounts/open" + }, + "response": { + "bodySize": 600, + "content": { + "mimeType": "application/json; charset=utf-8", + "size": 600, + "text": "{\"id\":\"ca_cc98db4313bc49e2bdd416b853f7dbf1\",\"object\":\"CarrierAccount\",\"type\":\"UniUniWalletAccount\",\"clone\":false,\"created_at\":\"2026-10-15T20:28:15Z\",\"updated_at\":\"2026-10-15T20:28:15Z\",\"description\":\"UniUni Wallet Account\",\"reference\":null,\"billing_type\":\"easypost\",\"readable\":\"UniUni Wallet\",\"logo\":null,\"fields\":[],\"credentials\":{},\"test_credentials\":{}}" + }, + "cookies": [], + "headers": [ + { + "name": "cache-control", + "value": "private, no-cache, no-store" + }, + { + "name": "content-encoding", + "value": "gzip" + }, + { + "name": "content-type", + "value": "application/json; charset=utf-8" + }, + { + "name": "easypost-api-version", + "value": "2015-01-01" + }, + { + "name": "expires", + "value": "0" + }, + { + "name": "pragma", + "value": "no-cache" + }, + { + "name": "referrer-policy", + "value": "strict-origin-when-cross-origin" + }, + { + "name": "strict-transport-security", + "value": "max-age=31536000; includeSubDomains; preload" + }, + { + "name": "vary", + "value": "EasyPost-Api-Version" + }, + { + "name": "x-backend", + "value": "easypost" + }, + { + "name": "x-content-type-options", + "value": "nosniff" + }, + { + "name": "x-download-options", + "value": "noopen" + }, + { + "name": "x-ep-request-uuid", + "value": "2cb8c6476ad1375fe2bc397a000857ab" + }, + { + "name": "x-frame-options", + "value": "SAMEORIGIN" + }, + { + "name": "x-node", + "value": "web118azw" + }, + { + "name": "x-permitted-cross-domain-policies", + "value": "none" + }, + { + "name": "x-proxied", + "value": "intlb3azw f29267e751, extlb2azw ff4cfe6eb5" + }, + { + "name": "x-runtime", + "value": "0.069136" + }, + { + "name": "x-version-label", + "value": "easypost-202610151955-b13716d895-main" + }, + { + "name": "x-xss-protection", + "value": "1; mode=block" + } + ], + "headersSize": 721, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 201, + "statusText": "Created" + }, + "startedDateTime": "2026-10-15T20:28:15.222Z", + "time": 104, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 104 + } + }, + { + "_id": "4a7309e507f0ce4bfba82bf13135e1ec", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 0, + "cookies": [], + "headers": [ + { + "name": "accept", + "value": "application/json" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "accept-encoding", + "value": "gzip, deflate" + }, + { + "name": "host", + "value": "api.easypost.com" + } + ], + "headersSize": 422, + "httpVersion": "HTTP/1.1", + "method": "DELETE", + "queryString": [], + "url": "https://api.easypost.com/v2/carrier_accounts/ca_cc98db4313bc49e2bdd416b853f7dbf1" + }, + "response": { + "bodySize": 2, + "content": { + "mimeType": "application/json; charset=utf-8", + "size": 2, + "text": "{}" + }, + "cookies": [], + "headers": [ + { + "name": "cache-control", + "value": "private, no-cache, no-store" + }, + { + "name": "content-encoding", + "value": "gzip" + }, + { + "name": "content-type", + "value": "application/json; charset=utf-8" + }, + { + "name": "easypost-api-version", + "value": "2015-01-01" + }, + { + "name": "expires", + "value": "0" + }, + { + "name": "pragma", + "value": "no-cache" + }, + { + "name": "referrer-policy", + "value": "strict-origin-when-cross-origin" + }, + { + "name": "strict-transport-security", + "value": "max-age=31536000; includeSubDomains; preload" + }, + { + "name": "vary", + "value": "EasyPost-Api-Version" + }, + { + "name": "x-backend", + "value": "easypost" + }, + { + "name": "x-content-type-options", + "value": "nosniff" + }, + { + "name": "x-download-options", + "value": "noopen" + }, + { + "name": "x-ep-request-uuid", + "value": "2cb8c6476ad1375fe2bc397a000857c8" + }, + { + "name": "x-frame-options", + "value": "SAMEORIGIN" + }, + { + "name": "x-node", + "value": "web120azw" + }, + { + "name": "x-permitted-cross-domain-policies", + "value": "none" + }, + { + "name": "x-proxied", + "value": "intlb1azw f29267e751, extlb2azw ff4cfe6eb5" + }, + { + "name": "x-runtime", + "value": "0.073523" + }, + { + "name": "x-version-label", + "value": "easypost-202610151955-b13716d895-main" + }, + { + "name": "x-xss-protection", + "value": "1; mode=block" + } + ], + "headersSize": 721, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2026-10-15T20:28:15.327Z", + "time": 105, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 105 + } + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-UpsAccount_816002135/recording.har b/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-UpsAccount_816002135/recording.har new file mode 100644 index 000000000..155b6d30a --- /dev/null +++ b/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-UpsAccount_816002135/recording.har @@ -0,0 +1,162 @@ +{ + "log": { + "_recordingName": "CarrierAccount Service/routes create URL correctly for UpsAccount", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.6" + }, + "entries": [ + { + "_id": "96c4b86070ec8c8136ecf352e312b590", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 61, + "cookies": [], + "headers": [ + { + "name": "accept", + "value": "application/json" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "accept-encoding", + "value": "gzip, deflate" + }, + { + "name": "host", + "value": "api.easypost.com" + }, + { + "name": "content-length", + "value": 61 + } + ], + "headersSize": 419, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\"carrier_account_oauth_registrations\":{\"type\":\"UpsAccount\"}}" + }, + "queryString": [], + "url": "https://api.easypost.com/v2/carrier_accounts/register_oauth" + }, + "response": { + "bodySize": 227, + "content": { + "mimeType": "application/json; charset=utf-8", + "size": 227, + "text": "{\"error\":{\"code\":\"UNPROCESSABLE_ENTITY\",\"message\":\"The request was understood, but cannot be processed.\",\"errors\":[{\"field\":\"account_number\",\"message\":\"The provided Carrier Account's Account Number is required but missing.\"}]}}" + }, + "cookies": [], + "headers": [ + { + "name": "cache-control", + "value": "private, no-cache, no-store" + }, + { + "name": "content-encoding", + "value": "gzip" + }, + { + "name": "content-type", + "value": "application/json; charset=utf-8" + }, + { + "name": "easypost-api-version", + "value": "2015-01-01" + }, + { + "name": "expires", + "value": "0" + }, + { + "name": "pragma", + "value": "no-cache" + }, + { + "name": "referrer-policy", + "value": "strict-origin-when-cross-origin" + }, + { + "name": "strict-transport-security", + "value": "max-age=31536000; includeSubDomains; preload" + }, + { + "name": "vary", + "value": "EasyPost-Api-Version" + }, + { + "name": "x-backend", + "value": "easypost" + }, + { + "name": "x-content-type-options", + "value": "nosniff" + }, + { + "name": "x-download-options", + "value": "noopen" + }, + { + "name": "x-ep-request-uuid", + "value": "2cb8c6476ad13760e2bc397a000858c4" + }, + { + "name": "x-frame-options", + "value": "SAMEORIGIN" + }, + { + "name": "x-node", + "value": "web102azw" + }, + { + "name": "x-permitted-cross-domain-policies", + "value": "none" + }, + { + "name": "x-proxied", + "value": "intlb4azw f29267e751, extlb2azw ff4cfe6eb5" + }, + { + "name": "x-runtime", + "value": "0.023593" + }, + { + "name": "x-version-label", + "value": "easypost-202610151955-b13716d895-main" + }, + { + "name": "x-xss-protection", + "value": "1; mode=block" + } + ], + "headersSize": 721, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 422, + "statusText": "Unprocessable Entity" + }, + "startedDateTime": "2026-10-15T20:28:16.072Z", + "time": 59, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 59 + } + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-UpsDapAccount_1475169828/recording.har b/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-UpsDapAccount_1475169828/recording.har new file mode 100644 index 000000000..96a237eb8 --- /dev/null +++ b/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-UpsDapAccount_1475169828/recording.har @@ -0,0 +1,162 @@ +{ + "log": { + "_recordingName": "CarrierAccount Service/routes create URL correctly for UpsDapAccount", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.6" + }, + "entries": [ + { + "_id": "03aa40d8c719e0cb5a0ecd77d37b85f2", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 67, + "cookies": [], + "headers": [ + { + "name": "accept", + "value": "application/json" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "accept-encoding", + "value": "gzip, deflate" + }, + { + "name": "host", + "value": "api.easypost.com" + }, + { + "name": "content-length", + "value": 67 + } + ], + "headersSize": 409, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\"carrier_account\":{\"type\":\"UpsDapAccount\",\"registration_data\":{}}}" + }, + "queryString": [], + "url": "https://api.easypost.com/v2/carrier_accounts/open" + }, + "response": { + "bodySize": 216, + "content": { + "mimeType": "application/json; charset=utf-8", + "size": 216, + "text": "{\"error\":{\"code\":\"UNPROCESSABLE_ENTITY\",\"message\":\"The request was understood, but cannot be processed.\",\"errors\":[{\"field\":\"type\",\"message\":\"Cannot open a UPS DAP account for a user with an existing UPS account\"}]}}" + }, + "cookies": [], + "headers": [ + { + "name": "cache-control", + "value": "private, no-cache, no-store" + }, + { + "name": "content-encoding", + "value": "gzip" + }, + { + "name": "content-type", + "value": "application/json; charset=utf-8" + }, + { + "name": "easypost-api-version", + "value": "2015-01-01" + }, + { + "name": "expires", + "value": "0" + }, + { + "name": "pragma", + "value": "no-cache" + }, + { + "name": "referrer-policy", + "value": "strict-origin-when-cross-origin" + }, + { + "name": "strict-transport-security", + "value": "max-age=31536000; includeSubDomains; preload" + }, + { + "name": "vary", + "value": "EasyPost-Api-Version" + }, + { + "name": "x-backend", + "value": "easypost" + }, + { + "name": "x-content-type-options", + "value": "nosniff" + }, + { + "name": "x-download-options", + "value": "noopen" + }, + { + "name": "x-ep-request-uuid", + "value": "2cb8c6476ad1375fe2bc397a00085785" + }, + { + "name": "x-frame-options", + "value": "SAMEORIGIN" + }, + { + "name": "x-node", + "value": "web107azw" + }, + { + "name": "x-permitted-cross-domain-policies", + "value": "none" + }, + { + "name": "x-proxied", + "value": "intlb2azw f29267e751, extlb2azw ff4cfe6eb5" + }, + { + "name": "x-runtime", + "value": "0.048193" + }, + { + "name": "x-version-label", + "value": "easypost-202610151955-b13716d895-main" + }, + { + "name": "x-xss-protection", + "value": "1; mode=block" + } + ], + "headersSize": 721, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 422, + "statusText": "Unprocessable Entity" + }, + "startedDateTime": "2026-10-15T20:28:15.125Z", + "time": 89, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 89 + } + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-UpsMailInnovationsAccount_3939531772/recording.har b/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-UpsMailInnovationsAccount_3939531772/recording.har new file mode 100644 index 000000000..1ccb5bbcb --- /dev/null +++ b/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-UpsMailInnovationsAccount_3939531772/recording.har @@ -0,0 +1,162 @@ +{ + "log": { + "_recordingName": "CarrierAccount Service/routes create URL correctly for UpsMailInnovationsAccount", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.6" + }, + "entries": [ + { + "_id": "e957021fccc9465e806a4da671414e67", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 76, + "cookies": [], + "headers": [ + { + "name": "accept", + "value": "application/json" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "accept-encoding", + "value": "gzip, deflate" + }, + { + "name": "host", + "value": "api.easypost.com" + }, + { + "name": "content-length", + "value": 76 + } + ], + "headersSize": 419, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\"carrier_account_oauth_registrations\":{\"type\":\"UpsMailInnovationsAccount\"}}" + }, + "queryString": [], + "url": "https://api.easypost.com/v2/carrier_accounts/register_oauth" + }, + "response": { + "bodySize": 227, + "content": { + "mimeType": "application/json; charset=utf-8", + "size": 227, + "text": "{\"error\":{\"code\":\"UNPROCESSABLE_ENTITY\",\"message\":\"The request was understood, but cannot be processed.\",\"errors\":[{\"field\":\"account_number\",\"message\":\"The provided Carrier Account's Account Number is required but missing.\"}]}}" + }, + "cookies": [], + "headers": [ + { + "name": "cache-control", + "value": "private, no-cache, no-store" + }, + { + "name": "content-encoding", + "value": "gzip" + }, + { + "name": "content-type", + "value": "application/json; charset=utf-8" + }, + { + "name": "easypost-api-version", + "value": "2015-01-01" + }, + { + "name": "expires", + "value": "0" + }, + { + "name": "pragma", + "value": "no-cache" + }, + { + "name": "referrer-policy", + "value": "strict-origin-when-cross-origin" + }, + { + "name": "strict-transport-security", + "value": "max-age=31536000; includeSubDomains; preload" + }, + { + "name": "vary", + "value": "EasyPost-Api-Version" + }, + { + "name": "x-backend", + "value": "easypost" + }, + { + "name": "x-content-type-options", + "value": "nosniff" + }, + { + "name": "x-download-options", + "value": "noopen" + }, + { + "name": "x-ep-request-uuid", + "value": "2cb8c6476ad13760e2bc397a000858db" + }, + { + "name": "x-frame-options", + "value": "SAMEORIGIN" + }, + { + "name": "x-node", + "value": "web111azw" + }, + { + "name": "x-permitted-cross-domain-policies", + "value": "none" + }, + { + "name": "x-proxied", + "value": "intlb1azw f29267e751, extlb2azw ff4cfe6eb5" + }, + { + "name": "x-runtime", + "value": "0.034127" + }, + { + "name": "x-version-label", + "value": "easypost-202610151955-b13716d895-main" + }, + { + "name": "x-xss-protection", + "value": "1; mode=block" + } + ], + "headersSize": 721, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 422, + "statusText": "Unprocessable Entity" + }, + "startedDateTime": "2026-10-15T20:28:16.133Z", + "time": 64, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 64 + } + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-UpsSurepostAccount_488621050/recording.har b/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-UpsSurepostAccount_488621050/recording.har new file mode 100644 index 000000000..f1beff94d --- /dev/null +++ b/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-UpsSurepostAccount_488621050/recording.har @@ -0,0 +1,162 @@ +{ + "log": { + "_recordingName": "CarrierAccount Service/routes create URL correctly for UpsSurepostAccount", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.6" + }, + "entries": [ + { + "_id": "848ccbcc9d7af01bf4c6e9a4fb419acb", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 69, + "cookies": [], + "headers": [ + { + "name": "accept", + "value": "application/json" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "accept-encoding", + "value": "gzip, deflate" + }, + { + "name": "host", + "value": "api.easypost.com" + }, + { + "name": "content-length", + "value": 69 + } + ], + "headersSize": 419, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\"carrier_account_oauth_registrations\":{\"type\":\"UpsSurepostAccount\"}}" + }, + "queryString": [], + "url": "https://api.easypost.com/v2/carrier_accounts/register_oauth" + }, + "response": { + "bodySize": 227, + "content": { + "mimeType": "application/json; charset=utf-8", + "size": 227, + "text": "{\"error\":{\"code\":\"UNPROCESSABLE_ENTITY\",\"message\":\"The request was understood, but cannot be processed.\",\"errors\":[{\"field\":\"account_number\",\"message\":\"The provided Carrier Account's Account Number is required but missing.\"}]}}" + }, + "cookies": [], + "headers": [ + { + "name": "cache-control", + "value": "private, no-cache, no-store" + }, + { + "name": "content-encoding", + "value": "gzip" + }, + { + "name": "content-type", + "value": "application/json; charset=utf-8" + }, + { + "name": "easypost-api-version", + "value": "2015-01-01" + }, + { + "name": "expires", + "value": "0" + }, + { + "name": "pragma", + "value": "no-cache" + }, + { + "name": "referrer-policy", + "value": "strict-origin-when-cross-origin" + }, + { + "name": "strict-transport-security", + "value": "max-age=31536000; includeSubDomains; preload" + }, + { + "name": "vary", + "value": "EasyPost-Api-Version" + }, + { + "name": "x-backend", + "value": "easypost" + }, + { + "name": "x-content-type-options", + "value": "nosniff" + }, + { + "name": "x-download-options", + "value": "noopen" + }, + { + "name": "x-ep-request-uuid", + "value": "2cb8c6476ad13760e2bc397a0008590b" + }, + { + "name": "x-frame-options", + "value": "SAMEORIGIN" + }, + { + "name": "x-node", + "value": "web113azw" + }, + { + "name": "x-permitted-cross-domain-policies", + "value": "none" + }, + { + "name": "x-proxied", + "value": "intlb1azw f29267e751, extlb2azw ff4cfe6eb5" + }, + { + "name": "x-runtime", + "value": "0.022615" + }, + { + "name": "x-version-label", + "value": "easypost-202610151955-b13716d895-main" + }, + { + "name": "x-xss-protection", + "value": "1; mode=block" + } + ], + "headersSize": 721, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 422, + "statusText": "Unprocessable Entity" + }, + "startedDateTime": "2026-10-15T20:28:16.199Z", + "time": 59, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 59 + } + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-UspsShipAccount_2253578256/recording.har b/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-UspsShipAccount_2253578256/recording.har new file mode 100644 index 000000000..4211c3b49 --- /dev/null +++ b/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-UspsShipAccount_2253578256/recording.har @@ -0,0 +1,301 @@ +{ + "log": { + "_recordingName": "CarrierAccount Service/routes create URL correctly for UspsShipAccount", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.6" + }, + "entries": [ + { + "_id": "d3d3c93f742161cbb1a1d5db41708eed", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 66, + "cookies": [], + "headers": [ + { + "name": "accept", + "value": "application/json" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "accept-encoding", + "value": "gzip, deflate" + }, + { + "name": "host", + "value": "api.easypost.com" + }, + { + "name": "content-length", + "value": 66 + } + ], + "headersSize": 419, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\"carrier_account_oauth_registrations\":{\"type\":\"UspsShipAccount\"}}" + }, + "queryString": [], + "url": "https://api.easypost.com/v2/carrier_accounts/register_oauth" + }, + "response": { + "bodySize": 2561, + "content": { + "mimeType": "application/json; charset=utf-8", + "size": 2561, + "text": "{\"id\":\"ca_1969e1aca18345b8b1001d704ce446d9\",\"object\":\"CarrierAccount\",\"type\":\"UspsShipAccount\",\"clone\":false,\"created_at\":\"2026-10-15T20:28:16Z\",\"updated_at\":\"2026-10-15T20:28:16Z\",\"description\":null,\"reference\":null,\"billing_type\":\"carrier\",\"readable\":\"Usps Ship\",\"logo\":null,\"fields\":[],\"credentials\":{},\"test_credentials\":{}}" + }, + "cookies": [], + "headers": [ + { + "name": "cache-control", + "value": "private, no-cache, no-store" + }, + { + "name": "content-encoding", + "value": "gzip" + }, + { + "name": "content-type", + "value": "application/json; charset=utf-8" + }, + { + "name": "easypost-api-version", + "value": "2015-01-01" + }, + { + "name": "expires", + "value": "0" + }, + { + "name": "pragma", + "value": "no-cache" + }, + { + "name": "referrer-policy", + "value": "strict-origin-when-cross-origin" + }, + { + "name": "strict-transport-security", + "value": "max-age=31536000; includeSubDomains; preload" + }, + { + "name": "vary", + "value": "EasyPost-Api-Version" + }, + { + "name": "x-backend", + "value": "easypost" + }, + { + "name": "x-content-type-options", + "value": "nosniff" + }, + { + "name": "x-download-options", + "value": "noopen" + }, + { + "name": "x-ep-request-uuid", + "value": "2cb8c6476ad13760e2bc397a0008591a" + }, + { + "name": "x-frame-options", + "value": "SAMEORIGIN" + }, + { + "name": "x-node", + "value": "web116azw" + }, + { + "name": "x-permitted-cross-domain-policies", + "value": "none" + }, + { + "name": "x-proxied", + "value": "intlb1azw f29267e751, extlb2azw ff4cfe6eb5" + }, + { + "name": "x-runtime", + "value": "0.111160" + }, + { + "name": "x-version-label", + "value": "easypost-202610151955-b13716d895-main" + }, + { + "name": "x-xss-protection", + "value": "1; mode=block" + } + ], + "headersSize": 721, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 201, + "statusText": "Created" + }, + "startedDateTime": "2026-10-15T20:28:16.260Z", + "time": 143, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 143 + } + }, + { + "_id": "92b5c765d6a1df2d74479ec0c36bfb76", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 0, + "cookies": [], + "headers": [ + { + "name": "accept", + "value": "application/json" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "accept-encoding", + "value": "gzip, deflate" + }, + { + "name": "host", + "value": "api.easypost.com" + } + ], + "headersSize": 422, + "httpVersion": "HTTP/1.1", + "method": "DELETE", + "queryString": [], + "url": "https://api.easypost.com/v2/carrier_accounts/ca_1969e1aca18345b8b1001d704ce446d9" + }, + "response": { + "bodySize": 2, + "content": { + "mimeType": "application/json; charset=utf-8", + "size": 2, + "text": "{}" + }, + "cookies": [], + "headers": [ + { + "name": "cache-control", + "value": "private, no-cache, no-store" + }, + { + "name": "content-encoding", + "value": "gzip" + }, + { + "name": "content-type", + "value": "application/json; charset=utf-8" + }, + { + "name": "easypost-api-version", + "value": "2015-01-01" + }, + { + "name": "expires", + "value": "0" + }, + { + "name": "pragma", + "value": "no-cache" + }, + { + "name": "referrer-policy", + "value": "strict-origin-when-cross-origin" + }, + { + "name": "strict-transport-security", + "value": "max-age=31536000; includeSubDomains; preload" + }, + { + "name": "vary", + "value": "EasyPost-Api-Version" + }, + { + "name": "x-backend", + "value": "easypost" + }, + { + "name": "x-content-type-options", + "value": "nosniff" + }, + { + "name": "x-download-options", + "value": "noopen" + }, + { + "name": "x-ep-request-uuid", + "value": "2cb8c6476ad13760e2bc397a0008594e" + }, + { + "name": "x-frame-options", + "value": "SAMEORIGIN" + }, + { + "name": "x-node", + "value": "web122azw" + }, + { + "name": "x-permitted-cross-domain-policies", + "value": "none" + }, + { + "name": "x-proxied", + "value": "intlb3azw f29267e751, extlb2azw ff4cfe6eb5" + }, + { + "name": "x-runtime", + "value": "0.083109" + }, + { + "name": "x-version-label", + "value": "easypost-202610151955-b13716d895-main" + }, + { + "name": "x-xss-protection", + "value": "1; mode=block" + } + ], + "headersSize": 721, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2026-10-15T20:28:16.403Z", + "time": 114, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 114 + } + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-VehoWalletAccount_2925149370/recording.har b/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-VehoWalletAccount_2925149370/recording.har new file mode 100644 index 000000000..c801a6708 --- /dev/null +++ b/test/cassettes/CarrierAccount-Service_2076435725/routes-create-URL-correctly-for-VehoWalletAccount_2925149370/recording.har @@ -0,0 +1,305 @@ +{ + "log": { + "_recordingName": "CarrierAccount Service/routes create URL correctly for VehoWalletAccount", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.6" + }, + "entries": [ + { + "_id": "2153cd27979212598e1a68e8ec7e0577", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 71, + "cookies": [], + "headers": [ + { + "name": "accept", + "value": "application/json" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "accept-encoding", + "value": "gzip, deflate" + }, + { + "name": "host", + "value": "api.easypost.com" + }, + { + "name": "content-length", + "value": 71 + } + ], + "headersSize": 409, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\"carrier_account\":{\"type\":\"VehoWalletAccount\",\"registration_data\":{}}}" + }, + "queryString": [], + "url": "https://api.easypost.com/v2/carrier_accounts/open" + }, + "response": { + "bodySize": 583, + "content": { + "mimeType": "application/json; charset=utf-8", + "size": 583, + "text": "{\"id\":\"ca_32b37c6de12546ff9e0ec98bd2b9bf09\",\"object\":\"CarrierAccount\",\"type\":\"VehoWalletAccount\",\"clone\":false,\"created_at\":\"2026-10-15T20:28:15Z\",\"updated_at\":\"2026-10-15T20:28:15Z\",\"description\":\"Veho Account\",\"reference\":null,\"billing_type\":\"easypost\",\"readable\":\"Veho\",\"logo\":null,\"fields\":[],\"credentials\":{},\"test_credentials\":{}}" + }, + "cookies": [], + "headers": [ + { + "name": "cache-control", + "value": "private, no-cache, no-store" + }, + { + "name": "content-encoding", + "value": "gzip" + }, + { + "name": "content-type", + "value": "application/json; charset=utf-8" + }, + { + "name": "easypost-api-version", + "value": "2015-01-01" + }, + { + "name": "expires", + "value": "0" + }, + { + "name": "pragma", + "value": "no-cache" + }, + { + "name": "referrer-policy", + "value": "strict-origin-when-cross-origin" + }, + { + "name": "strict-transport-security", + "value": "max-age=31536000; includeSubDomains; preload" + }, + { + "name": "vary", + "value": "EasyPost-Api-Version" + }, + { + "name": "x-backend", + "value": "easypost" + }, + { + "name": "x-canary", + "value": "direct" + }, + { + "name": "x-content-type-options", + "value": "nosniff" + }, + { + "name": "x-download-options", + "value": "noopen" + }, + { + "name": "x-ep-request-uuid", + "value": "2cb8c6476ad1375fe2bc397a000857f7" + }, + { + "name": "x-frame-options", + "value": "SAMEORIGIN" + }, + { + "name": "x-node", + "value": "web100azw" + }, + { + "name": "x-permitted-cross-domain-policies", + "value": "none" + }, + { + "name": "x-proxied", + "value": "intlb3azw f29267e751, extlb2azw ff4cfe6eb5" + }, + { + "name": "x-runtime", + "value": "0.067505" + }, + { + "name": "x-version-label", + "value": "easypost-202610151955-b13716d895-main" + }, + { + "name": "x-xss-protection", + "value": "1; mode=block" + } + ], + "headersSize": 739, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 201, + "statusText": "Created" + }, + "startedDateTime": "2026-10-15T20:28:15.435Z", + "time": 100, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 100 + } + }, + { + "_id": "f8c95d22ab3ec65e5c5af90dfa371fb9", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 0, + "cookies": [], + "headers": [ + { + "name": "accept", + "value": "application/json" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "accept-encoding", + "value": "gzip, deflate" + }, + { + "name": "host", + "value": "api.easypost.com" + } + ], + "headersSize": 422, + "httpVersion": "HTTP/1.1", + "method": "DELETE", + "queryString": [], + "url": "https://api.easypost.com/v2/carrier_accounts/ca_32b37c6de12546ff9e0ec98bd2b9bf09" + }, + "response": { + "bodySize": 2, + "content": { + "mimeType": "application/json; charset=utf-8", + "size": 2, + "text": "{}" + }, + "cookies": [], + "headers": [ + { + "name": "cache-control", + "value": "private, no-cache, no-store" + }, + { + "name": "content-encoding", + "value": "gzip" + }, + { + "name": "content-type", + "value": "application/json; charset=utf-8" + }, + { + "name": "easypost-api-version", + "value": "2015-01-01" + }, + { + "name": "expires", + "value": "0" + }, + { + "name": "pragma", + "value": "no-cache" + }, + { + "name": "referrer-policy", + "value": "strict-origin-when-cross-origin" + }, + { + "name": "strict-transport-security", + "value": "max-age=31536000; includeSubDomains; preload" + }, + { + "name": "vary", + "value": "EasyPost-Api-Version" + }, + { + "name": "x-backend", + "value": "easypost" + }, + { + "name": "x-content-type-options", + "value": "nosniff" + }, + { + "name": "x-download-options", + "value": "noopen" + }, + { + "name": "x-ep-request-uuid", + "value": "2cb8c6476ad1375fe2bc397a0008580f" + }, + { + "name": "x-frame-options", + "value": "SAMEORIGIN" + }, + { + "name": "x-node", + "value": "web103azw" + }, + { + "name": "x-permitted-cross-domain-policies", + "value": "none" + }, + { + "name": "x-proxied", + "value": "intlb3azw f29267e751, extlb2azw ff4cfe6eb5" + }, + { + "name": "x-runtime", + "value": "0.068074" + }, + { + "name": "x-version-label", + "value": "easypost-202610151955-b13716d895-main" + }, + { + "name": "x-xss-protection", + "value": "1; mode=block" + } + ], + "headersSize": 721, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2026-10-15T20:28:15.535Z", + "time": 102, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 102 + } + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/test/services/carrier_account.test.ts b/test/services/carrier_account.test.ts index ce31442d2..d19e33875 100644 --- a/test/services/carrier_account.test.ts +++ b/test/services/carrier_account.test.ts @@ -1,7 +1,9 @@ /* eslint-disable no-param-reassign */ import { expect } from 'vitest'; +import Constants from '../../src/constants'; import EasyPostClient from '../../src/easypost'; +import ApiError from '../../src/errors/api/api_error'; import CarrierAccount from '../../src/models/carrier_account'; import type CarrierAccountServiceFactory from '../../src/services/carrier_account_service'; import Fixture from '../helpers/fixture'; @@ -10,6 +12,20 @@ import { withoutParams } from '../helpers/utils'; type CarrierAccountTestCreateInput = Parameters['create']>[0]; +function flattenCustomCarrierRouteMapping() { + return Object.entries(Constants.CARRIER_ACCOUNT_CREATE_ENDPOINT_TYPES).flatMap(([endpoint, carrierAccountTypes]) => + carrierAccountTypes.map((carrierAccountType) => [carrierAccountType, endpoint] as const), + ); +} + +function carrierCreatePayloadForEndpoint(endpoint: string): Record { + if (endpoint === 'carrier_accounts/open' || endpoint === 'carrier_accounts/register') { + return { registration_data: {} }; + } + + return {}; +} + /* eslint-disable func-names */ describe('CarrierAccount Service', function () { const getPolly = setupPolly.setupPollyTests(); @@ -37,37 +53,43 @@ describe('CarrierAccount Service', function () { await client.CarrierAccount.delete(carrierAccount.id); }); - it('creates a UPS carrier account', async function () { - const accountNumber = '123456789'; - const type = 'UpsAccount'; - - const data = { - type: type, - account_number: accountNumber, - }; - - const carrierAccount = await client.CarrierAccount.create(data); - - expect(carrierAccount).to.be.an.instanceOf(CarrierAccount); - expect(carrierAccount.id).to.match(/^ca_/); - expect(carrierAccount.type).to.equal(type); - - await client.CarrierAccount.delete(carrierAccount.id); - }); - - it('creates an Amazon carrier account', async function () { - const type = 'AmazonShippingAccount'; - - const data = { type: type }; - - const carrierAccount = await client.CarrierAccount.create(data); - - expect(carrierAccount).to.be.an.instanceOf(CarrierAccount); - expect(carrierAccount.id).to.match(/^ca_/); - expect(carrierAccount.type).to.equal(type); - - await client.CarrierAccount.delete(carrierAccount.id); - }); + for (const [carrierAccountType, expectedEndpoint] of flattenCustomCarrierRouteMapping()) { + it(`routes create URL correctly for ${carrierAccountType}`, async function () { + const payload = { + type: carrierAccountType, + ...carrierCreatePayloadForEndpoint(expectedEndpoint), + }; + const capturedRequest: { path?: string; requestBody?: unknown } = {}; + + const captureRequestHook = ({ path, requestBody }: { path: string; requestBody: unknown }) => { + if (!capturedRequest.path && path.includes('/carrier_accounts')) { + capturedRequest.path = path; + capturedRequest.requestBody = requestBody; + } + }; + + client.addRequestHook(captureRequestHook); + try { + const carrierAccount = await client.CarrierAccount.create(payload); + expect(carrierAccount).to.be.an.instanceOf(CarrierAccount); + expect(carrierAccount.id).to.match(/^ca_/); + await client.CarrierAccount.delete(carrierAccount.id); + } catch (error: unknown) { + expect(error).to.be.an.instanceOf(ApiError); + expect((error as ApiError).statusCode).to.not.be.oneOf([404, 500]); + } finally { + client.removeRequestHook(captureRequestHook); + } + + expect(capturedRequest.path).to.include(`/${expectedEndpoint}`); + const requestBody = capturedRequest.requestBody as Record; + if (expectedEndpoint === 'carrier_accounts/register_oauth') { + expect(requestBody).to.have.property('carrier_account_oauth_registrations'); + } else { + expect(requestBody).to.have.property('carrier_account'); + } + }); + } it('retrieves a carrier account', async function () { const carrierAccount = await client.CarrierAccount.create( @@ -112,29 +134,6 @@ describe('CarrierAccount Service', function () { await client.CarrierAccount.delete(carrierAccount.id); }); - it('updates a UPS carrier account', async function () { - const params = { - type: 'UpsAccount', - account_number: '123456789', - }; - const carrierAccount = await client.CarrierAccount.create(params); - - const testAccountNumber = '987654321'; - const updateParams = { - account_number: testAccountNumber, - }; - - await client.CarrierAccount.update(carrierAccount.id, updateParams); - - const updatedCarrierAccount = await client.CarrierAccount.retrieve(carrierAccount.id); - - expect(updatedCarrierAccount).to.be.an.instanceOf(CarrierAccount); - expect(updatedCarrierAccount.id).to.match(/^ca_/); - - // Remove the carrier account once we have tested it so we don't pollute the account with test accounts - await client.CarrierAccount.delete(carrierAccount.id); - }); - it('deletes a carrier account', async function () { const carrierAccount = await client.CarrierAccount.create( Fixture.basicCarrierAccount() as CarrierAccountTestCreateInput, From 8dcf6dce4c10ca3a48bd9ae3b22ccebe1afaa25d Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Thu, 15 Oct 2026 14:58:45 -0600 Subject: [PATCH 2/2] chore: remove obsolete UPS update cassette Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../recording.har | 588 ------------------ 1 file changed, 588 deletions(-) delete mode 100644 test/cassettes/CarrierAccount-Service_2076435725/updates-a-UPS-carrier-account_2425174955/recording.har diff --git a/test/cassettes/CarrierAccount-Service_2076435725/updates-a-UPS-carrier-account_2425174955/recording.har b/test/cassettes/CarrierAccount-Service_2076435725/updates-a-UPS-carrier-account_2425174955/recording.har deleted file mode 100644 index cf193c430..000000000 --- a/test/cassettes/CarrierAccount-Service_2076435725/updates-a-UPS-carrier-account_2425174955/recording.har +++ /dev/null @@ -1,588 +0,0 @@ -{ - "log": { - "_recordingName": "CarrierAccount Service/updates a UPS carrier account", - "creator": { - "comment": "persister:fs", - "name": "Polly.JS", - "version": "6.0.6" - }, - "entries": [ - { - "_id": "51110e81f98cbbcf36e02d92b319e601", - "_order": 0, - "cache": {}, - "request": { - "bodySize": 90, - "cookies": [], - "headers": [ - { - "name": "accept", - "value": "application/json" - }, - { - "name": "content-type", - "value": "application/json" - }, - { - "name": "accept-encoding", - "value": "gzip, deflate" - }, - { - "name": "host", - "value": "api.easypost.com" - }, - { - "name": "content-length", - "value": 90 - } - ], - "headersSize": 413, - "httpVersion": "HTTP/1.1", - "method": "POST", - "postData": { - "mimeType": "application/json", - "params": [], - "text": "{\"carrier_account_oauth_registrations\":{\"type\":\"UpsAccount\",\"account_number\":\"123456789\"}}" - }, - "queryString": [], - "url": "https://api.easypost.com/v2/carrier_accounts/register_oauth" - }, - "response": { - "bodySize": 1762, - "content": { - "mimeType": "application/json; charset=utf-8", - "size": 1762, - "text": "{\"id\":\"ca_776fcfc95458489d96baa7fea109f558\",\"object\":\"CarrierAccount\",\"type\":\"UpsAccount\",\"clone\":false,\"created_at\":\"2026-07-30T17:37:56Z\",\"updated_at\":\"2026-07-30T17:37:56Z\",\"description\":null,\"reference\":null,\"billing_type\":\"carrier\",\"readable\":\"UPS\",\"logo\":null,\"fields\":[],\"credentials\":{},\"test_credentials\":null}" - }, - "cookies": [], - "headers": [ - { - "name": "cache-control", - "value": "private, no-cache, no-store" - }, - { - "name": "content-encoding", - "value": "gzip" - }, - { - "name": "content-type", - "value": "application/json; charset=utf-8" - }, - { - "name": "easypost-api-version", - "value": "2015-01-01" - }, - { - "name": "expires", - "value": "0" - }, - { - "name": "pragma", - "value": "no-cache" - }, - { - "name": "referrer-policy", - "value": "strict-origin-when-cross-origin" - }, - { - "name": "strict-transport-security", - "value": "max-age=31536000; includeSubDomains; preload" - }, - { - "name": "vary", - "value": "EasyPost-Api-Version" - }, - { - "name": "x-backend", - "value": "easypost" - }, - { - "name": "x-content-type-options", - "value": "nosniff" - }, - { - "name": "x-download-options", - "value": "noopen" - }, - { - "name": "x-ep-request-uuid", - "value": "d6c23b776a6b8bf4e0e306b603f2aae8" - }, - { - "name": "x-frame-options", - "value": "SAMEORIGIN" - }, - { - "name": "x-node", - "value": "bigweb57nuq" - }, - { - "name": "x-permitted-cross-domain-policies", - "value": "none" - }, - { - "name": "x-proxied", - "value": "intlb4nuq 1bff4a8790, extlb1nuq e8c67c6320" - }, - { - "name": "x-runtime", - "value": "0.094913" - }, - { - "name": "x-version-label", - "value": "easypost-202607300115-be0cf87c94-main" - }, - { - "name": "x-xss-protection", - "value": "1; mode=block" - } - ], - "headersSize": 723, - "httpVersion": "HTTP/1.1", - "redirectURL": "", - "status": 201, - "statusText": "Created" - }, - "startedDateTime": "2026-07-30T17:37:56.030Z", - "time": 206, - "timings": { - "blocked": -1, - "connect": -1, - "dns": -1, - "receive": 0, - "send": 0, - "ssl": -1, - "wait": 206 - } - }, - { - "_id": "7224ecb1b357209ccae85202ef0f076e", - "_order": 0, - "cache": {}, - "request": { - "bodySize": 50, - "cookies": [], - "headers": [ - { - "name": "accept", - "value": "application/json" - }, - { - "name": "content-type", - "value": "application/json" - }, - { - "name": "accept-encoding", - "value": "gzip, deflate" - }, - { - "name": "host", - "value": "api.easypost.com" - }, - { - "name": "content-length", - "value": 50 - } - ], - "headersSize": 435, - "httpVersion": "HTTP/1.1", - "method": "PATCH", - "postData": { - "mimeType": "application/json", - "params": [], - "text": "{\"carrier_account\":{\"account_number\":\"987654321\"}}" - }, - "queryString": [], - "url": "https://api.easypost.com/v2/carrier_accounts/ca_776fcfc95458489d96baa7fea109f558" - }, - "response": { - "bodySize": 1762, - "content": { - "mimeType": "application/json; charset=utf-8", - "size": 1762, - "text": "{\"id\":\"ca_776fcfc95458489d96baa7fea109f558\",\"object\":\"CarrierAccount\",\"type\":\"UpsAccount\",\"clone\":false,\"created_at\":\"2026-07-30T17:37:56Z\",\"updated_at\":\"2026-07-30T17:37:56Z\",\"description\":null,\"reference\":null,\"billing_type\":\"carrier\",\"readable\":\"UPS\",\"logo\":null,\"fields\":[],\"credentials\":{},\"test_credentials\":null}" - }, - "cookies": [], - "headers": [ - { - "name": "cache-control", - "value": "private, no-cache, no-store" - }, - { - "name": "content-encoding", - "value": "gzip" - }, - { - "name": "content-type", - "value": "application/json; charset=utf-8" - }, - { - "name": "easypost-api-version", - "value": "2015-01-01" - }, - { - "name": "expires", - "value": "0" - }, - { - "name": "pragma", - "value": "no-cache" - }, - { - "name": "referrer-policy", - "value": "strict-origin-when-cross-origin" - }, - { - "name": "strict-transport-security", - "value": "max-age=31536000; includeSubDomains; preload" - }, - { - "name": "vary", - "value": "EasyPost-Api-Version" - }, - { - "name": "x-backend", - "value": "easypost" - }, - { - "name": "x-content-type-options", - "value": "nosniff" - }, - { - "name": "x-download-options", - "value": "noopen" - }, - { - "name": "x-ep-request-uuid", - "value": "d6c23b776a6b8bf4e0e306b603f2ab4a" - }, - { - "name": "x-frame-options", - "value": "SAMEORIGIN" - }, - { - "name": "x-node", - "value": "bigweb36nuq" - }, - { - "name": "x-permitted-cross-domain-policies", - "value": "none" - }, - { - "name": "x-proxied", - "value": "intlb4nuq 1bff4a8790, extlb1nuq e8c67c6320" - }, - { - "name": "x-runtime", - "value": "0.073206" - }, - { - "name": "x-version-label", - "value": "easypost-202607300115-be0cf87c94-main" - }, - { - "name": "x-xss-protection", - "value": "1; mode=block" - } - ], - "headersSize": 723, - "httpVersion": "HTTP/1.1", - "redirectURL": "", - "status": 200, - "statusText": "OK" - }, - "startedDateTime": "2026-07-30T17:37:56.237Z", - "time": 199, - "timings": { - "blocked": -1, - "connect": -1, - "dns": -1, - "receive": 0, - "send": 0, - "ssl": -1, - "wait": 199 - } - }, - { - "_id": "e3931ec30ad39ea600f81b799560b2e7", - "_order": 0, - "cache": {}, - "request": { - "bodySize": 0, - "cookies": [], - "headers": [ - { - "name": "accept", - "value": "application/json" - }, - { - "name": "content-type", - "value": "application/json" - }, - { - "name": "accept-encoding", - "value": "gzip, deflate" - }, - { - "name": "host", - "value": "api.easypost.com" - } - ], - "headersSize": 413, - "httpVersion": "HTTP/1.1", - "method": "GET", - "queryString": [], - "url": "https://api.easypost.com/v2/carrier_accounts/ca_776fcfc95458489d96baa7fea109f558" - }, - "response": { - "bodySize": 1762, - "content": { - "mimeType": "application/json; charset=utf-8", - "size": 1762, - "text": "{\"id\":\"ca_776fcfc95458489d96baa7fea109f558\",\"object\":\"CarrierAccount\",\"type\":\"UpsAccount\",\"clone\":false,\"created_at\":\"2026-07-30T17:37:56Z\",\"updated_at\":\"2026-07-30T17:37:56Z\",\"description\":null,\"reference\":null,\"billing_type\":\"carrier\",\"readable\":\"UPS\",\"logo\":null,\"fields\":[],\"credentials\":{},\"test_credentials\":null}" - }, - "cookies": [], - "headers": [ - { - "name": "cache-control", - "value": "private, no-cache, no-store" - }, - { - "name": "content-encoding", - "value": "gzip" - }, - { - "name": "content-type", - "value": "application/json; charset=utf-8" - }, - { - "name": "easypost-api-version", - "value": "2015-01-01" - }, - { - "name": "expires", - "value": "0" - }, - { - "name": "pragma", - "value": "no-cache" - }, - { - "name": "referrer-policy", - "value": "strict-origin-when-cross-origin" - }, - { - "name": "strict-transport-security", - "value": "max-age=31536000; includeSubDomains; preload" - }, - { - "name": "vary", - "value": "EasyPost-Api-Version" - }, - { - "name": "x-backend", - "value": "easypost" - }, - { - "name": "x-content-type-options", - "value": "nosniff" - }, - { - "name": "x-download-options", - "value": "noopen" - }, - { - "name": "x-ep-request-uuid", - "value": "d6c23b776a6b8bf4e0e306b603f2ab8a" - }, - { - "name": "x-frame-options", - "value": "SAMEORIGIN" - }, - { - "name": "x-node", - "value": "bigweb36nuq" - }, - { - "name": "x-permitted-cross-domain-policies", - "value": "none" - }, - { - "name": "x-proxied", - "value": "intlb4nuq 1bff4a8790, extlb1nuq e8c67c6320" - }, - { - "name": "x-runtime", - "value": "0.030850" - }, - { - "name": "x-version-label", - "value": "easypost-202607300115-be0cf87c94-main" - }, - { - "name": "x-xss-protection", - "value": "1; mode=block" - } - ], - "headersSize": 723, - "httpVersion": "HTTP/1.1", - "redirectURL": "", - "status": 200, - "statusText": "OK" - }, - "startedDateTime": "2026-07-30T17:37:56.437Z", - "time": 138, - "timings": { - "blocked": -1, - "connect": -1, - "dns": -1, - "receive": 0, - "send": 0, - "ssl": -1, - "wait": 138 - } - }, - { - "_id": "0e35c4ee557df995ae8594ad0ef6bf92", - "_order": 0, - "cache": {}, - "request": { - "bodySize": 0, - "cookies": [], - "headers": [ - { - "name": "accept", - "value": "application/json" - }, - { - "name": "content-type", - "value": "application/json" - }, - { - "name": "accept-encoding", - "value": "gzip, deflate" - }, - { - "name": "host", - "value": "api.easypost.com" - } - ], - "headersSize": 416, - "httpVersion": "HTTP/1.1", - "method": "DELETE", - "queryString": [], - "url": "https://api.easypost.com/v2/carrier_accounts/ca_776fcfc95458489d96baa7fea109f558" - }, - "response": { - "bodySize": 2, - "content": { - "mimeType": "application/json; charset=utf-8", - "size": 2, - "text": "{}" - }, - "cookies": [], - "headers": [ - { - "name": "cache-control", - "value": "private, no-cache, no-store" - }, - { - "name": "content-encoding", - "value": "gzip" - }, - { - "name": "content-type", - "value": "application/json; charset=utf-8" - }, - { - "name": "easypost-api-version", - "value": "2015-01-01" - }, - { - "name": "expires", - "value": "0" - }, - { - "name": "pragma", - "value": "no-cache" - }, - { - "name": "referrer-policy", - "value": "strict-origin-when-cross-origin" - }, - { - "name": "strict-transport-security", - "value": "max-age=31536000; includeSubDomains; preload" - }, - { - "name": "vary", - "value": "EasyPost-Api-Version" - }, - { - "name": "x-backend", - "value": "easypost" - }, - { - "name": "x-content-type-options", - "value": "nosniff" - }, - { - "name": "x-download-options", - "value": "noopen" - }, - { - "name": "x-ep-request-uuid", - "value": "d6c23b776a6b8bf4e0e306b603f2abd1" - }, - { - "name": "x-frame-options", - "value": "SAMEORIGIN" - }, - { - "name": "x-node", - "value": "bigweb39nuq" - }, - { - "name": "x-permitted-cross-domain-policies", - "value": "none" - }, - { - "name": "x-proxied", - "value": "intlb6nuq 1bff4a8790, extlb1nuq e8c67c6320" - }, - { - "name": "x-runtime", - "value": "0.073023" - }, - { - "name": "x-version-label", - "value": "easypost-202607300115-be0cf87c94-main" - }, - { - "name": "x-xss-protection", - "value": "1; mode=block" - } - ], - "headersSize": 723, - "httpVersion": "HTTP/1.1", - "redirectURL": "", - "status": 200, - "statusText": "OK" - }, - "startedDateTime": "2026-07-30T17:37:56.575Z", - "time": 200, - "timings": { - "blocked": -1, - "connect": -1, - "dns": -1, - "receive": 0, - "send": 0, - "ssl": -1, - "wait": 200 - } - } - ], - "pages": [], - "version": "1.2" - } -}