diff --git a/CHANGELOG.md b/CHANGELOG.md index b98324cd..e8767b02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # CHANGELOG +## Next Release + +- Routes `UpsAccount`, `UpsMailInnovationsAccount`, and `UpsSurepostAccount` create/update requests to the new `/ups_oauth_registrations` endpoint + - Starting `2024-08-05`, UPS accounts will require a new payload to register or update. See [UPS OAuth 2.0 Update](https://support.easypost.com/hc/en-us/articles/26635027512717-UPS-OAuth-2-0-Update?utm_medium=email&_hsenc=p2ANqtz-96MmFtWICOzy9sKRbbcZSiMovZSrY3MSX1_bgY9N3f9yLVfWQdLhjAGq-SmNcOnDIS6GYhZ0OApjDBrGkKyLLMx1z6_TFOVp6-wllhEFQINrkuRuc&_hsmi=313130292&utm_content=313130292&utm_source=hs_email) for more details + ## v7.2.0 (2024-04-10) - Fix payment method funding and deletion failures due to undetermined payment method type diff --git a/Makefile b/Makefile index addc6307..bb5d823e 100644 --- a/Makefile +++ b/Makefile @@ -23,8 +23,13 @@ docs: curl -LJs https://github.com/phpDocumentor/phpDocumentor/releases/download/v3.3.1/phpDocumentor.phar -o phpDocumentor.phar php phpDocumentor.phar -d lib -t docs +## init-examples-submodule - Initialize the examples submodule +init-examples-submodule: + git submodule init + git submodule update + ## install - Install dependencies -install: | update-examples-submodule +install: | init-examples-submodule composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist ## lint - Lint the project diff --git a/lib/EasyPost/Constant/Constants.php b/lib/EasyPost/Constant/Constants.php index b10ca163..e6cafe85 100644 --- a/lib/EasyPost/Constant/Constants.php +++ b/lib/EasyPost/Constant/Constants.php @@ -17,10 +17,15 @@ abstract class Constants // Validation const CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_WORKFLOWS = [ 'FedexAccount', - 'UpsAccount', 'FedexSmartpostAccount' ]; + const UPS_OAUTH_ACCOUNT_TYPES = [ + 'UpsAccount', + 'UpsMailInnovationsAccount', + 'UpsSurepostAccount' + ]; + // 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 cdbc5840..bb4afa99 100644 --- a/lib/EasyPost/Service/CarrierAccountService.php +++ b/lib/EasyPost/Service/CarrierAccountService.php @@ -43,7 +43,16 @@ public function all(mixed $params = null): mixed */ public function update(string $id, mixed $params): mixed { - return self::updateResource(self::serviceModelClassName(self::class), $id, $params); + $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]; + } + return self::updateResource($className, $id, $params); } /** @@ -67,17 +76,13 @@ public function delete(string $id, mixed $params = null): void */ public function create(mixed $params = null): mixed { - if (!isset($params['carrier_account']) || !is_array($params['carrier_account'])) { - $clone = $params; - unset($params); - $params['carrier_account'] = $clone; - } - - if (!isset($params['carrier_account']['type'])) { + if (!isset($params['type'])) { throw new MissingParameterException(sprintf(Constants::MISSING_PARAMETER_ERROR, 'type')); } - $url = self::selectCarrierAccountCreationEndpoint($params['carrier_account']['type']); + $carrierAccountType = $params['type']; + $params = [self::selectTopLayerKey($carrierAccountType) => $params]; + $url = self::selectCarrierAccountCreationEndpoint($carrierAccountType); $response = Requestor::request($this->client, 'post', $url, $params); return InternalUtil::convertToEasyPostObject($this->client, $response); @@ -106,8 +111,23 @@ 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'; } return '/carrier_accounts'; } + + /** + * Select the top-key layer for creating/updating a carrier account based on the type of carrier account. + * + * @param string $carrierAccountType The type of carrier account to create. + * @return string The top-layer key for creating/updating a carrier account. + */ + private function selectTopLayerKey(string $carrierAccountType): string + { + return in_array($carrierAccountType, Constants::UPS_OAUTH_ACCOUNT_TYPES, true) + ? 'ups_oauth_registrations' + : 'carrier_account'; + } } diff --git a/test/EasyPost/CarrierAccountTest.php b/test/EasyPost/CarrierAccountTest.php index a1d60495..9b460631 100644 --- a/test/EasyPost/CarrierAccountTest.php +++ b/test/EasyPost/CarrierAccountTest.php @@ -47,6 +47,28 @@ public function testCreate(): void self::$client->carrierAccount->delete($carrierAccount->id); } + /** + * Test creating an UPS account. + */ + public function testCreateUps(): void + { + TestUtil::setupCassette('carrier_accounts/create_ups.yml'); + + self::$client = new EasyPostClient(getenv('EASYPOST_PROD_API_KEY')); + + $upsAccount = self::$client->carrierAccount->create([ + 'type' => 'UpsAccount', + 'account_number' => '123456789' + ]); + + $this->assertEquals('UpsAccount', $upsAccount->type); + $this->assertInstanceOf(CarrierAccount::class, $upsAccount); + $this->assertStringMatchesFormat('ca_%s', $upsAccount->id); + + // Delete the carrier account once it's done being tested. + self::$client->carrierAccount->delete($upsAccount->id); + } + /** * Test creating a carrier account. */ @@ -138,6 +160,30 @@ public function testAll(): void $this->assertContainsOnlyInstancesOf(CarrierAccount::class, $carrierAccounts); } + /** + * Test updating an UPS account. + */ + public function testUpdateUps(): void + { + TestUtil::setupCassette('carrier_accounts/update_ups.yml'); + + self::$client = new EasyPostClient(getenv('EASYPOST_PROD_API_KEY')); + + $upsAccount = self::$client->carrierAccount->create([ + 'type' => 'UpsAccount', + 'account_number' => '123456789' + ]); + + $updatedUpsAccount = self::$client->carrierAccount->update($upsAccount->id, ['account_number' => '987654321']); + + $this->assertInstanceOf(CarrierAccount::class, $updatedUpsAccount); + $this->assertStringMatchesFormat('ca_%s', $updatedUpsAccount->id); + $this->assertEquals('UpsAccount', $updatedUpsAccount->type); + + // Delete the carrier account once it's done being tested. + self::$client->carrierAccount->delete($updatedUpsAccount->id); + } + /** * Test updating a carrier account. */ diff --git a/test/cassettes/carrier_accounts/create_ups.yml b/test/cassettes/carrier_accounts/create_ups.yml new file mode 100644 index 00000000..9e888aa5 --- /dev/null +++ b/test/cassettes/carrier_accounts/create_ups.yml @@ -0,0 +1,157 @@ + +- + request: + method: POST + url: 'https://api.easypost.com/v2/ups_oauth_registrations' + headers: + Host: api.easypost.com + Expect: '' + Accept-Encoding: '' + Accept: application/json + Authorization: '' + Content-Type: application/json + User-Agent: '' + body: '{"ups_oauth_registrations":{"type":"UpsAccount","account_number":"123456789"}}' + response: + status: + code: 201 + message: Created + 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: 6754031e668dafcae78bb4ad002eae7b + cache-control: 'private, no-cache, no-store' + pragma: no-cache + expires: '0' + content-type: 'application/json; charset=utf-8' + content-length: '1392' + x-runtime: '0.096106' + x-node: bigweb35nuq + x-version-label: easypost-202407092027-324ee50b5a-master + x-backend: easypost + x-proxied: ['intlb4nuq fa152d4755', 'extlb1nuq fa152d4755'] + strict-transport-security: 'max-age=31536000; includeSubDomains; preload' + body: '{"id":"ca_7ca26177f5ae42429027f6f40c80fad0","object":"CarrierAccount","type":"UpsAccount","clone":false,"created_at":"2024-07-09T21:46:50Z","updated_at":"2024-07-09T21:46: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' + content_type: 'application/json; charset=utf-8' + http_code: 201 + header_size: 694 + request_size: 399 + filetime: -1 + ssl_verify_result: 0 + redirect_count: 0 + total_time: 0.569285 + namelookup_time: 0.025107 + connect_time: 0.169711 + pretransfer_time: 0.325097 + size_upload: 78.0 + size_download: 1392.0 + speed_download: 2445.0 + speed_upload: 137.0 + download_content_length: 1392.0 + upload_content_length: 78.0 + starttransfer_time: 0.569251 + redirect_time: 0.0 + redirect_url: '' + primary_ip: 169.62.110.131 + certinfo: { } + primary_port: 443 + local_ip: 10.130.6.20 + local_port: 59855 + http_version: 2 + protocol: 2 + ssl_verifyresult: 0 + scheme: HTTPS + appconnect_time_us: 325029 + connect_time_us: 169711 + namelookup_time_us: 25107 + pretransfer_time_us: 325097 + redirect_time_us: 0 + starttransfer_time_us: 569251 + total_time_us: 569285 + effective_method: POST + capath: '' + cainfo: '' + index: 0 +- + request: + method: DELETE + url: 'https://api.easypost.com/v2/carrier_accounts/ca_7ca26177f5ae42429027f6f40c80fad0' + headers: + Host: api.easypost.com + Accept-Encoding: '' + Accept: application/json + Authorization: '' + Content-Type: application/json + User-Agent: '' + 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: 67540321668dafcae78bb4ae002eaee5 + 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.062256' + x-node: bigweb35nuq + x-version-label: easypost-202407092027-324ee50b5a-master + x-backend: easypost + x-proxied: ['intlb4nuq fa152d4755', 'extlb1nuq fa152d4755'] + strict-transport-security: 'max-age=31536000; includeSubDomains; preload' + body: '[]' + curl_info: + url: 'https://api.easypost.com/v2/carrier_accounts/ca_7ca26177f5ae42429027f6f40c80fad0' + content_type: 'application/json; charset=utf-8' + http_code: 200 + header_size: 686 + request_size: 332 + filetime: -1 + ssl_verify_result: 0 + redirect_count: 0 + total_time: 0.494344 + namelookup_time: 0.001172 + connect_time: 0.135907 + pretransfer_time: 0.288911 + size_upload: 0.0 + size_download: 2.0 + speed_download: 4.0 + speed_upload: 0.0 + download_content_length: 2.0 + upload_content_length: 0.0 + starttransfer_time: 0.494308 + redirect_time: 0.0 + redirect_url: '' + primary_ip: 169.62.110.131 + certinfo: { } + primary_port: 443 + local_ip: 10.130.6.20 + local_port: 59856 + http_version: 2 + protocol: 2 + ssl_verifyresult: 0 + scheme: HTTPS + appconnect_time_us: 288815 + connect_time_us: 135907 + namelookup_time_us: 1172 + pretransfer_time_us: 288911 + redirect_time_us: 0 + starttransfer_time_us: 494308 + total_time_us: 494344 + effective_method: DELETE + capath: '' + cainfo: '' + index: 0 diff --git a/test/cassettes/carrier_accounts/update.yml b/test/cassettes/carrier_accounts/update.yml index c94d8ccd..13fa9510 100644 --- a/test/cassettes/carrier_accounts/update.yml +++ b/test/cassettes/carrier_accounts/update.yml @@ -14,8 +14,7 @@ body: '{"carrier_account":{"type":"DhlEcsAccount","credentials":{"client_id":"123456","client_secret":"123abc","distribution_center":"USLAX1","pickup_id":"123456"},"test_credentials":{"client_id":"123456","client_secret":"123abc","distribution_center":"USLAX1","pickup_id":"123456"}}}' response: status: - http_version: '1.1' - code: '201' + code: 201 message: Created headers: x-frame-options: SAMEORIGIN @@ -24,19 +23,19 @@ x-download-options: noopen x-permitted-cross-domain-policies: none referrer-policy: strict-origin-when-cross-origin - x-ep-request-uuid: 6c53f872655e6541e7885e02001f4518 + x-ep-request-uuid: 1f7ff67a668db350e798c45d0032c503 cache-control: 'private, no-cache, no-store' pragma: no-cache expires: '0' content-type: 'application/json; charset=utf-8' content-length: '1469' - x-runtime: '0.112027' - x-node: bigweb31nuq - x-version-label: easypost-202311212221-a0f06fbc2c-master + x-runtime: '0.086550' + x-node: bigweb40nuq + x-version-label: easypost-202407092027-324ee50b5a-master x-backend: easypost - x-proxied: ['intlb1nuq b3de2c47ef', 'extlb1nuq 003ad9bca0'] + x-proxied: ['intlb3nuq fa152d4755', 'extlb2nuq fa152d4755'] strict-transport-security: 'max-age=31536000; includeSubDomains; preload' - body: '{"id":"ca_b9bdc1b4620d47188f410cc2f386b31c","object":"CarrierAccount","type":"DhlEcsAccount","clone":false,"created_at":"2023-11-22T20:32:02Z","updated_at":"2023-11-22T20:32:02Z","description":"DHL eCommerce Solutions Account","reference":null,"billing_type":"carrier","readable":"DHL eCommerce Solutions","logo":null,"fields":[],"credentials":[],"test_credentials":[]}' + body: '{"id":"ca_2ffe0d6ea57d44069f96e8343e01d134","object":"CarrierAccount","type":"DhlEcsAccount","clone":false,"created_at":"2024-07-09T22:01:52Z","updated_at":"2024-07-09T22:01:52Z","description":"DHL eCommerce Solutions Account","reference":null,"billing_type":"carrier","readable":"DHL eCommerce Solutions","logo":null,"fields":[],"credentials":[],"test_credentials":[]}' curl_info: url: 'https://api.easypost.com/v2/carrier_accounts' content_type: 'application/json; charset=utf-8' @@ -46,40 +45,120 @@ filetime: -1 ssl_verify_result: 0 redirect_count: 0 - total_time: 0.310246 - namelookup_time: 0.001315 - connect_time: 0.067338 - pretransfer_time: 0.134517 + total_time: 0.530043 + namelookup_time: 0.003049 + connect_time: 0.146971 + pretransfer_time: 0.299929 size_upload: 277.0 size_download: 1469.0 - speed_download: 4734.0 - speed_upload: 892.0 + speed_download: 2771.0 + speed_upload: 522.0 download_content_length: 1469.0 upload_content_length: 277.0 - starttransfer_time: 0.310192 + starttransfer_time: 0.530017 redirect_time: 0.0 redirect_url: '' - primary_ip: 169.62.110.131 + primary_ip: 169.62.110.130 + certinfo: { } + primary_port: 443 + local_ip: 10.130.6.20 + local_port: 60262 + http_version: 2 + protocol: 2 + ssl_verifyresult: 0 + scheme: HTTPS + appconnect_time_us: 299749 + connect_time_us: 146971 + namelookup_time_us: 3049 + pretransfer_time_us: 299929 + redirect_time_us: 0 + starttransfer_time_us: 530017 + total_time_us: 530043 + effective_method: POST + capath: '' + cainfo: '' + index: 0 +- + request: + method: GET + url: 'https://api.easypost.com/v2/carrier_accounts/ca_2ffe0d6ea57d44069f96e8343e01d134' + headers: + Host: api.easypost.com + Accept-Encoding: '' + Accept: application/json + Authorization: '' + Content-Type: application/json + User-Agent: '' + 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: 1f7ff677668db350e798c45e0032c59c + cache-control: 'private, no-cache, no-store' + pragma: no-cache + expires: '0' + content-type: 'application/json; charset=utf-8' + content-length: '1469' + x-runtime: '0.035548' + x-node: bigweb42nuq + x-version-label: easypost-202407092027-324ee50b5a-master + x-backend: easypost + x-proxied: ['intlb4nuq fa152d4755', 'extlb2nuq fa152d4755'] + strict-transport-security: 'max-age=31536000; includeSubDomains; preload' + body: '{"id":"ca_2ffe0d6ea57d44069f96e8343e01d134","object":"CarrierAccount","type":"DhlEcsAccount","clone":false,"created_at":"2024-07-09T22:01:52Z","updated_at":"2024-07-09T22:01:52Z","description":"DHL eCommerce Solutions Account","reference":null,"billing_type":"carrier","readable":"DHL eCommerce Solutions","logo":null,"fields":[],"credentials":[],"test_credentials":[]}' + curl_info: + url: 'https://api.easypost.com/v2/carrier_accounts/ca_2ffe0d6ea57d44069f96e8343e01d134' + content_type: 'application/json; charset=utf-8' + http_code: 200 + header_size: 689 + request_size: 329 + filetime: -1 + ssl_verify_result: 0 + redirect_count: 0 + total_time: 0.462106 + namelookup_time: 0.000968 + connect_time: 0.136148 + pretransfer_time: 0.280391 + size_upload: 0.0 + size_download: 1469.0 + speed_download: 3178.0 + speed_upload: 0.0 + download_content_length: 1469.0 + upload_content_length: 0.0 + starttransfer_time: 0.462072 + redirect_time: 0.0 + redirect_url: '' + primary_ip: 169.62.110.130 certinfo: { } primary_port: 443 - local_ip: 10.130.6.39 - local_port: 53580 + local_ip: 10.130.6.20 + local_port: 60263 http_version: 2 protocol: 2 ssl_verifyresult: 0 scheme: HTTPS - appconnect_time_us: 134445 - connect_time_us: 67338 - namelookup_time_us: 1315 - pretransfer_time_us: 134517 + appconnect_time_us: 280299 + connect_time_us: 136148 + namelookup_time_us: 968 + pretransfer_time_us: 280391 redirect_time_us: 0 - starttransfer_time_us: 310192 - total_time_us: 310246 + starttransfer_time_us: 462072 + total_time_us: 462106 + effective_method: GET + capath: '' + cainfo: '' index: 0 - request: method: PATCH - url: 'https://api.easypost.com/v2/carrier_accounts/ca_b9bdc1b4620d47188f410cc2f386b31c' + url: 'https://api.easypost.com/v2/carrier_accounts/ca_2ffe0d6ea57d44069f96e8343e01d134' headers: Host: api.easypost.com Expect: '' @@ -88,11 +167,10 @@ Authorization: '' Content-Type: application/json User-Agent: '' - body: '{"description":"My custom description"}' + body: '{"carrier_account":{"description":"My custom description"}}' response: status: - http_version: '1.1' - code: '200' + code: 200 message: OK headers: x-frame-options: SAMEORIGIN @@ -101,62 +179,66 @@ x-download-options: noopen x-permitted-cross-domain-policies: none referrer-policy: strict-origin-when-cross-origin - x-ep-request-uuid: 6c53f876655e6542e7885e03001f4552 + x-ep-request-uuid: 67540322668db351e798c45f00319cc8 cache-control: 'private, no-cache, no-store' pragma: no-cache expires: '0' content-type: 'application/json; charset=utf-8' content-length: '1459' - x-runtime: '0.143297' - x-node: bigweb34nuq - x-version-label: easypost-202311212221-a0f06fbc2c-master + x-runtime: '0.213593' + x-node: bigweb32nuq + x-version-label: easypost-202407092027-324ee50b5a-master x-backend: easypost - x-proxied: ['intlb1nuq b3de2c47ef', 'extlb1nuq 003ad9bca0'] + x-canary: direct + x-proxied: ['intlb4nuq fa152d4755', 'extlb1nuq fa152d4755'] strict-transport-security: 'max-age=31536000; includeSubDomains; preload' - body: '{"id":"ca_b9bdc1b4620d47188f410cc2f386b31c","object":"CarrierAccount","type":"DhlEcsAccount","clone":false,"created_at":"2023-11-22T20:32:02Z","updated_at":"2023-11-22T20:32:02Z","description":"My custom description","reference":null,"billing_type":"carrier","readable":"DHL eCommerce Solutions","logo":null,"fields":[],"credentials":[],"test_credentials":[]}' + body: '{"id":"ca_2ffe0d6ea57d44069f96e8343e01d134","object":"CarrierAccount","type":"DhlEcsAccount","clone":false,"created_at":"2024-07-09T22:01:52Z","updated_at":"2024-07-09T22:01:53Z","description":"My custom description","reference":null,"billing_type":"carrier","readable":"DHL eCommerce Solutions","logo":null,"fields":[],"credentials":[],"test_credentials":[]}' curl_info: - url: 'https://api.easypost.com/v2/carrier_accounts/ca_b9bdc1b4620d47188f410cc2f386b31c' + url: 'https://api.easypost.com/v2/carrier_accounts/ca_2ffe0d6ea57d44069f96e8343e01d134' content_type: 'application/json; charset=utf-8' http_code: 200 - header_size: 689 - request_size: 390 + header_size: 707 + request_size: 410 filetime: -1 ssl_verify_result: 0 redirect_count: 0 - total_time: 0.33584 - namelookup_time: 0.001073 - connect_time: 0.062722 - pretransfer_time: 0.128365 - size_upload: 39.0 + total_time: 0.641964 + namelookup_time: 0.00116 + connect_time: 0.142065 + pretransfer_time: 0.279365 + size_upload: 59.0 size_download: 1459.0 - speed_download: 4344.0 - speed_upload: 116.0 + speed_download: 2272.0 + speed_upload: 91.0 download_content_length: 1459.0 - upload_content_length: 39.0 - starttransfer_time: 0.335805 + upload_content_length: 59.0 + starttransfer_time: 0.641941 redirect_time: 0.0 redirect_url: '' primary_ip: 169.62.110.131 certinfo: { } primary_port: 443 - local_ip: 10.130.6.39 - local_port: 53581 + local_ip: 10.130.6.20 + local_port: 60264 http_version: 2 protocol: 2 ssl_verifyresult: 0 scheme: HTTPS - appconnect_time_us: 128305 - connect_time_us: 62722 - namelookup_time_us: 1073 - pretransfer_time_us: 128365 + appconnect_time_us: 279316 + connect_time_us: 142065 + namelookup_time_us: 1160 + pretransfer_time_us: 279365 redirect_time_us: 0 - starttransfer_time_us: 335805 - total_time_us: 335840 + starttransfer_time_us: 641941 + total_time_us: 641964 + effective_method: PATCH + capath: '' + cainfo: '' index: 0 - request: method: DELETE - url: 'https://api.easypost.com/v2/carrier_accounts/ca_b9bdc1b4620d47188f410cc2f386b31c' + url: 'https://api.easypost.com/v2/carrier_accounts/ca_2ffe0d6ea57d44069f96e8343e01d134' headers: Host: api.easypost.com Accept-Encoding: '' @@ -166,8 +248,7 @@ User-Agent: '' response: status: - http_version: '1.1' - code: '200' + code: 200 message: OK headers: x-frame-options: SAMEORIGIN @@ -176,21 +257,21 @@ x-download-options: noopen x-permitted-cross-domain-policies: none referrer-policy: strict-origin-when-cross-origin - x-ep-request-uuid: 6c53f872655e6542e7885e04001f45a7 + x-ep-request-uuid: 6754031f668db352e798c46300319daf 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.108569' - x-node: bigweb38nuq - x-version-label: easypost-202311212221-a0f06fbc2c-master + x-runtime: '0.062378' + x-node: bigweb53nuq + x-version-label: easypost-202407092027-324ee50b5a-master x-backend: easypost - x-proxied: ['intlb2nuq b3de2c47ef', 'extlb1nuq 003ad9bca0'] + x-proxied: ['intlb3nuq fa152d4755', 'extlb1nuq fa152d4755'] strict-transport-security: 'max-age=31536000; includeSubDomains; preload' body: '[]' curl_info: - url: 'https://api.easypost.com/v2/carrier_accounts/ca_b9bdc1b4620d47188f410cc2f386b31c' + url: 'https://api.easypost.com/v2/carrier_accounts/ca_2ffe0d6ea57d44069f96e8343e01d134' content_type: 'application/json; charset=utf-8' http_code: 200 header_size: 686 @@ -198,33 +279,36 @@ filetime: -1 ssl_verify_result: 0 redirect_count: 0 - total_time: 0.304357 - namelookup_time: 0.001048 - connect_time: 0.065379 - pretransfer_time: 0.131954 + total_time: 0.49259 + namelookup_time: 0.000986 + connect_time: 0.142402 + pretransfer_time: 0.2853 size_upload: 0.0 size_download: 2.0 - speed_download: 6.0 + speed_download: 4.0 speed_upload: 0.0 download_content_length: 2.0 upload_content_length: 0.0 - starttransfer_time: 0.304325 + starttransfer_time: 0.492559 redirect_time: 0.0 redirect_url: '' primary_ip: 169.62.110.131 certinfo: { } primary_port: 443 - local_ip: 10.130.6.39 - local_port: 53582 + local_ip: 10.130.6.20 + local_port: 60268 http_version: 2 protocol: 2 ssl_verifyresult: 0 scheme: HTTPS - appconnect_time_us: 131881 - connect_time_us: 65379 - namelookup_time_us: 1048 - pretransfer_time_us: 131954 + appconnect_time_us: 285209 + connect_time_us: 142402 + namelookup_time_us: 986 + pretransfer_time_us: 285300 redirect_time_us: 0 - starttransfer_time_us: 304325 - total_time_us: 304357 + starttransfer_time_us: 492559 + total_time_us: 492590 + effective_method: DELETE + capath: '' + cainfo: '' index: 0 diff --git a/test/cassettes/carrier_accounts/update_ups.yml b/test/cassettes/carrier_accounts/update_ups.yml new file mode 100644 index 00000000..af3ee00c --- /dev/null +++ b/test/cassettes/carrier_accounts/update_ups.yml @@ -0,0 +1,314 @@ + +- + request: + method: POST + url: 'https://api.easypost.com/v2/ups_oauth_registrations' + headers: + Host: api.easypost.com + Expect: '' + Accept-Encoding: '' + Accept: application/json + Authorization: '' + Content-Type: application/json + User-Agent: '' + body: '{"ups_oauth_registrations":{"type":"UpsAccount","account_number":"123456789"}}' + response: + status: + code: 201 + message: Created + 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: 67540321668db352e798c46400319e54 + cache-control: 'private, no-cache, no-store' + pragma: no-cache + expires: '0' + content-type: 'application/json; charset=utf-8' + content-length: '1404' + x-runtime: '0.099291' + x-node: bigweb38nuq + x-version-label: easypost-202407092027-324ee50b5a-master + x-backend: easypost + x-proxied: ['intlb3nuq fa152d4755', 'extlb1nuq fa152d4755'] + strict-transport-security: 'max-age=31536000; includeSubDomains; preload' + body: '{"id":"ca_abab1d73e47943938a56326d10d0776b","object":"CarrierAccount","type":"UpsAccount","clone":false,"created_at":"2024-07-09T22:01:54Z","updated_at":"2024-07-09T22:01:54Z","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' + content_type: 'application/json; charset=utf-8' + http_code: 201 + header_size: 694 + request_size: 399 + filetime: -1 + ssl_verify_result: 0 + redirect_count: 0 + total_time: 0.538196 + namelookup_time: 0.001377 + connect_time: 0.138061 + pretransfer_time: 0.291193 + size_upload: 78.0 + size_download: 1404.0 + speed_download: 2608.0 + speed_upload: 144.0 + download_content_length: 1404.0 + upload_content_length: 78.0 + starttransfer_time: 0.538149 + redirect_time: 0.0 + redirect_url: '' + primary_ip: 169.62.110.131 + certinfo: { } + primary_port: 443 + local_ip: 10.130.6.20 + local_port: 60269 + http_version: 2 + protocol: 2 + ssl_verifyresult: 0 + scheme: HTTPS + appconnect_time_us: 291133 + connect_time_us: 138061 + namelookup_time_us: 1377 + pretransfer_time_us: 291193 + redirect_time_us: 0 + starttransfer_time_us: 538149 + total_time_us: 538196 + effective_method: POST + capath: '' + cainfo: '' + index: 0 +- + request: + method: GET + url: 'https://api.easypost.com/v2/carrier_accounts/ca_abab1d73e47943938a56326d10d0776b' + headers: + Host: api.easypost.com + Accept-Encoding: '' + Accept: application/json + Authorization: '' + Content-Type: application/json + User-Agent: '' + 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: 67540320668db353e798c47c00319f28 + cache-control: 'private, no-cache, no-store' + pragma: no-cache + expires: '0' + content-type: 'application/json; charset=utf-8' + content-length: '1404' + x-runtime: '0.037830' + x-node: bigweb42nuq + x-version-label: easypost-202407092027-324ee50b5a-master + x-backend: easypost + x-proxied: ['intlb3nuq fa152d4755', 'extlb1nuq fa152d4755'] + strict-transport-security: 'max-age=31536000; includeSubDomains; preload' + body: '{"id":"ca_abab1d73e47943938a56326d10d0776b","object":"CarrierAccount","type":"UpsAccount","clone":false,"created_at":"2024-07-09T22:01:54Z","updated_at":"2024-07-09T22:01:54Z","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_abab1d73e47943938a56326d10d0776b' + content_type: 'application/json; charset=utf-8' + http_code: 200 + header_size: 689 + request_size: 329 + filetime: -1 + ssl_verify_result: 0 + redirect_count: 0 + total_time: 0.480215 + namelookup_time: 0.001224 + connect_time: 0.144826 + pretransfer_time: 0.297933 + size_upload: 0.0 + size_download: 1404.0 + speed_download: 2923.0 + speed_upload: 0.0 + download_content_length: 1404.0 + upload_content_length: 0.0 + starttransfer_time: 0.480186 + redirect_time: 0.0 + redirect_url: '' + primary_ip: 169.62.110.131 + certinfo: { } + primary_port: 443 + local_ip: 10.130.6.20 + local_port: 60270 + http_version: 2 + protocol: 2 + ssl_verifyresult: 0 + scheme: HTTPS + appconnect_time_us: 297877 + connect_time_us: 144826 + namelookup_time_us: 1224 + pretransfer_time_us: 297933 + redirect_time_us: 0 + starttransfer_time_us: 480186 + total_time_us: 480215 + effective_method: GET + capath: '' + cainfo: '' + index: 0 +- + request: + method: PATCH + url: 'https://api.easypost.com/v2/ups_oauth_registrations/ca_abab1d73e47943938a56326d10d0776b' + 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: 6754031e668db353e798c47e00319fb8 + cache-control: 'private, no-cache, no-store' + pragma: no-cache + expires: '0' + content-type: 'application/json; charset=utf-8' + content-length: '1400' + x-runtime: '0.072803' + x-node: bigweb40nuq + x-version-label: easypost-202407092027-324ee50b5a-master + x-backend: easypost + x-proxied: ['intlb3nuq fa152d4755', 'extlb1nuq fa152d4755'] + strict-transport-security: 'max-age=31536000; includeSubDomains; preload' + body: '{"id":"ca_abab1d73e47943938a56326d10d0776b","object":"CarrierAccount","type":"UpsAccount","clone":false,"created_at":"2024-07-09T22:01:54Z","updated_at":"2024-07-09T22:01:55Z","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_abab1d73e47943938a56326d10d0776b' + 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.496408 + namelookup_time: 0.00119 + connect_time: 0.144791 + pretransfer_time: 0.282148 + size_upload: 58.0 + size_download: 1400.0 + speed_download: 2820.0 + speed_upload: 116.0 + download_content_length: 1400.0 + upload_content_length: 58.0 + starttransfer_time: 0.496363 + redirect_time: 0.0 + redirect_url: '' + primary_ip: 169.62.110.131 + certinfo: { } + primary_port: 443 + local_ip: 10.130.6.20 + local_port: 60272 + http_version: 2 + protocol: 2 + ssl_verifyresult: 0 + scheme: HTTPS + appconnect_time_us: 282090 + connect_time_us: 144791 + namelookup_time_us: 1190 + pretransfer_time_us: 282148 + redirect_time_us: 0 + starttransfer_time_us: 496363 + total_time_us: 496408 + effective_method: PATCH + capath: '' + cainfo: '' + index: 0 +- + request: + method: DELETE + url: 'https://api.easypost.com/v2/carrier_accounts/ca_abab1d73e47943938a56326d10d0776b' + headers: + Host: api.easypost.com + Accept-Encoding: '' + Accept: application/json + Authorization: '' + Content-Type: application/json + User-Agent: '' + 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: 6754031c668db354e798c47f0031a055 + 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.064436' + x-node: bigweb43nuq + x-version-label: easypost-202407092027-324ee50b5a-master + x-backend: easypost + x-canary: direct + x-proxied: ['intlb3nuq fa152d4755', 'extlb1nuq fa152d4755'] + strict-transport-security: 'max-age=31536000; includeSubDomains; preload' + body: '[]' + curl_info: + url: 'https://api.easypost.com/v2/carrier_accounts/ca_abab1d73e47943938a56326d10d0776b' + content_type: 'application/json; charset=utf-8' + http_code: 200 + header_size: 704 + request_size: 332 + filetime: -1 + ssl_verify_result: 0 + redirect_count: 0 + total_time: 0.487325 + namelookup_time: 0.001181 + connect_time: 0.130724 + pretransfer_time: 0.276682 + size_upload: 0.0 + size_download: 2.0 + speed_download: 4.0 + speed_upload: 0.0 + download_content_length: 2.0 + upload_content_length: 0.0 + starttransfer_time: 0.487301 + redirect_time: 0.0 + redirect_url: '' + primary_ip: 169.62.110.131 + certinfo: { } + primary_port: 443 + local_ip: 10.130.6.20 + local_port: 60273 + http_version: 2 + protocol: 2 + ssl_verifyresult: 0 + scheme: HTTPS + appconnect_time_us: 276624 + connect_time_us: 130724 + namelookup_time_us: 1181 + pretransfer_time_us: 276682 + redirect_time_us: 0 + starttransfer_time_us: 487301 + total_time_us: 487325 + effective_method: DELETE + capath: '' + cainfo: '' + index: 0