commit 8d925075da2ffef7ff02af7ea7cdcc491fa38863 Author: Tim van Veenendaal Date: Thu Nov 25 18:24:54 2021 +0100 Dump off the swaggerIo generator with tests removed and fix for Round->loser and Round->dicerolls diff --git a/README.md b/README.md new file mode 100644 index 0000000..4fc4d96 --- /dev/null +++ b/README.md @@ -0,0 +1,212 @@ +# SwaggerClient-php +Play perudo with your friends through the api! + +This PHP package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: + +- API version: 1.0.0 +- Build package: io.swagger.codegen.v3.generators.php.PhpClientCodegen + +## Requirements + +PHP 5.5 and later + +## Installation & Usage +### Composer + +To install the bindings via [Composer](http://getcomposer.org/), add the following to `composer.json`: + +``` +{ + "repositories": [ + { + "type": "git", + "url": "http://github.com/GIT_USER_ID/GIT_REPO_ID.git" + } + ], + "require": { + "GIT_USER_ID/GIT_REPO_ID": "*@dev" + } +} +``` + +Then run `composer install` + +### Manual Installation + +Download the files and include `autoload.php`: + +```php + require_once('/path/to/SwaggerClient-php/vendor/autoload.php'); +``` + +## Tests + +To run the unit tests: + +``` +composer install +./vendor/bin/phpunit +``` + +## Getting Started + +Please follow the [installation procedure](#installation--usage) and then run the following: + +```php +callTurn($player); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling DefaultApi->callTurn: ', $e->getMessage(), PHP_EOL; +} + +$apiInstance = new Swagger\Client\Api\DefaultApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client() +); +$name = "name_example"; // string | + +try { + $result = $apiInstance->createGame($name); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling DefaultApi->createGame: ', $e->getMessage(), PHP_EOL; +} + +$apiInstance = new Swagger\Client\Api\DefaultApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client() +); +$player = "player_example"; // string | + +try { + $result = $apiInstance->gameIsStarted($player); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling DefaultApi->gameIsStarted: ', $e->getMessage(), PHP_EOL; +} + +$apiInstance = new Swagger\Client\Api\DefaultApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client() +); +$player = "player_example"; // string | + +try { + $result = $apiInstance->getTurn($player); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling DefaultApi->getTurn: ', $e->getMessage(), PHP_EOL; +} + +$apiInstance = new Swagger\Client\Api\DefaultApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client() +); +$name = "name_example"; // string | +$code = "code_example"; // string | + +try { + $result = $apiInstance->joinGame($name, $code); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling DefaultApi->joinGame: ', $e->getMessage(), PHP_EOL; +} + +$apiInstance = new Swagger\Client\Api\DefaultApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client() +); +$player = "player_example"; // string | +$body = new \Swagger\Client\Model\PlayerGuess(); // \Swagger\Client\Model\PlayerGuess | + +try { + $result = $apiInstance->postTurn($player, $body); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling DefaultApi->postTurn: ', $e->getMessage(), PHP_EOL; +} + +$apiInstance = new Swagger\Client\Api\DefaultApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client() +); +$player = "player_example"; // string | +$body = new \Swagger\Client\Model\GameRules(); // \Swagger\Client\Model\GameRules | + +try { + $result = $apiInstance->setGameRules($player, $body); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling DefaultApi->setGameRules: ', $e->getMessage(), PHP_EOL; +} + +$apiInstance = new Swagger\Client\Api\DefaultApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client() +); +$player = "player_example"; // string | + +try { + $result = $apiInstance->startGame($player); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling DefaultApi->startGame: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +## Documentation for API Endpoints + +All URIs are relative to */* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*DefaultApi* | [**callTurn**](docs/Api/DefaultApi.md#callturn) | **POST** /player/call/{player} | +*DefaultApi* | [**createGame**](docs/Api/DefaultApi.md#creategame) | **GET** /game/create | +*DefaultApi* | [**gameIsStarted**](docs/Api/DefaultApi.md#gameisstarted) | **GET** /game/started/{player} | +*DefaultApi* | [**getTurn**](docs/Api/DefaultApi.md#getturn) | **GET** /player/turn/{player} | +*DefaultApi* | [**joinGame**](docs/Api/DefaultApi.md#joingame) | **GET** /game/join/{code} | +*DefaultApi* | [**postTurn**](docs/Api/DefaultApi.md#postturn) | **POST** /player/guess/{player} | +*DefaultApi* | [**setGameRules**](docs/Api/DefaultApi.md#setgamerules) | **POST** /game/rules/{player} | +*DefaultApi* | [**startGame**](docs/Api/DefaultApi.md#startgame) | **GET** /game/start/{player} | + +## Documentation For Models + + - [GameIsStarted](docs/Model/GameIsStarted.md) + - [GameRules](docs/Model/GameRules.md) + - [GameState](docs/Model/GameState.md) + - [MessageResponse](docs/Model/MessageResponse.md) + - [MyTurn](docs/Model/MyTurn.md) + - [Player](docs/Model/Player.md) + - [PlayerCode](docs/Model/PlayerCode.md) + - [PlayerGuess](docs/Model/PlayerGuess.md) + - [Round](docs/Model/Round.md) + - [Turn](docs/Model/Turn.md) + +## Documentation For Authorization + + All endpoints do not require authorization. + + +## Author + + + diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..be0f1e1 --- /dev/null +++ b/composer.json @@ -0,0 +1,36 @@ +{ + "name": "ardent/perudo-php-api", + "description": "", + "keywords": [ + "swagger", + "php", + "sdk", + "api" + ], + "homepage": "http://swagger.io", + "license": "proprietary", + "authors": [ + { + "name": "Swagger and contributors", + "homepage": "https://github.com/swagger-api/swagger-codegen" + } + ], + "require": { + "php": ">=5.5", + "ext-curl": "*", + "ext-json": "*", + "ext-mbstring": "*", + "guzzlehttp/guzzle": "^6.2" + }, + "require-dev": { + "phpunit/phpunit": "^4.8", + "squizlabs/php_codesniffer": "~2.6", + "friendsofphp/php-cs-fixer": "~1.12" + }, + "autoload": { + "psr-4": { "Swagger\\Client\\" : "lib/" } + }, + "autoload-dev": { + "psr-4": { "Swagger\\Client\\" : "test/" } + } +} diff --git a/docs/Api/DefaultApi.md b/docs/Api/DefaultApi.md new file mode 100644 index 0000000..5e2d482 --- /dev/null +++ b/docs/Api/DefaultApi.md @@ -0,0 +1,397 @@ +# Swagger\Client\DefaultApi + +All URIs are relative to */* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**callTurn**](DefaultApi.md#callturn) | **POST** /player/call/{player} | +[**createGame**](DefaultApi.md#creategame) | **GET** /game/create | +[**gameIsStarted**](DefaultApi.md#gameisstarted) | **GET** /game/started/{player} | +[**getTurn**](DefaultApi.md#getturn) | **GET** /player/turn/{player} | +[**joinGame**](DefaultApi.md#joingame) | **GET** /game/join/{code} | +[**postTurn**](DefaultApi.md#postturn) | **POST** /player/guess/{player} | +[**setGameRules**](DefaultApi.md#setgamerules) | **POST** /game/rules/{player} | +[**startGame**](DefaultApi.md#startgame) | **GET** /game/start/{player} | + +# **callTurn** +> \Swagger\Client\Model\MyTurn callTurn($player) + + + +### Example +```php +callTurn($player); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling DefaultApi->callTurn: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **player** | **string**| | + +### Return type + +[**\Swagger\Client\Model\MyTurn**](../Model/MyTurn.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **createGame** +> \Swagger\Client\Model\PlayerCode createGame($name) + + + +### Example +```php +createGame($name); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling DefaultApi->createGame: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **name** | **string**| | + +### Return type + +[**\Swagger\Client\Model\PlayerCode**](../Model/PlayerCode.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **gameIsStarted** +> \Swagger\Client\Model\GameIsStarted gameIsStarted($player) + + + +### Example +```php +gameIsStarted($player); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling DefaultApi->gameIsStarted: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **player** | **string**| | + +### Return type + +[**\Swagger\Client\Model\GameIsStarted**](../Model/GameIsStarted.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **getTurn** +> \Swagger\Client\Model\MyTurn getTurn($player) + + + +### Example +```php +getTurn($player); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling DefaultApi->getTurn: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **player** | **string**| | + +### Return type + +[**\Swagger\Client\Model\MyTurn**](../Model/MyTurn.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **joinGame** +> \Swagger\Client\Model\PlayerCode joinGame($name, $code) + + + +### Example +```php +joinGame($name, $code); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling DefaultApi->joinGame: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **name** | **string**| | + **code** | **string**| | + +### Return type + +[**\Swagger\Client\Model\PlayerCode**](../Model/PlayerCode.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **postTurn** +> \Swagger\Client\Model\MyTurn postTurn($player, $body) + + + +### Example +```php +postTurn($player, $body); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling DefaultApi->postTurn: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **player** | **string**| | + **body** | [**\Swagger\Client\Model\PlayerGuess**](../Model/PlayerGuess.md)| | [optional] + +### Return type + +[**\Swagger\Client\Model\MyTurn**](../Model/MyTurn.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **setGameRules** +> \Swagger\Client\Model\MessageResponse setGameRules($player, $body) + + + +### Example +```php +setGameRules($player, $body); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling DefaultApi->setGameRules: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **player** | **string**| | + **body** | [**\Swagger\Client\Model\GameRules**](../Model/GameRules.md)| | [optional] + +### Return type + +[**\Swagger\Client\Model\MessageResponse**](../Model/MessageResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **startGame** +> \Swagger\Client\Model\MessageResponse startGame($player) + + + +### Example +```php +startGame($player); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling DefaultApi->startGame: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **player** | **string**| | + +### Return type + +[**\Swagger\Client\Model\MessageResponse**](../Model/MessageResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/docs/Model/AllOfRoundLoser.md b/docs/Model/AllOfRoundLoser.md new file mode 100644 index 0000000..7140a48 --- /dev/null +++ b/docs/Model/AllOfRoundLoser.md @@ -0,0 +1,8 @@ +# AllOfRoundLoser + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/docs/Model/GameIsStarted.md b/docs/Model/GameIsStarted.md new file mode 100644 index 0000000..56c7418 --- /dev/null +++ b/docs/Model/GameIsStarted.md @@ -0,0 +1,10 @@ +# GameIsStarted + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**started** | **bool** | | [optional] +**game_state** | [**\Swagger\Client\Model\GameState**](GameState.md) | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/docs/Model/GameRules.md b/docs/Model/GameRules.md new file mode 100644 index 0000000..807dc26 --- /dev/null +++ b/docs/Model/GameRules.md @@ -0,0 +1,15 @@ +# GameRules + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**start_dice_per_player** | **int** | | [optional] +**higher_count_lower_value** | **bool** | | [optional] +**joker_counts_double** | **bool** | | [optional] +**has_joker** | **bool** | | [optional] +**has_palifico** | **bool** | | [optional] +**has_calza** | **bool** | | [optional] +**joker_die_value** | **int** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/docs/Model/GameState.md b/docs/Model/GameState.md new file mode 100644 index 0000000..c4628d8 --- /dev/null +++ b/docs/Model/GameState.md @@ -0,0 +1,15 @@ +# GameState + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**state** | **string** | | [optional] +**code** | **string** | | [optional] +**rounds** | [**\Swagger\Client\Model\Round[]**](Round.md) | | [optional] +**players** | [**\Swagger\Client\Model\Player[]**](Player.md) | | [optional] +**current_player** | [**\Swagger\Client\Model\Player**](Player.md) | | [optional] +**owning_player** | [**\Swagger\Client\Model\Player**](Player.md) | | [optional] +**rules** | [**\Swagger\Client\Model\GameRules**](GameRules.md) | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/docs/Model/MessageResponse.md b/docs/Model/MessageResponse.md new file mode 100644 index 0000000..1bddd05 --- /dev/null +++ b/docs/Model/MessageResponse.md @@ -0,0 +1,10 @@ +# MessageResponse + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**message** | **string** | | [optional] +**errors** | **string[]** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/docs/Model/MyTurn.md b/docs/Model/MyTurn.md new file mode 100644 index 0000000..8656153 --- /dev/null +++ b/docs/Model/MyTurn.md @@ -0,0 +1,11 @@ +# MyTurn + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**turn** | **bool** | | [optional] +**game_state** | [**\Swagger\Client\Model\GameState**](GameState.md) | | [optional] +**errors** | **string[]** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/docs/Model/Player.md b/docs/Model/Player.md new file mode 100644 index 0000000..1899837 --- /dev/null +++ b/docs/Model/Player.md @@ -0,0 +1,11 @@ +# Player + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **string** | | [optional] +**hash** | **string** | | [optional] +**name** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/docs/Model/PlayerCode.md b/docs/Model/PlayerCode.md new file mode 100644 index 0000000..b330ca8 --- /dev/null +++ b/docs/Model/PlayerCode.md @@ -0,0 +1,11 @@ +# PlayerCode + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**player** | [**\Swagger\Client\Model\Player**](Player.md) | | [optional] +**code** | **string** | | [optional] +**errors** | **string[]** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/docs/Model/PlayerGuess.md b/docs/Model/PlayerGuess.md new file mode 100644 index 0000000..66e6a0a --- /dev/null +++ b/docs/Model/PlayerGuess.md @@ -0,0 +1,10 @@ +# PlayerGuess + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**dice_count** | **int** | | +**die_value** | **int** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/docs/Model/Round.md b/docs/Model/Round.md new file mode 100644 index 0000000..8d235af --- /dev/null +++ b/docs/Model/Round.md @@ -0,0 +1,13 @@ +# Round + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**number** | **int** | | [optional] +**turns** | [**\Swagger\Client\Model\Turn[]**](Turn.md) | | [optional] +**loser** | [**AllOfRoundLoser**](AllOfRoundLoser.md) | | [optional] +**my_rolls** | [**int[][]**](array.md) | | [optional] +**rolls** | **int[]** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/docs/Model/Turn.md b/docs/Model/Turn.md new file mode 100644 index 0000000..6dda1f0 --- /dev/null +++ b/docs/Model/Turn.md @@ -0,0 +1,12 @@ +# Turn + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**number** | **int** | | [optional] +**player** | [**\Swagger\Client\Model\Player**](Player.md) | | [optional] +**dice_count** | **int** | | [optional] +**die_value** | **int** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/lib/Api/DefaultApi.php b/lib/Api/DefaultApi.php new file mode 100644 index 0000000..42378a2 --- /dev/null +++ b/lib/Api/DefaultApi.php @@ -0,0 +1,2198 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation callTurn + * + * @param string $player player (required) + * + * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Swagger\Client\Model\MyTurn + */ + public function callTurn($player) + { + list($response) = $this->callTurnWithHttpInfo($player); + return $response; + } + + /** + * Operation callTurnWithHttpInfo + * + * @param string $player (required) + * + * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Swagger\Client\Model\MyTurn, HTTP status code, HTTP response headers (array of strings) + */ + public function callTurnWithHttpInfo($player) + { + $returnType = '\Swagger\Client\Model\MyTurn'; + $request = $this->callTurnRequest($player); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if (!in_array($returnType, ['string','integer','bool'])) { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 0: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Swagger\Client\Model\MyTurn', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation callTurnAsync + * + * + * + * @param string $player (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function callTurnAsync($player) + { + return $this->callTurnAsyncWithHttpInfo($player) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation callTurnAsyncWithHttpInfo + * + * + * + * @param string $player (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function callTurnAsyncWithHttpInfo($player) + { + $returnType = '\Swagger\Client\Model\MyTurn'; + $request = $this->callTurnRequest($player); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'callTurn' + * + * @param string $player (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function callTurnRequest($player) + { + // verify the required parameter 'player' is set + if ($player === null || (is_array($player) && count($player) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $player when calling callTurn' + ); + } + + $resourcePath = '/player/call/{player}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + // path params + if ($player !== null) { + $resourcePath = str_replace( + '{' . 'player' . '}', + ObjectSerializer::toPathValue($player), + $resourcePath + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation createGame + * + * @param string $name name (required) + * + * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Swagger\Client\Model\PlayerCode + */ + public function createGame($name) + { + list($response) = $this->createGameWithHttpInfo($name); + return $response; + } + + /** + * Operation createGameWithHttpInfo + * + * @param string $name (required) + * + * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Swagger\Client\Model\PlayerCode, HTTP status code, HTTP response headers (array of strings) + */ + public function createGameWithHttpInfo($name) + { + $returnType = '\Swagger\Client\Model\PlayerCode'; + $request = $this->createGameRequest($name); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if (!in_array($returnType, ['string','integer','bool'])) { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 0: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Swagger\Client\Model\PlayerCode', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation createGameAsync + * + * + * + * @param string $name (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createGameAsync($name) + { + return $this->createGameAsyncWithHttpInfo($name) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation createGameAsyncWithHttpInfo + * + * + * + * @param string $name (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createGameAsyncWithHttpInfo($name) + { + $returnType = '\Swagger\Client\Model\PlayerCode'; + $request = $this->createGameRequest($name); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'createGame' + * + * @param string $name (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function createGameRequest($name) + { + // verify the required parameter 'name' is set + if ($name === null || (is_array($name) && count($name) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $name when calling createGame' + ); + } + + $resourcePath = '/game/create'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + if ($name !== null) { + $queryParams['name'] = ObjectSerializer::toQueryValue($name, null); + } + + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation gameIsStarted + * + * @param string $player player (required) + * + * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Swagger\Client\Model\GameIsStarted + */ + public function gameIsStarted($player) + { + list($response) = $this->gameIsStartedWithHttpInfo($player); + return $response; + } + + /** + * Operation gameIsStartedWithHttpInfo + * + * @param string $player (required) + * + * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Swagger\Client\Model\GameIsStarted, HTTP status code, HTTP response headers (array of strings) + */ + public function gameIsStartedWithHttpInfo($player) + { + $returnType = '\Swagger\Client\Model\GameIsStarted'; + $request = $this->gameIsStartedRequest($player); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if (!in_array($returnType, ['string','integer','bool'])) { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 0: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Swagger\Client\Model\GameIsStarted', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation gameIsStartedAsync + * + * + * + * @param string $player (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function gameIsStartedAsync($player) + { + return $this->gameIsStartedAsyncWithHttpInfo($player) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation gameIsStartedAsyncWithHttpInfo + * + * + * + * @param string $player (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function gameIsStartedAsyncWithHttpInfo($player) + { + $returnType = '\Swagger\Client\Model\GameIsStarted'; + $request = $this->gameIsStartedRequest($player); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'gameIsStarted' + * + * @param string $player (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function gameIsStartedRequest($player) + { + // verify the required parameter 'player' is set + if ($player === null || (is_array($player) && count($player) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $player when calling gameIsStarted' + ); + } + + $resourcePath = '/game/started/{player}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + // path params + if ($player !== null) { + $resourcePath = str_replace( + '{' . 'player' . '}', + ObjectSerializer::toPathValue($player), + $resourcePath + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getTurn + * + * @param string $player player (required) + * + * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Swagger\Client\Model\MyTurn + */ + public function getTurn($player) + { + list($response) = $this->getTurnWithHttpInfo($player); + return $response; + } + + /** + * Operation getTurnWithHttpInfo + * + * @param string $player (required) + * + * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Swagger\Client\Model\MyTurn, HTTP status code, HTTP response headers (array of strings) + */ + public function getTurnWithHttpInfo($player) + { + $returnType = '\Swagger\Client\Model\MyTurn'; + $request = $this->getTurnRequest($player); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if (!in_array($returnType, ['string','integer','bool'])) { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 0: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Swagger\Client\Model\MyTurn', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getTurnAsync + * + * + * + * @param string $player (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getTurnAsync($player) + { + return $this->getTurnAsyncWithHttpInfo($player) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getTurnAsyncWithHttpInfo + * + * + * + * @param string $player (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getTurnAsyncWithHttpInfo($player) + { + $returnType = '\Swagger\Client\Model\MyTurn'; + $request = $this->getTurnRequest($player); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getTurn' + * + * @param string $player (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function getTurnRequest($player) + { + // verify the required parameter 'player' is set + if ($player === null || (is_array($player) && count($player) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $player when calling getTurn' + ); + } + + $resourcePath = '/player/turn/{player}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + // path params + if ($player !== null) { + $resourcePath = str_replace( + '{' . 'player' . '}', + ObjectSerializer::toPathValue($player), + $resourcePath + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation joinGame + * + * @param string $name name (required) + * @param string $code code (required) + * + * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Swagger\Client\Model\PlayerCode + */ + public function joinGame($name, $code) + { + list($response) = $this->joinGameWithHttpInfo($name, $code); + return $response; + } + + /** + * Operation joinGameWithHttpInfo + * + * @param string $name (required) + * @param string $code (required) + * + * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Swagger\Client\Model\PlayerCode, HTTP status code, HTTP response headers (array of strings) + */ + public function joinGameWithHttpInfo($name, $code) + { + $returnType = '\Swagger\Client\Model\PlayerCode'; + $request = $this->joinGameRequest($name, $code); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if (!in_array($returnType, ['string','integer','bool'])) { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 0: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Swagger\Client\Model\PlayerCode', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation joinGameAsync + * + * + * + * @param string $name (required) + * @param string $code (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function joinGameAsync($name, $code) + { + return $this->joinGameAsyncWithHttpInfo($name, $code) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation joinGameAsyncWithHttpInfo + * + * + * + * @param string $name (required) + * @param string $code (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function joinGameAsyncWithHttpInfo($name, $code) + { + $returnType = '\Swagger\Client\Model\PlayerCode'; + $request = $this->joinGameRequest($name, $code); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'joinGame' + * + * @param string $name (required) + * @param string $code (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function joinGameRequest($name, $code) + { + // verify the required parameter 'name' is set + if ($name === null || (is_array($name) && count($name) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $name when calling joinGame' + ); + } + // verify the required parameter 'code' is set + if ($code === null || (is_array($code) && count($code) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $code when calling joinGame' + ); + } + + $resourcePath = '/game/join/{code}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + if ($name !== null) { + $queryParams['name'] = ObjectSerializer::toQueryValue($name, null); + } + + // path params + if ($code !== null) { + $resourcePath = str_replace( + '{' . 'code' . '}', + ObjectSerializer::toPathValue($code), + $resourcePath + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation postTurn + * + * @param string $player player (required) + * @param \Swagger\Client\Model\PlayerGuess $body body (optional) + * + * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Swagger\Client\Model\MyTurn + */ + public function postTurn($player, $body = null) + { + list($response) = $this->postTurnWithHttpInfo($player, $body); + return $response; + } + + /** + * Operation postTurnWithHttpInfo + * + * @param string $player (required) + * @param \Swagger\Client\Model\PlayerGuess $body (optional) + * + * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Swagger\Client\Model\MyTurn, HTTP status code, HTTP response headers (array of strings) + */ + public function postTurnWithHttpInfo($player, $body = null) + { + $returnType = '\Swagger\Client\Model\MyTurn'; + $request = $this->postTurnRequest($player, $body); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if (!in_array($returnType, ['string','integer','bool'])) { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 0: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Swagger\Client\Model\MyTurn', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation postTurnAsync + * + * + * + * @param string $player (required) + * @param \Swagger\Client\Model\PlayerGuess $body (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postTurnAsync($player, $body = null) + { + return $this->postTurnAsyncWithHttpInfo($player, $body) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation postTurnAsyncWithHttpInfo + * + * + * + * @param string $player (required) + * @param \Swagger\Client\Model\PlayerGuess $body (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postTurnAsyncWithHttpInfo($player, $body = null) + { + $returnType = '\Swagger\Client\Model\MyTurn'; + $request = $this->postTurnRequest($player, $body); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'postTurn' + * + * @param string $player (required) + * @param \Swagger\Client\Model\PlayerGuess $body (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function postTurnRequest($player, $body = null) + { + // verify the required parameter 'player' is set + if ($player === null || (is_array($player) && count($player) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $player when calling postTurn' + ); + } + + $resourcePath = '/player/guess/{player}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + // path params + if ($player !== null) { + $resourcePath = str_replace( + '{' . 'player' . '}', + ObjectSerializer::toPathValue($player), + $resourcePath + ); + } + + // body params + $_tempBody = null; + if (isset($body)) { + $_tempBody = $body; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation setGameRules + * + * @param string $player player (required) + * @param \Swagger\Client\Model\GameRules $body body (optional) + * + * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Swagger\Client\Model\MessageResponse + */ + public function setGameRules($player, $body = null) + { + list($response) = $this->setGameRulesWithHttpInfo($player, $body); + return $response; + } + + /** + * Operation setGameRulesWithHttpInfo + * + * @param string $player (required) + * @param \Swagger\Client\Model\GameRules $body (optional) + * + * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Swagger\Client\Model\MessageResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function setGameRulesWithHttpInfo($player, $body = null) + { + $returnType = '\Swagger\Client\Model\MessageResponse'; + $request = $this->setGameRulesRequest($player, $body); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if (!in_array($returnType, ['string','integer','bool'])) { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 0: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Swagger\Client\Model\MessageResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation setGameRulesAsync + * + * + * + * @param string $player (required) + * @param \Swagger\Client\Model\GameRules $body (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setGameRulesAsync($player, $body = null) + { + return $this->setGameRulesAsyncWithHttpInfo($player, $body) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation setGameRulesAsyncWithHttpInfo + * + * + * + * @param string $player (required) + * @param \Swagger\Client\Model\GameRules $body (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setGameRulesAsyncWithHttpInfo($player, $body = null) + { + $returnType = '\Swagger\Client\Model\MessageResponse'; + $request = $this->setGameRulesRequest($player, $body); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'setGameRules' + * + * @param string $player (required) + * @param \Swagger\Client\Model\GameRules $body (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function setGameRulesRequest($player, $body = null) + { + // verify the required parameter 'player' is set + if ($player === null || (is_array($player) && count($player) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $player when calling setGameRules' + ); + } + + $resourcePath = '/game/rules/{player}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + // path params + if ($player !== null) { + $resourcePath = str_replace( + '{' . 'player' . '}', + ObjectSerializer::toPathValue($player), + $resourcePath + ); + } + + // body params + $_tempBody = null; + if (isset($body)) { + $_tempBody = $body; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation startGame + * + * @param string $player player (required) + * + * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Swagger\Client\Model\MessageResponse + */ + public function startGame($player) + { + list($response) = $this->startGameWithHttpInfo($player); + return $response; + } + + /** + * Operation startGameWithHttpInfo + * + * @param string $player (required) + * + * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Swagger\Client\Model\MessageResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function startGameWithHttpInfo($player) + { + $returnType = '\Swagger\Client\Model\MessageResponse'; + $request = $this->startGameRequest($player); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if (!in_array($returnType, ['string','integer','bool'])) { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 0: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Swagger\Client\Model\MessageResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation startGameAsync + * + * + * + * @param string $player (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function startGameAsync($player) + { + return $this->startGameAsyncWithHttpInfo($player) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation startGameAsyncWithHttpInfo + * + * + * + * @param string $player (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function startGameAsyncWithHttpInfo($player) + { + $returnType = '\Swagger\Client\Model\MessageResponse'; + $request = $this->startGameRequest($player); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'startGame' + * + * @param string $player (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function startGameRequest($player) + { + // verify the required parameter 'player' is set + if ($player === null || (is_array($player) && count($player) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $player when calling startGame' + ); + } + + $resourcePath = '/game/start/{player}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + // path params + if ($player !== null) { + $resourcePath = str_replace( + '{' . 'player' . '}', + ObjectSerializer::toPathValue($player), + $resourcePath + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/lib/ApiException.php b/lib/ApiException.php new file mode 100644 index 0000000..9d74c6e --- /dev/null +++ b/lib/ApiException.php @@ -0,0 +1,120 @@ +responseHeaders = $responseHeaders; + $this->responseBody = $responseBody; + } + + /** + * Gets the HTTP response header + * + * @return string[]|null HTTP response header + */ + public function getResponseHeaders() + { + return $this->responseHeaders; + } + + /** + * Gets the HTTP body of the server response either as Json or string + * + * @return mixed HTTP body of the server response either as \stdClass or string + */ + public function getResponseBody() + { + return $this->responseBody; + } + + /** + * Sets the deseralized response object (during deserialization) + * + * @param mixed $obj Deserialized response object + * + * @return void + */ + public function setResponseObject($obj) + { + $this->responseObject = $obj; + } + + /** + * Gets the deseralized response object (during deserialization) + * + * @return mixed the deserialized response object + */ + public function getResponseObject() + { + return $this->responseObject; + } +} diff --git a/lib/Configuration.php b/lib/Configuration.php new file mode 100644 index 0000000..b2961bd --- /dev/null +++ b/lib/Configuration.php @@ -0,0 +1,428 @@ +tempFolderPath = sys_get_temp_dir(); + } + + /** + * Sets API key + * + * @param string $apiKeyIdentifier API key identifier (authentication scheme) + * @param string $key API key or token + * + * @return $this + */ + public function setApiKey($apiKeyIdentifier, $key) + { + $this->apiKeys[$apiKeyIdentifier] = $key; + return $this; + } + + /** + * Gets API key + * + * @param string $apiKeyIdentifier API key identifier (authentication scheme) + * + * @return string API key or token + */ + public function getApiKey($apiKeyIdentifier) + { + return isset($this->apiKeys[$apiKeyIdentifier]) ? $this->apiKeys[$apiKeyIdentifier] : null; + } + + /** + * Sets the prefix for API key (e.g. Bearer) + * + * @param string $apiKeyIdentifier API key identifier (authentication scheme) + * @param string $prefix API key prefix, e.g. Bearer + * + * @return $this + */ + public function setApiKeyPrefix($apiKeyIdentifier, $prefix) + { + $this->apiKeyPrefixes[$apiKeyIdentifier] = $prefix; + return $this; + } + + /** + * Gets API key prefix + * + * @param string $apiKeyIdentifier API key identifier (authentication scheme) + * + * @return string + */ + public function getApiKeyPrefix($apiKeyIdentifier) + { + return isset($this->apiKeyPrefixes[$apiKeyIdentifier]) ? $this->apiKeyPrefixes[$apiKeyIdentifier] : null; + } + + /** + * Sets the access token for OAuth + * + * @param string $accessToken Token for OAuth + * + * @return $this + */ + public function setAccessToken($accessToken) + { + $this->accessToken = $accessToken; + return $this; + } + + /** + * Gets the access token for OAuth + * + * @return string Access token for OAuth + */ + public function getAccessToken() + { + return $this->accessToken; + } + + /** + * Sets the username for HTTP basic authentication + * + * @param string $username Username for HTTP basic authentication + * + * @return $this + */ + public function setUsername($username) + { + $this->username = $username; + return $this; + } + + /** + * Gets the username for HTTP basic authentication + * + * @return string Username for HTTP basic authentication + */ + public function getUsername() + { + return $this->username; + } + + /** + * Sets the password for HTTP basic authentication + * + * @param string $password Password for HTTP basic authentication + * + * @return $this + */ + public function setPassword($password) + { + $this->password = $password; + return $this; + } + + /** + * Gets the password for HTTP basic authentication + * + * @return string Password for HTTP basic authentication + */ + public function getPassword() + { + return $this->password; + } + + /** + * Sets the host + * + * @param string $host Host + * + * @return $this + */ + public function setHost($host) + { + $this->host = $host; + return $this; + } + + /** + * Gets the host + * + * @return string Host + */ + public function getHost() + { + return $this->host; + } + + /** + * Sets the user agent of the api client + * + * @param string $userAgent the user agent of the api client + * + * @throws \InvalidArgumentException + * @return $this + */ + public function setUserAgent($userAgent) + { + if (!is_string($userAgent)) { + throw new \InvalidArgumentException('User-agent must be a string.'); + } + + $this->userAgent = $userAgent; + return $this; + } + + /** + * Gets the user agent of the api client + * + * @return string user agent + */ + public function getUserAgent() + { + return $this->userAgent; + } + + /** + * Sets debug flag + * + * @param bool $debug Debug flag + * + * @return $this + */ + public function setDebug($debug) + { + $this->debug = $debug; + return $this; + } + + /** + * Gets the debug flag + * + * @return bool + */ + public function getDebug() + { + return $this->debug; + } + + /** + * Sets the debug file + * + * @param string $debugFile Debug file + * + * @return $this + */ + public function setDebugFile($debugFile) + { + $this->debugFile = $debugFile; + return $this; + } + + /** + * Gets the debug file + * + * @return string + */ + public function getDebugFile() + { + return $this->debugFile; + } + + /** + * Sets the temp folder path + * + * @param string $tempFolderPath Temp folder path + * + * @return $this + */ + public function setTempFolderPath($tempFolderPath) + { + $this->tempFolderPath = $tempFolderPath; + return $this; + } + + /** + * Gets the temp folder path + * + * @return string Temp folder path + */ + public function getTempFolderPath() + { + return $this->tempFolderPath; + } + + /** + * Gets the default configuration instance + * + * @return Configuration + */ + public static function getDefaultConfiguration() + { + if (self::$defaultConfiguration === null) { + self::$defaultConfiguration = new Configuration(); + } + + return self::$defaultConfiguration; + } + + /** + * Sets the detault configuration instance + * + * @param Configuration $config An instance of the Configuration Object + * + * @return void + */ + public static function setDefaultConfiguration(Configuration $config) + { + self::$defaultConfiguration = $config; + } + + /** + * Gets the essential information for debugging + * + * @return string The report for debugging + */ + public static function toDebugReport() + { + $report = 'PHP SDK (Swagger\Client) Debug Report:' . PHP_EOL; + $report .= ' OS: ' . php_uname() . PHP_EOL; + $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; + $report .= ' OpenAPI Spec Version: 1.0.0' . PHP_EOL; + $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; + + return $report; + } + + /** + * Get API key (with prefix if set) + * + * @param string $apiKeyIdentifier name of apikey + * + * @return string API key with the prefix + */ + public function getApiKeyWithPrefix($apiKeyIdentifier) + { + $prefix = $this->getApiKeyPrefix($apiKeyIdentifier); + $apiKey = $this->getApiKey($apiKeyIdentifier); + + if ($apiKey === null) { + return null; + } + + if ($prefix === null) { + $keyWithPrefix = $apiKey; + } else { + $keyWithPrefix = $prefix . ' ' . $apiKey; + } + + return $keyWithPrefix; + } +} diff --git a/lib/HeaderSelector.php b/lib/HeaderSelector.php new file mode 100644 index 0000000..3662cb2 --- /dev/null +++ b/lib/HeaderSelector.php @@ -0,0 +1,109 @@ +selectAcceptHeader($accept); + if ($accept !== null) { + $headers['Accept'] = $accept; + } + + $headers['Content-Type'] = $this->selectContentTypeHeader($contentTypes); + return $headers; + } + + /** + * @param string[] $accept + * @return array + */ + public function selectHeadersForMultipart($accept) + { + $headers = $this->selectHeaders($accept, []); + + unset($headers['Content-Type']); + return $headers; + } + + /** + * Return the header 'Accept' based on an array of Accept provided + * + * @param string[] $accept Array of header + * + * @return string Accept (e.g. application/json) + */ + private function selectAcceptHeader($accept) + { + if (count($accept) === 0 || (count($accept) === 1 && $accept[0] === '')) { + return null; + } elseif (preg_grep("/application\/json/i", $accept)) { + return 'application/json'; + } else { + return implode(',', $accept); + } + } + + /** + * Return the content type based on an array of content-type provided + * + * @param string[] $contentType Array fo content-type + * + * @return string Content-Type (e.g. application/json) + */ + private function selectContentTypeHeader($contentType) + { + if (count($contentType) === 0 || (count($contentType) === 1 && $contentType[0] === '')) { + return 'application/json'; + } elseif (preg_grep("/application\/json/i", $contentType)) { + return 'application/json'; + } else { + return implode(',', $contentType); + } + } +} + diff --git a/lib/Model/GameIsStarted.php b/lib/Model/GameIsStarted.php new file mode 100644 index 0000000..72511db --- /dev/null +++ b/lib/Model/GameIsStarted.php @@ -0,0 +1,321 @@ + 'bool', +'game_state' => '\Swagger\Client\Model\GameState' ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $swaggerFormats = [ + 'started' => null, +'game_state' => null ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerTypes() + { + return self::$swaggerTypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerFormats() + { + return self::$swaggerFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'started' => 'started', +'game_state' => 'gameState' ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'started' => 'setStarted', +'game_state' => 'setGameState' ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'started' => 'getStarted', +'game_state' => 'getGameState' ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$swaggerModelName; + } + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['started'] = isset($data['started']) ? $data['started'] : null; + $this->container['game_state'] = isset($data['game_state']) ? $data['game_state'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets started + * + * @return bool + */ + public function getStarted() + { + return $this->container['started']; + } + + /** + * Sets started + * + * @param bool $started started + * + * @return $this + */ + public function setStarted($started) + { + $this->container['started'] = $started; + + return $this; + } + + /** + * Gets game_state + * + * @return \Swagger\Client\Model\GameState + */ + public function getGameState() + { + return $this->container['game_state']; + } + + /** + * Sets game_state + * + * @param \Swagger\Client\Model\GameState $game_state game_state + * + * @return $this + */ + public function setGameState($game_state) + { + $this->container['game_state'] = $game_state; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} diff --git a/lib/Model/GameRules.php b/lib/Model/GameRules.php new file mode 100644 index 0000000..696f6a1 --- /dev/null +++ b/lib/Model/GameRules.php @@ -0,0 +1,471 @@ + 'int', +'higher_count_lower_value' => 'bool', +'joker_counts_double' => 'bool', +'has_joker' => 'bool', +'has_palifico' => 'bool', +'has_calza' => 'bool', +'joker_die_value' => 'int' ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $swaggerFormats = [ + 'start_dice_per_player' => null, +'higher_count_lower_value' => null, +'joker_counts_double' => null, +'has_joker' => null, +'has_palifico' => null, +'has_calza' => null, +'joker_die_value' => null ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerTypes() + { + return self::$swaggerTypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerFormats() + { + return self::$swaggerFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'start_dice_per_player' => 'startDicePerPlayer', +'higher_count_lower_value' => 'higherCountLowerValue', +'joker_counts_double' => 'jokerCountsDouble', +'has_joker' => 'hasJoker', +'has_palifico' => 'hasPalifico', +'has_calza' => 'hasCalza', +'joker_die_value' => 'jokerDieValue' ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'start_dice_per_player' => 'setStartDicePerPlayer', +'higher_count_lower_value' => 'setHigherCountLowerValue', +'joker_counts_double' => 'setJokerCountsDouble', +'has_joker' => 'setHasJoker', +'has_palifico' => 'setHasPalifico', +'has_calza' => 'setHasCalza', +'joker_die_value' => 'setJokerDieValue' ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'start_dice_per_player' => 'getStartDicePerPlayer', +'higher_count_lower_value' => 'getHigherCountLowerValue', +'joker_counts_double' => 'getJokerCountsDouble', +'has_joker' => 'getHasJoker', +'has_palifico' => 'getHasPalifico', +'has_calza' => 'getHasCalza', +'joker_die_value' => 'getJokerDieValue' ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$swaggerModelName; + } + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['start_dice_per_player'] = isset($data['start_dice_per_player']) ? $data['start_dice_per_player'] : null; + $this->container['higher_count_lower_value'] = isset($data['higher_count_lower_value']) ? $data['higher_count_lower_value'] : null; + $this->container['joker_counts_double'] = isset($data['joker_counts_double']) ? $data['joker_counts_double'] : null; + $this->container['has_joker'] = isset($data['has_joker']) ? $data['has_joker'] : null; + $this->container['has_palifico'] = isset($data['has_palifico']) ? $data['has_palifico'] : null; + $this->container['has_calza'] = isset($data['has_calza']) ? $data['has_calza'] : null; + $this->container['joker_die_value'] = isset($data['joker_die_value']) ? $data['joker_die_value'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets start_dice_per_player + * + * @return int + */ + public function getStartDicePerPlayer() + { + return $this->container['start_dice_per_player']; + } + + /** + * Sets start_dice_per_player + * + * @param int $start_dice_per_player start_dice_per_player + * + * @return $this + */ + public function setStartDicePerPlayer($start_dice_per_player) + { + $this->container['start_dice_per_player'] = $start_dice_per_player; + + return $this; + } + + /** + * Gets higher_count_lower_value + * + * @return bool + */ + public function getHigherCountLowerValue() + { + return $this->container['higher_count_lower_value']; + } + + /** + * Sets higher_count_lower_value + * + * @param bool $higher_count_lower_value higher_count_lower_value + * + * @return $this + */ + public function setHigherCountLowerValue($higher_count_lower_value) + { + $this->container['higher_count_lower_value'] = $higher_count_lower_value; + + return $this; + } + + /** + * Gets joker_counts_double + * + * @return bool + */ + public function getJokerCountsDouble() + { + return $this->container['joker_counts_double']; + } + + /** + * Sets joker_counts_double + * + * @param bool $joker_counts_double joker_counts_double + * + * @return $this + */ + public function setJokerCountsDouble($joker_counts_double) + { + $this->container['joker_counts_double'] = $joker_counts_double; + + return $this; + } + + /** + * Gets has_joker + * + * @return bool + */ + public function getHasJoker() + { + return $this->container['has_joker']; + } + + /** + * Sets has_joker + * + * @param bool $has_joker has_joker + * + * @return $this + */ + public function setHasJoker($has_joker) + { + $this->container['has_joker'] = $has_joker; + + return $this; + } + + /** + * Gets has_palifico + * + * @return bool + */ + public function getHasPalifico() + { + return $this->container['has_palifico']; + } + + /** + * Sets has_palifico + * + * @param bool $has_palifico has_palifico + * + * @return $this + */ + public function setHasPalifico($has_palifico) + { + $this->container['has_palifico'] = $has_palifico; + + return $this; + } + + /** + * Gets has_calza + * + * @return bool + */ + public function getHasCalza() + { + return $this->container['has_calza']; + } + + /** + * Sets has_calza + * + * @param bool $has_calza has_calza + * + * @return $this + */ + public function setHasCalza($has_calza) + { + $this->container['has_calza'] = $has_calza; + + return $this; + } + + /** + * Gets joker_die_value + * + * @return int + */ + public function getJokerDieValue() + { + return $this->container['joker_die_value']; + } + + /** + * Sets joker_die_value + * + * @param int $joker_die_value joker_die_value + * + * @return $this + */ + public function setJokerDieValue($joker_die_value) + { + $this->container['joker_die_value'] = $joker_die_value; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} diff --git a/lib/Model/GameState.php b/lib/Model/GameState.php new file mode 100644 index 0000000..5b0242d --- /dev/null +++ b/lib/Model/GameState.php @@ -0,0 +1,471 @@ + 'string', +'code' => 'string', +'rounds' => '\Swagger\Client\Model\Round[]', +'players' => '\Swagger\Client\Model\Player[]', +'current_player' => '\Swagger\Client\Model\Player', +'owning_player' => '\Swagger\Client\Model\Player', +'rules' => '\Swagger\Client\Model\GameRules' ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $swaggerFormats = [ + 'state' => null, +'code' => null, +'rounds' => null, +'players' => null, +'current_player' => null, +'owning_player' => null, +'rules' => null ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerTypes() + { + return self::$swaggerTypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerFormats() + { + return self::$swaggerFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'state' => 'state', +'code' => 'code', +'rounds' => 'rounds', +'players' => 'players', +'current_player' => 'currentPlayer', +'owning_player' => 'owningPlayer', +'rules' => 'rules' ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'state' => 'setState', +'code' => 'setCode', +'rounds' => 'setRounds', +'players' => 'setPlayers', +'current_player' => 'setCurrentPlayer', +'owning_player' => 'setOwningPlayer', +'rules' => 'setRules' ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'state' => 'getState', +'code' => 'getCode', +'rounds' => 'getRounds', +'players' => 'getPlayers', +'current_player' => 'getCurrentPlayer', +'owning_player' => 'getOwningPlayer', +'rules' => 'getRules' ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$swaggerModelName; + } + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['state'] = isset($data['state']) ? $data['state'] : null; + $this->container['code'] = isset($data['code']) ? $data['code'] : null; + $this->container['rounds'] = isset($data['rounds']) ? $data['rounds'] : null; + $this->container['players'] = isset($data['players']) ? $data['players'] : null; + $this->container['current_player'] = isset($data['current_player']) ? $data['current_player'] : null; + $this->container['owning_player'] = isset($data['owning_player']) ? $data['owning_player'] : null; + $this->container['rules'] = isset($data['rules']) ? $data['rules'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets state + * + * @return string + */ + public function getState() + { + return $this->container['state']; + } + + /** + * Sets state + * + * @param string $state state + * + * @return $this + */ + public function setState($state) + { + $this->container['state'] = $state; + + return $this; + } + + /** + * Gets code + * + * @return string + */ + public function getCode() + { + return $this->container['code']; + } + + /** + * Sets code + * + * @param string $code code + * + * @return $this + */ + public function setCode($code) + { + $this->container['code'] = $code; + + return $this; + } + + /** + * Gets rounds + * + * @return \Swagger\Client\Model\Round[] + */ + public function getRounds() + { + return $this->container['rounds']; + } + + /** + * Sets rounds + * + * @param \Swagger\Client\Model\Round[] $rounds rounds + * + * @return $this + */ + public function setRounds($rounds) + { + $this->container['rounds'] = $rounds; + + return $this; + } + + /** + * Gets players + * + * @return \Swagger\Client\Model\Player[] + */ + public function getPlayers() + { + return $this->container['players']; + } + + /** + * Sets players + * + * @param \Swagger\Client\Model\Player[] $players players + * + * @return $this + */ + public function setPlayers($players) + { + $this->container['players'] = $players; + + return $this; + } + + /** + * Gets current_player + * + * @return \Swagger\Client\Model\Player + */ + public function getCurrentPlayer() + { + return $this->container['current_player']; + } + + /** + * Sets current_player + * + * @param \Swagger\Client\Model\Player $current_player current_player + * + * @return $this + */ + public function setCurrentPlayer($current_player) + { + $this->container['current_player'] = $current_player; + + return $this; + } + + /** + * Gets owning_player + * + * @return \Swagger\Client\Model\Player + */ + public function getOwningPlayer() + { + return $this->container['owning_player']; + } + + /** + * Sets owning_player + * + * @param \Swagger\Client\Model\Player $owning_player owning_player + * + * @return $this + */ + public function setOwningPlayer($owning_player) + { + $this->container['owning_player'] = $owning_player; + + return $this; + } + + /** + * Gets rules + * + * @return \Swagger\Client\Model\GameRules + */ + public function getRules() + { + return $this->container['rules']; + } + + /** + * Sets rules + * + * @param \Swagger\Client\Model\GameRules $rules rules + * + * @return $this + */ + public function setRules($rules) + { + $this->container['rules'] = $rules; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} diff --git a/lib/Model/MessageResponse.php b/lib/Model/MessageResponse.php new file mode 100644 index 0000000..6034ca7 --- /dev/null +++ b/lib/Model/MessageResponse.php @@ -0,0 +1,321 @@ + 'string', +'errors' => 'string[]' ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $swaggerFormats = [ + 'message' => null, +'errors' => null ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerTypes() + { + return self::$swaggerTypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerFormats() + { + return self::$swaggerFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'message' => 'message', +'errors' => 'errors' ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'message' => 'setMessage', +'errors' => 'setErrors' ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'message' => 'getMessage', +'errors' => 'getErrors' ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$swaggerModelName; + } + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['message'] = isset($data['message']) ? $data['message'] : null; + $this->container['errors'] = isset($data['errors']) ? $data['errors'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets message + * + * @return string + */ + public function getMessage() + { + return $this->container['message']; + } + + /** + * Sets message + * + * @param string $message message + * + * @return $this + */ + public function setMessage($message) + { + $this->container['message'] = $message; + + return $this; + } + + /** + * Gets errors + * + * @return string[] + */ + public function getErrors() + { + return $this->container['errors']; + } + + /** + * Sets errors + * + * @param string[] $errors errors + * + * @return $this + */ + public function setErrors($errors) + { + $this->container['errors'] = $errors; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} diff --git a/lib/Model/ModelInterface.php b/lib/Model/ModelInterface.php new file mode 100644 index 0000000..af22eed --- /dev/null +++ b/lib/Model/ModelInterface.php @@ -0,0 +1,95 @@ + 'bool', +'game_state' => '\Swagger\Client\Model\GameState', +'errors' => 'string[]' ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $swaggerFormats = [ + 'turn' => null, +'game_state' => null, +'errors' => null ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerTypes() + { + return self::$swaggerTypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerFormats() + { + return self::$swaggerFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'turn' => 'turn', +'game_state' => 'gameState', +'errors' => 'errors' ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'turn' => 'setTurn', +'game_state' => 'setGameState', +'errors' => 'setErrors' ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'turn' => 'getTurn', +'game_state' => 'getGameState', +'errors' => 'getErrors' ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$swaggerModelName; + } + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['turn'] = isset($data['turn']) ? $data['turn'] : null; + $this->container['game_state'] = isset($data['game_state']) ? $data['game_state'] : null; + $this->container['errors'] = isset($data['errors']) ? $data['errors'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets turn + * + * @return bool + */ + public function getTurn() + { + return $this->container['turn']; + } + + /** + * Sets turn + * + * @param bool $turn turn + * + * @return $this + */ + public function setTurn($turn) + { + $this->container['turn'] = $turn; + + return $this; + } + + /** + * Gets game_state + * + * @return \Swagger\Client\Model\GameState + */ + public function getGameState() + { + return $this->container['game_state']; + } + + /** + * Sets game_state + * + * @param \Swagger\Client\Model\GameState $game_state game_state + * + * @return $this + */ + public function setGameState($game_state) + { + $this->container['game_state'] = $game_state; + + return $this; + } + + /** + * Gets errors + * + * @return string[] + */ + public function getErrors() + { + return $this->container['errors']; + } + + /** + * Sets errors + * + * @param string[] $errors errors + * + * @return $this + */ + public function setErrors($errors) + { + $this->container['errors'] = $errors; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} diff --git a/lib/Model/Player.php b/lib/Model/Player.php new file mode 100644 index 0000000..deb02e6 --- /dev/null +++ b/lib/Model/Player.php @@ -0,0 +1,351 @@ + 'string', +'hash' => 'string', +'name' => 'string' ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $swaggerFormats = [ + 'id' => null, +'hash' => null, +'name' => null ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerTypes() + { + return self::$swaggerTypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerFormats() + { + return self::$swaggerFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', +'hash' => 'hash', +'name' => 'name' ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', +'hash' => 'setHash', +'name' => 'setName' ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', +'hash' => 'getHash', +'name' => 'getName' ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$swaggerModelName; + } + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['id'] = isset($data['id']) ? $data['id'] : null; + $this->container['hash'] = isset($data['hash']) ? $data['hash'] : null; + $this->container['name'] = isset($data['name']) ? $data['name'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return string + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string $id id + * + * @return $this + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets hash + * + * @return string + */ + public function getHash() + { + return $this->container['hash']; + } + + /** + * Sets hash + * + * @param string $hash hash + * + * @return $this + */ + public function setHash($hash) + { + $this->container['hash'] = $hash; + + return $this; + } + + /** + * Gets name + * + * @return string + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string $name name + * + * @return $this + */ + public function setName($name) + { + $this->container['name'] = $name; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} diff --git a/lib/Model/PlayerCode.php b/lib/Model/PlayerCode.php new file mode 100644 index 0000000..900add8 --- /dev/null +++ b/lib/Model/PlayerCode.php @@ -0,0 +1,351 @@ + '\Swagger\Client\Model\Player', +'code' => 'string', +'errors' => 'string[]' ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $swaggerFormats = [ + 'player' => null, +'code' => null, +'errors' => null ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerTypes() + { + return self::$swaggerTypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerFormats() + { + return self::$swaggerFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'player' => 'player', +'code' => 'code', +'errors' => 'errors' ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'player' => 'setPlayer', +'code' => 'setCode', +'errors' => 'setErrors' ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'player' => 'getPlayer', +'code' => 'getCode', +'errors' => 'getErrors' ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$swaggerModelName; + } + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['player'] = isset($data['player']) ? $data['player'] : null; + $this->container['code'] = isset($data['code']) ? $data['code'] : null; + $this->container['errors'] = isset($data['errors']) ? $data['errors'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets player + * + * @return \Swagger\Client\Model\Player + */ + public function getPlayer() + { + return $this->container['player']; + } + + /** + * Sets player + * + * @param \Swagger\Client\Model\Player $player player + * + * @return $this + */ + public function setPlayer($player) + { + $this->container['player'] = $player; + + return $this; + } + + /** + * Gets code + * + * @return string + */ + public function getCode() + { + return $this->container['code']; + } + + /** + * Sets code + * + * @param string $code code + * + * @return $this + */ + public function setCode($code) + { + $this->container['code'] = $code; + + return $this; + } + + /** + * Gets errors + * + * @return string[] + */ + public function getErrors() + { + return $this->container['errors']; + } + + /** + * Sets errors + * + * @param string[] $errors errors + * + * @return $this + */ + public function setErrors($errors) + { + $this->container['errors'] = $errors; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} diff --git a/lib/Model/PlayerGuess.php b/lib/Model/PlayerGuess.php new file mode 100644 index 0000000..d289fe1 --- /dev/null +++ b/lib/Model/PlayerGuess.php @@ -0,0 +1,327 @@ + 'int', +'die_value' => 'int' ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $swaggerFormats = [ + 'dice_count' => null, +'die_value' => null ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerTypes() + { + return self::$swaggerTypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerFormats() + { + return self::$swaggerFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'dice_count' => 'diceCount', +'die_value' => 'dieValue' ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'dice_count' => 'setDiceCount', +'die_value' => 'setDieValue' ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'dice_count' => 'getDiceCount', +'die_value' => 'getDieValue' ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$swaggerModelName; + } + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['dice_count'] = isset($data['dice_count']) ? $data['dice_count'] : null; + $this->container['die_value'] = isset($data['die_value']) ? $data['die_value'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['dice_count'] === null) { + $invalidProperties[] = "'dice_count' can't be null"; + } + if ($this->container['die_value'] === null) { + $invalidProperties[] = "'die_value' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets dice_count + * + * @return int + */ + public function getDiceCount() + { + return $this->container['dice_count']; + } + + /** + * Sets dice_count + * + * @param int $dice_count dice_count + * + * @return $this + */ + public function setDiceCount($dice_count) + { + $this->container['dice_count'] = $dice_count; + + return $this; + } + + /** + * Gets die_value + * + * @return int + */ + public function getDieValue() + { + return $this->container['die_value']; + } + + /** + * Sets die_value + * + * @param int $die_value die_value + * + * @return $this + */ + public function setDieValue($die_value) + { + $this->container['die_value'] = $die_value; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} diff --git a/lib/Model/Round.php b/lib/Model/Round.php new file mode 100644 index 0000000..6f4df6c --- /dev/null +++ b/lib/Model/Round.php @@ -0,0 +1,411 @@ + 'int', +'turns' => '\Swagger\Client\Model\Turn[]', +'loser' => '\Swagger\Client\Model\Player', +'my_rolls' => 'int[]', +'rolls' => 'int[][]' ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $swaggerFormats = [ + 'number' => null, +'turns' => null, +'loser' => null, +'my_rolls' => null, +'rolls' => null ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerTypes() + { + return self::$swaggerTypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerFormats() + { + return self::$swaggerFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'number' => 'number', +'turns' => 'turns', +'loser' => 'loser', +'my_rolls' => 'myRolls', +'rolls' => 'rolls' ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'number' => 'setNumber', +'turns' => 'setTurns', +'loser' => 'setLoser', +'my_rolls' => 'setMyRolls', +'rolls' => 'setRolls' ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'number' => 'getNumber', +'turns' => 'getTurns', +'loser' => 'getLoser', +'my_rolls' => 'getMyRolls', +'rolls' => 'getRolls' ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$swaggerModelName; + } + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['number'] = isset($data['number']) ? $data['number'] : null; + $this->container['turns'] = isset($data['turns']) ? $data['turns'] : null; + $this->container['loser'] = isset($data['loser']) ? $data['loser'] : null; + $this->container['my_rolls'] = isset($data['my_rolls']) ? $data['my_rolls'] : null; + $this->container['rolls'] = isset($data['rolls']) ? $data['rolls'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets number + * + * @return int + */ + public function getNumber() + { + return $this->container['number']; + } + + /** + * Sets number + * + * @param int $number number + * + * @return $this + */ + public function setNumber($number) + { + $this->container['number'] = $number; + + return $this; + } + + /** + * Gets turns + * + * @return \Swagger\Client\Model\Turn[] + */ + public function getTurns() + { + return $this->container['turns']; + } + + /** + * Sets turns + * + * @param \Swagger\Client\Model\Turn[] $turns turns + * + * @return $this + */ + public function setTurns($turns) + { + $this->container['turns'] = $turns; + + return $this; + } + + /** + * Gets loser + * + * @return AllOfRoundLoser + */ + public function getLoser() + { + return $this->container['loser']; + } + + /** + * Sets loser + * + * @param AllOfRoundLoser $loser loser + * + * @return $this + */ + public function setLoser($loser) + { + $this->container['loser'] = $loser; + + return $this; + } + + /** + * Gets my_rolls + * + * @return int[][] + */ + public function getMyRolls() + { + return $this->container['my_rolls']; + } + + /** + * Sets my_rolls + * + * @param int[][] $my_rolls my_rolls + * + * @return $this + */ + public function setMyRolls($my_rolls) + { + $this->container['my_rolls'] = $my_rolls; + + return $this; + } + + /** + * Gets rolls + * + * @return int[] + */ + public function getRolls() + { + return $this->container['rolls']; + } + + /** + * Sets rolls + * + * @param int[] $rolls rolls + * + * @return $this + */ + public function setRolls($rolls) + { + $this->container['rolls'] = $rolls; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} diff --git a/lib/Model/Turn.php b/lib/Model/Turn.php new file mode 100644 index 0000000..fc10c0c --- /dev/null +++ b/lib/Model/Turn.php @@ -0,0 +1,381 @@ + 'int', +'player' => '\Swagger\Client\Model\Player', +'dice_count' => 'int', +'die_value' => 'int' ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $swaggerFormats = [ + 'number' => null, +'player' => null, +'dice_count' => null, +'die_value' => null ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerTypes() + { + return self::$swaggerTypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerFormats() + { + return self::$swaggerFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'number' => 'number', +'player' => 'player', +'dice_count' => 'diceCount', +'die_value' => 'dieValue' ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'number' => 'setNumber', +'player' => 'setPlayer', +'dice_count' => 'setDiceCount', +'die_value' => 'setDieValue' ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'number' => 'getNumber', +'player' => 'getPlayer', +'dice_count' => 'getDiceCount', +'die_value' => 'getDieValue' ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$swaggerModelName; + } + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['number'] = isset($data['number']) ? $data['number'] : null; + $this->container['player'] = isset($data['player']) ? $data['player'] : null; + $this->container['dice_count'] = isset($data['dice_count']) ? $data['dice_count'] : null; + $this->container['die_value'] = isset($data['die_value']) ? $data['die_value'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets number + * + * @return int + */ + public function getNumber() + { + return $this->container['number']; + } + + /** + * Sets number + * + * @param int $number number + * + * @return $this + */ + public function setNumber($number) + { + $this->container['number'] = $number; + + return $this; + } + + /** + * Gets player + * + * @return \Swagger\Client\Model\Player + */ + public function getPlayer() + { + return $this->container['player']; + } + + /** + * Sets player + * + * @param \Swagger\Client\Model\Player $player player + * + * @return $this + */ + public function setPlayer($player) + { + $this->container['player'] = $player; + + return $this; + } + + /** + * Gets dice_count + * + * @return int + */ + public function getDiceCount() + { + return $this->container['dice_count']; + } + + /** + * Sets dice_count + * + * @param int $dice_count dice_count + * + * @return $this + */ + public function setDiceCount($dice_count) + { + $this->container['dice_count'] = $dice_count; + + return $this; + } + + /** + * Gets die_value + * + * @return int + */ + public function getDieValue() + { + return $this->container['die_value']; + } + + /** + * Sets die_value + * + * @param int $die_value die_value + * + * @return $this + */ + public function setDieValue($die_value) + { + $this->container['die_value'] = $die_value; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} diff --git a/lib/ObjectSerializer.php b/lib/ObjectSerializer.php new file mode 100644 index 0000000..13dff02 --- /dev/null +++ b/lib/ObjectSerializer.php @@ -0,0 +1,318 @@ +format('Y-m-d') : $data->format(\DateTime::ATOM); + } elseif (is_array($data)) { + foreach ($data as $property => $value) { + $data[$property] = self::sanitizeForSerialization($value); + } + return $data; + } elseif (is_object($data)) { + $values = []; + $formats = $data::swaggerFormats(); + foreach ($data::swaggerTypes() as $property => $swaggerType) { + $getter = $data::getters()[$property]; + $value = $data->$getter(); + if ($value !== null + && !in_array($swaggerType, ['DateTime', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true) + && method_exists($swaggerType, 'getAllowableEnumValues') + && !in_array($value, $swaggerType::getAllowableEnumValues())) { + $imploded = implode("', '", $swaggerType::getAllowableEnumValues()); + throw new \InvalidArgumentException("Invalid value for enum '$swaggerType', must be one of: '$imploded'"); + } + if ($value !== null) { + $values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value, $swaggerType, $formats[$property]); + } + } + return (object)$values; + } else { + return (string)$data; + } + } + + /** + * Sanitize filename by removing path. + * e.g. ../../sun.gif becomes sun.gif + * + * @param string $filename filename to be sanitized + * + * @return string the sanitized filename + */ + public static function sanitizeFilename($filename) + { + if (preg_match("/.*[\/\\\\](.*)$/", $filename, $match)) { + return $match[1]; + } else { + return $filename; + } + } + + /** + * Take value and turn it into a string suitable for inclusion in + * the path, by url-encoding. + * + * @param string $value a string which will be part of the path + * + * @return string the serialized object + */ + public static function toPathValue($value) + { + return rawurlencode(self::toString($value)); + } + + /** + * Take value and turn it into a string suitable for inclusion in + * the query, by imploding comma-separated if it's an object. + * If it's a string, pass through unchanged. It will be url-encoded + * later. + * + * @param string[]|string|\DateTime $object an object to be serialized to a string + * @param string|null $format the format of the parameter + * + * @return string the serialized object + */ + public static function toQueryValue($object, $format = null) + { + if (is_array($object)) { + return implode(',', $object); + } else { + return self::toString($object, $format); + } + } + + /** + * Take value and turn it into a string suitable for inclusion in + * the header. If it's a string, pass through unchanged + * If it's a datetime object, format it in RFC3339 + * + * @param string $value a string which will be part of the header + * + * @return string the header string + */ + public static function toHeaderValue($value) + { + return self::toString($value); + } + + /** + * Take value and turn it into a string suitable for inclusion in + * the http body (form parameter). If it's a string, pass through unchanged + * If it's a datetime object, format it in RFC3339 + * + * @param string|\SplFileObject $value the value of the form parameter + * + * @return string the form string + */ + public static function toFormValue($value) + { + if ($value instanceof \SplFileObject) { + return $value->getRealPath(); + } else { + return self::toString($value); + } + } + + /** + * Take value and turn it into a string suitable for inclusion in + * the parameter. If it's a string, pass through unchanged + * If it's a datetime object, format it in RFC3339 + * If it's a date, format it in Y-m-d + * + * @param string|\DateTime $value the value of the parameter + * @param string|null $format the format of the parameter + * + * @return string the header string + */ + public static function toString($value, $format = null) + { + if ($value instanceof \DateTime) { + return ($format === 'date') ? $value->format('Y-m-d') : $value->format(\DateTime::ATOM); + } else { + return $value; + } + } + + /** + * Serialize an array to a string. + * + * @param array $collection collection to serialize to a string + * @param string $collectionFormat the format use for serialization (csv, + * ssv, tsv, pipes, multi) + * @param bool $allowCollectionFormatMulti allow collection format to be a multidimensional array + * + * @return string + */ + public static function serializeCollection(array $collection, $collectionFormat, $allowCollectionFormatMulti = false) + { + if ($allowCollectionFormatMulti && ('multi' === $collectionFormat)) { + // http_build_query() almost does the job for us. We just + // need to fix the result of multidimensional arrays. + return preg_replace('/%5B[0-9]+%5D=/', '=', http_build_query($collection, '', '&')); + } + switch ($collectionFormat) { + case 'pipes': + return implode('|', $collection); + + case 'tsv': + return implode("\t", $collection); + + case 'ssv': + return implode(' ', $collection); + + case 'csv': + // Deliberate fall through. CSV is default format. + default: + return implode(',', $collection); + } + } + + /** + * Deserialize a JSON string into an object + * + * @param mixed $data object or primitive to be deserialized + * @param string $class class name is passed as a string + * @param string[] $httpHeaders HTTP headers + * @param string $discriminator discriminator if polymorphism is used + * + * @return object|array|null an single or an array of $class instances + */ + public static function deserialize($data, $class, $httpHeaders = null) + { + if (null === $data) { + return null; + } elseif (substr($class, 0, 4) === 'map[') { // for associative array e.g. map[string,int] + $inner = substr($class, 4, -1); + $deserialized = []; + if (strrpos($inner, ",") !== false) { + $subClass_array = explode(',', $inner, 2); + $subClass = $subClass_array[1]; + foreach ($data as $key => $value) { + $deserialized[$key] = self::deserialize($value, $subClass, null); + } + } + return $deserialized; + } elseif (strcasecmp(substr($class, -2), '[]') === 0) { + $subClass = substr($class, 0, -2); + $values = []; + foreach ($data as $key => $value) { + $values[] = self::deserialize($value, $subClass, null); + } + return $values; + } elseif ($class === 'object') { + settype($data, 'array'); + return $data; + } elseif ($class === '\DateTime') { + // Some API's return an invalid, empty string as a + // date-time property. DateTime::__construct() will return + // the current time for empty input which is probably not + // what is meant. The invalid empty string is probably to + // be interpreted as a missing field/value. Let's handle + // this graceful. + if (!empty($data)) { + return new \DateTime($data); + } else { + return null; + } + } elseif (in_array($class, ['DateTime', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) { + settype($data, $class); + return $data; + } elseif ($class === '\SplFileObject') { + /** @var \Psr\Http\Message\StreamInterface $data */ + + // determine file name + if (array_key_exists('Content-Disposition', $httpHeaders) && + preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeaders['Content-Disposition'], $match)) { + $filename = Configuration::getDefaultConfiguration()->getTempFolderPath() . DIRECTORY_SEPARATOR . self::sanitizeFilename($match[1]); + } else { + $filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), ''); + } + + $file = fopen($filename, 'w'); + while ($chunk = $data->read(200)) { + fwrite($file, $chunk); + } + fclose($file); + + return new \SplFileObject($filename, 'r'); + } elseif (method_exists($class, 'getAllowableEnumValues')) { + if (!in_array($data, $class::getAllowableEnumValues())) { + $imploded = implode("', '", $class::getAllowableEnumValues()); + throw new \InvalidArgumentException("Invalid value for enum '$class', must be one of: '$imploded'"); + } + return $data; + } else { + // If a discriminator is defined and points to a valid subclass, use it. + $discriminator = $class::DISCRIMINATOR; + if (!empty($discriminator) && isset($data->{$discriminator}) && is_string($data->{$discriminator})) { + $subclass = '{{invokerPackage}}\Model\\' . $data->{$discriminator}; + if (is_subclass_of($subclass, $class)) { + $class = $subclass; + } + } + $instance = new $class(); + foreach ($instance::swaggerTypes() as $property => $type) { + $propertySetter = $instance::setters()[$property]; + + if (!isset($propertySetter) || !isset($data->{$instance::attributeMap()[$property]})) { + continue; + } + + $propertyValue = $data->{$instance::attributeMap()[$property]}; + if (isset($propertyValue)) { + $instance->$propertySetter(self::deserialize($propertyValue, $type, null)); + } + } + return $instance; + } + } +}