lob / lob-php

PHP Client for Lob API
https://lob.com
MIT License
67 stars 21 forks source link

Invalid type in PHPDoc block for AddressEditable::setAddressCountry #170

Open alies-dev opened 1 year ago

alies-dev commented 1 year ago

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