mvenghaus / saloon-plenty-connector
Saloon Connector for Plenty
dev-main
2024-10-26 11:05 UTC
Requires
- php: ^8.2
- saloonphp/saloon: ^3.7.0
Requires (Dev)
- larapack/dd: ^1.1
- mockery/mockery: ^1.6
- pestphp/pest: ^3.5.0
This package is auto-updated.
Last update: 2024-11-26 11:16:40 UTC
README
Saloon - Plentymarkets Connector with token handling, allowing you to easily start building your own requests.
Installation
Install the package via composer:
composer require mvenghaus/saloon-plenty-connector
Usage
Basic Structure
$configuration = new Configuration(...); $apiConnector = new ApiConnector($configuration); $response = $apiConnector->send(new Your_Request());
Configuration - Structure
class Configuration { public function __construct( public string $endpoint, // https://www.your-domain.com/rest/ public string $username, public string $password, public ?string $authenticator = null, // saloon authenticator (serialized) public ?Closure $authenticatorUpdateCallback = null, // callback to save authenticator if changed public ?Closure $debugCallback = null // callback for debugging ) { } }
Configuration - Example
$authenticator = load_from_your_cache(); $configuration = new Configuration( 'https://www.your-domain.com/rest/', 'USERNAME', 'PASSWORD', $authenticator, function (string $authenticator) { save_to_your_cache($authenticator); }, function (PendingRequest $pendingRequest, RequestInterface $psrRequest) { echo $pendingRequest->getUrl() . PHP_EOL; } );