Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
],
"require": {
"php": ">=7.4",
"guzzlehttp/guzzle": "^6.0 || ^7.0",
"netresearch/jsonmapper": "^1.4 || ^2.0 || ^3.0 || ^4.0 || ^5.0",
"guzzlehttp/guzzle": "^6.0 || ^7.0 || ^8.0",
"netresearch/jsonmapper": "1.4 || ^2.0 || ^3.0 || ^4.0 || ^5.0 || ^6.0",
"psr/http-message": "^1.1 || ^2.0",
"ext-json": "*"
},
"require-dev": {
"roave/security-advisories": "dev-latest",
"sturents/swagger-php-model-generator": "^0.3",
"vimeo/psalm": "^6.12"
"psalm/phar": "^6.16"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 2 additions & 0 deletions generate.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
use SwaggerGen\GenerateModels;
use SwaggerGen\GenerateRequests;

// Ensure packages such as sturents/swagger-php-model-generator are upto date when generating
shell_exec('composer update');
require __DIR__.'/vendor/autoload.php';

$namespace = "SturentsLib\\Api";
Expand Down
2 changes: 1 addition & 1 deletion src/Requests/DeleteContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct($property_id, $contract_id)
public function sendWith(SwaggerClient $client)
{
return $client->make($this, [
'204' => '',
'204' => null,
'401' => \SturentsLib\Api\Models\AuthError::class,
'404' => \SturentsLib\Api\Models\Error::class,
'default' => \SturentsLib\Api\Models\Error::class
Expand Down
2 changes: 1 addition & 1 deletion src/Requests/DeleteMedia.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct($property_id, $media_id)
public function sendWith(SwaggerClient $client)
{
return $client->make($this, [
'204' => '',
'204' => null,
'401' => \SturentsLib\Api\Models\AuthError::class,
'404' => \SturentsLib\Api\Models\Error::class,
'default' => \SturentsLib\Api\Models\Error::class
Expand Down
2 changes: 1 addition & 1 deletion src/Requests/DeleteRoom.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct($property_id, $room_id)
public function sendWith(SwaggerClient $client)
{
return $client->make($this, [
'204' => '',
'204' => null,
'401' => \SturentsLib\Api\Models\AuthError::class,
'404' => \SturentsLib\Api\Models\Error::class,
'default' => \SturentsLib\Api\Models\Error::class
Expand Down
2 changes: 1 addition & 1 deletion src/Requests/GetFacilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class GetFacilities extends SwaggerRequest
public function sendWith(SwaggerClient $client)
{
return $client->make($this, [
'200' => ''
'200' => null
]);
}
}
2 changes: 1 addition & 1 deletion src/Requests/PatchContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class PatchContract extends SwaggerRequest
*/
public function setBody(\SturentsLib\Api\Models\ContractCreation $contract)
{
$this->body = json_encode($contract);
$this->body = json_encode($contract, JSON_THROW_ON_ERROR);
}


Expand Down
2 changes: 1 addition & 1 deletion src/Requests/PatchProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class PatchProperty extends SwaggerRequest
*/
public function setBody(\SturentsLib\Api\Models\Property $property)
{
$this->body = json_encode($property);
$this->body = json_encode($property, JSON_THROW_ON_ERROR);
}


Expand Down
2 changes: 1 addition & 1 deletion src/Requests/PatchRoom.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class PatchRoom extends SwaggerRequest
*/
public function setBody(\SturentsLib\Api\Models\Room $room)
{
$this->body = json_encode($room);
$this->body = json_encode($room, JSON_THROW_ON_ERROR);
}


Expand Down
2 changes: 1 addition & 1 deletion src/Requests/PutContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class PutContract extends SwaggerRequest
*/
public function setBody(\SturentsLib\Api\Models\ContractCreation $contract)
{
$this->body = json_encode($contract);
$this->body = json_encode($contract, JSON_THROW_ON_ERROR);
}


Expand Down
2 changes: 1 addition & 1 deletion src/Requests/PutMedia.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class PutMedia extends SwaggerRequest
*/
public function setBody(\SturentsLib\Api\Models\MediaUpload $mediaupload)
{
$this->body = json_encode($mediaupload);
$this->body = json_encode($mediaupload, JSON_THROW_ON_ERROR);
}


Expand Down
2 changes: 1 addition & 1 deletion src/Requests/PutProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class PutProperty extends SwaggerRequest
*/
public function setBody(\SturentsLib\Api\Models\PropertyCreation $property)
{
$this->body = json_encode($property);
$this->body = json_encode($property, JSON_THROW_ON_ERROR);
}


Expand Down
2 changes: 1 addition & 1 deletion src/Requests/PutRoom.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class PutRoom extends SwaggerRequest
*/
public function setBody(\SturentsLib\Api\Models\Room $room)
{
$this->body = json_encode($room);
$this->body = json_encode($room, JSON_THROW_ON_ERROR);
}


Expand Down
2 changes: 1 addition & 1 deletion src/Requests/SwaggerClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface SwaggerClient {
/**
* @template T of SwaggerModel
*
* @param array<array-key, class-string<T>|''> $response_models
* @param array<array-key, class-string<T>|null> $response_models
* @return T|list<T>
*/
public function make(SwaggerRequest $swagger, array $response_models);
Expand Down
3 changes: 2 additions & 1 deletion src/SturentsClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ public function make(SwaggerRequest $swagger, array $response_models){
}
catch (ClientException $e) {
$this->debug_request_exception = $e;
if (!$e->hasResponse()){
// In Guzzle 8 ClientException always has a ResponseInterface
if (method_exists($e, 'hasResponse') && !$e->hasResponse()){
throw new SturentsException("The StuRents API could not be reached. The client reported: {$e->getMessage()}", self::EX_CODE_RESPONSE);
}

Expand Down