You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We encountered an InvalidArgumentException while utilizing your SDK to verify an international address:
Failed to send a postcard using Lob: “Invalid value 'Housenumber/Building' for 'coverage', must be one of 'SUBBUILDING', 'HOUSENUMBER/BUILDING', 'STREET', 'LOCALITY', 'SPARSE'”.
Expected Behavior
In this case, the exception should not be thrown since the response from the Lob service is Housenumber/Building, whereas the SDK expects it to be in uppercase as HOUSENUMBER/BUILDING. It's worth noting that PHP's in_array method is case-sensitive.
Current Behavior
The SDK is throwing an exception, as mentioned before, when attempting to verify an international address.
Possible Solution
To address the issue, there are two potential solutions:
Modify the response from the Lob service to send the coverage in uppercase to match the SDK's expectations.
Invalid value 'Housenumber/Building' for 'coverage', must be one of 'SUBBUILDING', 'HOUSENUMBER/BUILDING', 'STREET', 'LOCALITY', 'SPARSE'
and
Invalid value 'Subbuilding' for 'coverage', must be one of 'SUBBUILDING', 'HOUSENUMBER/BUILDING', 'STREET', 'LOCALITY', 'SPARSE'
Exception message is confusing
Example of API response:
{
"id": "intl_ver_bf83dde51d4d738acd4a",
"recipient": "John Zorn",
"primary_line": "THE UNIVERSITY OF MELBOURNE, THOMAS CHERRY BUILDING, LEVEL 1",
"secondary_line": "",
"last_line": "MELBOURNE VIC 3010",
"country": "AU",
"coverage": "Subbuilding",
"deliverability": "deliverable_missing_info",
"status": "2",
"components": {
"primary_number": "",
"building": "",
"street_name": "THE UNIVERSITY OF MELBOURNE, THOMAS CHERRY BUILDING, LEVEL 1",
"locality": "",
"city": "MELBOURNE",
"state": "VIC",
"postal_code": "3010"
},
"object": "intl_verification"
}
Please note to the "coverage": "Subbuilding" part - it has a wrong case (should be SUBBUILDING)
But \OpenAPI\Client\Model\IntlVerification::getCoverageAllowableValues returns uppercase options only:
And similar issue with \OpenAPI\Client\Model\IntlVerification::setStatus method: API uses numeric values (1, 2, 3, 4), but this method accepts only string values prefixed by LV:
I'll create a PR to solve both issues
UPD: Sorry, it's not possible to fix \OpenAPI\Client\Model\IntlVerification::setStatus on this library level: when this method accept a numeric string (e.g. 1), we don't how to properly prefix the string because there are few possible prefixes (LV, LF, LM, LU. see the screenshot above). So, the only solution is to fix server response or lose IntlVerification validation in setCoverage and setStatus methods
Summary
We encountered an
InvalidArgumentException
while utilizing your SDK to verify an international address:Expected Behavior
In this case, the exception should not be thrown since the response from the Lob service is
Housenumber/Building
, whereas the SDK expects it to be in uppercase asHOUSENUMBER/BUILDING
. It's worth noting that PHP'sin_array
method is case-sensitive.Current Behavior
The SDK is throwing an exception, as mentioned before, when attempting to verify an international address.
Possible Solution
To address the issue, there are two potential solutions:
coverage
in uppercase to match the SDK's expectations.strtoupper($coverage)
as the first parameter of thein_array
method.Steps to Reproduce
Using a simple code like this, leads to same error:
Context (Environment)
Version: 4.2.0
The text was updated successfully, but these errors were encountered: