saloon

🤠 Build beautiful API integrations and SDKs with Saloon

MIT License

Downloads
2.4M
Stars
1.8K

Bot releases are visible (Hide)

saloon - Version v2.0.0 Beta 5

Published by Sammyjo20 over 1 year ago

What's Changed

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v2.0.0-beta4...v2.0.0-beta5

saloon - Version v2.0.0 Beta 4

Published by Sammyjo20 over 1 year ago

What's Changed

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v2.0.0-beta3...v2.0.0-beta4

saloon - Version v2.0.0 Beta 3

Published by Sammyjo20 over 1 year ago

What's Changed

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v2.0.0-beta2...v2.0.0-beta3

saloon - Version v2.0.0 Beta 2

Published by Sammyjo20 over 1 year ago

What's Changed

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v2.0.0-beta1...v2.0-beta2

saloon - Version v2.0.0 Beta 1

Published by Sammyjo20 almost 2 years ago

What's Changed

It's finally time for the first Saloon v2 beta! After months of work and pretty much rewriting the core code, Saloon v2 is finally in beta for you to try out. Please provide feedback on the main issue.

Issue: https://github.com/Sammyjo20/Saloon/issues/64
Docs: https://docs.saloon.dev/v/2/

New Contributors

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v1.6.0...v2.0.0-beta1

saloon - Version v1.6.0

Published by Sammyjo20 almost 2 years ago

What's Changed

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v1.5.3...v1.6.0

saloon - Version v1.5.3

Published by Sammyjo20 almost 2 years ago

What's Changed

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v1.5.2...v1.5.3

saloon - Version v1.5.2

Published by Sammyjo20 almost 2 years ago

What's Changed

New Contributors

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v1.5.1...v1.5.2

saloon - Version v1.5.1

Published by Sammyjo20 almost 2 years ago

What's Changed

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v1.5...v1.5.1

saloon - Version v1.5.0

Published by Sammyjo20 almost 2 years ago

What's Changed

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v1.4.4...v1.5

saloon - Version v1.4.4

Published by Sammyjo20 about 2 years ago

What's Changed

New Contributors

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v1.4.3...v1.4.4

saloon - Version v1.4.3

Published by Sammyjo20 about 2 years ago

What's Changed

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v1.4.2...v1.4.3

saloon - Version v1.4.2

Published by Sammyjo20 over 2 years ago

What's Changed

New Contributors

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v1.4.1...v1.4.2

saloon - Version v1.4.1

Published by Sammyjo20 over 2 years ago

  • Added missing test for using invokable classes for mocking.

What's Changed

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v1.4.0...v1.4.1

saloon - Version v1.4.0

Published by Sammyjo20 over 2 years ago

What's Changed

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v1.3.3...v1.4.0

saloon - Version v1.3.3

Published by Sammyjo20 over 2 years ago

  • Updated composer.json

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v1.3.2...v1.3.3

saloon - Version v1.3.2

Published by Sammyjo20 over 2 years ago

What's Changed

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v1.3.1...v1.3.2

saloon - Version v1.3.1

Published by Sammyjo20 over 2 years ago

What's Changed

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v1.3.0...v1.3.1

saloon - Version v1.3 - OAuth2 Support 🔥

Published by Sammyjo20 over 2 years ago

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);
saloon - Version v1.2.0 - More SDK Tools

Published by Sammyjo20 over 2 years ago

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: https://github.com/Sammyjo20/Saloon/compare/v1.1.0...v1.2.0