lob / lob-php Goto Github PK
View Code? Open in Web Editor NEWPHP Client for Lob API
Home Page: https://lob.com
License: MIT License
PHP Client for Lob API
Home Page: https://lob.com
License: MIT License
I'm currently validating a metric crap-ton of county data and wanted to give you some feedback on an error I've gotten. (This is all public data, so I haven't blanked anything out.)
Given this data:
{
"owner_id": "194249",
"owner_name": "BAHR D E",
"owner_care_of": null,
"owner_addr_1": "@ DE ZIMMERMANN",
"owner_addr_2": "P O BOX 23",
"owner_addr_3": null,
"owner_city": "SANTA FE",
"owner_state": "TX",
"owner_zip": "77517",
"owner_zip_4": "0023",
}
I get the following error:
[2018-01-08 17:16:29] local.ERROR: fopen( DE ZIMMERMANN): failed to open stream: No such file or directory {"exception":"[object] (ErrorException(code: 0): fopen( DE ZIMMERMANN): failed to open stream: No such file or directory at /project/vendor/lob/lob-php/src/Lob/Resource.php:200)
I assume the county is using @
to represent "Care Of", but it's clearly mucking things up.
Can you add a safeguard check to Resource.php
?
[Lob\Exception\UnexpectedErrorException]
An Unexpected Error has occurred.
Can anyone please explain??
(I was trying with test api key)
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'”.
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.
The SDK is throwing an exception, as mentioned before, when attempting to verify an international address.
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 the in_array
method.Using a simple code like this, leads to same error:
$verificationApi = new IntlVerificationsApi($this->config);
$verificationWritable = new IntlVerificationWritable([
'recipient' => $recipientFullname,
'primary_line' => $address->addressLine1,
'secondary_line' => $address->addressLine2,
'city' => $address->city,
'state' => $address->state,
'postal_code' => $address->postalCode,
'country' => $address->country->code,
]);
$verification = $verificationApi->verifySingle($verificationWritable);
Version: 4.2.0
This is what i requested:
require '../vendor/autoload.php';
$lob = new \Lob\Lob('TEST_KEY');
$check = $lob->addresses()->verify(array(
'address_line1' => '185 Berry Street234',
'address_city' => 'San Francisco',
'address_state' => 'CA',
'address_zip' => '94107'
));
I get this issue when invalid address. Any idea?
Fatal error: Uncaught exception ResourceNotFoundException
Hey!
I'm just working with your API and got confused when I saw the // required
comment next to the address_state
. What if I have customers in say Denmark, where there are no states? And what about other stateless countries? Will it then not be possible to send a print job to you or?
Hope you can clarify. :-)
Have a great day!
Hi,
I am getting this error on staging server:
PHP Fatal error: Call to undefined function GuzzleHttp\Handler\curl_reset() in /home/........./vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php on line 78
.
PHP version is 5.4
Please help.
Declaration of Lob\Resource\USVerifications::create(array $data) must be compatible with Lob\Resource::create(array $data, ?array $headers = NULL)
The US Verifications class extends the Lob\Resource class, but the create signatures don't match
\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:
The ISO 3166 country code of Armenia is AM
. Armenia is not included in the CountryExtended
nor CountryExtendedExpanded
enum. Please correct me if it is on purpose and Armenia is indeed an unsupported country.
The enums should include AM
/ ARMENIA
as one of the possible values.
https://github.com/lob/lob-php/blob/main/lib/Model/CountryExtended.php
https://github.com/lob/lob-php/blob/main/lib/Model/CountryExtendedExpanded.php
AM
/ ARMENIA
is not a supported country.
Add AM
/ ARMENIA
as one of the supported countries.
\OpenAPI\Client\Model\CountryExtended::from('AM')
"AM" is not a valid backing value for enum OpenAPI\Client\Model\CountryExtended
I'm getting a fatal error with this library when attempting to pass merge variables:
Uncaught Lob\Exception\ValidationException: merge_variables is not allowed
This is just passing a simple string value, i.e.:
'merge_variables' => array( 'expiration_date' => $expiration_date )
I also tried this parameter format with no luck:
merge_variables[expiration_date] => $expiration_date
I'm running PHP 7.x
The requirement for the latest version of this package is "PHP 7.3 and later" but PHP 7.X doesn't support Enums so I am getting errors on serialization.
The package should work normally on PHP 7 or the requirement should be different.
syntax error, unexpected 'PostcardSize' (T_STRING)
(new LettersApi($config, $guzzleClient))->create(new LetterEditable($data));
--> Exception: syntax error, unexpected 'PostcardSize' (T_STRING)
--> /var/www/vendor/lob/lob-php/lib/ObjectSerializer.php:93
--> FYI: $data['size'] === "4x6";
I get this message when installing:
Package guzzle/guzzle is abandoned, you should avoid using it. Use guzzlehttp/guzzle instead.
Should be as easy as changing the package name in composer. Also just to note you are using guzzle 3 and guzzle 6 is out now, not a huge deal just thought I'd throw that out there.
Im not sure if I am overlooking this, but I think there needs to be a PUT method to update addresses. I am running into issues with having to delete addresses for a user just to update their address in Lob. Is there another way?
Add ability to specify API version in the headers, like 2015-11-23
.
A great addition to the PHP API would be Rate Limiting info. While using the API, a RateLimiting exception is shows if this happens, but with no additional info.
Each API requests has this kind of data in headers but there's no way to access it.
Adding a method to access the headers on requests would solve this
Cheers
Hi, it would be great that any exception thrown by LOB library extends a parent LobException class.
Right now it is kind of annoying to catch LOB exceptions because it requires either to try/catch every single type of LOB exception or make a try / catch on the PHP base class Exception and most of the time you don't want to do that.
This library has its code generated in the \OpenAPI\Client
namespace, which is likely the default configuration for the code generator that was used. This would conflict with any other library that used the same configuration.
it should likely be something like \Lob\Client
instead.
An additional if statement needs to be added to src/Lob/Resource.php
so 429's don't get returned as UnexpectedErrorException
.
The documentation on authentication is very misleading. There is no username or password in lob account for basic authentication. It only provides api keys.
// Configure HTTP basic authorization: basicAuth
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()
->setUsername('YOUR_USERNAME')
->setPassword('YOUR_PASSWORD');
This is the correct way to have configuration:
// Configure HTTP basic authorization: basicAuth
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()
->setApiKey('basic', 'API_KEY);
Older API's had an error message like 'scheduled mailings' if the user's account did not have the ability to send a mailing with a 'send_date', which was an Authorization Exception. This was useful so an automated mailer could retry without a send_date in this instance.
Now the API only returns the message 'Forbidden', a Forbidden Exception, which is not enough information to try to send again without a send_date.
LOB explaig error codes here.
https://lob.com/docs/php#errors
I am using address verification. How i can get error codes? Does lop-php implemented error code?
try { $check = $lob->addresses()->verify(array( 'address_line1' => $billing_address, 'address_city' => $billing_city, 'address_state' => $billing_state, 'address_zip' => $billing_zip, 'address_country' => $billing_country )); } catch (Lob\Exception\ResourceNotFoundException $e) {}
Or Is there a other way to check address verification instead of exception?
Thanks in advance.
Also Is there a way to check if LOB is active? Sometime it will down and API request fail.
Hey again,
I'm getting another error from time to time in a catch block.
The exception:
Call to a member function getBody() on null at vendor/lob/lob-php/src/Lob/Resource.php:107)
in Resource.php:107, which is (in my version)
} catch (GuzzleException $e) {
// The line below
$responseErrorBody = strval($e->getResponse()->getBody());
$errorMessage = $this->errorMessageFromJsonBody($responseErrorBody);
$statusCode = $e->getResponse()->getStatusCode();
// ...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.