sportmaster/api-client

A flexible and extensible PHP client for the Sportmaster Seller API

Maintainers

Package info

github.com/ilyalazarev31/sportmaster-api

pkg:composer/sportmaster/api-client

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-master 2025-07-29 07:50 UTC

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 implement TokenStorageInterface for custom storage.
  • Logger: By default, logs are written to sportmaster_api.log. Implement LoggerInterface for custom logging.
  • HTTP Client: Uses Guzzle by default. Pass a custom ClientInterface to the Client constructor 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.