lob-php icon indicating copy to clipboard operation
lob-php copied to clipboard

Invalid type in PHPDoc block for AddressEditable::setAddressCountry

Open alies-dev opened this issue 2 years ago • 0 comments

Summary

\OpenAPI\Client\Model\AddressEditable::setAddressCountry declared to accept @param \OpenAPI\Client\Model\CountryExtended|null $address_country address_country (where CountryExtended is enum), but it doesn't work with enums: it failed with Invalid address. Code: address_country must be a string RequestException on calling \OpenAPI\Client\Api\AddressesApi::create.

Stacktrace:

/var/www/vendor/lob/lob-php/lib/Api/AddressesApi.php:197
/var/www/vendor/lob/lob-php/lib/Api/AddressesApi.php:166

Snippet to test:

$addressApi = new AddressesApi($config);

$editableAddress = new AddressEditable();
$editableAddress->setAddressCountry(\OpenAPI\Client\Model\CountryExtended::AE);

$createdAddress = $addressApi->create($editableAddress);

Workaround solution:

-$editableAddress->setAddressCountry(\OpenAPI\Client\Model\CountryExtended::AE);
+$editableAddress->setAddressCountry(\OpenAPI\Client\Model\CountryExtended::AE->value);

PS: I have not tested other cases where this enum used in PHPDoc, there are few: image

alies-dev avatar Apr 07 '23 08:04 alies-dev