Releases: saloonphp/saloon
Version v1.4.2
What's Changed
- Fix docblock in SaloonResponse by @szepeviktor in #69
- Plugins on a base class will be used when extending the base class by @leo108 in #70
New Contributors
- @szepeviktor made their first contribution in #69
- @leo108 made their first contribution in #70
Full Changelog: v1.4.1...v1.4.2
Version v1.4.1
- Added missing test for using invokable classes for mocking.
What's Changed
- Invokable mock response by @Sammyjo20 in #67
Full Changelog: v1.4.0...v1.4.1
Version v1.4.0
Version v1.3.3
- Updated composer.json
Full Changelog: v1.3.2...v1.3.3
Version v1.3.2
Version v1.3.1
What's Changed
- Feature | Spring cleaning & added authentication alias by @Sammyjo20 in #63
Full Changelog: v1.3.0...v1.3.1
Version v1.3 - OAuth2 Support 🔥
Read the documentation here: https://docs.saloon.dev/advanced/oauth2-authentication
Version 1.3 introduces OAuth2 helpers/boilerplate code for the Authorization Code Flow! 🥳 It will allow you to write all the OAuth2 client configuration in a connector that you can use to:
- Generate an authorization URL
- Create access tokens
- Create a refresh token
Connector
<?php
use Sammyjo20\Saloon\Helpers\OAuth2\OAuthConfig;
use Sammyjo20\Saloon\Http\SaloonConnector;
use Sammyjo20\Saloon\Traits\OAuth2\AuthorizationCodeGrant;
class SpotifyAuthConnector extends SaloonConnector
{
use AuthorizationCodeGrant;
public function defineBaseUrl(): string
{
return 'https://accounts.spotify.com';
}
protected function defaultOauthConfig(): OAuthConfig
{
return OAuthConfig::make()
->setClientId('my-client-id')
->setClientSecret('my-client-secret')
->setDefaultScopes(['user-read-currently-playing'])
->setRedirectUri('https://my-app.saloon.dev/auth/callback')
->setAuthorizeEndpoint('authorize')
->setTokenEndpoint('token')
->setUserEndpoint('user')
}
}Your application:
$authConnector = new SpotifyAuthConnector;
// 1. Redirect the user to the authorization URL...
$authorizationUrl = $authConnector->getAuthorizationUrl($scopes, $state);
// 2. Handle the callback from the API provider and create an access token...
$authenticator = $authConnector->getAccessTokens($code, $state);
// 3. Authenticate your requests!
$request = new GetTracksRequest;
$request->withAuth($authenticator);
$request->send(); // 🚀
// 4. Refresh your access tokens...
$newAuthenticator = $authConnector->refreshAccessTokens($authenticator);Version v1.2.0 - More SDK Tools
Previously you could define custom methods on the connector to call requests in Saloon, like so:
protected array $requests = [
'getMyUser' => UserRequest::class,
ErrorRequest::class,
];This was pretty limited as you couldn't define "groups" of requests.
This PR introduces an extension to this API and now you can define an array of requests, keyed for a collection or a custom "RequestCollection" which is a class that extends the base "RequestCollection" class and can have completely custom methods inside. You will also have access to the connector.
Define groups of requests
$connector->user()->get()
protected array $requests = [
'user' => [
'get' => UserRequest::class,
],
];Define custom request collections
$connector->user()->get()
protected array $requests = [
'user' => UserCollection::class,
];class UserCollection extends RequestCollection
{
public function get(): SaloonRequest
{
return $this->connector->request(new UserRequest);
}
}What's Changed
- Feature | Nested SDK Requests by @Sammyjo20 in #59
Full Changelog: v1.1.0...v1.2.0
Version v1.1.0 - Asynchronous Requests
Introducing asynchronous request support for Saloon! There is now a new sendAsnc method on both the request and the connector and when used, it will return an instance of Guzzle Promise which you can then use in your application.
$request = new GetUserRequest(userId: 1);
$promise = $request->sendAsync();
$promise->then(
function (SaloonResponse $response) {
// Handle successful response...
},
function (SaloonRequestException $exception) {
$response = $exception->getSaloonResponse();
// Handle unsuccessful response...
},
);Version v1.0.1
What's Changed
- Removed InstalledVersions from Laravel check by @Sammyjo20 in #53
Full Changelog: v0.11.0...v1.0.1