From 687226f7c05f5c4ce7340913039a480b4882453c Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Fri, 23 May 2025 13:35:05 -0600 Subject: [PATCH 1/3] fix: endpoint used for ups create/update --- CHANGELOG.md | 4 + composer.json | 2 +- lib/EasyPost/Constant/Constants.php | 9 +- .../Service/CarrierAccountService.php | 21 +- .../cassettes/carrier_accounts/create_ups.yml | 110 ++++---- .../cassettes/carrier_accounts/update_ups.yml | 234 ++++++------------ 6 files changed, 151 insertions(+), 229 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3279e0ca..aa9588a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## v8.0.1 (2025-05-27) + +- Corrects the endpoint used for creating/updating UPS accounts + ## v8.0.0 (2025-04-28) See our [Upgrade Guide](UPGRADE_GUIDE.md#upgrading-from-7x-to-80) for more details. diff --git a/composer.json b/composer.json index b23829e5..132e7451 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "easypost/easypost-php", "description": "EasyPost Shipping API Client Library for PHP", - "version": "8.0.0", + "version": "8.0.1", "keywords": [ "shipping", "api", diff --git a/lib/EasyPost/Constant/Constants.php b/lib/EasyPost/Constant/Constants.php index 231e60e2..a2bed2b9 100644 --- a/lib/EasyPost/Constant/Constants.php +++ b/lib/EasyPost/Constant/Constants.php @@ -11,7 +11,7 @@ abstract class Constants const BETA_API_VERSION = 'beta'; // Library constants - const LIBRARY_VERSION = '8.0.0'; + const LIBRARY_VERSION = '8.0.1'; const SUPPORT_EMAIL = 'support@easypost.com'; // Validation @@ -20,16 +20,13 @@ abstract class Constants 'FedexSmartpostAccount' ]; - const UPS_OAUTH_ACCOUNT_TYPES = [ + const CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH = [ + 'AmazonShippingAccount', 'UpsAccount', 'UpsMailInnovationsAccount', 'UpsSurepostAccount' ]; - const CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH = [ - 'AmazonShippingAccount', - ]; - // Exception messages (many of these are intended to be used with `sprintf()`) const ARRAY_REQUIRED_ERROR = 'You must pass an array as the first argument to EasyPost API method calls.'; const COMMUNICATION_ERROR = 'Unexpected error communicating with %s. If this problem persists please let us know at ' . self::SUPPORT_EMAIL . '. %s'; // phpcs:ignore diff --git a/lib/EasyPost/Service/CarrierAccountService.php b/lib/EasyPost/Service/CarrierAccountService.php index 2ee91225..6483585a 100644 --- a/lib/EasyPost/Service/CarrierAccountService.php +++ b/lib/EasyPost/Service/CarrierAccountService.php @@ -43,16 +43,13 @@ public function all(mixed $params = null): mixed */ public function update(string $id, mixed $params): mixed { - $carrierAccount = self::retrieve($id); - $carrierAccountType = $carrierAccount['type']; - if (in_array($carrierAccountType, Constants::UPS_OAUTH_ACCOUNT_TYPES, true)) { - $className = 'UpsOauthRegistration'; - $params = [self::selectTopLayerKey($carrierAccountType) => $params]; - } else { - $className = 'CarrierAccount'; - $params = [self::selectTopLayerKey($carrierAccountType) => $params]; + if (!isset($params['carrier_account']) || !is_array($params['carrier_account'])) { + $clone = $params; + unset($params); + $params['carrier_account'] = $clone; } - return self::updateResource($className, $id, $params); + + return self::updateResource(self::serviceModelClassName(self::class), $id, $params); } /** @@ -111,8 +108,6 @@ private function selectCarrierAccountCreationEndpoint(string $carrierAccountType { if (in_array($carrierAccountType, Constants::CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_WORKFLOWS, true)) { return '/carrier_accounts/register'; - } else if (in_array($carrierAccountType, Constants::UPS_OAUTH_ACCOUNT_TYPES, true)) { - return '/ups_oauth_registrations'; } else if (in_array($carrierAccountType, Constants::CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH, true)) { return '/carrier_accounts/register_oauth'; } @@ -128,9 +123,7 @@ private function selectCarrierAccountCreationEndpoint(string $carrierAccountType */ private function selectTopLayerKey(string $carrierAccountType): string { - if (in_array($carrierAccountType, Constants::UPS_OAUTH_ACCOUNT_TYPES, true)) { - return 'ups_oauth_registrations'; - } else if (in_array($carrierAccountType, Constants::CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH, true)) { + if (in_array($carrierAccountType, Constants::CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH, true)) { return 'carrier_account_oauth_registrations'; } else { return 'carrier_account'; diff --git a/test/cassettes/carrier_accounts/create_ups.yml b/test/cassettes/carrier_accounts/create_ups.yml index 5849214c..c635c8a7 100644 --- a/test/cassettes/carrier_accounts/create_ups.yml +++ b/test/cassettes/carrier_accounts/create_ups.yml @@ -2,7 +2,7 @@ - request: method: POST - url: 'https://api.easypost.com/v2/ups_oauth_registrations' + url: 'https://api.easypost.com/v2/carrier_accounts/register_oauth' headers: Host: api.easypost.com Expect: '' @@ -11,7 +11,7 @@ Authorization: '' Content-Type: application/json User-Agent: '' - body: '{"ups_oauth_registrations":{"type":"UpsAccount","account_number":"123456789"}}' + body: '{"carrier_account_oauth_registrations":{"type":"UpsAccount","account_number":"123456789"}}' response: status: code: 201 @@ -23,57 +23,58 @@ x-download-options: noopen x-permitted-cross-domain-policies: none referrer-policy: strict-origin-when-cross-origin - x-ep-request-uuid: e181587866bcebfee2b8ffd60086fbfd + x-ep-request-uuid: 6be4a8f16830cc36e787445b0042f39b cache-control: 'private, no-cache, no-store' pragma: no-cache expires: '0' content-type: 'application/json; charset=utf-8' - content-length: '1388' - x-runtime: '0.088214' - x-node: bigweb41nuq - x-version-label: easypost-202408141633-8ef9a7bcc9-master + content-length: '1392' + x-runtime: '0.089284' + x-node: bigweb53nuq + x-version-label: easypost-202505231841-d89645a184-master x-backend: easypost - x-proxied: ['intlb3nuq c0f5e722d1', 'extlb2nuq b6e1b5034c'] + x-proxied: ['intlb4nuq 668d3fc830', 'extlb1nuq 99aac35317'] strict-transport-security: 'max-age=31536000; includeSubDomains; preload' - body: '{"id":"ca_b1968143bc0843c681bdf9022fa56c01","object":"CarrierAccount","type":"UpsAccount","clone":false,"created_at":"2024-08-14T17:40:14Z","updated_at":"2024-08-14T17:40:14Z","description":null,"reference":null,"billing_type":"carrier","readable":"UPS","logo":null,"fields":[],"credentials":[],"test_credentials":[]}' + body: '{"id":"ca_50a298c915b64a3d858293e6d545720c","object":"CarrierAccount","type":"UpsAccount","clone":false,"created_at":"2025-05-23T19:27:50Z","updated_at":"2025-05-23T19:27:50Z","description":null,"reference":null,"billing_type":"carrier","readable":"UPS","logo":null,"fields":[],"credentials":[],"test_credentials":[]}' curl_info: - url: 'https://api.easypost.com/v2/ups_oauth_registrations' + url: 'https://api.easypost.com/v2/carrier_accounts/register_oauth' content_type: 'application/json; charset=utf-8' http_code: 201 header_size: 694 - request_size: 399 + request_size: 418 filetime: -1 ssl_verify_result: 0 redirect_count: 0 - total_time: 0.184623 - namelookup_time: 0.002278 - connect_time: 0.031561 - pretransfer_time: 0.063377 - size_upload: 78.0 - size_download: 1388.0 - speed_download: 7518.0 - speed_upload: 422.0 - download_content_length: 1388.0 - upload_content_length: 78.0 - starttransfer_time: 0.184586 + total_time: 0.295775 + namelookup_time: 0.001682 + connect_time: 0.068252 + pretransfer_time: 0.136525 + size_upload: 90.0 + size_download: 1392.0 + speed_download: 4706.0 + speed_upload: 304.0 + download_content_length: 1392.0 + upload_content_length: 90.0 + starttransfer_time: 0.295723 redirect_time: 0.0 redirect_url: '' - primary_ip: 169.62.110.130 + primary_ip: 169.62.110.131 certinfo: { } primary_port: 443 - local_ip: 192.168.1.75 - local_port: 52753 + local_ip: 10.130.6.32 + local_port: 51512 http_version: 2 protocol: 2 ssl_verifyresult: 0 scheme: https - appconnect_time_us: 63323 - connect_time_us: 31561 - namelookup_time_us: 2278 - pretransfer_time_us: 63377 + appconnect_time_us: 136490 + connect_time_us: 68252 + namelookup_time_us: 1682 + pretransfer_time_us: 136525 redirect_time_us: 0 - starttransfer_time_us: 184586 - total_time_us: 184623 + starttransfer_time_us: 295723 + posttransfer_time_us: 136524 + total_time_us: 295775 effective_method: POST capath: '' cainfo: '' @@ -81,7 +82,7 @@ - request: method: DELETE - url: 'https://api.easypost.com/v2/carrier_accounts/ca_b1968143bc0843c681bdf9022fa56c01' + url: 'https://api.easypost.com/v2/carrier_accounts/ca_50a298c915b64a3d858293e6d545720c' headers: Host: api.easypost.com Accept-Encoding: '' @@ -100,57 +101,58 @@ x-download-options: noopen x-permitted-cross-domain-policies: none referrer-policy: strict-origin-when-cross-origin - x-ep-request-uuid: e181587666bcebfee2b8ffd70086fc39 + x-ep-request-uuid: 6be4a8f36830cc36e787445c0042f431 cache-control: 'private, no-cache, no-store' pragma: no-cache expires: '0' content-type: 'application/json; charset=utf-8' content-length: '2' - x-runtime: '0.063497' - x-node: bigweb36nuq - x-version-label: easypost-202408141633-8ef9a7bcc9-master + x-runtime: '0.069504' + x-node: bigweb40nuq + x-version-label: easypost-202505231841-d89645a184-master x-backend: easypost - x-proxied: ['intlb3nuq c0f5e722d1', 'extlb2nuq b6e1b5034c'] + x-proxied: ['intlb3nuq 668d3fc830', 'extlb1nuq 99aac35317'] strict-transport-security: 'max-age=31536000; includeSubDomains; preload' body: '[]' curl_info: - url: 'https://api.easypost.com/v2/carrier_accounts/ca_b1968143bc0843c681bdf9022fa56c01' + url: 'https://api.easypost.com/v2/carrier_accounts/ca_50a298c915b64a3d858293e6d545720c' content_type: 'application/json; charset=utf-8' http_code: 200 header_size: 686 - request_size: 332 + request_size: 331 filetime: -1 ssl_verify_result: 0 redirect_count: 0 - total_time: 0.159146 - namelookup_time: 0.001444 - connect_time: 0.030851 - pretransfer_time: 0.062969 + total_time: 0.273879 + namelookup_time: 0.002253 + connect_time: 0.067789 + pretransfer_time: 0.136042 size_upload: 0.0 size_download: 2.0 - speed_download: 12.0 + speed_download: 7.0 speed_upload: 0.0 download_content_length: 2.0 upload_content_length: 0.0 - starttransfer_time: 0.159113 + starttransfer_time: 0.273794 redirect_time: 0.0 redirect_url: '' - primary_ip: 169.62.110.130 + primary_ip: 169.62.110.131 certinfo: { } primary_port: 443 - local_ip: 192.168.1.75 - local_port: 52754 + local_ip: 10.130.6.32 + local_port: 51513 http_version: 2 protocol: 2 ssl_verifyresult: 0 scheme: https - appconnect_time_us: 62921 - connect_time_us: 30851 - namelookup_time_us: 1444 - pretransfer_time_us: 62969 + appconnect_time_us: 135989 + connect_time_us: 67789 + namelookup_time_us: 2253 + pretransfer_time_us: 136042 redirect_time_us: 0 - starttransfer_time_us: 159113 - total_time_us: 159146 + starttransfer_time_us: 273794 + posttransfer_time_us: 136077 + total_time_us: 273879 effective_method: DELETE capath: '' cainfo: '' diff --git a/test/cassettes/carrier_accounts/update_ups.yml b/test/cassettes/carrier_accounts/update_ups.yml index e5a50da6..70d7a291 100644 --- a/test/cassettes/carrier_accounts/update_ups.yml +++ b/test/cassettes/carrier_accounts/update_ups.yml @@ -2,7 +2,7 @@ - request: method: POST - url: 'https://api.easypost.com/v2/ups_oauth_registrations' + url: 'https://api.easypost.com/v2/carrier_accounts/register_oauth' headers: Host: api.easypost.com Expect: '' @@ -11,7 +11,7 @@ Authorization: '' Content-Type: application/json User-Agent: '' - body: '{"ups_oauth_registrations":{"type":"UpsAccount","account_number":"123456789"}}' + body: '{"carrier_account_oauth_registrations":{"type":"UpsAccount","account_number":"123456789"}}' response: status: code: 201 @@ -23,72 +23,75 @@ x-download-options: noopen x-permitted-cross-domain-policies: none referrer-policy: strict-origin-when-cross-origin - x-ep-request-uuid: e181587d66bcebffe2b8fff40086fd9d + x-ep-request-uuid: 6ae239366830cdb8e7874543008db232 cache-control: 'private, no-cache, no-store' pragma: no-cache expires: '0' content-type: 'application/json; charset=utf-8' content-length: '1420' - x-runtime: '0.239964' - x-node: bigweb34nuq - x-version-label: easypost-202408141633-8ef9a7bcc9-master + x-runtime: '0.091240' + x-node: bigweb41nuq + x-version-label: easypost-202505231841-d89645a184-master x-backend: easypost - x-proxied: ['intlb3nuq c0f5e722d1', 'extlb2nuq b6e1b5034c'] + x-proxied: ['intlb3nuq 668d3fc830', 'extlb2nuq 99aac35317'] strict-transport-security: 'max-age=31536000; includeSubDomains; preload' - body: '{"id":"ca_b67dad1962d94759b9d47c31a3c245cd","object":"CarrierAccount","type":"UpsAccount","clone":false,"created_at":"2024-08-14T17:40:15Z","updated_at":"2024-08-14T17:40:15Z","description":null,"reference":null,"billing_type":"carrier","readable":"UPS","logo":null,"fields":[],"credentials":[],"test_credentials":[]}' + body: '{"id":"ca_06c594e584bc423e887fd9f130b485d8","object":"CarrierAccount","type":"UpsAccount","clone":false,"created_at":"2025-05-23T19:34:16Z","updated_at":"2025-05-23T19:34:16Z","description":null,"reference":null,"billing_type":"carrier","readable":"UPS","logo":null,"fields":[],"credentials":[],"test_credentials":[]}' curl_info: - url: 'https://api.easypost.com/v2/ups_oauth_registrations' + url: 'https://api.easypost.com/v2/carrier_accounts/register_oauth' content_type: 'application/json; charset=utf-8' http_code: 201 header_size: 694 - request_size: 399 + request_size: 418 filetime: -1 ssl_verify_result: 0 redirect_count: 0 - total_time: 0.348442 - namelookup_time: 0.002537 - connect_time: 0.034826 - pretransfer_time: 0.072128 - size_upload: 78.0 + total_time: 0.303049 + namelookup_time: 0.003562 + connect_time: 0.071055 + pretransfer_time: 0.140912 + size_upload: 90.0 size_download: 1420.0 - speed_download: 4075.0 - speed_upload: 223.0 + speed_download: 4685.0 + speed_upload: 296.0 download_content_length: 1420.0 - upload_content_length: 78.0 - starttransfer_time: 0.348371 + upload_content_length: 90.0 + starttransfer_time: 0.303017 redirect_time: 0.0 redirect_url: '' primary_ip: 169.62.110.130 certinfo: { } primary_port: 443 - local_ip: 192.168.1.75 - local_port: 52760 + local_ip: 10.130.6.32 + local_port: 51583 http_version: 2 protocol: 2 ssl_verifyresult: 0 scheme: https - appconnect_time_us: 72046 - connect_time_us: 34826 - namelookup_time_us: 2537 - pretransfer_time_us: 72128 + appconnect_time_us: 140871 + connect_time_us: 71055 + namelookup_time_us: 3562 + pretransfer_time_us: 140912 redirect_time_us: 0 - starttransfer_time_us: 348371 - total_time_us: 348442 + starttransfer_time_us: 303017 + posttransfer_time_us: 140912 + total_time_us: 303049 effective_method: POST capath: '' cainfo: '' index: 0 - request: - method: GET - url: 'https://api.easypost.com/v2/carrier_accounts/ca_b67dad1962d94759b9d47c31a3c245cd' + method: PATCH + url: 'https://api.easypost.com/v2/carrier_accounts/ca_06c594e584bc423e887fd9f130b485d8' headers: Host: api.easypost.com + Expect: '' Accept-Encoding: '' Accept: application/json Authorization: '' Content-Type: application/json User-Agent: '' + body: '{"carrier_account":{"account_number":"987654321"}}' response: status: code: 200 @@ -100,136 +103,58 @@ x-download-options: noopen x-permitted-cross-domain-policies: none referrer-policy: strict-origin-when-cross-origin - x-ep-request-uuid: e181587d66bcebffe2b8fff50086fe0f + x-ep-request-uuid: 6ae239376830cdb8e7874544008db287 cache-control: 'private, no-cache, no-store' pragma: no-cache expires: '0' content-type: 'application/json; charset=utf-8' content-length: '1420' - x-runtime: '0.129408' + x-runtime: '0.120034' x-node: bigweb53nuq - x-version-label: easypost-202408141633-8ef9a7bcc9-master + x-version-label: easypost-202505231841-d89645a184-master x-backend: easypost - x-proxied: ['intlb4nuq c0f5e722d1', 'extlb2nuq b6e1b5034c'] + x-proxied: ['intlb4nuq 668d3fc830', 'extlb2nuq 99aac35317'] strict-transport-security: 'max-age=31536000; includeSubDomains; preload' - body: '{"id":"ca_b67dad1962d94759b9d47c31a3c245cd","object":"CarrierAccount","type":"UpsAccount","clone":false,"created_at":"2024-08-14T17:40:15Z","updated_at":"2024-08-14T17:40:15Z","description":null,"reference":null,"billing_type":"carrier","readable":"UPS","logo":null,"fields":[],"credentials":[],"test_credentials":[]}' + body: '{"id":"ca_06c594e584bc423e887fd9f130b485d8","object":"CarrierAccount","type":"UpsAccount","clone":false,"created_at":"2025-05-23T19:34:16Z","updated_at":"2025-05-23T19:34:16Z","description":null,"reference":null,"billing_type":"carrier","readable":"UPS","logo":null,"fields":[],"credentials":[],"test_credentials":[]}' curl_info: - url: 'https://api.easypost.com/v2/carrier_accounts/ca_b67dad1962d94759b9d47c31a3c245cd' + url: 'https://api.easypost.com/v2/carrier_accounts/ca_06c594e584bc423e887fd9f130b485d8' content_type: 'application/json; charset=utf-8' http_code: 200 header_size: 689 - request_size: 329 + request_size: 400 filetime: -1 ssl_verify_result: 0 redirect_count: 0 - total_time: 0.229087 - namelookup_time: 0.001906 - connect_time: 0.031486 - pretransfer_time: 0.065886 - size_upload: 0.0 + total_time: 0.326864 + namelookup_time: 0.001438 + connect_time: 0.067508 + pretransfer_time: 0.135774 + size_upload: 50.0 size_download: 1420.0 - speed_download: 6198.0 - speed_upload: 0.0 + speed_download: 4344.0 + speed_upload: 152.0 download_content_length: 1420.0 - upload_content_length: 0.0 - starttransfer_time: 0.229022 - redirect_time: 0.0 - redirect_url: '' - primary_ip: 169.62.110.130 - certinfo: { } - primary_port: 443 - local_ip: 192.168.1.75 - local_port: 52761 - http_version: 2 - protocol: 2 - ssl_verifyresult: 0 - scheme: https - appconnect_time_us: 65814 - connect_time_us: 31486 - namelookup_time_us: 1906 - pretransfer_time_us: 65886 - redirect_time_us: 0 - starttransfer_time_us: 229022 - total_time_us: 229087 - effective_method: GET - capath: '' - cainfo: '' - index: 0 -- - request: - method: PATCH - url: 'https://api.easypost.com/v2/ups_oauth_registrations/ca_b67dad1962d94759b9d47c31a3c245cd' - headers: - Host: api.easypost.com - Expect: '' - Accept-Encoding: '' - Accept: application/json - Authorization: '' - Content-Type: application/json - User-Agent: '' - body: '{"ups_oauth_registrations":{"account_number":"987654321"}}' - response: - status: - code: 200 - message: OK - headers: - x-frame-options: SAMEORIGIN - x-xss-protection: '1; mode=block' - x-content-type-options: nosniff - x-download-options: noopen - x-permitted-cross-domain-policies: none - referrer-policy: strict-origin-when-cross-origin - x-ep-request-uuid: e181587a66bcebffe2b8fff60086fe42 - cache-control: 'private, no-cache, no-store' - pragma: no-cache - expires: '0' - content-type: 'application/json; charset=utf-8' - content-length: '1396' - x-runtime: '0.068094' - x-node: bigweb36nuq - x-version-label: easypost-202408141633-8ef9a7bcc9-master - x-backend: easypost - x-proxied: ['intlb4nuq c0f5e722d1', 'extlb2nuq b6e1b5034c'] - strict-transport-security: 'max-age=31536000; includeSubDomains; preload' - body: '{"id":"ca_b67dad1962d94759b9d47c31a3c245cd","object":"CarrierAccount","type":"UpsAccount","clone":false,"created_at":"2024-08-14T17:40:15Z","updated_at":"2024-08-14T17:40:15Z","description":null,"reference":null,"billing_type":"carrier","readable":"UPS","logo":null,"fields":[],"credentials":[],"test_credentials":[]}' - curl_info: - url: 'https://api.easypost.com/v2/ups_oauth_registrations/ca_b67dad1962d94759b9d47c31a3c245cd' - content_type: 'application/json; charset=utf-8' - http_code: 200 - header_size: 689 - request_size: 416 - filetime: -1 - ssl_verify_result: 0 - redirect_count: 0 - total_time: 0.177725 - namelookup_time: 0.002558 - connect_time: 0.035114 - pretransfer_time: 0.073278 - size_upload: 58.0 - size_download: 1396.0 - speed_download: 7854.0 - speed_upload: 326.0 - download_content_length: 1396.0 - upload_content_length: 58.0 - starttransfer_time: 0.177639 + upload_content_length: 50.0 + starttransfer_time: 0.326771 redirect_time: 0.0 redirect_url: '' primary_ip: 169.62.110.130 certinfo: { } primary_port: 443 - local_ip: 192.168.1.75 - local_port: 52762 + local_ip: 10.130.6.32 + local_port: 51584 http_version: 2 protocol: 2 ssl_verifyresult: 0 scheme: https - appconnect_time_us: 73204 - connect_time_us: 35114 - namelookup_time_us: 2558 - pretransfer_time_us: 73278 + appconnect_time_us: 135715 + connect_time_us: 67508 + namelookup_time_us: 1438 + pretransfer_time_us: 135774 redirect_time_us: 0 - starttransfer_time_us: 177639 - total_time_us: 177725 + starttransfer_time_us: 326771 + posttransfer_time_us: 135773 + total_time_us: 326864 effective_method: PATCH capath: '' cainfo: '' @@ -237,7 +162,7 @@ - request: method: DELETE - url: 'https://api.easypost.com/v2/carrier_accounts/ca_b67dad1962d94759b9d47c31a3c245cd' + url: 'https://api.easypost.com/v2/carrier_accounts/ca_06c594e584bc423e887fd9f130b485d8' headers: Host: api.easypost.com Accept-Encoding: '' @@ -256,57 +181,58 @@ x-download-options: noopen x-permitted-cross-domain-policies: none referrer-policy: strict-origin-when-cross-origin - x-ep-request-uuid: e181587a66bcec00e2b8fff70086fe6c + x-ep-request-uuid: 6ae239326830cdb8e7874545008db2ef cache-control: 'private, no-cache, no-store' pragma: no-cache expires: '0' content-type: 'application/json; charset=utf-8' content-length: '2' - x-runtime: '0.065005' - x-node: bigweb53nuq - x-version-label: easypost-202408141633-8ef9a7bcc9-master + x-runtime: '0.072700' + x-node: bigweb36nuq + x-version-label: easypost-202505231841-d89645a184-master x-backend: easypost - x-proxied: ['intlb3nuq c0f5e722d1', 'extlb2nuq b6e1b5034c'] + x-proxied: ['intlb3nuq 668d3fc830', 'extlb2nuq 99aac35317'] strict-transport-security: 'max-age=31536000; includeSubDomains; preload' body: '[]' curl_info: - url: 'https://api.easypost.com/v2/carrier_accounts/ca_b67dad1962d94759b9d47c31a3c245cd' + url: 'https://api.easypost.com/v2/carrier_accounts/ca_06c594e584bc423e887fd9f130b485d8' content_type: 'application/json; charset=utf-8' http_code: 200 header_size: 686 - request_size: 332 + request_size: 331 filetime: -1 ssl_verify_result: 0 redirect_count: 0 - total_time: 0.171474 - namelookup_time: 0.001919 - connect_time: 0.035195 - pretransfer_time: 0.070244 + total_time: 0.276449 + namelookup_time: 0.002645 + connect_time: 0.066904 + pretransfer_time: 0.135033 size_upload: 0.0 size_download: 2.0 - speed_download: 11.0 + speed_download: 7.0 speed_upload: 0.0 download_content_length: 2.0 upload_content_length: 0.0 - starttransfer_time: 0.171454 + starttransfer_time: 0.276357 redirect_time: 0.0 redirect_url: '' primary_ip: 169.62.110.130 certinfo: { } primary_port: 443 - local_ip: 192.168.1.75 - local_port: 52763 + local_ip: 10.130.6.32 + local_port: 51585 http_version: 2 protocol: 2 ssl_verifyresult: 0 scheme: https - appconnect_time_us: 70215 - connect_time_us: 35195 - namelookup_time_us: 1919 - pretransfer_time_us: 70244 + appconnect_time_us: 134974 + connect_time_us: 66904 + namelookup_time_us: 2645 + pretransfer_time_us: 135033 redirect_time_us: 0 - starttransfer_time_us: 171454 - total_time_us: 171474 + starttransfer_time_us: 276357 + posttransfer_time_us: 135063 + total_time_us: 276449 effective_method: DELETE capath: '' cainfo: '' From 8310ae9ca3e7b8f1d7213ae9594634abbdf52782 Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Fri, 23 May 2025 13:37:14 -0600 Subject: [PATCH 2/3] fix: lint --- lib/EasyPost/Exception/Api/ApiException.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/EasyPost/Exception/Api/ApiException.php b/lib/EasyPost/Exception/Api/ApiException.php index a84b67de..c2c6004e 100644 --- a/lib/EasyPost/Exception/Api/ApiException.php +++ b/lib/EasyPost/Exception/Api/ApiException.php @@ -51,7 +51,7 @@ public function __construct(string $message = '', ?int $httpStatus = null, ?stri if (isset($this->jsonBody) && !empty($this->jsonBody['error']['code'])) { $this->code = $this->jsonBody['error']['code']; } - } catch (Exception $e) { // @phpstan-ignore-line + } catch (Exception $e) { $this->jsonBody = null; } } From 236adfda01535b7339ec22eae289ebf49eea4d26 Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Fri, 23 May 2025 13:47:27 -0600 Subject: [PATCH 3/3] fix: lint --- lib/EasyPost/Exception/Api/ApiException.php | 20 ++++++++------------ lib/EasyPost/Http/Requestor.php | 2 +- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/lib/EasyPost/Exception/Api/ApiException.php b/lib/EasyPost/Exception/Api/ApiException.php index c2c6004e..0b85ac3f 100644 --- a/lib/EasyPost/Exception/Api/ApiException.php +++ b/lib/EasyPost/Exception/Api/ApiException.php @@ -39,20 +39,16 @@ public function __construct(string $message = '', ?int $httpStatus = null, ?stri $this->errors = []; $this->code = null; - try { - $this->jsonBody = isset($httpBody) ? json_decode($httpBody, true) : null; + $this->jsonBody = isset($httpBody) ? json_decode($httpBody, true) : null; - // Set `errors` property - if (isset($this->jsonBody) && !empty($this->jsonBody['error']['errors'])) { - $this->errors = $this->jsonBody['error']['errors']; - } + // Set `errors` property + if (isset($this->jsonBody) && !empty($this->jsonBody['error']['errors'])) { + $this->errors = $this->jsonBody['error']['errors']; + } - // Set `code` property - if (isset($this->jsonBody) && !empty($this->jsonBody['error']['code'])) { - $this->code = $this->jsonBody['error']['code']; - } - } catch (Exception $e) { - $this->jsonBody = null; + // Set `code` property + if (isset($this->jsonBody) && !empty($this->jsonBody['error']['code'])) { + $this->code = $this->jsonBody['error']['code']; } } diff --git a/lib/EasyPost/Http/Requestor.php b/lib/EasyPost/Http/Requestor.php index 2adb2af8..8139b044 100644 --- a/lib/EasyPost/Http/Requestor.php +++ b/lib/EasyPost/Http/Requestor.php @@ -55,7 +55,7 @@ private static function absoluteUrl(EasyPostClient $client, string $url = '', bo public static function utf8(mixed $value): string { if (is_string($value) && mb_detect_encoding($value, 'UTF-8', true) != 'UTF-8') { - return mb_convert_encoding($value, 'UTF-8', 'ISO-8859-1'); + return (string)mb_convert_encoding($value, 'UTF-8', 'ISO-8859-1'); } return $value;