hypertensy / warface-sdk
Fast and flexible SDK client of the Warface API in PHP.
Requires
- php: ^7.4 || ^8.0
- ext-json: *
- fig/http-message-util: ^1.1
- myclabs/php-enum: ^1.8
- php-http/client-common: ^2.0
- php-http/discovery: ^1.13
- php-http/httplug: ^2.0
- php-http/message: ^1.0
- psr/http-client-implementation: ^1.0
- psr/http-message: ^1.0
Requires (Dev)
- guzzlehttp/guzzle: ^7.5
- guzzlehttp/psr7: ^1.8
- http-interop/http-factory-guzzle: ^1.2
- pestphp/pest: ^1.22.1
- pestphp/pest-plugin-parallel: ^1.2
- php-http/guzzle7-adapter: ^1.0
- php-http/mock-client: ^1.5
- phpstan/phpstan: ^1.8.6
README
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
-
Method
catalog
returns a complete list of achievements available in the game, with their id and name.$catalog = (new \Wnull\Warface\Client())->achievement()->catalog();
Clan branch
-
Method
members
returns information about the clan.$members = (new \Wnull\Warface\Client())->clan()->members('<clan>');
Game branch
-
Method
missions
returns detailed information about available missions and rewards for completing.$missions = (new \Wnull\Warface\Client())->game()->missions();
Rating branch
-
Method
monthly
returns the monthly rating.If the
$clan
parameter is used, the response from the server will contain data about the selected clan, it will also indicate exactly the league in which this clan is located even if it was not selected in the$league
.If only the
$league
parameter is used, the server will return the top 100 for that league.$monthly = (new \Wnull\Warface\Client()) ->rating() ->monthly('?<clan>', \Wnull\Warface\Enum\RatingLeague::ELITE(), '?<page>');
-
Method
clan
returns information about the rating of clans.$clan = (new \Wnull\Warface\Client())->rating()->clan();
-
Method
top100
returns a TOP-100 rating.If the parameter
$class
is not specified, the data gets for all classes.$top100 = (new \Wnull\Warface\Client())->rating()->top100(\Wnull\Warface\Enum\GameClass::MEDIC());
User branch
-
Method
stat
returns player statistics.$stat = (new \Wnull\Warface\Client())->user()->stat('<name>');
-
Method
achievements
returns player's achievements.$achievements = (new \Wnull\Warface\Client())->user()->achievements('<name>');
Weapon branch (deprecated since September 2024)
-
Method
catalog
returns a complete list of items available in the game, with their id and name.$catalog = (new \Wnull\Warface\Client())->achievement()->catalog();
Testing
$ composer test
Credits
License
The MIT License (MIT). Please see License File for more information.