diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a4eccc3..2f306913 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Fixes a bug where the original filtering criteria of `all` calls wasn't passed along to `getNextPage` calls. Now, these are persisted via a `_params` key on response objects locally - Removes the undocumented `createAndBuy` function from the `Batch` service. The proper usage is to create a batch first and buy it separately - Renames `primaryOrSecondary` to `priority` to match the API name for the parameter +- Fix various bugs throughout the library ## v6.9.1 (2023-11-20) diff --git a/Makefile b/Makefile index 560c33ef..d119060a 100644 --- a/Makefile +++ b/Makefile @@ -28,11 +28,15 @@ install: | update-examples-submodule composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist ## lint - Lint the project -lint: codesniffer scan +lint: codesniffer phpstan scan ## lint-fix - Fix linting errors lint-fix: codesniffer-fix +## phpstan - Scan for static analysis errors +phpstan: + composer phpstan + ## release - Cuts a release for the project on GitHub (requires GitHub CLI) # tag = The associated tag title of the release release: diff --git a/composer.json b/composer.json index 6c4a18a7..da5178a8 100644 --- a/composer.json +++ b/composer.json @@ -29,12 +29,14 @@ "phpunit/phpunit": "^9", "squizlabs/php_codesniffer": "^3.7", "roave/security-advisories": "dev-latest", - "rregeer/phpunit-coverage-check": "^0.3.1" + "rregeer/phpunit-coverage-check": "^0.3.1", + "phpstan/phpstan": "^1.10" }, "scripts": { "coverage": "XDEBUG_MODE=coverage ./bin/phpunit --coverage-html clover.html --coverage-clover build/logs/clover.xml && ./bin/coverage-check build/logs/clover.xml 85 --only-percentage", "fix": "./bin/phpcbf --standard=examples/style_guides/php/phpcs.xml lib test", "lint": "./bin/phpcs --standard=examples/style_guides/php/phpcs.xml lib test", + "phpstan": "./bin/phpstan analyse --memory-limit 1G", "scan": "composer update --dry-run roave/security-advisories", "test": "./bin/phpunit" }, diff --git a/lib/EasyPost/Brand.php b/lib/EasyPost/Brand.php index 45b5ebd4..f45268b1 100644 --- a/lib/EasyPost/Brand.php +++ b/lib/EasyPost/Brand.php @@ -4,6 +4,8 @@ /** * @package EasyPost + * @property string $id + * @property string $object * @property string $background_color * @property string $color * @property string $logo diff --git a/lib/EasyPost/EasyPostClient.php b/lib/EasyPost/EasyPostClient.php index ebfae4df..8cbc295f 100644 --- a/lib/EasyPost/EasyPostClient.php +++ b/lib/EasyPost/EasyPostClient.php @@ -39,11 +39,13 @@ * * @package EasyPost * @property AddressService $address - * @property ApiKeyService $apiKey + * @property ApiKeyService $apiKeys * @property BatchService $batch - * @property BetaReferralCustomer $betaReferralCustomer + * @property BetaRateService $betaRate + * @property BetaReferralCustomerService $betaReferralCustomer * @property BillingService $billing * @property CarrierAccountService $carrierAccount + * @property CarrierMetadataService $carrierMetadata * @property CustomsInfoService $customsInfo * @property CustomsItemService $customsItem * @property EndShipperService $endShipper @@ -65,13 +67,13 @@ class EasyPostClient extends BaseService { // Client properties - private $apiKey; - private $timeout; - private $apiBase; - private $mockingUtility; - public $requestEvent; - public $responseEvent; - public $httpClient; + private string $apiKey; + private float $timeout; + private string $apiBase; + private ?object $mockingUtility; + public object $requestEvent; + public object $responseEvent; + public Client $httpClient; /** * Constructor for an EasyPostClient. @@ -79,7 +81,7 @@ class EasyPostClient extends BaseService * @param string $apiKey * @param float $timeout * @param string $apiBase - * @param object $mockingUtility + * @param object|null $mockingUtility */ public function __construct( string $apiKey, @@ -110,8 +112,8 @@ public function __get(string $serviceName) 'address' => AddressService::class, 'apiKeys' => ApiKeyService::class, 'batch' => BatchService::class, - 'betaReferralCustomer' => BetaReferralCustomerService::class, 'betaRate' => BetaRateService::class, + 'betaReferralCustomer' => BetaReferralCustomerService::class, 'billing' => BillingService::class, 'carrierAccount' => CarrierAccountService::class, 'carrierMetadata' => CarrierMetadataService::class, diff --git a/lib/EasyPost/EasyPostObject.php b/lib/EasyPost/EasyPostObject.php index 167f712e..b1a73659 100644 --- a/lib/EasyPost/EasyPostObject.php +++ b/lib/EasyPost/EasyPostObject.php @@ -8,8 +8,16 @@ class EasyPostObject implements \ArrayAccess, \Iterator { + /** + * @var array + */ protected array $_values; + + /** + * @var array + */ protected array $_immutableValues; + private mixed $_parent; private mixed $_name; @@ -41,6 +49,8 @@ public function __set(string $k, mixed $v): void $current = $this; $param = [$k => $v]; + // TODO: Rework this when we fix (de)serialization + // @phpstan-ignore-next-line while (true && $i < 99) { if (!is_null($current->_parent)) { $param = [$current->_name => $param]; @@ -75,6 +85,8 @@ public function __unset(string $k): void $current = $this; $param = [$k => null]; + // TODO: Rework this when we fix (de)serialization + // @phpstan-ignore-next-line while (true && $i < 99) { if (!is_null($current->_parent)) { $param = [$current->_name => $param]; @@ -107,7 +119,7 @@ public function __get(string $k): mixed * Construct EasyPost objects from a response. * * @param EasyPostClient|null $client - * @param array $values + * @param array $values * @param string $class * @return mixed */ @@ -123,7 +135,7 @@ public static function constructFrom(?EasyPostClient $client, array $values, str * Convert each piece of an EasyPost object. * * @param EasyPostClient|null $client - * @param array $values + * @param array $values */ public function convertEach(?EasyPostClient $client, array $values): void { @@ -259,7 +271,7 @@ public function __toString(): string * Convert object to an array. * * @param bool|null $recursive - * @return array + * @return array */ public function __toArray(?bool $recursive = false): array { diff --git a/lib/EasyPost/Exception/Api/ApiException.php b/lib/EasyPost/Exception/Api/ApiException.php index cb4d3220..75216b9f 100644 --- a/lib/EasyPost/Exception/Api/ApiException.php +++ b/lib/EasyPost/Exception/Api/ApiException.php @@ -3,20 +3,26 @@ namespace EasyPost\Exception\Api; use EasyPost\Exception\General\EasyPostException; +use EasyPost\FieldError; +use Exception; /** * @package EasyPost - * @property string $code - * @property FieldError[] $errors + * @property string|null $code + * @property FieldError[]|null $errors + * @property string $message + * @property string|null $httpBody + * @property int|null $httpStatus + * @property mixed $jsonBody */ class ApiException extends EasyPostException { - public $code; - public $errors; - protected $message; - private $httpBody; - private $httpStatus; - private $jsonBody; + public $code; // @phpstan-ignore-line + public $errors; // @phpstan-ignore-line + protected $message; // @phpstan-ignore-line + private ?string $httpBody; + private ?int $httpStatus; + private mixed $jsonBody; /** * ApiException constructor. @@ -30,24 +36,22 @@ public function __construct(string $message = '', ?int $httpStatus = null, ?stri parent::__construct($message); $this->httpStatus = $httpStatus; $this->httpBody = $httpBody; + $this->errors = null; + $this->code = null; try { $this->jsonBody = isset($httpBody) ? json_decode($httpBody, true) : null; - // Setup `errors` property + // Set `errors` property if (isset($this->jsonBody) && !empty($this->jsonBody['error']['errors'])) { $this->errors = $this->jsonBody['error']['errors']; - } else { - $this->errors = null; } - // Setup `code` property + // Set `code` property if (isset($this->jsonBody) && !empty($this->jsonBody['error']['code'])) { $this->code = $this->jsonBody['error']['code']; - } else { - $this->code = null; } - } catch (\Exception $e) { + } catch (Exception $e) { // @phpstan-ignore-line $this->jsonBody = null; } } diff --git a/lib/EasyPost/Exception/General/EasyPostException.php b/lib/EasyPost/Exception/General/EasyPostException.php index c0131afb..f4e602e4 100644 --- a/lib/EasyPost/Exception/General/EasyPostException.php +++ b/lib/EasyPost/Exception/General/EasyPostException.php @@ -2,6 +2,10 @@ namespace EasyPost\Exception\General; +/** + * @package EasyPost + * @param string $message + */ class EasyPostException extends \Exception { /** diff --git a/lib/EasyPost/Exception/General/EndOfPaginationException.php b/lib/EasyPost/Exception/General/EndOfPaginationException.php index fdf1bd2d..48c269e3 100644 --- a/lib/EasyPost/Exception/General/EndOfPaginationException.php +++ b/lib/EasyPost/Exception/General/EndOfPaginationException.php @@ -8,8 +8,6 @@ class EndOfPaginationException extends \Exception { /** * EndOfPaginationException constructor. - * - * @param string $message */ public function __construct() { diff --git a/lib/EasyPost/Hook/EventHook.php b/lib/EasyPost/Hook/EventHook.php index f8b274c8..65da6fe0 100644 --- a/lib/EasyPost/Hook/EventHook.php +++ b/lib/EasyPost/Hook/EventHook.php @@ -7,9 +7,18 @@ */ class EventHook { - private $eventHandlers = []; + /** + * @var array + */ + private array $eventHandlers = []; - public function __invoke(...$args) + /** + * Fires when the class is invoked. + * + * @param array ...$args + * @return void + */ + public function __invoke(array ...$args): void { foreach ($this->eventHandlers as $eventHandler) { $eventHandler(...$args); diff --git a/lib/EasyPost/Http/Requestor.php b/lib/EasyPost/Http/Requestor.php index fe719518..648c5e33 100644 --- a/lib/EasyPost/Http/Requestor.php +++ b/lib/EasyPost/Http/Requestor.php @@ -6,7 +6,7 @@ use DateTimeZone; use EasyPost\Constant\Constants; use EasyPost\EasyPostClient; -use EasyPost\EasypostObject; +use EasyPost\EasyPostObject; use EasyPost\Exception\Api\BadRequestException; use EasyPost\Exception\Api\ForbiddenException; use EasyPost\Exception\Api\GatewayTimeoutException; @@ -23,6 +23,7 @@ use EasyPost\Exception\Api\TimeoutException; use EasyPost\Exception\Api\UnauthorizedException; use EasyPost\Exception\Api\UnknownApiException; +use Exception; class Requestor { @@ -64,14 +65,14 @@ public static function utf8(mixed $value): string * Encodes an EasyPost object and prepares the data for the request. * * @param mixed $data - * @return array|string + * @return array|string */ private static function encodeObjects(mixed $data): array|string { if (is_null($data)) { return []; } elseif ($data instanceof EasypostObject) { - return ['id' => self::utf8($data->id)]; + return ['id' => self::utf8($data->id)]; // @phpstan-ignore-line } elseif ($data === true) { return 'true'; } elseif ($data === false) { @@ -109,9 +110,9 @@ public static function urlEncode(mixed $arr, ?string $prefix = null): string continue; } - if ($prefix && isset($k)) { + if (isset($prefix)) { $k = $prefix . '[' . $k . ']'; - } elseif ($prefix) { + } else { $k = $prefix . '[]'; } @@ -156,7 +157,7 @@ public static function request( * @param string $url * @param mixed $params * @param bool $beta - * @return array + * @return array * @throws HttpException * @throws TimeoutException */ @@ -223,6 +224,7 @@ private static function requestRaw( // Guzzle does not have a native way of catching timeout exceptions... // If we don't have a response at this point, it's likely due to a timeout. + // @phpstan-ignore-next-line if (!isset($response)) { throw new TimeoutException(sprintf(Constants::NO_RESPONSE_ERROR, 'EasyPost')); } @@ -259,7 +261,7 @@ public static function interpretResponse(string $httpBody, int $httpStatus): mix { try { $response = json_decode($httpBody, true); - } catch (\Exception $e) { + } catch (Exception $e) { // @phpstan-ignore-line throw new JsonException( "Invalid response body from API: HTTP Status: ({$httpStatus}) {$httpBody}", $httpStatus, @@ -279,7 +281,7 @@ public static function interpretResponse(string $httpBody, int $httpStatus): mix * * @param string|null $httpBody * @param int $httpStatus - * @param array $response + * @param array $response * @throws BadRequestException * @throws GatewayTimeoutException * @throws InternalServerException @@ -295,7 +297,7 @@ public static function interpretResponse(string $httpBody, int $httpStatus): mix * @throws UnauthorizedException * @throws UnknownApiException */ - public static function handleApiError(?string $httpBody, int $httpStatus, array $response) + public static function handleApiError(?string $httpBody, int $httpStatus, array $response): void { if (!is_array($response) || !isset($response['error'])) { throw new JsonException( @@ -363,7 +365,7 @@ public static function handleApiError(?string $httpBody, int $httpStatus, array * Recursively traverses a JSON element to extract error messages and returns them as a comma-separated string. * * @param mixed $errorMessage - * @param array $messagesList + * @param array $messagesList * @return string */ private static function traverseJsonElement(mixed $errorMessage, array &$messagesList): string diff --git a/lib/EasyPost/Order.php b/lib/EasyPost/Order.php index ddb7a1bf..5562b14d 100644 --- a/lib/EasyPost/Order.php +++ b/lib/EasyPost/Order.php @@ -28,8 +28,8 @@ class Order extends EasyPostObject * * To exclude a carrier or service, prepend the string with `!`. * - * @param array|null $carriers - * @param array|null $services + * @param array|null $carriers + * @param array|null $services * @return Rate */ public function lowestRate(?array $carriers = [], ?array $services = []): Rate diff --git a/lib/EasyPost/Pickup.php b/lib/EasyPost/Pickup.php index bc130c6a..bff5b35f 100644 --- a/lib/EasyPost/Pickup.php +++ b/lib/EasyPost/Pickup.php @@ -32,8 +32,8 @@ class Pickup extends EasyPostObject * * To exclude a carrier or service, prepend the string with `!`. * - * @param array|null $carriers - * @param array|null $services + * @param array|null $carriers + * @param array|null $services * @return PickupRate */ public function lowestRate(?array $carriers = [], ?array $services = []): PickupRate diff --git a/lib/EasyPost/Service/BaseService.php b/lib/EasyPost/Service/BaseService.php index 612aec78..72e47bfd 100644 --- a/lib/EasyPost/Service/BaseService.php +++ b/lib/EasyPost/Service/BaseService.php @@ -85,7 +85,7 @@ protected static function classUrl(string $class): string protected function instanceUrl(string $class, string $id): string { if (!$id) { - throw new InvalidObjectException(sprintf(Constants::NO_ID_URL_ERROR), $class, $id); + throw new InvalidObjectException(sprintf(Constants::NO_ID_URL_ERROR, $class, $id)); } $id = Requestor::utf8($id); $classUrl = self::classUrl($class); diff --git a/lib/EasyPost/Service/BillingService.php b/lib/EasyPost/Service/BillingService.php index 4f97c626..79669200 100644 --- a/lib/EasyPost/Service/BillingService.php +++ b/lib/EasyPost/Service/BillingService.php @@ -13,7 +13,7 @@ class BillingService extends BaseService { // Overridden here because the logic we need is tied to PaymentMethod - private static $modelClass = 'PaymentMethod'; + private static string $modelClass = 'PaymentMethod'; /** * Retrieve all payment methods. @@ -68,7 +68,7 @@ public function deletePaymentMethod(string $priority): void * Get payment info (type of the payment method and ID of the payment method) * * @param string $priority - * @return array + * @return array * @throws PaymentException */ private function getPaymentInfo(string $priority = 'primary'): array diff --git a/lib/EasyPost/Service/CarrierMetadataService.php b/lib/EasyPost/Service/CarrierMetadataService.php index 2a3d1238..b2725db4 100644 --- a/lib/EasyPost/Service/CarrierMetadataService.php +++ b/lib/EasyPost/Service/CarrierMetadataService.php @@ -13,8 +13,8 @@ class CarrierMetadataService extends BaseService /** * Get carrier metadata for all carriers on the EasyPost platform. * - * @param array|null $carriers - * @param array|null $types + * @param array|null $carriers + * @param array|null $types * @return mixed */ public function retrieve(?array $carriers = null, ?array $types = null): mixed diff --git a/lib/EasyPost/Service/ReferralCustomerService.php b/lib/EasyPost/Service/ReferralCustomerService.php index 4c153623..22d047a0 100644 --- a/lib/EasyPost/Service/ReferralCustomerService.php +++ b/lib/EasyPost/Service/ReferralCustomerService.php @@ -136,7 +136,7 @@ private function retrieveEasypostStripeApiKey(): string * * @param string $number * @param int $expirationMonth - * @param int @expirationYear + * @param int $expirationYear * @param string $cvc * @param string $easypostStripeKey * @return mixed @@ -180,6 +180,7 @@ private function createStripeToken( // Guzzle does not have a native way of catching timeout exceptions... // If we don't have a response at this point, it's likely due to a timeout. + // @phpstan-ignore-next-line if (!isset($response)) { throw new TimeoutException(sprintf(Constants::NO_RESPONSE_ERROR, 'Stripe')); } @@ -196,7 +197,7 @@ private function createStripeToken( * * @param string $referralApiKey * @param string $stripeObjectId - * @param string @priority + * @param string $priority * @return mixed */ private function createEasypostCreditCard( diff --git a/lib/EasyPost/Service/ShipmentService.php b/lib/EasyPost/Service/ShipmentService.php index 25d65bae..ebc5bab3 100644 --- a/lib/EasyPost/Service/ShipmentService.php +++ b/lib/EasyPost/Service/ShipmentService.php @@ -82,7 +82,7 @@ public function regenerateRates(string $id, mixed $params = null): mixed * Get SmartRates for a shipment. * * @param string $id - * @return array + * @return array */ public function getSmartRates(string $id): array { diff --git a/lib/EasyPost/Service/UserService.php b/lib/EasyPost/Service/UserService.php index b530a099..d9a39e1f 100644 --- a/lib/EasyPost/Service/UserService.php +++ b/lib/EasyPost/Service/UserService.php @@ -70,12 +70,12 @@ public function retrieveMe(): mixed * Delete a user. * * @param string $id - * @param mixed @params - * @return mixed + * @param mixed $params + * @return void */ - public function delete(string $id, mixed $params = null): mixed + public function delete(string $id, mixed $params = null): void { - return $this->deleteResource(self::serviceModelClassName(self::class), $id, $params); + $this->deleteResource(self::serviceModelClassName(self::class), $id, $params); } /** diff --git a/lib/EasyPost/Shipment.php b/lib/EasyPost/Shipment.php index b58f8363..afd90e50 100644 --- a/lib/EasyPost/Shipment.php +++ b/lib/EasyPost/Shipment.php @@ -44,8 +44,8 @@ class Shipment extends EasyPostObject * * To exclude a carrier or service, prepend the string with `!`. * - * @param array|null $carriers - * @param array|null $services + * @param array|null $carriers + * @param array|null $services * @return Rate */ public function lowestRate(?array $carriers = [], ?array $services = []): Rate diff --git a/lib/EasyPost/Util/InternalUtil.php b/lib/EasyPost/Util/InternalUtil.php index 9e2bca52..6ab2cfe2 100644 --- a/lib/EasyPost/Util/InternalUtil.php +++ b/lib/EasyPost/Util/InternalUtil.php @@ -15,6 +15,7 @@ use EasyPost\EasyPostObject; use EasyPost\EndShipper; use EasyPost\Event; +use EasyPost\Exception\General\EasyPostException; use EasyPost\Exception\General\FilteringException; use EasyPost\Fee; use EasyPost\Insurance; @@ -28,6 +29,7 @@ use EasyPost\Report; use EasyPost\ScanForm; use EasyPost\Shipment; +use EasyPost\TaxIdentifier; use EasyPost\Tracker; use EasyPost\TrackingDetail; use EasyPost\TrackingLocation; @@ -173,15 +175,15 @@ public static function convertToEasyPostObject(EasyPostClient|null $client, mixe * * This internal utility is intended to be used by other EasyPost `lowest_rate` functions. * - * @param object EasyPostObject|null - * @param array $carriers - * @param array $services + * @param EasyPostObject|null $easypostObject + * @param array $carriers + * @param array $services * @param string|null $ratesKey * @return Rate|PickupRate - * @throws \EasyPost\Exception\EasyPostException + * @throws EasyPostException */ public static function getLowestObjectRate( - EasyPostObject|null $easypostObject, + ?EasyPostObject $easypostObject, array $carriers = [], array $services = [], ?string $ratesKey = 'rates' diff --git a/lib/EasyPost/Util/Util.php b/lib/EasyPost/Util/Util.php index 4e00e5e4..12b2adce 100644 --- a/lib/EasyPost/Util/Util.php +++ b/lib/EasyPost/Util/Util.php @@ -5,6 +5,7 @@ use EasyPost\Constant\Constants; use EasyPost\EasyPostObject; use EasyPost\Exception\Api\EncodingException; +use EasyPost\Exception\General\EasyPostException; use EasyPost\Exception\General\FilteringException; use EasyPost\Exception\General\InvalidParameterException; use EasyPost\Exception\General\MissingParameterException; @@ -18,7 +19,7 @@ abstract class Util * Convert EasyPost object to an array. * * @param mixed $values - * @return array + * @return array */ public static function convertEasyPostObjectToArray(mixed $values): array { @@ -41,7 +42,7 @@ public static function convertEasyPostObjectToArray(mixed $values): array * * To exclude a carrier or service, prepend the string with `!`. * - * @param array $smartRates + * @param array $smartRates * @param int $deliveryDays * @param string $deliveryAccuracy * @return Rate @@ -140,11 +141,11 @@ public static function receiveEvent(?string $rawInput = null): mixed * Get the lowest stateless rate. * To exclude a carrier or service, prepend the string with `!`. * - * @param array statelessRates - * @param array $carriers - * @param array $services + * @param array $statelessRates + * @param array $carriers + * @param array $services * @return Rate - * @throws \EasyPost\Exception\EasyPostException + * @throws EasyPostException */ public static function getLowestStatelessRate(array $statelessRates, array $carriers = [], array $services = []) { diff --git a/lib/EasyPost/Verification.php b/lib/EasyPost/Verification.php index ffe3a72a..7c50ba5e 100644 --- a/lib/EasyPost/Verification.php +++ b/lib/EasyPost/Verification.php @@ -4,9 +4,9 @@ /** * @package EasyPost - * @param bool success - * @param FieldError[] errors - * @param VerificationDetails details + * @param bool $success + * @param FieldError[] $errors + * @param VerificationDetails $details */ class Verification extends EasyPostObject { diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 00000000..961941fa --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,6 @@ +parameters: + level: 6 + paths: + - lib + - test + checkGenericClassInNonGenericObjectType: false diff --git a/test/EasyPost/AddressTest.php b/test/EasyPost/AddressTest.php index 46911644..63d4b3f4 100644 --- a/test/EasyPost/AddressTest.php +++ b/test/EasyPost/AddressTest.php @@ -10,7 +10,7 @@ class AddressTest extends \PHPUnit\Framework\TestCase { - private static $client; + private static EasyPostClient $client; /** * Setup the testing environment for this file. @@ -32,7 +32,7 @@ public static function tearDownAfterClass(): void /** * Test creating an address. */ - public function testCreate() + public function testCreate(): void { TestUtil::setupCassette('addresses/create.yml'); @@ -48,7 +48,7 @@ public function testCreate() * * We purposefully pass in slightly incorrect data to get the corrected address back once verified. */ - public function testCreateVerify() + public function testCreateVerify(): void { TestUtil::setupCassette('addresses/createVerify.yml'); @@ -65,7 +65,7 @@ public function testCreateVerify() /** * Test creating an address with verify_strict param. */ - public function testCreateVerifyStrict() + public function testCreateVerifyStrict(): void { TestUtil::setupCassette('addresses/createVerifyStrict.yml'); @@ -84,7 +84,7 @@ public function testCreateVerifyStrict() * * We purposefully pass in slightly incorrect data to get the corrected address back once verified. */ - public function testCreateVerifyArray() + public function testCreateVerifyArray(): void { TestUtil::setupCassette('addresses/createVerifyArray.yml'); @@ -101,7 +101,7 @@ public function testCreateVerifyArray() /** * Test retrieving an address. */ - public function testRetrieve() + public function testRetrieve(): void { TestUtil::setupCassette('addresses/retrieve.yml'); @@ -116,7 +116,7 @@ public function testRetrieve() /** * Test retrieving all addresses. */ - public function testAll() + public function testAll(): void { TestUtil::setupCassette('addresses/all.yml'); @@ -134,7 +134,7 @@ public function testAll() /** * Test retrieving next page. */ - public function testGetNextPage() + public function testGetNextPage(): void { TestUtil::setupCassette('addresses/getNextPage.yml'); @@ -161,7 +161,7 @@ public function testGetNextPage() * * We purposefully pass in slightly incorrect data to get the corrected address back once verified. */ - public function testCreateAndVerify() + public function testCreateAndVerify(): void { TestUtil::setupCassette('addresses/createAndVerify.yml'); @@ -177,7 +177,7 @@ public function testCreateAndVerify() /** * Test we can verify an already created address. */ - public function testVerify() + public function testVerify(): void { TestUtil::setupCassette('addresses/verify.yml'); @@ -193,7 +193,7 @@ public function testVerify() /** * Test we throw an error for an invalid address verification. */ - public function testVerifyInvalid() + public function testVerifyInvalid(): void { TestUtil::setupCassette('addresses/verifyInvalid.yml'); diff --git a/test/EasyPost/ApiKeyTest.php b/test/EasyPost/ApiKeyTest.php index e471fd52..39383c9a 100644 --- a/test/EasyPost/ApiKeyTest.php +++ b/test/EasyPost/ApiKeyTest.php @@ -7,7 +7,7 @@ class ApiKeyTest extends \PHPUnit\Framework\TestCase { - private static $client; + private static EasyPostClient $client; /** * Setup the testing environment for this file. @@ -29,7 +29,7 @@ public static function tearDownAfterClass(): void /** * Test retrieving all API keys. */ - public function testAllApiKeys() + public function testAllApiKeys(): void { TestUtil::setupCassette('apiKeys/allApiKeys.yml'); @@ -44,7 +44,7 @@ public function testAllApiKeys() /** * Test retrieving the authenticated user's API keys. */ - public function testAuthenticatedUserApiKeys() + public function testAuthenticatedUserApiKeys(): void { TestUtil::setupCassette('apiKeys/authenticatedUserApiKeys.yml'); @@ -58,7 +58,7 @@ public function testAuthenticatedUserApiKeys() /** * Test retrieving the authenticated user's API keys. */ - public function testChildUserApiKeys() + public function testChildUserApiKeys(): void { TestUtil::setupCassette('apiKeys/childUserApiKeys.yml'); diff --git a/test/EasyPost/BatchTest.php b/test/EasyPost/BatchTest.php index 0e583567..437c4f9d 100644 --- a/test/EasyPost/BatchTest.php +++ b/test/EasyPost/BatchTest.php @@ -7,7 +7,7 @@ class BatchTest extends \PHPUnit\Framework\TestCase { - private static $client; + private static EasyPostClient $client; /** * Setup the testing environment for this file. @@ -29,7 +29,7 @@ public static function tearDownAfterClass(): void /** * Test creating a Batch. */ - public function testCreate() + public function testCreate(): void { TestUtil::setupCassette('batches/create.yml'); @@ -45,7 +45,7 @@ public function testCreate() /** * Test retrieving a Batch. */ - public function testRetrieve() + public function testRetrieve(): void { TestUtil::setupCassette('batches/retrieve.yml'); @@ -62,7 +62,7 @@ public function testRetrieve() /** * Test retrieving all batches. */ - public function testAll() + public function testAll(): void { TestUtil::setupCassette('batches/all.yml'); @@ -80,7 +80,7 @@ public function testAll() /** * Test buying a batch. */ - public function testBuy() + public function testBuy(): void { TestUtil::setupCassette('batches/buy.yml'); @@ -99,9 +99,10 @@ public function testBuy() /** * Test creating a scanform for a batch. */ - public function testCreateScanForm() + public function testCreateScanForm(): void { $cassetteName = 'batches/createScanForm.yml'; + // @phpstan-ignore-next-line $testRequiresWait = true ? file_exists(dirname(__DIR__, 1) . "/cassettes/$cassetteName") === false : false; TestUtil::setupCassette($cassetteName); @@ -125,7 +126,7 @@ public function testCreateScanForm() /** * Test adding and removing a shipment from a batch. */ - public function testAddRemoveShipment() + public function testAddRemoveShipment(): void { TestUtil::setupCassette('batches/addRemoveShipment.yml'); @@ -149,9 +150,10 @@ public function testAddRemoveShipment() /** * Test generating a label for a Batch. */ - public function testLabel() + public function testLabel(): void { $cassetteName = 'batches/label.yml'; + // @phpstan-ignore-next-line $testRequiresWait = true ? file_exists(dirname(__DIR__, 1) . "/cassettes/$cassetteName") === false : false; TestUtil::setupCassette($cassetteName); diff --git a/test/EasyPost/BetaRateTest.php b/test/EasyPost/BetaRateTest.php index 634c9e7f..6ebfe1fd 100644 --- a/test/EasyPost/BetaRateTest.php +++ b/test/EasyPost/BetaRateTest.php @@ -9,7 +9,7 @@ class BetaRateTest extends \PHPUnit\Framework\TestCase { - private static $client; + private static EasyPostClient $client; /** * Setup the testing environment for this file. @@ -31,7 +31,7 @@ public static function tearDownAfterClass(): void /** * Test retrieving stateless rates. */ - public function testRetrieveStatelessRate() + public function testRetrieveStatelessRate(): void { TestUtil::setupCassette('beta/rate/retrieveStatelessRates.yml'); @@ -43,7 +43,7 @@ public function testRetrieveStatelessRate() /** * Test retrieving lowest stateless rate. */ - public function testRetrieveLowestStatelessRate() + public function testRetrieveLowestStatelessRate(): void { TestUtil::setupCassette('beta/rate/retrieveLowestStatelessRates.yml'); diff --git a/test/EasyPost/BetaReferralCustomerTest.php b/test/EasyPost/BetaReferralCustomerTest.php index 2dbaf309..598b7e0b 100644 --- a/test/EasyPost/BetaReferralCustomerTest.php +++ b/test/EasyPost/BetaReferralCustomerTest.php @@ -7,7 +7,7 @@ class BetaReferralCustomerTest extends \PHPUnit\Framework\TestCase { - private static $client; + private static EasyPostClient $client; /** * Setup the testing environment for this file. @@ -33,7 +33,7 @@ public static function tearDownAfterClass(): void * * We expect this test to fail because we don't have valid Stripe details to use. Assert the correct error. */ - public function testAddPaymentMethod() + public function testAddPaymentMethod(): void { TestUtil::setupCassette('beta/referral_customers/addPaymentMethod.yml'); @@ -53,7 +53,7 @@ public function testAddPaymentMethod() * * We expect this test to fail because we don't have valid billing details to use. Assert the correct error. */ - public function testRefundByAmount() + public function testRefundByAmount(): void { TestUtil::setupCassette('beta/referral_customers/refundByAmount.yml'); @@ -72,7 +72,7 @@ public function testRefundByAmount() * * We expect this test to fail because we don't have valid billing details to use. Assert the correct error. */ - public function testRefundByPaymentLog() + public function testRefundByPaymentLog(): void { TestUtil::setupCassette('beta/referral_customers/refundByPaymentLog.yml'); diff --git a/test/EasyPost/BillingTest.php b/test/EasyPost/BillingTest.php index 5f88cbf1..2c05ca5b 100644 --- a/test/EasyPost/BillingTest.php +++ b/test/EasyPost/BillingTest.php @@ -10,7 +10,7 @@ class BillingTest extends \PHPUnit\Framework\TestCase { - private static $client; + private static EasyPostClient $client; /** * Set up the testing environment for this file. @@ -80,7 +80,7 @@ public static function setUpBeforeClass(): void * @param MockingUtility|null $mockUtility * @return EasyPostClient */ - public static function getClient($mockUtility = null) + public static function getClient(MockingUtility $mockUtility = null): EasyPostClient { return new EasyPostClient( getenv('EASYPOST_TEST_API_KEY'), @@ -93,7 +93,7 @@ public static function getClient($mockUtility = null) /** * Test funding a wallet */ - public function testFundWallet() + public function testFundWallet(): void { try { self::$client->billing->fundWallet('2000', 'primary'); @@ -107,7 +107,7 @@ public function testFundWallet() /** * Test funding a wallet without providing a priority level (default value) */ - public function testFundWalletWithNoPriorityLevel() + public function testFundWalletWithNoPriorityLevel(): void { try { self::$client->billing->fundWallet('2000'); @@ -121,7 +121,7 @@ public function testFundWalletWithNoPriorityLevel() /** * Test retrieving a payment method summary */ - public function testRetrievePaymentMethodSummary() + public function testRetrievePaymentMethodSummary(): void { $paymentMethodSummary = self::$client->billing->retrievePaymentMethods(); @@ -133,7 +133,7 @@ public function testRetrievePaymentMethodSummary() /** * Test retrieving a payment method summary that does not have an ID */ - public function testRetrievePaymentMethodSummaryNoId() + public function testRetrievePaymentMethodSummaryNoId(): void { $mockingUtility = new MockingUtility( new MockRequest( @@ -161,7 +161,7 @@ public function testRetrievePaymentMethodSummaryNoId() /** * Test deleting a payment method */ - public function testDeletePaymentMethod() + public function testDeletePaymentMethod(): void { try { self::$client->billing->deletePaymentMethod('primary'); @@ -179,7 +179,7 @@ public function testDeletePaymentMethod() * The payment method is not exposed by this method, so we can't assert against it. * If the function doesn't throw an exception, it worked. */ - public function testGetPaymentMethodPrioritySwitchCase() + public function testGetPaymentMethodPrioritySwitchCase(): void { // testing "primary" try { @@ -212,7 +212,7 @@ public function testGetPaymentMethodPrioritySwitchCase() /** * Test getting a payment method by priority level that has no payment method */ - public function testGetPaymentMethodByPriorityNoPaymentMethod() + public function testGetPaymentMethodByPriorityNoPaymentMethod(): void { $mockingUtility = new MockingUtility( new MockRequest( @@ -244,7 +244,7 @@ public function testGetPaymentMethodByPriorityNoPaymentMethod() /** * Test getting a payment method by priority level that has no payment method ID */ - public function testGetPaymentMethodByPriorityPaymentMethodNoId() + public function testGetPaymentMethodByPriorityPaymentMethodNoId(): void { $mockingUtility = new MockingUtility( new MockRequest( diff --git a/test/EasyPost/CarrierAccountTest.php b/test/EasyPost/CarrierAccountTest.php index f2c03fa2..a1d60495 100644 --- a/test/EasyPost/CarrierAccountTest.php +++ b/test/EasyPost/CarrierAccountTest.php @@ -9,7 +9,7 @@ class CarrierAccountTest extends \PHPUnit\Framework\TestCase { - private static $client; + private static EasyPostClient $client; /** * Setup the testing environment for this file. @@ -31,7 +31,7 @@ public static function tearDownAfterClass(): void /** * Test creating a carrier account. */ - public function testCreate() + public function testCreate(): void { TestUtil::setupCassette('carrier_accounts/create.yml'); @@ -50,7 +50,7 @@ public function testCreate() /** * Test creating a carrier account. */ - public function testCreateWithoutType() + public function testCreateWithoutType(): void { self::$client = new EasyPostClient(getenv('EASYPOST_PROD_API_KEY')); @@ -73,7 +73,7 @@ public function testCreateWithoutType() * We purposefully don't pass data here because real data is required for this endpoint * which we don't have in a test context, simply assert the error matches when no data is passed. */ - public function testCreateWithCustomWorkflow() + public function testCreateWithCustomWorkflow(): void { TestUtil::setupCassette('carrier_accounts/createWithCustomWorkflow.yml'); @@ -84,13 +84,14 @@ public function testCreateWithCustomWorkflow() // We have to send some registration data, otherwise API will throw a 400 Bad Request $data['registration_data'] = ['some' => 'data']; + $errorFound = false; + try { $carrierAccount = self::$client->carrierAccount->create($data); // Delete the carrier account once it's done being tested (should not be reached). self::$client->carrierAccount->delete($carrierAccount->id); } catch (ApiException $error) { $this->assertEquals(422, $error->getHttpStatus()); - $errorFound = false; $errors = $error->errors; foreach ($errors as $error) { if ($error['field'] == 'account_number' && $error['message'] == 'must be present and a string') { @@ -106,7 +107,7 @@ public function testCreateWithCustomWorkflow() /** * Test retrieving a carrier account. */ - public function testRetrieve() + public function testRetrieve(): void { TestUtil::setupCassette('carrier_accounts/retrieve.yml'); @@ -126,7 +127,7 @@ public function testRetrieve() /** * Test retrieving all carrier accounts. */ - public function testAll() + public function testAll(): void { TestUtil::setupCassette('carrier_accounts/all.yml'); @@ -140,7 +141,7 @@ public function testAll() /** * Test updating a carrier account. */ - public function testUpdate() + public function testUpdate(): void { TestUtil::setupCassette('carrier_accounts/update.yml'); @@ -164,7 +165,7 @@ public function testUpdate() /** * Test deleting a carrier account. */ - public function testDelete() + public function testDelete(): void { TestUtil::setupCassette('carrier_accounts/delete.yml'); @@ -183,7 +184,7 @@ public function testDelete() /** * Test retrieving the carrier account types available. */ - public function testTypes() + public function testTypes(): void { TestUtil::setupCassette('carrier_accounts/types.yml'); diff --git a/test/EasyPost/CarrierMetadataTest.php b/test/EasyPost/CarrierMetadataTest.php index 395451ba..259460a2 100644 --- a/test/EasyPost/CarrierMetadataTest.php +++ b/test/EasyPost/CarrierMetadataTest.php @@ -6,7 +6,7 @@ class CarrierMetadataTest extends \PHPUnit\Framework\TestCase { - private static $client; + private static EasyPostClient $client; /** * Setup the testing environment for this file. @@ -28,7 +28,7 @@ public static function tearDownAfterClass(): void /** * Tests that we can retrieve all carriers and all metadata from the API when no params are provided. */ - public function testRetrieveCarrierMetadata() + public function testRetrieveCarrierMetadata(): void { TestUtil::setupCassette('carrier_metadata/retrieveCarrierMetadata.yml'); @@ -56,7 +56,7 @@ public function testRetrieveCarrierMetadata() /** * Tests that we can retrieve metadata based on the filters provided. */ - public function testRetrieveCarrierMetadataWithFilters() + public function testRetrieveCarrierMetadataWithFilters(): void { TestUtil::setupCassette('carrier_metadata/retrieveCarrierMetadataWithFilters.yml'); diff --git a/test/EasyPost/CustomsInfoTest.php b/test/EasyPost/CustomsInfoTest.php index 58eb44fe..d55d7081 100644 --- a/test/EasyPost/CustomsInfoTest.php +++ b/test/EasyPost/CustomsInfoTest.php @@ -7,7 +7,7 @@ class CustomsInfoTest extends \PHPUnit\Framework\TestCase { - private static $client; + private static EasyPostClient $client; /** * Setup the testing environment for this file. @@ -29,7 +29,7 @@ public static function tearDownAfterClass(): void /** * Test creating a CustomsInfo. */ - public function testCreate() + public function testCreate(): void { TestUtil::setupCassette('customs_info/create.yml'); @@ -43,7 +43,7 @@ public function testCreate() /** * Test retrieving a CustomsInfo. */ - public function testRetrieve() + public function testRetrieve(): void { TestUtil::setupCassette('customs_info/retrieve.yml'); diff --git a/test/EasyPost/CustomsItemTest.php b/test/EasyPost/CustomsItemTest.php index c6fe5bc1..b127a507 100644 --- a/test/EasyPost/CustomsItemTest.php +++ b/test/EasyPost/CustomsItemTest.php @@ -7,7 +7,7 @@ class CustomsItemTest extends \PHPUnit\Framework\TestCase { - private static $client; + private static EasyPostClient $client; /** * Setup the testing environment for this file. @@ -29,7 +29,7 @@ public static function tearDownAfterClass(): void /** * Test creating a CustomsItem. */ - public function testCreate() + public function testCreate(): void { TestUtil::setupCassette('customs_items/create.yml'); @@ -43,7 +43,7 @@ public function testCreate() /** * Test retrieving a CustomsItem. */ - public function testRetrieve() + public function testRetrieve(): void { TestUtil::setupCassette('customs_items/retrieve.yml'); diff --git a/test/EasyPost/EasyPostClientTest.php b/test/EasyPost/EasyPostClientTest.php index 9a9d79bd..828e5ae1 100644 --- a/test/EasyPost/EasyPostClientTest.php +++ b/test/EasyPost/EasyPostClientTest.php @@ -4,14 +4,13 @@ use EasyPost\EasyPostClient; use EasyPost\Exception\General\EasyPostException; -use EasyPost\Exception\General\MissingParameterException; class EasyPostClientTest extends \PHPUnit\Framework\TestCase { /** * Test setting and getting the API key for different EasyPostClients. */ - public function testApiKey() + public function testApiKey(): void { $apiKey1 = '123'; $client1 = new EasyPostClient($apiKey1); @@ -28,7 +27,7 @@ public function testApiKey() /** * Test setting and getting the API base. */ - public function testApiBase() + public function testApiBase(): void { $apiBase = 'http://example.com'; @@ -41,7 +40,7 @@ public function testApiBase() /** * Test setting and getting the timeout. */ - public function testTimeout() + public function testTimeout(): void { $timeout = 1.0; @@ -54,11 +53,11 @@ public function testTimeout() /** * Test invalid property (service) called on an EasyPostClient. */ - public function testInvalidServiceProperty() + public function testInvalidServiceProperty(): void { try { $client = new EasyPostClient('123'); - $client->invalidProperty; + $client->invalidProperty; // @phpstan-ignore-line } catch (EasyPostException $error) { $this->assertEquals( 'EasyPost Notice: Undefined property of EasyPostClient instance: invalidProperty', diff --git a/test/EasyPost/EasyPostObjectTest.php b/test/EasyPost/EasyPostObjectTest.php index 45d10169..1ee69d98 100644 --- a/test/EasyPost/EasyPostObjectTest.php +++ b/test/EasyPost/EasyPostObjectTest.php @@ -7,7 +7,7 @@ class EasyPostObjectTest extends \PHPUnit\Framework\TestCase { - private static $client; + private static EasyPostClient $client; /** * Setup the testing environment for this file. @@ -20,7 +20,7 @@ public static function setUpBeforeClass(): void /** * Test using `isset` magic method. */ - public function testIssetMagicMethod() + public function testIssetMagicMethod(): void { $object = InternalUtil::convertToEasyPostObject(self::$client, Fixture::caAddress1()); @@ -32,7 +32,7 @@ public function testIssetMagicMethod() /** * Test using `get` magic method with an invalid property. */ - public function testGetMagicMethodInvalidProperty() + public function testGetMagicMethodInvalidProperty(): void { $object = InternalUtil::convertToEasyPostObject(self::$client, Fixture::caAddress1()); @@ -45,7 +45,7 @@ public function testGetMagicMethodInvalidProperty() /** * Tests that we can print an object correctly. */ - public function testPrintObject() + public function testPrintObject(): void { $object = InternalUtil::convertToEasyPostObject(self::$client, Fixture::caAddress1()); diff --git a/test/EasyPost/EndShipperTest.php b/test/EasyPost/EndShipperTest.php index 74e1e47a..a16967dd 100644 --- a/test/EasyPost/EndShipperTest.php +++ b/test/EasyPost/EndShipperTest.php @@ -7,7 +7,7 @@ class EndShipperTest extends \PHPUnit\Framework\TestCase { - private static $client; + private static EasyPostClient $client; /** * Setup the testing environment for this file. @@ -29,7 +29,7 @@ public static function tearDownAfterClass(): void /** * Test creating an EndShipper. */ - public function testCreate() + public function testCreate(): void { TestUtil::setupCassette('end_shipper/create.yml'); @@ -43,7 +43,7 @@ public function testCreate() /** * Test retrieving an EndShipper. */ - public function testRetrieve() + public function testRetrieve(): void { TestUtil::setupCassette('end_shipper/retrieve.yml'); @@ -58,7 +58,7 @@ public function testRetrieve() /** * Test retrieving all EndShippers. */ - public function testAll() + public function testAll(): void { TestUtil::setupCassette('end_shipper/all.yml'); @@ -76,7 +76,7 @@ public function testAll() /** * Test updating an EndShipper. */ - public function testUpdate() + public function testUpdate(): void { TestUtil::setupCassette('end_shipper/update.yml'); diff --git a/test/EasyPost/ErrorTest.php b/test/EasyPost/ErrorTest.php index 0f14209b..5fb97285 100644 --- a/test/EasyPost/ErrorTest.php +++ b/test/EasyPost/ErrorTest.php @@ -9,7 +9,7 @@ class ErrorTest extends \PHPUnit\Framework\TestCase { - private static $client; + private static EasyPostClient $client; /** * Setup the testing environment for this file. @@ -31,7 +31,7 @@ public static function tearDownAfterClass(): void /** * Test creating a bad shipment and retrieving errors. */ - public function testError() + public function testError(): void { TestUtil::setupCassette('errors/errors.yml'); @@ -60,7 +60,7 @@ public function testError() /** * Test error deserialization with an array of error.message */ - public function testErrorMessageArray() + public function testErrorMessageArray(): void { $errorResponse = json_decode('{ "error": { @@ -80,7 +80,7 @@ public function testErrorMessageArray() /** * Test error deserialization with an Array Map of error.message */ - public function testErrorMessageMap() + public function testErrorMessageMap(): void { $errorResponse = json_decode('{ "error": { @@ -104,7 +104,7 @@ public function testErrorMessageMap() /** * Test error deserialization with an really bad format of error.message */ - public function testErrorMessageBadFormat() + public function testErrorMessageBadFormat(): void { $errorResponse = json_decode('{ "error": { diff --git a/test/EasyPost/EventTest.php b/test/EasyPost/EventTest.php index cd31604c..ea348d4f 100644 --- a/test/EasyPost/EventTest.php +++ b/test/EasyPost/EventTest.php @@ -4,6 +4,7 @@ use EasyPost\EasyPostClient; use EasyPost\Event; +use EasyPost\Exception\Api\ApiException; use EasyPost\Exception\General\EasyPostException; use EasyPost\Exception\General\EndOfPaginationException; use EasyPost\Payload; @@ -12,7 +13,7 @@ class EventTest extends \PHPUnit\Framework\TestCase { - private static $client; + private static EasyPostClient $client; /** * Setup the testing environment for this file. @@ -34,7 +35,7 @@ public static function tearDownAfterClass(): void /** * Test retrieving all events. */ - public function testAll() + public function testAll(): void { TestUtil::setupCassette('events/all.yml'); @@ -52,7 +53,7 @@ public function testAll() /** * Test retrieving next page. */ - public function testGetNextPage() + public function testGetNextPage(): void { TestUtil::setupCassette('events/getNextPage.yml'); @@ -77,7 +78,7 @@ public function testGetNextPage() /** * Test retrieving an event. */ - public function testRetrieve() + public function testRetrieve(): void { TestUtil::setupCassette('events/retrieve.yml'); @@ -94,7 +95,7 @@ public function testRetrieve() /** * Test receiving (converting) an event. */ - public function testReceive() + public function testReceive(): void { $event = Util::receiveEvent(Fixture::eventJson()); @@ -105,7 +106,7 @@ public function testReceive() /** * Test that we throw an error when bad input is received. */ - public function testReceiveBadInput() + public function testReceiveBadInput(): void { $this->expectException(EasyPostException::class); @@ -115,7 +116,7 @@ public function testReceiveBadInput() /** * Test that we throw an error when no input is received. */ - public function testReceiveNoInput() + public function testReceiveNoInput(): void { $this->expectException(EasyPostException::class); @@ -125,9 +126,10 @@ public function testReceiveNoInput() /** * Test retrieving all payloads for an event. */ - public function testRetrieveAllPayloads() + public function testRetrieveAllPayloads(): void { $cassetteName = 'events/retrieve_all_payloads.yml'; + // @phpstan-ignore-next-line $testRequiresWait = true ? file_exists(dirname(__DIR__, 1) . "/cassettes/$cassetteName") === false : false; TestUtil::setupCassette($cassetteName); @@ -165,9 +167,10 @@ public function testRetrieveAllPayloads() /** * Test retrieving a payload for an event. */ - public function testRetrievePayload() + public function testRetrievePayload(): void { $cassetteName = 'events/retrieve_payload.yml'; + // @phpstan-ignore-next-line $testRequiresWait = true ? file_exists(dirname(__DIR__, 1) . "/cassettes/$cassetteName") === false : false; TestUtil::setupCassette($cassetteName); @@ -197,7 +200,7 @@ public function testRetrievePayload() $event->id, 'payload_11111111111111111111111111111111', ); - } catch (EasyPostException $error) { + } catch (ApiException $error) { $this->assertEquals(404, $error->getHttpStatus()); } diff --git a/test/EasyPost/Fixture.php b/test/EasyPost/Fixture.php index 46958061..fbc4921f 100644 --- a/test/EasyPost/Fixture.php +++ b/test/EasyPost/Fixture.php @@ -5,7 +5,7 @@ class Fixture { // Read fixture data from the fixtures JSON file - private static function readFixtureData() + private static function readFixtureData(): mixed { $currentDir = getcwd(); $data = file_get_contents("$currentDir/examples/official/fixtures/client-library-fixtures.json"); @@ -14,14 +14,14 @@ private static function readFixtureData() } // We keep the page_size of retrieving `all` records small so cassettes stay small - public static function pageSize() + public static function pageSize(): int { return self::readFixtureData()['page_sizes']['five_results']; } // This is the USPS carrier account ID that comes with your EasyPost account by // default and should be used for all tests. - public static function uspsCarrierAccountId() + public static function uspsCarrierAccountId(): string { // Fallback to the EasyPost PHP Client Library Test User USPS carrier account ID due to strict matching $uspsCarrierAccountId = getenv('USPS_CARRIER_ACCOUNT_ID') !== false @@ -30,82 +30,112 @@ public static function uspsCarrierAccountId() return $uspsCarrierAccountId; } - public static function usps() + public static function usps(): string { return self::readFixtureData()['carrier_strings']['usps']; } - public static function uspsService() + public static function uspsService(): string { return self::readFixtureData()['service_names']['usps']['first_service']; } - public static function pickupService() + public static function pickupService(): string { return self::readFixtureData()['service_names']['usps']['pickup_service']; } - public static function reportType() + public static function reportType(): string { return self::readFixtureData()['report_types']['shipment']; } - public static function reportDate() + public static function reportDate(): string { return '2022-04-09'; } - public static function webhookUrl() + public static function webhookUrl(): string { return self::readFixtureData()['webhook_url']; } - public static function caAddress1() + /** + * @return array + */ + public static function caAddress1(): array { return self::readFixtureData()['addresses']['ca_address_1']; } - public static function caAddress2() + /** + * @return array + */ + public static function caAddress2(): array { return self::readFixtureData()['addresses']['ca_address_2']; } - public static function incorrectAddress() + /** + * @return array + */ + public static function incorrectAddress(): array { return self::readFixtureData()['addresses']['incorrect']; } - public static function basicParcel() + /** + * @return array + */ + public static function basicParcel(): array { return self::readFixtureData()['parcels']['basic']; } - public static function basicCustomsItem() + /** + * @return array + */ + public static function basicCustomsItem(): array { return self::readFixtureData()['customs_items']['basic']; } - public static function basicCustomsInfo() + /** + * @return array + */ + public static function basicCustomsInfo(): array { return self::readFixtureData()['customs_infos']['basic']; } - public static function taxIdentifier() + /** + * @return array + */ + public static function taxIdentifier(): array { return self::readFixtureData()['tax_identifiers']['basic']; } - public static function basicShipment() + /** + * @return array + */ + public static function basicShipment(): array { return self::readFixtureData()['shipments']['basic_domestic']; } - public static function fullShipment() + /** + * @return array + */ + public static function fullShipment(): array { return self::readFixtureData()['shipments']['full']; } - public static function oneCallBuyShipment() + /** + * @return array + */ + public static function oneCallBuyShipment(): array { return [ 'to_address' => self::caAddress1(), @@ -117,10 +147,14 @@ public static function oneCallBuyShipment() ]; } - // This fixture will require you to add a `shipment` key with a Shipment object from a test. - // If you need to re-record cassettes, increment the date below and ensure it is one day in the future, - // USPS only does "next-day" pickups including Saturday but not Sunday or Holidays. - public static function basicPickup() + /** + * This fixture will require you to add a `shipment` key with a Shipment object from a test. + * If you need to re-record cassettes, increment the date below and ensure it is one day in the future, + * USPS only does "next-day" pickups including Saturday but not Sunday or Holidays. + * + * @return array + */ + public static function basicPickup(): array { $pickupDate = '2023-11-24'; @@ -131,23 +165,34 @@ public static function basicPickup() return $pickupData; } - public static function basicCarrierAccount() + /** + * @return array + */ + public static function basicCarrierAccount(): array { return self::readFixtureData()['carrier_accounts']['basic']; } - // This fixture will require you to add a `tracking_code` key with a tracking code from a shipment - public static function basicInsurance() + + /** + * This fixture will require you to add a `tracking_code` key with a tracking code from a shipment + * + * @return array + */ + public static function basicInsurance(): array { return self::readFixtureData()['insurances']['basic']; } - public static function basicOrder() + /** + * @return array + */ + public static function basicOrder(): array { return self::readFixtureData()['orders']['basic']; } - public static function eventJson() + public static function eventJson(): mixed { $currentDir = getcwd(); $data = file_get_contents("$currentDir/examples/official/fixtures/event-body.json"); @@ -155,7 +200,7 @@ public static function eventJson() return json_encode(json_decode($data, true)); } - public static function eventBytes() + public static function eventBytes(): mixed { $currentDir = getcwd(); $eventBytesFilepath = file("$currentDir/examples/official/fixtures/event-body.json"); @@ -164,20 +209,27 @@ public static function eventBytes() return mb_convert_encoding(json_encode(json_decode($data, true)), 'UTF-8', mb_list_encodings()); } - // The credit card details below are for a valid proxy card usable - // for tests only and cannot be used for real transactions. - // DO NOT alter these details with real credit card information. - public static function creditCardDetails() + /** + * The credit card details below are for a valid proxy card usable + * for tests only and cannot be used for real transactions. + * DO NOT alter these details with real credit card information. + * + * @return array + */ + public static function creditCardDetails(): array { return self::readFixtureData()['credit_cards']['test']; } - public static function rmaFormOtions() + /** + * @return array + */ + public static function rmaFormOtions(): array { return self::readFixtureData()['form_options']['rma']; } - public static function plannedShipDate() + public static function plannedShipDate(): string { return '2023-11-24'; } diff --git a/test/EasyPost/HookTest.php b/test/EasyPost/HookTest.php index 917dc22a..3b6fa713 100644 --- a/test/EasyPost/HookTest.php +++ b/test/EasyPost/HookTest.php @@ -7,7 +7,7 @@ class HookTest extends \PHPUnit\Framework\TestCase { - private static $client; + private static EasyPostClient $client; /** * Setup the testing environment for this file. @@ -28,8 +28,10 @@ public static function tearDownAfterClass(): void /** * Make assertions about a request once the RequestHook fires. + * + * @param array $args */ - public function requestTest($args) + public function requestTest(array $args): void { $this->assertEquals('post', $args['method']); $this->assertEquals('https://api.easypost.com/v2/parcels', $args['path']); @@ -42,7 +44,7 @@ public function requestTest($args) /** * Test that we fire a RequestHook prior to making an HTTP request. */ - public function testRequestHooks() + public function testRequestHooks(): void { TestUtil::setupCassette('hooks/request.yml'); @@ -52,8 +54,10 @@ public function testRequestHooks() /** * Make assertions about a response once the ResponseHook fires. + * + * @param array $args */ - public function responseTest($args) + public function responseTest(array $args): void { $this->assertEquals(201, $args['http_status']); $this->assertEquals('post', $args['method']); @@ -67,7 +71,7 @@ public function responseTest($args) /** * Test that we fire a ResponseHook after receiving an HTTP response. */ - public function testResponseHooks() + public function testResponseHooks(): void { TestUtil::setupCassette('hooks/response.yml'); @@ -78,7 +82,7 @@ public function testResponseHooks() /** * This function should never run since we unsubscribe from HTTP hooks. */ - public function failIfSubscribed() + public function failIfSubscribed(): void { throw new \Exception('Unsubscribing from HTTP hooks did not work as intended'); } @@ -86,7 +90,7 @@ public function failIfSubscribed() /** * Test that we do not fire a hook once unsubscribed. */ - public function testUnsubscribeHooks() + public function testUnsubscribeHooks(): void { TestUtil::setupCassette('hooks/unsubscribe.yml'); diff --git a/test/EasyPost/InsuranceTest.php b/test/EasyPost/InsuranceTest.php index 54f740f4..f0e115bb 100644 --- a/test/EasyPost/InsuranceTest.php +++ b/test/EasyPost/InsuranceTest.php @@ -9,7 +9,7 @@ class InsuranceTest extends \PHPUnit\Framework\TestCase { - private static $client; + private static EasyPostClient $client; /** * Setup the testing environment for this file. @@ -31,7 +31,7 @@ public static function tearDownAfterClass(): void /** * Test creating an insurance object. */ - public function testCreate() + public function testCreate(): void { TestUtil::setupCassette('insurance/create.yml'); @@ -50,7 +50,7 @@ public function testCreate() /** * Test retrieving an insurance object. */ - public function testRetrieve() + public function testRetrieve(): void { TestUtil::setupCassette('insurance/retrieve.yml'); @@ -69,7 +69,7 @@ public function testRetrieve() /** * Test retrieving all insurance. */ - public function testAll() + public function testAll(): void { TestUtil::setupCassette('insurance/all.yml'); @@ -87,7 +87,7 @@ public function testAll() /** * Test retrieving next page. */ - public function testGetNextPage() + public function testGetNextPage(): void { TestUtil::setupCassette('insurance/getNextPage.yml'); diff --git a/test/EasyPost/Mocking/MockingUtility.php b/test/EasyPost/Mocking/MockingUtility.php index 6f5aa044..bf883410 100644 --- a/test/EasyPost/Mocking/MockingUtility.php +++ b/test/EasyPost/Mocking/MockingUtility.php @@ -2,21 +2,33 @@ namespace EasyPost\Test\Mocking; +use EasyPost\Test\Mocking\MockRequest; + class MockingUtility { - public array $mockRequests; + /** + * @var array|MockRequest + */ + public array|MockRequest $mockRequests; /** * Construct a new MockingUtility. * - * @param array $mockRequests + * @param array|MockRequest $mockRequests */ - public function __construct(MockRequest ...$mockRequests) + public function __construct(array|MockRequest ...$mockRequests) { $this->mockRequests = $mockRequests; } - public function findMatchingMockRequest($method, $url) + /** + * Finds a matching mocked request. + * + * @param string $method + * @param string $url + * @return mixed + */ + public function findMatchingMockRequest($method, $url): mixed { foreach ($this->mockRequests as $mockRequest) { $methodMatches = $mockRequest->matchRule->method === '' diff --git a/test/EasyPost/OrderTest.php b/test/EasyPost/OrderTest.php index 8722cc00..423afb08 100644 --- a/test/EasyPost/OrderTest.php +++ b/test/EasyPost/OrderTest.php @@ -9,7 +9,7 @@ class OrderTest extends \PHPUnit\Framework\TestCase { - private static $client; + private static EasyPostClient $client; /** * Setup the testing environment for this file. @@ -31,7 +31,7 @@ public static function tearDownAfterClass(): void /** * Test creating an Order. */ - public function testCreate() + public function testCreate(): void { TestUtil::setupCassette('orders/create.yml'); @@ -45,7 +45,7 @@ public function testCreate() /** * Test retrieving an Order. */ - public function testRetrieve() + public function testRetrieve(): void { TestUtil::setupCassette('orders/retrieve.yml'); @@ -60,7 +60,7 @@ public function testRetrieve() /** * Test retrieving rates for a order. */ - public function testGetRates() + public function testGetRates(): void { TestUtil::setupCassette('orders/getRates.yml'); @@ -77,7 +77,7 @@ public function testGetRates() /** * Test buying an Order. */ - public function testBuy() + public function testBuy(): void { TestUtil::setupCassette('orders/buy.yml'); @@ -101,7 +101,7 @@ public function testBuy() /** * Test buying an Order with a Rate object. */ - public function testBuyRateObject() + public function testBuyRateObject(): void { TestUtil::setupCassette('orders/buyRateObject.yml'); @@ -119,7 +119,7 @@ public function testBuyRateObject() /** * Test various usage alterations of the lowest_rate method. */ - public function testLowestRate() + public function testLowestRate(): void { TestUtil::setupCassette('orders/lowestRate.yml'); diff --git a/test/EasyPost/ParcelTest.php b/test/EasyPost/ParcelTest.php index b4e2ead7..d6d61aad 100644 --- a/test/EasyPost/ParcelTest.php +++ b/test/EasyPost/ParcelTest.php @@ -7,7 +7,7 @@ class ParcelTest extends \PHPUnit\Framework\TestCase { - private static $client; + private static EasyPostClient $client; /** * Setup the testing environment for this file. @@ -29,7 +29,7 @@ public static function tearDownAfterClass(): void /** * Test creating a Parcel. */ - public function testCreate() + public function testCreate(): void { TestUtil::setupCassette('parcels/create.yml'); @@ -43,7 +43,7 @@ public function testCreate() /** * Test retrieving a Parcel. */ - public function testRetrieve() + public function testRetrieve(): void { TestUtil::setupCassette('parcels/retrieve.yml'); diff --git a/test/EasyPost/PickupTest.php b/test/EasyPost/PickupTest.php index a4a31115..b33d532b 100644 --- a/test/EasyPost/PickupTest.php +++ b/test/EasyPost/PickupTest.php @@ -10,7 +10,7 @@ class PickupTest extends \PHPUnit\Framework\TestCase { - private static $client; + private static EasyPostClient $client; /** * Setup the testing environment for this file. @@ -32,7 +32,7 @@ public static function tearDownAfterClass(): void /** * Test creating a pickup. */ - public function testCreate() + public function testCreate(): void { TestUtil::setupCassette('pickups/create.yml'); @@ -51,7 +51,7 @@ public function testCreate() /** * Test retrieving a pickup. */ - public function testRetrieve() + public function testRetrieve(): void { TestUtil::setupCassette('pickups/retrieve.yml'); @@ -70,7 +70,7 @@ public function testRetrieve() /** * Test retrieving all shipments. */ - public function testAll() + public function testAll(): void { TestUtil::setupCassette('pickups/all.yml'); @@ -88,7 +88,7 @@ public function testAll() /** * Test retrieving next page. */ - public function testGetNextPage() + public function testGetNextPage(): void { TestUtil::setupCassette('pickups/getNextPage.yml'); @@ -113,7 +113,7 @@ public function testGetNextPage() /** * Test buying a pickup. */ - public function testBuy() + public function testBuy(): void { TestUtil::setupCassette('pickups/buy.yml'); @@ -141,7 +141,7 @@ public function testBuy() /** * Test cancelling a pickup. */ - public function testCancel() + public function testCancel(): void { TestUtil::setupCassette('pickups/cancel.yml'); @@ -170,7 +170,7 @@ public function testCancel() /** * Test various usage alterations of the lowest_rate method. */ - public function testLowestRate() + public function testLowestRate(): void { TestUtil::setupCassette('pickups/lowestRate.yml'); diff --git a/test/EasyPost/RateTest.php b/test/EasyPost/RateTest.php index 7b831c5e..f13987a8 100644 --- a/test/EasyPost/RateTest.php +++ b/test/EasyPost/RateTest.php @@ -7,7 +7,7 @@ class RateTest extends \PHPUnit\Framework\TestCase { - private static $client; + private static EasyPostClient $client; /** * Setup the testing environment for this file. @@ -29,7 +29,7 @@ public static function tearDownAfterClass(): void /** * Test retrieving a rate. */ - public function testRetrieve() + public function testRetrieve(): void { TestUtil::setupCassette('rates/retrieve.yml'); diff --git a/test/EasyPost/ReferralCustomerTest.php b/test/EasyPost/ReferralCustomerTest.php index 7cc5ddcb..2d9d83be 100644 --- a/test/EasyPost/ReferralCustomerTest.php +++ b/test/EasyPost/ReferralCustomerTest.php @@ -9,8 +9,8 @@ class ReferralCustomerTest extends \PHPUnit\Framework\TestCase { - private static $client; - private static $referralUserProdApiKey; + private static EasyPostClient $client; + private static string $referralUserProdApiKey; /** * Setup the testing environment for this file. @@ -36,7 +36,7 @@ public static function tearDownAfterClass(): void /** * Test creating a child user. */ - public function testCreate() + public function testCreate(): void { TestUtil::setupCassette('referral_customers/create.yml'); @@ -54,7 +54,7 @@ public function testCreate() /** * Test retrieving a child user. */ - public function testAll() + public function testAll(): void { TestUtil::setupCassette('referral_customers/all.yml'); @@ -72,7 +72,7 @@ public function testAll() /** * Test retrieving next page. */ - public function testGetNextPage() + public function testGetNextPage(): void { TestUtil::setupCassette('referral_customers/getNextPage.yml'); @@ -97,7 +97,7 @@ public function testGetNextPage() /** * Test retrieving the authenticated user. */ - public function testUpdateEmail() + public function testUpdateEmail(): void { TestUtil::setupCassette('referral_customers/updateEmail.yml'); @@ -120,7 +120,7 @@ public function testUpdateEmail() * This test requires a partner user's production API key via PARTNER_USER_PROD_API_KEY * as well as one of that user's referral's production API keys via REFERRAL_USER_PROD_API_KEY. */ - public function testReferralAddCreditCard() + public function testReferralAddCreditCard(): void { TestUtil::setupCassette('referral_customers/addCreditCard.yml'); diff --git a/test/EasyPost/RefundTest.php b/test/EasyPost/RefundTest.php index 0ea790db..6762e368 100644 --- a/test/EasyPost/RefundTest.php +++ b/test/EasyPost/RefundTest.php @@ -9,7 +9,7 @@ class RefundTest extends \PHPUnit\Framework\TestCase { - private static $client; + private static EasyPostClient $client; /** * Setup the testing environment for this file. @@ -31,7 +31,7 @@ public static function tearDownAfterClass(): void /** * Test creating a refund. */ - public function testCreate() + public function testCreate(): void { TestUtil::setupCassette('refunds/create.yml'); @@ -51,7 +51,7 @@ public function testCreate() /** * Test retrieving all refunds. */ - public function testAll() + public function testAll(): void { TestUtil::setupCassette('refunds/all.yml'); @@ -64,15 +64,12 @@ public function testAll() $this->assertLessThanOrEqual($refundsArray, Fixture::pageSize()); $this->assertNotNull($refunds['has_more']); $this->assertContainsOnlyInstancesOf(Refund::class, $refundsArray); - - // Return so other tests can reuse these objects - return $refunds; } /** * Test retrieving next page. */ - public function testGetNextPage() + public function testGetNextPage(): void { TestUtil::setupCassette('refunds/getNextPage.yml'); @@ -97,7 +94,7 @@ public function testGetNextPage() /** * Test retrieving a refund. */ - public function testRetrieve() + public function testRetrieve(): void { TestUtil::setupCassette('refunds/retrieve.yml'); diff --git a/test/EasyPost/ReportTest.php b/test/EasyPost/ReportTest.php index a4902e45..dd9b3178 100644 --- a/test/EasyPost/ReportTest.php +++ b/test/EasyPost/ReportTest.php @@ -10,7 +10,7 @@ class ReportTest extends \PHPUnit\Framework\TestCase { - private static $client; + private static EasyPostClient $client; /** * Setup the testing environment for this file. @@ -32,7 +32,7 @@ public static function tearDownAfterClass(): void /** * Test creating a report. */ - public function testCreateReport() + public function testCreateReport(): void { TestUtil::setupCassette('reports/createReport.yml'); @@ -49,7 +49,7 @@ public function testCreateReport() /** * Test creating a report with custom columns */ - public function testCreateCustomColumnReport() + public function testCreateCustomColumnReport(): void { TestUtil::setupCassette('reports/createCustomColumnReport.yml'); @@ -69,7 +69,7 @@ public function testCreateCustomColumnReport() /** * Test creating a report with custom additional columns */ - public function testCreateCustomAdditionalColumnReport() + public function testCreateCustomAdditionalColumnReport(): void { TestUtil::setupCassette('reports/createCustomAdditionalColumnReport.yml'); @@ -89,7 +89,7 @@ public function testCreateCustomAdditionalColumnReport() /** * Test retrieving a report. */ - public function testRetrieveReport() + public function testRetrieveReport(): void { TestUtil::setupCassette('reports/retrieveReport.yml'); @@ -109,7 +109,7 @@ public function testRetrieveReport() /** * Test retrieving all reports. */ - public function testAll() + public function testAll(): void { TestUtil::setupCassette('reports/all.yml'); @@ -128,7 +128,7 @@ public function testAll() /** * Test retrieving next page. */ - public function testGetNextPage() + public function testGetNextPage(): void { TestUtil::setupCassette('reports/getNextPage.yml'); @@ -154,7 +154,7 @@ public function testGetNextPage() /** * Test throwing an error when creating a report with no report type set. */ - public function testCreateNoType() + public function testCreateNoType(): void { $this->expectException(MissingParameterException::class); @@ -164,7 +164,7 @@ public function testCreateNoType() /** * Test throwing an error when retrieving all reports with no report type set. */ - public function testAllNoType() + public function testAllNoType(): void { $this->expectException(MissingParameterException::class); diff --git a/test/EasyPost/RequireTest.php b/test/EasyPost/RequireTest.php index 191d9d41..aaf31891 100644 --- a/test/EasyPost/RequireTest.php +++ b/test/EasyPost/RequireTest.php @@ -9,7 +9,7 @@ class RequireTest extends \PHPUnit\Framework\TestCase * Things like missing or extra imports should be caught by this. The actual assertion here * doesn't matter, only that an import/require error isn't thrown when the test suite runs. */ - public function testRequireLibrary() + public function testRequireLibrary(): void { // Manually require the library to ensure there are no import errors (eg: when the autoloader is not used) require_once('lib/easypost.php'); diff --git a/test/EasyPost/ScanFormTest.php b/test/EasyPost/ScanFormTest.php index 401ca744..755aecf9 100644 --- a/test/EasyPost/ScanFormTest.php +++ b/test/EasyPost/ScanFormTest.php @@ -9,7 +9,7 @@ class ScanFormTest extends \PHPUnit\Framework\TestCase { - private static $client; + private static EasyPostClient $client; /** * Setup the testing environment for this file. @@ -31,7 +31,7 @@ public static function tearDownAfterClass(): void /** * Test creating a scanForm. */ - public function testCreate() + public function testCreate(): void { TestUtil::setupCassette('scanForms/create.yml'); @@ -48,7 +48,7 @@ public function testCreate() /** * Test retrieving a scanForm. */ - public function testRetrieve() + public function testRetrieve(): void { TestUtil::setupCassette('scanForms/retrieve.yml'); @@ -67,7 +67,7 @@ public function testRetrieve() /** * Test retrieving all scanForms. */ - public function testAll() + public function testAll(): void { TestUtil::setupCassette('scanForms/all.yml'); @@ -85,7 +85,7 @@ public function testAll() /** * Test retrieving next page. */ - public function testGetNextPage() + public function testGetNextPage(): void { TestUtil::setupCassette('scanForms/getNextPage.yml'); diff --git a/test/EasyPost/ShipmentTest.php b/test/EasyPost/ShipmentTest.php index 6e3e5d70..6601274d 100644 --- a/test/EasyPost/ShipmentTest.php +++ b/test/EasyPost/ShipmentTest.php @@ -13,7 +13,7 @@ class ShipmentTest extends \PHPUnit\Framework\TestCase { - private static $client; + private static EasyPostClient $client; /** * Setup the testing environment for this file. @@ -35,7 +35,7 @@ public static function tearDownAfterClass(): void /** * Test creating a Shipment. */ - public function testCreate() + public function testCreate(): void { TestUtil::setupCassette('shipments/create.yml'); @@ -44,15 +44,15 @@ public function testCreate() $this->assertInstanceOf(Shipment::class, $shipment); $this->assertStringMatchesFormat('shp_%s', $shipment->id); $this->assertNotNull($shipment->rates); - $this->assertEquals('PNG', $shipment->options->label_format); - $this->assertEquals('123', $shipment->options->invoice_number); + $this->assertEquals('PNG', $shipment->options['label_format']); + $this->assertEquals('123', $shipment->options['invoice_number']); $this->assertEquals('123', $shipment->reference); } /** * Test retrieving a Shipment. */ - public function testRetrieve() + public function testRetrieve(): void { TestUtil::setupCassette('shipments/retrieve.yml'); @@ -67,7 +67,7 @@ public function testRetrieve() /** * Test retrieving all shipments. */ - public function testAll() + public function testAll(): void { TestUtil::setupCassette('shipments/all.yml'); @@ -85,7 +85,7 @@ public function testAll() /** * Test retrieving next page. */ - public function testGetNextPage() + public function testGetNextPage(): void { TestUtil::setupCassette('shipments/getNextPage.yml'); @@ -111,7 +111,7 @@ public function testGetNextPage() /** * Test buying a Shipment. */ - public function testBuy() + public function testBuy(): void { TestUtil::setupCassette('shipments/buy.yml'); @@ -128,7 +128,7 @@ public function testBuy() /** * Test buying a Shipment with a Rate object. */ - public function testBuyRateObject() + public function testBuyRateObject(): void { TestUtil::setupCassette('shipments/buyRateObject.yml'); @@ -142,7 +142,7 @@ public function testBuyRateObject() /** * Test regenerating rates for a shipment. */ - public function testRegenerateRates() + public function testRegenerateRates(): void { TestUtil::setupCassette('shipments/regenerateRates.yml'); @@ -161,7 +161,7 @@ public function testRegenerateRates() /** * Test converting the label format of a Shipment. */ - public function testConvertLabel() + public function testConvertLabel(): void { TestUtil::setupCassette('shipments/convertLabel.yml'); @@ -178,7 +178,7 @@ public function testConvertLabel() /** * Test converting the label format of a Shipment when we don't wrap the format. */ - public function testConvertLabelUnwrappedParam() + public function testConvertLabelUnwrappedParam(): void { TestUtil::setupCassette('shipments/convertLabelUnwrappedParam.yml'); @@ -195,7 +195,7 @@ public function testConvertLabelUnwrappedParam() * If the shipment was purchased with a USPS rate, it must have had its insurance set to `0` when bought * so that USPS doesn't automatically insure it so we could manually insure it here. */ - public function testInsure() + public function testInsure(): void { TestUtil::setupCassette('shipments/insure.yml'); @@ -219,7 +219,7 @@ public function testInsure() * If the shipment was purchased with a USPS rate, it must have had its insurance set to `0` when bought * so that USPS doesn't automatically insure it so we could manually insure it here. */ - public function testInsureUnwrappedParam() + public function testInsureUnwrappedParam(): void { TestUtil::setupCassette('shipments/insureUnwrappedParam.yml'); @@ -241,7 +241,7 @@ public function testInsureUnwrappedParam() * follow a flow of created -> delivered to cycle through tracking events in test mode - as such anything older * than a few seconds in test mode may not be refundable. */ - public function testRefund() + public function testRefund(): void { TestUtil::setupCassette('shipments/refund.yml'); @@ -255,7 +255,7 @@ public function testRefund() /** * Test retrieving SmartRates for a shipment. */ - public function testSmartRate() + public function testSmartRate(): void { TestUtil::setupCassette('shipments/smartrates.yml'); @@ -277,7 +277,7 @@ public function testSmartRate() /** * Test creating a Shipment with empty or null objects and arrays. */ - public function testCreateEmptyObjects() + public function testCreateEmptyObjects(): void { TestUtil::setupCassette('shipments/createEmptyObjects.yml'); @@ -299,7 +299,7 @@ public function testCreateEmptyObjects() /** * Test creating a Shipment with `tax_identifiers`. */ - public function testCreateTaxIdentifiers() + public function testCreateTaxIdentifiers(): void { TestUtil::setupCassette('shipments/createTaxIdentifiers.yml'); @@ -310,13 +310,13 @@ public function testCreateTaxIdentifiers() $this->assertInstanceOf(Shipment::class, $shipment); $this->assertStringMatchesFormat('shp_%s', $shipment->id); - $this->assertEquals('IOSS', $shipment->tax_identifiers[0]['tax_id_type']); + $this->assertEquals('IOSS', $shipment['tax_identifiers'][0]['tax_id_type']); } /** * Test creating a Shipment when only IDs are used. */ - public function testCreateWithIds() + public function testCreateWithIds(): void { TestUtil::setupCassette('shipments/createWithIds.yml'); @@ -341,7 +341,7 @@ public function testCreateWithIds() /** * Test various usage alterations of the lowest_rate method. */ - public function testLowestRate() + public function testLowestRate(): void { TestUtil::setupCassette('shipments/lowestRate.yml'); @@ -370,7 +370,7 @@ public function testLowestRate() /** * Test various usage alterations of the lowestRate method when excluding params by appending `!` to the string. */ - public function testLowestRateExclusions() + public function testLowestRateExclusions(): void { TestUtil::setupCassette('shipments/lowestRateExclusions.yml'); @@ -396,7 +396,7 @@ public function testLowestRateExclusions() * These tests are unfortunately combined because the VCR can't pull cassettes correctly * when testing these two functions in different tests/cassettes. */ - public function testLowestSmartRateVariations() + public function testLowestSmartRateVariations(): void { TestUtil::setupCassette('shipments/lowestSmartRateVariations.yml'); @@ -455,7 +455,7 @@ public function testLowestSmartRateVariations() /** * Tests generating a form for a shipment. */ - public function testGenerateForm() + public function testGenerateForm(): void { TestUtil::setupCassette('shipments/generateForm.yml'); @@ -479,7 +479,7 @@ public function testGenerateForm() /** * Tests buying a shipment with an end shipper. */ - public function testBuyShipmentWithEndShipper() + public function testBuyShipmentWithEndShipper(): void { TestUtil::setupCassette('shipments/buyShipmentWithEndShipper.yml'); @@ -492,7 +492,6 @@ public function testBuyShipmentWithEndShipper() $boughtShipment = self::$client->shipment->buy( $shipment->id, ['rate' => $lowestRate], - false, $endShipper->id ); @@ -502,7 +501,7 @@ public function testBuyShipmentWithEndShipper() /** * Tests that we retrieve time-in-transit data for each of the Rates of a Shipment. */ - public function testRetrieveEstimatedDeliveryDate() + public function testRetrieveEstimatedDeliveryDate(): void { TestUtil::setupCassette('shipments/retrieveEstimatedDeliveryDate.yml'); diff --git a/test/EasyPost/TestUtil.php b/test/EasyPost/TestUtil.php index 332f01da..dd2e32d3 100644 --- a/test/EasyPost/TestUtil.php +++ b/test/EasyPost/TestUtil.php @@ -12,7 +12,7 @@ class TestUtil * * @return void */ - public static function setupVcrTests() + public static function setupVcrTests(): void { VCR::turnOn(); } @@ -22,7 +22,7 @@ public static function setupVcrTests() * * @return void */ - public static function teardownVcrTests() + public static function teardownVcrTests(): void { VCR::eject(); VCR::turnOff(); @@ -34,7 +34,7 @@ public static function teardownVcrTests() * @param string $cassettePath * @return void */ - public static function setupCassette($cassettePath) + public static function setupCassette(string $cassettePath): void { self::checkExpiredCassette($cassettePath); VCR::insertCassette($cassettePath); @@ -43,9 +43,10 @@ public static function setupCassette($cassettePath) /** * Checks for an expired cassette and warns if it is too old and must be re-recorded. * + * @param string $cassettePath * @return void */ - private static function checkExpiredCassette($cassettePath) + private static function checkExpiredCassette(string $cassettePath): void { $fullCassettePath = "test/cassettes/$cassettePath"; $secondsInDay = 86400; diff --git a/test/EasyPost/TrackerTest.php b/test/EasyPost/TrackerTest.php index 582ca7d9..408057eb 100644 --- a/test/EasyPost/TrackerTest.php +++ b/test/EasyPost/TrackerTest.php @@ -9,7 +9,7 @@ class TrackerTest extends \PHPUnit\Framework\TestCase { - private static $client; + private static EasyPostClient $client; /** * Setup the testing environment for this file. @@ -31,7 +31,7 @@ public static function tearDownAfterClass(): void /** * Test creating a Tracker. */ - public function testCreate() + public function testCreate(): void { TestUtil::setupCassette('trackers/create.yml'); @@ -47,7 +47,7 @@ public function testCreate() /** * Test creating a Tracker when we don't wrap the param. */ - public function testCreateUnwrappedParam() + public function testCreateUnwrappedParam(): void { TestUtil::setupCassette('trackers/createUnwrappedParam.yml'); @@ -61,7 +61,7 @@ public function testCreateUnwrappedParam() /** * Test retrieving a Tracker. */ - public function testRetrieve() + public function testRetrieve(): void { TestUtil::setupCassette('trackers/retrieve.yml'); @@ -80,7 +80,7 @@ public function testRetrieve() /** * Test retrieving all trackers. */ - public function testAll() + public function testAll(): void { TestUtil::setupCassette('trackers/all.yml'); @@ -98,7 +98,7 @@ public function testAll() /** * Test retrieving next page. */ - public function testGetNextPage() + public function testGetNextPage(): void { TestUtil::setupCassette('trackers/getNextPage.yml'); @@ -123,7 +123,7 @@ public function testGetNextPage() /** * Tests that we can create a list of bulk trackers with one request. */ - public function testCreateList() + public function testCreateList(): void { TestUtil::setupCassette('trackers/createList.yml'); diff --git a/test/EasyPost/UserTest.php b/test/EasyPost/UserTest.php index 714bc5af..a117c6f8 100644 --- a/test/EasyPost/UserTest.php +++ b/test/EasyPost/UserTest.php @@ -7,7 +7,7 @@ class UserTest extends \PHPUnit\Framework\TestCase { - private static $client; + private static EasyPostClient $client; /** * Setup the testing environment for this file. @@ -29,7 +29,7 @@ public static function tearDownAfterClass(): void /** * Test creating a child user. */ - public function testCreate() + public function testCreate(): void { TestUtil::setupCassette('users/create.yml'); @@ -48,7 +48,7 @@ public function testCreate() /** * Test retrieving a user. */ - public function testRetrieve() + public function testRetrieve(): void { TestUtil::setupCassette('users/retrieve.yml'); @@ -63,7 +63,7 @@ public function testRetrieve() /** * Test retrieving the authenticated user. */ - public function testRetrieveMe() + public function testRetrieveMe(): void { TestUtil::setupCassette('users/retrieveMe.yml'); @@ -76,7 +76,7 @@ public function testRetrieveMe() /** * Test updating the authenticated user. */ - public function testUpdate() + public function testUpdate(): void { TestUtil::setupCassette('users/update.yml'); @@ -96,7 +96,7 @@ public function testUpdate() /** * Test deleting a child user. */ - public function testDelete() + public function testDelete(): void { TestUtil::setupCassette('users/delete.yml'); @@ -115,7 +115,7 @@ public function testDelete() /** * Test updating the authenticated user's Brand. */ - public function testUpdateBrand() + public function testUpdateBrand(): void { TestUtil::setupCassette('users/brand.yml'); diff --git a/test/EasyPost/UtilTest.php b/test/EasyPost/UtilTest.php index a0918d41..c886f5e8 100644 --- a/test/EasyPost/UtilTest.php +++ b/test/EasyPost/UtilTest.php @@ -9,7 +9,7 @@ class UtilTest extends \PHPUnit\Framework\TestCase /** * Test converting an EasyPost object to an array. */ - public function testConvertEasyPostObjectToArray() + public function testConvertEasyPostObjectToArray(): void { $object = Util::convertEasyPostObjectToArray(Fixture::caAddress1()); diff --git a/test/EasyPost/WebhookTest.php b/test/EasyPost/WebhookTest.php index dc2c821d..40576f4b 100644 --- a/test/EasyPost/WebhookTest.php +++ b/test/EasyPost/WebhookTest.php @@ -9,7 +9,7 @@ class WebhookTest extends \PHPUnit\Framework\TestCase { - private static $client; + private static EasyPostClient $client; /** * Setup the testing environment for this file. @@ -31,7 +31,7 @@ public static function tearDownAfterClass(): void /** * Test creating a Webhook. */ - public function testCreate() + public function testCreate(): void { TestUtil::setupCassette('webhooks/create.yml'); @@ -50,7 +50,7 @@ public function testCreate() /** * Test retrieving a Webhook. */ - public function testRetrieve() + public function testRetrieve(): void { TestUtil::setupCassette('webhooks/retrieve.yml'); @@ -70,7 +70,7 @@ public function testRetrieve() /** * Test retrieving all webhooks. */ - public function testAll() + public function testAll(): void { TestUtil::setupCassette('webhooks/all.yml'); @@ -87,7 +87,7 @@ public function testAll() /** * Test updating a Webhook. */ - public function testUpdate() + public function testUpdate(): void { TestUtil::setupCassette('webhooks/update.yml'); @@ -107,7 +107,7 @@ public function testUpdate() /** * Test deleting a Webhook. */ - public function testDelete() + public function testDelete(): void { TestUtil::setupCassette('webhooks/delete.yml'); @@ -127,7 +127,7 @@ public function testDelete() * Test a webhook signature that is originated from EasyPost by comparing the HMAC header * to a shared secret. */ - public function testValidateWebhook() + public function testValidateWebhook(): void { $webhookSecret = 'sécret'; $expectedHmacSignature = 'hmac-sha256-hex=e93977c8ccb20363d51a62b3fe1fc402b7829be1152da9e88cf9e8d07115a46b'; @@ -143,7 +143,7 @@ public function testValidateWebhook() /** * Test a webhook signature that has invalid secret. */ - public function testValidateWebhookInvalidSecret() + public function testValidateWebhookInvalidSecret(): void { $webhookSecret = 'invalid_secret'; $headers = [ @@ -163,7 +163,7 @@ public function testValidateWebhookInvalidSecret() /** * Test a webhook signature does not have HMAC signature header. */ - public function testValidateWebhookMissingSecret() + public function testValidateWebhookMissingSecret(): void { $webhookSecret = '123'; $headers = [ diff --git a/test/cassettes/shipments/buyShipmentWithEndShipper.yml b/test/cassettes/shipments/buyShipmentWithEndShipper.yml index 32616776..a52cb534 100644 --- a/test/cassettes/shipments/buyShipmentWithEndShipper.yml +++ b/test/cassettes/shipments/buyShipmentWithEndShipper.yml @@ -14,8 +14,7 @@ body: '{"address":{"name":"Jack Sparrow","street1":"388 Townsend St","street2":"Apt 20","city":"San Francisco","state":"CA","zip":"94107","country":"US","email":"test@example.com","phone":"5555555555"}}' response: status: - http_version: '1.1' - code: '201' + code: 201 message: Created headers: x-frame-options: SAMEORIGIN @@ -24,57 +23,60 @@ x-download-options: noopen x-permitted-cross-domain-policies: none referrer-policy: strict-origin-when-cross-origin - x-ep-request-uuid: 71ef911b655e64dfe788593d001fbb74 + x-ep-request-uuid: 02ef19156568d1d3e7874da30000c56c cache-control: 'private, no-cache, no-store' pragma: no-cache expires: '0' content-type: 'application/json; charset=utf-8' content-length: '365' - x-runtime: '0.054860' + x-runtime: '0.046775' x-node: bigweb34nuq - x-version-label: easypost-202311212221-a0f06fbc2c-master + x-version-label: easypost-202311301748-2efb918c5f-master x-backend: easypost - x-proxied: ['intlb1nuq b3de2c47ef', 'extlb2nuq 003ad9bca0'] + x-proxied: ['intlb2nuq b3de2c47ef', 'extlb2nuq 003ad9bca0'] strict-transport-security: 'max-age=31536000; includeSubDomains; preload' - body: '{"id":"es_12266117832142d2b0c4eb7324c563a5","object":"EndShipper","mode":"test","created_at":"2023-11-22T20:30:23+00:00","updated_at":"2023-11-22T20:30:23+00:00","name":"JACK SPARROW","company":null,"street1":"388 TOWNSEND ST APT 20","street2":"","city":"SAN FRANCISCO","state":"CA","zip":"94107-1670","country":"US","phone":"","email":""}' + body: '{"id":"es_bd11fd978d1041aa940ff6fa05adc386","object":"EndShipper","mode":"test","created_at":"2023-11-30T18:17:55+00:00","updated_at":"2023-11-30T18:17:55+00:00","name":"JACK SPARROW","company":null,"street1":"388 TOWNSEND ST APT 20","street2":"","city":"SAN FRANCISCO","state":"CA","zip":"94107-1670","country":"US","phone":"","email":""}' curl_info: url: 'https://api.easypost.com/v2/end_shippers' content_type: 'application/json; charset=utf-8' http_code: 201 header_size: 693 - request_size: 506 + request_size: 505 filetime: -1 ssl_verify_result: 0 redirect_count: 0 - total_time: 0.253609 - namelookup_time: 0.001927 - connect_time: 0.067922 - pretransfer_time: 0.133399 + total_time: 0.286097 + namelookup_time: 0.028983 + connect_time: 0.09359 + pretransfer_time: 0.167444 size_upload: 195.0 size_download: 365.0 - speed_download: 1439.0 - speed_upload: 768.0 + speed_download: 1275.0 + speed_upload: 681.0 download_content_length: 365.0 upload_content_length: 195.0 - starttransfer_time: 0.253576 + starttransfer_time: 0.286082 redirect_time: 0.0 redirect_url: '' primary_ip: 169.62.110.130 certinfo: { } primary_port: 443 - local_ip: 10.130.6.39 - local_port: 53440 + local_ip: 10.130.6.25 + local_port: 51772 http_version: 2 protocol: 2 ssl_verifyresult: 0 scheme: HTTPS - appconnect_time_us: 133370 - connect_time_us: 67922 - namelookup_time_us: 1927 - pretransfer_time_us: 133399 + appconnect_time_us: 167168 + connect_time_us: 93590 + namelookup_time_us: 28983 + pretransfer_time_us: 167444 redirect_time_us: 0 - starttransfer_time_us: 253576 - total_time_us: 253609 + starttransfer_time_us: 286082 + total_time_us: 286097 + effective_method: POST + capath: '' + cainfo: '' index: 0 - request: @@ -91,8 +93,7 @@ body: '{"shipment":{"from_address":{"name":"Jack Sparrow","street1":"388 Townsend St","street2":"Apt 20","city":"San Francisco","state":"CA","zip":"94107","country":"US","email":"test@example.com","phone":"5555555555"},"to_address":{"name":"Elizabeth Swan","street1":"179 N Harbor Dr","city":"Redondo Beach","state":"CA","zip":"90277","country":"US","email":"test@example.com","phone":"5555555555"},"parcel":{"length":"10","width":"8","height":"4","weight":"15.4"}}}' response: status: - http_version: '1.1' - code: '201' + code: 201 message: Created headers: x-frame-options: SAMEORIGIN @@ -101,63 +102,66 @@ x-download-options: noopen x-permitted-cross-domain-policies: none referrer-policy: strict-origin-when-cross-origin - x-ep-request-uuid: 71ef9120655e64dfe788593e001fbbe4 + x-ep-request-uuid: 02ef19186568d1d3e7874da40000c5bd cache-control: 'private, no-cache, no-store' pragma: no-cache expires: '0' - location: /api/v2/shipments/shp_562f4b074ef9489e8801ba5b3be01632 + location: /api/v2/shipments/shp_6ce61d3fe8a24882b28b4452e8d3d209 content-type: 'application/json; charset=utf-8' content-length: '6229' - x-runtime: '0.890121' - x-node: bigweb33nuq - x-version-label: easypost-202311212221-a0f06fbc2c-master + x-runtime: '0.674738' + x-node: bigweb41nuq + x-version-label: easypost-202311301748-2efb918c5f-master x-backend: easypost - x-proxied: ['intlb1nuq b3de2c47ef', 'extlb2nuq 003ad9bca0'] + x-proxied: ['intlb2nuq b3de2c47ef', 'extlb2nuq 003ad9bca0'] strict-transport-security: 'max-age=31536000; includeSubDomains; preload' - body: '{"created_at":"2023-11-22T20:30:23Z","is_return":false,"messages":[{"carrier":"DhlEcs","carrier_account_id":"ca_23d193562e8e459bbd937c2aad3dd092","type":"rate_error","message":"Unauthorized. Please check credentials and try again"},{"carrier":"DhlEcs","carrier_account_id":"ca_cb65fc8581184ea38a3108f9e9d1e81c","type":"rate_error","message":"Unauthorized. Please check credentials and try again"},{"carrier":"DhlEcs","carrier_account_id":"ca_cd846680a6f74c23891086de730769d6","type":"rate_error","message":"Unauthorized. Please check credentials and try again"},{"carrier":"DhlEcs","carrier_account_id":"ca_5e8c4f41363b432594441dbf98e4032e","type":"rate_error","message":"Unauthorized. Please check credentials and try again"},{"carrier":"DhlEcs","carrier_account_id":"ca_91e6857e8cb6455180f8ef8a3db8baaa","type":"rate_error","message":"Unauthorized. Please check credentials and try again"}],"mode":"test","options":{"currency":"USD","payment":{"type":"SENDER"},"date_advance":0},"reference":null,"status":"unknown","tracking_code":null,"updated_at":"2023-11-22T20:30:24Z","batch_id":null,"batch_status":null,"batch_message":null,"customs_info":null,"from_address":{"id":"adr_f678dd54897511ee8b1b3cecef1b359e","object":"Address","created_at":"2023-11-22T20:30:23+00:00","updated_at":"2023-11-22T20:30:23+00:00","name":"Jack Sparrow","company":null,"street1":"388 Townsend St","street2":"Apt 20","city":"San Francisco","state":"CA","zip":"94107","country":"US","phone":"","email":"","mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":[]},"insurance":null,"order_id":null,"parcel":{"id":"prcl_90502ae22b8b4582abfd95025d05ea03","object":"Parcel","created_at":"2023-11-22T20:30:23Z","updated_at":"2023-11-22T20:30:23Z","length":10,"width":8,"height":4,"predefined_package":null,"weight":15.4,"mode":"test"},"postage_label":null,"rates":[{"id":"rate_78a1c6d548ad492dbdaa7070d52688fa","object":"Rate","created_at":"2023-11-22T20:30:24Z","updated_at":"2023-11-22T20:30:24Z","mode":"test","service":"Express","carrier":"USPS","rate":"31.25","currency":"USD","retail_rate":"35.80","retail_currency":"USD","list_rate":"31.25","list_currency":"USD","billing_type":"easypost","delivery_days":null,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":null,"shipment_id":"shp_562f4b074ef9489e8801ba5b3be01632","carrier_account_id":"ca_8dc116debcdb49b5a66a2ddee4612600"},{"id":"rate_8dc1ff1b3f76457bbec2625e03b13300","object":"Rate","created_at":"2023-11-22T20:30:24Z","updated_at":"2023-11-22T20:30:24Z","mode":"test","service":"Priority","carrier":"USPS","rate":"6.95","currency":"USD","retail_rate":"10.20","retail_currency":"USD","list_rate":"8.24","list_currency":"USD","billing_type":"easypost","delivery_days":2,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":2,"shipment_id":"shp_562f4b074ef9489e8801ba5b3be01632","carrier_account_id":"ca_8dc116debcdb49b5a66a2ddee4612600"},{"id":"rate_a8cbb8391fa2498d9a29562021f05fa1","object":"Rate","created_at":"2023-11-22T20:30:24Z","updated_at":"2023-11-22T20:30:24Z","mode":"test","service":"GroundAdvantage","carrier":"USPS","rate":"5.93","currency":"USD","retail_rate":"8.00","retail_currency":"USD","list_rate":"6.07","list_currency":"USD","billing_type":"easypost","delivery_days":3,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":3,"shipment_id":"shp_562f4b074ef9489e8801ba5b3be01632","carrier_account_id":"ca_8dc116debcdb49b5a66a2ddee4612600"},{"id":"rate_66a1e16e06f14e4bbf56529ad497cf44","object":"Rate","created_at":"2023-11-22T20:30:24Z","updated_at":"2023-11-22T20:30:24Z","mode":"test","service":"First","carrier":"USPS","rate":"5.93","currency":"USD","retail_rate":"8.00","retail_currency":"USD","list_rate":"6.07","list_currency":"USD","billing_type":"easypost","delivery_days":3,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":3,"shipment_id":"shp_562f4b074ef9489e8801ba5b3be01632","carrier_account_id":"ca_8dc116debcdb49b5a66a2ddee4612600"},{"id":"rate_0961c993a9e349f8b0211e4ceba7c51c","object":"Rate","created_at":"2023-11-22T20:30:24Z","updated_at":"2023-11-22T20:30:24Z","mode":"test","service":"ParcelSelect","carrier":"USPS","rate":"5.93","currency":"USD","retail_rate":"8.00","retail_currency":"USD","list_rate":"6.07","list_currency":"USD","billing_type":"easypost","delivery_days":3,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":3,"shipment_id":"shp_562f4b074ef9489e8801ba5b3be01632","carrier_account_id":"ca_8dc116debcdb49b5a66a2ddee4612600"}],"refund_status":null,"scan_form":null,"selected_rate":null,"tracker":null,"to_address":{"id":"adr_f676b4de897511ee8b193cecef1b359e","object":"Address","created_at":"2023-11-22T20:30:23+00:00","updated_at":"2023-11-22T20:30:23+00:00","name":"Elizabeth Swan","company":null,"street1":"179 N Harbor Dr","street2":null,"city":"Redondo Beach","state":"CA","zip":"90277","country":"US","phone":"","email":"","mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":[]},"usps_zone":4,"return_address":{"id":"adr_f678dd54897511ee8b1b3cecef1b359e","object":"Address","created_at":"2023-11-22T20:30:23+00:00","updated_at":"2023-11-22T20:30:23+00:00","name":"Jack Sparrow","company":null,"street1":"388 Townsend St","street2":"Apt 20","city":"San Francisco","state":"CA","zip":"94107","country":"US","phone":"","email":"","mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":[]},"buyer_address":{"id":"adr_f676b4de897511ee8b193cecef1b359e","object":"Address","created_at":"2023-11-22T20:30:23+00:00","updated_at":"2023-11-22T20:30:23+00:00","name":"Elizabeth Swan","company":null,"street1":"179 N Harbor Dr","street2":null,"city":"Redondo Beach","state":"CA","zip":"90277","country":"US","phone":"","email":"","mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":[]},"forms":[],"fees":[],"id":"shp_562f4b074ef9489e8801ba5b3be01632","object":"Shipment"}' + body: '{"created_at":"2023-11-30T18:17:56Z","is_return":false,"messages":[{"carrier":"DhlEcs","carrier_account_id":"ca_cd846680a6f74c23891086de730769d6","type":"rate_error","message":"Unauthorized. Please check credentials and try again"},{"carrier":"DhlEcs","carrier_account_id":"ca_23d193562e8e459bbd937c2aad3dd092","type":"rate_error","message":"Unauthorized. Please check credentials and try again"},{"carrier":"DhlEcs","carrier_account_id":"ca_5e8c4f41363b432594441dbf98e4032e","type":"rate_error","message":"Unauthorized. Please check credentials and try again"},{"carrier":"DhlEcs","carrier_account_id":"ca_cb65fc8581184ea38a3108f9e9d1e81c","type":"rate_error","message":"Unauthorized. Please check credentials and try again"},{"carrier":"DhlEcs","carrier_account_id":"ca_91e6857e8cb6455180f8ef8a3db8baaa","type":"rate_error","message":"Unauthorized. Please check credentials and try again"}],"mode":"test","options":{"currency":"USD","payment":{"type":"SENDER"},"date_advance":0},"reference":null,"status":"unknown","tracking_code":null,"updated_at":"2023-11-30T18:17:56Z","batch_id":null,"batch_status":null,"batch_message":null,"customs_info":null,"from_address":{"id":"adr_c8bb4f6d8fac11eeb1363cecef1b359e","object":"Address","created_at":"2023-11-30T18:17:55+00:00","updated_at":"2023-11-30T18:17:55+00:00","name":"Jack Sparrow","company":null,"street1":"388 Townsend St","street2":"Apt 20","city":"San Francisco","state":"CA","zip":"94107","country":"US","phone":"","email":"","mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":[]},"insurance":null,"order_id":null,"parcel":{"id":"prcl_29af64a0a1894275b318374eff150e2a","object":"Parcel","created_at":"2023-11-30T18:17:56Z","updated_at":"2023-11-30T18:17:56Z","length":10,"width":8,"height":4,"predefined_package":null,"weight":15.4,"mode":"test"},"postage_label":null,"rates":[{"id":"rate_b093b86bee8b4b12add4c8f0b5e23f8a","object":"Rate","created_at":"2023-11-30T18:17:56Z","updated_at":"2023-11-30T18:17:56Z","mode":"test","service":"Priority","carrier":"USPS","rate":"6.95","currency":"USD","retail_rate":"10.20","retail_currency":"USD","list_rate":"8.24","list_currency":"USD","billing_type":"easypost","delivery_days":2,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":2,"shipment_id":"shp_6ce61d3fe8a24882b28b4452e8d3d209","carrier_account_id":"ca_8dc116debcdb49b5a66a2ddee4612600"},{"id":"rate_11dc01675b394f5ba5eefdd8aa3f1e56","object":"Rate","created_at":"2023-11-30T18:17:56Z","updated_at":"2023-11-30T18:17:56Z","mode":"test","service":"GroundAdvantage","carrier":"USPS","rate":"5.93","currency":"USD","retail_rate":"8.00","retail_currency":"USD","list_rate":"6.07","list_currency":"USD","billing_type":"easypost","delivery_days":3,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":3,"shipment_id":"shp_6ce61d3fe8a24882b28b4452e8d3d209","carrier_account_id":"ca_8dc116debcdb49b5a66a2ddee4612600"},{"id":"rate_fe728b7d36ac4fe392d146b700ef6ff4","object":"Rate","created_at":"2023-11-30T18:17:56Z","updated_at":"2023-11-30T18:17:56Z","mode":"test","service":"First","carrier":"USPS","rate":"5.93","currency":"USD","retail_rate":"8.00","retail_currency":"USD","list_rate":"6.07","list_currency":"USD","billing_type":"easypost","delivery_days":3,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":3,"shipment_id":"shp_6ce61d3fe8a24882b28b4452e8d3d209","carrier_account_id":"ca_8dc116debcdb49b5a66a2ddee4612600"},{"id":"rate_d9b0a0e87b2a49ffb50c7de44116818c","object":"Rate","created_at":"2023-11-30T18:17:56Z","updated_at":"2023-11-30T18:17:56Z","mode":"test","service":"ParcelSelect","carrier":"USPS","rate":"5.93","currency":"USD","retail_rate":"8.00","retail_currency":"USD","list_rate":"6.07","list_currency":"USD","billing_type":"easypost","delivery_days":3,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":3,"shipment_id":"shp_6ce61d3fe8a24882b28b4452e8d3d209","carrier_account_id":"ca_8dc116debcdb49b5a66a2ddee4612600"},{"id":"rate_ecbf216b9e1b47eb90588a33f054bfce","object":"Rate","created_at":"2023-11-30T18:17:56Z","updated_at":"2023-11-30T18:17:56Z","mode":"test","service":"Express","carrier":"USPS","rate":"31.25","currency":"USD","retail_rate":"35.80","retail_currency":"USD","list_rate":"31.25","list_currency":"USD","billing_type":"easypost","delivery_days":null,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":null,"shipment_id":"shp_6ce61d3fe8a24882b28b4452e8d3d209","carrier_account_id":"ca_8dc116debcdb49b5a66a2ddee4612600"}],"refund_status":null,"scan_form":null,"selected_rate":null,"tracker":null,"to_address":{"id":"adr_c8b944398fac11eeba5cac1f6bc539aa","object":"Address","created_at":"2023-11-30T18:17:55+00:00","updated_at":"2023-11-30T18:17:55+00:00","name":"Elizabeth Swan","company":null,"street1":"179 N Harbor Dr","street2":null,"city":"Redondo Beach","state":"CA","zip":"90277","country":"US","phone":"","email":"","mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":[]},"usps_zone":4,"return_address":{"id":"adr_c8bb4f6d8fac11eeb1363cecef1b359e","object":"Address","created_at":"2023-11-30T18:17:55+00:00","updated_at":"2023-11-30T18:17:55+00:00","name":"Jack Sparrow","company":null,"street1":"388 Townsend St","street2":"Apt 20","city":"San Francisco","state":"CA","zip":"94107","country":"US","phone":"","email":"","mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":[]},"buyer_address":{"id":"adr_c8b944398fac11eeba5cac1f6bc539aa","object":"Address","created_at":"2023-11-30T18:17:55+00:00","updated_at":"2023-11-30T18:17:55+00:00","name":"Elizabeth Swan","company":null,"street1":"179 N Harbor Dr","street2":null,"city":"Redondo Beach","state":"CA","zip":"90277","country":"US","phone":"","email":"","mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":[]},"forms":[],"fees":[],"id":"shp_6ce61d3fe8a24882b28b4452e8d3d209","object":"Shipment"}' curl_info: url: 'https://api.easypost.com/v2/shipments' content_type: 'application/json; charset=utf-8' http_code: 201 header_size: 760 - request_size: 767 + request_size: 766 filetime: -1 ssl_verify_result: 0 redirect_count: 0 - total_time: 1.094414 - namelookup_time: 0.001165 - connect_time: 0.065821 - pretransfer_time: 0.132665 + total_time: 0.883991 + namelookup_time: 0.001332 + connect_time: 0.073319 + pretransfer_time: 0.140918 size_upload: 459.0 size_download: 6229.0 - speed_download: 5691.0 - speed_upload: 419.0 + speed_download: 7046.0 + speed_upload: 519.0 download_content_length: 6229.0 upload_content_length: 459.0 - starttransfer_time: 1.094204 + starttransfer_time: 0.883961 redirect_time: 0.0 redirect_url: '' primary_ip: 169.62.110.130 certinfo: { } primary_port: 443 - local_ip: 10.130.6.39 - local_port: 53441 + local_ip: 10.130.6.25 + local_port: 51773 http_version: 2 protocol: 2 ssl_verifyresult: 0 scheme: HTTPS - appconnect_time_us: 132602 - connect_time_us: 65821 - namelookup_time_us: 1165 - pretransfer_time_us: 132665 + appconnect_time_us: 140890 + connect_time_us: 73319 + namelookup_time_us: 1332 + pretransfer_time_us: 140918 redirect_time_us: 0 - starttransfer_time_us: 1094204 - total_time_us: 1094414 + starttransfer_time_us: 883961 + total_time_us: 883991 + effective_method: POST + capath: '' + cainfo: '' index: 0 - request: method: POST - url: 'https://api.easypost.com/v2/shipments/shp_562f4b074ef9489e8801ba5b3be01632/buy' + url: 'https://api.easypost.com/v2/shipments/shp_6ce61d3fe8a24882b28b4452e8d3d209/buy' headers: Host: api.easypost.com Expect: '' @@ -166,11 +170,10 @@ Authorization: '' Content-Type: application/json User-Agent: '' - body: '{"rate":{"id":"rate_a8cbb8391fa2498d9a29562021f05fa1"}}' + body: '{"rate":{"id":"rate_11dc01675b394f5ba5eefdd8aa3f1e56"},"end_shipper_id":"es_bd11fd978d1041aa940ff6fa05adc386"}' response: status: - http_version: '1.1' - code: '200' + code: 200 message: OK headers: x-frame-options: SAMEORIGIN @@ -179,55 +182,58 @@ x-download-options: noopen x-permitted-cross-domain-policies: none referrer-policy: strict-origin-when-cross-origin - x-ep-request-uuid: 71ef9120655e64e0e788593f001fbd7d + x-ep-request-uuid: 02ef19156568d1d4e7874da50000c6b0 cache-control: 'private, no-cache, no-store' pragma: no-cache expires: '0' content-type: 'application/json; charset=utf-8' content-length: '8447' - x-runtime: '0.893604' - x-node: bigweb33nuq - x-version-label: easypost-202311212221-a0f06fbc2c-master + x-runtime: '0.851035' + x-node: bigweb39nuq + x-version-label: easypost-202311301748-2efb918c5f-master x-backend: easypost x-proxied: ['intlb2nuq b3de2c47ef', 'extlb2nuq 003ad9bca0'] strict-transport-security: 'max-age=31536000; includeSubDomains; preload' - body: '{"created_at":"2023-11-22T20:30:23Z","is_return":false,"messages":[{"carrier":"DhlEcs","carrier_account_id":"ca_23d193562e8e459bbd937c2aad3dd092","type":"rate_error","message":"Unauthorized. Please check credentials and try again"},{"carrier":"DhlEcs","carrier_account_id":"ca_cb65fc8581184ea38a3108f9e9d1e81c","type":"rate_error","message":"Unauthorized. Please check credentials and try again"},{"carrier":"DhlEcs","carrier_account_id":"ca_cd846680a6f74c23891086de730769d6","type":"rate_error","message":"Unauthorized. Please check credentials and try again"},{"carrier":"DhlEcs","carrier_account_id":"ca_5e8c4f41363b432594441dbf98e4032e","type":"rate_error","message":"Unauthorized. Please check credentials and try again"},{"carrier":"DhlEcs","carrier_account_id":"ca_91e6857e8cb6455180f8ef8a3db8baaa","type":"rate_error","message":"Unauthorized. Please check credentials and try again"}],"mode":"test","options":{"currency":"USD","payment":{"type":"SENDER"},"date_advance":0},"reference":null,"status":"unknown","tracking_code":"9400100105440282035855","updated_at":"2023-11-22T20:30:25Z","batch_id":null,"batch_status":null,"batch_message":null,"customs_info":null,"from_address":{"id":"adr_f678dd54897511ee8b1b3cecef1b359e","object":"Address","created_at":"2023-11-22T20:30:23+00:00","updated_at":"2023-11-22T20:30:23+00:00","name":"Jack Sparrow","company":null,"street1":"388 Townsend St","street2":"Apt 20","city":"San Francisco","state":"CA","zip":"94107","country":"US","phone":"","email":"","mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":[]},"insurance":"50.00","order_id":null,"parcel":{"id":"prcl_90502ae22b8b4582abfd95025d05ea03","object":"Parcel","created_at":"2023-11-22T20:30:23Z","updated_at":"2023-11-22T20:30:23Z","length":10,"width":8,"height":4,"predefined_package":null,"weight":15.4,"mode":"test"},"postage_label":{"object":"PostageLabel","id":"pl_9dde43ac0a124e2a85ae59bce6e74c1e","created_at":"2023-11-22T20:30:24Z","updated_at":"2023-11-22T20:30:25Z","date_advance":0,"integrated_form":"none","label_date":"2023-11-22T20:30:24Z","label_resolution":300,"label_size":"4x6","label_type":"default","label_file_type":"image\/png","label_url":"https:\/\/easypost-files.s3.us-west-2.amazonaws.com\/files\/postage_label\/20231122\/e8c25bb6e2cb0d4049b1462bcadd164c79.png","label_pdf_url":null,"label_zpl_url":null,"label_epl2_url":null,"label_file":null},"rates":[{"id":"rate_78a1c6d548ad492dbdaa7070d52688fa","object":"Rate","created_at":"2023-11-22T20:30:24Z","updated_at":"2023-11-22T20:30:24Z","mode":"test","service":"Express","carrier":"USPS","rate":"31.25","currency":"USD","retail_rate":"35.80","retail_currency":"USD","list_rate":"31.25","list_currency":"USD","billing_type":"easypost","delivery_days":null,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":null,"shipment_id":"shp_562f4b074ef9489e8801ba5b3be01632","carrier_account_id":"ca_8dc116debcdb49b5a66a2ddee4612600"},{"id":"rate_8dc1ff1b3f76457bbec2625e03b13300","object":"Rate","created_at":"2023-11-22T20:30:24Z","updated_at":"2023-11-22T20:30:24Z","mode":"test","service":"Priority","carrier":"USPS","rate":"6.95","currency":"USD","retail_rate":"10.20","retail_currency":"USD","list_rate":"8.24","list_currency":"USD","billing_type":"easypost","delivery_days":2,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":2,"shipment_id":"shp_562f4b074ef9489e8801ba5b3be01632","carrier_account_id":"ca_8dc116debcdb49b5a66a2ddee4612600"},{"id":"rate_a8cbb8391fa2498d9a29562021f05fa1","object":"Rate","created_at":"2023-11-22T20:30:24Z","updated_at":"2023-11-22T20:30:24Z","mode":"test","service":"GroundAdvantage","carrier":"USPS","rate":"5.93","currency":"USD","retail_rate":"8.00","retail_currency":"USD","list_rate":"6.07","list_currency":"USD","billing_type":"easypost","delivery_days":3,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":3,"shipment_id":"shp_562f4b074ef9489e8801ba5b3be01632","carrier_account_id":"ca_8dc116debcdb49b5a66a2ddee4612600"},{"id":"rate_66a1e16e06f14e4bbf56529ad497cf44","object":"Rate","created_at":"2023-11-22T20:30:24Z","updated_at":"2023-11-22T20:30:24Z","mode":"test","service":"First","carrier":"USPS","rate":"5.93","currency":"USD","retail_rate":"8.00","retail_currency":"USD","list_rate":"6.07","list_currency":"USD","billing_type":"easypost","delivery_days":3,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":3,"shipment_id":"shp_562f4b074ef9489e8801ba5b3be01632","carrier_account_id":"ca_8dc116debcdb49b5a66a2ddee4612600"},{"id":"rate_0961c993a9e349f8b0211e4ceba7c51c","object":"Rate","created_at":"2023-11-22T20:30:24Z","updated_at":"2023-11-22T20:30:24Z","mode":"test","service":"ParcelSelect","carrier":"USPS","rate":"5.93","currency":"USD","retail_rate":"8.00","retail_currency":"USD","list_rate":"6.07","list_currency":"USD","billing_type":"easypost","delivery_days":3,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":3,"shipment_id":"shp_562f4b074ef9489e8801ba5b3be01632","carrier_account_id":"ca_8dc116debcdb49b5a66a2ddee4612600"}],"refund_status":null,"scan_form":null,"selected_rate":{"id":"rate_a8cbb8391fa2498d9a29562021f05fa1","object":"Rate","created_at":"2023-11-22T20:30:25Z","updated_at":"2023-11-22T20:30:25Z","mode":"test","service":"GroundAdvantage","carrier":"USPS","rate":"5.93","currency":"USD","retail_rate":"8.00","retail_currency":"USD","list_rate":"6.07","list_currency":"USD","billing_type":"easypost","delivery_days":3,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":3,"shipment_id":"shp_562f4b074ef9489e8801ba5b3be01632","carrier_account_id":"ca_8dc116debcdb49b5a66a2ddee4612600"},"tracker":{"id":"trk_a7a12a098f474bf4aad85ac94791971c","object":"Tracker","mode":"test","tracking_code":"9400100105440282035855","status":"unknown","status_detail":"unknown","created_at":"2023-11-22T20:30:25Z","updated_at":"2023-11-22T20:30:25Z","signed_by":null,"weight":null,"est_delivery_date":null,"shipment_id":"shp_562f4b074ef9489e8801ba5b3be01632","carrier":"USPS","tracking_details":[],"fees":[],"carrier_detail":null,"public_url":"https:\/\/track.easypost.com\/djE6dHJrX2E3YTEyYTA5OGY0NzRiZjRhYWQ4NWFjOTQ3OTE5NzFj"},"to_address":{"id":"adr_f676b4de897511ee8b193cecef1b359e","object":"Address","created_at":"2023-11-22T20:30:23+00:00","updated_at":"2023-11-22T20:30:24+00:00","name":"ELIZABETH SWAN","company":null,"street1":"179 N HARBOR DR","street2":"","city":"REDONDO BEACH","state":"CA","zip":"90277-2506","country":"US","phone":"","email":"","mode":"test","carrier_facility":null,"residential":false,"federal_tax_id":null,"state_tax_id":null,"verifications":{"zip4":{"success":true,"errors":[],"details":null},"delivery":{"success":true,"errors":[],"details":{"latitude":33.8436,"longitude":-118.39177,"time_zone":"America\/Los_Angeles"}}}},"usps_zone":4,"return_address":{"id":"adr_f678dd54897511ee8b1b3cecef1b359e","object":"Address","created_at":"2023-11-22T20:30:23+00:00","updated_at":"2023-11-22T20:30:23+00:00","name":"Jack Sparrow","company":null,"street1":"388 Townsend St","street2":"Apt 20","city":"San Francisco","state":"CA","zip":"94107","country":"US","phone":"","email":"","mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":[]},"buyer_address":{"id":"adr_f676b4de897511ee8b193cecef1b359e","object":"Address","created_at":"2023-11-22T20:30:23+00:00","updated_at":"2023-11-22T20:30:24+00:00","name":"ELIZABETH SWAN","company":null,"street1":"179 N HARBOR DR","street2":"","city":"REDONDO BEACH","state":"CA","zip":"90277-2506","country":"US","phone":"","email":"","mode":"test","carrier_facility":null,"residential":false,"federal_tax_id":null,"state_tax_id":null,"verifications":{"zip4":{"success":true,"errors":[],"details":null},"delivery":{"success":true,"errors":[],"details":{"latitude":33.8436,"longitude":-118.39177,"time_zone":"America\/Los_Angeles"}}}},"forms":[],"fees":[{"object":"Fee","type":"LabelFee","amount":"0.00000","charged":true,"refunded":false},{"object":"Fee","type":"PostageFee","amount":"5.93000","charged":true,"refunded":false},{"object":"Fee","type":"InsuranceFee","amount":"0.25000","charged":true,"refunded":false}],"id":"shp_562f4b074ef9489e8801ba5b3be01632","object":"Shipment"}' + body: '{"created_at":"2023-11-30T18:17:56Z","is_return":false,"messages":[{"carrier":"DhlEcs","carrier_account_id":"ca_cd846680a6f74c23891086de730769d6","type":"rate_error","message":"Unauthorized. Please check credentials and try again"},{"carrier":"DhlEcs","carrier_account_id":"ca_23d193562e8e459bbd937c2aad3dd092","type":"rate_error","message":"Unauthorized. Please check credentials and try again"},{"carrier":"DhlEcs","carrier_account_id":"ca_5e8c4f41363b432594441dbf98e4032e","type":"rate_error","message":"Unauthorized. Please check credentials and try again"},{"carrier":"DhlEcs","carrier_account_id":"ca_cb65fc8581184ea38a3108f9e9d1e81c","type":"rate_error","message":"Unauthorized. Please check credentials and try again"},{"carrier":"DhlEcs","carrier_account_id":"ca_91e6857e8cb6455180f8ef8a3db8baaa","type":"rate_error","message":"Unauthorized. Please check credentials and try again"}],"mode":"test","options":{"currency":"USD","payment":{"type":"SENDER"},"date_advance":0},"reference":null,"status":"unknown","tracking_code":"9400100105442287323159","updated_at":"2023-11-30T18:17:57Z","batch_id":null,"batch_status":null,"batch_message":null,"customs_info":null,"from_address":{"id":"adr_c8bb4f6d8fac11eeb1363cecef1b359e","object":"Address","created_at":"2023-11-30T18:17:55+00:00","updated_at":"2023-11-30T18:17:55+00:00","name":"Jack Sparrow","company":null,"street1":"388 Townsend St","street2":"Apt 20","city":"San Francisco","state":"CA","zip":"94107","country":"US","phone":"","email":"","mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":[]},"insurance":"50.00","order_id":null,"parcel":{"id":"prcl_29af64a0a1894275b318374eff150e2a","object":"Parcel","created_at":"2023-11-30T18:17:56Z","updated_at":"2023-11-30T18:17:56Z","length":10,"width":8,"height":4,"predefined_package":null,"weight":15.4,"mode":"test"},"postage_label":{"object":"PostageLabel","id":"pl_596f62af811f4a618f658699763ba3d7","created_at":"2023-11-30T18:17:57Z","updated_at":"2023-11-30T18:17:57Z","date_advance":0,"integrated_form":"none","label_date":"2023-11-30T18:17:57Z","label_resolution":300,"label_size":"4x6","label_type":"default","label_file_type":"image\/png","label_url":"https:\/\/easypost-files.s3.us-west-2.amazonaws.com\/files\/postage_label\/20231130\/e8597dfd93262c497fa3b58eb52d9fbe28.png","label_pdf_url":null,"label_zpl_url":null,"label_epl2_url":null,"label_file":null},"rates":[{"id":"rate_b093b86bee8b4b12add4c8f0b5e23f8a","object":"Rate","created_at":"2023-11-30T18:17:56Z","updated_at":"2023-11-30T18:17:56Z","mode":"test","service":"Priority","carrier":"USPS","rate":"6.95","currency":"USD","retail_rate":"10.20","retail_currency":"USD","list_rate":"8.24","list_currency":"USD","billing_type":"easypost","delivery_days":2,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":2,"shipment_id":"shp_6ce61d3fe8a24882b28b4452e8d3d209","carrier_account_id":"ca_8dc116debcdb49b5a66a2ddee4612600"},{"id":"rate_11dc01675b394f5ba5eefdd8aa3f1e56","object":"Rate","created_at":"2023-11-30T18:17:56Z","updated_at":"2023-11-30T18:17:56Z","mode":"test","service":"GroundAdvantage","carrier":"USPS","rate":"5.93","currency":"USD","retail_rate":"8.00","retail_currency":"USD","list_rate":"6.07","list_currency":"USD","billing_type":"easypost","delivery_days":3,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":3,"shipment_id":"shp_6ce61d3fe8a24882b28b4452e8d3d209","carrier_account_id":"ca_8dc116debcdb49b5a66a2ddee4612600"},{"id":"rate_fe728b7d36ac4fe392d146b700ef6ff4","object":"Rate","created_at":"2023-11-30T18:17:56Z","updated_at":"2023-11-30T18:17:56Z","mode":"test","service":"First","carrier":"USPS","rate":"5.93","currency":"USD","retail_rate":"8.00","retail_currency":"USD","list_rate":"6.07","list_currency":"USD","billing_type":"easypost","delivery_days":3,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":3,"shipment_id":"shp_6ce61d3fe8a24882b28b4452e8d3d209","carrier_account_id":"ca_8dc116debcdb49b5a66a2ddee4612600"},{"id":"rate_d9b0a0e87b2a49ffb50c7de44116818c","object":"Rate","created_at":"2023-11-30T18:17:56Z","updated_at":"2023-11-30T18:17:56Z","mode":"test","service":"ParcelSelect","carrier":"USPS","rate":"5.93","currency":"USD","retail_rate":"8.00","retail_currency":"USD","list_rate":"6.07","list_currency":"USD","billing_type":"easypost","delivery_days":3,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":3,"shipment_id":"shp_6ce61d3fe8a24882b28b4452e8d3d209","carrier_account_id":"ca_8dc116debcdb49b5a66a2ddee4612600"},{"id":"rate_ecbf216b9e1b47eb90588a33f054bfce","object":"Rate","created_at":"2023-11-30T18:17:56Z","updated_at":"2023-11-30T18:17:56Z","mode":"test","service":"Express","carrier":"USPS","rate":"31.25","currency":"USD","retail_rate":"35.80","retail_currency":"USD","list_rate":"31.25","list_currency":"USD","billing_type":"easypost","delivery_days":null,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":null,"shipment_id":"shp_6ce61d3fe8a24882b28b4452e8d3d209","carrier_account_id":"ca_8dc116debcdb49b5a66a2ddee4612600"}],"refund_status":null,"scan_form":null,"selected_rate":{"id":"rate_11dc01675b394f5ba5eefdd8aa3f1e56","object":"Rate","created_at":"2023-11-30T18:17:57Z","updated_at":"2023-11-30T18:17:57Z","mode":"test","service":"GroundAdvantage","carrier":"USPS","rate":"5.93","currency":"USD","retail_rate":"8.00","retail_currency":"USD","list_rate":"6.07","list_currency":"USD","billing_type":"easypost","delivery_days":3,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":3,"shipment_id":"shp_6ce61d3fe8a24882b28b4452e8d3d209","carrier_account_id":"ca_8dc116debcdb49b5a66a2ddee4612600"},"tracker":{"id":"trk_67329b8be628457ab48433e7c678d119","object":"Tracker","mode":"test","tracking_code":"9400100105442287323159","status":"unknown","status_detail":"unknown","created_at":"2023-11-30T18:17:57Z","updated_at":"2023-11-30T18:17:57Z","signed_by":null,"weight":null,"est_delivery_date":null,"shipment_id":"shp_6ce61d3fe8a24882b28b4452e8d3d209","carrier":"USPS","tracking_details":[],"fees":[],"carrier_detail":null,"public_url":"https:\/\/track.easypost.com\/djE6dHJrXzY3MzI5YjhiZTYyODQ1N2FiNDg0MzNlN2M2NzhkMTE5"},"to_address":{"id":"adr_c8b944398fac11eeba5cac1f6bc539aa","object":"Address","created_at":"2023-11-30T18:17:55+00:00","updated_at":"2023-11-30T18:17:57+00:00","name":"ELIZABETH SWAN","company":null,"street1":"179 N HARBOR DR","street2":"","city":"REDONDO BEACH","state":"CA","zip":"90277-2506","country":"US","phone":"","email":"","mode":"test","carrier_facility":null,"residential":false,"federal_tax_id":null,"state_tax_id":null,"verifications":{"zip4":{"success":true,"errors":[],"details":null},"delivery":{"success":true,"errors":[],"details":{"latitude":33.8436,"longitude":-118.39177,"time_zone":"America\/Los_Angeles"}}}},"usps_zone":4,"return_address":{"id":"adr_c8bb4f6d8fac11eeb1363cecef1b359e","object":"Address","created_at":"2023-11-30T18:17:55+00:00","updated_at":"2023-11-30T18:17:55+00:00","name":"Jack Sparrow","company":null,"street1":"388 Townsend St","street2":"Apt 20","city":"San Francisco","state":"CA","zip":"94107","country":"US","phone":"","email":"","mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":[]},"buyer_address":{"id":"adr_c8b944398fac11eeba5cac1f6bc539aa","object":"Address","created_at":"2023-11-30T18:17:55+00:00","updated_at":"2023-11-30T18:17:57+00:00","name":"ELIZABETH SWAN","company":null,"street1":"179 N HARBOR DR","street2":"","city":"REDONDO BEACH","state":"CA","zip":"90277-2506","country":"US","phone":"","email":"","mode":"test","carrier_facility":null,"residential":false,"federal_tax_id":null,"state_tax_id":null,"verifications":{"zip4":{"success":true,"errors":[],"details":null},"delivery":{"success":true,"errors":[],"details":{"latitude":33.8436,"longitude":-118.39177,"time_zone":"America\/Los_Angeles"}}}},"forms":[],"fees":[{"object":"Fee","type":"LabelFee","amount":"0.00000","charged":true,"refunded":false},{"object":"Fee","type":"PostageFee","amount":"5.93000","charged":true,"refunded":false},{"object":"Fee","type":"InsuranceFee","amount":"0.25000","charged":true,"refunded":false}],"id":"shp_6ce61d3fe8a24882b28b4452e8d3d209","object":"Shipment"}' curl_info: - url: 'https://api.easypost.com/v2/shipments/shp_562f4b074ef9489e8801ba5b3be01632/buy' + url: 'https://api.easypost.com/v2/shipments/shp_6ce61d3fe8a24882b28b4452e8d3d209/buy' content_type: 'application/json; charset=utf-8' http_code: 200 header_size: 689 - request_size: 403 + request_size: 458 filetime: -1 ssl_verify_result: 0 redirect_count: 0 - total_time: 1.088988 - namelookup_time: 0.001049 - connect_time: 0.06314 - pretransfer_time: 0.131047 - size_upload: 55.0 + total_time: 1.057047 + namelookup_time: 0.001436 + connect_time: 0.066092 + pretransfer_time: 0.138144 + size_upload: 110.0 size_download: 8447.0 - speed_download: 7756.0 - speed_upload: 50.0 + speed_download: 7991.0 + speed_upload: 104.0 download_content_length: 8447.0 - upload_content_length: 55.0 - starttransfer_time: 1.088667 + upload_content_length: 110.0 + starttransfer_time: 1.056988 redirect_time: 0.0 redirect_url: '' primary_ip: 169.62.110.130 certinfo: { } primary_port: 443 - local_ip: 10.130.6.39 - local_port: 53442 + local_ip: 10.130.6.25 + local_port: 51774 http_version: 2 protocol: 2 ssl_verifyresult: 0 scheme: HTTPS - appconnect_time_us: 130837 - connect_time_us: 63140 - namelookup_time_us: 1049 - pretransfer_time_us: 131047 + appconnect_time_us: 138040 + connect_time_us: 66092 + namelookup_time_us: 1436 + pretransfer_time_us: 138144 redirect_time_us: 0 - starttransfer_time_us: 1088667 - total_time_us: 1088988 + starttransfer_time_us: 1056988 + total_time_us: 1057047 + effective_method: POST + capath: '' + cainfo: '' index: 0