saloonphp / saloon

🤠 Build beautiful API integrations and SDKs with Saloon
https://docs.saloon.dev
MIT License
2.03k stars 105 forks source link

Add `Stringable` to OAuthConfig `set` methods. #429

Closed avenjamin closed 1 month ago

avenjamin commented 2 months ago

This PR adds |Stringable to the set methods in the OAuthConfig class that accept a string parameter.

In my use case, I'm constructing URLs using the spatie/url package and would like to be able to pass the URL directly to the setAuthorizeEndpoint() method:

$this->oauthConfig()->setAuthorizeEndpoint(
    Url::fromString('https://api.example.com/oauth2/authorize')
    ->withQueryParameters([
        'app_key' => $appKey,
        'response_type' => 'code'
    ])
);

The Url implements the Stringable __toString() method so I can either cast to a string or update Saloon to support Stringable parameters :smile:

Sammyjo20 commented 1 month ago

Thank you for the PR and the suggestions @juse-less. To be honest, I don't think Saloon should support casting strings like this, if I were to implement the PR, I would have to add it everywhere to keep it consistent.