Skip to content

Releases: saloonphp/saloon

Version v1.4.2

24 Jun 14:31
7ab32e7

Choose a tag to compare

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

Full Changelog: v1.4.1...v1.4.2

Version v1.4.1

13 Jun 21:34
3908325

Choose a tag to compare

  • Added missing test for using invokable classes for mocking.

What's Changed

Full Changelog: v1.4.0...v1.4.1

Version v1.4.0

13 Jun 21:22
ece7cb7

Choose a tag to compare

What's Changed

Full Changelog: v1.3.3...v1.4.0

Version v1.3.3

12 Jun 20:36

Choose a tag to compare

  • Updated composer.json

Full Changelog: v1.3.2...v1.3.3

Version v1.3.2

12 Jun 20:27
f7f3b87

Choose a tag to compare

What's Changed

Full Changelog: v1.3.1...v1.3.2

Version v1.3.1

10 Jun 20:31
82a4569

Choose a tag to compare

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 🔥

09 Jun 20:50
e1c0114

Choose a tag to compare

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

22 May 22:43
8efb063

Choose a tag to compare

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

Full Changelog: v1.1.0...v1.2.0

Version v1.1.0 - Asynchronous Requests

24 Apr 18:01
af934a9

Choose a tag to compare

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

17 Apr 19:43
e6a0a2b

Choose a tag to compare

What's Changed

  • Removed InstalledVersions from Laravel check by @Sammyjo20 in #53

Full Changelog: v0.11.0...v1.0.1