Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow for http adapter param #636

Open
wants to merge 1 commit into
base: v3-v2021-02-25
Choose a base branch
from

Conversation

saas786
Copy link

@saas786 saas786 commented Sep 28, 2021

  • Base client class now accepts Http Adapter object as param.
  • Add http adapter interface.

@SinusPi
Copy link

SinusPi commented Mar 3, 2022

This seems like a useful PR, I'd happily write a curl variant for my needs. What's missing for this to be merged? I could think of adding implements HttpAdapterInterface to the HttpAdapter class definition, I guess, but is that what's wrong here?

@saas786
Copy link
Author

saas786 commented Mar 4, 2022

This seems like a useful PR, I'd happily write a curl variant for my needs. What's missing for this to be merged? I could think of adding implements HttpAdapterInterface to the HttpAdapter class definition, I guess, but is that what's wrong here?

I have been using my fork with this PR.

But in order to be merged into core, core needs to implement error handling using PSR I guess, that way, if I just merge this PR, it should work without issues.

But with current implementation regarding error handling, this can break error handling, you will have to write your own error handlers.

@SinusPi
Copy link

SinusPi commented Mar 4, 2022 via email

@saas786
Copy link
Author

saas786 commented Mar 4, 2022

I am not blaming somebody here...

I might be wrong...

But this doesn't work when I use Guzzle Client:

        try{}
        catch (\Recurly\Errors\Validation $e) {}
        catch (\Recurly\Errors\NotFound $e) {}
        catch (\Recurly\RecurlyError $e) {}

but only this work:

        try{}
        catch (Exception $e) {}

Because errors are not being thrown / handled by recurly, but rather by Guzzle now, so they are more like this:

try {} catch (\GuzzleHttp\Exception\RequestException $e) {}

@SinusPi
Copy link

SinusPi commented Mar 4, 2022

(By the way: your PR won't merge cleanly anymore; there have been changes to the Base_Client constructor definition.)

@SinusPi
Copy link

SinusPi commented Mar 18, 2022

After incorporating your HttpAdapterInterface into my variant (a cURL adapter), I see what you meant with the exceptions. Well, yes, you'll probably have to catch the GuzzleHttp\Exception exceptions and throw them back at the "final" code. For simplicity's sake, I just went with a simple ConnectionError class that wraps any cURL error details if the connection fails entirely, but leaves it up to the Recurly lib to throw its exceptions if the connection succeeds but the response isn't valid.

@saas786 saas786 force-pushed the syed/v3-v2021-02-25/guzzle branch from 774dc86 to f33fe4a Compare March 2, 2023 16:36
@saas786 saas786 force-pushed the syed/v3-v2021-02-25/guzzle branch from 55e0726 to f33fe4a Compare May 12, 2023 12:57
- Base client class now accepts Http Adapter object as param.
- Add http adapter interface
@saas786 saas786 force-pushed the syed/v3-v2021-02-25/guzzle branch from f33fe4a to 15c384d Compare May 12, 2023 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants