saloon

🤠 Build beautiful API integrations and SDKs with Saloon

MIT License

Downloads
2.4M
Stars
1.8K

Bot releases are visible (Hide)

saloon - Version v1.1.0 - Asynchronous Requests

Published by Sammyjo20 over 2 years ago

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...
    },
);
saloon - Version v1.0.1

Published by Sammyjo20 over 2 years ago

What's Changed

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v0.11.0...v1.0.1

saloon - Version v1.0.0 🎉

Published by Sammyjo20 over 2 years ago

I have decided to tag version 1.0 of Saloon. The API is now stable, with small tidy-ups and optimisations that can be done, but there are plenty of tests and big changes will now wait until later versions.

Have fun with Saloon!

saloon - Version v0.11.0

Published by Sammyjo20 over 2 years ago

What's Changed

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v0.10.0...v0.10.1

saloon - Version v0.10.0

Published by Sammyjo20 over 2 years ago

Authenticators!

This release introduces a new feature into Saloon, authenticators. Easily authenticate with your API integrations using the built in methods or create your own custom authenticators.

Click here to read more

What's Changed

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v0.9.2...v0.10.0

saloon - Version v0.9.2

Published by Sammyjo20 over 2 years ago

What's Changed

  • Added new send and request methods to the connector
  • Changed return type of cast method
  • Moved make back out from trait to improve readability

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v0.9.1...v0.9.2

saloon - Version v0.9.1

Published by Sammyjo20 over 2 years ago

Changes

  • Fixed an issue where the "default" method on the Keychain did not return an instance of the class.

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v0.9.0...v0.9.1

saloon - Version v0.9.0

Published by Sammyjo20 over 2 years ago

Features

  • Added Keychain authentication

Breaking Changes

  • Renamed "setLoadedConnector" to "setConnector" on SaloonRequest.

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v0.8.3...v0.9.0

saloon - Version v0.8.3

Published by Sammyjo20 over 2 years ago

What's Changed

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v0.8.2...v0.8.3

saloon - Version v0.8.2

Published by Sammyjo20 over 2 years ago

What's Changed

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v0.8.1...v0.8.2

saloon - Version v0.8.1

Published by Sammyjo20 over 2 years ago

This release introduces a first-party way to cast directly to a DTO of your choice.

Firstly, add the "CastsToDto" trait to your request. After that, you need to add the "castToDto" method on the request. This should return your DTO with the data populated inside of it.

public function castToDto(SaloonResponse $response): object
{
    return User::fromSaloon($response);
}

After your request has been sent, you can use the dto method on the response to retrieve your DTO.

$response = UserRequest::make()->send();
$dto = $response->dto(); // Data\User

What's Changed

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v0.8.0...v0.8.1

saloon - Version v0.8.0

Published by Sammyjo20 over 2 years ago

The biggest release in terms of changes for Saloon, be careful there are quite a number of breaking changes as Saloon leads up to v1.0 so keep an eye out for them below.

Features

  • Added “getStream” to Saloon Response
  • Added “xml” method to Saloon Response which will cast a XML response to a SimpleXMLElement
  • Added the current request being processed to the “boot” methods on the connector and request. (Breaking Change)
  • Added new authentication methods
    • withBasicAuth (for username/password auth)
    • withDigestAuth (for username/password auth with a digest)
    • withToken (for Authentication: Bearer tokens)
  • Added a default connection timeout of 10 seconds and default request timeout of 30 seconds (Breaking Change)
  • Added a new “make” static method on a request and connector.
  • Added the current request being processed to the “boot” method of your plugins.

Changes

  • Removed unused “connectorHasQueryParamsTrait” method
  • Removed the requirement to add the word “feature” on the end of plugins (Breaking Change)
  • The “defineXMLBody” method on the HasXMLBody plugin is now abstract
  • The namespace for all plugins has changed from "Sammyjo20\Saloon\Traits\Features" to “Sammyjo20\Saloon\Traits\Plugins" (Breaking Change)
  • All built in plugins now have "SaloonRequest $request" added to their boot methods.

Breaking Changes

  • Plugins no longer have the word “feature” at the end of them on their boot method. You should rename your boot methods of your plugins to address this. For example “bootHasJsonBodyFeature” is now “bootHasJsonBody”.
  • Saloon now has a default connection timeout of 10 seconds and a request timeout of 30 seconds, if you need a larger timeout, you should overwrite this by using the HasTimeout plugin.
  • The “boot” method on your connectors and requests now have the current processing request being passed in, you should specify this if you are using the “boot” method on either your connector or request.
  • The namespace for all plugins has changed from "Sammyjo20\Saloon\Features\Plugins" to “Sammyjo20\Saloon\Traits\Plugins"
  • All built in plugins now have "SaloonRequest $request" added to their boot methods. If you are extending any of these plugins, you should reflect this change too.

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v0.7.2...v0.8.0

saloon - Version v0.7.2

Published by Sammyjo20 over 2 years ago

What's Changed

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v0.7.1...v0.7.2

saloon - Version v0.7.1

Published by Sammyjo20 over 2 years ago

Bug Fixes

New Contributors

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v0.7.0...v0.7.1

saloon - Version v0.7.0 - Mock Expectations

Published by Sammyjo20 over 2 years ago

New Features

You can now assert that Saloon has sent the correct response in your application! The following expectation methods have been added:

  • AssertSent (accepts request classes, closures and URL patterns)
  • AssertNotSent (inverse of assert sent)
  • AssertSentJson (accepts a class and an array to check both are equal)
  • AssertNothingSent
  • AssertSentCount

Here's how you can use it:

// Laravel (using Facade)

Saloon::assertSent(GetForgeServerRequest::class);

// Normal PHP

$mockClient->assertSent(GetForgeServerRequest::class);

What's Changed

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v0.6.6...v0.7.0

saloon - Version v0.6.6

Published by Sammyjo20 over 2 years ago

New Features

Introducing a new way to use Saloon! You can now register your requests within your connector to use it just like an SDK. Take a look:

// Currently, the only way to make requests...

$request = new GetForgeServerRequest(serverId: 123456);
$response = $request->send();

// Introducing the new "SDK" API!

$connector = new ForgeConnector();
$request = $connector->getForgeServerRequest(serverId: 123456);
$response = $request->send();

// You can even use static methods...

$request = ForgeConnector::getForgeServerRequest(serverId: 123456);
$response = $request->send();

Click here to read more

What's Changed

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v0.6.5...v0.6.6

saloon - Version v0.6.5

Published by Sammyjo20 over 2 years ago

What's Changed

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v0.6.4...v0.6.5

saloon - Version v0.6.4

Published by Sammyjo20 over 2 years ago

Fixes

  • Fixed bug where if you tried to add the AlwaysThrowsOnErrors trait to a connector it would fail.

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v0.6.3...v0.6.4

saloon - Version v0.6.3

Published by Sammyjo20 over 2 years ago

Changes

  • Removed cookies() method from SaloonResponse

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v0.6.2...v0.6.3

saloon - Version v0.6.2

Published by Sammyjo20 over 2 years ago

Added

  • New getGuzzleException() to SaloonResponse
  • Previous exception to SaloonRequestException

Changed

  • Tidied up "Should Guess Status From Body" feature
  • Removed effectiveUri() and handlerStats() from response
  • Renamed getSaloonRequestOptions to getRequestOptions

Full Changelog: https://github.com/Sammyjo20/Saloon/compare/v0.6.1...v0.6.2