sportmaster / api-client
A flexible and extensible PHP client for the Sportmaster Seller API
dev-master
2025-07-29 07:50 UTC
Requires
- php: ^8.1
- guzzlehttp/guzzle: ^7.5
- monolog/monolog: ^3.0
Requires (Dev)
- phpunit/phpunit: ^10.0
This package is auto-updated.
Last update: 2026-03-29 01:13:16 UTC
README
A flexible and extensible PHP client for interacting with the Sportmaster Seller API. This package supports both native PHP and frameworks like Laravel, with easy configuration, token management, and logging.
Installation
Install the package via Composer:
composer require sportmaster/api-client
Usage
Basic Example (Native PHP)
use Sportmaster\Api\Client; use Sportmaster\Api\Endpoints\AuthClient; use Sportmaster\Api\Request\AuthRequest; $client = new Client(); $authClient = new AuthClient($client); $request = new AuthRequest('your_client_id', 'your_client_secret'); $response = $authClient->authenticate($request); echo $response->getAccessToken(); // Outputs the access token
Laravel Integration
Add the service provider to config/app.php:
'providers' => [ Sportmaster\Api\Laravel\SportmasterApiServiceProvider::class, ]
Use the client in your application:
use Sportmaster\Api\Endpoints\AuthClient; use Sportmaster\Api\Request\AuthRequest; $client = app(\Sportmaster\Api\Client::class); $authClient = new AuthClient($client); $request = new AuthRequest('your_client_id', 'your_client_secret'); $response = $authClient->authenticate($request); echo $response->getAccessToken();
Configuration
- Token Storage: By default, tokens are stored in a JSON file (
.sportmaster_token.json). You can implementTokenStorageInterfacefor custom storage. - Logger: By default, logs are written to
sportmaster_api.log. ImplementLoggerInterfacefor custom logging. - HTTP Client: Uses Guzzle by default. Pass a custom
ClientInterfaceto theClientconstructor for alternative HTTP clients.
Requirements
- PHP ^8.1
- Guzzle HTTP Client ^7.5
- Monolog ^3.0
Testing
Run tests with PHPUnit:
composer test
Documentation
Detailed documentation for each class is available in the docs/ directory.