hypertensy / warface-sdk

Fast and flexible SDK client of the Warface API in PHP.
MIT License
13 stars 3 forks source link
api php sdk warface warface-api

Warface SDK client

Build Status Latest Version

Fast and flexible SDK client of the Warface API in PHP.

Note that the "Weapon" branch is no longer a public API method. The International region API has also ceased to exist.

During technical weekly work on the game servers, the API may work unstable and give incorrect data.

References

Installation

Via Composer:

$ composer require wnull/warface-sdk guzzlehttp/guzzle:^7.3 http-interop/http-factory-guzzle:^1.0

We are decoupled from any HTTP messaging client with help by HTTPlug.

Quickstart

Structure of the client class constructor.

public function __construct(
    \Wnull\Warface\HttpClient\ClientBuilder $httpClientBuilder = null, 
    \Wnull\Warface\Enum\RegionEnum $region = null,
): \Wnull\Warface\Client

Create an instance of the client using the following code:

$client = new \Wnull\Warface\Client();

When creating a builder, you can add custom plugins to it.

$builder = (new \Wnull\Warface\HttpClient\ClientBuilder());
$builder->addPlugin(
    new class implements \Http\Client\Common\Plugin {
        public function handleRequest(
            \Psr\Http\Message\RequestInterface $request, 
            callable $next, 
            callable $first
        ): \Http\Promise\Promise {
            // TODO: Implement handleRequest() method.
        }
    }
);

$client = new \Wnull\Warface\Client($builder);

By default, the CIS region is set in the client. It can be changed to INTERNATIONAL if necessary.

$builder = null; // builder or null
$client = new \Wnull\Warface\Client($builder, \Wnull\Warface\Enum\RegionEnum::INTERNATIONAL());

Overview

Thanks to HTTPlug, we support the use of many HTTP clients. For example, to use the Symfony HTTP Client, first install the client and PSR-7 implementation.

composer require wnull/warface-sdk symfony/http-client nyholm/psr7

Next, set up the Warface SDK client with this HTTP client:

$client = \Wnull\Warface\Client::createWithHttpClient(
    new \Symfony\Component\HttpClient\HttplugClient()
);

Alternatively, you can inject an HTTP client through the Client constructor.

API

The structure of the application is based solely on the public methods described in the official docs.

Achievement branch

Clan branch

Game branch

Rating branch

User branch

Weapon branch (deprecated since September 2024)

Testing

$ composer test

Credits

License

The MIT License (MIT). Please see License File for more information.