From e50bf956dab5483cb0511487b21f1e9c04517d6d Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Mon, 17 Nov 2025 13:17:54 -0700 Subject: [PATCH 1/4] feat: portal and embeddable sessions --- CHANGELOG.md | 6 + lib/EasyPost/EasyPostClient.php | 6 + .../Service/CustomerPortalService.php | 25 +++ lib/EasyPost/Service/EmbeddableService.php | 25 +++ lib/easypost.php | 2 + test/EasyPost/CustomerPortalTest.php | 49 ++++++ test/EasyPost/EmbeddableTest.php | 47 +++++ test/EasyPost/ScanFormTest.php | 8 +- .../customer_portal/createAccountLink.yml | 159 +++++++++++++++++ test/cassettes/embeddables/createSession.yml | 160 ++++++++++++++++++ .../{scanForms => scan_forms}/all.yml | 0 .../{scanForms => scan_forms}/create.yml | 0 .../{scanForms => scan_forms}/getNextPage.yml | 0 .../{scanForms => scan_forms}/retrieve.yml | 0 14 files changed, 483 insertions(+), 4 deletions(-) create mode 100644 lib/EasyPost/Service/CustomerPortalService.php create mode 100644 lib/EasyPost/Service/EmbeddableService.php create mode 100644 test/EasyPost/CustomerPortalTest.php create mode 100644 test/EasyPost/EmbeddableTest.php create mode 100644 test/cassettes/customer_portal/createAccountLink.yml create mode 100644 test/cassettes/embeddables/createSession.yml rename test/cassettes/{scanForms => scan_forms}/all.yml (100%) rename test/cassettes/{scanForms => scan_forms}/create.yml (100%) rename test/cassettes/{scanForms => scan_forms}/getNextPage.yml (100%) rename test/cassettes/{scanForms => scan_forms}/retrieve.yml (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff40451e..faa5b493 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # CHANGELOG +## Next Release + +- Adds the following functions: + - `embeddable.createSession` + - `customerPortal.createAccountLink` + ## v8.3.0 (2025-11-10) - Adds support for `UspsShipAccount` diff --git a/lib/EasyPost/EasyPostClient.php b/lib/EasyPost/EasyPostClient.php index 24b2a2d9..f0d8db68 100644 --- a/lib/EasyPost/EasyPostClient.php +++ b/lib/EasyPost/EasyPostClient.php @@ -16,8 +16,10 @@ use EasyPost\Service\CarrierAccountService; use EasyPost\Service\CarrierMetadataService; use EasyPost\Service\ClaimService; +use EasyPost\Service\CustomerPortalService; use EasyPost\Service\CustomsInfoService; use EasyPost\Service\CustomsItemService; +use EasyPost\Service\EmbeddableService; use EasyPost\Service\EndShipperService; use EasyPost\Service\EventService; use EasyPost\Service\InsuranceService; @@ -50,8 +52,10 @@ * @property CarrierAccountService $carrierAccount * @property CarrierMetadataService $carrierMetadata * @property ClaimService $claim + * @property CustomerPortalService $customerPortal * @property CustomsInfoService $customsInfo * @property CustomsItemService $customsItem + * @property EmbeddableService $embeddable * @property EndShipperService $endShipper * @property EventService $event * @property InsuranceService $insurance @@ -124,8 +128,10 @@ public function __get(string $serviceName) 'carrierAccount' => CarrierAccountService::class, 'carrierMetadata' => CarrierMetadataService::class, 'claim' => ClaimService::class, + 'customerPortal' => CustomerPortalService::class, 'customsInfo' => CustomsInfoService::class, 'customsItem' => CustomsItemService::class, + 'embeddable' => EmbeddableService::class, 'endShipper' => EndShipperService::class, 'event' => EventService::class, 'insurance' => InsuranceService::class, diff --git a/lib/EasyPost/Service/CustomerPortalService.php b/lib/EasyPost/Service/CustomerPortalService.php new file mode 100644 index 00000000..3fac3e6e --- /dev/null +++ b/lib/EasyPost/Service/CustomerPortalService.php @@ -0,0 +1,25 @@ +client, 'post', "/customer_portal/account_link", $params); + + return InternalUtil::convertToEasyPostObject($this->client, $response); + } +} diff --git a/lib/EasyPost/Service/EmbeddableService.php b/lib/EasyPost/Service/EmbeddableService.php new file mode 100644 index 00000000..de508d83 --- /dev/null +++ b/lib/EasyPost/Service/EmbeddableService.php @@ -0,0 +1,25 @@ +client, 'post', '/embeddables/session', $params); + + return InternalUtil::convertToEasyPostObject($this->client, $response); + } +} diff --git a/lib/easypost.php b/lib/easypost.php index f55a7cf5..52ea1bbc 100644 --- a/lib/easypost.php +++ b/lib/easypost.php @@ -98,8 +98,10 @@ require_once(dirname(__FILE__) . '/EasyPost/Service/BillingService.php'); require_once(dirname(__FILE__) . '/EasyPost/Service/CarrierAccountService.php'); require_once(dirname(__FILE__) . '/EasyPost/Service/ClaimService.php'); +require_once(dirname(__FILE__) . '/EasyPost/Service/CustomerPortalService.php'); require_once(dirname(__FILE__) . '/EasyPost/Service/CustomsInfoService.php'); require_once(dirname(__FILE__) . '/EasyPost/Service/CustomsItemService.php'); +require_once(dirname(__FILE__) . '/EasyPost/Service/EmbeddableService.php'); require_once(dirname(__FILE__) . '/EasyPost/Service/EndShipperService.php'); require_once(dirname(__FILE__) . '/EasyPost/Service/EventService.php'); require_once(dirname(__FILE__) . '/EasyPost/Service/InsuranceService.php'); diff --git a/test/EasyPost/CustomerPortalTest.php b/test/EasyPost/CustomerPortalTest.php new file mode 100644 index 00000000..ed925e6e --- /dev/null +++ b/test/EasyPost/CustomerPortalTest.php @@ -0,0 +1,49 @@ +user->allChildren()['children'][0]; + + $accountLink = self::$client->customerPortal->createAccountLink( + [ + 'session_type' => "account_onboarding", + 'user_id' => $user->id, + 'refresh_url' => "https://example.com/refresh", + 'return_url' => "https://example.com/return", + ] + ); + + $this->assertEquals('CustomerPortalAccountLink', $accountLink->object); + } +} diff --git a/test/EasyPost/EmbeddableTest.php b/test/EasyPost/EmbeddableTest.php new file mode 100644 index 00000000..60fe0a0f --- /dev/null +++ b/test/EasyPost/EmbeddableTest.php @@ -0,0 +1,47 @@ +user->allChildren()['children'][0]; + + $accountLink = self::$client->embeddable->createSession( + [ + 'origin_host' => "https://example.com", + 'user_id' => $user->id, + ] + ); + + $this->assertEquals('EmbeddablesSession', $accountLink->object); + } +} diff --git a/test/EasyPost/ScanFormTest.php b/test/EasyPost/ScanFormTest.php index 65ff7f2e..bda9e699 100644 --- a/test/EasyPost/ScanFormTest.php +++ b/test/EasyPost/ScanFormTest.php @@ -34,7 +34,7 @@ public static function tearDownAfterClass(): void */ public function testCreate(): void { - TestUtil::setupCassette('scanForms/create.yml'); + TestUtil::setupCassette('scan_forms/create.yml'); $shipment = self::$client->shipment->create(Fixture::oneCallBuyShipment()); @@ -51,7 +51,7 @@ public function testCreate(): void */ public function testRetrieve(): void { - TestUtil::setupCassette('scanForms/retrieve.yml'); + TestUtil::setupCassette('scan_forms/retrieve.yml'); $shipment = self::$client->shipment->create(Fixture::oneCallBuyShipment()); @@ -70,7 +70,7 @@ public function testRetrieve(): void */ public function testAll(): void { - TestUtil::setupCassette('scanForms/all.yml'); + TestUtil::setupCassette('scan_forms/all.yml'); $scanForms = self::$client->scanForm->all([ 'page_size' => Fixture::pageSize(), @@ -88,7 +88,7 @@ public function testAll(): void */ public function testGetNextPage(): void { - TestUtil::setupCassette('scanForms/getNextPage.yml'); + TestUtil::setupCassette('scan_forms/getNextPage.yml'); try { $scanforms = self::$client->scanForm->all([ diff --git a/test/cassettes/customer_portal/createAccountLink.yml b/test/cassettes/customer_portal/createAccountLink.yml new file mode 100644 index 00000000..60098288 --- /dev/null +++ b/test/cassettes/customer_portal/createAccountLink.yml @@ -0,0 +1,159 @@ + +- + request: + method: GET + url: 'https://api.easypost.com/v2/users/children' + 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: 53842888691b8272e786bc6301675092 + cache-control: 'private, no-cache, no-store' + pragma: no-cache + expires: '0' + content-type: 'application/json; charset=utf-8' + content-length: '1315' + x-runtime: '0.031698' + x-node: bigweb63nuq + x-version-label: easypost-202511171535-3e300ad867-master + x-backend: easypost + x-proxied: ['intlb4nuq c0061e0a2e', 'extlb1nuq cbbd141214'] + strict-transport-security: 'max-age=31536000; includeSubDomains; preload' + body: '{"children":[{"id":"user_3c44214dcf744d169c3f2db034fd965e","object":"User","parent_id":"user_465eab8bb86844108100be2d4d5288ab","name":"Test User","phone_number":"","verified":true,"created_at":"2022-11-23T21:03:03Z"},{"id":"user_78019b89199646358298fd311435458f","object":"User","parent_id":"user_465eab8bb86844108100be2d4d5288ab","name":"Test User","phone_number":"","verified":true,"created_at":"2022-12-02T22:41:09Z"},{"id":"user_1a2e9fb7903c4a08b2da7d7f57150370","object":"User","parent_id":"user_465eab8bb86844108100be2d4d5288ab","name":"Test User","phone_number":"","verified":true,"created_at":"2022-12-02T22:43:07Z"},{"id":"user_f01890d357374ac3837ff556a957b9b4","object":"User","parent_id":"user_465eab8bb86844108100be2d4d5288ab","name":"Test User","phone_number":"","verified":true,"created_at":"2022-12-05T17:00:14Z"},{"id":"user_4f3642aa792a49d1bbf723956cccdb9f","object":"User","parent_id":"user_465eab8bb86844108100be2d4d5288ab","name":"Test User","phone_number":"","verified":true,"created_at":"2024-03-22T19:40:51Z"},{"id":"user_38e8f37bca2d4b8aa932cb39af02ce58","object":"User","parent_id":"user_465eab8bb86844108100be2d4d5288ab","name":"Test User","phone_number":"","verified":true,"created_at":"2024-03-26T23:01:59Z"}],"has_more":false}' + curl_info: + url: 'https://api.easypost.com/v2/users/children' + content_type: 'application/json; charset=utf-8' + http_code: 200 + header_size: 689 + request_size: 291 + filetime: -1 + ssl_verify_result: 0 + redirect_count: 0 + total_time: 0.277248 + namelookup_time: 0.066846 + connect_time: 0.124745 + pretransfer_time: 0.185077 + size_upload: 0.0 + size_download: 1315.0 + speed_download: 4743.0 + speed_upload: 0.0 + download_content_length: 1315.0 + upload_content_length: 0.0 + starttransfer_time: 0.27723 + redirect_time: 0.0 + redirect_url: '' + primary_ip: 169.62.110.131 + certinfo: { } + primary_port: 443 + local_ip: 10.130.6.21 + local_port: 50629 + http_version: 2 + protocol: 2 + ssl_verifyresult: 0 + scheme: https + appconnect_time_us: 184798 + connect_time_us: 124745 + namelookup_time_us: 66846 + pretransfer_time_us: 185077 + redirect_time_us: 0 + starttransfer_time_us: 277230 + posttransfer_time_us: 185085 + total_time_us: 277248 + effective_method: GET + capath: '' + cainfo: '' + index: 0 +- + request: + method: POST + url: 'https://api.easypost.com/v2/customer_portal/account_link' + headers: + Host: api.easypost.com + Expect: '' + Accept-Encoding: '' + Accept: application/json + Authorization: '' + Content-Type: application/json + User-Agent: '' + body: '{"session_type":"account_onboarding","user_id":"user_3c44214dcf744d169c3f2db034fd965e","refresh_url":"https:\/\/example.com\/refresh","return_url":"https:\/\/example.com\/return"}' + 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: 53842884691b8273e786bc7b016750dc + cache-control: 'private, no-cache, no-store' + pragma: no-cache + expires: '0' + content-type: 'application/json; charset=utf-8' + content-length: '199' + x-runtime: '0.163636' + x-node: bigweb55nuq + x-version-label: easypost-202511171535-3e300ad867-master + x-backend: easypost + x-proxied: ['intlb5nuq c0061e0a2e', 'extlb1nuq cbbd141214'] + strict-transport-security: 'max-age=31536000; includeSubDomains; preload' + body: '{"link":"https:\/\/app.easypost.com\/customer-portal\/onboarding?session_id=PLsospNCGD_h8tnu","object":"CustomerPortalAccountLink","expires_at":"2025-11-17T20:20:47Z","created_at":"2025-11-17T20:15:47Z"}' + curl_info: + url: 'https://api.easypost.com/v2/customer_portal/account_link' + content_type: 'application/json; charset=utf-8' + http_code: 201 + header_size: 693 + request_size: 506 + filetime: -1 + ssl_verify_result: 0 + redirect_count: 0 + total_time: 0.343982 + namelookup_time: 0.001674 + connect_time: 0.059447 + pretransfer_time: 0.119234 + size_upload: 179.0 + size_download: 199.0 + speed_download: 578.0 + speed_upload: 520.0 + download_content_length: 199.0 + upload_content_length: 179.0 + starttransfer_time: 0.343962 + redirect_time: 0.0 + redirect_url: '' + primary_ip: 169.62.110.131 + certinfo: { } + primary_port: 443 + local_ip: 10.130.6.21 + local_port: 50630 + http_version: 2 + protocol: 2 + ssl_verifyresult: 0 + scheme: https + appconnect_time_us: 119181 + connect_time_us: 59447 + namelookup_time_us: 1674 + pretransfer_time_us: 119234 + redirect_time_us: 0 + starttransfer_time_us: 343962 + posttransfer_time_us: 119233 + total_time_us: 343982 + effective_method: POST + capath: '' + cainfo: '' + index: 0 diff --git a/test/cassettes/embeddables/createSession.yml b/test/cassettes/embeddables/createSession.yml new file mode 100644 index 00000000..64c2716c --- /dev/null +++ b/test/cassettes/embeddables/createSession.yml @@ -0,0 +1,160 @@ + +- + request: + method: GET + url: 'https://api.easypost.com/v2/users/children' + 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: 5384288b691b82d0e786bc820167ff66 + cache-control: 'private, no-cache, no-store' + pragma: no-cache + expires: '0' + content-type: 'application/json; charset=utf-8' + content-length: '1315' + x-runtime: '0.079931' + x-node: bigweb54nuq + x-version-label: easypost-202511171535-3e300ad867-master + x-backend: easypost + x-proxied: ['intlb3nuq c0061e0a2e', 'extlb1nuq cbbd141214'] + strict-transport-security: 'max-age=31536000; includeSubDomains; preload' + body: '{"children":[{"id":"user_3c44214dcf744d169c3f2db034fd965e","object":"User","parent_id":"user_465eab8bb86844108100be2d4d5288ab","name":"Test User","phone_number":"","verified":true,"created_at":"2022-11-23T21:03:03Z"},{"id":"user_78019b89199646358298fd311435458f","object":"User","parent_id":"user_465eab8bb86844108100be2d4d5288ab","name":"Test User","phone_number":"","verified":true,"created_at":"2022-12-02T22:41:09Z"},{"id":"user_1a2e9fb7903c4a08b2da7d7f57150370","object":"User","parent_id":"user_465eab8bb86844108100be2d4d5288ab","name":"Test User","phone_number":"","verified":true,"created_at":"2022-12-02T22:43:07Z"},{"id":"user_f01890d357374ac3837ff556a957b9b4","object":"User","parent_id":"user_465eab8bb86844108100be2d4d5288ab","name":"Test User","phone_number":"","verified":true,"created_at":"2022-12-05T17:00:14Z"},{"id":"user_4f3642aa792a49d1bbf723956cccdb9f","object":"User","parent_id":"user_465eab8bb86844108100be2d4d5288ab","name":"Test User","phone_number":"","verified":true,"created_at":"2024-03-22T19:40:51Z"},{"id":"user_38e8f37bca2d4b8aa932cb39af02ce58","object":"User","parent_id":"user_465eab8bb86844108100be2d4d5288ab","name":"Test User","phone_number":"","verified":true,"created_at":"2024-03-26T23:01:59Z"}],"has_more":false}' + curl_info: + url: 'https://api.easypost.com/v2/users/children' + content_type: 'application/json; charset=utf-8' + http_code: 200 + header_size: 689 + request_size: 291 + filetime: -1 + ssl_verify_result: 0 + redirect_count: 0 + total_time: 0.257994 + namelookup_time: 0.002764 + connect_time: 0.060084 + pretransfer_time: 0.118599 + size_upload: 0.0 + size_download: 1315.0 + speed_download: 5097.0 + speed_upload: 0.0 + download_content_length: 1315.0 + upload_content_length: 0.0 + starttransfer_time: 0.257954 + redirect_time: 0.0 + redirect_url: '' + primary_ip: 169.62.110.131 + certinfo: { } + primary_port: 443 + local_ip: 10.130.6.21 + local_port: 50637 + http_version: 2 + protocol: 2 + ssl_verifyresult: 0 + scheme: https + appconnect_time_us: 118559 + connect_time_us: 60084 + namelookup_time_us: 2764 + pretransfer_time_us: 118599 + redirect_time_us: 0 + starttransfer_time_us: 257954 + posttransfer_time_us: 118606 + total_time_us: 257994 + effective_method: GET + capath: '' + cainfo: '' + index: 0 +- + request: + method: POST + url: 'https://api.easypost.com/v2/embeddables/session' + headers: + Host: api.easypost.com + Expect: '' + Accept-Encoding: '' + Accept: application/json + Authorization: '' + Content-Type: application/json + User-Agent: '' + body: '{"origin_host":"https:\/\/example.com","user_id":"user_3c44214dcf744d169c3f2db034fd965e"}' + 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: 53842889691b82d1e786bc830167ffd3 + cache-control: 'private, no-cache, no-store' + pragma: no-cache + expires: '0' + content-type: 'application/json; charset=utf-8' + content-length: '135' + x-runtime: '0.281017' + x-node: bigweb32nuq + x-version-label: easypost-202511172009-5a977589c2-master + x-backend: easypost + x-canary: direct + x-proxied: ['intlb4nuq c0061e0a2e', 'extlb1nuq cbbd141214'] + strict-transport-security: 'max-age=31536000; includeSubDomains; preload' + body: '{"object":"EmbeddablesSession","session_id":"EwzOq-mnmknzXM_c","expires_at":"2025-11-17T20:32:21Z","created_at":"2025-11-17T20:17:21Z"}' + curl_info: + url: 'https://api.easypost.com/v2/embeddables/session' + content_type: 'application/json; charset=utf-8' + http_code: 201 + header_size: 711 + request_size: 406 + filetime: -1 + ssl_verify_result: 0 + redirect_count: 0 + total_time: 0.460503 + namelookup_time: 0.002657 + connect_time: 0.058966 + pretransfer_time: 0.120078 + size_upload: 89.0 + size_download: 135.0 + speed_download: 293.0 + speed_upload: 193.0 + download_content_length: 135.0 + upload_content_length: 89.0 + starttransfer_time: 0.460483 + redirect_time: 0.0 + redirect_url: '' + primary_ip: 169.62.110.131 + certinfo: { } + primary_port: 443 + local_ip: 10.130.6.21 + local_port: 50638 + http_version: 2 + protocol: 2 + ssl_verifyresult: 0 + scheme: https + appconnect_time_us: 120011 + connect_time_us: 58966 + namelookup_time_us: 2657 + pretransfer_time_us: 120078 + redirect_time_us: 0 + starttransfer_time_us: 460483 + posttransfer_time_us: 120077 + total_time_us: 460503 + effective_method: POST + capath: '' + cainfo: '' + index: 0 diff --git a/test/cassettes/scanForms/all.yml b/test/cassettes/scan_forms/all.yml similarity index 100% rename from test/cassettes/scanForms/all.yml rename to test/cassettes/scan_forms/all.yml diff --git a/test/cassettes/scanForms/create.yml b/test/cassettes/scan_forms/create.yml similarity index 100% rename from test/cassettes/scanForms/create.yml rename to test/cassettes/scan_forms/create.yml diff --git a/test/cassettes/scanForms/getNextPage.yml b/test/cassettes/scan_forms/getNextPage.yml similarity index 100% rename from test/cassettes/scanForms/getNextPage.yml rename to test/cassettes/scan_forms/getNextPage.yml diff --git a/test/cassettes/scanForms/retrieve.yml b/test/cassettes/scan_forms/retrieve.yml similarity index 100% rename from test/cassettes/scanForms/retrieve.yml rename to test/cassettes/scan_forms/retrieve.yml From ad01c48bf3cb8497dd14a201274e91d163950063 Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Mon, 17 Nov 2025 13:18:56 -0700 Subject: [PATCH 2/4] fix: lint --- lib/EasyPost/Service/CustomerPortalService.php | 2 +- test/EasyPost/CustomerPortalTest.php | 6 +++--- test/EasyPost/EmbeddableTest.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/EasyPost/Service/CustomerPortalService.php b/lib/EasyPost/Service/CustomerPortalService.php index 3fac3e6e..ea8a5d44 100644 --- a/lib/EasyPost/Service/CustomerPortalService.php +++ b/lib/EasyPost/Service/CustomerPortalService.php @@ -18,7 +18,7 @@ class CustomerPortalService extends BaseService */ public function createAccountLink(mixed $params = null): mixed { - $response = Requestor::request($this->client, 'post', "/customer_portal/account_link", $params); + $response = Requestor::request($this->client, 'post', '/customer_portal/account_link', $params); return InternalUtil::convertToEasyPostObject($this->client, $response); } diff --git a/test/EasyPost/CustomerPortalTest.php b/test/EasyPost/CustomerPortalTest.php index ed925e6e..721dbeeb 100644 --- a/test/EasyPost/CustomerPortalTest.php +++ b/test/EasyPost/CustomerPortalTest.php @@ -37,10 +37,10 @@ public function testCreateAccountLink(): void $accountLink = self::$client->customerPortal->createAccountLink( [ - 'session_type' => "account_onboarding", + 'session_type' => 'account_onboarding', 'user_id' => $user->id, - 'refresh_url' => "https://example.com/refresh", - 'return_url' => "https://example.com/return", + 'refresh_url' => 'https://example.com/refresh', + 'return_url' => 'https://example.com/return', ] ); diff --git a/test/EasyPost/EmbeddableTest.php b/test/EasyPost/EmbeddableTest.php index 60fe0a0f..c675f403 100644 --- a/test/EasyPost/EmbeddableTest.php +++ b/test/EasyPost/EmbeddableTest.php @@ -37,7 +37,7 @@ public function testCreateSession(): void $accountLink = self::$client->embeddable->createSession( [ - 'origin_host' => "https://example.com", + 'origin_host' => 'https://example.com', 'user_id' => $user->id, ] ); From f4ed70d7dc6c309214f90ebd8be7db2e90678612 Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Mon, 17 Nov 2025 13:58:43 -0700 Subject: [PATCH 3/4] fix: lint --- lib/EasyPost/Util/InternalUtil.php | 11 +++++++---- test/EasyPost/Fixture.php | 8 ++++++++ test/EasyPost/ReferralCustomerTest.php | 6 +++--- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/EasyPost/Util/InternalUtil.php b/lib/EasyPost/Util/InternalUtil.php index 63aaa6c8..a0ff86be 100644 --- a/lib/EasyPost/Util/InternalUtil.php +++ b/lib/EasyPost/Util/InternalUtil.php @@ -181,7 +181,7 @@ public static function convertToEasyPostObject(EasyPostClient|null $client, mixe * @param array $carriers * @param array $services * @param string|null $ratesKey - * @return Rate|PickupRate + * @return object * @throws EasyPostException */ public static function getLowestObjectRate( @@ -189,7 +189,7 @@ public static function getLowestObjectRate( ?array $carriers = [], ?array $services = [], ?string $ratesKey = 'rates' - ): Rate|PickupRate { + ): object { $lowestRate = false; $carriersInclude = []; $carriersExclude = []; @@ -235,8 +235,11 @@ public static function getLowestObjectRate( continue; } - if (!$lowestRate || floatval($easypostObject->$ratesKey[$i]->rate) < floatval($lowestRate->rate)) { - $lowestRate = clone ($easypostObject->$ratesKey[$i]); + if ( + !$lowestRate || + floatval($easypostObject->$ratesKey[$i]->rate) < floatval($lowestRate->rate) // @phpstan-ignore-line + ) { + $lowestRate = clone($easypostObject->$ratesKey[$i]); } } diff --git a/test/EasyPost/Fixture.php b/test/EasyPost/Fixture.php index 2bf6b25e..18fe398e 100644 --- a/test/EasyPost/Fixture.php +++ b/test/EasyPost/Fixture.php @@ -296,4 +296,12 @@ public static function lumaPlannedShipDate(): string { return '2025-06-12'; } + + /** + * @return array + */ + public static function referralUser(): array + { + return self::readFixtureData()['users']['referral']; + } } diff --git a/test/EasyPost/ReferralCustomerTest.php b/test/EasyPost/ReferralCustomerTest.php index b173a7c3..e5bd09e8 100644 --- a/test/EasyPost/ReferralCustomerTest.php +++ b/test/EasyPost/ReferralCustomerTest.php @@ -43,9 +43,9 @@ public function testCreate(): void TestUtil::setupCassette('referral_customers/create.yml'); $referral = self::$client->referralCustomer->create([ - 'name' => 'Test Referral', - 'email' => 'test@test.com', - 'phone' => '8888888888' + 'name' => Fixture::referralUser()['name'], + 'email' => Fixture::referralUser()['email'], + 'phone' => Fixture::referralUser()['phone'], ]); $this->assertInstanceOf(User::class, $referral); From aefe879d804310b3af08ba5857cb48d3b35b2636 Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Tue, 18 Nov 2025 12:28:47 -0700 Subject: [PATCH 4/4] fix: re-record cassette --- test/cassettes/referral_customers/create.yml | 52 ++++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/test/cassettes/referral_customers/create.yml b/test/cassettes/referral_customers/create.yml index 9aac7ba0..bdd04b76 100644 --- a/test/cassettes/referral_customers/create.yml +++ b/test/cassettes/referral_customers/create.yml @@ -11,7 +11,7 @@ Authorization: '' Content-Type: application/json User-Agent: '' - body: '{"user":{"name":"Test Referral","email":"test@test.com","phone":"8888888888"}}' + body: '{"user":{"name":"Test Referral","email":"test@example.com","phone":"5555555555"}}' response: status: code: 201 @@ -23,57 +23,57 @@ x-download-options: noopen x-permitted-cross-domain-policies: none referrer-policy: strict-origin-when-cross-origin - x-ep-request-uuid: e181587966bcec1de2b903ba00871d23 + x-ep-request-uuid: 57503b0e691cc8e1e2ba185c0146bb4e cache-control: 'private, no-cache, no-store' pragma: no-cache expires: '0' content-type: 'application/json; charset=utf-8' content-length: '1021' - x-runtime: '0.633094' - x-node: bigweb33nuq - x-version-label: easypost-202408141633-8ef9a7bcc9-master + x-runtime: '0.695374' + x-node: bigweb41nuq + x-version-label: easypost-202511181852-613eda4497-master x-backend: easypost - x-proxied: ['intlb4nuq c0f5e722d1', 'extlb2nuq b6e1b5034c'] + x-proxied: ['intlb4nuq c0061e0a2e', 'extlb1nuq cbbd141214'] strict-transport-security: 'max-age=31536000; includeSubDomains; preload' - body: '{"id":"user_7b554ec665fb46d5bddb54089264f511","object":"User","parent_id":null,"name":"Test Referral","phone_number":"","verified":true,"created_at":"2024-08-14T17:40:45Z","default_carbon_offset":false,"has_elevate_access":false,"balance":"0.00000","price_per_shipment":"0.00000","recharge_amount":null,"secondary_recharge_amount":null,"recharge_threshold":null,"has_billing_method":null,"cc_fee_rate":"0.0375","default_insurance_amount":"50.00","insurance_fee_rate":"0.01","insurance_fee_minimum":"0.50","email":"","children":[],"api_keys":[{"object":"ApiKey","key":"","mode":"test","created_at":"2024-08-14T17:40:46Z","active":true,"id":"ak_1c37a3b09b944b87b72fe589968e3891"},{"object":"ApiKey","key":"","mode":"production","created_at":"2024-08-14T17:40:46Z","active":true,"id":"ak_2c727a5e5a6b4895928987326cda20f9"}]}' + body: '{"id":"user_bad143ad8a174cef8c337ad53951efbf","object":"User","parent_id":null,"name":"Test Referral","phone_number":"","verified":true,"created_at":"2025-11-18T19:28:34Z","default_carbon_offset":false,"has_elevate_access":false,"balance":"0.00000","price_per_shipment":"0.00000","recharge_amount":null,"secondary_recharge_amount":null,"recharge_threshold":null,"has_billing_method":null,"cc_fee_rate":"0.0375","default_insurance_amount":"50.00","insurance_fee_rate":"0.01","insurance_fee_minimum":"0.50","email":"","children":[],"api_keys":[{"object":"ApiKey","key":"","mode":"test","created_at":"2025-11-18T19:28:34Z","active":true,"id":"ak_65cb7a7c1b7649d0890e9b534b4752c8"},{"object":"ApiKey","key":"","mode":"production","created_at":"2025-11-18T19:28:34Z","active":true,"id":"ak_a6a2c13999b44412bb12e46d89890c4c"}]}' curl_info: url: 'https://api.easypost.com/v2/referral_customers' content_type: 'application/json; charset=utf-8' http_code: 201 header_size: 694 - request_size: 394 + request_size: 397 filetime: -1 ssl_verify_result: 0 redirect_count: 0 - total_time: 0.742202 - namelookup_time: 0.003012 - connect_time: 0.032476 - pretransfer_time: 0.064935 - size_upload: 78.0 + total_time: 0.832394 + namelookup_time: 0.035748 + connect_time: 0.066345 + pretransfer_time: 0.10232 + size_upload: 81.0 size_download: 1021.0 - speed_download: 1375.0 - speed_upload: 105.0 + speed_download: 1226.0 + speed_upload: 97.0 download_content_length: 1021.0 - upload_content_length: 78.0 - starttransfer_time: 0.742171 + upload_content_length: 81.0 + starttransfer_time: 0.83236 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: 52829 + local_ip: 192.168.1.60 + local_port: 54739 http_version: 2 protocol: 2 ssl_verifyresult: 0 scheme: https - appconnect_time_us: 64873 - connect_time_us: 32476 - namelookup_time_us: 3012 - pretransfer_time_us: 64935 + appconnect_time_us: 102055 + connect_time_us: 66345 + namelookup_time_us: 35748 + pretransfer_time_us: 102320 redirect_time_us: 0 - starttransfer_time_us: 742171 - total_time_us: 742202 + starttransfer_time_us: 832360 + total_time_us: 832394 effective_method: POST capath: '' cainfo: ''