Giter Site home page Giter Site logo

lob-php's People

Contributors

aarondfrancis avatar amaan-lob avatar ami avatar amrit avatar bennykitchell avatar brianseitel avatar charlesbjohnson avatar daniloassis avatar dependabot[bot] avatar dmlittle avatar elnaz avatar forbaokhanh avatar graysonchao avatar haroutrs avatar jho44 avatar joshstrange avatar leore avatar mpiercy827 avatar mriosdandb avatar mrkaspa avatar mwj8410 avatar ph-7 avatar pon avatar robinjoseph08 avatar russelltaylor05 avatar senechko avatar shrav avatar siddharthpant92 avatar sishaarrao avatar sudoku-lord avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lob-php's Issues

Expose Rate Limit headers

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

Change Guzzle dependency to guzzlehttp/guzzle

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.

Call to a member function getBody() on null

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();

    // ...

Different issues related to Enums on PHP7

Summary

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.

Expected Behavior

The package should work normally on PHP 7 or the requirement should be different.

Current Behavior

syntax error, unexpected 'PostcardSize' (T_STRING)

PostcardSize is an Enum

Steps to Reproduce

(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";

Context (Environment)

  • I got the same exception with any API method that uses Enums.
  • I am using PHP 7.4.6 and Laravel 6.
  • If there is another way to use the library that works on PHP 7 that would be awesome.

Parent class for LOB exceptions

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.

Bad Method Signature

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

Misleading authentication example

Summary

The documentation on authentication is very misleading. There is no username or password in lob account for basic authentication. It only provides api keys.

Current Behavior

// Configure HTTP basic authorization: basicAuth
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()
              ->setUsername('YOUR_USERNAME')
              ->setPassword('YOUR_PASSWORD');

Possible Solution

This is the correct way to have configuration:


// Configure HTTP basic authorization: basicAuth
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()
              ->setApiKey('basic', 'API_KEY);

Armenia is not supported

Summary

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.

Expected Behavior

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

Current Behavior

AM / ARMENIA is not a supported country.

Possible Solution

Add AM / ARMENIA as one of the supported countries.

Steps to Reproduce

  1. \OpenAPI\Client\Model\CountryExtended::from('AM')
  2. See exception: "AM" is not a valid backing value for enum OpenAPI\Client\Model\CountryExtended

@ symbol causing error.

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?

bad error message if user account does not have scheduled mailing ability

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.

Invalid type in PHPDoc block for AddressEditable::setAddressCountry

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

How i can get Error Code?

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.

Fatal error

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'
));

print_r($check);

I get this issue when invalid address. Any idea?

Fatal error: Uncaught exception ResourceNotFoundException

CURL Reset Error

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.

Library has incorrect PSR-4 namespace

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.

Exception Handling Issue during International Address Verification

Summary

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.

image

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:

  1. Modify the response from the Lob service to send the coverage in uppercase to match the SDK's expectations.
  2. Alternatively, you can modify the SDK code by adding strtoupper($coverage) as the first parameter of the in_array method.

Steps to Reproduce

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);

Context (Environment)

Version: 4.2.0

Update Existing Address

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?

Are non-US states optional or still required?

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!

Correctly catch 429s

An additional if statement needs to be added to src/Lob/Resource.php so 429's don't get returned as UnexpectedErrorException.

merge_variables not allowed

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.