From 4c8f83806066e8d4a67b5bd9bb62c8c81b40e06d Mon Sep 17 00:00:00 2001 From: Daen Rebel Date: Fri, 4 Aug 2017 15:14:33 +0200 Subject: [PATCH] Release of version 1.0.92 --- autoload.php | 54 + docs/Api/BlockApi.md | 8 +- docs/Api/BroadcastApi.md | 22 +- docs/Api/CampaignApi.md | 10 +- docs/Api/ContactApi.md | 10 +- docs/Api/ExternalMessageApi.md | 2 +- docs/Api/GenreApi.md | 4 +- docs/Api/ItemApi.md | 18 +- docs/Api/ModelTypeApi.md | 4 +- docs/Api/PresenterApi.md | 10 +- docs/Api/ProgramApi.md | 10 +- docs/Api/StoryApi.md | 10 +- docs/Api/StringApi.md | 2 +- docs/Api/TagApi.md | 10 +- docs/Api/UserApi.md | 8 +- docs/Api/VisualSlideApi.md | 2 +- lib/Api/BlockApi.php | 1008 ++-------- lib/Api/BroadcastApi.php | 2842 ++++++--------------------- lib/Api/CampaignApi.php | 1266 +++--------- lib/Api/ContactApi.php | 1261 +++--------- lib/Api/ExternalMessageApi.php | 297 +-- lib/Api/GenreApi.php | 556 ++---- lib/Api/ItemApi.php | 2359 +++++----------------- lib/Api/ModelTypeApi.php | 576 ++---- lib/Api/PresenterApi.php | 1261 +++--------- lib/Api/ProgramApi.php | 1281 +++--------- lib/Api/StoryApi.php | 1255 +++--------- lib/Api/StringApi.php | 298 +-- lib/Api/TagApi.php | 1266 +++--------- lib/Api/UserApi.php | 998 ++-------- lib/Api/VisualSlideApi.php | 280 +-- lib/ApiClient.php | 371 ++++ lib/ApiException.php | 12 +- lib/Configuration.php | 356 +++- lib/HeaderSelector.php | 110 -- lib/ObjectSerializer.php | 33 +- test/Api/BlockApiTest.php | 1 + test/Api/BroadcastApiTest.php | 1 + test/Api/CampaignApiTest.php | 1 + test/Api/ContactApiTest.php | 1 + test/Api/ExternalMessageApiTest.php | 1 + test/Api/GenreApiTest.php | 1 + test/Api/ItemApiTest.php | 1 + test/Api/ModelTypeApiTest.php | 1 + test/Api/PresenterApiTest.php | 1 + test/Api/ProgramApiTest.php | 1 + test/Api/StoryApiTest.php | 1 + test/Api/StringApiTest.php | 1 + test/Api/TagApiTest.php | 1 + test/Api/UserApiTest.php | 1 + test/Api/VisualSlideApiTest.php | 1 + 51 files changed, 4471 insertions(+), 13414 deletions(-) create mode 100644 autoload.php create mode 100644 lib/ApiClient.php delete mode 100644 lib/HeaderSelector.php diff --git a/autoload.php b/autoload.php new file mode 100644 index 0000000..b10ef87 --- /dev/null +++ b/autoload.php @@ -0,0 +1,54 @@ +setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\BlockApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\BlockApi(); $id = 789; // int | ID of Block **(Required)** $_external_station_id = 789; // int | Query on a different (content providing) station *(Optional)* @@ -79,7 +79,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\BlockApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\BlockApi(); try { $result = $api_instance->getCurrentBlock(); @@ -125,7 +125,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\BlockApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\BlockApi(); try { $result = $api_instance->getNextBlock(); @@ -171,7 +171,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\BlockApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\BlockApi(); $page = 1; // int | Current page *(Optional)* $start_min = new \DateTime("2013-10-20T19:20:30+01:00"); // \DateTime | Minimum start date *(Optional)* $start_max = new \DateTime("2013-10-20T19:20:30+01:00"); // \DateTime | Maximum start date *(Optional)* diff --git a/docs/Api/BroadcastApi.md b/docs/Api/BroadcastApi.md index e0d9b48..44ac071 100644 --- a/docs/Api/BroadcastApi.md +++ b/docs/Api/BroadcastApi.md @@ -34,7 +34,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\BroadcastApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\BroadcastApi(); $data = new \RadioManager\Model\BroadcastDataInput(); // \RadioManager\Model\BroadcastDataInput | Data **(Required)** try { @@ -84,7 +84,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\BroadcastApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\BroadcastApi(); $id = 789; // int | ID of Broadcast **(Required)** try { @@ -134,7 +134,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\BroadcastApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\BroadcastApi(); $id = 789; // int | ID of Broadcast **(Required)** $_external_station_id = 789; // int | Query on a different (content providing) station *(Optional)* @@ -186,7 +186,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\BroadcastApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\BroadcastApi(); try { $result = $api_instance->getCurrentBroadcast(); @@ -232,7 +232,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\BroadcastApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\BroadcastApi(); $date = new \DateTime("2013-10-20T19:20:30+01:00"); // \DateTime | Date *(Optional)* try { @@ -282,7 +282,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\BroadcastApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\BroadcastApi(); $date = new \DateTime("2013-10-20T19:20:30+01:00"); // \DateTime | Date *(Optional)* try { @@ -332,7 +332,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\BroadcastApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\BroadcastApi(); try { $result = $api_instance->getNextBroadcast(); @@ -378,7 +378,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\BroadcastApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\BroadcastApi(); $date = "date_example"; // string | Date *(Optional)* try { @@ -428,7 +428,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\BroadcastApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\BroadcastApi(); $page = 1; // int | Current page *(Optional)* $start_min = new \DateTime("2013-10-20T19:20:30+01:00"); // \DateTime | Minimum start date *(Optional)* $start_max = new \DateTime("2013-10-20T19:20:30+01:00"); // \DateTime | Maximum start date *(Optional)* @@ -498,7 +498,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\BroadcastApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\BroadcastApi(); $id = 789; // int | ID of Broadcast **(Required)** $program_id = 789; // int | Search on Program ID *(Optional)* `(Relation)` $presenter_id = 789; // int | Search on Presenter ID *(Optional)* `(Relation)` @@ -554,7 +554,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\BroadcastApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\BroadcastApi(); $id = 789; // int | ID of Broadcast **(Required)** $data = new \RadioManager\Model\BroadcastDataInput(); // \RadioManager\Model\BroadcastDataInput | Data *(Optional)* diff --git a/docs/Api/CampaignApi.md b/docs/Api/CampaignApi.md index fc31ad0..c1778b9 100644 --- a/docs/Api/CampaignApi.md +++ b/docs/Api/CampaignApi.md @@ -28,7 +28,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\CampaignApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\CampaignApi(); $data = new \RadioManager\Model\CampaignDataInput(); // \RadioManager\Model\CampaignDataInput | Data **(Required)** try { @@ -78,7 +78,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\CampaignApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\CampaignApi(); $id = 789; // int | ID of Campaign **(Required)** try { @@ -128,7 +128,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\CampaignApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\CampaignApi(); $id = 789; // int | ID of Campaign **(Required)** $_external_station_id = 789; // int | Query on a different (content providing) station *(Optional)* @@ -180,7 +180,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\CampaignApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\CampaignApi(); $page = 789; // int | Current page *(Optional)* $model_type_id = 789; // int | Search on ModelType ID *(Optional)* $item_id = 789; // int | Search on Item ID *(Optional)* `(Relation)` @@ -240,7 +240,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\CampaignApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\CampaignApi(); $id = 789; // int | ID of Campaign **(Required)** $data = new \RadioManager\Model\CampaignDataInput(); // \RadioManager\Model\CampaignDataInput | Data *(Optional)* diff --git a/docs/Api/ContactApi.md b/docs/Api/ContactApi.md index 6162e5d..6608599 100644 --- a/docs/Api/ContactApi.md +++ b/docs/Api/ContactApi.md @@ -28,7 +28,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\ContactApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\ContactApi(); $data = new \RadioManager\Model\ContactDataInput(); // \RadioManager\Model\ContactDataInput | Data **(Required)** try { @@ -78,7 +78,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\ContactApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\ContactApi(); $id = 789; // int | ID of Contact **(Required)** try { @@ -128,7 +128,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\ContactApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\ContactApi(); $id = 789; // int | ID of Contact **(Required)** $_external_station_id = 789; // int | Query on a different (content providing) station *(Optional)* @@ -180,7 +180,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\ContactApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\ContactApi(); $page = 1; // int | Current page *(Optional)* $model_type_id = 789; // int | Search on ModelType ID *(Optional)* $tag_id = 789; // int | Search on Tag ID *(Optional)* `(Relation)` @@ -238,7 +238,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\ContactApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\ContactApi(); $id = 789; // int | ID of Contact **(Required)** $data = new \RadioManager\Model\ContactDataInput(); // \RadioManager\Model\ContactDataInput | Data *(Optional)* diff --git a/docs/Api/ExternalMessageApi.md b/docs/Api/ExternalMessageApi.md index 0e87c77..6d731f1 100644 --- a/docs/Api/ExternalMessageApi.md +++ b/docs/Api/ExternalMessageApi.md @@ -24,7 +24,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\ExternalMessageApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\ExternalMessageApi(); $message = new \RadioManager\Model\ExternalMessageQueueData(); // \RadioManager\Model\ExternalMessageQueueData | Data **(Required)** try { diff --git a/docs/Api/GenreApi.md b/docs/Api/GenreApi.md index a19c9be..468b4d7 100644 --- a/docs/Api/GenreApi.md +++ b/docs/Api/GenreApi.md @@ -25,7 +25,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\GenreApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\GenreApi(); $id = 789; // int | ID of Genre **(Required)** $_external_station_id = 789; // int | Query on a different (content providing) station *(Optional)* @@ -77,7 +77,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\GenreApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\GenreApi(); $page = 789; // int | Current page *(Optional)* $parent_id = 789; // int | Search on Parent ID of Genre *(Optional)* $program_id = 789; // int | Search on Program ID *(Optional)* `(Relation)` diff --git a/docs/Api/ItemApi.md b/docs/Api/ItemApi.md index 377b95a..a71c728 100644 --- a/docs/Api/ItemApi.md +++ b/docs/Api/ItemApi.md @@ -32,7 +32,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\ItemApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\ItemApi(); $data = new \RadioManager\Model\ItemDataInput(); // \RadioManager\Model\ItemDataInput | Data *(Optional)* try { @@ -82,7 +82,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\ItemApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\ItemApi(); $data = new \RadioManager\Model\ImportItem(); // \RadioManager\Model\ImportItem | Data *(Optional)* try { @@ -132,7 +132,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\ItemApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\ItemApi(); $data = new \RadioManager\Model\ImportItem(); // \RadioManager\Model\ImportItem | Data *(Optional)* try { @@ -182,7 +182,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\ItemApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\ItemApi(); $id = 789; // int | ID of Item **(Required)** try { @@ -232,7 +232,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\ItemApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\ItemApi(); $id = 789; // int | ID of Item **(Required)** $_external_station_id = 789; // int | Query on a different (content providing) station *(Optional)* @@ -284,7 +284,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\ItemApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\ItemApi(); $page = 789; // int | Current page *(Optional)* $order_by = "order_by_example"; // string | Field to order the results *(Optional)* $order_direction = "order_direction_example"; // string | Direction of ordering *(Optional)* @@ -370,7 +370,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\ItemApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\ItemApi(); $data = new \RadioManager\Model\Data1(); // \RadioManager\Model\Data1 | Data *(Optional)* try { @@ -420,7 +420,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\ItemApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\ItemApi(); $data = new \RadioManager\Model\Data(); // \RadioManager\Model\Data | Data *(Optional)* try { @@ -470,7 +470,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\ItemApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\ItemApi(); $id = 789; // int | ID of Item **(Required)** $data = new \RadioManager\Model\Item(); // \RadioManager\Model\Item | Data *(Optional)* diff --git a/docs/Api/ModelTypeApi.md b/docs/Api/ModelTypeApi.md index 0d73c5a..e406770 100644 --- a/docs/Api/ModelTypeApi.md +++ b/docs/Api/ModelTypeApi.md @@ -25,7 +25,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\ModelTypeApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\ModelTypeApi(); $id = 789; // int | ID of ModelType **(Required)** $_external_station_id = 789; // int | Query on a different (content providing) station *(Optional)* @@ -77,7 +77,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\ModelTypeApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\ModelTypeApi(); $page = 789; // int | Current page *(Optional)* $model = "model_example"; // string | $program_id = 789; // int | Search on Program ID *(Optional)* diff --git a/docs/Api/PresenterApi.md b/docs/Api/PresenterApi.md index 3d10412..8542c65 100644 --- a/docs/Api/PresenterApi.md +++ b/docs/Api/PresenterApi.md @@ -28,7 +28,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\PresenterApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\PresenterApi(); $data = new \RadioManager\Model\PresenterDataInput(); // \RadioManager\Model\PresenterDataInput | Data **(Required)** try { @@ -78,7 +78,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\PresenterApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\PresenterApi(); $id = 789; // int | id of presenter try { @@ -128,7 +128,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\PresenterApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\PresenterApi(); $id = 789; // int | id of Presenter $_external_station_id = 789; // int | Query on a different (content providing) station *(Optional)* @@ -180,7 +180,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\PresenterApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\PresenterApi(); $page = 789; // int | Current page *(Optional)* $model_type_id = 789; // int | Search on ModelType ID (Optional) $program_id = 789; // int | Search on Program ID *(Optional)* `(Relation)` @@ -238,7 +238,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\PresenterApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\PresenterApi(); $id = 789; // int | id of Presenter $data = new \RadioManager\Model\PresenterDataInput(); // \RadioManager\Model\PresenterDataInput | Data *(Optional)* diff --git a/docs/Api/ProgramApi.md b/docs/Api/ProgramApi.md index 23e73a9..4479169 100644 --- a/docs/Api/ProgramApi.md +++ b/docs/Api/ProgramApi.md @@ -28,7 +28,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\ProgramApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\ProgramApi(); $data = new \RadioManager\Model\ProgramDataInput(); // \RadioManager\Model\ProgramDataInput | Data **(Required)** try { @@ -78,7 +78,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\ProgramApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\ProgramApi(); $id = 789; // int | ID of program **(Required)** try { @@ -128,7 +128,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\ProgramApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\ProgramApi(); $id = 789; // int | ID of Program **(Required)** $_external_station_id = 789; // int | Query on a different (content providing) station *(Optional)* @@ -180,7 +180,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\ProgramApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\ProgramApi(); $page = 789; // int | Current page *(Optional)* $genre_id = 789; // int | Search on Genre ID *(Optional)* $model_type_id = 789; // int | Search on ModelType ID *(Optional)* @@ -246,7 +246,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\ProgramApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\ProgramApi(); $id = 789; // int | ID of Program **(Required)** $data = new \RadioManager\Model\ProgramDataInput(); // \RadioManager\Model\ProgramDataInput | Data *(Optional)* diff --git a/docs/Api/StoryApi.md b/docs/Api/StoryApi.md index 2d2d0e4..bd85876 100644 --- a/docs/Api/StoryApi.md +++ b/docs/Api/StoryApi.md @@ -28,7 +28,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\StoryApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\StoryApi(); $data = new \RadioManager\Model\StoryDataInput(); // \RadioManager\Model\StoryDataInput | Data **(Required)** try { @@ -78,7 +78,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\StoryApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\StoryApi(); $id = 789; // int | ID of Story **(Required)** try { @@ -128,7 +128,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\StoryApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\StoryApi(); $id = 789; // int | ID of Story **(Required)** $_external_station_id = 789; // int | Query on a different (content providing) station *(Optional)* @@ -180,7 +180,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\StoryApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\StoryApi(); $page = 1; // int | Current page *(Optional)* $model_type_id = 789; // int | Search on ModelType ID *(Optional)* $tag_id = 789; // int | Search on Tag ID *(Optional)* `(Relation)` @@ -238,7 +238,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\StoryApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\StoryApi(); $id = 789; // int | ID of Story **(Required)** $data = new \RadioManager\Model\StoryDataInput(); // \RadioManager\Model\StoryDataInput | Data *(Optional)* diff --git a/docs/Api/StringApi.md b/docs/Api/StringApi.md index 6bbb28c..c3c1465 100644 --- a/docs/Api/StringApi.md +++ b/docs/Api/StringApi.md @@ -24,7 +24,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\StringApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\StringApi(); $name = "name_example"; // string | Name of Strings **(Required)** $full_model = true; // bool | Full model or content only **(Required)** diff --git a/docs/Api/TagApi.md b/docs/Api/TagApi.md index ef7f1be..dc752e1 100644 --- a/docs/Api/TagApi.md +++ b/docs/Api/TagApi.md @@ -28,7 +28,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\TagApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\TagApi(); $data = new \RadioManager\Model\TagDataInput(); // \RadioManager\Model\TagDataInput | Data **(Required)** try { @@ -78,7 +78,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\TagApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\TagApi(); $id = 789; // int | ID of Tag **(Required)** try { @@ -128,7 +128,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\TagApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\TagApi(); $id = 789; // int | ID of Tag **(Required)** $_external_station_id = 789; // int | Query on a different (content providing) station *(Optional)* @@ -180,7 +180,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\TagApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\TagApi(); $page = 789; // int | Current page *(Optional)* $program_id = 789; // int | Search on Program ID *(Optional)* `(Relation)` $item_id = 789; // int | Search on Item ID *(Optional)* `(Relation)` @@ -240,7 +240,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\TagApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\TagApi(); $id = 789; // int | ID of Tag **(Required)** $data = new \RadioManager\Model\TagDataInput(); // \RadioManager\Model\TagDataInput | Data *(Optional)* diff --git a/docs/Api/UserApi.md b/docs/Api/UserApi.md index 14cab5d..5f58824 100644 --- a/docs/Api/UserApi.md +++ b/docs/Api/UserApi.md @@ -27,7 +27,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\UserApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\UserApi(); $id = 789; // int | id of User try { @@ -77,7 +77,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\UserApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\UserApi(); $id = 789; // int | id of User try { @@ -127,7 +127,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\UserApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\UserApi(); $data = new \RadioManager\Model\InviteUserData(); // \RadioManager\Model\InviteUserData | Data **(Required)** try { @@ -177,7 +177,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\UserApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\UserApi(); $page = 1; // int | Current page *(Optional)* $role_id = 789; // int | Search on Role ID *(Optional)* diff --git a/docs/Api/VisualSlideApi.md b/docs/Api/VisualSlideApi.md index 1df0825..4481e22 100644 --- a/docs/Api/VisualSlideApi.md +++ b/docs/Api/VisualSlideApi.md @@ -24,7 +24,7 @@ RadioManager\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOU // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // RadioManager\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); -$api_instance = new RadioManager\Api\VisualSlideApi(new \Http\Adapter\Guzzle6\Client()); +$api_instance = new RadioManager\Api\VisualSlideApi(); try { $result = $api_instance->getVisualSlide(); diff --git a/lib/Api/BlockApi.php b/lib/Api/BlockApi.php index 3c570a7..178c76c 100644 --- a/lib/Api/BlockApi.php +++ b/lib/Api/BlockApi.php @@ -28,15 +28,10 @@ namespace RadioManager\Api; -use GuzzleHttp\Client; -use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\Psr7\MultipartStream; -use GuzzleHttp\Psr7\Request; -use RadioManager\ApiException; -use RadioManager\Configuration; -use RadioManager\HeaderSelector; -use RadioManager\ObjectSerializer; +use \RadioManager\ApiClient; +use \RadioManager\ApiException; +use \RadioManager\Configuration; +use \RadioManager\ObjectSerializer; /** * BlockApi Class Doc Comment @@ -49,36 +44,47 @@ class BlockApi { /** - * @var ClientInterface + * API Client + * + * @var \RadioManager\ApiClient instance of the ApiClient */ - protected $client; + protected $apiClient; /** - * @var Configuration + * Constructor + * + * @param \RadioManager\ApiClient|null $apiClient The api client to use */ - protected $config; + public function __construct(\RadioManager\ApiClient $apiClient = null) + { + if ($apiClient === null) { + $apiClient = new ApiClient(); + } + + $this->apiClient = $apiClient; + } /** - * @param ClientInterface $client - * @param Configuration $config - * @param HeaderSelector $selector + * Get API client + * + * @return \RadioManager\ApiClient get the API client */ - public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null - ) { - $this->client = $client ?: new Client(); - $this->config = $config ?: new Configuration(); - $this->headerSelector = $selector ?: new HeaderSelector(); + public function getApiClient() + { + return $this->apiClient; } /** - * @return Configuration + * Set the API client + * + * @param \RadioManager\ApiClient $apiClient set the API client + * + * @return BlockApi */ - public function getConfig() + public function setApiClient(\RadioManager\ApiClient $apiClient) { - return $this->config; + $this->apiClient = $apiClient; + return $this; } /** @@ -89,7 +95,6 @@ public function getConfig() * @param int $id ID of Block **(Required)** (required) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return \RadioManager\Model\BlockResult */ public function getBlockById($id, $_external_station_id = null) @@ -106,798 +111,263 @@ public function getBlockById($id, $_external_station_id = null) * @param int $id ID of Block **(Required)** (required) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return array of \RadioManager\Model\BlockResult, HTTP status code, HTTP response headers (array of strings) */ public function getBlockByIdWithHttpInfo($id, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\BlockResult'; - $request = $this->getBlockByIdRequest($id, $_external_station_id); - - try { - - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\BlockResult', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation getBlockByIdAsync - * - * Get block by id - * - * @param int $id ID of Block **(Required)** (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getBlockByIdAsync($id, $_external_station_id = null) - { - return $this->getBlockByIdAsyncWithHttpInfo($id, $_external_station_id)->then(function ($response) { - return $response[0]; - }); - } - - /** - * Operation getBlockByIdAsyncWithHttpInfo - * - * Get block by id - * - * @param int $id ID of Block **(Required)** (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getBlockByIdAsyncWithHttpInfo($id, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\BlockResult'; - $request = $this->getBlockByIdRequest($id, $_external_station_id); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'getBlockById' - * - * @param int $id ID of Block **(Required)** (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - protected function getBlockByIdRequest($id, $_external_station_id = null) { // verify the required parameter 'id' is set if ($id === null) { throw new \InvalidArgumentException('Missing the required parameter $id when calling getBlockById'); } - if ($id < 0) { + if (($id < 0)) { throw new \InvalidArgumentException('invalid value for "$id" when calling BlockApi.getBlockById, must be bigger than or equal to 0.'); } - - $resourcePath = '/blocks/{id}'; - $formParams = []; + // parse inputs + $resourcePath = "/blocks/{id}"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // query params if ($_external_station_id !== null) { - $queryParams['_external_station_id'] = ObjectSerializer::toQueryValue($_external_station_id); + $queryParams['_external_station_id'] = $this->apiClient->getSerializer()->toQueryValue($_external_station_id); } - // path params if ($id !== null) { - $resourcePath = str_replace('{' . 'id' . '}', ObjectSerializer::toPathValue($id), $resourcePath); - } - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] + $resourcePath = str_replace( + "{" . "id" . "}", + $this->apiClient->getSerializer()->toPathValue($id), + $resourcePath ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'GET', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation getCurrentBlock - * - * Get current Block - * - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\BlockResult - */ - public function getCurrentBlock() - { - list($response) = $this->getCurrentBlockWithHttpInfo(); - return $response; - } - - /** - * Operation getCurrentBlockWithHttpInfo - * - * Get current Block - * - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\BlockResult, HTTP status code, HTTP response headers (array of strings) - */ - public function getCurrentBlockWithHttpInfo() - { - $returnType = '\RadioManager\Model\BlockResult'; - $request = $this->getCurrentBlockRequest(); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'GET', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\BlockResult', + '/blocks/{id}' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\BlockResult', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\BlockResult', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\BlockResult', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation getCurrentBlockAsync + * Operation getCurrentBlock * * Get current Block * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\BlockResult */ - public function getCurrentBlockAsync() + public function getCurrentBlock() { - return $this->getCurrentBlockAsyncWithHttpInfo()->then(function ($response) { - return $response[0]; - }); + list($response) = $this->getCurrentBlockWithHttpInfo(); + return $response; } /** - * Operation getCurrentBlockAsyncWithHttpInfo + * Operation getCurrentBlockWithHttpInfo * * Get current Block * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getCurrentBlockAsyncWithHttpInfo() - { - $returnType = '\RadioManager\Model\BlockResult'; - $request = $this->getCurrentBlockRequest(); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'getCurrentBlock' - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\BlockResult, HTTP status code, HTTP response headers (array of strings) */ - protected function getCurrentBlockRequest() + public function getCurrentBlockWithHttpInfo() { - - $resourcePath = '/blocks/current'; - $formParams = []; + // parse inputs + $resourcePath = "/blocks/current"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); + // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'GET', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation getNextBlock - * - * Get next Block - * - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\BlockResult - */ - public function getNextBlock() - { - list($response) = $this->getNextBlockWithHttpInfo(); - return $response; - } - - /** - * Operation getNextBlockWithHttpInfo - * - * Get next Block - * - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\BlockResult, HTTP status code, HTTP response headers (array of strings) - */ - public function getNextBlockWithHttpInfo() - { - $returnType = '\RadioManager\Model\BlockResult'; - $request = $this->getNextBlockRequest(); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'GET', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\BlockResult', + '/blocks/current' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\BlockResult', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\BlockResult', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\BlockResult', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation getNextBlockAsync + * Operation getNextBlock * * Get next Block * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\BlockResult */ - public function getNextBlockAsync() + public function getNextBlock() { - return $this->getNextBlockAsyncWithHttpInfo()->then(function ($response) { - return $response[0]; - }); + list($response) = $this->getNextBlockWithHttpInfo(); + return $response; } /** - * Operation getNextBlockAsyncWithHttpInfo + * Operation getNextBlockWithHttpInfo * * Get next Block * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getNextBlockAsyncWithHttpInfo() - { - $returnType = '\RadioManager\Model\BlockResult'; - $request = $this->getNextBlockRequest(); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'getNextBlock' - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\BlockResult, HTTP status code, HTTP response headers (array of strings) */ - protected function getNextBlockRequest() + public function getNextBlockWithHttpInfo() { - - $resourcePath = '/blocks/next'; - $formParams = []; + // parse inputs + $resourcePath = "/blocks/next"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); + // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; - } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'GET', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation listBlocks - * - * Get a list of all blocks currently in your station. - * - * @param int $page Current page *(Optional)* (optional, default to 1) - * @param \DateTime $start_min Minimum start date *(Optional)* (optional) - * @param \DateTime $start_max Maximum start date *(Optional)* (optional) - * @param int $broadcast_id Search on Broadcast ID *(Optional)* `(Relation)` (optional) - * @param int $program_id Search on Program ID *(Optional)* `(Relation)` (optional) - * @param int $item_id Search on Item ID *(Optional)* `(Relation)` (optional) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\BlockResults - */ - public function listBlocks($page = '1', $start_min = null, $start_max = null, $broadcast_id = null, $program_id = null, $item_id = null, $_external_station_id = null) - { - list($response) = $this->listBlocksWithHttpInfo($page, $start_min, $start_max, $broadcast_id, $program_id, $item_id, $_external_station_id); - return $response; - } - - /** - * Operation listBlocksWithHttpInfo - * - * Get a list of all blocks currently in your station. - * - * @param int $page Current page *(Optional)* (optional, default to 1) - * @param \DateTime $start_min Minimum start date *(Optional)* (optional) - * @param \DateTime $start_max Maximum start date *(Optional)* (optional) - * @param int $broadcast_id Search on Broadcast ID *(Optional)* `(Relation)` (optional) - * @param int $program_id Search on Program ID *(Optional)* `(Relation)` (optional) - * @param int $item_id Search on Item ID *(Optional)* `(Relation)` (optional) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\BlockResults, HTTP status code, HTTP response headers (array of strings) - */ - public function listBlocksWithHttpInfo($page = '1', $start_min = null, $start_max = null, $broadcast_id = null, $program_id = null, $item_id = null, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\BlockResults'; - $request = $this->listBlocksRequest($page, $start_min, $start_max, $broadcast_id, $program_id, $item_id, $_external_station_id); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'GET', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\BlockResult', + '/blocks/next' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\BlockResult', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\BlockResults', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\BlockResult', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation listBlocksAsync + * Operation listBlocks * * Get a list of all blocks currently in your station. * @@ -908,18 +378,17 @@ public function listBlocksWithHttpInfo($page = '1', $start_min = null, $start_ma * @param int $program_id Search on Program ID *(Optional)* `(Relation)` (optional) * @param int $item_id Search on Item ID *(Optional)* `(Relation)` (optional) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\BlockResults */ - public function listBlocksAsync($page = '1', $start_min = null, $start_max = null, $broadcast_id = null, $program_id = null, $item_id = null, $_external_station_id = null) + public function listBlocks($page = '1', $start_min = null, $start_max = null, $broadcast_id = null, $program_id = null, $item_id = null, $_external_station_id = null) { - return $this->listBlocksAsyncWithHttpInfo($page, $start_min, $start_max, $broadcast_id, $program_id, $item_id, $_external_station_id)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->listBlocksWithHttpInfo($page, $start_min, $start_max, $broadcast_id, $program_id, $item_id, $_external_station_id); + return $response; } /** - * Operation listBlocksAsyncWithHttpInfo + * Operation listBlocksWithHttpInfo * * Get a list of all blocks currently in your station. * @@ -930,160 +399,101 @@ public function listBlocksAsync($page = '1', $start_min = null, $start_max = nul * @param int $program_id Search on Program ID *(Optional)* `(Relation)` (optional) * @param int $item_id Search on Item ID *(Optional)* `(Relation)` (optional) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function listBlocksAsyncWithHttpInfo($page = '1', $start_min = null, $start_max = null, $broadcast_id = null, $program_id = null, $item_id = null, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\BlockResults'; - $request = $this->listBlocksRequest($page, $start_min, $start_max, $broadcast_id, $program_id, $item_id, $_external_station_id); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'listBlocks' - * - * @param int $page Current page *(Optional)* (optional, default to 1) - * @param \DateTime $start_min Minimum start date *(Optional)* (optional) - * @param \DateTime $start_max Maximum start date *(Optional)* (optional) - * @param int $broadcast_id Search on Broadcast ID *(Optional)* `(Relation)` (optional) - * @param int $program_id Search on Program ID *(Optional)* `(Relation)` (optional) - * @param int $item_id Search on Item ID *(Optional)* `(Relation)` (optional) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\BlockResults, HTTP status code, HTTP response headers (array of strings) */ - protected function listBlocksRequest($page = '1', $start_min = null, $start_max = null, $broadcast_id = null, $program_id = null, $item_id = null, $_external_station_id = null) + public function listBlocksWithHttpInfo($page = '1', $start_min = null, $start_max = null, $broadcast_id = null, $program_id = null, $item_id = null, $_external_station_id = null) { - if ($page !== null && $page < 0) { + if (!is_null($page) && ($page < 0)) { throw new \InvalidArgumentException('invalid value for "$page" when calling BlockApi.listBlocks, must be bigger than or equal to 0.'); } - - $resourcePath = '/blocks'; - $formParams = []; + // parse inputs + $resourcePath = "/blocks"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // query params if ($page !== null) { - $queryParams['page'] = ObjectSerializer::toQueryValue($page); + $queryParams['page'] = $this->apiClient->getSerializer()->toQueryValue($page); } // query params if ($start_min !== null) { - $queryParams['start-min'] = ObjectSerializer::toQueryValue($start_min); + $queryParams['start-min'] = $this->apiClient->getSerializer()->toQueryValue($start_min); } // query params if ($start_max !== null) { - $queryParams['start-max'] = ObjectSerializer::toQueryValue($start_max); + $queryParams['start-max'] = $this->apiClient->getSerializer()->toQueryValue($start_max); } // query params if ($broadcast_id !== null) { - $queryParams['broadcast_id'] = ObjectSerializer::toQueryValue($broadcast_id); + $queryParams['broadcast_id'] = $this->apiClient->getSerializer()->toQueryValue($broadcast_id); } // query params if ($program_id !== null) { - $queryParams['program_id'] = ObjectSerializer::toQueryValue($program_id); + $queryParams['program_id'] = $this->apiClient->getSerializer()->toQueryValue($program_id); } // query params if ($item_id !== null) { - $queryParams['item_id'] = ObjectSerializer::toQueryValue($item_id); + $queryParams['item_id'] = $this->apiClient->getSerializer()->toQueryValue($item_id); } // query params if ($_external_station_id !== null) { - $queryParams['_external_station_id'] = ObjectSerializer::toQueryValue($_external_station_id); - } - - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); + $queryParams['_external_station_id'] = $this->apiClient->getSerializer()->toQueryValue($_external_station_id); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'GET', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\BlockResults', + '/blocks' + ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\BlockResults', $httpHeader), $statusCode, $httpHeader]; + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\BlockResults', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 403: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 404: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 429: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + } - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + throw $e; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'GET', - $url, - $headers, - $httpBody - ); } - } diff --git a/lib/Api/BroadcastApi.php b/lib/Api/BroadcastApi.php index 971863a..9a9ca25 100644 --- a/lib/Api/BroadcastApi.php +++ b/lib/Api/BroadcastApi.php @@ -28,15 +28,10 @@ namespace RadioManager\Api; -use GuzzleHttp\Client; -use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\Psr7\MultipartStream; -use GuzzleHttp\Psr7\Request; -use RadioManager\ApiException; -use RadioManager\Configuration; -use RadioManager\HeaderSelector; -use RadioManager\ObjectSerializer; +use \RadioManager\ApiClient; +use \RadioManager\ApiException; +use \RadioManager\Configuration; +use \RadioManager\ObjectSerializer; /** * BroadcastApi Class Doc Comment @@ -49,36 +44,47 @@ class BroadcastApi { /** - * @var ClientInterface + * API Client + * + * @var \RadioManager\ApiClient instance of the ApiClient */ - protected $client; + protected $apiClient; /** - * @var Configuration + * Constructor + * + * @param \RadioManager\ApiClient|null $apiClient The api client to use */ - protected $config; + public function __construct(\RadioManager\ApiClient $apiClient = null) + { + if ($apiClient === null) { + $apiClient = new ApiClient(); + } + + $this->apiClient = $apiClient; + } /** - * @param ClientInterface $client - * @param Configuration $config - * @param HeaderSelector $selector + * Get API client + * + * @return \RadioManager\ApiClient get the API client */ - public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null - ) { - $this->client = $client ?: new Client(); - $this->config = $config ?: new Configuration(); - $this->headerSelector = $selector ?: new HeaderSelector(); + public function getApiClient() + { + return $this->apiClient; } /** - * @return Configuration + * Set the API client + * + * @param \RadioManager\ApiClient $apiClient set the API client + * + * @return BroadcastApi */ - public function getConfig() + public function setApiClient(\RadioManager\ApiClient $apiClient) { - return $this->config; + $this->apiClient = $apiClient; + return $this; } /** @@ -88,7 +94,6 @@ public function getConfig() * * @param \RadioManager\Model\BroadcastDataInput $data Data **(Required)** (required) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return \RadioManager\Model\PostSuccess */ public function createBroadcast($data) @@ -104,160 +109,25 @@ public function createBroadcast($data) * * @param \RadioManager\Model\BroadcastDataInput $data Data **(Required)** (required) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return array of \RadioManager\Model\PostSuccess, HTTP status code, HTTP response headers (array of strings) */ public function createBroadcastWithHttpInfo($data) - { - $returnType = '\RadioManager\Model\PostSuccess'; - $request = $this->createBroadcastRequest($data); - - try { - - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\PostSuccess', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 422: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation createBroadcastAsync - * - * Create broadcast. - * - * @param \RadioManager\Model\BroadcastDataInput $data Data **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function createBroadcastAsync($data) - { - return $this->createBroadcastAsyncWithHttpInfo($data)->then(function ($response) { - return $response[0]; - }); - } - - /** - * Operation createBroadcastAsyncWithHttpInfo - * - * Create broadcast. - * - * @param \RadioManager\Model\BroadcastDataInput $data Data **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function createBroadcastAsyncWithHttpInfo($data) - { - $returnType = '\RadioManager\Model\PostSuccess'; - $request = $this->createBroadcastRequest($data); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'createBroadcast' - * - * @param \RadioManager\Model\BroadcastDataInput $data Data **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - protected function createBroadcastRequest($data) { // verify the required parameter 'data' is set if ($data === null) { throw new \InvalidArgumentException('Missing the required parameter $data when calling createBroadcast'); } - - $resourcePath = '/broadcasts'; - $formParams = []; + // parse inputs + $resourcePath = "/broadcasts"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - - + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // body params $_tempBody = null; @@ -265,66 +135,56 @@ protected function createBroadcastRequest($data) $_tempBody = $data; } - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } - // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'POST', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\PostSuccess', + '/broadcasts' + ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\PostSuccess', $httpHeader), $statusCode, $httpHeader]; + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\PostSuccess', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 403: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 404: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 422: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 429: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + } - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + throw $e; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'POST', - $url, - $headers, - $httpBody - ); } /** @@ -334,7 +194,6 @@ protected function createBroadcastRequest($data) * * @param int $id ID of Broadcast **(Required)** (required) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return \RadioManager\Model\Success */ public function deleteBroadcastById($id) @@ -350,1760 +209,637 @@ public function deleteBroadcastById($id) * * @param int $id ID of Broadcast **(Required)** (required) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return array of \RadioManager\Model\Success, HTTP status code, HTTP response headers (array of strings) */ public function deleteBroadcastByIdWithHttpInfo($id) { - $returnType = '\RadioManager\Model\Success'; - $request = $this->deleteBroadcastByIdRequest($id); - - try { - - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); + // verify the required parameter 'id' is set + if ($id === null) { + throw new \InvalidArgumentException('Missing the required parameter $id when calling deleteBroadcastById'); + } + if (($id < 0)) { + throw new \InvalidArgumentException('invalid value for "$id" when calling BroadcastApi.deleteBroadcastById, must be bigger than or equal to 0.'); + } - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } + // parse inputs + $resourcePath = "/broadcasts/{id}"; + $httpBody = ''; + $queryParams = []; + $headerParams = []; + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); - $responseBody = $response->getBody(); - if ($returnType === '\SplFileObject') { - $content = $responseBody; //stream goes to serializer - } else { - $content = $responseBody->getContents(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } + // path params + if ($id !== null) { + $resourcePath = str_replace( + "{" . "id" . "}", + $this->apiClient->getSerializer()->toPathValue($id), + $resourcePath + ); + } - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } elseif (count($formParams) > 0) { + $httpBody = $formParams; // for HTTP post (form) + } + // this endpoint requires API key authentication + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; + } + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'DELETE', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\Success', + '/broadcasts/{id}' + ); + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\Success', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation deleteBroadcastByIdAsync + * Operation getBroadcastById * - * Delete broadcast by id + * Get broadcast by id * * @param int $id ID of Broadcast **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\BroadcastResult */ - public function deleteBroadcastByIdAsync($id) + public function getBroadcastById($id, $_external_station_id = null) { - return $this->deleteBroadcastByIdAsyncWithHttpInfo($id)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->getBroadcastByIdWithHttpInfo($id, $_external_station_id); + return $response; } /** - * Operation deleteBroadcastByIdAsyncWithHttpInfo - * - * Delete broadcast by id + * Operation getBroadcastByIdWithHttpInfo * - * @param int $id ID of Broadcast **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function deleteBroadcastByIdAsyncWithHttpInfo($id) - { - $returnType = '\RadioManager\Model\Success'; - $request = $this->deleteBroadcastByIdRequest($id); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'deleteBroadcastById' + * Get broadcast by id * * @param int $id ID of Broadcast **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\BroadcastResult, HTTP status code, HTTP response headers (array of strings) */ - protected function deleteBroadcastByIdRequest($id) + public function getBroadcastByIdWithHttpInfo($id, $_external_station_id = null) { // verify the required parameter 'id' is set if ($id === null) { - throw new \InvalidArgumentException('Missing the required parameter $id when calling deleteBroadcastById'); + throw new \InvalidArgumentException('Missing the required parameter $id when calling getBroadcastById'); } - if ($id < 0) { - throw new \InvalidArgumentException('invalid value for "$id" when calling BroadcastApi.deleteBroadcastById, must be bigger than or equal to 0.'); + if (($id < 0)) { + throw new \InvalidArgumentException('invalid value for "$id" when calling BroadcastApi.getBroadcastById, must be bigger than or equal to 0.'); } - - $resourcePath = '/broadcasts/{id}'; - $formParams = []; + // parse inputs + $resourcePath = "/broadcasts/{id}"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); + // query params + if ($_external_station_id !== null) { + $queryParams['_external_station_id'] = $this->apiClient->getSerializer()->toQueryValue($_external_station_id); + } // path params if ($id !== null) { - $resourcePath = str_replace('{' . 'id' . '}', ObjectSerializer::toPathValue($id), $resourcePath); - } - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] + $resourcePath = str_replace( + "{" . "id" . "}", + $this->apiClient->getSerializer()->toPathValue($id), + $resourcePath ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'GET', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\BroadcastResult', + '/broadcasts/{id}' + ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\BroadcastResult', $httpHeader), $statusCode, $httpHeader]; + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\BroadcastResult', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 403: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 404: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 429: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + } - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + throw $e; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'DELETE', - $url, - $headers, - $httpBody - ); } /** - * Operation getBroadcastById + * Operation getCurrentBroadcast * - * Get broadcast by id + * Get current Broadcast * - * @param int $id ID of Broadcast **(Required)** (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\BroadcastResult + * @return \RadioManager\Model\Broadcast */ - public function getBroadcastById($id, $_external_station_id = null) + public function getCurrentBroadcast() { - list($response) = $this->getBroadcastByIdWithHttpInfo($id, $_external_station_id); + list($response) = $this->getCurrentBroadcastWithHttpInfo(); return $response; } /** - * Operation getBroadcastByIdWithHttpInfo + * Operation getCurrentBroadcastWithHttpInfo * - * Get broadcast by id + * Get current Broadcast * - * @param int $id ID of Broadcast **(Required)** (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\BroadcastResult, HTTP status code, HTTP response headers (array of strings) + * @return array of \RadioManager\Model\Broadcast, HTTP status code, HTTP response headers (array of strings) */ - public function getBroadcastByIdWithHttpInfo($id, $_external_station_id = null) + public function getCurrentBroadcastWithHttpInfo() { - $returnType = '\RadioManager\Model\BroadcastResult'; - $request = $this->getBroadcastByIdRequest($id, $_external_station_id); - - try { - - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } + // parse inputs + $resourcePath = "/broadcasts/current"; + $httpBody = ''; + $queryParams = []; + $headerParams = []; + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); - $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() - ]; + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } elseif (count($formParams) > 0) { + $httpBody = $formParams; // for HTTP post (form) + } + // this endpoint requires API key authentication + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; + } + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'GET', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\Broadcast', + '/broadcasts/current' + ); + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\Broadcast', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\BroadcastResult', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Broadcast', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation getBroadcastByIdAsync + * Operation getDailyEPG * - * Get broadcast by id + * Get daily EPG * - * @param int $id ID of Broadcast **(Required)** (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @param \DateTime $date Date *(Optional)* (optional) + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\EPGBroadcast */ - public function getBroadcastByIdAsync($id, $_external_station_id = null) + public function getDailyEPG($date = null) { - return $this->getBroadcastByIdAsyncWithHttpInfo($id, $_external_station_id)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->getDailyEPGWithHttpInfo($date); + return $response; } /** - * Operation getBroadcastByIdAsyncWithHttpInfo - * - * Get broadcast by id + * Operation getDailyEPGWithHttpInfo * - * @param int $id ID of Broadcast **(Required)** (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getBroadcastByIdAsyncWithHttpInfo($id, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\BroadcastResult'; - $request = $this->getBroadcastByIdRequest($id, $_external_station_id); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'getBroadcastById' + * Get daily EPG * - * @param int $id ID of Broadcast **(Required)** (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @param \DateTime $date Date *(Optional)* (optional) + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\EPGBroadcast, HTTP status code, HTTP response headers (array of strings) */ - protected function getBroadcastByIdRequest($id, $_external_station_id = null) + public function getDailyEPGWithHttpInfo($date = null) { - // verify the required parameter 'id' is set - if ($id === null) { - throw new \InvalidArgumentException('Missing the required parameter $id when calling getBroadcastById'); - } - if ($id < 0) { - throw new \InvalidArgumentException('invalid value for "$id" when calling BroadcastApi.getBroadcastById, must be bigger than or equal to 0.'); - } - - - $resourcePath = '/broadcasts/{id}'; - $formParams = []; + // parse inputs + $resourcePath = "/broadcasts/epg/daily"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - - // query params - if ($_external_station_id !== null) { - $queryParams['_external_station_id'] = ObjectSerializer::toQueryValue($_external_station_id); - } - - // path params - if ($id !== null) { - $resourcePath = str_replace('{' . 'id' . '}', ObjectSerializer::toPathValue($id), $resourcePath); + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); + // query params + if ($date !== null) { + $queryParams['date'] = $this->apiClient->getSerializer()->toQueryValue($date); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; - } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'GET', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation getCurrentBroadcast - * - * Get current Broadcast - * - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\Broadcast - */ - public function getCurrentBroadcast() - { - list($response) = $this->getCurrentBroadcastWithHttpInfo(); - return $response; - } - - /** - * Operation getCurrentBroadcastWithHttpInfo - * - * Get current Broadcast - * - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\Broadcast, HTTP status code, HTTP response headers (array of strings) - */ - public function getCurrentBroadcastWithHttpInfo() - { - $returnType = '\RadioManager\Model\Broadcast'; - $request = $this->getCurrentBroadcastRequest(); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'GET', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\EPGBroadcast', + '/broadcasts/epg/daily' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\EPGBroadcast', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Broadcast', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\EPGBroadcast', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation getCurrentBroadcastAsync + * Operation getEPGByDate * - * Get current Broadcast + * Get EPG by date * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @param \DateTime $date Date *(Optional)* (optional) + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\EPGBroadcast */ - public function getCurrentBroadcastAsync() + public function getEPGByDate($date = null) { - return $this->getCurrentBroadcastAsyncWithHttpInfo()->then(function ($response) { - return $response[0]; - }); + list($response) = $this->getEPGByDateWithHttpInfo($date); + return $response; } /** - * Operation getCurrentBroadcastAsyncWithHttpInfo - * - * Get current Broadcast + * Operation getEPGByDateWithHttpInfo * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getCurrentBroadcastAsyncWithHttpInfo() - { - $returnType = '\RadioManager\Model\Broadcast'; - $request = $this->getCurrentBroadcastRequest(); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'getCurrentBroadcast' + * Get EPG by date * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @param \DateTime $date Date *(Optional)* (optional) + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\EPGBroadcast, HTTP status code, HTTP response headers (array of strings) */ - protected function getCurrentBroadcastRequest() + public function getEPGByDateWithHttpInfo($date = null) { - - $resourcePath = '/broadcasts/current'; - $formParams = []; + // parse inputs + $resourcePath = "/broadcasts/epg"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - - - + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); + // query params + if ($date !== null) { + $queryParams['date'] = $this->apiClient->getSerializer()->toQueryValue($date); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'GET', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation getDailyEPG - * - * Get daily EPG - * - * @param \DateTime $date Date *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\EPGBroadcast - */ - public function getDailyEPG($date = null) - { - list($response) = $this->getDailyEPGWithHttpInfo($date); - return $response; - } - - /** - * Operation getDailyEPGWithHttpInfo - * - * Get daily EPG - * - * @param \DateTime $date Date *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\EPGBroadcast, HTTP status code, HTTP response headers (array of strings) - */ - public function getDailyEPGWithHttpInfo($date = null) - { - $returnType = '\RadioManager\Model\EPGBroadcast'; - $request = $this->getDailyEPGRequest($date); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'GET', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\EPGBroadcast', + '/broadcasts/epg' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\EPGBroadcast', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\EPGBroadcast', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\EPGBroadcast', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation getDailyEPGAsync + * Operation getNextBroadcast * - * Get daily EPG + * Get next Broadcast * - * @param \DateTime $date Date *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\Broadcast */ - public function getDailyEPGAsync($date = null) + public function getNextBroadcast() { - return $this->getDailyEPGAsyncWithHttpInfo($date)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->getNextBroadcastWithHttpInfo(); + return $response; } /** - * Operation getDailyEPGAsyncWithHttpInfo - * - * Get daily EPG + * Operation getNextBroadcastWithHttpInfo * - * @param \DateTime $date Date *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getDailyEPGAsyncWithHttpInfo($date = null) - { - $returnType = '\RadioManager\Model\EPGBroadcast'; - $request = $this->getDailyEPGRequest($date); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'getDailyEPG' + * Get next Broadcast * - * @param \DateTime $date Date *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\Broadcast, HTTP status code, HTTP response headers (array of strings) */ - protected function getDailyEPGRequest($date = null) + public function getNextBroadcastWithHttpInfo() { - - $resourcePath = '/broadcasts/epg/daily'; - $formParams = []; + // parse inputs + $resourcePath = "/broadcasts/next"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - - // query params - if ($date !== null) { - $queryParams['date'] = ObjectSerializer::toQueryValue($date); + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } - // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'GET', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\Broadcast', + '/broadcasts/next' + ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\Broadcast', $httpHeader), $statusCode, $httpHeader]; + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Broadcast', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 403: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 404: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 429: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + } - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + throw $e; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'GET', - $url, - $headers, - $httpBody - ); } /** - * Operation getEPGByDate + * Operation getWeeklyEPG * - * Get EPG by date + * Get weekly EPG * - * @param \DateTime $date Date *(Optional)* (optional) + * @param string $date Date *(Optional)* (optional) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return \RadioManager\Model\EPGBroadcast */ - public function getEPGByDate($date = null) + public function getWeeklyEPG($date = null) { - list($response) = $this->getEPGByDateWithHttpInfo($date); + list($response) = $this->getWeeklyEPGWithHttpInfo($date); return $response; } /** - * Operation getEPGByDateWithHttpInfo + * Operation getWeeklyEPGWithHttpInfo * - * Get EPG by date - * - * @param \DateTime $date Date *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\EPGBroadcast, HTTP status code, HTTP response headers (array of strings) - */ - public function getEPGByDateWithHttpInfo($date = null) - { - $returnType = '\RadioManager\Model\EPGBroadcast'; - $request = $this->getEPGByDateRequest($date); - - try { - - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\EPGBroadcast', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation getEPGByDateAsync - * - * Get EPG by date - * - * @param \DateTime $date Date *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getEPGByDateAsync($date = null) - { - return $this->getEPGByDateAsyncWithHttpInfo($date)->then(function ($response) { - return $response[0]; - }); - } - - /** - * Operation getEPGByDateAsyncWithHttpInfo - * - * Get EPG by date - * - * @param \DateTime $date Date *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getEPGByDateAsyncWithHttpInfo($date = null) - { - $returnType = '\RadioManager\Model\EPGBroadcast'; - $request = $this->getEPGByDateRequest($date); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'getEPGByDate' - * - * @param \DateTime $date Date *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - protected function getEPGByDateRequest($date = null) - { - - $resourcePath = '/broadcasts/epg'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - // query params - if ($date !== null) { - $queryParams['date'] = ObjectSerializer::toQueryValue($date); - } - - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } - - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } - } - - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; - } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'GET', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation getNextBroadcast - * - * Get next Broadcast - * - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\Broadcast - */ - public function getNextBroadcast() - { - list($response) = $this->getNextBroadcastWithHttpInfo(); - return $response; - } - - /** - * Operation getNextBroadcastWithHttpInfo - * - * Get next Broadcast - * - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\Broadcast, HTTP status code, HTTP response headers (array of strings) - */ - public function getNextBroadcastWithHttpInfo() - { - $returnType = '\RadioManager\Model\Broadcast'; - $request = $this->getNextBroadcastRequest(); - - try { - - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Broadcast', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation getNextBroadcastAsync - * - * Get next Broadcast - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getNextBroadcastAsync() - { - return $this->getNextBroadcastAsyncWithHttpInfo()->then(function ($response) { - return $response[0]; - }); - } - - /** - * Operation getNextBroadcastAsyncWithHttpInfo - * - * Get next Broadcast - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getNextBroadcastAsyncWithHttpInfo() - { - $returnType = '\RadioManager\Model\Broadcast'; - $request = $this->getNextBroadcastRequest(); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'getNextBroadcast' - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - protected function getNextBroadcastRequest() - { - - $resourcePath = '/broadcasts/next'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } - - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } - } - - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; - } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'GET', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation getWeeklyEPG - * - * Get weekly EPG - * - * @param string $date Date *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\EPGBroadcast - */ - public function getWeeklyEPG($date = null) - { - list($response) = $this->getWeeklyEPGWithHttpInfo($date); - return $response; - } - - /** - * Operation getWeeklyEPGWithHttpInfo - * - * Get weekly EPG + * Get weekly EPG * * @param string $date Date *(Optional)* (optional) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return array of \RadioManager\Model\EPGBroadcast, HTTP status code, HTTP response headers (array of strings) */ public function getWeeklyEPGWithHttpInfo($date = null) { - $returnType = '\RadioManager\Model\EPGBroadcast'; - $request = $this->getWeeklyEPGRequest($date); - - try { - - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\EPGBroadcast', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation getWeeklyEPGAsync - * - * Get weekly EPG - * - * @param string $date Date *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getWeeklyEPGAsync($date = null) - { - return $this->getWeeklyEPGAsyncWithHttpInfo($date)->then(function ($response) { - return $response[0]; - }); - } - - /** - * Operation getWeeklyEPGAsyncWithHttpInfo - * - * Get weekly EPG - * - * @param string $date Date *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getWeeklyEPGAsyncWithHttpInfo($date = null) - { - $returnType = '\RadioManager\Model\EPGBroadcast'; - $request = $this->getWeeklyEPGRequest($date); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'getWeeklyEPG' - * - * @param string $date Date *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - protected function getWeeklyEPGRequest($date = null) - { - - $resourcePath = '/broadcasts/epg/weekly'; - $formParams = []; + // parse inputs + $resourcePath = "/broadcasts/epg/weekly"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // query params if ($date !== null) { - $queryParams['date'] = ObjectSerializer::toQueryValue($date); - } - - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } - - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } - } - - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; - } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'GET', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation listBroadcasts - * - * Get all broadcasts. - * - * @param int $page Current page *(Optional)* (optional, default to 1) - * @param \DateTime $start_min Minimum start date *(Optional)* (optional) - * @param \DateTime $start_max Maximum start date *(Optional)* (optional) - * @param int $model_type_id Search on ModelType ID *(Optional)* (optional) - * @param int $tag_id Search on Tag ID *(Optional)* `(Relation)` (optional) - * @param int $presenter_id Search on Presenter ID *(Optional)* `(Relation)` (optional) - * @param int $item_id Search on Item ID *(Optional)* `(Relation)` (optional) - * @param int $block_id Search on Block ID *(Optional)* `(Relation)` (optional) - * @param int $genre_id Search on Genre ID *(Optional)* `(Relation)` (optional) - * @param int $program_id Search on Program ID *(Optional)* `(Relation)` (optional) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\BroadcastResults - */ - public function listBroadcasts($page = '1', $start_min = null, $start_max = null, $model_type_id = null, $tag_id = null, $presenter_id = null, $item_id = null, $block_id = null, $genre_id = null, $program_id = null, $_external_station_id = null) - { - list($response) = $this->listBroadcastsWithHttpInfo($page, $start_min, $start_max, $model_type_id, $tag_id, $presenter_id, $item_id, $block_id, $genre_id, $program_id, $_external_station_id); - return $response; - } - - /** - * Operation listBroadcastsWithHttpInfo - * - * Get all broadcasts. - * - * @param int $page Current page *(Optional)* (optional, default to 1) - * @param \DateTime $start_min Minimum start date *(Optional)* (optional) - * @param \DateTime $start_max Maximum start date *(Optional)* (optional) - * @param int $model_type_id Search on ModelType ID *(Optional)* (optional) - * @param int $tag_id Search on Tag ID *(Optional)* `(Relation)` (optional) - * @param int $presenter_id Search on Presenter ID *(Optional)* `(Relation)` (optional) - * @param int $item_id Search on Item ID *(Optional)* `(Relation)` (optional) - * @param int $block_id Search on Block ID *(Optional)* `(Relation)` (optional) - * @param int $genre_id Search on Genre ID *(Optional)* `(Relation)` (optional) - * @param int $program_id Search on Program ID *(Optional)* `(Relation)` (optional) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\BroadcastResults, HTTP status code, HTTP response headers (array of strings) - */ - public function listBroadcastsWithHttpInfo($page = '1', $start_min = null, $start_max = null, $model_type_id = null, $tag_id = null, $presenter_id = null, $item_id = null, $block_id = null, $genre_id = null, $program_id = null, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\BroadcastResults'; - $request = $this->listBroadcastsRequest($page, $start_min, $start_max, $model_type_id, $tag_id, $presenter_id, $item_id, $block_id, $genre_id, $program_id, $_external_station_id); - - try { - - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $responseBody = $response->getBody(); - if ($returnType === '\SplFileObject') { - $content = $responseBody; //stream goes to serializer - } else { - $content = $responseBody->getContents(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } + $queryParams['date'] = $this->apiClient->getSerializer()->toQueryValue($date); + } - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } elseif (count($formParams) > 0) { + $httpBody = $formParams; // for HTTP post (form) + } + // this endpoint requires API key authentication + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; + } + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'GET', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\EPGBroadcast', + '/broadcasts/epg/weekly' + ); + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\EPGBroadcast', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\BroadcastResults', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\EPGBroadcast', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation listBroadcastsAsync + * Operation listBroadcasts * * Get all broadcasts. * @@ -2118,18 +854,17 @@ public function listBroadcastsWithHttpInfo($page = '1', $start_min = null, $star * @param int $genre_id Search on Genre ID *(Optional)* `(Relation)` (optional) * @param int $program_id Search on Program ID *(Optional)* `(Relation)` (optional) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\BroadcastResults */ - public function listBroadcastsAsync($page = '1', $start_min = null, $start_max = null, $model_type_id = null, $tag_id = null, $presenter_id = null, $item_id = null, $block_id = null, $genre_id = null, $program_id = null, $_external_station_id = null) + public function listBroadcasts($page = '1', $start_min = null, $start_max = null, $model_type_id = null, $tag_id = null, $presenter_id = null, $item_id = null, $block_id = null, $genre_id = null, $program_id = null, $_external_station_id = null) { - return $this->listBroadcastsAsyncWithHttpInfo($page, $start_min, $start_max, $model_type_id, $tag_id, $presenter_id, $item_id, $block_id, $genre_id, $program_id, $_external_station_id)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->listBroadcastsWithHttpInfo($page, $start_min, $start_max, $model_type_id, $tag_id, $presenter_id, $item_id, $block_id, $genre_id, $program_id, $_external_station_id); + return $response; } /** - * Operation listBroadcastsAsyncWithHttpInfo + * Operation listBroadcastsWithHttpInfo * * Get all broadcasts. * @@ -2144,283 +879,122 @@ public function listBroadcastsAsync($page = '1', $start_min = null, $start_max = * @param int $genre_id Search on Genre ID *(Optional)* `(Relation)` (optional) * @param int $program_id Search on Program ID *(Optional)* `(Relation)` (optional) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function listBroadcastsAsyncWithHttpInfo($page = '1', $start_min = null, $start_max = null, $model_type_id = null, $tag_id = null, $presenter_id = null, $item_id = null, $block_id = null, $genre_id = null, $program_id = null, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\BroadcastResults'; - $request = $this->listBroadcastsRequest($page, $start_min, $start_max, $model_type_id, $tag_id, $presenter_id, $item_id, $block_id, $genre_id, $program_id, $_external_station_id); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'listBroadcasts' - * - * @param int $page Current page *(Optional)* (optional, default to 1) - * @param \DateTime $start_min Minimum start date *(Optional)* (optional) - * @param \DateTime $start_max Maximum start date *(Optional)* (optional) - * @param int $model_type_id Search on ModelType ID *(Optional)* (optional) - * @param int $tag_id Search on Tag ID *(Optional)* `(Relation)` (optional) - * @param int $presenter_id Search on Presenter ID *(Optional)* `(Relation)` (optional) - * @param int $item_id Search on Item ID *(Optional)* `(Relation)` (optional) - * @param int $block_id Search on Block ID *(Optional)* `(Relation)` (optional) - * @param int $genre_id Search on Genre ID *(Optional)* `(Relation)` (optional) - * @param int $program_id Search on Program ID *(Optional)* `(Relation)` (optional) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\BroadcastResults, HTTP status code, HTTP response headers (array of strings) */ - protected function listBroadcastsRequest($page = '1', $start_min = null, $start_max = null, $model_type_id = null, $tag_id = null, $presenter_id = null, $item_id = null, $block_id = null, $genre_id = null, $program_id = null, $_external_station_id = null) + public function listBroadcastsWithHttpInfo($page = '1', $start_min = null, $start_max = null, $model_type_id = null, $tag_id = null, $presenter_id = null, $item_id = null, $block_id = null, $genre_id = null, $program_id = null, $_external_station_id = null) { - if ($page !== null && $page < 0) { + if (!is_null($page) && ($page < 0)) { throw new \InvalidArgumentException('invalid value for "$page" when calling BroadcastApi.listBroadcasts, must be bigger than or equal to 0.'); } - - $resourcePath = '/broadcasts'; - $formParams = []; + // parse inputs + $resourcePath = "/broadcasts"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // query params if ($page !== null) { - $queryParams['page'] = ObjectSerializer::toQueryValue($page); + $queryParams['page'] = $this->apiClient->getSerializer()->toQueryValue($page); } // query params if ($start_min !== null) { - $queryParams['start-min'] = ObjectSerializer::toQueryValue($start_min); + $queryParams['start-min'] = $this->apiClient->getSerializer()->toQueryValue($start_min); } // query params if ($start_max !== null) { - $queryParams['start-max'] = ObjectSerializer::toQueryValue($start_max); + $queryParams['start-max'] = $this->apiClient->getSerializer()->toQueryValue($start_max); } // query params if ($model_type_id !== null) { - $queryParams['model_type_id'] = ObjectSerializer::toQueryValue($model_type_id); + $queryParams['model_type_id'] = $this->apiClient->getSerializer()->toQueryValue($model_type_id); } // query params if ($tag_id !== null) { - $queryParams['tag_id'] = ObjectSerializer::toQueryValue($tag_id); + $queryParams['tag_id'] = $this->apiClient->getSerializer()->toQueryValue($tag_id); } // query params if ($presenter_id !== null) { - $queryParams['presenter_id'] = ObjectSerializer::toQueryValue($presenter_id); + $queryParams['presenter_id'] = $this->apiClient->getSerializer()->toQueryValue($presenter_id); } // query params if ($item_id !== null) { - $queryParams['item_id'] = ObjectSerializer::toQueryValue($item_id); + $queryParams['item_id'] = $this->apiClient->getSerializer()->toQueryValue($item_id); } // query params if ($block_id !== null) { - $queryParams['block_id'] = ObjectSerializer::toQueryValue($block_id); + $queryParams['block_id'] = $this->apiClient->getSerializer()->toQueryValue($block_id); } // query params if ($genre_id !== null) { - $queryParams['genre_id'] = ObjectSerializer::toQueryValue($genre_id); + $queryParams['genre_id'] = $this->apiClient->getSerializer()->toQueryValue($genre_id); } // query params if ($program_id !== null) { - $queryParams['program_id'] = ObjectSerializer::toQueryValue($program_id); + $queryParams['program_id'] = $this->apiClient->getSerializer()->toQueryValue($program_id); } // query params if ($_external_station_id !== null) { - $queryParams['_external_station_id'] = ObjectSerializer::toQueryValue($_external_station_id); - } - - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); + $queryParams['_external_station_id'] = $this->apiClient->getSerializer()->toQueryValue($_external_station_id); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; - } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'GET', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation printBroadcastById - * - * Print Broadcast by id - * - * @param int $id ID of Broadcast **(Required)** (required) - * @param int $program_id Search on Program ID *(Optional)* `(Relation)` (optional) - * @param int $presenter_id Search on Presenter ID *(Optional)* `(Relation)` (optional) - * @param int $tag_id Search on Tag ID *(Optional)* `(Relation)` (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\EPGBroadcast - */ - public function printBroadcastById($id, $program_id = null, $presenter_id = null, $tag_id = null) - { - list($response) = $this->printBroadcastByIdWithHttpInfo($id, $program_id, $presenter_id, $tag_id); - return $response; - } - - /** - * Operation printBroadcastByIdWithHttpInfo - * - * Print Broadcast by id - * - * @param int $id ID of Broadcast **(Required)** (required) - * @param int $program_id Search on Program ID *(Optional)* `(Relation)` (optional) - * @param int $presenter_id Search on Presenter ID *(Optional)* `(Relation)` (optional) - * @param int $tag_id Search on Tag ID *(Optional)* `(Relation)` (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\EPGBroadcast, HTTP status code, HTTP response headers (array of strings) - */ - public function printBroadcastByIdWithHttpInfo($id, $program_id = null, $presenter_id = null, $tag_id = null) - { - $returnType = '\RadioManager\Model\EPGBroadcast'; - $request = $this->printBroadcastByIdRequest($id, $program_id, $presenter_id, $tag_id); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'GET', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\BroadcastResults', + '/broadcasts' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\BroadcastResults', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\EPGBroadcast', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\BroadcastResults', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation printBroadcastByIdAsync + * Operation printBroadcastById * * Print Broadcast by id * @@ -2428,18 +1002,17 @@ public function printBroadcastByIdWithHttpInfo($id, $program_id = null, $present * @param int $program_id Search on Program ID *(Optional)* `(Relation)` (optional) * @param int $presenter_id Search on Presenter ID *(Optional)* `(Relation)` (optional) * @param int $tag_id Search on Tag ID *(Optional)* `(Relation)` (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\EPGBroadcast */ - public function printBroadcastByIdAsync($id, $program_id = null, $presenter_id = null, $tag_id = null) + public function printBroadcastById($id, $program_id = null, $presenter_id = null, $tag_id = null) { - return $this->printBroadcastByIdAsyncWithHttpInfo($id, $program_id, $presenter_id, $tag_id)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->printBroadcastByIdWithHttpInfo($id, $program_id, $presenter_id, $tag_id); + return $response; } /** - * Operation printBroadcastByIdAsyncWithHttpInfo + * Operation printBroadcastByIdWithHttpInfo * * Print Broadcast by id * @@ -2447,408 +1020,211 @@ public function printBroadcastByIdAsync($id, $program_id = null, $presenter_id = * @param int $program_id Search on Program ID *(Optional)* `(Relation)` (optional) * @param int $presenter_id Search on Presenter ID *(Optional)* `(Relation)` (optional) * @param int $tag_id Search on Tag ID *(Optional)* `(Relation)` (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function printBroadcastByIdAsyncWithHttpInfo($id, $program_id = null, $presenter_id = null, $tag_id = null) - { - $returnType = '\RadioManager\Model\EPGBroadcast'; - $request = $this->printBroadcastByIdRequest($id, $program_id, $presenter_id, $tag_id); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'printBroadcastById' - * - * @param int $id ID of Broadcast **(Required)** (required) - * @param int $program_id Search on Program ID *(Optional)* `(Relation)` (optional) - * @param int $presenter_id Search on Presenter ID *(Optional)* `(Relation)` (optional) - * @param int $tag_id Search on Tag ID *(Optional)* `(Relation)` (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\EPGBroadcast, HTTP status code, HTTP response headers (array of strings) */ - protected function printBroadcastByIdRequest($id, $program_id = null, $presenter_id = null, $tag_id = null) + public function printBroadcastByIdWithHttpInfo($id, $program_id = null, $presenter_id = null, $tag_id = null) { // verify the required parameter 'id' is set if ($id === null) { throw new \InvalidArgumentException('Missing the required parameter $id when calling printBroadcastById'); } - if ($id < 0) { + if (($id < 0)) { throw new \InvalidArgumentException('invalid value for "$id" when calling BroadcastApi.printBroadcastById, must be bigger than or equal to 0.'); } - - $resourcePath = '/broadcasts/print/{id}'; - $formParams = []; + // parse inputs + $resourcePath = "/broadcasts/print/{id}"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // query params if ($program_id !== null) { - $queryParams['program_id'] = ObjectSerializer::toQueryValue($program_id); + $queryParams['program_id'] = $this->apiClient->getSerializer()->toQueryValue($program_id); } // query params if ($presenter_id !== null) { - $queryParams['presenter_id'] = ObjectSerializer::toQueryValue($presenter_id); + $queryParams['presenter_id'] = $this->apiClient->getSerializer()->toQueryValue($presenter_id); } // query params if ($tag_id !== null) { - $queryParams['tag_id'] = ObjectSerializer::toQueryValue($tag_id); + $queryParams['tag_id'] = $this->apiClient->getSerializer()->toQueryValue($tag_id); } - // path params if ($id !== null) { - $resourcePath = str_replace('{' . 'id' . '}', ObjectSerializer::toPathValue($id), $resourcePath); - } - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] + $resourcePath = str_replace( + "{" . "id" . "}", + $this->apiClient->getSerializer()->toPathValue($id), + $resourcePath ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; - } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'GET', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation updateBroadcastByID - * - * Update broadcast by id - * - * @param int $id ID of Broadcast **(Required)** (required) - * @param \RadioManager\Model\BroadcastDataInput $data Data *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\Success - */ - public function updateBroadcastByID($id, $data = null) - { - list($response) = $this->updateBroadcastByIDWithHttpInfo($id, $data); - return $response; - } - - /** - * Operation updateBroadcastByIDWithHttpInfo - * - * Update broadcast by id - * - * @param int $id ID of Broadcast **(Required)** (required) - * @param \RadioManager\Model\BroadcastDataInput $data Data *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\Success, HTTP status code, HTTP response headers (array of strings) - */ - public function updateBroadcastByIDWithHttpInfo($id, $data = null) - { - $returnType = '\RadioManager\Model\Success'; - $request = $this->updateBroadcastByIDRequest($id, $data); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'GET', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\EPGBroadcast', + '/broadcasts/print/{id}' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\EPGBroadcast', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\EPGBroadcast', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 422: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation updateBroadcastByIDAsync + * Operation updateBroadcastByID * * Update broadcast by id * * @param int $id ID of Broadcast **(Required)** (required) * @param \RadioManager\Model\BroadcastDataInput $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\Success */ - public function updateBroadcastByIDAsync($id, $data = null) + public function updateBroadcastByID($id, $data = null) { - return $this->updateBroadcastByIDAsyncWithHttpInfo($id, $data)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->updateBroadcastByIDWithHttpInfo($id, $data); + return $response; } /** - * Operation updateBroadcastByIDAsyncWithHttpInfo + * Operation updateBroadcastByIDWithHttpInfo * * Update broadcast by id * * @param int $id ID of Broadcast **(Required)** (required) * @param \RadioManager\Model\BroadcastDataInput $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function updateBroadcastByIDAsyncWithHttpInfo($id, $data = null) - { - $returnType = '\RadioManager\Model\Success'; - $request = $this->updateBroadcastByIDRequest($id, $data); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'updateBroadcastByID' - * - * @param int $id ID of Broadcast **(Required)** (required) - * @param \RadioManager\Model\BroadcastDataInput $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\Success, HTTP status code, HTTP response headers (array of strings) */ - protected function updateBroadcastByIDRequest($id, $data = null) + public function updateBroadcastByIDWithHttpInfo($id, $data = null) { // verify the required parameter 'id' is set if ($id === null) { throw new \InvalidArgumentException('Missing the required parameter $id when calling updateBroadcastByID'); } - if ($id < 0) { + if (($id < 0)) { throw new \InvalidArgumentException('invalid value for "$id" when calling BroadcastApi.updateBroadcastByID, must be bigger than or equal to 0.'); } - - $resourcePath = '/broadcasts/{id}'; - $formParams = []; + // parse inputs + $resourcePath = "/broadcasts/{id}"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // path params if ($id !== null) { - $resourcePath = str_replace('{' . 'id' . '}', ObjectSerializer::toPathValue($id), $resourcePath); + $resourcePath = str_replace( + "{" . "id" . "}", + $this->apiClient->getSerializer()->toPathValue($id), + $resourcePath + ); } - // body params $_tempBody = null; if (isset($data)) { $_tempBody = $data; } - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } - // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'PATCH', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\Success', + '/broadcasts/{id}' + ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\Success', $httpHeader), $statusCode, $httpHeader]; + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 403: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 404: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 422: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 429: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + } - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + throw $e; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'PATCH', - $url, - $headers, - $httpBody - ); } - } diff --git a/lib/Api/CampaignApi.php b/lib/Api/CampaignApi.php index 7221c5d..d56cf9c 100644 --- a/lib/Api/CampaignApi.php +++ b/lib/Api/CampaignApi.php @@ -28,15 +28,10 @@ namespace RadioManager\Api; -use GuzzleHttp\Client; -use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\Psr7\MultipartStream; -use GuzzleHttp\Psr7\Request; -use RadioManager\ApiException; -use RadioManager\Configuration; -use RadioManager\HeaderSelector; -use RadioManager\ObjectSerializer; +use \RadioManager\ApiClient; +use \RadioManager\ApiException; +use \RadioManager\Configuration; +use \RadioManager\ObjectSerializer; /** * CampaignApi Class Doc Comment @@ -49,36 +44,47 @@ class CampaignApi { /** - * @var ClientInterface + * API Client + * + * @var \RadioManager\ApiClient instance of the ApiClient */ - protected $client; + protected $apiClient; /** - * @var Configuration + * Constructor + * + * @param \RadioManager\ApiClient|null $apiClient The api client to use */ - protected $config; + public function __construct(\RadioManager\ApiClient $apiClient = null) + { + if ($apiClient === null) { + $apiClient = new ApiClient(); + } + + $this->apiClient = $apiClient; + } /** - * @param ClientInterface $client - * @param Configuration $config - * @param HeaderSelector $selector + * Get API client + * + * @return \RadioManager\ApiClient get the API client */ - public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null - ) { - $this->client = $client ?: new Client(); - $this->config = $config ?: new Configuration(); - $this->headerSelector = $selector ?: new HeaderSelector(); + public function getApiClient() + { + return $this->apiClient; } /** - * @return Configuration + * Set the API client + * + * @param \RadioManager\ApiClient $apiClient set the API client + * + * @return CampaignApi */ - public function getConfig() + public function setApiClient(\RadioManager\ApiClient $apiClient) { - return $this->config; + $this->apiClient = $apiClient; + return $this; } /** @@ -88,7 +94,6 @@ public function getConfig() * * @param \RadioManager\Model\CampaignDataInput $data Data **(Required)** (required) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return \RadioManager\Model\PostSuccess */ public function createCampaign($data) @@ -104,160 +109,25 @@ public function createCampaign($data) * * @param \RadioManager\Model\CampaignDataInput $data Data **(Required)** (required) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return array of \RadioManager\Model\PostSuccess, HTTP status code, HTTP response headers (array of strings) */ public function createCampaignWithHttpInfo($data) - { - $returnType = '\RadioManager\Model\PostSuccess'; - $request = $this->createCampaignRequest($data); - - try { - - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\PostSuccess', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 422: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation createCampaignAsync - * - * Create campaign. - * - * @param \RadioManager\Model\CampaignDataInput $data Data **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function createCampaignAsync($data) - { - return $this->createCampaignAsyncWithHttpInfo($data)->then(function ($response) { - return $response[0]; - }); - } - - /** - * Operation createCampaignAsyncWithHttpInfo - * - * Create campaign. - * - * @param \RadioManager\Model\CampaignDataInput $data Data **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function createCampaignAsyncWithHttpInfo($data) - { - $returnType = '\RadioManager\Model\PostSuccess'; - $request = $this->createCampaignRequest($data); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'createCampaign' - * - * @param \RadioManager\Model\CampaignDataInput $data Data **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - protected function createCampaignRequest($data) { // verify the required parameter 'data' is set if ($data === null) { throw new \InvalidArgumentException('Missing the required parameter $data when calling createCampaign'); } - - $resourcePath = '/campaigns'; - $formParams = []; + // parse inputs + $resourcePath = "/campaigns"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - - + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // body params $_tempBody = null; @@ -265,672 +135,272 @@ protected function createCampaignRequest($data) $_tempBody = $data; } - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } - // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; - } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'POST', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation deleteCampaignById - * - * Delete campaign by id - * - * @param int $id ID of Campaign **(Required)** (required) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\Success - */ - public function deleteCampaignById($id) - { - list($response) = $this->deleteCampaignByIdWithHttpInfo($id); - return $response; - } - - /** - * Operation deleteCampaignByIdWithHttpInfo - * - * Delete campaign by id - * - * @param int $id ID of Campaign **(Required)** (required) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\Success, HTTP status code, HTTP response headers (array of strings) - */ - public function deleteCampaignByIdWithHttpInfo($id) - { - $returnType = '\RadioManager\Model\Success'; - $request = $this->deleteCampaignByIdRequest($id); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'POST', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\PostSuccess', + '/campaigns' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\PostSuccess', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\PostSuccess', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 422: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation deleteCampaignByIdAsync + * Operation deleteCampaignById * * Delete campaign by id * * @param int $id ID of Campaign **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\Success */ - public function deleteCampaignByIdAsync($id) + public function deleteCampaignById($id) { - return $this->deleteCampaignByIdAsyncWithHttpInfo($id)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->deleteCampaignByIdWithHttpInfo($id); + return $response; } /** - * Operation deleteCampaignByIdAsyncWithHttpInfo + * Operation deleteCampaignByIdWithHttpInfo * * Delete campaign by id * * @param int $id ID of Campaign **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function deleteCampaignByIdAsyncWithHttpInfo($id) - { - $returnType = '\RadioManager\Model\Success'; - $request = $this->deleteCampaignByIdRequest($id); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'deleteCampaignById' - * - * @param int $id ID of Campaign **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\Success, HTTP status code, HTTP response headers (array of strings) */ - protected function deleteCampaignByIdRequest($id) + public function deleteCampaignByIdWithHttpInfo($id) { // verify the required parameter 'id' is set if ($id === null) { throw new \InvalidArgumentException('Missing the required parameter $id when calling deleteCampaignById'); } - if ($id < 0) { + if (($id < 0)) { throw new \InvalidArgumentException('invalid value for "$id" when calling CampaignApi.deleteCampaignById, must be bigger than or equal to 0.'); } - - $resourcePath = '/campaigns/{id}'; - $formParams = []; + // parse inputs + $resourcePath = "/campaigns/{id}"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // path params if ($id !== null) { - $resourcePath = str_replace('{' . 'id' . '}', ObjectSerializer::toPathValue($id), $resourcePath); - } - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] + $resourcePath = str_replace( + "{" . "id" . "}", + $this->apiClient->getSerializer()->toPathValue($id), + $resourcePath ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'DELETE', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation getCampaignById - * - * Get campaign by id - * - * @param int $id ID of Campaign **(Required)** (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\CampaignResult - */ - public function getCampaignById($id, $_external_station_id = null) - { - list($response) = $this->getCampaignByIdWithHttpInfo($id, $_external_station_id); - return $response; - } - - /** - * Operation getCampaignByIdWithHttpInfo - * - * Get campaign by id - * - * @param int $id ID of Campaign **(Required)** (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\CampaignResult, HTTP status code, HTTP response headers (array of strings) - */ - public function getCampaignByIdWithHttpInfo($id, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\CampaignResult'; - $request = $this->getCampaignByIdRequest($id, $_external_station_id); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'DELETE', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\Success', + '/campaigns/{id}' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\Success', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\CampaignResult', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation getCampaignByIdAsync + * Operation getCampaignById * * Get campaign by id * * @param int $id ID of Campaign **(Required)** (required) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\CampaignResult */ - public function getCampaignByIdAsync($id, $_external_station_id = null) + public function getCampaignById($id, $_external_station_id = null) { - return $this->getCampaignByIdAsyncWithHttpInfo($id, $_external_station_id)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->getCampaignByIdWithHttpInfo($id, $_external_station_id); + return $response; } /** - * Operation getCampaignByIdAsyncWithHttpInfo + * Operation getCampaignByIdWithHttpInfo * * Get campaign by id * * @param int $id ID of Campaign **(Required)** (required) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getCampaignByIdAsyncWithHttpInfo($id, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\CampaignResult'; - $request = $this->getCampaignByIdRequest($id, $_external_station_id); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'getCampaignById' - * - * @param int $id ID of Campaign **(Required)** (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\CampaignResult, HTTP status code, HTTP response headers (array of strings) */ - protected function getCampaignByIdRequest($id, $_external_station_id = null) + public function getCampaignByIdWithHttpInfo($id, $_external_station_id = null) { // verify the required parameter 'id' is set if ($id === null) { throw new \InvalidArgumentException('Missing the required parameter $id when calling getCampaignById'); } - if ($id < 0) { + if (($id < 0)) { throw new \InvalidArgumentException('invalid value for "$id" when calling CampaignApi.getCampaignById, must be bigger than or equal to 0.'); } - - $resourcePath = '/campaigns/{id}'; - $formParams = []; + // parse inputs + $resourcePath = "/campaigns/{id}"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // query params if ($_external_station_id !== null) { - $queryParams['_external_station_id'] = ObjectSerializer::toQueryValue($_external_station_id); + $queryParams['_external_station_id'] = $this->apiClient->getSerializer()->toQueryValue($_external_station_id); } - // path params if ($id !== null) { - $resourcePath = str_replace('{' . 'id' . '}', ObjectSerializer::toPathValue($id), $resourcePath); - } - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] + $resourcePath = str_replace( + "{" . "id" . "}", + $this->apiClient->getSerializer()->toPathValue($id), + $resourcePath ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'GET', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation listCampaigns - * - * Get all campaigns. - * - * @param int $page Current page *(Optional)* (optional) - * @param int $model_type_id Search on ModelType ID *(Optional)* (optional) - * @param int $item_id Search on Item ID *(Optional)* `(Relation)` (optional) - * @param \DateTime $start_min Minimum start date *(Optional)* (optional) - * @param \DateTime $start_max Maximum start date *(Optional)* (optional) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\CampaignResults - */ - public function listCampaigns($page = null, $model_type_id = null, $item_id = null, $start_min = null, $start_max = null, $_external_station_id = null) - { - list($response) = $this->listCampaignsWithHttpInfo($page, $model_type_id, $item_id, $start_min, $start_max, $_external_station_id); - return $response; - } - - /** - * Operation listCampaignsWithHttpInfo - * - * Get all campaigns. - * - * @param int $page Current page *(Optional)* (optional) - * @param int $model_type_id Search on ModelType ID *(Optional)* (optional) - * @param int $item_id Search on Item ID *(Optional)* `(Relation)` (optional) - * @param \DateTime $start_min Minimum start date *(Optional)* (optional) - * @param \DateTime $start_max Maximum start date *(Optional)* (optional) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\CampaignResults, HTTP status code, HTTP response headers (array of strings) - */ - public function listCampaignsWithHttpInfo($page = null, $model_type_id = null, $item_id = null, $start_min = null, $start_max = null, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\CampaignResults'; - $request = $this->listCampaignsRequest($page, $model_type_id, $item_id, $start_min, $start_max, $_external_station_id); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'GET', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\CampaignResult', + '/campaigns/{id}' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\CampaignResult', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\CampaignResults', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\CampaignResult', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation listCampaignsAsync + * Operation listCampaigns * * Get all campaigns. * @@ -940,18 +410,17 @@ public function listCampaignsWithHttpInfo($page = null, $model_type_id = null, $ * @param \DateTime $start_min Minimum start date *(Optional)* (optional) * @param \DateTime $start_max Maximum start date *(Optional)* (optional) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\CampaignResults */ - public function listCampaignsAsync($page = null, $model_type_id = null, $item_id = null, $start_min = null, $start_max = null, $_external_station_id = null) + public function listCampaigns($page = null, $model_type_id = null, $item_id = null, $start_min = null, $start_max = null, $_external_station_id = null) { - return $this->listCampaignsAsyncWithHttpInfo($page, $model_type_id, $item_id, $start_min, $start_max, $_external_station_id)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->listCampaignsWithHttpInfo($page, $model_type_id, $item_id, $start_min, $start_max, $_external_station_id); + return $response; } /** - * Operation listCampaignsAsyncWithHttpInfo + * Operation listCampaignsWithHttpInfo * * Get all campaigns. * @@ -961,414 +430,211 @@ public function listCampaignsAsync($page = null, $model_type_id = null, $item_id * @param \DateTime $start_min Minimum start date *(Optional)* (optional) * @param \DateTime $start_max Maximum start date *(Optional)* (optional) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function listCampaignsAsyncWithHttpInfo($page = null, $model_type_id = null, $item_id = null, $start_min = null, $start_max = null, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\CampaignResults'; - $request = $this->listCampaignsRequest($page, $model_type_id, $item_id, $start_min, $start_max, $_external_station_id); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'listCampaigns' - * - * @param int $page Current page *(Optional)* (optional) - * @param int $model_type_id Search on ModelType ID *(Optional)* (optional) - * @param int $item_id Search on Item ID *(Optional)* `(Relation)` (optional) - * @param \DateTime $start_min Minimum start date *(Optional)* (optional) - * @param \DateTime $start_max Maximum start date *(Optional)* (optional) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\CampaignResults, HTTP status code, HTTP response headers (array of strings) */ - protected function listCampaignsRequest($page = null, $model_type_id = null, $item_id = null, $start_min = null, $start_max = null, $_external_station_id = null) + public function listCampaignsWithHttpInfo($page = null, $model_type_id = null, $item_id = null, $start_min = null, $start_max = null, $_external_station_id = null) { - if ($page !== null && $page < 0) { + if (!is_null($page) && ($page < 0)) { throw new \InvalidArgumentException('invalid value for "$page" when calling CampaignApi.listCampaigns, must be bigger than or equal to 0.'); } - - $resourcePath = '/campaigns'; - $formParams = []; + // parse inputs + $resourcePath = "/campaigns"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // query params if ($page !== null) { - $queryParams['page'] = ObjectSerializer::toQueryValue($page); + $queryParams['page'] = $this->apiClient->getSerializer()->toQueryValue($page); } // query params if ($model_type_id !== null) { - $queryParams['model_type_id'] = ObjectSerializer::toQueryValue($model_type_id); + $queryParams['model_type_id'] = $this->apiClient->getSerializer()->toQueryValue($model_type_id); } // query params if ($item_id !== null) { - $queryParams['item_id'] = ObjectSerializer::toQueryValue($item_id); + $queryParams['item_id'] = $this->apiClient->getSerializer()->toQueryValue($item_id); } // query params if ($start_min !== null) { - $queryParams['start-min'] = ObjectSerializer::toQueryValue($start_min); + $queryParams['start-min'] = $this->apiClient->getSerializer()->toQueryValue($start_min); } // query params if ($start_max !== null) { - $queryParams['start-max'] = ObjectSerializer::toQueryValue($start_max); + $queryParams['start-max'] = $this->apiClient->getSerializer()->toQueryValue($start_max); } // query params if ($_external_station_id !== null) { - $queryParams['_external_station_id'] = ObjectSerializer::toQueryValue($_external_station_id); - } - - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); + $queryParams['_external_station_id'] = $this->apiClient->getSerializer()->toQueryValue($_external_station_id); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; - } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'GET', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation updateCampaignByID - * - * Update campaign by id - * - * @param int $id ID of Campaign **(Required)** (required) - * @param \RadioManager\Model\CampaignDataInput $data Data *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\Success - */ - public function updateCampaignByID($id, $data = null) - { - list($response) = $this->updateCampaignByIDWithHttpInfo($id, $data); - return $response; - } - - /** - * Operation updateCampaignByIDWithHttpInfo - * - * Update campaign by id - * - * @param int $id ID of Campaign **(Required)** (required) - * @param \RadioManager\Model\CampaignDataInput $data Data *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\Success, HTTP status code, HTTP response headers (array of strings) - */ - public function updateCampaignByIDWithHttpInfo($id, $data = null) - { - $returnType = '\RadioManager\Model\Success'; - $request = $this->updateCampaignByIDRequest($id, $data); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'GET', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\CampaignResults', + '/campaigns' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\CampaignResults', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\CampaignResults', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 422: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation updateCampaignByIDAsync + * Operation updateCampaignByID * * Update campaign by id * * @param int $id ID of Campaign **(Required)** (required) * @param \RadioManager\Model\CampaignDataInput $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\Success */ - public function updateCampaignByIDAsync($id, $data = null) + public function updateCampaignByID($id, $data = null) { - return $this->updateCampaignByIDAsyncWithHttpInfo($id, $data)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->updateCampaignByIDWithHttpInfo($id, $data); + return $response; } /** - * Operation updateCampaignByIDAsyncWithHttpInfo + * Operation updateCampaignByIDWithHttpInfo * * Update campaign by id * * @param int $id ID of Campaign **(Required)** (required) * @param \RadioManager\Model\CampaignDataInput $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function updateCampaignByIDAsyncWithHttpInfo($id, $data = null) - { - $returnType = '\RadioManager\Model\Success'; - $request = $this->updateCampaignByIDRequest($id, $data); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'updateCampaignByID' - * - * @param int $id ID of Campaign **(Required)** (required) - * @param \RadioManager\Model\CampaignDataInput $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\Success, HTTP status code, HTTP response headers (array of strings) */ - protected function updateCampaignByIDRequest($id, $data = null) + public function updateCampaignByIDWithHttpInfo($id, $data = null) { // verify the required parameter 'id' is set if ($id === null) { throw new \InvalidArgumentException('Missing the required parameter $id when calling updateCampaignByID'); } - if ($id < 0) { + if (($id < 0)) { throw new \InvalidArgumentException('invalid value for "$id" when calling CampaignApi.updateCampaignByID, must be bigger than or equal to 0.'); } - - $resourcePath = '/campaigns/{id}'; - $formParams = []; + // parse inputs + $resourcePath = "/campaigns/{id}"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // path params if ($id !== null) { - $resourcePath = str_replace('{' . 'id' . '}', ObjectSerializer::toPathValue($id), $resourcePath); + $resourcePath = str_replace( + "{" . "id" . "}", + $this->apiClient->getSerializer()->toPathValue($id), + $resourcePath + ); } - // body params $_tempBody = null; if (isset($data)) { $_tempBody = $data; } - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } - // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'PATCH', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\Success', + '/campaigns/{id}' + ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\Success', $httpHeader), $statusCode, $httpHeader]; + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 403: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 404: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 422: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 429: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + } - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + throw $e; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'PATCH', - $url, - $headers, - $httpBody - ); } - } diff --git a/lib/Api/ContactApi.php b/lib/Api/ContactApi.php index 83ef6fe..a05dd2d 100644 --- a/lib/Api/ContactApi.php +++ b/lib/Api/ContactApi.php @@ -28,15 +28,10 @@ namespace RadioManager\Api; -use GuzzleHttp\Client; -use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\Psr7\MultipartStream; -use GuzzleHttp\Psr7\Request; -use RadioManager\ApiException; -use RadioManager\Configuration; -use RadioManager\HeaderSelector; -use RadioManager\ObjectSerializer; +use \RadioManager\ApiClient; +use \RadioManager\ApiException; +use \RadioManager\Configuration; +use \RadioManager\ObjectSerializer; /** * ContactApi Class Doc Comment @@ -49,36 +44,47 @@ class ContactApi { /** - * @var ClientInterface + * API Client + * + * @var \RadioManager\ApiClient instance of the ApiClient */ - protected $client; + protected $apiClient; /** - * @var Configuration + * Constructor + * + * @param \RadioManager\ApiClient|null $apiClient The api client to use */ - protected $config; + public function __construct(\RadioManager\ApiClient $apiClient = null) + { + if ($apiClient === null) { + $apiClient = new ApiClient(); + } + + $this->apiClient = $apiClient; + } /** - * @param ClientInterface $client - * @param Configuration $config - * @param HeaderSelector $selector + * Get API client + * + * @return \RadioManager\ApiClient get the API client */ - public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null - ) { - $this->client = $client ?: new Client(); - $this->config = $config ?: new Configuration(); - $this->headerSelector = $selector ?: new HeaderSelector(); + public function getApiClient() + { + return $this->apiClient; } /** - * @return Configuration + * Set the API client + * + * @param \RadioManager\ApiClient $apiClient set the API client + * + * @return ContactApi */ - public function getConfig() + public function setApiClient(\RadioManager\ApiClient $apiClient) { - return $this->config; + $this->apiClient = $apiClient; + return $this; } /** @@ -88,7 +94,6 @@ public function getConfig() * * @param \RadioManager\Model\ContactDataInput $data Data **(Required)** (required) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return \RadioManager\Model\PostSuccess */ public function createContact($data) @@ -104,160 +109,25 @@ public function createContact($data) * * @param \RadioManager\Model\ContactDataInput $data Data **(Required)** (required) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return array of \RadioManager\Model\PostSuccess, HTTP status code, HTTP response headers (array of strings) */ public function createContactWithHttpInfo($data) - { - $returnType = '\RadioManager\Model\PostSuccess'; - $request = $this->createContactRequest($data); - - try { - - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\PostSuccess', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 422: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation createContactAsync - * - * Create contact. - * - * @param \RadioManager\Model\ContactDataInput $data Data **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function createContactAsync($data) - { - return $this->createContactAsyncWithHttpInfo($data)->then(function ($response) { - return $response[0]; - }); - } - - /** - * Operation createContactAsyncWithHttpInfo - * - * Create contact. - * - * @param \RadioManager\Model\ContactDataInput $data Data **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function createContactAsyncWithHttpInfo($data) - { - $returnType = '\RadioManager\Model\PostSuccess'; - $request = $this->createContactRequest($data); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'createContact' - * - * @param \RadioManager\Model\ContactDataInput $data Data **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - protected function createContactRequest($data) { // verify the required parameter 'data' is set if ($data === null) { throw new \InvalidArgumentException('Missing the required parameter $data when calling createContact'); } - - $resourcePath = '/contacts'; - $formParams = []; + // parse inputs + $resourcePath = "/contacts"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - - + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // body params $_tempBody = null; @@ -265,670 +135,272 @@ protected function createContactRequest($data) $_tempBody = $data; } - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } - // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'POST', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation deleteContactById - * - * Delete contact by id - * - * @param int $id ID of Contact **(Required)** (required) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\Success - */ - public function deleteContactById($id) - { - list($response) = $this->deleteContactByIdWithHttpInfo($id); - return $response; - } - - /** - * Operation deleteContactByIdWithHttpInfo - * - * Delete contact by id - * - * @param int $id ID of Contact **(Required)** (required) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\Success, HTTP status code, HTTP response headers (array of strings) - */ - public function deleteContactByIdWithHttpInfo($id) - { - $returnType = '\RadioManager\Model\Success'; - $request = $this->deleteContactByIdRequest($id); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'POST', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\PostSuccess', + '/contacts' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\PostSuccess', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\PostSuccess', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 422: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation deleteContactByIdAsync + * Operation deleteContactById * * Delete contact by id * * @param int $id ID of Contact **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\Success */ - public function deleteContactByIdAsync($id) + public function deleteContactById($id) { - return $this->deleteContactByIdAsyncWithHttpInfo($id)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->deleteContactByIdWithHttpInfo($id); + return $response; } /** - * Operation deleteContactByIdAsyncWithHttpInfo + * Operation deleteContactByIdWithHttpInfo * * Delete contact by id * * @param int $id ID of Contact **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function deleteContactByIdAsyncWithHttpInfo($id) - { - $returnType = '\RadioManager\Model\Success'; - $request = $this->deleteContactByIdRequest($id); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'deleteContactById' - * - * @param int $id ID of Contact **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\Success, HTTP status code, HTTP response headers (array of strings) */ - protected function deleteContactByIdRequest($id) + public function deleteContactByIdWithHttpInfo($id) { // verify the required parameter 'id' is set if ($id === null) { throw new \InvalidArgumentException('Missing the required parameter $id when calling deleteContactById'); } - if ($id < 0) { + if (($id < 0)) { throw new \InvalidArgumentException('invalid value for "$id" when calling ContactApi.deleteContactById, must be bigger than or equal to 0.'); } - - $resourcePath = '/contacts/{id}'; - $formParams = []; + // parse inputs + $resourcePath = "/contacts/{id}"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // path params if ($id !== null) { - $resourcePath = str_replace('{' . 'id' . '}', ObjectSerializer::toPathValue($id), $resourcePath); - } - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] + $resourcePath = str_replace( + "{" . "id" . "}", + $this->apiClient->getSerializer()->toPathValue($id), + $resourcePath ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; - } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'DELETE', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation getContactById - * - * Get contact by id - * - * @param int $id ID of Contact **(Required)** (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\ContactResult - */ - public function getContactById($id, $_external_station_id = null) - { - list($response) = $this->getContactByIdWithHttpInfo($id, $_external_station_id); - return $response; - } - - /** - * Operation getContactByIdWithHttpInfo - * - * Get contact by id - * - * @param int $id ID of Contact **(Required)** (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\ContactResult, HTTP status code, HTTP response headers (array of strings) - */ - public function getContactByIdWithHttpInfo($id, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\ContactResult'; - $request = $this->getContactByIdRequest($id, $_external_station_id); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'DELETE', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\Success', + '/contacts/{id}' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\Success', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\ContactResult', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation getContactByIdAsync + * Operation getContactById * * Get contact by id * * @param int $id ID of Contact **(Required)** (required) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\ContactResult */ - public function getContactByIdAsync($id, $_external_station_id = null) + public function getContactById($id, $_external_station_id = null) { - return $this->getContactByIdAsyncWithHttpInfo($id, $_external_station_id)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->getContactByIdWithHttpInfo($id, $_external_station_id); + return $response; } /** - * Operation getContactByIdAsyncWithHttpInfo + * Operation getContactByIdWithHttpInfo * * Get contact by id * * @param int $id ID of Contact **(Required)** (required) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getContactByIdAsyncWithHttpInfo($id, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\ContactResult'; - $request = $this->getContactByIdRequest($id, $_external_station_id); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'getContactById' - * - * @param int $id ID of Contact **(Required)** (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\ContactResult, HTTP status code, HTTP response headers (array of strings) */ - protected function getContactByIdRequest($id, $_external_station_id = null) + public function getContactByIdWithHttpInfo($id, $_external_station_id = null) { // verify the required parameter 'id' is set if ($id === null) { throw new \InvalidArgumentException('Missing the required parameter $id when calling getContactById'); } - if ($id < 0) { + if (($id < 0)) { throw new \InvalidArgumentException('invalid value for "$id" when calling ContactApi.getContactById, must be bigger than or equal to 0.'); } - - $resourcePath = '/contacts/{id}'; - $formParams = []; + // parse inputs + $resourcePath = "/contacts/{id}"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // query params if ($_external_station_id !== null) { - $queryParams['_external_station_id'] = ObjectSerializer::toQueryValue($_external_station_id); + $queryParams['_external_station_id'] = $this->apiClient->getSerializer()->toQueryValue($_external_station_id); } - // path params if ($id !== null) { - $resourcePath = str_replace('{' . 'id' . '}', ObjectSerializer::toPathValue($id), $resourcePath); - } - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] + $resourcePath = str_replace( + "{" . "id" . "}", + $this->apiClient->getSerializer()->toPathValue($id), + $resourcePath ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'GET', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation listContacts - * - * Get all contacts. - * - * @param int $page Current page *(Optional)* (optional, default to 1) - * @param int $model_type_id Search on ModelType ID *(Optional)* (optional) - * @param int $tag_id Search on Tag ID *(Optional)* `(Relation)` (optional) - * @param int $item_id Search on Item ID *(Optional)* `(Relation)` (optional) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\ContactResults - */ - public function listContacts($page = '1', $model_type_id = null, $tag_id = null, $item_id = null, $_external_station_id = null) - { - list($response) = $this->listContactsWithHttpInfo($page, $model_type_id, $tag_id, $item_id, $_external_station_id); - return $response; - } - - /** - * Operation listContactsWithHttpInfo - * - * Get all contacts. - * - * @param int $page Current page *(Optional)* (optional, default to 1) - * @param int $model_type_id Search on ModelType ID *(Optional)* (optional) - * @param int $tag_id Search on Tag ID *(Optional)* `(Relation)` (optional) - * @param int $item_id Search on Item ID *(Optional)* `(Relation)` (optional) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\ContactResults, HTTP status code, HTTP response headers (array of strings) - */ - public function listContactsWithHttpInfo($page = '1', $model_type_id = null, $tag_id = null, $item_id = null, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\ContactResults'; - $request = $this->listContactsRequest($page, $model_type_id, $tag_id, $item_id, $_external_station_id); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'GET', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\ContactResult', + '/contacts/{id}' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\ContactResult', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\ContactResults', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\ContactResult', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation listContactsAsync + * Operation listContacts * * Get all contacts. * @@ -937,18 +409,17 @@ public function listContactsWithHttpInfo($page = '1', $model_type_id = null, $ta * @param int $tag_id Search on Tag ID *(Optional)* `(Relation)` (optional) * @param int $item_id Search on Item ID *(Optional)* `(Relation)` (optional) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\ContactResults */ - public function listContactsAsync($page = '1', $model_type_id = null, $tag_id = null, $item_id = null, $_external_station_id = null) + public function listContacts($page = '1', $model_type_id = null, $tag_id = null, $item_id = null, $_external_station_id = null) { - return $this->listContactsAsyncWithHttpInfo($page, $model_type_id, $tag_id, $item_id, $_external_station_id)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->listContactsWithHttpInfo($page, $model_type_id, $tag_id, $item_id, $_external_station_id); + return $response; } /** - * Operation listContactsAsyncWithHttpInfo + * Operation listContactsWithHttpInfo * * Get all contacts. * @@ -957,409 +428,207 @@ public function listContactsAsync($page = '1', $model_type_id = null, $tag_id = * @param int $tag_id Search on Tag ID *(Optional)* `(Relation)` (optional) * @param int $item_id Search on Item ID *(Optional)* `(Relation)` (optional) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function listContactsAsyncWithHttpInfo($page = '1', $model_type_id = null, $tag_id = null, $item_id = null, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\ContactResults'; - $request = $this->listContactsRequest($page, $model_type_id, $tag_id, $item_id, $_external_station_id); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'listContacts' - * - * @param int $page Current page *(Optional)* (optional, default to 1) - * @param int $model_type_id Search on ModelType ID *(Optional)* (optional) - * @param int $tag_id Search on Tag ID *(Optional)* `(Relation)` (optional) - * @param int $item_id Search on Item ID *(Optional)* `(Relation)` (optional) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\ContactResults, HTTP status code, HTTP response headers (array of strings) */ - protected function listContactsRequest($page = '1', $model_type_id = null, $tag_id = null, $item_id = null, $_external_station_id = null) + public function listContactsWithHttpInfo($page = '1', $model_type_id = null, $tag_id = null, $item_id = null, $_external_station_id = null) { - if ($page !== null && $page < 0) { + if (!is_null($page) && ($page < 0)) { throw new \InvalidArgumentException('invalid value for "$page" when calling ContactApi.listContacts, must be bigger than or equal to 0.'); } - - $resourcePath = '/contacts'; - $formParams = []; + // parse inputs + $resourcePath = "/contacts"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // query params if ($page !== null) { - $queryParams['page'] = ObjectSerializer::toQueryValue($page); + $queryParams['page'] = $this->apiClient->getSerializer()->toQueryValue($page); } // query params if ($model_type_id !== null) { - $queryParams['model_type_id'] = ObjectSerializer::toQueryValue($model_type_id); + $queryParams['model_type_id'] = $this->apiClient->getSerializer()->toQueryValue($model_type_id); } // query params if ($tag_id !== null) { - $queryParams['tag_id'] = ObjectSerializer::toQueryValue($tag_id); + $queryParams['tag_id'] = $this->apiClient->getSerializer()->toQueryValue($tag_id); } // query params if ($item_id !== null) { - $queryParams['item_id'] = ObjectSerializer::toQueryValue($item_id); + $queryParams['item_id'] = $this->apiClient->getSerializer()->toQueryValue($item_id); } // query params if ($_external_station_id !== null) { - $queryParams['_external_station_id'] = ObjectSerializer::toQueryValue($_external_station_id); - } - - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); + $queryParams['_external_station_id'] = $this->apiClient->getSerializer()->toQueryValue($_external_station_id); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; - } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'GET', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation updateContactByID - * - * Update contact by id - * - * @param int $id ID of Contact **(Required)** (required) - * @param \RadioManager\Model\ContactDataInput $data Data *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\Success - */ - public function updateContactByID($id, $data = null) - { - list($response) = $this->updateContactByIDWithHttpInfo($id, $data); - return $response; - } - - /** - * Operation updateContactByIDWithHttpInfo - * - * Update contact by id - * - * @param int $id ID of Contact **(Required)** (required) - * @param \RadioManager\Model\ContactDataInput $data Data *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\Success, HTTP status code, HTTP response headers (array of strings) - */ - public function updateContactByIDWithHttpInfo($id, $data = null) - { - $returnType = '\RadioManager\Model\Success'; - $request = $this->updateContactByIDRequest($id, $data); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'GET', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\ContactResults', + '/contacts' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\ContactResults', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\ContactResults', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 422: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation updateContactByIDAsync + * Operation updateContactByID * * Update contact by id * * @param int $id ID of Contact **(Required)** (required) * @param \RadioManager\Model\ContactDataInput $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\Success */ - public function updateContactByIDAsync($id, $data = null) + public function updateContactByID($id, $data = null) { - return $this->updateContactByIDAsyncWithHttpInfo($id, $data)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->updateContactByIDWithHttpInfo($id, $data); + return $response; } /** - * Operation updateContactByIDAsyncWithHttpInfo + * Operation updateContactByIDWithHttpInfo * * Update contact by id * * @param int $id ID of Contact **(Required)** (required) * @param \RadioManager\Model\ContactDataInput $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function updateContactByIDAsyncWithHttpInfo($id, $data = null) - { - $returnType = '\RadioManager\Model\Success'; - $request = $this->updateContactByIDRequest($id, $data); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'updateContactByID' - * - * @param int $id ID of Contact **(Required)** (required) - * @param \RadioManager\Model\ContactDataInput $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\Success, HTTP status code, HTTP response headers (array of strings) */ - protected function updateContactByIDRequest($id, $data = null) + public function updateContactByIDWithHttpInfo($id, $data = null) { // verify the required parameter 'id' is set if ($id === null) { throw new \InvalidArgumentException('Missing the required parameter $id when calling updateContactByID'); } - if ($id < 0) { + if (($id < 0)) { throw new \InvalidArgumentException('invalid value for "$id" when calling ContactApi.updateContactByID, must be bigger than or equal to 0.'); } - - $resourcePath = '/contacts/{id}'; - $formParams = []; + // parse inputs + $resourcePath = "/contacts/{id}"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // path params if ($id !== null) { - $resourcePath = str_replace('{' . 'id' . '}', ObjectSerializer::toPathValue($id), $resourcePath); + $resourcePath = str_replace( + "{" . "id" . "}", + $this->apiClient->getSerializer()->toPathValue($id), + $resourcePath + ); } - // body params $_tempBody = null; if (isset($data)) { $_tempBody = $data; } - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } - // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'PATCH', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\Success', + '/contacts/{id}' + ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\Success', $httpHeader), $statusCode, $httpHeader]; + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 403: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 404: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 422: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 429: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + } - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + throw $e; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'PATCH', - $url, - $headers, - $httpBody - ); } - } diff --git a/lib/Api/ExternalMessageApi.php b/lib/Api/ExternalMessageApi.php index e288ed7..70632a1 100644 --- a/lib/Api/ExternalMessageApi.php +++ b/lib/Api/ExternalMessageApi.php @@ -28,15 +28,10 @@ namespace RadioManager\Api; -use GuzzleHttp\Client; -use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\Psr7\MultipartStream; -use GuzzleHttp\Psr7\Request; -use RadioManager\ApiException; -use RadioManager\Configuration; -use RadioManager\HeaderSelector; -use RadioManager\ObjectSerializer; +use \RadioManager\ApiClient; +use \RadioManager\ApiException; +use \RadioManager\Configuration; +use \RadioManager\ObjectSerializer; /** * ExternalMessageApi Class Doc Comment @@ -49,36 +44,47 @@ class ExternalMessageApi { /** - * @var ClientInterface + * API Client + * + * @var \RadioManager\ApiClient instance of the ApiClient */ - protected $client; + protected $apiClient; /** - * @var Configuration + * Constructor + * + * @param \RadioManager\ApiClient|null $apiClient The api client to use */ - protected $config; + public function __construct(\RadioManager\ApiClient $apiClient = null) + { + if ($apiClient === null) { + $apiClient = new ApiClient(); + } + + $this->apiClient = $apiClient; + } /** - * @param ClientInterface $client - * @param Configuration $config - * @param HeaderSelector $selector + * Get API client + * + * @return \RadioManager\ApiClient get the API client */ - public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null - ) { - $this->client = $client ?: new Client(); - $this->config = $config ?: new Configuration(); - $this->headerSelector = $selector ?: new HeaderSelector(); + public function getApiClient() + { + return $this->apiClient; } /** - * @return Configuration + * Set the API client + * + * @param \RadioManager\ApiClient $apiClient set the API client + * + * @return ExternalMessageApi */ - public function getConfig() + public function setApiClient(\RadioManager\ApiClient $apiClient) { - return $this->config; + $this->apiClient = $apiClient; + return $this; } /** @@ -88,7 +94,6 @@ public function getConfig() * * @param \RadioManager\Model\ExternalMessageQueueData $message Data **(Required)** (required) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return object */ public function queueExternalMessage($message) @@ -104,156 +109,25 @@ public function queueExternalMessage($message) * * @param \RadioManager\Model\ExternalMessageQueueData $message Data **(Required)** (required) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return array of object, HTTP status code, HTTP response headers (array of strings) */ public function queueExternalMessageWithHttpInfo($message) - { - $returnType = 'object'; - $request = $this->queueExternalMessageRequest($message); - - try { - - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), 'object', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 422: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation queueExternalMessageAsync - * - * Queue External Message. - * - * @param \RadioManager\Model\ExternalMessageQueueData $message Data **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function queueExternalMessageAsync($message) - { - return $this->queueExternalMessageAsyncWithHttpInfo($message)->then(function ($response) { - return $response[0]; - }); - } - - /** - * Operation queueExternalMessageAsyncWithHttpInfo - * - * Queue External Message. - * - * @param \RadioManager\Model\ExternalMessageQueueData $message Data **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function queueExternalMessageAsyncWithHttpInfo($message) - { - $returnType = 'object'; - $request = $this->queueExternalMessageRequest($message); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'queueExternalMessage' - * - * @param \RadioManager\Model\ExternalMessageQueueData $message Data **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - protected function queueExternalMessageRequest($message) { // verify the required parameter 'message' is set if ($message === null) { throw new \InvalidArgumentException('Missing the required parameter $message when calling queueExternalMessage'); } - - $resourcePath = '/externalmessagequeue'; - $formParams = []; + // parse inputs + $resourcePath = "/externalmessagequeue"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - - + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // body params $_tempBody = null; @@ -261,66 +135,51 @@ protected function queueExternalMessageRequest($message) $_tempBody = $message; } - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } - // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'POST', + $queryParams, + $httpBody, + $headerParams, + 'object', + '/externalmessagequeue' + ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); + return [$this->apiClient->getSerializer()->deserialize($response, 'object', $httpHeader), $statusCode, $httpHeader]; + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), 'object', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 403: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 422: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 429: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + } - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + throw $e; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'POST', - $url, - $headers, - $httpBody - ); } - } diff --git a/lib/Api/GenreApi.php b/lib/Api/GenreApi.php index 0e41cc1..e1d361f 100644 --- a/lib/Api/GenreApi.php +++ b/lib/Api/GenreApi.php @@ -28,15 +28,10 @@ namespace RadioManager\Api; -use GuzzleHttp\Client; -use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\Psr7\MultipartStream; -use GuzzleHttp\Psr7\Request; -use RadioManager\ApiException; -use RadioManager\Configuration; -use RadioManager\HeaderSelector; -use RadioManager\ObjectSerializer; +use \RadioManager\ApiClient; +use \RadioManager\ApiException; +use \RadioManager\Configuration; +use \RadioManager\ObjectSerializer; /** * GenreApi Class Doc Comment @@ -49,36 +44,47 @@ class GenreApi { /** - * @var ClientInterface + * API Client + * + * @var \RadioManager\ApiClient instance of the ApiClient */ - protected $client; + protected $apiClient; /** - * @var Configuration + * Constructor + * + * @param \RadioManager\ApiClient|null $apiClient The api client to use */ - protected $config; + public function __construct(\RadioManager\ApiClient $apiClient = null) + { + if ($apiClient === null) { + $apiClient = new ApiClient(); + } + + $this->apiClient = $apiClient; + } /** - * @param ClientInterface $client - * @param Configuration $config - * @param HeaderSelector $selector + * Get API client + * + * @return \RadioManager\ApiClient get the API client */ - public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null - ) { - $this->client = $client ?: new Client(); - $this->config = $config ?: new Configuration(); - $this->headerSelector = $selector ?: new HeaderSelector(); + public function getApiClient() + { + return $this->apiClient; } /** - * @return Configuration + * Set the API client + * + * @param \RadioManager\ApiClient $apiClient set the API client + * + * @return GenreApi */ - public function getConfig() + public function setApiClient(\RadioManager\ApiClient $apiClient) { - return $this->config; + $this->apiClient = $apiClient; + return $this; } /** @@ -89,7 +95,6 @@ public function getConfig() * @param int $id ID of Genre **(Required)** (required) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return \RadioManager\Model\GenreResult */ public function getGenreById($id, $_external_station_id = null) @@ -106,338 +111,93 @@ public function getGenreById($id, $_external_station_id = null) * @param int $id ID of Genre **(Required)** (required) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return array of \RadioManager\Model\GenreResult, HTTP status code, HTTP response headers (array of strings) */ public function getGenreByIdWithHttpInfo($id, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\GenreResult'; - $request = $this->getGenreByIdRequest($id, $_external_station_id); - - try { - - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\GenreResult', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation getGenreByIdAsync - * - * Get genre by id - * - * @param int $id ID of Genre **(Required)** (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getGenreByIdAsync($id, $_external_station_id = null) - { - return $this->getGenreByIdAsyncWithHttpInfo($id, $_external_station_id)->then(function ($response) { - return $response[0]; - }); - } - - /** - * Operation getGenreByIdAsyncWithHttpInfo - * - * Get genre by id - * - * @param int $id ID of Genre **(Required)** (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getGenreByIdAsyncWithHttpInfo($id, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\GenreResult'; - $request = $this->getGenreByIdRequest($id, $_external_station_id); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'getGenreById' - * - * @param int $id ID of Genre **(Required)** (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - protected function getGenreByIdRequest($id, $_external_station_id = null) { // verify the required parameter 'id' is set if ($id === null) { throw new \InvalidArgumentException('Missing the required parameter $id when calling getGenreById'); } - if ($id < 0) { + if (($id < 0)) { throw new \InvalidArgumentException('invalid value for "$id" when calling GenreApi.getGenreById, must be bigger than or equal to 0.'); } - - $resourcePath = '/genres/{id}'; - $formParams = []; + // parse inputs + $resourcePath = "/genres/{id}"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // query params if ($_external_station_id !== null) { - $queryParams['_external_station_id'] = ObjectSerializer::toQueryValue($_external_station_id); + $queryParams['_external_station_id'] = $this->apiClient->getSerializer()->toQueryValue($_external_station_id); } - // path params if ($id !== null) { - $resourcePath = str_replace('{' . 'id' . '}', ObjectSerializer::toPathValue($id), $resourcePath); - } - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] + $resourcePath = str_replace( + "{" . "id" . "}", + $this->apiClient->getSerializer()->toPathValue($id), + $resourcePath ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; - } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'GET', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation listGenres - * - * List all genres. - * - * @param int $page Current page *(Optional)* (optional) - * @param int $parent_id Search on Parent ID of Genre *(Optional)* (optional) - * @param int $program_id Search on Program ID *(Optional)* `(Relation)` (optional) - * @param int $broadcast_id Search on Broadcast ID *(Optional)* `(Relation)` (optional) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\GenreResults - */ - public function listGenres($page = null, $parent_id = null, $program_id = null, $broadcast_id = null, $_external_station_id = null) - { - list($response) = $this->listGenresWithHttpInfo($page, $parent_id, $program_id, $broadcast_id, $_external_station_id); - return $response; - } - - /** - * Operation listGenresWithHttpInfo - * - * List all genres. - * - * @param int $page Current page *(Optional)* (optional) - * @param int $parent_id Search on Parent ID of Genre *(Optional)* (optional) - * @param int $program_id Search on Program ID *(Optional)* `(Relation)` (optional) - * @param int $broadcast_id Search on Broadcast ID *(Optional)* `(Relation)` (optional) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\GenreResults, HTTP status code, HTTP response headers (array of strings) - */ - public function listGenresWithHttpInfo($page = null, $parent_id = null, $program_id = null, $broadcast_id = null, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\GenreResults'; - $request = $this->listGenresRequest($page, $parent_id, $program_id, $broadcast_id, $_external_station_id); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'GET', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\GenreResult', + '/genres/{id}' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\GenreResult', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\GenreResults', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\GenreResult', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation listGenresAsync + * Operation listGenres * * List all genres. * @@ -446,18 +206,17 @@ public function listGenresWithHttpInfo($page = null, $parent_id = null, $program * @param int $program_id Search on Program ID *(Optional)* `(Relation)` (optional) * @param int $broadcast_id Search on Broadcast ID *(Optional)* `(Relation)` (optional) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\GenreResults */ - public function listGenresAsync($page = null, $parent_id = null, $program_id = null, $broadcast_id = null, $_external_station_id = null) + public function listGenres($page = null, $parent_id = null, $program_id = null, $broadcast_id = null, $_external_station_id = null) { - return $this->listGenresAsyncWithHttpInfo($page, $parent_id, $program_id, $broadcast_id, $_external_station_id)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->listGenresWithHttpInfo($page, $parent_id, $program_id, $broadcast_id, $_external_station_id); + return $response; } /** - * Operation listGenresAsyncWithHttpInfo + * Operation listGenresWithHttpInfo * * List all genres. * @@ -466,150 +225,93 @@ public function listGenresAsync($page = null, $parent_id = null, $program_id = n * @param int $program_id Search on Program ID *(Optional)* `(Relation)` (optional) * @param int $broadcast_id Search on Broadcast ID *(Optional)* `(Relation)` (optional) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function listGenresAsyncWithHttpInfo($page = null, $parent_id = null, $program_id = null, $broadcast_id = null, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\GenreResults'; - $request = $this->listGenresRequest($page, $parent_id, $program_id, $broadcast_id, $_external_station_id); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'listGenres' - * - * @param int $page Current page *(Optional)* (optional) - * @param int $parent_id Search on Parent ID of Genre *(Optional)* (optional) - * @param int $program_id Search on Program ID *(Optional)* `(Relation)` (optional) - * @param int $broadcast_id Search on Broadcast ID *(Optional)* `(Relation)` (optional) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\GenreResults, HTTP status code, HTTP response headers (array of strings) */ - protected function listGenresRequest($page = null, $parent_id = null, $program_id = null, $broadcast_id = null, $_external_station_id = null) + public function listGenresWithHttpInfo($page = null, $parent_id = null, $program_id = null, $broadcast_id = null, $_external_station_id = null) { - if ($page !== null && $page < 0) { + if (!is_null($page) && ($page < 0)) { throw new \InvalidArgumentException('invalid value for "$page" when calling GenreApi.listGenres, must be bigger than or equal to 0.'); } - - $resourcePath = '/genres'; - $formParams = []; + // parse inputs + $resourcePath = "/genres"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // query params if ($page !== null) { - $queryParams['page'] = ObjectSerializer::toQueryValue($page); + $queryParams['page'] = $this->apiClient->getSerializer()->toQueryValue($page); } // query params if ($parent_id !== null) { - $queryParams['parent_id'] = ObjectSerializer::toQueryValue($parent_id); + $queryParams['parent_id'] = $this->apiClient->getSerializer()->toQueryValue($parent_id); } // query params if ($program_id !== null) { - $queryParams['program_id'] = ObjectSerializer::toQueryValue($program_id); + $queryParams['program_id'] = $this->apiClient->getSerializer()->toQueryValue($program_id); } // query params if ($broadcast_id !== null) { - $queryParams['broadcast_id'] = ObjectSerializer::toQueryValue($broadcast_id); + $queryParams['broadcast_id'] = $this->apiClient->getSerializer()->toQueryValue($broadcast_id); } // query params if ($_external_station_id !== null) { - $queryParams['_external_station_id'] = ObjectSerializer::toQueryValue($_external_station_id); - } - - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); + $queryParams['_external_station_id'] = $this->apiClient->getSerializer()->toQueryValue($_external_station_id); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'GET', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\GenreResults', + '/genres' + ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\GenreResults', $httpHeader), $statusCode, $httpHeader]; + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\GenreResults', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 403: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 404: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 429: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + } - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + throw $e; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'GET', - $url, - $headers, - $httpBody - ); } - } diff --git a/lib/Api/ItemApi.php b/lib/Api/ItemApi.php index dd0778e..2314a35 100644 --- a/lib/Api/ItemApi.php +++ b/lib/Api/ItemApi.php @@ -28,15 +28,10 @@ namespace RadioManager\Api; -use GuzzleHttp\Client; -use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\Psr7\MultipartStream; -use GuzzleHttp\Psr7\Request; -use RadioManager\ApiException; -use RadioManager\Configuration; -use RadioManager\HeaderSelector; -use RadioManager\ObjectSerializer; +use \RadioManager\ApiClient; +use \RadioManager\ApiException; +use \RadioManager\Configuration; +use \RadioManager\ObjectSerializer; /** * ItemApi Class Doc Comment @@ -49,36 +44,47 @@ class ItemApi { /** - * @var ClientInterface + * API Client + * + * @var \RadioManager\ApiClient instance of the ApiClient */ - protected $client; + protected $apiClient; /** - * @var Configuration + * Constructor + * + * @param \RadioManager\ApiClient|null $apiClient The api client to use */ - protected $config; + public function __construct(\RadioManager\ApiClient $apiClient = null) + { + if ($apiClient === null) { + $apiClient = new ApiClient(); + } + + $this->apiClient = $apiClient; + } /** - * @param ClientInterface $client - * @param Configuration $config - * @param HeaderSelector $selector + * Get API client + * + * @return \RadioManager\ApiClient get the API client */ - public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null - ) { - $this->client = $client ?: new Client(); - $this->config = $config ?: new Configuration(); - $this->headerSelector = $selector ?: new HeaderSelector(); + public function getApiClient() + { + return $this->apiClient; } /** - * @return Configuration + * Set the API client + * + * @param \RadioManager\ApiClient $apiClient set the API client + * + * @return ItemApi */ - public function getConfig() + public function setApiClient(\RadioManager\ApiClient $apiClient) { - return $this->config; + $this->apiClient = $apiClient; + return $this; } /** @@ -88,7 +94,6 @@ public function getConfig() * * @param \RadioManager\Model\ItemDataInput $data Data *(Optional)* (optional) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return \RadioManager\Model\PostSuccess */ public function createItem($data = null) @@ -104,148 +109,21 @@ public function createItem($data = null) * * @param \RadioManager\Model\ItemDataInput $data Data *(Optional)* (optional) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return array of \RadioManager\Model\PostSuccess, HTTP status code, HTTP response headers (array of strings) */ public function createItemWithHttpInfo($data = null) { - $returnType = '\RadioManager\Model\PostSuccess'; - $request = $this->createItemRequest($data); - - try { - - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\PostSuccess', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 422: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation createItemAsync - * - * Create an new item. - * - * @param \RadioManager\Model\ItemDataInput $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function createItemAsync($data = null) - { - return $this->createItemAsyncWithHttpInfo($data)->then(function ($response) { - return $response[0]; - }); - } - - /** - * Operation createItemAsyncWithHttpInfo - * - * Create an new item. - * - * @param \RadioManager\Model\ItemDataInput $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function createItemAsyncWithHttpInfo($data = null) - { - $returnType = '\RadioManager\Model\PostSuccess'; - $request = $this->createItemRequest($data); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'createItem' - * - * @param \RadioManager\Model\ItemDataInput $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - protected function createItemRequest($data = null) - { - - $resourcePath = '/items'; - $formParams = []; + // parse inputs + $resourcePath = "/items"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - - + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // body params $_tempBody = null; @@ -253,66 +131,48 @@ protected function createItemRequest($data = null) $_tempBody = $data; } - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } - // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'POST', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\PostSuccess', + '/items' + ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\PostSuccess', $httpHeader), $statusCode, $httpHeader]; + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\PostSuccess', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 422: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 429: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + } - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + throw $e; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'POST', - $url, - $headers, - $httpBody - ); } /** @@ -322,7 +182,6 @@ protected function createItemRequest($data = null) * * @param \RadioManager\Model\ImportItem $data Data *(Optional)* (optional) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return \RadioManager\Model\Success */ public function currentItemPostStructure($data = null) @@ -338,152 +197,113 @@ public function currentItemPostStructure($data = null) * * @param \RadioManager\Model\ImportItem $data Data *(Optional)* (optional) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return array of \RadioManager\Model\Success, HTTP status code, HTTP response headers (array of strings) */ public function currentItemPostStructureWithHttpInfo($data = null) { - $returnType = '\RadioManager\Model\Success'; - $request = $this->currentItemPostStructureRequest($data); - - try { - - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } + // parse inputs + $resourcePath = "/items/current/structure"; + $httpBody = ''; + $queryParams = []; + $headerParams = []; + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); - $responseBody = $response->getBody(); - if ($returnType === '\SplFileObject') { - $content = $responseBody; //stream goes to serializer - } else { - $content = $responseBody->getContents(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } + // body params + $_tempBody = null; + if (isset($data)) { + $_tempBody = $data; + } - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } elseif (count($formParams) > 0) { + $httpBody = $formParams; // for HTTP post (form) + } + // this endpoint requires API key authentication + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; + } + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'POST', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\Success', + '/items/current/structure' + ); + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\Success', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 422: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation currentItemPostStructureAsync + * Operation currentItemPostTiming * - * Post a current playing item, keep structure + * Post a current playing item * * @param \RadioManager\Model\ImportItem $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\Success */ - public function currentItemPostStructureAsync($data = null) + public function currentItemPostTiming($data = null) { - return $this->currentItemPostStructureAsyncWithHttpInfo($data)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->currentItemPostTimingWithHttpInfo($data); + return $response; } /** - * Operation currentItemPostStructureAsyncWithHttpInfo - * - * Post a current playing item, keep structure + * Operation currentItemPostTimingWithHttpInfo * - * @param \RadioManager\Model\ImportItem $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function currentItemPostStructureAsyncWithHttpInfo($data = null) - { - $returnType = '\RadioManager\Model\Success'; - $request = $this->currentItemPostStructureRequest($data); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'currentItemPostStructure' + * Post a current playing item * * @param \RadioManager\Model\ImportItem $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\Success, HTTP status code, HTTP response headers (array of strings) */ - protected function currentItemPostStructureRequest($data = null) + public function currentItemPostTimingWithHttpInfo($data = null) { - - $resourcePath = '/items/current/structure'; - $formParams = []; + // parse inputs + $resourcePath = "/items/current/timing"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - - + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // body params $_tempBody = null; @@ -491,799 +311,260 @@ protected function currentItemPostStructureRequest($data = null) $_tempBody = $data; } - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } - // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'POST', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\Success', + '/items/current/timing' + ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\Success', $httpHeader), $statusCode, $httpHeader]; + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 403: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 422: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 429: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + } - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + throw $e; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'POST', - $url, - $headers, - $httpBody - ); } /** - * Operation currentItemPostTiming + * Operation deleteItemById * - * Post a current playing item + * Delete item by ID. * - * @param \RadioManager\Model\ImportItem $data Data *(Optional)* (optional) + * @param int $id ID of Item **(Required)** (required) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return \RadioManager\Model\Success */ - public function currentItemPostTiming($data = null) + public function deleteItemById($id) { - list($response) = $this->currentItemPostTimingWithHttpInfo($data); + list($response) = $this->deleteItemByIdWithHttpInfo($id); return $response; } /** - * Operation currentItemPostTimingWithHttpInfo + * Operation deleteItemByIdWithHttpInfo * - * Post a current playing item + * Delete item by ID. * - * @param \RadioManager\Model\ImportItem $data Data *(Optional)* (optional) + * @param int $id ID of Item **(Required)** (required) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return array of \RadioManager\Model\Success, HTTP status code, HTTP response headers (array of strings) */ - public function currentItemPostTimingWithHttpInfo($data = null) + public function deleteItemByIdWithHttpInfo($id) { - $returnType = '\RadioManager\Model\Success'; - $request = $this->currentItemPostTimingRequest($data); - - try { - - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); + // verify the required parameter 'id' is set + if ($id === null) { + throw new \InvalidArgumentException('Missing the required parameter $id when calling deleteItemById'); + } + if (($id < 0)) { + throw new \InvalidArgumentException('invalid value for "$id" when calling ItemApi.deleteItemById, must be bigger than or equal to 0.'); + } - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } + // parse inputs + $resourcePath = "/items/{id}"; + $httpBody = ''; + $queryParams = []; + $headerParams = []; + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); - $responseBody = $response->getBody(); - if ($returnType === '\SplFileObject') { - $content = $responseBody; //stream goes to serializer - } else { - $content = $responseBody->getContents(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } + // path params + if ($id !== null) { + $resourcePath = str_replace( + "{" . "id" . "}", + $this->apiClient->getSerializer()->toPathValue($id), + $resourcePath + ); + } - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } elseif (count($formParams) > 0) { + $httpBody = $formParams; // for HTTP post (form) + } + // this endpoint requires API key authentication + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; + } + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'DELETE', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\Success', + '/items/{id}' + ); + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\Success', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); + case 202: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 422: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; - case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + case 404: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation currentItemPostTimingAsync + * Operation getItemById * - * Post a current playing item + * Get extended item details by ID. * - * @param \RadioManager\Model\ImportItem $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @param int $id ID of Item **(Required)** (required) + * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\ItemResult */ - public function currentItemPostTimingAsync($data = null) + public function getItemById($id, $_external_station_id = null) { - return $this->currentItemPostTimingAsyncWithHttpInfo($data)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->getItemByIdWithHttpInfo($id, $_external_station_id); + return $response; } /** - * Operation currentItemPostTimingAsyncWithHttpInfo + * Operation getItemByIdWithHttpInfo * - * Post a current playing item - * - * @param \RadioManager\Model\ImportItem $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function currentItemPostTimingAsyncWithHttpInfo($data = null) - { - $returnType = '\RadioManager\Model\Success'; - $request = $this->currentItemPostTimingRequest($data); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'currentItemPostTiming' - * - * @param \RadioManager\Model\ImportItem $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - protected function currentItemPostTimingRequest($data = null) - { - - $resourcePath = '/items/current/timing'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - // body params - $_tempBody = null; - if (isset($data)) { - $_tempBody = $data; - } - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } - - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } - } - - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; - } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'POST', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation deleteItemById - * - * Delete item by ID. - * - * @param int $id ID of Item **(Required)** (required) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\Success - */ - public function deleteItemById($id) - { - list($response) = $this->deleteItemByIdWithHttpInfo($id); - return $response; - } - - /** - * Operation deleteItemByIdWithHttpInfo - * - * Delete item by ID. + * Get extended item details by ID. * * @param int $id ID of Item **(Required)** (required) + * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\Success, HTTP status code, HTTP response headers (array of strings) - */ - public function deleteItemByIdWithHttpInfo($id) - { - $returnType = '\RadioManager\Model\Success'; - $request = $this->deleteItemByIdRequest($id); - - try { - - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 202: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation deleteItemByIdAsync - * - * Delete item by ID. - * - * @param int $id ID of Item **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function deleteItemByIdAsync($id) - { - return $this->deleteItemByIdAsyncWithHttpInfo($id)->then(function ($response) { - return $response[0]; - }); - } - - /** - * Operation deleteItemByIdAsyncWithHttpInfo - * - * Delete item by ID. - * - * @param int $id ID of Item **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function deleteItemByIdAsyncWithHttpInfo($id) - { - $returnType = '\RadioManager\Model\Success'; - $request = $this->deleteItemByIdRequest($id); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'deleteItemById' - * - * @param int $id ID of Item **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @return array of \RadioManager\Model\ItemResult, HTTP status code, HTTP response headers (array of strings) */ - protected function deleteItemByIdRequest($id) + public function getItemByIdWithHttpInfo($id, $_external_station_id = null) { // verify the required parameter 'id' is set if ($id === null) { - throw new \InvalidArgumentException('Missing the required parameter $id when calling deleteItemById'); + throw new \InvalidArgumentException('Missing the required parameter $id when calling getItemById'); } - if ($id < 0) { - throw new \InvalidArgumentException('invalid value for "$id" when calling ItemApi.deleteItemById, must be bigger than or equal to 0.'); + if (($id < 0)) { + throw new \InvalidArgumentException('invalid value for "$id" when calling ItemApi.getItemById, must be bigger than or equal to 0.'); } - - $resourcePath = '/items/{id}'; - $formParams = []; + // parse inputs + $resourcePath = "/items/{id}"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); + // query params + if ($_external_station_id !== null) { + $queryParams['_external_station_id'] = $this->apiClient->getSerializer()->toQueryValue($_external_station_id); + } // path params if ($id !== null) { - $resourcePath = str_replace('{' . 'id' . '}', ObjectSerializer::toPathValue($id), $resourcePath); - } - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] + $resourcePath = str_replace( + "{" . "id" . "}", + $this->apiClient->getSerializer()->toPathValue($id), + $resourcePath ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; - } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'DELETE', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation getItemById - * - * Get extended item details by ID. - * - * @param int $id ID of Item **(Required)** (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\ItemResult - */ - public function getItemById($id, $_external_station_id = null) - { - list($response) = $this->getItemByIdWithHttpInfo($id, $_external_station_id); - return $response; - } - - /** - * Operation getItemByIdWithHttpInfo - * - * Get extended item details by ID. - * - * @param int $id ID of Item **(Required)** (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\ItemResult, HTTP status code, HTTP response headers (array of strings) - */ - public function getItemByIdWithHttpInfo($id, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\ItemResult'; - $request = $this->getItemByIdRequest($id, $_external_station_id); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'GET', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\ItemResult', + '/items/{id}' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\ItemResult', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\ItemResult', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\ItemResult', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } - throw $e; - } - } - - /** - * Operation getItemByIdAsync - * - * Get extended item details by ID. - * - * @param int $id ID of Item **(Required)** (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getItemByIdAsync($id, $_external_station_id = null) - { - return $this->getItemByIdAsyncWithHttpInfo($id, $_external_station_id)->then(function ($response) { - return $response[0]; - }); - } - - /** - * Operation getItemByIdAsyncWithHttpInfo - * - * Get extended item details by ID. - * - * @param int $id ID of Item **(Required)** (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getItemByIdAsyncWithHttpInfo($id, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\ItemResult'; - $request = $this->getItemByIdRequest($id, $_external_station_id); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - /** - * Create request for operation 'getItemById' - * - * @param int $id ID of Item **(Required)** (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - protected function getItemByIdRequest($id, $_external_station_id = null) - { - // verify the required parameter 'id' is set - if ($id === null) { - throw new \InvalidArgumentException('Missing the required parameter $id when calling getItemById'); - } - if ($id < 0) { - throw new \InvalidArgumentException('invalid value for "$id" when calling ItemApi.getItemById, must be bigger than or equal to 0.'); - } - - - $resourcePath = '/items/{id}'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - // query params - if ($_external_station_id !== null) { - $queryParams['_external_station_id'] = ObjectSerializer::toQueryValue($_external_station_id); - } - - // path params - if ($id !== null) { - $resourcePath = str_replace('{' . 'id' . '}', ObjectSerializer::toPathValue($id), $resourcePath); - } - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } - - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } - } - - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; - } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + throw $e; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'GET', - $url, - $headers, - $httpBody - ); } /** @@ -1311,7 +592,6 @@ protected function getItemByIdRequest($id, $_external_station_id = null) * @param int $tag_id Search on Tag ID *(Optional)* `(Relation)` (optional) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return \RadioManager\Model\ItemResults */ public function listItems($page = null, $order_by = null, $order_direction = null, $start_min = null, $start_max = null, $duration_min = null, $duration_max = null, $status = null, $model_type_id = null, $program_draft_id = null, $user_draft_id = null, $station_draft_id = null, $block_id = null, $broadcast_id = null, $campaign_id = null, $contact_id = null, $program_id = null, $tag_id = null, $_external_station_id = null) @@ -1345,519 +625,192 @@ public function listItems($page = null, $order_by = null, $order_direction = nul * @param int $tag_id Search on Tag ID *(Optional)* `(Relation)` (optional) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return array of \RadioManager\Model\ItemResults, HTTP status code, HTTP response headers (array of strings) */ public function listItemsWithHttpInfo($page = null, $order_by = null, $order_direction = null, $start_min = null, $start_max = null, $duration_min = null, $duration_max = null, $status = null, $model_type_id = null, $program_draft_id = null, $user_draft_id = null, $station_draft_id = null, $block_id = null, $broadcast_id = null, $campaign_id = null, $contact_id = null, $program_id = null, $tag_id = null, $_external_station_id = null) { - $returnType = '\RadioManager\Model\ItemResults'; - $request = $this->listItemsRequest($page, $order_by, $order_direction, $start_min, $start_max, $duration_min, $duration_max, $status, $model_type_id, $program_draft_id, $user_draft_id, $station_draft_id, $block_id, $broadcast_id, $campaign_id, $contact_id, $program_id, $tag_id, $_external_station_id); - - try { - - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\ItemResults', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 422: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation listItemsAsync - * - * Get a list of all the items currently in your station. - * - * @param int $page Current page *(Optional)* (optional) - * @param string $order_by Field to order the results *(Optional)* (optional) - * @param string $order_direction Direction of ordering *(Optional)* (optional) - * @param \DateTime $start_min Minimum start date *(Optional)* (optional) - * @param \DateTime $start_max Maximum start date *(Optional)* (optional) - * @param int $duration_min Minimum duration (seconds) *(Optional)* (optional) - * @param int $duration_max Maximum duration (seconds) *(Optional)* (optional) - * @param string $status Play Status of item *(Optional)* (optional) - * @param int $model_type_id Search on ModelType ID *(Optional)* (optional) - * @param int $program_draft_id Search on Program Draft ID *(Optional)* (optional) - * @param int $user_draft_id Search on User Draft ID *(Optional)* (optional) - * @param int $station_draft_id Search on Station Draft ID *(Optional)* (optional) - * @param int $block_id Search on Block ID *(Optional)* `(Relation)` (optional) - * @param int $broadcast_id Search on Broadcast ID *(Optional)* `(Relation)` (optional) - * @param int $campaign_id Search on Campaign ID *(Optional)* `(Relation)` (optional) - * @param int $contact_id Search on Contact ID *(Optional)* `(Relation)` (optional) - * @param int $program_id Search on Program ID *(Optional)* `(Relation)` (optional) - * @param int $tag_id Search on Tag ID *(Optional)* `(Relation)` (optional) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function listItemsAsync($page = null, $order_by = null, $order_direction = null, $start_min = null, $start_max = null, $duration_min = null, $duration_max = null, $status = null, $model_type_id = null, $program_draft_id = null, $user_draft_id = null, $station_draft_id = null, $block_id = null, $broadcast_id = null, $campaign_id = null, $contact_id = null, $program_id = null, $tag_id = null, $_external_station_id = null) - { - return $this->listItemsAsyncWithHttpInfo($page, $order_by, $order_direction, $start_min, $start_max, $duration_min, $duration_max, $status, $model_type_id, $program_draft_id, $user_draft_id, $station_draft_id, $block_id, $broadcast_id, $campaign_id, $contact_id, $program_id, $tag_id, $_external_station_id)->then(function ($response) { - return $response[0]; - }); - } - - /** - * Operation listItemsAsyncWithHttpInfo - * - * Get a list of all the items currently in your station. - * - * @param int $page Current page *(Optional)* (optional) - * @param string $order_by Field to order the results *(Optional)* (optional) - * @param string $order_direction Direction of ordering *(Optional)* (optional) - * @param \DateTime $start_min Minimum start date *(Optional)* (optional) - * @param \DateTime $start_max Maximum start date *(Optional)* (optional) - * @param int $duration_min Minimum duration (seconds) *(Optional)* (optional) - * @param int $duration_max Maximum duration (seconds) *(Optional)* (optional) - * @param string $status Play Status of item *(Optional)* (optional) - * @param int $model_type_id Search on ModelType ID *(Optional)* (optional) - * @param int $program_draft_id Search on Program Draft ID *(Optional)* (optional) - * @param int $user_draft_id Search on User Draft ID *(Optional)* (optional) - * @param int $station_draft_id Search on Station Draft ID *(Optional)* (optional) - * @param int $block_id Search on Block ID *(Optional)* `(Relation)` (optional) - * @param int $broadcast_id Search on Broadcast ID *(Optional)* `(Relation)` (optional) - * @param int $campaign_id Search on Campaign ID *(Optional)* `(Relation)` (optional) - * @param int $contact_id Search on Contact ID *(Optional)* `(Relation)` (optional) - * @param int $program_id Search on Program ID *(Optional)* `(Relation)` (optional) - * @param int $tag_id Search on Tag ID *(Optional)* `(Relation)` (optional) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function listItemsAsyncWithHttpInfo($page = null, $order_by = null, $order_direction = null, $start_min = null, $start_max = null, $duration_min = null, $duration_max = null, $status = null, $model_type_id = null, $program_draft_id = null, $user_draft_id = null, $station_draft_id = null, $block_id = null, $broadcast_id = null, $campaign_id = null, $contact_id = null, $program_id = null, $tag_id = null, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\ItemResults'; - $request = $this->listItemsRequest($page, $order_by, $order_direction, $start_min, $start_max, $duration_min, $duration_max, $status, $model_type_id, $program_draft_id, $user_draft_id, $station_draft_id, $block_id, $broadcast_id, $campaign_id, $contact_id, $program_id, $tag_id, $_external_station_id); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'listItems' - * - * @param int $page Current page *(Optional)* (optional) - * @param string $order_by Field to order the results *(Optional)* (optional) - * @param string $order_direction Direction of ordering *(Optional)* (optional) - * @param \DateTime $start_min Minimum start date *(Optional)* (optional) - * @param \DateTime $start_max Maximum start date *(Optional)* (optional) - * @param int $duration_min Minimum duration (seconds) *(Optional)* (optional) - * @param int $duration_max Maximum duration (seconds) *(Optional)* (optional) - * @param string $status Play Status of item *(Optional)* (optional) - * @param int $model_type_id Search on ModelType ID *(Optional)* (optional) - * @param int $program_draft_id Search on Program Draft ID *(Optional)* (optional) - * @param int $user_draft_id Search on User Draft ID *(Optional)* (optional) - * @param int $station_draft_id Search on Station Draft ID *(Optional)* (optional) - * @param int $block_id Search on Block ID *(Optional)* `(Relation)` (optional) - * @param int $broadcast_id Search on Broadcast ID *(Optional)* `(Relation)` (optional) - * @param int $campaign_id Search on Campaign ID *(Optional)* `(Relation)` (optional) - * @param int $contact_id Search on Contact ID *(Optional)* `(Relation)` (optional) - * @param int $program_id Search on Program ID *(Optional)* `(Relation)` (optional) - * @param int $tag_id Search on Tag ID *(Optional)* `(Relation)` (optional) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - protected function listItemsRequest($page = null, $order_by = null, $order_direction = null, $start_min = null, $start_max = null, $duration_min = null, $duration_max = null, $status = null, $model_type_id = null, $program_draft_id = null, $user_draft_id = null, $station_draft_id = null, $block_id = null, $broadcast_id = null, $campaign_id = null, $contact_id = null, $program_id = null, $tag_id = null, $_external_station_id = null) - { - if ($page !== null && $page < 1) { + if (!is_null($page) && ($page < 1)) { throw new \InvalidArgumentException('invalid value for "$page" when calling ItemApi.listItems, must be bigger than or equal to 1.'); } - - $resourcePath = '/items'; - $formParams = []; + // parse inputs + $resourcePath = "/items"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // query params if ($page !== null) { - $queryParams['page'] = ObjectSerializer::toQueryValue($page); + $queryParams['page'] = $this->apiClient->getSerializer()->toQueryValue($page); } // query params if ($order_by !== null) { - $queryParams['order-by'] = ObjectSerializer::toQueryValue($order_by); + $queryParams['order-by'] = $this->apiClient->getSerializer()->toQueryValue($order_by); } // query params if ($order_direction !== null) { - $queryParams['order-direction'] = ObjectSerializer::toQueryValue($order_direction); + $queryParams['order-direction'] = $this->apiClient->getSerializer()->toQueryValue($order_direction); } // query params if ($start_min !== null) { - $queryParams['start-min'] = ObjectSerializer::toQueryValue($start_min); + $queryParams['start-min'] = $this->apiClient->getSerializer()->toQueryValue($start_min); } // query params if ($start_max !== null) { - $queryParams['start-max'] = ObjectSerializer::toQueryValue($start_max); + $queryParams['start-max'] = $this->apiClient->getSerializer()->toQueryValue($start_max); } // query params if ($duration_min !== null) { - $queryParams['duration-min'] = ObjectSerializer::toQueryValue($duration_min); + $queryParams['duration-min'] = $this->apiClient->getSerializer()->toQueryValue($duration_min); } // query params if ($duration_max !== null) { - $queryParams['duration-max'] = ObjectSerializer::toQueryValue($duration_max); + $queryParams['duration-max'] = $this->apiClient->getSerializer()->toQueryValue($duration_max); } // query params if ($status !== null) { - $queryParams['status'] = ObjectSerializer::toQueryValue($status); + $queryParams['status'] = $this->apiClient->getSerializer()->toQueryValue($status); } // query params if ($model_type_id !== null) { - $queryParams['model_type_id'] = ObjectSerializer::toQueryValue($model_type_id); + $queryParams['model_type_id'] = $this->apiClient->getSerializer()->toQueryValue($model_type_id); } // query params if ($program_draft_id !== null) { - $queryParams['program_draft_id'] = ObjectSerializer::toQueryValue($program_draft_id); + $queryParams['program_draft_id'] = $this->apiClient->getSerializer()->toQueryValue($program_draft_id); } // query params if ($user_draft_id !== null) { - $queryParams['user_draft_id'] = ObjectSerializer::toQueryValue($user_draft_id); + $queryParams['user_draft_id'] = $this->apiClient->getSerializer()->toQueryValue($user_draft_id); } // query params if ($station_draft_id !== null) { - $queryParams['station_draft_id'] = ObjectSerializer::toQueryValue($station_draft_id); + $queryParams['station_draft_id'] = $this->apiClient->getSerializer()->toQueryValue($station_draft_id); } // query params if ($block_id !== null) { - $queryParams['block_id'] = ObjectSerializer::toQueryValue($block_id); + $queryParams['block_id'] = $this->apiClient->getSerializer()->toQueryValue($block_id); } // query params if ($broadcast_id !== null) { - $queryParams['broadcast_id'] = ObjectSerializer::toQueryValue($broadcast_id); + $queryParams['broadcast_id'] = $this->apiClient->getSerializer()->toQueryValue($broadcast_id); } // query params if ($campaign_id !== null) { - $queryParams['campaign_id'] = ObjectSerializer::toQueryValue($campaign_id); + $queryParams['campaign_id'] = $this->apiClient->getSerializer()->toQueryValue($campaign_id); } // query params if ($contact_id !== null) { - $queryParams['contact_id'] = ObjectSerializer::toQueryValue($contact_id); + $queryParams['contact_id'] = $this->apiClient->getSerializer()->toQueryValue($contact_id); } // query params if ($program_id !== null) { - $queryParams['program_id'] = ObjectSerializer::toQueryValue($program_id); + $queryParams['program_id'] = $this->apiClient->getSerializer()->toQueryValue($program_id); } // query params if ($tag_id !== null) { - $queryParams['tag_id'] = ObjectSerializer::toQueryValue($tag_id); + $queryParams['tag_id'] = $this->apiClient->getSerializer()->toQueryValue($tag_id); } // query params - if ($_external_station_id !== null) { - $queryParams['_external_station_id'] = ObjectSerializer::toQueryValue($_external_station_id); - } - - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } - - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } - } - - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; - } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'GET', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation playlistPostStructure - * - * Post a playlist, keep current structure - * - * @param \RadioManager\Model\Data1 $data Data *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\InlineResponse202 - */ - public function playlistPostStructure($data = null) - { - list($response) = $this->playlistPostStructureWithHttpInfo($data); - return $response; - } - - /** - * Operation playlistPostStructureWithHttpInfo - * - * Post a playlist, keep current structure - * - * @param \RadioManager\Model\Data1 $data Data *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\InlineResponse202, HTTP status code, HTTP response headers (array of strings) - */ - public function playlistPostStructureWithHttpInfo($data = null) - { - $returnType = '\RadioManager\Model\InlineResponse202'; - $request = $this->playlistPostStructureRequest($data); + if ($_external_station_id !== null) { + $queryParams['_external_station_id'] = $this->apiClient->getSerializer()->toQueryValue($_external_station_id); + } + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } elseif (count($formParams) > 0) { + $httpBody = $formParams; // for HTTP post (form) + } + // this endpoint requires API key authentication + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; + } + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'GET', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\ItemResults', + '/items' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\ItemResults', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { - case 202: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\InlineResponse202', $e->getResponseHeaders()); + case 200: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\ItemResults', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 404: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 422: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 429: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation playlistPostStructureAsync + * Operation playlistPostStructure * * Post a playlist, keep current structure * * @param \RadioManager\Model\Data1 $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\InlineResponse202 */ - public function playlistPostStructureAsync($data = null) + public function playlistPostStructure($data = null) { - return $this->playlistPostStructureAsyncWithHttpInfo($data)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->playlistPostStructureWithHttpInfo($data); + return $response; } /** - * Operation playlistPostStructureAsyncWithHttpInfo + * Operation playlistPostStructureWithHttpInfo * * Post a playlist, keep current structure * * @param \RadioManager\Model\Data1 $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function playlistPostStructureAsyncWithHttpInfo($data = null) - { - $returnType = '\RadioManager\Model\InlineResponse202'; - $request = $this->playlistPostStructureRequest($data); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'playlistPostStructure' - * - * @param \RadioManager\Model\Data1 $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\InlineResponse202, HTTP status code, HTTP response headers (array of strings) */ - protected function playlistPostStructureRequest($data = null) + public function playlistPostStructureWithHttpInfo($data = null) { - - $resourcePath = '/items/playlist/structure'; - $formParams = []; + // parse inputs + $resourcePath = "/items/playlist/structure"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - - + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // body params $_tempBody = null; @@ -1865,233 +818,87 @@ protected function playlistPostStructureRequest($data = null) $_tempBody = $data; } - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } - // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; - } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'POST', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation playlistPostTiming - * - * Post a playlist - * - * @param \RadioManager\Model\Data $data Data *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\InlineResponse202 - */ - public function playlistPostTiming($data = null) - { - list($response) = $this->playlistPostTimingWithHttpInfo($data); - return $response; - } - - /** - * Operation playlistPostTimingWithHttpInfo - * - * Post a playlist - * - * @param \RadioManager\Model\Data $data Data *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\InlineResponse202, HTTP status code, HTTP response headers (array of strings) - */ - public function playlistPostTimingWithHttpInfo($data = null) - { - $returnType = '\RadioManager\Model\InlineResponse202'; - $request = $this->playlistPostTimingRequest($data); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'POST', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\InlineResponse202', + '/items/playlist/structure' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\InlineResponse202', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 202: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\InlineResponse202', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\InlineResponse202', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 422: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation playlistPostTimingAsync + * Operation playlistPostTiming * * Post a playlist * * @param \RadioManager\Model\Data $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\InlineResponse202 */ - public function playlistPostTimingAsync($data = null) + public function playlistPostTiming($data = null) { - return $this->playlistPostTimingAsyncWithHttpInfo($data)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->playlistPostTimingWithHttpInfo($data); + return $response; } /** - * Operation playlistPostTimingAsyncWithHttpInfo + * Operation playlistPostTimingWithHttpInfo * * Post a playlist * * @param \RadioManager\Model\Data $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function playlistPostTimingAsyncWithHttpInfo($data = null) - { - $returnType = '\RadioManager\Model\InlineResponse202'; - $request = $this->playlistPostTimingRequest($data); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'playlistPostTiming' - * - * @param \RadioManager\Model\Data $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\InlineResponse202, HTTP status code, HTTP response headers (array of strings) */ - protected function playlistPostTimingRequest($data = null) + public function playlistPostTimingWithHttpInfo($data = null) { - - $resourcePath = '/items/playlist/timing'; - $formParams = []; + // parse inputs + $resourcePath = "/items/playlist/timing"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - - + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // body params $_tempBody = null; @@ -2099,325 +906,161 @@ protected function playlistPostTimingRequest($data = null) $_tempBody = $data; } - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } - // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; - } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'POST', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation updateItemById - * - * Update extended item details by ID. - * - * @param int $id ID of Item **(Required)** (required) - * @param \RadioManager\Model\Item $data Data *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\Success - */ - public function updateItemById($id, $data = null) - { - list($response) = $this->updateItemByIdWithHttpInfo($id, $data); - return $response; - } - - /** - * Operation updateItemByIdWithHttpInfo - * - * Update extended item details by ID. - * - * @param int $id ID of Item **(Required)** (required) - * @param \RadioManager\Model\Item $data Data *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\Success, HTTP status code, HTTP response headers (array of strings) - */ - public function updateItemByIdWithHttpInfo($id, $data = null) - { - $returnType = '\RadioManager\Model\Success'; - $request = $this->updateItemByIdRequest($id, $data); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'POST', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\InlineResponse202', + '/items/playlist/timing' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\InlineResponse202', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); + case 202: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\InlineResponse202', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 422: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation updateItemByIdAsync + * Operation updateItemById * * Update extended item details by ID. * * @param int $id ID of Item **(Required)** (required) * @param \RadioManager\Model\Item $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\Success */ - public function updateItemByIdAsync($id, $data = null) + public function updateItemById($id, $data = null) { - return $this->updateItemByIdAsyncWithHttpInfo($id, $data)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->updateItemByIdWithHttpInfo($id, $data); + return $response; } /** - * Operation updateItemByIdAsyncWithHttpInfo + * Operation updateItemByIdWithHttpInfo * * Update extended item details by ID. * * @param int $id ID of Item **(Required)** (required) * @param \RadioManager\Model\Item $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function updateItemByIdAsyncWithHttpInfo($id, $data = null) - { - $returnType = '\RadioManager\Model\Success'; - $request = $this->updateItemByIdRequest($id, $data); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'updateItemById' - * - * @param int $id ID of Item **(Required)** (required) - * @param \RadioManager\Model\Item $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\Success, HTTP status code, HTTP response headers (array of strings) */ - protected function updateItemByIdRequest($id, $data = null) + public function updateItemByIdWithHttpInfo($id, $data = null) { // verify the required parameter 'id' is set if ($id === null) { throw new \InvalidArgumentException('Missing the required parameter $id when calling updateItemById'); } - if ($id < 0) { + if (($id < 0)) { throw new \InvalidArgumentException('invalid value for "$id" when calling ItemApi.updateItemById, must be bigger than or equal to 0.'); } - - $resourcePath = '/items/{id}'; - $formParams = []; + // parse inputs + $resourcePath = "/items/{id}"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // path params if ($id !== null) { - $resourcePath = str_replace('{' . 'id' . '}', ObjectSerializer::toPathValue($id), $resourcePath); + $resourcePath = str_replace( + "{" . "id" . "}", + $this->apiClient->getSerializer()->toPathValue($id), + $resourcePath + ); } - // body params $_tempBody = null; if (isset($data)) { $_tempBody = $data; } - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } - // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'PATCH', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\Success', + '/items/{id}' + ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\Success', $httpHeader), $statusCode, $httpHeader]; + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 403: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 404: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 422: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 429: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + } - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + throw $e; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'PATCH', - $url, - $headers, - $httpBody - ); } - } diff --git a/lib/Api/ModelTypeApi.php b/lib/Api/ModelTypeApi.php index ad1be9f..3e2733b 100644 --- a/lib/Api/ModelTypeApi.php +++ b/lib/Api/ModelTypeApi.php @@ -28,15 +28,10 @@ namespace RadioManager\Api; -use GuzzleHttp\Client; -use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\Psr7\MultipartStream; -use GuzzleHttp\Psr7\Request; -use RadioManager\ApiException; -use RadioManager\Configuration; -use RadioManager\HeaderSelector; -use RadioManager\ObjectSerializer; +use \RadioManager\ApiClient; +use \RadioManager\ApiException; +use \RadioManager\Configuration; +use \RadioManager\ObjectSerializer; /** * ModelTypeApi Class Doc Comment @@ -49,36 +44,47 @@ class ModelTypeApi { /** - * @var ClientInterface + * API Client + * + * @var \RadioManager\ApiClient instance of the ApiClient */ - protected $client; + protected $apiClient; /** - * @var Configuration + * Constructor + * + * @param \RadioManager\ApiClient|null $apiClient The api client to use */ - protected $config; + public function __construct(\RadioManager\ApiClient $apiClient = null) + { + if ($apiClient === null) { + $apiClient = new ApiClient(); + } + + $this->apiClient = $apiClient; + } /** - * @param ClientInterface $client - * @param Configuration $config - * @param HeaderSelector $selector + * Get API client + * + * @return \RadioManager\ApiClient get the API client */ - public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null - ) { - $this->client = $client ?: new Client(); - $this->config = $config ?: new Configuration(); - $this->headerSelector = $selector ?: new HeaderSelector(); + public function getApiClient() + { + return $this->apiClient; } /** - * @return Configuration + * Set the API client + * + * @param \RadioManager\ApiClient $apiClient set the API client + * + * @return ModelTypeApi */ - public function getConfig() + public function setApiClient(\RadioManager\ApiClient $apiClient) { - return $this->config; + $this->apiClient = $apiClient; + return $this; } /** @@ -89,7 +95,6 @@ public function getConfig() * @param int $id ID of ModelType **(Required)** (required) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return \RadioManager\Model\ModelTypeResult */ public function getModelTypeById($id, $_external_station_id = null) @@ -106,346 +111,93 @@ public function getModelTypeById($id, $_external_station_id = null) * @param int $id ID of ModelType **(Required)** (required) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return array of \RadioManager\Model\ModelTypeResult, HTTP status code, HTTP response headers (array of strings) */ public function getModelTypeByIdWithHttpInfo($id, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\ModelTypeResult'; - $request = $this->getModelTypeByIdRequest($id, $_external_station_id); - - try { - - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\ModelTypeResult', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation getModelTypeByIdAsync - * - * Get modelType by id - * - * @param int $id ID of ModelType **(Required)** (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getModelTypeByIdAsync($id, $_external_station_id = null) - { - return $this->getModelTypeByIdAsyncWithHttpInfo($id, $_external_station_id)->then(function ($response) { - return $response[0]; - }); - } - - /** - * Operation getModelTypeByIdAsyncWithHttpInfo - * - * Get modelType by id - * - * @param int $id ID of ModelType **(Required)** (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getModelTypeByIdAsyncWithHttpInfo($id, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\ModelTypeResult'; - $request = $this->getModelTypeByIdRequest($id, $_external_station_id); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'getModelTypeById' - * - * @param int $id ID of ModelType **(Required)** (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - protected function getModelTypeByIdRequest($id, $_external_station_id = null) { // verify the required parameter 'id' is set if ($id === null) { throw new \InvalidArgumentException('Missing the required parameter $id when calling getModelTypeById'); } - if ($id < 0) { + if (($id < 0)) { throw new \InvalidArgumentException('invalid value for "$id" when calling ModelTypeApi.getModelTypeById, must be bigger than or equal to 0.'); } - - $resourcePath = '/model_types/{id}'; - $formParams = []; + // parse inputs + $resourcePath = "/model_types/{id}"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // query params if ($_external_station_id !== null) { - $queryParams['_external_station_id'] = ObjectSerializer::toQueryValue($_external_station_id); + $queryParams['_external_station_id'] = $this->apiClient->getSerializer()->toQueryValue($_external_station_id); } - // path params if ($id !== null) { - $resourcePath = str_replace('{' . 'id' . '}', ObjectSerializer::toPathValue($id), $resourcePath); - } - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] + $resourcePath = str_replace( + "{" . "id" . "}", + $this->apiClient->getSerializer()->toPathValue($id), + $resourcePath ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'GET', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation listModelTypes - * - * Get all modelTypes. - * - * @param int $page Current page *(Optional)* (optional) - * @param string $model (optional) - * @param int $program_id Search on Program ID *(Optional)* (optional) - * @param int $broadcast_id Search on Broadcast ID *(Optional)* (optional) - * @param int $item_id Search on Item ID *(Optional)* (optional) - * @param int $campaign_id Search on Campaign ID *(Optional)* (optional) - * @param int $presenter_id Search on Presenter ID *(Optional)* (optional) - * @param int $contact_id Search on Contact ID *(Optional)* (optional) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\ModelTypeResults - */ - public function listModelTypes($page = null, $model = null, $program_id = null, $broadcast_id = null, $item_id = null, $campaign_id = null, $presenter_id = null, $contact_id = null, $_external_station_id = null) - { - list($response) = $this->listModelTypesWithHttpInfo($page, $model, $program_id, $broadcast_id, $item_id, $campaign_id, $presenter_id, $contact_id, $_external_station_id); - return $response; - } - - /** - * Operation listModelTypesWithHttpInfo - * - * Get all modelTypes. - * - * @param int $page Current page *(Optional)* (optional) - * @param string $model (optional) - * @param int $program_id Search on Program ID *(Optional)* (optional) - * @param int $broadcast_id Search on Broadcast ID *(Optional)* (optional) - * @param int $item_id Search on Item ID *(Optional)* (optional) - * @param int $campaign_id Search on Campaign ID *(Optional)* (optional) - * @param int $presenter_id Search on Presenter ID *(Optional)* (optional) - * @param int $contact_id Search on Contact ID *(Optional)* (optional) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\ModelTypeResults, HTTP status code, HTTP response headers (array of strings) - */ - public function listModelTypesWithHttpInfo($page = null, $model = null, $program_id = null, $broadcast_id = null, $item_id = null, $campaign_id = null, $presenter_id = null, $contact_id = null, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\ModelTypeResults'; - $request = $this->listModelTypesRequest($page, $model, $program_id, $broadcast_id, $item_id, $campaign_id, $presenter_id, $contact_id, $_external_station_id); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'GET', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\ModelTypeResult', + '/model_types/{id}' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\ModelTypeResult', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\ModelTypeResults', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\ModelTypeResult', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation listModelTypesAsync + * Operation listModelTypes * * Get all modelTypes. * @@ -458,18 +210,17 @@ public function listModelTypesWithHttpInfo($page = null, $model = null, $program * @param int $presenter_id Search on Presenter ID *(Optional)* (optional) * @param int $contact_id Search on Contact ID *(Optional)* (optional) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\ModelTypeResults */ - public function listModelTypesAsync($page = null, $model = null, $program_id = null, $broadcast_id = null, $item_id = null, $campaign_id = null, $presenter_id = null, $contact_id = null, $_external_station_id = null) + public function listModelTypes($page = null, $model = null, $program_id = null, $broadcast_id = null, $item_id = null, $campaign_id = null, $presenter_id = null, $contact_id = null, $_external_station_id = null) { - return $this->listModelTypesAsyncWithHttpInfo($page, $model, $program_id, $broadcast_id, $item_id, $campaign_id, $presenter_id, $contact_id, $_external_station_id)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->listModelTypesWithHttpInfo($page, $model, $program_id, $broadcast_id, $item_id, $campaign_id, $presenter_id, $contact_id, $_external_station_id); + return $response; } /** - * Operation listModelTypesAsyncWithHttpInfo + * Operation listModelTypesWithHttpInfo * * Get all modelTypes. * @@ -482,170 +233,109 @@ public function listModelTypesAsync($page = null, $model = null, $program_id = n * @param int $presenter_id Search on Presenter ID *(Optional)* (optional) * @param int $contact_id Search on Contact ID *(Optional)* (optional) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function listModelTypesAsyncWithHttpInfo($page = null, $model = null, $program_id = null, $broadcast_id = null, $item_id = null, $campaign_id = null, $presenter_id = null, $contact_id = null, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\ModelTypeResults'; - $request = $this->listModelTypesRequest($page, $model, $program_id, $broadcast_id, $item_id, $campaign_id, $presenter_id, $contact_id, $_external_station_id); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'listModelTypes' - * - * @param int $page Current page *(Optional)* (optional) - * @param string $model (optional) - * @param int $program_id Search on Program ID *(Optional)* (optional) - * @param int $broadcast_id Search on Broadcast ID *(Optional)* (optional) - * @param int $item_id Search on Item ID *(Optional)* (optional) - * @param int $campaign_id Search on Campaign ID *(Optional)* (optional) - * @param int $presenter_id Search on Presenter ID *(Optional)* (optional) - * @param int $contact_id Search on Contact ID *(Optional)* (optional) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\ModelTypeResults, HTTP status code, HTTP response headers (array of strings) */ - protected function listModelTypesRequest($page = null, $model = null, $program_id = null, $broadcast_id = null, $item_id = null, $campaign_id = null, $presenter_id = null, $contact_id = null, $_external_station_id = null) + public function listModelTypesWithHttpInfo($page = null, $model = null, $program_id = null, $broadcast_id = null, $item_id = null, $campaign_id = null, $presenter_id = null, $contact_id = null, $_external_station_id = null) { - if ($page !== null && $page < 0) { + if (!is_null($page) && ($page < 0)) { throw new \InvalidArgumentException('invalid value for "$page" when calling ModelTypeApi.listModelTypes, must be bigger than or equal to 0.'); } - - $resourcePath = '/model_types'; - $formParams = []; + // parse inputs + $resourcePath = "/model_types"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // query params if ($page !== null) { - $queryParams['page'] = ObjectSerializer::toQueryValue($page); + $queryParams['page'] = $this->apiClient->getSerializer()->toQueryValue($page); } // query params if ($model !== null) { - $queryParams['model'] = ObjectSerializer::toQueryValue($model); + $queryParams['model'] = $this->apiClient->getSerializer()->toQueryValue($model); } // query params if ($program_id !== null) { - $queryParams['program_id'] = ObjectSerializer::toQueryValue($program_id); + $queryParams['program_id'] = $this->apiClient->getSerializer()->toQueryValue($program_id); } // query params if ($broadcast_id !== null) { - $queryParams['broadcast_id'] = ObjectSerializer::toQueryValue($broadcast_id); + $queryParams['broadcast_id'] = $this->apiClient->getSerializer()->toQueryValue($broadcast_id); } // query params if ($item_id !== null) { - $queryParams['item_id'] = ObjectSerializer::toQueryValue($item_id); + $queryParams['item_id'] = $this->apiClient->getSerializer()->toQueryValue($item_id); } // query params if ($campaign_id !== null) { - $queryParams['campaign_id'] = ObjectSerializer::toQueryValue($campaign_id); + $queryParams['campaign_id'] = $this->apiClient->getSerializer()->toQueryValue($campaign_id); } // query params if ($presenter_id !== null) { - $queryParams['presenter_id'] = ObjectSerializer::toQueryValue($presenter_id); + $queryParams['presenter_id'] = $this->apiClient->getSerializer()->toQueryValue($presenter_id); } // query params if ($contact_id !== null) { - $queryParams['contact_id'] = ObjectSerializer::toQueryValue($contact_id); + $queryParams['contact_id'] = $this->apiClient->getSerializer()->toQueryValue($contact_id); } // query params if ($_external_station_id !== null) { - $queryParams['_external_station_id'] = ObjectSerializer::toQueryValue($_external_station_id); - } - - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); + $queryParams['_external_station_id'] = $this->apiClient->getSerializer()->toQueryValue($_external_station_id); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'GET', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\ModelTypeResults', + '/model_types' + ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\ModelTypeResults', $httpHeader), $statusCode, $httpHeader]; + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\ModelTypeResults', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 403: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 404: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 429: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + } - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + throw $e; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'GET', - $url, - $headers, - $httpBody - ); } - } diff --git a/lib/Api/PresenterApi.php b/lib/Api/PresenterApi.php index d44e34c..f6faeb3 100644 --- a/lib/Api/PresenterApi.php +++ b/lib/Api/PresenterApi.php @@ -28,15 +28,10 @@ namespace RadioManager\Api; -use GuzzleHttp\Client; -use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\Psr7\MultipartStream; -use GuzzleHttp\Psr7\Request; -use RadioManager\ApiException; -use RadioManager\Configuration; -use RadioManager\HeaderSelector; -use RadioManager\ObjectSerializer; +use \RadioManager\ApiClient; +use \RadioManager\ApiException; +use \RadioManager\Configuration; +use \RadioManager\ObjectSerializer; /** * PresenterApi Class Doc Comment @@ -49,36 +44,47 @@ class PresenterApi { /** - * @var ClientInterface + * API Client + * + * @var \RadioManager\ApiClient instance of the ApiClient */ - protected $client; + protected $apiClient; /** - * @var Configuration + * Constructor + * + * @param \RadioManager\ApiClient|null $apiClient The api client to use */ - protected $config; + public function __construct(\RadioManager\ApiClient $apiClient = null) + { + if ($apiClient === null) { + $apiClient = new ApiClient(); + } + + $this->apiClient = $apiClient; + } /** - * @param ClientInterface $client - * @param Configuration $config - * @param HeaderSelector $selector + * Get API client + * + * @return \RadioManager\ApiClient get the API client */ - public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null - ) { - $this->client = $client ?: new Client(); - $this->config = $config ?: new Configuration(); - $this->headerSelector = $selector ?: new HeaderSelector(); + public function getApiClient() + { + return $this->apiClient; } /** - * @return Configuration + * Set the API client + * + * @param \RadioManager\ApiClient $apiClient set the API client + * + * @return PresenterApi */ - public function getConfig() + public function setApiClient(\RadioManager\ApiClient $apiClient) { - return $this->config; + $this->apiClient = $apiClient; + return $this; } /** @@ -88,7 +94,6 @@ public function getConfig() * * @param \RadioManager\Model\PresenterDataInput $data Data **(Required)** (required) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return \RadioManager\Model\PostSuccess */ public function createPresenter($data) @@ -104,160 +109,25 @@ public function createPresenter($data) * * @param \RadioManager\Model\PresenterDataInput $data Data **(Required)** (required) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return array of \RadioManager\Model\PostSuccess, HTTP status code, HTTP response headers (array of strings) */ public function createPresenterWithHttpInfo($data) - { - $returnType = '\RadioManager\Model\PostSuccess'; - $request = $this->createPresenterRequest($data); - - try { - - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\PostSuccess', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 422: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation createPresenterAsync - * - * Create presenter. - * - * @param \RadioManager\Model\PresenterDataInput $data Data **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function createPresenterAsync($data) - { - return $this->createPresenterAsyncWithHttpInfo($data)->then(function ($response) { - return $response[0]; - }); - } - - /** - * Operation createPresenterAsyncWithHttpInfo - * - * Create presenter. - * - * @param \RadioManager\Model\PresenterDataInput $data Data **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function createPresenterAsyncWithHttpInfo($data) - { - $returnType = '\RadioManager\Model\PostSuccess'; - $request = $this->createPresenterRequest($data); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'createPresenter' - * - * @param \RadioManager\Model\PresenterDataInput $data Data **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - protected function createPresenterRequest($data) { // verify the required parameter 'data' is set if ($data === null) { throw new \InvalidArgumentException('Missing the required parameter $data when calling createPresenter'); } - - $resourcePath = '/presenters'; - $formParams = []; + // parse inputs + $resourcePath = "/presenters"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - - + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // body params $_tempBody = null; @@ -265,670 +135,272 @@ protected function createPresenterRequest($data) $_tempBody = $data; } - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } - // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'POST', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation deletePresenterById - * - * Delete presenter by id - * - * @param int $id id of presenter (required) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\Success - */ - public function deletePresenterById($id) - { - list($response) = $this->deletePresenterByIdWithHttpInfo($id); - return $response; - } - - /** - * Operation deletePresenterByIdWithHttpInfo - * - * Delete presenter by id - * - * @param int $id id of presenter (required) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\Success, HTTP status code, HTTP response headers (array of strings) - */ - public function deletePresenterByIdWithHttpInfo($id) - { - $returnType = '\RadioManager\Model\Success'; - $request = $this->deletePresenterByIdRequest($id); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'POST', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\PostSuccess', + '/presenters' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\PostSuccess', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\PostSuccess', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 422: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation deletePresenterByIdAsync + * Operation deletePresenterById * * Delete presenter by id * * @param int $id id of presenter (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\Success */ - public function deletePresenterByIdAsync($id) + public function deletePresenterById($id) { - return $this->deletePresenterByIdAsyncWithHttpInfo($id)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->deletePresenterByIdWithHttpInfo($id); + return $response; } /** - * Operation deletePresenterByIdAsyncWithHttpInfo + * Operation deletePresenterByIdWithHttpInfo * * Delete presenter by id * * @param int $id id of presenter (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function deletePresenterByIdAsyncWithHttpInfo($id) - { - $returnType = '\RadioManager\Model\Success'; - $request = $this->deletePresenterByIdRequest($id); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'deletePresenterById' - * - * @param int $id id of presenter (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\Success, HTTP status code, HTTP response headers (array of strings) */ - protected function deletePresenterByIdRequest($id) + public function deletePresenterByIdWithHttpInfo($id) { // verify the required parameter 'id' is set if ($id === null) { throw new \InvalidArgumentException('Missing the required parameter $id when calling deletePresenterById'); } - if ($id < 0) { + if (($id < 0)) { throw new \InvalidArgumentException('invalid value for "$id" when calling PresenterApi.deletePresenterById, must be bigger than or equal to 0.'); } - - $resourcePath = '/presenters/{id}'; - $formParams = []; + // parse inputs + $resourcePath = "/presenters/{id}"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // path params if ($id !== null) { - $resourcePath = str_replace('{' . 'id' . '}', ObjectSerializer::toPathValue($id), $resourcePath); - } - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] + $resourcePath = str_replace( + "{" . "id" . "}", + $this->apiClient->getSerializer()->toPathValue($id), + $resourcePath ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; - } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'DELETE', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation getPresenterById - * - * Get presenter by id - * - * @param int $id id of Presenter (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\PresenterResult - */ - public function getPresenterById($id, $_external_station_id = null) - { - list($response) = $this->getPresenterByIdWithHttpInfo($id, $_external_station_id); - return $response; - } - - /** - * Operation getPresenterByIdWithHttpInfo - * - * Get presenter by id - * - * @param int $id id of Presenter (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\PresenterResult, HTTP status code, HTTP response headers (array of strings) - */ - public function getPresenterByIdWithHttpInfo($id, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\PresenterResult'; - $request = $this->getPresenterByIdRequest($id, $_external_station_id); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'DELETE', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\Success', + '/presenters/{id}' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\Success', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\PresenterResult', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation getPresenterByIdAsync + * Operation getPresenterById * * Get presenter by id * * @param int $id id of Presenter (required) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\PresenterResult */ - public function getPresenterByIdAsync($id, $_external_station_id = null) + public function getPresenterById($id, $_external_station_id = null) { - return $this->getPresenterByIdAsyncWithHttpInfo($id, $_external_station_id)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->getPresenterByIdWithHttpInfo($id, $_external_station_id); + return $response; } /** - * Operation getPresenterByIdAsyncWithHttpInfo + * Operation getPresenterByIdWithHttpInfo * * Get presenter by id * * @param int $id id of Presenter (required) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getPresenterByIdAsyncWithHttpInfo($id, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\PresenterResult'; - $request = $this->getPresenterByIdRequest($id, $_external_station_id); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'getPresenterById' - * - * @param int $id id of Presenter (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\PresenterResult, HTTP status code, HTTP response headers (array of strings) */ - protected function getPresenterByIdRequest($id, $_external_station_id = null) + public function getPresenterByIdWithHttpInfo($id, $_external_station_id = null) { // verify the required parameter 'id' is set if ($id === null) { throw new \InvalidArgumentException('Missing the required parameter $id when calling getPresenterById'); } - if ($id < 0) { + if (($id < 0)) { throw new \InvalidArgumentException('invalid value for "$id" when calling PresenterApi.getPresenterById, must be bigger than or equal to 0.'); } - - $resourcePath = '/presenters/{id}'; - $formParams = []; + // parse inputs + $resourcePath = "/presenters/{id}"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // query params if ($_external_station_id !== null) { - $queryParams['_external_station_id'] = ObjectSerializer::toQueryValue($_external_station_id); + $queryParams['_external_station_id'] = $this->apiClient->getSerializer()->toQueryValue($_external_station_id); } - // path params if ($id !== null) { - $resourcePath = str_replace('{' . 'id' . '}', ObjectSerializer::toPathValue($id), $resourcePath); - } - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] + $resourcePath = str_replace( + "{" . "id" . "}", + $this->apiClient->getSerializer()->toPathValue($id), + $resourcePath ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'GET', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation listPresenters - * - * Get all presenters. - * - * @param int $page Current page *(Optional)* (optional) - * @param int $model_type_id Search on ModelType ID (Optional) (optional) - * @param int $program_id Search on Program ID *(Optional)* `(Relation)` (optional) - * @param int $broadcast_id Search on Broadcast ID *(Optional)* `(Relation)` (optional) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\PresenterResults - */ - public function listPresenters($page = null, $model_type_id = null, $program_id = null, $broadcast_id = null, $_external_station_id = null) - { - list($response) = $this->listPresentersWithHttpInfo($page, $model_type_id, $program_id, $broadcast_id, $_external_station_id); - return $response; - } - - /** - * Operation listPresentersWithHttpInfo - * - * Get all presenters. - * - * @param int $page Current page *(Optional)* (optional) - * @param int $model_type_id Search on ModelType ID (Optional) (optional) - * @param int $program_id Search on Program ID *(Optional)* `(Relation)` (optional) - * @param int $broadcast_id Search on Broadcast ID *(Optional)* `(Relation)` (optional) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\PresenterResults, HTTP status code, HTTP response headers (array of strings) - */ - public function listPresentersWithHttpInfo($page = null, $model_type_id = null, $program_id = null, $broadcast_id = null, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\PresenterResults'; - $request = $this->listPresentersRequest($page, $model_type_id, $program_id, $broadcast_id, $_external_station_id); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'GET', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\PresenterResult', + '/presenters/{id}' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\PresenterResult', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\PresenterResults', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\PresenterResult', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation listPresentersAsync + * Operation listPresenters * * Get all presenters. * @@ -937,18 +409,17 @@ public function listPresentersWithHttpInfo($page = null, $model_type_id = null, * @param int $program_id Search on Program ID *(Optional)* `(Relation)` (optional) * @param int $broadcast_id Search on Broadcast ID *(Optional)* `(Relation)` (optional) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\PresenterResults */ - public function listPresentersAsync($page = null, $model_type_id = null, $program_id = null, $broadcast_id = null, $_external_station_id = null) + public function listPresenters($page = null, $model_type_id = null, $program_id = null, $broadcast_id = null, $_external_station_id = null) { - return $this->listPresentersAsyncWithHttpInfo($page, $model_type_id, $program_id, $broadcast_id, $_external_station_id)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->listPresentersWithHttpInfo($page, $model_type_id, $program_id, $broadcast_id, $_external_station_id); + return $response; } /** - * Operation listPresentersAsyncWithHttpInfo + * Operation listPresentersWithHttpInfo * * Get all presenters. * @@ -957,409 +428,207 @@ public function listPresentersAsync($page = null, $model_type_id = null, $progra * @param int $program_id Search on Program ID *(Optional)* `(Relation)` (optional) * @param int $broadcast_id Search on Broadcast ID *(Optional)* `(Relation)` (optional) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function listPresentersAsyncWithHttpInfo($page = null, $model_type_id = null, $program_id = null, $broadcast_id = null, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\PresenterResults'; - $request = $this->listPresentersRequest($page, $model_type_id, $program_id, $broadcast_id, $_external_station_id); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'listPresenters' - * - * @param int $page Current page *(Optional)* (optional) - * @param int $model_type_id Search on ModelType ID (Optional) (optional) - * @param int $program_id Search on Program ID *(Optional)* `(Relation)` (optional) - * @param int $broadcast_id Search on Broadcast ID *(Optional)* `(Relation)` (optional) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\PresenterResults, HTTP status code, HTTP response headers (array of strings) */ - protected function listPresentersRequest($page = null, $model_type_id = null, $program_id = null, $broadcast_id = null, $_external_station_id = null) + public function listPresentersWithHttpInfo($page = null, $model_type_id = null, $program_id = null, $broadcast_id = null, $_external_station_id = null) { - if ($page !== null && $page < 0) { + if (!is_null($page) && ($page < 0)) { throw new \InvalidArgumentException('invalid value for "$page" when calling PresenterApi.listPresenters, must be bigger than or equal to 0.'); } - - $resourcePath = '/presenters'; - $formParams = []; + // parse inputs + $resourcePath = "/presenters"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // query params if ($page !== null) { - $queryParams['page'] = ObjectSerializer::toQueryValue($page); + $queryParams['page'] = $this->apiClient->getSerializer()->toQueryValue($page); } // query params if ($model_type_id !== null) { - $queryParams['model_type_id'] = ObjectSerializer::toQueryValue($model_type_id); + $queryParams['model_type_id'] = $this->apiClient->getSerializer()->toQueryValue($model_type_id); } // query params if ($program_id !== null) { - $queryParams['program_id'] = ObjectSerializer::toQueryValue($program_id); + $queryParams['program_id'] = $this->apiClient->getSerializer()->toQueryValue($program_id); } // query params if ($broadcast_id !== null) { - $queryParams['broadcast_id'] = ObjectSerializer::toQueryValue($broadcast_id); + $queryParams['broadcast_id'] = $this->apiClient->getSerializer()->toQueryValue($broadcast_id); } // query params if ($_external_station_id !== null) { - $queryParams['_external_station_id'] = ObjectSerializer::toQueryValue($_external_station_id); - } - - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); + $queryParams['_external_station_id'] = $this->apiClient->getSerializer()->toQueryValue($_external_station_id); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; - } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'GET', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation updatePresenterByID - * - * Update presenter by id - * - * @param int $id id of Presenter (required) - * @param \RadioManager\Model\PresenterDataInput $data Data *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\Success - */ - public function updatePresenterByID($id, $data = null) - { - list($response) = $this->updatePresenterByIDWithHttpInfo($id, $data); - return $response; - } - - /** - * Operation updatePresenterByIDWithHttpInfo - * - * Update presenter by id - * - * @param int $id id of Presenter (required) - * @param \RadioManager\Model\PresenterDataInput $data Data *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\Success, HTTP status code, HTTP response headers (array of strings) - */ - public function updatePresenterByIDWithHttpInfo($id, $data = null) - { - $returnType = '\RadioManager\Model\Success'; - $request = $this->updatePresenterByIDRequest($id, $data); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'GET', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\PresenterResults', + '/presenters' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\PresenterResults', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\PresenterResults', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 422: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation updatePresenterByIDAsync + * Operation updatePresenterByID * * Update presenter by id * * @param int $id id of Presenter (required) * @param \RadioManager\Model\PresenterDataInput $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\Success */ - public function updatePresenterByIDAsync($id, $data = null) + public function updatePresenterByID($id, $data = null) { - return $this->updatePresenterByIDAsyncWithHttpInfo($id, $data)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->updatePresenterByIDWithHttpInfo($id, $data); + return $response; } /** - * Operation updatePresenterByIDAsyncWithHttpInfo + * Operation updatePresenterByIDWithHttpInfo * * Update presenter by id * * @param int $id id of Presenter (required) * @param \RadioManager\Model\PresenterDataInput $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function updatePresenterByIDAsyncWithHttpInfo($id, $data = null) - { - $returnType = '\RadioManager\Model\Success'; - $request = $this->updatePresenterByIDRequest($id, $data); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'updatePresenterByID' - * - * @param int $id id of Presenter (required) - * @param \RadioManager\Model\PresenterDataInput $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\Success, HTTP status code, HTTP response headers (array of strings) */ - protected function updatePresenterByIDRequest($id, $data = null) + public function updatePresenterByIDWithHttpInfo($id, $data = null) { // verify the required parameter 'id' is set if ($id === null) { throw new \InvalidArgumentException('Missing the required parameter $id when calling updatePresenterByID'); } - if ($id < 0) { + if (($id < 0)) { throw new \InvalidArgumentException('invalid value for "$id" when calling PresenterApi.updatePresenterByID, must be bigger than or equal to 0.'); } - - $resourcePath = '/presenters/{id}'; - $formParams = []; + // parse inputs + $resourcePath = "/presenters/{id}"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // path params if ($id !== null) { - $resourcePath = str_replace('{' . 'id' . '}', ObjectSerializer::toPathValue($id), $resourcePath); + $resourcePath = str_replace( + "{" . "id" . "}", + $this->apiClient->getSerializer()->toPathValue($id), + $resourcePath + ); } - // body params $_tempBody = null; if (isset($data)) { $_tempBody = $data; } - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } - // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'PATCH', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\Success', + '/presenters/{id}' + ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\Success', $httpHeader), $statusCode, $httpHeader]; + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 403: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 404: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 422: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 429: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + } - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + throw $e; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'PATCH', - $url, - $headers, - $httpBody - ); } - } diff --git a/lib/Api/ProgramApi.php b/lib/Api/ProgramApi.php index 38f7aba..4bf8e75 100644 --- a/lib/Api/ProgramApi.php +++ b/lib/Api/ProgramApi.php @@ -28,15 +28,10 @@ namespace RadioManager\Api; -use GuzzleHttp\Client; -use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\Psr7\MultipartStream; -use GuzzleHttp\Psr7\Request; -use RadioManager\ApiException; -use RadioManager\Configuration; -use RadioManager\HeaderSelector; -use RadioManager\ObjectSerializer; +use \RadioManager\ApiClient; +use \RadioManager\ApiException; +use \RadioManager\Configuration; +use \RadioManager\ObjectSerializer; /** * ProgramApi Class Doc Comment @@ -49,36 +44,47 @@ class ProgramApi { /** - * @var ClientInterface + * API Client + * + * @var \RadioManager\ApiClient instance of the ApiClient */ - protected $client; + protected $apiClient; /** - * @var Configuration + * Constructor + * + * @param \RadioManager\ApiClient|null $apiClient The api client to use */ - protected $config; + public function __construct(\RadioManager\ApiClient $apiClient = null) + { + if ($apiClient === null) { + $apiClient = new ApiClient(); + } + + $this->apiClient = $apiClient; + } /** - * @param ClientInterface $client - * @param Configuration $config - * @param HeaderSelector $selector + * Get API client + * + * @return \RadioManager\ApiClient get the API client */ - public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null - ) { - $this->client = $client ?: new Client(); - $this->config = $config ?: new Configuration(); - $this->headerSelector = $selector ?: new HeaderSelector(); + public function getApiClient() + { + return $this->apiClient; } /** - * @return Configuration + * Set the API client + * + * @param \RadioManager\ApiClient $apiClient set the API client + * + * @return ProgramApi */ - public function getConfig() + public function setApiClient(\RadioManager\ApiClient $apiClient) { - return $this->config; + $this->apiClient = $apiClient; + return $this; } /** @@ -88,7 +94,6 @@ public function getConfig() * * @param \RadioManager\Model\ProgramDataInput $data Data **(Required)** (required) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return \RadioManager\Model\PostSuccess */ public function createProgram($data) @@ -104,160 +109,25 @@ public function createProgram($data) * * @param \RadioManager\Model\ProgramDataInput $data Data **(Required)** (required) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return array of \RadioManager\Model\PostSuccess, HTTP status code, HTTP response headers (array of strings) */ public function createProgramWithHttpInfo($data) - { - $returnType = '\RadioManager\Model\PostSuccess'; - $request = $this->createProgramRequest($data); - - try { - - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\PostSuccess', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 422: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation createProgramAsync - * - * Create program. - * - * @param \RadioManager\Model\ProgramDataInput $data Data **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function createProgramAsync($data) - { - return $this->createProgramAsyncWithHttpInfo($data)->then(function ($response) { - return $response[0]; - }); - } - - /** - * Operation createProgramAsyncWithHttpInfo - * - * Create program. - * - * @param \RadioManager\Model\ProgramDataInput $data Data **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function createProgramAsyncWithHttpInfo($data) - { - $returnType = '\RadioManager\Model\PostSuccess'; - $request = $this->createProgramRequest($data); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'createProgram' - * - * @param \RadioManager\Model\ProgramDataInput $data Data **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - protected function createProgramRequest($data) { // verify the required parameter 'data' is set if ($data === null) { throw new \InvalidArgumentException('Missing the required parameter $data when calling createProgram'); } - - $resourcePath = '/programs'; - $formParams = []; + // parse inputs + $resourcePath = "/programs"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - - + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // body params $_tempBody = null; @@ -265,678 +135,272 @@ protected function createProgramRequest($data) $_tempBody = $data; } - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } - // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; - } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'POST', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation deleteProgramById - * - * Delete program by id - * - * @param int $id ID of program **(Required)** (required) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\Success - */ - public function deleteProgramById($id) - { - list($response) = $this->deleteProgramByIdWithHttpInfo($id); - return $response; - } - - /** - * Operation deleteProgramByIdWithHttpInfo - * - * Delete program by id - * - * @param int $id ID of program **(Required)** (required) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\Success, HTTP status code, HTTP response headers (array of strings) - */ - public function deleteProgramByIdWithHttpInfo($id) - { - $returnType = '\RadioManager\Model\Success'; - $request = $this->deleteProgramByIdRequest($id); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'POST', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\PostSuccess', + '/programs' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\PostSuccess', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\PostSuccess', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 422: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation deleteProgramByIdAsync + * Operation deleteProgramById * * Delete program by id * * @param int $id ID of program **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\Success */ - public function deleteProgramByIdAsync($id) + public function deleteProgramById($id) { - return $this->deleteProgramByIdAsyncWithHttpInfo($id)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->deleteProgramByIdWithHttpInfo($id); + return $response; } /** - * Operation deleteProgramByIdAsyncWithHttpInfo + * Operation deleteProgramByIdWithHttpInfo * * Delete program by id * * @param int $id ID of program **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function deleteProgramByIdAsyncWithHttpInfo($id) - { - $returnType = '\RadioManager\Model\Success'; - $request = $this->deleteProgramByIdRequest($id); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'deleteProgramById' - * - * @param int $id ID of program **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\Success, HTTP status code, HTTP response headers (array of strings) */ - protected function deleteProgramByIdRequest($id) + public function deleteProgramByIdWithHttpInfo($id) { // verify the required parameter 'id' is set if ($id === null) { throw new \InvalidArgumentException('Missing the required parameter $id when calling deleteProgramById'); } - if ($id < 0) { + if (($id < 0)) { throw new \InvalidArgumentException('invalid value for "$id" when calling ProgramApi.deleteProgramById, must be bigger than or equal to 0.'); } - - $resourcePath = '/programs/{id}'; - $formParams = []; + // parse inputs + $resourcePath = "/programs/{id}"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // path params if ($id !== null) { - $resourcePath = str_replace('{' . 'id' . '}', ObjectSerializer::toPathValue($id), $resourcePath); - } - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] + $resourcePath = str_replace( + "{" . "id" . "}", + $this->apiClient->getSerializer()->toPathValue($id), + $resourcePath ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'DELETE', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation getProgramById - * - * Get program by id - * - * @param int $id ID of Program **(Required)** (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\ProgramResult - */ - public function getProgramById($id, $_external_station_id = null) - { - list($response) = $this->getProgramByIdWithHttpInfo($id, $_external_station_id); - return $response; - } - - /** - * Operation getProgramByIdWithHttpInfo - * - * Get program by id - * - * @param int $id ID of Program **(Required)** (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\ProgramResult, HTTP status code, HTTP response headers (array of strings) - */ - public function getProgramByIdWithHttpInfo($id, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\ProgramResult'; - $request = $this->getProgramByIdRequest($id, $_external_station_id); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'DELETE', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\Success', + '/programs/{id}' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\Success', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\ProgramResult', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation getProgramByIdAsync + * Operation getProgramById * * Get program by id * * @param int $id ID of Program **(Required)** (required) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\ProgramResult */ - public function getProgramByIdAsync($id, $_external_station_id = null) + public function getProgramById($id, $_external_station_id = null) { - return $this->getProgramByIdAsyncWithHttpInfo($id, $_external_station_id)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->getProgramByIdWithHttpInfo($id, $_external_station_id); + return $response; } /** - * Operation getProgramByIdAsyncWithHttpInfo + * Operation getProgramByIdWithHttpInfo * * Get program by id * * @param int $id ID of Program **(Required)** (required) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getProgramByIdAsyncWithHttpInfo($id, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\ProgramResult'; - $request = $this->getProgramByIdRequest($id, $_external_station_id); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'getProgramById' - * - * @param int $id ID of Program **(Required)** (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\ProgramResult, HTTP status code, HTTP response headers (array of strings) */ - protected function getProgramByIdRequest($id, $_external_station_id = null) + public function getProgramByIdWithHttpInfo($id, $_external_station_id = null) { // verify the required parameter 'id' is set if ($id === null) { throw new \InvalidArgumentException('Missing the required parameter $id when calling getProgramById'); } - if ($id < 0) { + if (($id < 0)) { throw new \InvalidArgumentException('invalid value for "$id" when calling ProgramApi.getProgramById, must be bigger than or equal to 0.'); } - - $resourcePath = '/programs/{id}'; - $formParams = []; + // parse inputs + $resourcePath = "/programs/{id}"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // query params if ($_external_station_id !== null) { - $queryParams['_external_station_id'] = ObjectSerializer::toQueryValue($_external_station_id); + $queryParams['_external_station_id'] = $this->apiClient->getSerializer()->toQueryValue($_external_station_id); } - // path params if ($id !== null) { - $resourcePath = str_replace('{' . 'id' . '}', ObjectSerializer::toPathValue($id), $resourcePath); - } - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] + $resourcePath = str_replace( + "{" . "id" . "}", + $this->apiClient->getSerializer()->toPathValue($id), + $resourcePath ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; - } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'GET', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation listPrograms - * - * Get all programs. - * - * @param int $page Current page *(Optional)* (optional) - * @param int $genre_id Search on Genre ID *(Optional)* (optional) - * @param int $model_type_id Search on ModelType ID *(Optional)* (optional) - * @param int $presenter_id Search on Presenter ID *(Optional)* `(Relation)` (optional) - * @param int $tag_id Search on Tag ID *(Optional)* `(Relation)` (optional) - * @param int $broadcast_id Search on Broadcast ID *(Optional)* `(Relation)` (optional) - * @param int $item_id Search on Item ID *(Optional)* `(Relation)` (optional) - * @param int $block_id Search on Block ID *(Optional)* `(Relation)` (optional) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\ProgramResults - */ - public function listPrograms($page = null, $genre_id = null, $model_type_id = null, $presenter_id = null, $tag_id = null, $broadcast_id = null, $item_id = null, $block_id = null, $_external_station_id = null) - { - list($response) = $this->listProgramsWithHttpInfo($page, $genre_id, $model_type_id, $presenter_id, $tag_id, $broadcast_id, $item_id, $block_id, $_external_station_id); - return $response; - } - - /** - * Operation listProgramsWithHttpInfo - * - * Get all programs. - * - * @param int $page Current page *(Optional)* (optional) - * @param int $genre_id Search on Genre ID *(Optional)* (optional) - * @param int $model_type_id Search on ModelType ID *(Optional)* (optional) - * @param int $presenter_id Search on Presenter ID *(Optional)* `(Relation)` (optional) - * @param int $tag_id Search on Tag ID *(Optional)* `(Relation)` (optional) - * @param int $broadcast_id Search on Broadcast ID *(Optional)* `(Relation)` (optional) - * @param int $item_id Search on Item ID *(Optional)* `(Relation)` (optional) - * @param int $block_id Search on Block ID *(Optional)* `(Relation)` (optional) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\ProgramResults, HTTP status code, HTTP response headers (array of strings) - */ - public function listProgramsWithHttpInfo($page = null, $genre_id = null, $model_type_id = null, $presenter_id = null, $tag_id = null, $broadcast_id = null, $item_id = null, $block_id = null, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\ProgramResults'; - $request = $this->listProgramsRequest($page, $genre_id, $model_type_id, $presenter_id, $tag_id, $broadcast_id, $item_id, $block_id, $_external_station_id); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'GET', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\ProgramResult', + '/programs/{id}' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\ProgramResult', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\ProgramResults', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\ProgramResult', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation listProgramsAsync + * Operation listPrograms * * Get all programs. * @@ -949,18 +413,17 @@ public function listProgramsWithHttpInfo($page = null, $genre_id = null, $model_ * @param int $item_id Search on Item ID *(Optional)* `(Relation)` (optional) * @param int $block_id Search on Block ID *(Optional)* `(Relation)` (optional) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\ProgramResults */ - public function listProgramsAsync($page = null, $genre_id = null, $model_type_id = null, $presenter_id = null, $tag_id = null, $broadcast_id = null, $item_id = null, $block_id = null, $_external_station_id = null) + public function listPrograms($page = null, $genre_id = null, $model_type_id = null, $presenter_id = null, $tag_id = null, $broadcast_id = null, $item_id = null, $block_id = null, $_external_station_id = null) { - return $this->listProgramsAsyncWithHttpInfo($page, $genre_id, $model_type_id, $presenter_id, $tag_id, $broadcast_id, $item_id, $block_id, $_external_station_id)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->listProgramsWithHttpInfo($page, $genre_id, $model_type_id, $presenter_id, $tag_id, $broadcast_id, $item_id, $block_id, $_external_station_id); + return $response; } /** - * Operation listProgramsAsyncWithHttpInfo + * Operation listProgramsWithHttpInfo * * Get all programs. * @@ -973,429 +436,223 @@ public function listProgramsAsync($page = null, $genre_id = null, $model_type_id * @param int $item_id Search on Item ID *(Optional)* `(Relation)` (optional) * @param int $block_id Search on Block ID *(Optional)* `(Relation)` (optional) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function listProgramsAsyncWithHttpInfo($page = null, $genre_id = null, $model_type_id = null, $presenter_id = null, $tag_id = null, $broadcast_id = null, $item_id = null, $block_id = null, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\ProgramResults'; - $request = $this->listProgramsRequest($page, $genre_id, $model_type_id, $presenter_id, $tag_id, $broadcast_id, $item_id, $block_id, $_external_station_id); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'listPrograms' - * - * @param int $page Current page *(Optional)* (optional) - * @param int $genre_id Search on Genre ID *(Optional)* (optional) - * @param int $model_type_id Search on ModelType ID *(Optional)* (optional) - * @param int $presenter_id Search on Presenter ID *(Optional)* `(Relation)` (optional) - * @param int $tag_id Search on Tag ID *(Optional)* `(Relation)` (optional) - * @param int $broadcast_id Search on Broadcast ID *(Optional)* `(Relation)` (optional) - * @param int $item_id Search on Item ID *(Optional)* `(Relation)` (optional) - * @param int $block_id Search on Block ID *(Optional)* `(Relation)` (optional) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\ProgramResults, HTTP status code, HTTP response headers (array of strings) */ - protected function listProgramsRequest($page = null, $genre_id = null, $model_type_id = null, $presenter_id = null, $tag_id = null, $broadcast_id = null, $item_id = null, $block_id = null, $_external_station_id = null) + public function listProgramsWithHttpInfo($page = null, $genre_id = null, $model_type_id = null, $presenter_id = null, $tag_id = null, $broadcast_id = null, $item_id = null, $block_id = null, $_external_station_id = null) { - if ($page !== null && $page < 0) { + if (!is_null($page) && ($page < 0)) { throw new \InvalidArgumentException('invalid value for "$page" when calling ProgramApi.listPrograms, must be bigger than or equal to 0.'); } - - $resourcePath = '/programs'; - $formParams = []; + // parse inputs + $resourcePath = "/programs"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // query params if ($page !== null) { - $queryParams['page'] = ObjectSerializer::toQueryValue($page); + $queryParams['page'] = $this->apiClient->getSerializer()->toQueryValue($page); } // query params if ($genre_id !== null) { - $queryParams['genre_id'] = ObjectSerializer::toQueryValue($genre_id); + $queryParams['genre_id'] = $this->apiClient->getSerializer()->toQueryValue($genre_id); } // query params if ($model_type_id !== null) { - $queryParams['model_type_id'] = ObjectSerializer::toQueryValue($model_type_id); + $queryParams['model_type_id'] = $this->apiClient->getSerializer()->toQueryValue($model_type_id); } // query params if ($presenter_id !== null) { - $queryParams['presenter_id'] = ObjectSerializer::toQueryValue($presenter_id); + $queryParams['presenter_id'] = $this->apiClient->getSerializer()->toQueryValue($presenter_id); } // query params if ($tag_id !== null) { - $queryParams['tag_id'] = ObjectSerializer::toQueryValue($tag_id); + $queryParams['tag_id'] = $this->apiClient->getSerializer()->toQueryValue($tag_id); } // query params if ($broadcast_id !== null) { - $queryParams['broadcast_id'] = ObjectSerializer::toQueryValue($broadcast_id); + $queryParams['broadcast_id'] = $this->apiClient->getSerializer()->toQueryValue($broadcast_id); } // query params if ($item_id !== null) { - $queryParams['item_id'] = ObjectSerializer::toQueryValue($item_id); + $queryParams['item_id'] = $this->apiClient->getSerializer()->toQueryValue($item_id); } // query params if ($block_id !== null) { - $queryParams['block_id'] = ObjectSerializer::toQueryValue($block_id); + $queryParams['block_id'] = $this->apiClient->getSerializer()->toQueryValue($block_id); } // query params if ($_external_station_id !== null) { - $queryParams['_external_station_id'] = ObjectSerializer::toQueryValue($_external_station_id); - } - - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); + $queryParams['_external_station_id'] = $this->apiClient->getSerializer()->toQueryValue($_external_station_id); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; - } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'GET', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation updateProgramByID - * - * Update program by id - * - * @param int $id ID of Program **(Required)** (required) - * @param \RadioManager\Model\ProgramDataInput $data Data *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\Success - */ - public function updateProgramByID($id, $data = null) - { - list($response) = $this->updateProgramByIDWithHttpInfo($id, $data); - return $response; - } - - /** - * Operation updateProgramByIDWithHttpInfo - * - * Update program by id - * - * @param int $id ID of Program **(Required)** (required) - * @param \RadioManager\Model\ProgramDataInput $data Data *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\Success, HTTP status code, HTTP response headers (array of strings) - */ - public function updateProgramByIDWithHttpInfo($id, $data = null) - { - $returnType = '\RadioManager\Model\Success'; - $request = $this->updateProgramByIDRequest($id, $data); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'GET', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\ProgramResults', + '/programs' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\ProgramResults', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\ProgramResults', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 422: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation updateProgramByIDAsync + * Operation updateProgramByID * * Update program by id * * @param int $id ID of Program **(Required)** (required) * @param \RadioManager\Model\ProgramDataInput $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\Success */ - public function updateProgramByIDAsync($id, $data = null) + public function updateProgramByID($id, $data = null) { - return $this->updateProgramByIDAsyncWithHttpInfo($id, $data)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->updateProgramByIDWithHttpInfo($id, $data); + return $response; } /** - * Operation updateProgramByIDAsyncWithHttpInfo + * Operation updateProgramByIDWithHttpInfo * * Update program by id * * @param int $id ID of Program **(Required)** (required) * @param \RadioManager\Model\ProgramDataInput $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function updateProgramByIDAsyncWithHttpInfo($id, $data = null) - { - $returnType = '\RadioManager\Model\Success'; - $request = $this->updateProgramByIDRequest($id, $data); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'updateProgramByID' - * - * @param int $id ID of Program **(Required)** (required) - * @param \RadioManager\Model\ProgramDataInput $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\Success, HTTP status code, HTTP response headers (array of strings) */ - protected function updateProgramByIDRequest($id, $data = null) + public function updateProgramByIDWithHttpInfo($id, $data = null) { // verify the required parameter 'id' is set if ($id === null) { throw new \InvalidArgumentException('Missing the required parameter $id when calling updateProgramByID'); } - if ($id < 0) { + if (($id < 0)) { throw new \InvalidArgumentException('invalid value for "$id" when calling ProgramApi.updateProgramByID, must be bigger than or equal to 0.'); } - - $resourcePath = '/programs/{id}'; - $formParams = []; + // parse inputs + $resourcePath = "/programs/{id}"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // path params if ($id !== null) { - $resourcePath = str_replace('{' . 'id' . '}', ObjectSerializer::toPathValue($id), $resourcePath); + $resourcePath = str_replace( + "{" . "id" . "}", + $this->apiClient->getSerializer()->toPathValue($id), + $resourcePath + ); } - // body params $_tempBody = null; if (isset($data)) { $_tempBody = $data; } - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } - // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'PATCH', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\Success', + '/programs/{id}' + ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\Success', $httpHeader), $statusCode, $httpHeader]; + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 403: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 404: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 422: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 429: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + } - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + throw $e; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'PATCH', - $url, - $headers, - $httpBody - ); } - } diff --git a/lib/Api/StoryApi.php b/lib/Api/StoryApi.php index eb5d54d..9c2fa8a 100644 --- a/lib/Api/StoryApi.php +++ b/lib/Api/StoryApi.php @@ -28,15 +28,10 @@ namespace RadioManager\Api; -use GuzzleHttp\Client; -use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\Psr7\MultipartStream; -use GuzzleHttp\Psr7\Request; -use RadioManager\ApiException; -use RadioManager\Configuration; -use RadioManager\HeaderSelector; -use RadioManager\ObjectSerializer; +use \RadioManager\ApiClient; +use \RadioManager\ApiException; +use \RadioManager\Configuration; +use \RadioManager\ObjectSerializer; /** * StoryApi Class Doc Comment @@ -49,36 +44,47 @@ class StoryApi { /** - * @var ClientInterface + * API Client + * + * @var \RadioManager\ApiClient instance of the ApiClient */ - protected $client; + protected $apiClient; /** - * @var Configuration + * Constructor + * + * @param \RadioManager\ApiClient|null $apiClient The api client to use */ - protected $config; + public function __construct(\RadioManager\ApiClient $apiClient = null) + { + if ($apiClient === null) { + $apiClient = new ApiClient(); + } + + $this->apiClient = $apiClient; + } /** - * @param ClientInterface $client - * @param Configuration $config - * @param HeaderSelector $selector + * Get API client + * + * @return \RadioManager\ApiClient get the API client */ - public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null - ) { - $this->client = $client ?: new Client(); - $this->config = $config ?: new Configuration(); - $this->headerSelector = $selector ?: new HeaderSelector(); + public function getApiClient() + { + return $this->apiClient; } /** - * @return Configuration + * Set the API client + * + * @param \RadioManager\ApiClient $apiClient set the API client + * + * @return StoryApi */ - public function getConfig() + public function setApiClient(\RadioManager\ApiClient $apiClient) { - return $this->config; + $this->apiClient = $apiClient; + return $this; } /** @@ -88,7 +94,6 @@ public function getConfig() * * @param \RadioManager\Model\StoryDataInput $data Data **(Required)** (required) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return \RadioManager\Model\PostSuccess */ public function createStory($data) @@ -104,156 +109,25 @@ public function createStory($data) * * @param \RadioManager\Model\StoryDataInput $data Data **(Required)** (required) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return array of \RadioManager\Model\PostSuccess, HTTP status code, HTTP response headers (array of strings) */ public function createStoryWithHttpInfo($data) - { - $returnType = '\RadioManager\Model\PostSuccess'; - $request = $this->createStoryRequest($data); - - try { - - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\PostSuccess', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 422: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation createStoryAsync - * - * Create story. - * - * @param \RadioManager\Model\StoryDataInput $data Data **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function createStoryAsync($data) - { - return $this->createStoryAsyncWithHttpInfo($data)->then(function ($response) { - return $response[0]; - }); - } - - /** - * Operation createStoryAsyncWithHttpInfo - * - * Create story. - * - * @param \RadioManager\Model\StoryDataInput $data Data **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function createStoryAsyncWithHttpInfo($data) - { - $returnType = '\RadioManager\Model\PostSuccess'; - $request = $this->createStoryRequest($data); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'createStory' - * - * @param \RadioManager\Model\StoryDataInput $data Data **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - protected function createStoryRequest($data) { // verify the required parameter 'data' is set if ($data === null) { throw new \InvalidArgumentException('Missing the required parameter $data when calling createStory'); } - - $resourcePath = '/stories'; - $formParams = []; + // parse inputs + $resourcePath = "/stories"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - - + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // body params $_tempBody = null; @@ -261,670 +135,268 @@ protected function createStoryRequest($data) $_tempBody = $data; } - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } - // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; - } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'POST', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation deleteStoryById - * - * Delete story by id - * - * @param int $id ID of Story **(Required)** (required) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\Success - */ - public function deleteStoryById($id) - { - list($response) = $this->deleteStoryByIdWithHttpInfo($id); - return $response; - } - - /** - * Operation deleteStoryByIdWithHttpInfo - * - * Delete story by id - * - * @param int $id ID of Story **(Required)** (required) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\Success, HTTP status code, HTTP response headers (array of strings) - */ - public function deleteStoryByIdWithHttpInfo($id) - { - $returnType = '\RadioManager\Model\Success'; - $request = $this->deleteStoryByIdRequest($id); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'POST', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\PostSuccess', + '/stories' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\PostSuccess', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\PostSuccess', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; - case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + case 422: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation deleteStoryByIdAsync + * Operation deleteStoryById * * Delete story by id * * @param int $id ID of Story **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\Success */ - public function deleteStoryByIdAsync($id) + public function deleteStoryById($id) { - return $this->deleteStoryByIdAsyncWithHttpInfo($id)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->deleteStoryByIdWithHttpInfo($id); + return $response; } /** - * Operation deleteStoryByIdAsyncWithHttpInfo + * Operation deleteStoryByIdWithHttpInfo * * Delete story by id * * @param int $id ID of Story **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function deleteStoryByIdAsyncWithHttpInfo($id) - { - $returnType = '\RadioManager\Model\Success'; - $request = $this->deleteStoryByIdRequest($id); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'deleteStoryById' - * - * @param int $id ID of Story **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\Success, HTTP status code, HTTP response headers (array of strings) */ - protected function deleteStoryByIdRequest($id) + public function deleteStoryByIdWithHttpInfo($id) { // verify the required parameter 'id' is set if ($id === null) { throw new \InvalidArgumentException('Missing the required parameter $id when calling deleteStoryById'); } - if ($id < 0) { + if (($id < 0)) { throw new \InvalidArgumentException('invalid value for "$id" when calling StoryApi.deleteStoryById, must be bigger than or equal to 0.'); } - - $resourcePath = '/stories/{id}'; - $formParams = []; + // parse inputs + $resourcePath = "/stories/{id}"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // path params if ($id !== null) { - $resourcePath = str_replace('{' . 'id' . '}', ObjectSerializer::toPathValue($id), $resourcePath); - } - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] + $resourcePath = str_replace( + "{" . "id" . "}", + $this->apiClient->getSerializer()->toPathValue($id), + $resourcePath ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'DELETE', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation getStoryById - * - * Get story by id - * - * @param int $id ID of Story **(Required)** (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\StoryResult - */ - public function getStoryById($id, $_external_station_id = null) - { - list($response) = $this->getStoryByIdWithHttpInfo($id, $_external_station_id); - return $response; - } - - /** - * Operation getStoryByIdWithHttpInfo - * - * Get story by id - * - * @param int $id ID of Story **(Required)** (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\StoryResult, HTTP status code, HTTP response headers (array of strings) - */ - public function getStoryByIdWithHttpInfo($id, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\StoryResult'; - $request = $this->getStoryByIdRequest($id, $_external_station_id); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'DELETE', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\Success', + '/stories/{id}' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\Success', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\StoryResult', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation getStoryByIdAsync + * Operation getStoryById * * Get story by id * * @param int $id ID of Story **(Required)** (required) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\StoryResult */ - public function getStoryByIdAsync($id, $_external_station_id = null) + public function getStoryById($id, $_external_station_id = null) { - return $this->getStoryByIdAsyncWithHttpInfo($id, $_external_station_id)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->getStoryByIdWithHttpInfo($id, $_external_station_id); + return $response; } /** - * Operation getStoryByIdAsyncWithHttpInfo + * Operation getStoryByIdWithHttpInfo * * Get story by id * * @param int $id ID of Story **(Required)** (required) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getStoryByIdAsyncWithHttpInfo($id, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\StoryResult'; - $request = $this->getStoryByIdRequest($id, $_external_station_id); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'getStoryById' - * - * @param int $id ID of Story **(Required)** (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\StoryResult, HTTP status code, HTTP response headers (array of strings) */ - protected function getStoryByIdRequest($id, $_external_station_id = null) + public function getStoryByIdWithHttpInfo($id, $_external_station_id = null) { // verify the required parameter 'id' is set if ($id === null) { throw new \InvalidArgumentException('Missing the required parameter $id when calling getStoryById'); } - if ($id < 0) { + if (($id < 0)) { throw new \InvalidArgumentException('invalid value for "$id" when calling StoryApi.getStoryById, must be bigger than or equal to 0.'); } - - $resourcePath = '/stories/{id}'; - $formParams = []; + // parse inputs + $resourcePath = "/stories/{id}"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // query params if ($_external_station_id !== null) { - $queryParams['_external_station_id'] = ObjectSerializer::toQueryValue($_external_station_id); + $queryParams['_external_station_id'] = $this->apiClient->getSerializer()->toQueryValue($_external_station_id); } - // path params if ($id !== null) { - $resourcePath = str_replace('{' . 'id' . '}', ObjectSerializer::toPathValue($id), $resourcePath); - } - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] + $resourcePath = str_replace( + "{" . "id" . "}", + $this->apiClient->getSerializer()->toPathValue($id), + $resourcePath ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'GET', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation listStories - * - * Get all stories. - * - * @param int $page Current page *(Optional)* (optional, default to 1) - * @param int $model_type_id Search on ModelType ID *(Optional)* (optional) - * @param int $tag_id Search on Tag ID *(Optional)* `(Relation)` (optional) - * @param int $item_id Search on Item ID *(Optional)* `(Relation)` (optional) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\StoryResults - */ - public function listStories($page = '1', $model_type_id = null, $tag_id = null, $item_id = null, $_external_station_id = null) - { - list($response) = $this->listStoriesWithHttpInfo($page, $model_type_id, $tag_id, $item_id, $_external_station_id); - return $response; - } - - /** - * Operation listStoriesWithHttpInfo - * - * Get all stories. - * - * @param int $page Current page *(Optional)* (optional, default to 1) - * @param int $model_type_id Search on ModelType ID *(Optional)* (optional) - * @param int $tag_id Search on Tag ID *(Optional)* `(Relation)` (optional) - * @param int $item_id Search on Item ID *(Optional)* `(Relation)` (optional) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\StoryResults, HTTP status code, HTTP response headers (array of strings) - */ - public function listStoriesWithHttpInfo($page = '1', $model_type_id = null, $tag_id = null, $item_id = null, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\StoryResults'; - $request = $this->listStoriesRequest($page, $model_type_id, $tag_id, $item_id, $_external_station_id); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'GET', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\StoryResult', + '/stories/{id}' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\StoryResult', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\StoryResults', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\StoryResult', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation listStoriesAsync + * Operation listStories * * Get all stories. * @@ -933,18 +405,17 @@ public function listStoriesWithHttpInfo($page = '1', $model_type_id = null, $tag * @param int $tag_id Search on Tag ID *(Optional)* `(Relation)` (optional) * @param int $item_id Search on Item ID *(Optional)* `(Relation)` (optional) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\StoryResults */ - public function listStoriesAsync($page = '1', $model_type_id = null, $tag_id = null, $item_id = null, $_external_station_id = null) + public function listStories($page = '1', $model_type_id = null, $tag_id = null, $item_id = null, $_external_station_id = null) { - return $this->listStoriesAsyncWithHttpInfo($page, $model_type_id, $tag_id, $item_id, $_external_station_id)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->listStoriesWithHttpInfo($page, $model_type_id, $tag_id, $item_id, $_external_station_id); + return $response; } /** - * Operation listStoriesAsyncWithHttpInfo + * Operation listStoriesWithHttpInfo * * Get all stories. * @@ -953,409 +424,207 @@ public function listStoriesAsync($page = '1', $model_type_id = null, $tag_id = n * @param int $tag_id Search on Tag ID *(Optional)* `(Relation)` (optional) * @param int $item_id Search on Item ID *(Optional)* `(Relation)` (optional) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function listStoriesAsyncWithHttpInfo($page = '1', $model_type_id = null, $tag_id = null, $item_id = null, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\StoryResults'; - $request = $this->listStoriesRequest($page, $model_type_id, $tag_id, $item_id, $_external_station_id); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'listStories' - * - * @param int $page Current page *(Optional)* (optional, default to 1) - * @param int $model_type_id Search on ModelType ID *(Optional)* (optional) - * @param int $tag_id Search on Tag ID *(Optional)* `(Relation)` (optional) - * @param int $item_id Search on Item ID *(Optional)* `(Relation)` (optional) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\StoryResults, HTTP status code, HTTP response headers (array of strings) */ - protected function listStoriesRequest($page = '1', $model_type_id = null, $tag_id = null, $item_id = null, $_external_station_id = null) + public function listStoriesWithHttpInfo($page = '1', $model_type_id = null, $tag_id = null, $item_id = null, $_external_station_id = null) { - if ($page !== null && $page < 0) { + if (!is_null($page) && ($page < 0)) { throw new \InvalidArgumentException('invalid value for "$page" when calling StoryApi.listStories, must be bigger than or equal to 0.'); } - - $resourcePath = '/stories'; - $formParams = []; + // parse inputs + $resourcePath = "/stories"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // query params if ($page !== null) { - $queryParams['page'] = ObjectSerializer::toQueryValue($page); + $queryParams['page'] = $this->apiClient->getSerializer()->toQueryValue($page); } // query params if ($model_type_id !== null) { - $queryParams['model_type_id'] = ObjectSerializer::toQueryValue($model_type_id); + $queryParams['model_type_id'] = $this->apiClient->getSerializer()->toQueryValue($model_type_id); } // query params if ($tag_id !== null) { - $queryParams['tag_id'] = ObjectSerializer::toQueryValue($tag_id); + $queryParams['tag_id'] = $this->apiClient->getSerializer()->toQueryValue($tag_id); } // query params if ($item_id !== null) { - $queryParams['item_id'] = ObjectSerializer::toQueryValue($item_id); + $queryParams['item_id'] = $this->apiClient->getSerializer()->toQueryValue($item_id); } // query params if ($_external_station_id !== null) { - $queryParams['_external_station_id'] = ObjectSerializer::toQueryValue($_external_station_id); - } - - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); + $queryParams['_external_station_id'] = $this->apiClient->getSerializer()->toQueryValue($_external_station_id); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; - } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'GET', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation updateStoryByID - * - * Update story by id - * - * @param int $id ID of Story **(Required)** (required) - * @param \RadioManager\Model\StoryDataInput $data Data *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\Success - */ - public function updateStoryByID($id, $data = null) - { - list($response) = $this->updateStoryByIDWithHttpInfo($id, $data); - return $response; - } - - /** - * Operation updateStoryByIDWithHttpInfo - * - * Update story by id - * - * @param int $id ID of Story **(Required)** (required) - * @param \RadioManager\Model\StoryDataInput $data Data *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\Success, HTTP status code, HTTP response headers (array of strings) - */ - public function updateStoryByIDWithHttpInfo($id, $data = null) - { - $returnType = '\RadioManager\Model\Success'; - $request = $this->updateStoryByIDRequest($id, $data); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'GET', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\StoryResults', + '/stories' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\StoryResults', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\StoryResults', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 422: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation updateStoryByIDAsync + * Operation updateStoryByID * * Update story by id * * @param int $id ID of Story **(Required)** (required) * @param \RadioManager\Model\StoryDataInput $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\Success */ - public function updateStoryByIDAsync($id, $data = null) + public function updateStoryByID($id, $data = null) { - return $this->updateStoryByIDAsyncWithHttpInfo($id, $data)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->updateStoryByIDWithHttpInfo($id, $data); + return $response; } /** - * Operation updateStoryByIDAsyncWithHttpInfo + * Operation updateStoryByIDWithHttpInfo * * Update story by id * * @param int $id ID of Story **(Required)** (required) * @param \RadioManager\Model\StoryDataInput $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function updateStoryByIDAsyncWithHttpInfo($id, $data = null) - { - $returnType = '\RadioManager\Model\Success'; - $request = $this->updateStoryByIDRequest($id, $data); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'updateStoryByID' - * - * @param int $id ID of Story **(Required)** (required) - * @param \RadioManager\Model\StoryDataInput $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\Success, HTTP status code, HTTP response headers (array of strings) */ - protected function updateStoryByIDRequest($id, $data = null) + public function updateStoryByIDWithHttpInfo($id, $data = null) { // verify the required parameter 'id' is set if ($id === null) { throw new \InvalidArgumentException('Missing the required parameter $id when calling updateStoryByID'); } - if ($id < 0) { + if (($id < 0)) { throw new \InvalidArgumentException('invalid value for "$id" when calling StoryApi.updateStoryByID, must be bigger than or equal to 0.'); } - - $resourcePath = '/stories/{id}'; - $formParams = []; + // parse inputs + $resourcePath = "/stories/{id}"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // path params if ($id !== null) { - $resourcePath = str_replace('{' . 'id' . '}', ObjectSerializer::toPathValue($id), $resourcePath); + $resourcePath = str_replace( + "{" . "id" . "}", + $this->apiClient->getSerializer()->toPathValue($id), + $resourcePath + ); } - // body params $_tempBody = null; if (isset($data)) { $_tempBody = $data; } - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } - // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'PATCH', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\Success', + '/stories/{id}' + ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\Success', $httpHeader), $statusCode, $httpHeader]; + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 403: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 404: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 422: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 429: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + } - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + throw $e; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'PATCH', - $url, - $headers, - $httpBody - ); } - } diff --git a/lib/Api/StringApi.php b/lib/Api/StringApi.php index 3f27037..6979c60 100644 --- a/lib/Api/StringApi.php +++ b/lib/Api/StringApi.php @@ -28,15 +28,10 @@ namespace RadioManager\Api; -use GuzzleHttp\Client; -use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\Psr7\MultipartStream; -use GuzzleHttp\Psr7\Request; -use RadioManager\ApiException; -use RadioManager\Configuration; -use RadioManager\HeaderSelector; -use RadioManager\ObjectSerializer; +use \RadioManager\ApiClient; +use \RadioManager\ApiException; +use \RadioManager\Configuration; +use \RadioManager\ObjectSerializer; /** * StringApi Class Doc Comment @@ -49,36 +44,47 @@ class StringApi { /** - * @var ClientInterface + * API Client + * + * @var \RadioManager\ApiClient instance of the ApiClient */ - protected $client; + protected $apiClient; /** - * @var Configuration + * Constructor + * + * @param \RadioManager\ApiClient|null $apiClient The api client to use */ - protected $config; + public function __construct(\RadioManager\ApiClient $apiClient = null) + { + if ($apiClient === null) { + $apiClient = new ApiClient(); + } + + $this->apiClient = $apiClient; + } /** - * @param ClientInterface $client - * @param Configuration $config - * @param HeaderSelector $selector + * Get API client + * + * @return \RadioManager\ApiClient get the API client */ - public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null - ) { - $this->client = $client ?: new Client(); - $this->config = $config ?: new Configuration(); - $this->headerSelector = $selector ?: new HeaderSelector(); + public function getApiClient() + { + return $this->apiClient; } /** - * @return Configuration + * Set the API client + * + * @param \RadioManager\ApiClient $apiClient set the API client + * + * @return StringApi */ - public function getConfig() + public function setApiClient(\RadioManager\ApiClient $apiClient) { - return $this->config; + $this->apiClient = $apiClient; + return $this; } /** @@ -89,7 +95,6 @@ public function getConfig() * @param string $name Name of Strings **(Required)** (required) * @param bool $full_model Full model or content only **(Required)** (required) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return \RadioManager\Model\TextString */ public function getStringsByName($name, $full_model) @@ -106,141 +111,9 @@ public function getStringsByName($name, $full_model) * @param string $name Name of Strings **(Required)** (required) * @param bool $full_model Full model or content only **(Required)** (required) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return array of \RadioManager\Model\TextString, HTTP status code, HTTP response headers (array of strings) */ public function getStringsByNameWithHttpInfo($name, $full_model) - { - $returnType = '\RadioManager\Model\TextString'; - $request = $this->getStringsByNameRequest($name, $full_model); - - try { - - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TextString', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation getStringsByNameAsync - * - * Get Strings (formatted) - * - * @param string $name Name of Strings **(Required)** (required) - * @param bool $full_model Full model or content only **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getStringsByNameAsync($name, $full_model) - { - return $this->getStringsByNameAsyncWithHttpInfo($name, $full_model)->then(function ($response) { - return $response[0]; - }); - } - - /** - * Operation getStringsByNameAsyncWithHttpInfo - * - * Get Strings (formatted) - * - * @param string $name Name of Strings **(Required)** (required) - * @param bool $full_model Full model or content only **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getStringsByNameAsyncWithHttpInfo($name, $full_model) - { - $returnType = '\RadioManager\Model\TextString'; - $request = $this->getStringsByNameRequest($name, $full_model); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'getStringsByName' - * - * @param string $name Name of Strings **(Required)** (required) - * @param bool $full_model Full model or content only **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - protected function getStringsByNameRequest($name, $full_model) { // verify the required parameter 'name' is set if ($name === null) { @@ -250,85 +123,72 @@ protected function getStringsByNameRequest($name, $full_model) if ($full_model === null) { throw new \InvalidArgumentException('Missing the required parameter $full_model when calling getStringsByName'); } - - $resourcePath = '/strings/{name}'; - $formParams = []; + // parse inputs + $resourcePath = "/strings/{name}"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // query params if ($full_model !== null) { - $queryParams['full_model'] = ObjectSerializer::toQueryValue($full_model); + $queryParams['full_model'] = $this->apiClient->getSerializer()->toQueryValue($full_model); } - // path params if ($name !== null) { - $resourcePath = str_replace('{' . 'name' . '}', ObjectSerializer::toPathValue($name), $resourcePath); - } - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] + $resourcePath = str_replace( + "{" . "name" . "}", + $this->apiClient->getSerializer()->toPathValue($name), + $resourcePath ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'GET', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\TextString', + '/strings/{name}' + ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\TextString', $httpHeader), $statusCode, $httpHeader]; + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TextString', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 404: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 429: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + } - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + throw $e; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'GET', - $url, - $headers, - $httpBody - ); } - } diff --git a/lib/Api/TagApi.php b/lib/Api/TagApi.php index ed00a37..bce41ed 100644 --- a/lib/Api/TagApi.php +++ b/lib/Api/TagApi.php @@ -28,15 +28,10 @@ namespace RadioManager\Api; -use GuzzleHttp\Client; -use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\Psr7\MultipartStream; -use GuzzleHttp\Psr7\Request; -use RadioManager\ApiException; -use RadioManager\Configuration; -use RadioManager\HeaderSelector; -use RadioManager\ObjectSerializer; +use \RadioManager\ApiClient; +use \RadioManager\ApiException; +use \RadioManager\Configuration; +use \RadioManager\ObjectSerializer; /** * TagApi Class Doc Comment @@ -49,36 +44,47 @@ class TagApi { /** - * @var ClientInterface + * API Client + * + * @var \RadioManager\ApiClient instance of the ApiClient */ - protected $client; + protected $apiClient; /** - * @var Configuration + * Constructor + * + * @param \RadioManager\ApiClient|null $apiClient The api client to use */ - protected $config; + public function __construct(\RadioManager\ApiClient $apiClient = null) + { + if ($apiClient === null) { + $apiClient = new ApiClient(); + } + + $this->apiClient = $apiClient; + } /** - * @param ClientInterface $client - * @param Configuration $config - * @param HeaderSelector $selector + * Get API client + * + * @return \RadioManager\ApiClient get the API client */ - public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null - ) { - $this->client = $client ?: new Client(); - $this->config = $config ?: new Configuration(); - $this->headerSelector = $selector ?: new HeaderSelector(); + public function getApiClient() + { + return $this->apiClient; } /** - * @return Configuration + * Set the API client + * + * @param \RadioManager\ApiClient $apiClient set the API client + * + * @return TagApi */ - public function getConfig() + public function setApiClient(\RadioManager\ApiClient $apiClient) { - return $this->config; + $this->apiClient = $apiClient; + return $this; } /** @@ -88,7 +94,6 @@ public function getConfig() * * @param \RadioManager\Model\TagDataInput $data Data **(Required)** (required) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return \RadioManager\Model\PostSuccess */ public function createTag($data) @@ -104,160 +109,25 @@ public function createTag($data) * * @param \RadioManager\Model\TagDataInput $data Data **(Required)** (required) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return array of \RadioManager\Model\PostSuccess, HTTP status code, HTTP response headers (array of strings) */ public function createTagWithHttpInfo($data) - { - $returnType = '\RadioManager\Model\PostSuccess'; - $request = $this->createTagRequest($data); - - try { - - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\PostSuccess', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 422: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation createTagAsync - * - * Create tag. - * - * @param \RadioManager\Model\TagDataInput $data Data **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function createTagAsync($data) - { - return $this->createTagAsyncWithHttpInfo($data)->then(function ($response) { - return $response[0]; - }); - } - - /** - * Operation createTagAsyncWithHttpInfo - * - * Create tag. - * - * @param \RadioManager\Model\TagDataInput $data Data **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function createTagAsyncWithHttpInfo($data) - { - $returnType = '\RadioManager\Model\PostSuccess'; - $request = $this->createTagRequest($data); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'createTag' - * - * @param \RadioManager\Model\TagDataInput $data Data **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - protected function createTagRequest($data) { // verify the required parameter 'data' is set if ($data === null) { throw new \InvalidArgumentException('Missing the required parameter $data when calling createTag'); } - - $resourcePath = '/tags'; - $formParams = []; + // parse inputs + $resourcePath = "/tags"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - - + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // body params $_tempBody = null; @@ -265,672 +135,272 @@ protected function createTagRequest($data) $_tempBody = $data; } - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } - // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; - } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'POST', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation deleteTagById - * - * Delete tag by id - * - * @param int $id ID of Tag **(Required)** (required) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\Success - */ - public function deleteTagById($id) - { - list($response) = $this->deleteTagByIdWithHttpInfo($id); - return $response; - } - - /** - * Operation deleteTagByIdWithHttpInfo - * - * Delete tag by id - * - * @param int $id ID of Tag **(Required)** (required) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\Success, HTTP status code, HTTP response headers (array of strings) - */ - public function deleteTagByIdWithHttpInfo($id) - { - $returnType = '\RadioManager\Model\Success'; - $request = $this->deleteTagByIdRequest($id); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'POST', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\PostSuccess', + '/tags' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\PostSuccess', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\PostSuccess', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 422: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation deleteTagByIdAsync + * Operation deleteTagById * * Delete tag by id * * @param int $id ID of Tag **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\Success */ - public function deleteTagByIdAsync($id) + public function deleteTagById($id) { - return $this->deleteTagByIdAsyncWithHttpInfo($id)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->deleteTagByIdWithHttpInfo($id); + return $response; } /** - * Operation deleteTagByIdAsyncWithHttpInfo + * Operation deleteTagByIdWithHttpInfo * * Delete tag by id * * @param int $id ID of Tag **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function deleteTagByIdAsyncWithHttpInfo($id) - { - $returnType = '\RadioManager\Model\Success'; - $request = $this->deleteTagByIdRequest($id); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'deleteTagById' - * - * @param int $id ID of Tag **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\Success, HTTP status code, HTTP response headers (array of strings) */ - protected function deleteTagByIdRequest($id) + public function deleteTagByIdWithHttpInfo($id) { // verify the required parameter 'id' is set if ($id === null) { throw new \InvalidArgumentException('Missing the required parameter $id when calling deleteTagById'); } - if ($id < 0) { + if (($id < 0)) { throw new \InvalidArgumentException('invalid value for "$id" when calling TagApi.deleteTagById, must be bigger than or equal to 0.'); } - - $resourcePath = '/tags/{id}'; - $formParams = []; + // parse inputs + $resourcePath = "/tags/{id}"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // path params if ($id !== null) { - $resourcePath = str_replace('{' . 'id' . '}', ObjectSerializer::toPathValue($id), $resourcePath); - } - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] + $resourcePath = str_replace( + "{" . "id" . "}", + $this->apiClient->getSerializer()->toPathValue($id), + $resourcePath ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'DELETE', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation getTagById - * - * Get tags by id - * - * @param int $id ID of Tag **(Required)** (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\TagResult - */ - public function getTagById($id, $_external_station_id = null) - { - list($response) = $this->getTagByIdWithHttpInfo($id, $_external_station_id); - return $response; - } - - /** - * Operation getTagByIdWithHttpInfo - * - * Get tags by id - * - * @param int $id ID of Tag **(Required)** (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\TagResult, HTTP status code, HTTP response headers (array of strings) - */ - public function getTagByIdWithHttpInfo($id, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\TagResult'; - $request = $this->getTagByIdRequest($id, $_external_station_id); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'DELETE', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\Success', + '/tags/{id}' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\Success', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TagResult', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation getTagByIdAsync + * Operation getTagById * * Get tags by id * * @param int $id ID of Tag **(Required)** (required) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\TagResult */ - public function getTagByIdAsync($id, $_external_station_id = null) + public function getTagById($id, $_external_station_id = null) { - return $this->getTagByIdAsyncWithHttpInfo($id, $_external_station_id)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->getTagByIdWithHttpInfo($id, $_external_station_id); + return $response; } /** - * Operation getTagByIdAsyncWithHttpInfo + * Operation getTagByIdWithHttpInfo * * Get tags by id * * @param int $id ID of Tag **(Required)** (required) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getTagByIdAsyncWithHttpInfo($id, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\TagResult'; - $request = $this->getTagByIdRequest($id, $_external_station_id); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'getTagById' - * - * @param int $id ID of Tag **(Required)** (required) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\TagResult, HTTP status code, HTTP response headers (array of strings) */ - protected function getTagByIdRequest($id, $_external_station_id = null) + public function getTagByIdWithHttpInfo($id, $_external_station_id = null) { // verify the required parameter 'id' is set if ($id === null) { throw new \InvalidArgumentException('Missing the required parameter $id when calling getTagById'); } - if ($id < 0) { + if (($id < 0)) { throw new \InvalidArgumentException('invalid value for "$id" when calling TagApi.getTagById, must be bigger than or equal to 0.'); } - - $resourcePath = '/tags/{id}'; - $formParams = []; + // parse inputs + $resourcePath = "/tags/{id}"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // query params if ($_external_station_id !== null) { - $queryParams['_external_station_id'] = ObjectSerializer::toQueryValue($_external_station_id); + $queryParams['_external_station_id'] = $this->apiClient->getSerializer()->toQueryValue($_external_station_id); } - // path params if ($id !== null) { - $resourcePath = str_replace('{' . 'id' . '}', ObjectSerializer::toPathValue($id), $resourcePath); - } - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] + $resourcePath = str_replace( + "{" . "id" . "}", + $this->apiClient->getSerializer()->toPathValue($id), + $resourcePath ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'GET', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation listTags - * - * Get a list of all the tags currently in your station. - * - * @param int $page Current page *(Optional)* (optional) - * @param int $program_id Search on Program ID *(Optional)* `(Relation)` (optional) - * @param int $item_id Search on Item ID *(Optional)* `(Relation)` (optional) - * @param int $broadcast_id Search on Broadcast ID *(Optional)* `(Relation)` (optional) - * @param int $contact_id Search on Contact ID *(Optional)* `(Relation)` (optional) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\TagResults - */ - public function listTags($page = null, $program_id = null, $item_id = null, $broadcast_id = null, $contact_id = null, $_external_station_id = null) - { - list($response) = $this->listTagsWithHttpInfo($page, $program_id, $item_id, $broadcast_id, $contact_id, $_external_station_id); - return $response; - } - - /** - * Operation listTagsWithHttpInfo - * - * Get a list of all the tags currently in your station. - * - * @param int $page Current page *(Optional)* (optional) - * @param int $program_id Search on Program ID *(Optional)* `(Relation)` (optional) - * @param int $item_id Search on Item ID *(Optional)* `(Relation)` (optional) - * @param int $broadcast_id Search on Broadcast ID *(Optional)* `(Relation)` (optional) - * @param int $contact_id Search on Contact ID *(Optional)* `(Relation)` (optional) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\TagResults, HTTP status code, HTTP response headers (array of strings) - */ - public function listTagsWithHttpInfo($page = null, $program_id = null, $item_id = null, $broadcast_id = null, $contact_id = null, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\TagResults'; - $request = $this->listTagsRequest($page, $program_id, $item_id, $broadcast_id, $contact_id, $_external_station_id); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'GET', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\TagResult', + '/tags/{id}' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\TagResult', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TagResults', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TagResult', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation listTagsAsync + * Operation listTags * * Get a list of all the tags currently in your station. * @@ -940,18 +410,17 @@ public function listTagsWithHttpInfo($page = null, $program_id = null, $item_id * @param int $broadcast_id Search on Broadcast ID *(Optional)* `(Relation)` (optional) * @param int $contact_id Search on Contact ID *(Optional)* `(Relation)` (optional) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\TagResults */ - public function listTagsAsync($page = null, $program_id = null, $item_id = null, $broadcast_id = null, $contact_id = null, $_external_station_id = null) + public function listTags($page = null, $program_id = null, $item_id = null, $broadcast_id = null, $contact_id = null, $_external_station_id = null) { - return $this->listTagsAsyncWithHttpInfo($page, $program_id, $item_id, $broadcast_id, $contact_id, $_external_station_id)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->listTagsWithHttpInfo($page, $program_id, $item_id, $broadcast_id, $contact_id, $_external_station_id); + return $response; } /** - * Operation listTagsAsyncWithHttpInfo + * Operation listTagsWithHttpInfo * * Get a list of all the tags currently in your station. * @@ -961,414 +430,211 @@ public function listTagsAsync($page = null, $program_id = null, $item_id = null, * @param int $broadcast_id Search on Broadcast ID *(Optional)* `(Relation)` (optional) * @param int $contact_id Search on Contact ID *(Optional)* `(Relation)` (optional) * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function listTagsAsyncWithHttpInfo($page = null, $program_id = null, $item_id = null, $broadcast_id = null, $contact_id = null, $_external_station_id = null) - { - $returnType = '\RadioManager\Model\TagResults'; - $request = $this->listTagsRequest($page, $program_id, $item_id, $broadcast_id, $contact_id, $_external_station_id); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'listTags' - * - * @param int $page Current page *(Optional)* (optional) - * @param int $program_id Search on Program ID *(Optional)* `(Relation)` (optional) - * @param int $item_id Search on Item ID *(Optional)* `(Relation)` (optional) - * @param int $broadcast_id Search on Broadcast ID *(Optional)* `(Relation)` (optional) - * @param int $contact_id Search on Contact ID *(Optional)* `(Relation)` (optional) - * @param int $_external_station_id Query on a different (content providing) station *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\TagResults, HTTP status code, HTTP response headers (array of strings) */ - protected function listTagsRequest($page = null, $program_id = null, $item_id = null, $broadcast_id = null, $contact_id = null, $_external_station_id = null) + public function listTagsWithHttpInfo($page = null, $program_id = null, $item_id = null, $broadcast_id = null, $contact_id = null, $_external_station_id = null) { - if ($page !== null && $page < 1) { + if (!is_null($page) && ($page < 1)) { throw new \InvalidArgumentException('invalid value for "$page" when calling TagApi.listTags, must be bigger than or equal to 1.'); } - - $resourcePath = '/tags'; - $formParams = []; + // parse inputs + $resourcePath = "/tags"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // query params if ($page !== null) { - $queryParams['page'] = ObjectSerializer::toQueryValue($page); + $queryParams['page'] = $this->apiClient->getSerializer()->toQueryValue($page); } // query params if ($program_id !== null) { - $queryParams['program_id'] = ObjectSerializer::toQueryValue($program_id); + $queryParams['program_id'] = $this->apiClient->getSerializer()->toQueryValue($program_id); } // query params if ($item_id !== null) { - $queryParams['item_id'] = ObjectSerializer::toQueryValue($item_id); + $queryParams['item_id'] = $this->apiClient->getSerializer()->toQueryValue($item_id); } // query params if ($broadcast_id !== null) { - $queryParams['broadcast_id'] = ObjectSerializer::toQueryValue($broadcast_id); + $queryParams['broadcast_id'] = $this->apiClient->getSerializer()->toQueryValue($broadcast_id); } // query params if ($contact_id !== null) { - $queryParams['contact_id'] = ObjectSerializer::toQueryValue($contact_id); + $queryParams['contact_id'] = $this->apiClient->getSerializer()->toQueryValue($contact_id); } // query params if ($_external_station_id !== null) { - $queryParams['_external_station_id'] = ObjectSerializer::toQueryValue($_external_station_id); - } - - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); + $queryParams['_external_station_id'] = $this->apiClient->getSerializer()->toQueryValue($_external_station_id); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; - } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'GET', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation updateTagByID - * - * Update tag by id - * - * @param int $id ID of Tag **(Required)** (required) - * @param \RadioManager\Model\TagDataInput $data Data *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\Success - */ - public function updateTagByID($id, $data = null) - { - list($response) = $this->updateTagByIDWithHttpInfo($id, $data); - return $response; - } - - /** - * Operation updateTagByIDWithHttpInfo - * - * Update tag by id - * - * @param int $id ID of Tag **(Required)** (required) - * @param \RadioManager\Model\TagDataInput $data Data *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\Success, HTTP status code, HTTP response headers (array of strings) - */ - public function updateTagByIDWithHttpInfo($id, $data = null) - { - $returnType = '\RadioManager\Model\Success'; - $request = $this->updateTagByIDRequest($id, $data); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'GET', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\TagResults', + '/tags' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\TagResults', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TagResults', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 422: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation updateTagByIDAsync + * Operation updateTagByID * * Update tag by id * * @param int $id ID of Tag **(Required)** (required) * @param \RadioManager\Model\TagDataInput $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\Success */ - public function updateTagByIDAsync($id, $data = null) + public function updateTagByID($id, $data = null) { - return $this->updateTagByIDAsyncWithHttpInfo($id, $data)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->updateTagByIDWithHttpInfo($id, $data); + return $response; } /** - * Operation updateTagByIDAsyncWithHttpInfo + * Operation updateTagByIDWithHttpInfo * * Update tag by id * * @param int $id ID of Tag **(Required)** (required) * @param \RadioManager\Model\TagDataInput $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function updateTagByIDAsyncWithHttpInfo($id, $data = null) - { - $returnType = '\RadioManager\Model\Success'; - $request = $this->updateTagByIDRequest($id, $data); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'updateTagByID' - * - * @param int $id ID of Tag **(Required)** (required) - * @param \RadioManager\Model\TagDataInput $data Data *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\Success, HTTP status code, HTTP response headers (array of strings) */ - protected function updateTagByIDRequest($id, $data = null) + public function updateTagByIDWithHttpInfo($id, $data = null) { // verify the required parameter 'id' is set if ($id === null) { throw new \InvalidArgumentException('Missing the required parameter $id when calling updateTagByID'); } - if ($id < 0) { + if (($id < 0)) { throw new \InvalidArgumentException('invalid value for "$id" when calling TagApi.updateTagByID, must be bigger than or equal to 0.'); } - - $resourcePath = '/tags/{id}'; - $formParams = []; + // parse inputs + $resourcePath = "/tags/{id}"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // path params if ($id !== null) { - $resourcePath = str_replace('{' . 'id' . '}', ObjectSerializer::toPathValue($id), $resourcePath); + $resourcePath = str_replace( + "{" . "id" . "}", + $this->apiClient->getSerializer()->toPathValue($id), + $resourcePath + ); } - // body params $_tempBody = null; if (isset($data)) { $_tempBody = $data; } - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } - // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'PATCH', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\Success', + '/tags/{id}' + ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\Success', $httpHeader), $statusCode, $httpHeader]; + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 403: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 404: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 422: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 429: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + } - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + throw $e; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'PATCH', - $url, - $headers, - $httpBody - ); } - } diff --git a/lib/Api/UserApi.php b/lib/Api/UserApi.php index cc274bd..f343f62 100644 --- a/lib/Api/UserApi.php +++ b/lib/Api/UserApi.php @@ -28,15 +28,10 @@ namespace RadioManager\Api; -use GuzzleHttp\Client; -use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\Psr7\MultipartStream; -use GuzzleHttp\Psr7\Request; -use RadioManager\ApiException; -use RadioManager\Configuration; -use RadioManager\HeaderSelector; -use RadioManager\ObjectSerializer; +use \RadioManager\ApiClient; +use \RadioManager\ApiException; +use \RadioManager\Configuration; +use \RadioManager\ObjectSerializer; /** * UserApi Class Doc Comment @@ -49,36 +44,47 @@ class UserApi { /** - * @var ClientInterface + * API Client + * + * @var \RadioManager\ApiClient instance of the ApiClient */ - protected $client; + protected $apiClient; /** - * @var Configuration + * Constructor + * + * @param \RadioManager\ApiClient|null $apiClient The api client to use */ - protected $config; + public function __construct(\RadioManager\ApiClient $apiClient = null) + { + if ($apiClient === null) { + $apiClient = new ApiClient(); + } + + $this->apiClient = $apiClient; + } /** - * @param ClientInterface $client - * @param Configuration $config - * @param HeaderSelector $selector + * Get API client + * + * @return \RadioManager\ApiClient get the API client */ - public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null - ) { - $this->client = $client ?: new Client(); - $this->config = $config ?: new Configuration(); - $this->headerSelector = $selector ?: new HeaderSelector(); + public function getApiClient() + { + return $this->apiClient; } /** - * @return Configuration + * Set the API client + * + * @param \RadioManager\ApiClient $apiClient set the API client + * + * @return UserApi */ - public function getConfig() + public function setApiClient(\RadioManager\ApiClient $apiClient) { - return $this->config; + $this->apiClient = $apiClient; + return $this; } /** @@ -88,7 +94,6 @@ public function getConfig() * * @param int $id id of User (required) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return \RadioManager\Model\Success */ public function deleteUserById($id) @@ -104,650 +109,231 @@ public function deleteUserById($id) * * @param int $id id of User (required) * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return array of \RadioManager\Model\Success, HTTP status code, HTTP response headers (array of strings) */ public function deleteUserByIdWithHttpInfo($id) - { - $returnType = '\RadioManager\Model\Success'; - $request = $this->deleteUserByIdRequest($id); - - try { - - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation deleteUserByIdAsync - * - * Remove user from station by Id - * - * @param int $id id of User (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function deleteUserByIdAsync($id) - { - return $this->deleteUserByIdAsyncWithHttpInfo($id)->then(function ($response) { - return $response[0]; - }); - } - - /** - * Operation deleteUserByIdAsyncWithHttpInfo - * - * Remove user from station by Id - * - * @param int $id id of User (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function deleteUserByIdAsyncWithHttpInfo($id) - { - $returnType = '\RadioManager\Model\Success'; - $request = $this->deleteUserByIdRequest($id); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'deleteUserById' - * - * @param int $id id of User (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - protected function deleteUserByIdRequest($id) { // verify the required parameter 'id' is set if ($id === null) { throw new \InvalidArgumentException('Missing the required parameter $id when calling deleteUserById'); } - if ($id < 0) { + if (($id < 0)) { throw new \InvalidArgumentException('invalid value for "$id" when calling UserApi.deleteUserById, must be bigger than or equal to 0.'); } - - $resourcePath = '/users/{id}'; - $formParams = []; + // parse inputs + $resourcePath = "/users/{id}"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // path params if ($id !== null) { - $resourcePath = str_replace('{' . 'id' . '}', ObjectSerializer::toPathValue($id), $resourcePath); - } - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] + $resourcePath = str_replace( + "{" . "id" . "}", + $this->apiClient->getSerializer()->toPathValue($id), + $resourcePath ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'DELETE', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation getUserById - * - * Get user by id - * - * @param int $id id of User (required) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\UserResult - */ - public function getUserById($id) - { - list($response) = $this->getUserByIdWithHttpInfo($id); - return $response; - } - - /** - * Operation getUserByIdWithHttpInfo - * - * Get user by id - * - * @param int $id id of User (required) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\UserResult, HTTP status code, HTTP response headers (array of strings) - */ - public function getUserByIdWithHttpInfo($id) - { - $returnType = '\RadioManager\Model\UserResult'; - $request = $this->getUserByIdRequest($id); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'DELETE', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\Success', + '/users/{id}' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\Success', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\UserResult', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Success', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation getUserByIdAsync + * Operation getUserById * * Get user by id * * @param int $id id of User (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\UserResult */ - public function getUserByIdAsync($id) + public function getUserById($id) { - return $this->getUserByIdAsyncWithHttpInfo($id)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->getUserByIdWithHttpInfo($id); + return $response; } /** - * Operation getUserByIdAsyncWithHttpInfo + * Operation getUserByIdWithHttpInfo * * Get user by id * * @param int $id id of User (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getUserByIdAsyncWithHttpInfo($id) - { - $returnType = '\RadioManager\Model\UserResult'; - $request = $this->getUserByIdRequest($id); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'getUserById' - * - * @param int $id id of User (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\UserResult, HTTP status code, HTTP response headers (array of strings) */ - protected function getUserByIdRequest($id) + public function getUserByIdWithHttpInfo($id) { // verify the required parameter 'id' is set if ($id === null) { throw new \InvalidArgumentException('Missing the required parameter $id when calling getUserById'); } - if ($id < 0) { + if (($id < 0)) { throw new \InvalidArgumentException('invalid value for "$id" when calling UserApi.getUserById, must be bigger than or equal to 0.'); } - - $resourcePath = '/users/{id}'; - $formParams = []; + // parse inputs + $resourcePath = "/users/{id}"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // path params if ($id !== null) { - $resourcePath = str_replace('{' . 'id' . '}', ObjectSerializer::toPathValue($id), $resourcePath); - } - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] + $resourcePath = str_replace( + "{" . "id" . "}", + $this->apiClient->getSerializer()->toPathValue($id), + $resourcePath ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'GET', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation inviteUserByMail - * - * Invite user by mail - * - * @param \RadioManager\Model\InviteUserData $data Data **(Required)** (required) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\InviteUserSuccess - */ - public function inviteUserByMail($data) - { - list($response) = $this->inviteUserByMailWithHttpInfo($data); - return $response; - } - - /** - * Operation inviteUserByMailWithHttpInfo - * - * Invite user by mail - * - * @param \RadioManager\Model\InviteUserData $data Data **(Required)** (required) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\InviteUserSuccess, HTTP status code, HTTP response headers (array of strings) - */ - public function inviteUserByMailWithHttpInfo($data) - { - $returnType = '\RadioManager\Model\InviteUserSuccess'; - $request = $this->inviteUserByMailRequest($data); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'GET', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\UserResult', + '/users/{id}' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\UserResult', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\InviteUserSuccess', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\UserResult', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 422: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation inviteUserByMailAsync + * Operation inviteUserByMail * * Invite user by mail * * @param \RadioManager\Model\InviteUserData $data Data **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\InviteUserSuccess */ - public function inviteUserByMailAsync($data) + public function inviteUserByMail($data) { - return $this->inviteUserByMailAsyncWithHttpInfo($data)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->inviteUserByMailWithHttpInfo($data); + return $response; } /** - * Operation inviteUserByMailAsyncWithHttpInfo + * Operation inviteUserByMailWithHttpInfo * * Invite user by mail * * @param \RadioManager\Model\InviteUserData $data Data **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function inviteUserByMailAsyncWithHttpInfo($data) - { - $returnType = '\RadioManager\Model\InviteUserSuccess'; - $request = $this->inviteUserByMailRequest($data); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'inviteUserByMail' - * - * @param \RadioManager\Model\InviteUserData $data Data **(Required)** (required) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\InviteUserSuccess, HTTP status code, HTTP response headers (array of strings) */ - protected function inviteUserByMailRequest($data) + public function inviteUserByMailWithHttpInfo($data) { // verify the required parameter 'data' is set if ($data === null) { throw new \InvalidArgumentException('Missing the required parameter $data when calling inviteUserByMail'); } - - $resourcePath = '/users/invite'; - $formParams = []; + // parse inputs + $resourcePath = "/users/invite"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; - - + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // body params $_tempBody = null; @@ -755,316 +341,156 @@ protected function inviteUserByMailRequest($data) $_tempBody = $data; } - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } - // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; - } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'POST', - $url, - $headers, - $httpBody - ); - } - - /** - * Operation listUsers - * - * Get all users. - * - * @param int $page Current page *(Optional)* (optional, default to 1) - * @param int $role_id Search on Role ID *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \RadioManager\Model\UserResults - */ - public function listUsers($page = '1', $role_id = null) - { - list($response) = $this->listUsersWithHttpInfo($page, $role_id); - return $response; - } - - /** - * Operation listUsersWithHttpInfo - * - * Get all users. - * - * @param int $page Current page *(Optional)* (optional, default to 1) - * @param int $role_id Search on Role ID *(Optional)* (optional) - * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \RadioManager\Model\UserResults, HTTP status code, HTTP response headers (array of strings) - */ - public function listUsersWithHttpInfo($page = '1', $role_id = null) - { - $returnType = '\RadioManager\Model\UserResults'; - $request = $this->listUsersRequest($page, $role_id); - + // make the API Call try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'POST', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\InviteUserSuccess', + '/users/invite' + ); - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } - - $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() - ]; - + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\InviteUserSuccess', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\UserResults', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\InviteUserSuccess', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 403: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 422: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\UnprocessableEntity', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } + throw $e; } } /** - * Operation listUsersAsync + * Operation listUsers * * Get all users. * * @param int $page Current page *(Optional)* (optional, default to 1) * @param int $role_id Search on Role ID *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \RadioManager\ApiException on non-2xx response + * @return \RadioManager\Model\UserResults */ - public function listUsersAsync($page = '1', $role_id = null) + public function listUsers($page = '1', $role_id = null) { - return $this->listUsersAsyncWithHttpInfo($page, $role_id)->then(function ($response) { - return $response[0]; - }); + list($response) = $this->listUsersWithHttpInfo($page, $role_id); + return $response; } /** - * Operation listUsersAsyncWithHttpInfo + * Operation listUsersWithHttpInfo * * Get all users. * * @param int $page Current page *(Optional)* (optional, default to 1) * @param int $role_id Search on Role ID *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function listUsersAsyncWithHttpInfo($page = '1', $role_id = null) - { - $returnType = '\RadioManager\Model\UserResults'; - $request = $this->listUsersRequest($page, $role_id); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'listUsers' - * - * @param int $page Current page *(Optional)* (optional, default to 1) - * @param int $role_id Search on Role ID *(Optional)* (optional) - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws \RadioManager\ApiException on non-2xx response + * @return array of \RadioManager\Model\UserResults, HTTP status code, HTTP response headers (array of strings) */ - protected function listUsersRequest($page = '1', $role_id = null) + public function listUsersWithHttpInfo($page = '1', $role_id = null) { - if ($page !== null && $page < 0) { + if (!is_null($page) && ($page < 0)) { throw new \InvalidArgumentException('invalid value for "$page" when calling UserApi.listUsers, must be bigger than or equal to 0.'); } - - $resourcePath = '/users'; - $formParams = []; + // parse inputs + $resourcePath = "/users"; + $httpBody = ''; $queryParams = []; $headerParams = []; - $httpBody = ''; - $multipart = false; + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // query params if ($page !== null) { - $queryParams['page'] = ObjectSerializer::toQueryValue($page); + $queryParams['page'] = $this->apiClient->getSerializer()->toQueryValue($page); } // query params if ($role_id !== null) { - $queryParams['role_id'] = ObjectSerializer::toQueryValue($role_id); - } - - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); + $queryParams['role_id'] = $this->apiClient->getSerializer()->toQueryValue($role_id); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } + $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; } + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'GET', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\UserResults', + '/users' + ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\UserResults', $httpHeader), $statusCode, $httpHeader]; + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\UserResults', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 403: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\Forbidden', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 404: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 429: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + } - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + throw $e; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'GET', - $url, - $headers, - $httpBody - ); } - } diff --git a/lib/Api/VisualSlideApi.php b/lib/Api/VisualSlideApi.php index 1d499f9..a8d64dc 100644 --- a/lib/Api/VisualSlideApi.php +++ b/lib/Api/VisualSlideApi.php @@ -28,15 +28,10 @@ namespace RadioManager\Api; -use GuzzleHttp\Client; -use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\Psr7\MultipartStream; -use GuzzleHttp\Psr7\Request; -use RadioManager\ApiException; -use RadioManager\Configuration; -use RadioManager\HeaderSelector; -use RadioManager\ObjectSerializer; +use \RadioManager\ApiClient; +use \RadioManager\ApiException; +use \RadioManager\Configuration; +use \RadioManager\ObjectSerializer; /** * VisualSlideApi Class Doc Comment @@ -49,36 +44,47 @@ class VisualSlideApi { /** - * @var ClientInterface + * API Client + * + * @var \RadioManager\ApiClient instance of the ApiClient */ - protected $client; + protected $apiClient; /** - * @var Configuration + * Constructor + * + * @param \RadioManager\ApiClient|null $apiClient The api client to use */ - protected $config; + public function __construct(\RadioManager\ApiClient $apiClient = null) + { + if ($apiClient === null) { + $apiClient = new ApiClient(); + } + + $this->apiClient = $apiClient; + } /** - * @param ClientInterface $client - * @param Configuration $config - * @param HeaderSelector $selector + * Get API client + * + * @return \RadioManager\ApiClient get the API client */ - public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null - ) { - $this->client = $client ?: new Client(); - $this->config = $config ?: new Configuration(); - $this->headerSelector = $selector ?: new HeaderSelector(); + public function getApiClient() + { + return $this->apiClient; } /** - * @return Configuration + * Set the API client + * + * @param \RadioManager\ApiClient $apiClient set the API client + * + * @return VisualSlideApi */ - public function getConfig() + public function setApiClient(\RadioManager\ApiClient $apiClient) { - return $this->config; + $this->apiClient = $apiClient; + return $this; } /** @@ -87,7 +93,6 @@ public function getConfig() * Get Visual Slide Image as Base64 * * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return \RadioManager\Model\VisualResult */ public function getVisualSlide() @@ -102,207 +107,64 @@ public function getVisualSlide() * Get Visual Slide Image as Base64 * * @throws \RadioManager\ApiException on non-2xx response - * @throws \InvalidArgumentException * @return array of \RadioManager\Model\VisualResult, HTTP status code, HTTP response headers (array of strings) */ public function getVisualSlideWithHttpInfo() { - $returnType = '\RadioManager\Model\VisualResult'; - $request = $this->getVisualSlideRequest(); - - try { - - try { - $response = $this->client->send($request); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - } + // parse inputs + $resourcePath = "/visual"; + $httpBody = ''; + $queryParams = []; + $headerParams = []; + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); - $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() - ]; + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } elseif (count($formParams) > 0) { + $httpBody = $formParams; // for HTTP post (form) + } + // this endpoint requires API key authentication + $apiKey = $this->apiClient->getApiKeyWithPrefix('api-key'); + if (strlen($apiKey) !== 0) { + $headerParams['api-key'] = $apiKey; + } + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'GET', + $queryParams, + $httpBody, + $headerParams, + '\RadioManager\Model\VisualResult', + '/visual' + ); + return [$this->apiClient->getSerializer()->deserialize($response, '\RadioManager\Model\VisualResult', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\VisualResult', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\VisualResult', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\NotFound', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 429: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\RadioManager\Model\TooManyRequests', $e->getResponseHeaders()); $e->setResponseObject($data); break; } - throw $e; - } - } - - /** - * Operation getVisualSlideAsync - * - * Get Visual Slide Image as Base64 - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getVisualSlideAsync() - { - return $this->getVisualSlideAsyncWithHttpInfo()->then(function ($response) { - return $response[0]; - }); - } - - /** - * Operation getVisualSlideAsyncWithHttpInfo - * - * Get Visual Slide Image as Base64 - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getVisualSlideAsyncWithHttpInfo() - { - $returnType = '\RadioManager\Model\VisualResult'; - $request = $this->getVisualSlideRequest(); - - return $this->client->sendAsync($request)->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( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() - ); - }); - } - - /** - * Create request for operation 'getVisualSlide' - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - protected function getVisualSlideRequest() - { - - $resourcePath = '/visual'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - if ($multipart) { - $headers= $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } - - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValue - ]; - } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) - - } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); - - } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) - } - } - - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api-key'); - if ($apiKey !== null) { - $headers['api-key'] = $apiKey; - } - - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + throw $e; } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - return new Request( - 'GET', - $url, - $headers, - $httpBody - ); } - } diff --git a/lib/ApiClient.php b/lib/ApiClient.php new file mode 100644 index 0000000..09ea456 --- /dev/null +++ b/lib/ApiClient.php @@ -0,0 +1,371 @@ +config = $config; + $this->serializer = new ObjectSerializer(); + } + + /** + * Get the config + * + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Get the serializer + * + * @return ObjectSerializer + */ + public function getSerializer() + { + return $this->serializer; + } + + /** + * 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->config->getApiKeyPrefix($apiKeyIdentifier); + $apiKey = $this->config->getApiKey($apiKeyIdentifier); + + if (!isset($apiKey)) { + return null; + } + + if (isset($prefix)) { + $keyWithPrefix = $prefix." ".$apiKey; + } else { + $keyWithPrefix = $apiKey; + } + + return $keyWithPrefix; + } + + /** + * Make the HTTP call (Sync) + * + * @param string $resourcePath path to method endpoint + * @param string $method method to call + * @param array $queryParams parameters to be place in query URL + * @param array $postData parameters to be placed in POST body + * @param array $headerParams parameters to be place in request header + * @param string $responseType expected response type of the endpoint + * @param string $endpointPath path to method endpoint before expanding parameters + * + * @throws \RadioManager\ApiException on a non 2xx response + * @return mixed + */ + public function callApi($resourcePath, $method, $queryParams, $postData, $headerParams, $responseType = null, $endpointPath = null) + { + $headers = []; + + // construct the http header + $headerParams = array_merge( + (array)$this->config->getDefaultHeaders(), + (array)$headerParams + ); + + foreach ($headerParams as $key => $val) { + $headers[] = "$key: $val"; + } + + // form data + if ($postData and in_array('Content-Type: application/x-www-form-urlencoded', $headers, true)) { + $postData = http_build_query($postData); + } elseif ((is_object($postData) or is_array($postData)) and !in_array('Content-Type: multipart/form-data', $headers, true)) { // json model + $postData = json_encode(\RadioManager\ObjectSerializer::sanitizeForSerialization($postData)); + } + + $url = $this->config->getHost() . $resourcePath; + + $curl = curl_init(); + // set timeout, if needed + if ($this->config->getCurlTimeout() !== 0) { + curl_setopt($curl, CURLOPT_TIMEOUT, $this->config->getCurlTimeout()); + } + // set connect timeout, if needed + if ($this->config->getCurlConnectTimeout() != 0) { + curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $this->config->getCurlConnectTimeout()); + } + + // return the result on success, rather than just true + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + + curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); + + // disable SSL verification, if needed + if ($this->config->getSSLVerification() === false) { + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); + } + + if ($this->config->getCurlProxyHost()) { + curl_setopt($curl, CURLOPT_PROXY, $this->config->getCurlProxyHost()); + } + + if ($this->config->getCurlProxyPort()) { + curl_setopt($curl, CURLOPT_PROXYPORT, $this->config->getCurlProxyPort()); + } + + if ($this->config->getCurlProxyType()) { + curl_setopt($curl, CURLOPT_PROXYTYPE, $this->config->getCurlProxyType()); + } + + if ($this->config->getCurlProxyUser()) { + curl_setopt($curl, CURLOPT_PROXYUSERPWD, $this->config->getCurlProxyUser() . ':' .$this->config->getCurlProxyPassword()); + } + + if (!empty($queryParams)) { + $url = ($url . '?' . http_build_query($queryParams)); + } + + if ($this->config->getAllowEncoding()) { + curl_setopt($curl, CURLOPT_ENCODING, ''); + } + + if ($method === self::$POST) { + curl_setopt($curl, CURLOPT_POST, true); + curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); + } elseif ($method === self::$HEAD) { + curl_setopt($curl, CURLOPT_NOBODY, true); + } elseif ($method === self::$OPTIONS) { + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "OPTIONS"); + curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); + } elseif ($method === self::$PATCH) { + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH"); + curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); + } elseif ($method === self::$PUT) { + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT"); + curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); + } elseif ($method === self::$DELETE) { + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE"); + curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); + } elseif ($method !== self::$GET) { + throw new ApiException('Method ' . $method . ' is not recognized.'); + } + curl_setopt($curl, CURLOPT_URL, $url); + + // Set user agent + curl_setopt($curl, CURLOPT_USERAGENT, $this->config->getUserAgent()); + + // debugging for curl + if ($this->config->getDebug()) { + error_log("[DEBUG] HTTP Request body ~BEGIN~".PHP_EOL.print_r($postData, true).PHP_EOL."~END~".PHP_EOL, 3, $this->config->getDebugFile()); + + curl_setopt($curl, CURLOPT_VERBOSE, 1); + curl_setopt($curl, CURLOPT_STDERR, fopen($this->config->getDebugFile(), 'a')); + } else { + curl_setopt($curl, CURLOPT_VERBOSE, 0); + } + + // obtain the HTTP response headers + curl_setopt($curl, CURLOPT_HEADER, 1); + + // Make the request + $response = curl_exec($curl); + $http_header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE); + $http_header = $this->httpParseHeaders(substr($response, 0, $http_header_size)); + $http_body = substr($response, $http_header_size); + $response_info = curl_getinfo($curl); + + // debug HTTP response body + if ($this->config->getDebug()) { + error_log("[DEBUG] HTTP Response body ~BEGIN~".PHP_EOL.print_r($http_body, true).PHP_EOL."~END~".PHP_EOL, 3, $this->config->getDebugFile()); + } + + // Handle the response + if ($response_info['http_code'] === 0) { + $curl_error_message = curl_error($curl); + + // curl_exec can sometimes fail but still return a blank message from curl_error(). + if (!empty($curl_error_message)) { + $error_message = "API call to $url failed: $curl_error_message"; + } else { + $error_message = "API call to $url failed, but for an unknown reason. " . + "This could happen if you are disconnected from the network."; + } + + $exception = new ApiException($error_message, 0, null, null); + $exception->setResponseObject($response_info); + throw $exception; + } elseif ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299) { + // return raw body if response is a file + if ($responseType === '\SplFileObject' || $responseType === 'string') { + return [$http_body, $response_info['http_code'], $http_header]; + } + + $data = json_decode($http_body); + if (json_last_error() > 0) { // if response is a string + $data = $http_body; + } + } else { + $data = json_decode($http_body); + if (json_last_error() > 0) { // if response is a string + $data = $http_body; + } + + throw new ApiException( + "[".$response_info['http_code']."] Error connecting to the API ($url)", + $response_info['http_code'], + $http_header, + $data + ); + } + return [$data, $response_info['http_code'], $http_header]; + } + + /** + * Return the header 'Accept' based on an array of Accept provided + * + * @param string[] $accept Array of header + * + * @return string Accept (e.g. application/json) + */ + public function selectHeaderAccept($accept) + { + if (count($accept) === 0 or (count($accept) === 1 and $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[] $content_type Array fo content-type + * + * @return string Content-Type (e.g. application/json) + */ + public function selectHeaderContentType($content_type) + { + if (count($content_type) === 0 or (count($content_type) === 1 and $content_type[0] === '')) { + return 'application/json'; + } elseif (preg_grep("/application\/json/i", $content_type)) { + return 'application/json'; + } else { + return implode(',', $content_type); + } + } + + /** + * Return an array of HTTP response headers + * + * @param string $raw_headers A string of raw HTTP response headers + * + * @return string[] Array of HTTP response heaers + */ + protected function httpParseHeaders($raw_headers) + { + // ref/credit: http://php.net/manual/en/function.http-parse-headers.php#112986 + $headers = []; + $key = ''; + + foreach (explode("\n", $raw_headers) as $h) { + $h = explode(':', $h, 2); + + if (isset($h[1])) { + if (!isset($headers[$h[0]])) { + $headers[$h[0]] = trim($h[1]); + } elseif (is_array($headers[$h[0]])) { + $headers[$h[0]] = array_merge($headers[$h[0]], [trim($h[1])]); + } else { + $headers[$h[0]] = array_merge([$headers[$h[0]]], [trim($h[1])]); + } + + $key = $h[0]; + } else { + if (substr($h[0], 0, 1) === "\t") { + $headers[$key] .= "\r\n\t".trim($h[0]); + } elseif (!$key) { + $headers[0] = trim($h[0]); + } + trim($h[0]); + } + } + + return $headers; + } +} diff --git a/lib/ApiException.php b/lib/ApiException.php index 9b0b5bb..fdae2d7 100644 --- a/lib/ApiException.php +++ b/lib/ApiException.php @@ -51,7 +51,7 @@ class ApiException extends Exception /** * The HTTP header of the server response. * - * @var string[]|null + * @var string[] */ protected $responseHeaders; @@ -65,10 +65,10 @@ class ApiException extends Exception /** * Constructor * - * @param string $message Error message - * @param int $code HTTP status code - * @param string[]|null $responseHeaders HTTP response header - * @param mixed $responseBody HTTP decoded body of the server response either as \stdClass or string + * @param string $message Error message + * @param int $code HTTP status code + * @param string[] $responseHeaders HTTP response header + * @param mixed $responseBody HTTP decoded body of the server response either as \stdClass or string */ public function __construct($message = "", $code = 0, $responseHeaders = [], $responseBody = null) { @@ -80,7 +80,7 @@ public function __construct($message = "", $code = 0, $responseHeaders = [], $re /** * Gets the HTTP response header * - * @return string[]|null HTTP response header + * @return string[] HTTP response headers */ public function getResponseHeaders() { diff --git a/lib/Configuration.php b/lib/Configuration.php index 28e4922..9c0e8f3 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -76,6 +76,13 @@ class Configuration */ protected $password = ''; + /** + * The default header(s) + * + * @var array + */ + protected $defaultHeaders = []; + /** * The host * @@ -83,6 +90,20 @@ class Configuration */ protected $host = 'https://staging.radiomanager.pluxbox.com/api/v2'; + /** + * Timeout (second) of the HTTP request, by default set to 0, no timeout + * + * @var string + */ + protected $curlTimeout = 0; + + /** + * Timeout (second) of the HTTP connection, by default set to 0, no timeout + * + * @var string + */ + protected $curlConnectTimeout = 0; + /** * User agent of the HTTP request, set to "PHP-Swagger" by default * @@ -111,6 +132,58 @@ class Configuration */ protected $tempFolderPath; + /** + * Indicates if SSL verification should be enabled or disabled. + * + * This is useful if the host uses a self-signed SSL certificate. + * + * @var boolean True if the certificate should be validated, false otherwise. + */ + protected $sslVerification = true; + + /** + * Curl proxy host + * + * @var string + */ + protected $proxyHost; + + /** + * Curl proxy port + * + * @var integer + */ + protected $proxyPort; + + /** + * Curl proxy type, e.g. CURLPROXY_HTTP or CURLPROXY_SOCKS5 + * + * @see https://secure.php.net/manual/en/function.curl-setopt.php + * @var integer + */ + protected $proxyType; + + /** + * Curl proxy username + * + * @var string + */ + protected $proxyUser; + + /** + * Curl proxy password + * + * @var string + */ + protected $proxyPassword; + + /** + * Allow Curl encoding header + * + * @var bool + */ + protected $allowEncoding = false; + /** * Constructor */ @@ -240,6 +313,48 @@ public function getPassword() return $this->password; } + /** + * Adds a default header + * + * @param string $headerName header name (e.g. Token) + * @param string $headerValue header value (e.g. 1z8wp3) + * + * @throws \InvalidArgumentException + * @return $this + */ + public function addDefaultHeader($headerName, $headerValue) + { + if (!is_string($headerName)) { + throw new \InvalidArgumentException('Header name must be a string.'); + } + + $this->defaultHeaders[$headerName] = $headerValue; + return $this; + } + + /** + * Gets the default header + * + * @return array An array of default header(s) + */ + public function getDefaultHeaders() + { + return $this->defaultHeaders; + } + + /** + * Deletes a default header + * + * @param string $headerName the header to delete + * + * @return $this + */ + public function deleteDefaultHeader($headerName) + { + unset($this->defaultHeaders[$headerName]); + return $this; + } + /** * Sets the host * @@ -291,6 +406,199 @@ public function getUserAgent() return $this->userAgent; } + /** + * Sets the HTTP timeout value + * + * @param integer $seconds Number of seconds before timing out [set to 0 for no timeout] + * + * @throws \InvalidArgumentException + * @return $this + */ + public function setCurlTimeout($seconds) + { + if (!is_numeric($seconds) || $seconds < 0) { + throw new \InvalidArgumentException('Timeout value must be numeric and a non-negative number.'); + } + + $this->curlTimeout = $seconds; + return $this; + } + + /** + * Gets the HTTP timeout value + * + * @return string HTTP timeout value + */ + public function getCurlTimeout() + { + return $this->curlTimeout; + } + + /** + * Sets the HTTP connect timeout value + * + * @param integer $seconds Number of seconds before connection times out [set to 0 for no timeout] + * + * @throws \InvalidArgumentException + * @return $this + */ + public function setCurlConnectTimeout($seconds) + { + if (!is_numeric($seconds) || $seconds < 0) { + throw new \InvalidArgumentException('Connect timeout value must be numeric and a non-negative number.'); + } + + $this->curlConnectTimeout = $seconds; + return $this; + } + + /** + * Set whether to accept encoding + * @param bool $allowEncoding + * + * @return $this + */ + public function setAllowEncoding($allowEncoding) + { + $this->allowEncoding = $allowEncoding; + return $this; + } + + /** + * Gets the HTTP connect timeout value + * + * @return string HTTP connect timeout value + */ + public function getCurlConnectTimeout() + { + return $this->curlConnectTimeout; + } + + /** + * Get whether to allow encoding + * + * @return bool + */ + public function getAllowEncoding() + { + return $this->allowEncoding; + } + + /** + * Sets the HTTP Proxy Host + * + * @param string $proxyHost HTTP Proxy URL + * + * @return $this + */ + public function setCurlProxyHost($proxyHost) + { + $this->proxyHost = $proxyHost; + return $this; + } + + /** + * Gets the HTTP Proxy Host + * + * @return string + */ + public function getCurlProxyHost() + { + return $this->proxyHost; + } + + /** + * Sets the HTTP Proxy Port + * + * @param integer $proxyPort HTTP Proxy Port + * + * @return $this + */ + public function setCurlProxyPort($proxyPort) + { + $this->proxyPort = $proxyPort; + return $this; + } + + /** + * Gets the HTTP Proxy Port + * + * @return integer + */ + public function getCurlProxyPort() + { + return $this->proxyPort; + } + + /** + * Sets the HTTP Proxy Type + * + * @param integer $proxyType HTTP Proxy Type + * + * @return $this + */ + public function setCurlProxyType($proxyType) + { + $this->proxyType = $proxyType; + return $this; + } + + /** + * Gets the HTTP Proxy Type + * + * @return integer + */ + public function getCurlProxyType() + { + return $this->proxyType; + } + + /** + * Sets the HTTP Proxy User + * + * @param string $proxyUser HTTP Proxy User + * + * @return $this + */ + public function setCurlProxyUser($proxyUser) + { + $this->proxyUser = $proxyUser; + return $this; + } + + /** + * Gets the HTTP Proxy User + * + * @return string + */ + public function getCurlProxyUser() + { + return $this->proxyUser; + } + + /** + * Sets the HTTP Proxy Password + * + * @param string $proxyPassword HTTP Proxy Password + * + * @return $this + */ + public function setCurlProxyPassword($proxyPassword) + { + $this->proxyPassword = $proxyPassword; + return $this; + } + + /** + * Gets the HTTP Proxy Password + * + * @return string + */ + public function getCurlProxyPassword() + { + return $this->proxyPassword; + } + /** * Sets debug flag * @@ -360,6 +668,29 @@ public function getTempFolderPath() return $this->tempFolderPath; } + /** + * Sets if SSL verification should be enabled or disabled + * + * @param boolean $sslVerification True if the certificate should be validated, false otherwise + * + * @return $this + */ + public function setSSLVerification($sslVerification) + { + $this->sslVerification = $sslVerification; + return $this; + } + + /** + * Gets if SSL verification should be enabled or disabled + * + * @return boolean True if the certificate should be validated, false otherwise + */ + public function getSSLVerification() + { + return $this->sslVerification; + } + /** * Gets the default configuration instance * @@ -401,29 +732,4 @@ public static function toDebugReport() 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 deleted file mode 100644 index 225d2f5..0000000 --- a/lib/HeaderSelector.php +++ /dev/null @@ -1,110 +0,0 @@ -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/ObjectSerializer.php b/lib/ObjectSerializer.php index e7b538a..da4876e 100644 --- a/lib/ObjectSerializer.php +++ b/lib/ObjectSerializer.php @@ -105,9 +105,9 @@ public static function sanitizeFilename($filename) * * @return string the serialized object */ - public static function toPathValue($value) + public function toPathValue($value) { - return rawurlencode(self::toString($value)); + return rawurlencode($this->toString($value)); } /** @@ -120,12 +120,12 @@ public static function toPathValue($value) * * @return string the serialized object */ - public static function toQueryValue($object) + public function toQueryValue($object) { if (is_array($object)) { return implode(',', $object); } else { - return self::toString($object); + return $this->toString($object); } } @@ -138,9 +138,9 @@ public static function toQueryValue($object) * * @return string the header string */ - public static function toHeaderValue($value) + public function toHeaderValue($value) { - return self::toString($value); + return $this->toString($value); } /** @@ -152,12 +152,12 @@ public static function toHeaderValue($value) * * @return string the form string */ - public static function toFormValue($value) + public function toFormValue($value) { if ($value instanceof \SplFileObject) { return $value->getRealPath(); } else { - return self::toString($value); + return $this->toString($value); } } @@ -170,7 +170,7 @@ public static function toFormValue($value) * * @return string the header string */ - public static function toString($value) + public function toString($value) { if ($value instanceof \DateTime) { // datetime in ISO8601 format return $value->format(\DateTime::ATOM); @@ -189,7 +189,7 @@ public static function toString($value) * * @return string */ - public static function serializeCollection(array $collection, $collectionFormat, $allowCollectionFormatMulti = false) + public function serializeCollection(array $collection, $collectionFormat, $allowCollectionFormatMulti = false) { if ($allowCollectionFormatMulti && ('multi' === $collectionFormat)) { // http_build_query() almost does the job for us. We just @@ -264,8 +264,6 @@ public static function deserialize($data, $class, $httpHeaders = null) 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)) { @@ -273,14 +271,13 @@ public static function deserialize($data, $class, $httpHeaders = null) } else { $filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), ''); } - - $file = fopen($filename, 'w'); - while ($chunk = $data->read(200)) { - fwrite($file, $chunk); + $deserialized = new \SplFileObject($filename, "w"); + $byte_written = $deserialized->fwrite($data); + if (Configuration::getDefaultConfiguration()->getDebug()) { + error_log("[DEBUG] Written $byte_written byte to $filename. Please move the file to a proper folder or delete the temp file after processing.".PHP_EOL, 3, Configuration::getDefaultConfiguration()->getDebugFile()); } - fclose($file); - return new \SplFileObject($filename, 'r'); + return $deserialized; } elseif (method_exists($class, 'getAllowableEnumValues')) { if (!in_array($data, $class::getAllowableEnumValues())) { $imploded = implode("', '", $class::getAllowableEnumValues()); diff --git a/test/Api/BlockApiTest.php b/test/Api/BlockApiTest.php index b546770..0c03656 100644 --- a/test/Api/BlockApiTest.php +++ b/test/Api/BlockApiTest.php @@ -29,6 +29,7 @@ namespace RadioManager; use \RadioManager\Configuration; +use \RadioManager\ApiClient; use \RadioManager\ApiException; use \RadioManager\ObjectSerializer; diff --git a/test/Api/BroadcastApiTest.php b/test/Api/BroadcastApiTest.php index c3b1854..cef1896 100644 --- a/test/Api/BroadcastApiTest.php +++ b/test/Api/BroadcastApiTest.php @@ -29,6 +29,7 @@ namespace RadioManager; use \RadioManager\Configuration; +use \RadioManager\ApiClient; use \RadioManager\ApiException; use \RadioManager\ObjectSerializer; diff --git a/test/Api/CampaignApiTest.php b/test/Api/CampaignApiTest.php index 4135de8..2a7a595 100644 --- a/test/Api/CampaignApiTest.php +++ b/test/Api/CampaignApiTest.php @@ -29,6 +29,7 @@ namespace RadioManager; use \RadioManager\Configuration; +use \RadioManager\ApiClient; use \RadioManager\ApiException; use \RadioManager\ObjectSerializer; diff --git a/test/Api/ContactApiTest.php b/test/Api/ContactApiTest.php index 8720d5f..2bcf265 100644 --- a/test/Api/ContactApiTest.php +++ b/test/Api/ContactApiTest.php @@ -29,6 +29,7 @@ namespace RadioManager; use \RadioManager\Configuration; +use \RadioManager\ApiClient; use \RadioManager\ApiException; use \RadioManager\ObjectSerializer; diff --git a/test/Api/ExternalMessageApiTest.php b/test/Api/ExternalMessageApiTest.php index 7aefc35..4e38de8 100644 --- a/test/Api/ExternalMessageApiTest.php +++ b/test/Api/ExternalMessageApiTest.php @@ -29,6 +29,7 @@ namespace RadioManager; use \RadioManager\Configuration; +use \RadioManager\ApiClient; use \RadioManager\ApiException; use \RadioManager\ObjectSerializer; diff --git a/test/Api/GenreApiTest.php b/test/Api/GenreApiTest.php index 02725ed..3fff553 100644 --- a/test/Api/GenreApiTest.php +++ b/test/Api/GenreApiTest.php @@ -29,6 +29,7 @@ namespace RadioManager; use \RadioManager\Configuration; +use \RadioManager\ApiClient; use \RadioManager\ApiException; use \RadioManager\ObjectSerializer; diff --git a/test/Api/ItemApiTest.php b/test/Api/ItemApiTest.php index 622b17f..d31f83c 100644 --- a/test/Api/ItemApiTest.php +++ b/test/Api/ItemApiTest.php @@ -29,6 +29,7 @@ namespace RadioManager; use \RadioManager\Configuration; +use \RadioManager\ApiClient; use \RadioManager\ApiException; use \RadioManager\ObjectSerializer; diff --git a/test/Api/ModelTypeApiTest.php b/test/Api/ModelTypeApiTest.php index 81fef01..74d718e 100644 --- a/test/Api/ModelTypeApiTest.php +++ b/test/Api/ModelTypeApiTest.php @@ -29,6 +29,7 @@ namespace RadioManager; use \RadioManager\Configuration; +use \RadioManager\ApiClient; use \RadioManager\ApiException; use \RadioManager\ObjectSerializer; diff --git a/test/Api/PresenterApiTest.php b/test/Api/PresenterApiTest.php index e96bca7..008014f 100644 --- a/test/Api/PresenterApiTest.php +++ b/test/Api/PresenterApiTest.php @@ -29,6 +29,7 @@ namespace RadioManager; use \RadioManager\Configuration; +use \RadioManager\ApiClient; use \RadioManager\ApiException; use \RadioManager\ObjectSerializer; diff --git a/test/Api/ProgramApiTest.php b/test/Api/ProgramApiTest.php index 9a31736..8a425b7 100644 --- a/test/Api/ProgramApiTest.php +++ b/test/Api/ProgramApiTest.php @@ -29,6 +29,7 @@ namespace RadioManager; use \RadioManager\Configuration; +use \RadioManager\ApiClient; use \RadioManager\ApiException; use \RadioManager\ObjectSerializer; diff --git a/test/Api/StoryApiTest.php b/test/Api/StoryApiTest.php index 224e407..a8d979a 100644 --- a/test/Api/StoryApiTest.php +++ b/test/Api/StoryApiTest.php @@ -29,6 +29,7 @@ namespace RadioManager; use \RadioManager\Configuration; +use \RadioManager\ApiClient; use \RadioManager\ApiException; use \RadioManager\ObjectSerializer; diff --git a/test/Api/StringApiTest.php b/test/Api/StringApiTest.php index 64ad8cc..4a17036 100644 --- a/test/Api/StringApiTest.php +++ b/test/Api/StringApiTest.php @@ -29,6 +29,7 @@ namespace RadioManager; use \RadioManager\Configuration; +use \RadioManager\ApiClient; use \RadioManager\ApiException; use \RadioManager\ObjectSerializer; diff --git a/test/Api/TagApiTest.php b/test/Api/TagApiTest.php index 8a80e67..3d2c6d8 100644 --- a/test/Api/TagApiTest.php +++ b/test/Api/TagApiTest.php @@ -29,6 +29,7 @@ namespace RadioManager; use \RadioManager\Configuration; +use \RadioManager\ApiClient; use \RadioManager\ApiException; use \RadioManager\ObjectSerializer; diff --git a/test/Api/UserApiTest.php b/test/Api/UserApiTest.php index 9c65cfd..cc3e567 100644 --- a/test/Api/UserApiTest.php +++ b/test/Api/UserApiTest.php @@ -29,6 +29,7 @@ namespace RadioManager; use \RadioManager\Configuration; +use \RadioManager\ApiClient; use \RadioManager\ApiException; use \RadioManager\ObjectSerializer; diff --git a/test/Api/VisualSlideApiTest.php b/test/Api/VisualSlideApiTest.php index bedf5e2..a03fcec 100644 --- a/test/Api/VisualSlideApiTest.php +++ b/test/Api/VisualSlideApiTest.php @@ -29,6 +29,7 @@ namespace RadioManager; use \RadioManager\Configuration; +use \RadioManager\ApiClient; use \RadioManager\ApiException; use \RadioManager\ObjectSerializer;