diff --git a/.openapi-generator-ignore b/.openapi-generator-ignore new file mode 100644 index 0000000..7484ee5 --- /dev/null +++ b/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/.openapi-generator/VERSION b/.openapi-generator/VERSION new file mode 100644 index 0000000..f9dfe82 --- /dev/null +++ b/.openapi-generator/VERSION @@ -0,0 +1 @@ +4.0.0-beta2 \ No newline at end of file diff --git a/.php_cs b/.php_cs new file mode 100644 index 0000000..4fbe53e --- /dev/null +++ b/.php_cs @@ -0,0 +1,23 @@ +setUsingCache(true) + ->setRules([ + '@PSR2' => true, + 'ordered_imports' => true, + 'phpdoc_order' => true, + 'array_syntax' => [ 'syntax' => 'short' ], + 'strict_comparison' => true, + 'strict_param' => true, + 'no_trailing_whitespace' => false, + 'no_trailing_whitespace_in_comment' => false, + 'braces' => false, + 'single_blank_line_at_eof' => false, + 'blank_line_after_namespace' => false, + ]) + ->setFinder( + PhpCsFixer\Finder::create() + ->exclude('test') + ->exclude('tests') + ->in(__DIR__) + ); diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..d77f382 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,10 @@ +language: php +sudo: false +php: + - 5.4 + - 5.5 + - 5.6 + - 7.0 + - hhvm +before_install: "composer install" +script: "vendor/bin/phpunit" diff --git a/README.md b/README.md index 487396e..c51ce4f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,125 @@ -# messente-api-php -Messente public API libraries merged into one PHP library +# Messente API Library + +- Messente API version: 1.0.0 +- PHP artifact version: 1.0.0 + +[Messente](https://messente.com) is a global provider of messaging and user verification services. Use Messente API library to send and receive SMS, Viber and WhatsApp messages, blacklist phone numbers to make sure you're not sending any unwanted messages, manage contacts and groups. Messente builds [tools](https://messente.com/documentation) to help organizations connect their services to people anywhere in the world. + +## Installation + +Install Messente API library with `composer require messente/messente-api-php`. + +## Features + +Messente API has the following features: + +- Omnichannel ([external docs](https://messente.com/documentation/omnichannel-api)), +- Phonebook ([external docs](https://messente.com/documentation/phonebook-api)). + +Messente API Library provides the operations described below to access the features. + +### BlacklistApi + +1. Adds a phone number to the blacklist. [`addToBlacklist`](docs/Api/BlacklistApi.md#addtoblacklist) +1. Deletes a phone number from the blacklist. [`deleteFromBlacklist`](docs/Api/BlacklistApi.md#deletefromblacklist) +1. Returns all blacklisted phone numbers. [`fetchBlacklist`](docs/Api/BlacklistApi.md#fetchblacklist) +1. Checks if a phone number is blacklisted. [`isBlacklisted`](docs/Api/BlacklistApi.md#isblacklisted) + +### ContactsApi + +1. Adds a contact to a group. [`addContactToGroup`](docs/Api/ContactsApi.md#addcontacttogroup) +1. Creates a new contact. [`createContact`](docs/Api/ContactsApi.md#createcontact) +1. Deletes a contact. [`deleteContact`](docs/Api/ContactsApi.md#deletecontact) +1. Lists a contact. [`fetchContact`](docs/Api/ContactsApi.md#fetchcontact) +1. Lists groups of a contact. [`fetchContactGroups`](docs/Api/ContactsApi.md#fetchcontactgroups) +1. Returns all contacts. [`fetchContacts`](docs/Api/ContactsApi.md#fetchcontacts) +1. Removes a contact from a group. [`removeContactFromGroup`](docs/Api/ContactsApi.md#removecontactfromgroup) +1. Updates a contact. [`updateContact`](docs/Api/ContactsApi.md#updatecontact) + +### DeliveryReportApi + +1. Retrieves the delivery report for the Omnimessage. [`retrieveDeliveryReport`](docs/Api/DeliveryReportApi.md#retrievedeliveryreport) + +### GroupsApi + +1. Creates a new group with the provided name. [`createGroup`](docs/Api/GroupsApi.md#creategroup) +1. Deletes a group. [`deleteGroup`](docs/Api/GroupsApi.md#deletegroup) +1. Lists a group. [`fetchGroup`](docs/Api/GroupsApi.md#fetchgroup) +1. Returns all groups. [`fetchGroups`](docs/Api/GroupsApi.md#fetchgroups) +1. Updates a group with the provided name. [`updateGroup`](docs/Api/GroupsApi.md#updategroup) + +### OmnimessageApi + +1. Cancels a scheduled Omnimessage. [`cancelScheduledMessage`](docs/Api/OmnimessageApi.md#cancelscheduledmessage) +1. Sends an Omnimessage. [`sendOmnimessage`](docs/Api/OmnimessageApi.md#sendomnimessage) + +## Auth + +**Type**: HTTP basic authentication + +Read the [external getting-started article](https://messente.com/documentation/getting-started) which explains API keys and Sender ID logic. + +## Getting started: sending an omnimessage + +```php +setUsername('') + ->setPassword(''); + +$apiInstance = new OmnimessageApi( + new GuzzleHttp\Client(), + $config +); + +$omnimessage = new Omnimessage([ + "to" => "" +]); + +$viber = new Viber( + ["text" => "Hello Viber!", "sender" => "MyViberSender"] +); + +$sms = new SMS( + ["text" => "Hello SMS!", "sender" => "MySmsSender"] +); + + +$whatsAppText = new WhatsAppText(["body" => "Hello WhatsApp!"]); + +$whatsapp = new WhatsApp( + ['text' => $whatsAppText, "sender" => "MyWhatsAppSender"] +); + +$omnimessage->setMessages([$whatsapp, $viber, $sms]); + + +try { + $result = $apiInstance->sendOmnimessage($omnimessage); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling sendOmnimessage: ', $e->getMessage(), PHP_EOL; +} +?> + +``` + +## License + +[Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) + +## Terms + +[https://messente.com/terms-and-conditions](https://messente.com/terms-and-conditions) diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..570d92e --- /dev/null +++ b/composer.json @@ -0,0 +1,38 @@ +{ + "name": "messente/messente-api-php", + "version": "1.0.0", + "description": "[Messente](https://messente.com) is a global provider of messaging and user verification services. Use Messente API library to send and receive SMS, Viber and WhatsApp messages, blacklist phone numbers to make sure you're not sending any unwanted messages, manage contacts and groups. Messente builds [tools](https://messente.com/documentation) to help organizations connect their services to people anywhere in the world.", + "keywords": ["viber", "sms", "whatsapp", "phonebook", "openapitools", + "openapi-generator", + "php", + "sdk", + "rest", + "api" + ], + "homepage": "https://messente.com", + "license": "proprietary", + "authors": [ + { + "name": "Messente", + "homepage": "https://messente.com" + } + ], + "require": { + "php": ">=7.1", + "ext-curl": "*", + "ext-json": "*", + "ext-mbstring": "*", + "guzzlehttp/guzzle": "^6.2" + }, + "require-dev": { + "phpunit/phpunit": "^7.4", + "squizlabs/php_codesniffer": "~2.6", + "friendsofphp/php-cs-fixer": "~2.12" + }, + "autoload": { + "psr-4": { "Messente\\Api\\" : "lib/" } + }, + "autoload-dev": { + "psr-4": { "Messente\\Api\\" : "test/" } + } +} diff --git a/docs/Api/BlacklistApi.md b/docs/Api/BlacklistApi.md new file mode 100644 index 0000000..dd13323 --- /dev/null +++ b/docs/Api/BlacklistApi.md @@ -0,0 +1,221 @@ +# Messente\Api\BlacklistApi + +All URIs are relative to *https://api.messente.com/v1* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**addToBlacklist**](BlacklistApi.md#addToBlacklist) | **POST** /phonebook/blacklist | Adds a phone number to the blacklist. +[**deleteFromBlacklist**](BlacklistApi.md#deleteFromBlacklist) | **DELETE** /blacklist/{phone} | Deletes a phone number from the blacklist. +[**fetchBlacklist**](BlacklistApi.md#fetchBlacklist) | **GET** /phonebook/blacklist | Returns all blacklisted phone numbers. +[**isBlacklisted**](BlacklistApi.md#isBlacklisted) | **GET** /blacklist/{phone} | Checks if a phone number is blacklisted. + + +# **addToBlacklist** +> addToBlacklist($numberToBlacklist) + +Adds a phone number to the blacklist. + +### Example +```php +setUsername('YOUR_USERNAME') + ->setPassword('YOUR_PASSWORD'); + + +$apiInstance = new Messente\Api\Api\BlacklistApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$numberToBlacklist = new \Messente\Api\Model\NumberToBlacklist(); // \Messente\Api\Model\NumberToBlacklist | Phone number to be blacklisted + +try { + $apiInstance->addToBlacklist($numberToBlacklist); +} catch (Exception $e) { + echo 'Exception when calling BlacklistApi->addToBlacklist: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **numberToBlacklist** | [**\Messente\Api\Model\NumberToBlacklist**](../Model/NumberToBlacklist.md)| Phone number to be blacklisted | + +### Return type + +void (empty response body) + +### Authorization + +[basicAuth](../../README.md#basicAuth) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **deleteFromBlacklist** +> deleteFromBlacklist($phone) + +Deletes a phone number from the blacklist. + +### Example +```php +setUsername('YOUR_USERNAME') + ->setPassword('YOUR_PASSWORD'); + + +$apiInstance = new Messente\Api\Api\BlacklistApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$phone = 'phone_example'; // string | A phone number + +try { + $apiInstance->deleteFromBlacklist($phone); +} catch (Exception $e) { + echo 'Exception when calling BlacklistApi->deleteFromBlacklist: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **phone** | **string**| A phone number | + +### Return type + +void (empty response body) + +### Authorization + +[basicAuth](../../README.md#basicAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **fetchBlacklist** +> \Messente\Api\Model\FetchBlacklistSuccess fetchBlacklist() + +Returns all blacklisted phone numbers. + +### Example +```php +setUsername('YOUR_USERNAME') + ->setPassword('YOUR_PASSWORD'); + + +$apiInstance = new Messente\Api\Api\BlacklistApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); + +try { + $result = $apiInstance->fetchBlacklist(); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling BlacklistApi->fetchBlacklist: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**\Messente\Api\Model\FetchBlacklistSuccess**](../Model/FetchBlacklistSuccess.md) + +### Authorization + +[basicAuth](../../README.md#basicAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **isBlacklisted** +> isBlacklisted($phone) + +Checks if a phone number is blacklisted. + +### Example +```php +setUsername('YOUR_USERNAME') + ->setPassword('YOUR_PASSWORD'); + + +$apiInstance = new Messente\Api\Api\BlacklistApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$phone = 'phone_example'; // string | A phone number + +try { + $apiInstance->isBlacklisted($phone); +} catch (Exception $e) { + echo 'Exception when calling BlacklistApi->isBlacklisted: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **phone** | **string**| A phone number | + +### Return type + +void (empty response body) + +### Authorization + +[basicAuth](../../README.md#basicAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/docs/Api/ContactsApi.md b/docs/Api/ContactsApi.md new file mode 100644 index 0000000..5f7e65b --- /dev/null +++ b/docs/Api/ContactsApi.md @@ -0,0 +1,452 @@ +# Messente\Api\ContactsApi + +All URIs are relative to *https://api.messente.com/v1* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**addContactToGroup**](ContactsApi.md#addContactToGroup) | **POST** /groups/{groupId}/contacts/{phone} | Adds a contact to a group. +[**createContact**](ContactsApi.md#createContact) | **POST** /contacts | Creates a new contact. +[**deleteContact**](ContactsApi.md#deleteContact) | **DELETE** /contacts/{phone} | Deletes a contact. +[**fetchContact**](ContactsApi.md#fetchContact) | **GET** /contacts/{phone} | Lists a contact. +[**fetchContactGroups**](ContactsApi.md#fetchContactGroups) | **GET** /contacts/{phone}/groups | Lists groups of a contact. +[**fetchContacts**](ContactsApi.md#fetchContacts) | **GET** /contacts | Returns all contacts. +[**removeContactFromGroup**](ContactsApi.md#removeContactFromGroup) | **DELETE** /groups/{groupId}/contacts/{phone} | Removes a contact from a group. +[**updateContact**](ContactsApi.md#updateContact) | **PATCH** /contacts/{phone} | Updates a contact. + + +# **addContactToGroup** +> object addContactToGroup($groupId, $phone) + +Adds a contact to a group. + +### Example +```php +setUsername('YOUR_USERNAME') + ->setPassword('YOUR_PASSWORD'); + + +$apiInstance = new Messente\Api\Api\ContactsApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$groupId = 'groupId_example'; // string | String in uuid format. +$phone = 'phone_example'; // string | A phone number + +try { + $result = $apiInstance->addContactToGroup($groupId, $phone); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling ContactsApi->addContactToGroup: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **groupId** | **string**| String in uuid format. | + **phone** | **string**| A phone number | + +### Return type + +**object** + +### Authorization + +[basicAuth](../../README.md#basicAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **createContact** +> \Messente\Api\Model\ContactEnvelope createContact($contactFields) + +Creates a new contact. + +### Example +```php +setUsername('YOUR_USERNAME') + ->setPassword('YOUR_PASSWORD'); + + +$apiInstance = new Messente\Api\Api\ContactsApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$contactFields = new \Messente\Api\Model\ContactFields(); // \Messente\Api\Model\ContactFields | + +try { + $result = $apiInstance->createContact($contactFields); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling ContactsApi->createContact: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **contactFields** | [**\Messente\Api\Model\ContactFields**](../Model/ContactFields.md)| | + +### Return type + +[**\Messente\Api\Model\ContactEnvelope**](../Model/ContactEnvelope.md) + +### Authorization + +[basicAuth](../../README.md#basicAuth) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **deleteContact** +> deleteContact($phone) + +Deletes a contact. + +### Example +```php +setUsername('YOUR_USERNAME') + ->setPassword('YOUR_PASSWORD'); + + +$apiInstance = new Messente\Api\Api\ContactsApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$phone = 'phone_example'; // string | A phone number + +try { + $apiInstance->deleteContact($phone); +} catch (Exception $e) { + echo 'Exception when calling ContactsApi->deleteContact: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **phone** | **string**| A phone number | + +### Return type + +void (empty response body) + +### Authorization + +[basicAuth](../../README.md#basicAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **fetchContact** +> \Messente\Api\Model\ContactEnvelope fetchContact($phone) + +Lists a contact. + +### Example +```php +setUsername('YOUR_USERNAME') + ->setPassword('YOUR_PASSWORD'); + + +$apiInstance = new Messente\Api\Api\ContactsApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$phone = 'phone_example'; // string | A phone number + +try { + $result = $apiInstance->fetchContact($phone); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling ContactsApi->fetchContact: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **phone** | **string**| A phone number | + +### Return type + +[**\Messente\Api\Model\ContactEnvelope**](../Model/ContactEnvelope.md) + +### Authorization + +[basicAuth](../../README.md#basicAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **fetchContactGroups** +> \Messente\Api\Model\GroupListEnvelope fetchContactGroups($phone) + +Lists groups of a contact. + +### Example +```php +setUsername('YOUR_USERNAME') + ->setPassword('YOUR_PASSWORD'); + + +$apiInstance = new Messente\Api\Api\ContactsApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$phone = 'phone_example'; // string | A phone number + +try { + $result = $apiInstance->fetchContactGroups($phone); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling ContactsApi->fetchContactGroups: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **phone** | **string**| A phone number | + +### Return type + +[**\Messente\Api\Model\GroupListEnvelope**](../Model/GroupListEnvelope.md) + +### Authorization + +[basicAuth](../../README.md#basicAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **fetchContacts** +> \Messente\Api\Model\ContactListEnvelope fetchContacts($groupIds) + +Returns all contacts. + +### Example +```php +setUsername('YOUR_USERNAME') + ->setPassword('YOUR_PASSWORD'); + + +$apiInstance = new Messente\Api\Api\ContactsApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$groupIds = array('groupIds_example'); // string[] | Optional one or many group id strings in uuid format. For example: \"/contacts?groupIds=group_id_one&groupIds=group_id_two\" + +try { + $result = $apiInstance->fetchContacts($groupIds); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling ContactsApi->fetchContacts: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **groupIds** | [**string[]**](../Model/string.md)| Optional one or many group id strings in uuid format. For example: \"/contacts?groupIds=group_id_one&groupIds=group_id_two\" | [optional] + +### Return type + +[**\Messente\Api\Model\ContactListEnvelope**](../Model/ContactListEnvelope.md) + +### Authorization + +[basicAuth](../../README.md#basicAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **removeContactFromGroup** +> removeContactFromGroup($groupId, $phone) + +Removes a contact from a group. + +### Example +```php +setUsername('YOUR_USERNAME') + ->setPassword('YOUR_PASSWORD'); + + +$apiInstance = new Messente\Api\Api\ContactsApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$groupId = 'groupId_example'; // string | String in uuid format. +$phone = 'phone_example'; // string | A phone number + +try { + $apiInstance->removeContactFromGroup($groupId, $phone); +} catch (Exception $e) { + echo 'Exception when calling ContactsApi->removeContactFromGroup: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **groupId** | **string**| String in uuid format. | + **phone** | **string**| A phone number | + +### Return type + +void (empty response body) + +### Authorization + +[basicAuth](../../README.md#basicAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **updateContact** +> \Messente\Api\Model\ContactEnvelope updateContact($phone, $contactUpdateFields) + +Updates a contact. + +### Example +```php +setUsername('YOUR_USERNAME') + ->setPassword('YOUR_PASSWORD'); + + +$apiInstance = new Messente\Api\Api\ContactsApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$phone = 'phone_example'; // string | A phone number +$contactUpdateFields = new \Messente\Api\Model\ContactUpdateFields(); // \Messente\Api\Model\ContactUpdateFields | + +try { + $result = $apiInstance->updateContact($phone, $contactUpdateFields); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling ContactsApi->updateContact: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **phone** | **string**| A phone number | + **contactUpdateFields** | [**\Messente\Api\Model\ContactUpdateFields**](../Model/ContactUpdateFields.md)| | + +### Return type + +[**\Messente\Api\Model\ContactEnvelope**](../Model/ContactEnvelope.md) + +### Authorization + +[basicAuth](../../README.md#basicAuth) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/docs/Api/DeliveryReportApi.md b/docs/Api/DeliveryReportApi.md new file mode 100644 index 0000000..a7afc12 --- /dev/null +++ b/docs/Api/DeliveryReportApi.md @@ -0,0 +1,63 @@ +# Messente\Api\DeliveryReportApi + +All URIs are relative to *https://api.messente.com/v1* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**retrieveDeliveryReport**](DeliveryReportApi.md#retrieveDeliveryReport) | **GET** /omnimessage/{omnimessageId}/status | Retrieves the delivery report for the Omnimessage. + + +# **retrieveDeliveryReport** +> \Messente\Api\Model\DeliveryReportResponse retrieveDeliveryReport($omnimessageId) + +Retrieves the delivery report for the Omnimessage. + +### Example +```php +setUsername('YOUR_USERNAME') + ->setPassword('YOUR_PASSWORD'); + + +$apiInstance = new Messente\Api\Api\DeliveryReportApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$omnimessageId = 'omnimessageId_example'; // string | UUID of the Omnimessage to for which the delivery report is to be retrieved + +try { + $result = $apiInstance->retrieveDeliveryReport($omnimessageId); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling DeliveryReportApi->retrieveDeliveryReport: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **omnimessageId** | [**string**](../Model/.md)| UUID of the Omnimessage to for which the delivery report is to be retrieved | + +### Return type + +[**\Messente\Api\Model\DeliveryReportResponse**](../Model/DeliveryReportResponse.md) + +### Authorization + +[basicAuth](../../README.md#basicAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: */* + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/docs/Api/GroupsApi.md b/docs/Api/GroupsApi.md new file mode 100644 index 0000000..673701b --- /dev/null +++ b/docs/Api/GroupsApi.md @@ -0,0 +1,280 @@ +# Messente\Api\GroupsApi + +All URIs are relative to *https://api.messente.com/v1* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**createGroup**](GroupsApi.md#createGroup) | **POST** /groups | Creates a new group with the provided name. +[**deleteGroup**](GroupsApi.md#deleteGroup) | **DELETE** /groups/{groupId} | Deletes a group. +[**fetchGroup**](GroupsApi.md#fetchGroup) | **GET** /groups/{groupId} | Lists a group. +[**fetchGroups**](GroupsApi.md#fetchGroups) | **GET** /groups | Returns all groups. +[**updateGroup**](GroupsApi.md#updateGroup) | **PUT** /groups/{groupId} | Updates a group with the provided name. + + +# **createGroup** +> \Messente\Api\Model\GroupEnvelope createGroup($groupName) + +Creates a new group with the provided name. + +### Example +```php +setUsername('YOUR_USERNAME') + ->setPassword('YOUR_PASSWORD'); + + +$apiInstance = new Messente\Api\Api\GroupsApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$groupName = new \Messente\Api\Model\GroupName(); // \Messente\Api\Model\GroupName | + +try { + $result = $apiInstance->createGroup($groupName); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling GroupsApi->createGroup: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **groupName** | [**\Messente\Api\Model\GroupName**](../Model/GroupName.md)| | + +### Return type + +[**\Messente\Api\Model\GroupEnvelope**](../Model/GroupEnvelope.md) + +### Authorization + +[basicAuth](../../README.md#basicAuth) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **deleteGroup** +> deleteGroup($groupId) + +Deletes a group. + +### Example +```php +setUsername('YOUR_USERNAME') + ->setPassword('YOUR_PASSWORD'); + + +$apiInstance = new Messente\Api\Api\GroupsApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$groupId = 'groupId_example'; // string | String in uuid format. + +try { + $apiInstance->deleteGroup($groupId); +} catch (Exception $e) { + echo 'Exception when calling GroupsApi->deleteGroup: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **groupId** | **string**| String in uuid format. | + +### Return type + +void (empty response body) + +### Authorization + +[basicAuth](../../README.md#basicAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **fetchGroup** +> \Messente\Api\Model\GroupEnvelope fetchGroup($groupId) + +Lists a group. + +### Example +```php +setUsername('YOUR_USERNAME') + ->setPassword('YOUR_PASSWORD'); + + +$apiInstance = new Messente\Api\Api\GroupsApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$groupId = 'groupId_example'; // string | String in uuid format. + +try { + $result = $apiInstance->fetchGroup($groupId); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling GroupsApi->fetchGroup: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **groupId** | **string**| String in uuid format. | + +### Return type + +[**\Messente\Api\Model\GroupEnvelope**](../Model/GroupEnvelope.md) + +### Authorization + +[basicAuth](../../README.md#basicAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **fetchGroups** +> \Messente\Api\Model\GroupListEnvelope fetchGroups() + +Returns all groups. + +### Example +```php +setUsername('YOUR_USERNAME') + ->setPassword('YOUR_PASSWORD'); + + +$apiInstance = new Messente\Api\Api\GroupsApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); + +try { + $result = $apiInstance->fetchGroups(); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling GroupsApi->fetchGroups: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**\Messente\Api\Model\GroupListEnvelope**](../Model/GroupListEnvelope.md) + +### Authorization + +[basicAuth](../../README.md#basicAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **updateGroup** +> \Messente\Api\Model\GroupEnvelope updateGroup($groupId, $groupName) + +Updates a group with the provided name. + +### Example +```php +setUsername('YOUR_USERNAME') + ->setPassword('YOUR_PASSWORD'); + + +$apiInstance = new Messente\Api\Api\GroupsApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$groupId = 'groupId_example'; // string | String in uuid format. +$groupName = new \Messente\Api\Model\GroupName(); // \Messente\Api\Model\GroupName | + +try { + $result = $apiInstance->updateGroup($groupId, $groupName); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling GroupsApi->updateGroup: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **groupId** | **string**| String in uuid format. | + **groupName** | [**\Messente\Api\Model\GroupName**](../Model/GroupName.md)| | + +### Return type + +[**\Messente\Api\Model\GroupEnvelope**](../Model/GroupEnvelope.md) + +### Authorization + +[basicAuth](../../README.md#basicAuth) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/docs/Api/OmnimessageApi.md b/docs/Api/OmnimessageApi.md new file mode 100644 index 0000000..a65441d --- /dev/null +++ b/docs/Api/OmnimessageApi.md @@ -0,0 +1,117 @@ +# Messente\Api\OmnimessageApi + +All URIs are relative to *https://api.messente.com/v1* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**cancelScheduledMessage**](OmnimessageApi.md#cancelScheduledMessage) | **DELETE** /omnimessage/{omnimessageId} | Cancels a scheduled Omnimessage. +[**sendOmnimessage**](OmnimessageApi.md#sendOmnimessage) | **POST** /omnimessage | Sends an Omnimessage. + + +# **cancelScheduledMessage** +> cancelScheduledMessage($omnimessageId) + +Cancels a scheduled Omnimessage. + +### Example +```php +setUsername('YOUR_USERNAME') + ->setPassword('YOUR_PASSWORD'); + + +$apiInstance = new Messente\Api\Api\OmnimessageApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$omnimessageId = 'omnimessageId_example'; // string | UUID of the scheduled Omnimessage to be cancelled + +try { + $apiInstance->cancelScheduledMessage($omnimessageId); +} catch (Exception $e) { + echo 'Exception when calling OmnimessageApi->cancelScheduledMessage: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **omnimessageId** | [**string**](../Model/.md)| UUID of the scheduled Omnimessage to be cancelled | + +### Return type + +void (empty response body) + +### Authorization + +[basicAuth](../../README.md#basicAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **sendOmnimessage** +> \Messente\Api\Model\OmniMessageCreateSuccessResponse sendOmnimessage($omnimessage) + +Sends an Omnimessage. + +### Example +```php +setUsername('YOUR_USERNAME') + ->setPassword('YOUR_PASSWORD'); + + +$apiInstance = new Messente\Api\Api\OmnimessageApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$omnimessage = new \Messente\Api\Model\Omnimessage(); // \Messente\Api\Model\Omnimessage | Omnimessage to be sent + +try { + $result = $apiInstance->sendOmnimessage($omnimessage); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling OmnimessageApi->sendOmnimessage: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **omnimessage** | [**\Messente\Api\Model\Omnimessage**](../Model/Omnimessage.md)| Omnimessage to be sent | + +### Return type + +[**\Messente\Api\Model\OmniMessageCreateSuccessResponse**](../Model/OmniMessageCreateSuccessResponse.md) + +### Authorization + +[basicAuth](../../README.md#basicAuth) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/docs/Model/Channel.md b/docs/Model/Channel.md new file mode 100644 index 0000000..a76c8af --- /dev/null +++ b/docs/Model/Channel.md @@ -0,0 +1,9 @@ +# Channel + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Model/ContactEnvelope.md b/docs/Model/ContactEnvelope.md new file mode 100644 index 0000000..dd4316f --- /dev/null +++ b/docs/Model/ContactEnvelope.md @@ -0,0 +1,10 @@ +# ContactEnvelope + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**contact** | [**\Messente\Api\Model\ContactFields**](ContactFields.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Model/ContactFields.md b/docs/Model/ContactFields.md new file mode 100644 index 0000000..81c43e4 --- /dev/null +++ b/docs/Model/ContactFields.md @@ -0,0 +1,19 @@ +# ContactFields + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**phoneNumber** | **string** | Phone number in e.164 format | +**email** | **string** | | [optional] +**firstName** | **string** | | [optional] +**lastName** | **string** | | [optional] +**company** | **string** | | [optional] +**title** | **string** | | [optional] +**custom** | **string** | | [optional] +**custom2** | **string** | | [optional] +**custom3** | **string** | | [optional] +**custom4** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Model/ContactListEnvelope.md b/docs/Model/ContactListEnvelope.md new file mode 100644 index 0000000..fc1b8e7 --- /dev/null +++ b/docs/Model/ContactListEnvelope.md @@ -0,0 +1,10 @@ +# ContactListEnvelope + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**contacts** | [**\Messente\Api\Model\ContactFields[]**](ContactFields.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Model/ContactUpdateFields.md b/docs/Model/ContactUpdateFields.md new file mode 100644 index 0000000..ae1095f --- /dev/null +++ b/docs/Model/ContactUpdateFields.md @@ -0,0 +1,18 @@ +# ContactUpdateFields + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**email** | **string** | | [optional] +**firstName** | **string** | | [optional] +**lastName** | **string** | | [optional] +**company** | **string** | | [optional] +**title** | **string** | | [optional] +**custom** | **string** | | [optional] +**custom2** | **string** | | [optional] +**custom3** | **string** | | [optional] +**custom4** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Model/DeliveryReportResponse.md b/docs/Model/DeliveryReportResponse.md new file mode 100644 index 0000000..06eb847 --- /dev/null +++ b/docs/Model/DeliveryReportResponse.md @@ -0,0 +1,12 @@ +# DeliveryReportResponse + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**statuses** | [**\Messente\Api\Model\DeliveryResult[]**](DeliveryResult.md) | Contains the delivery reports for each channnel, ordered by send order | +**to** | **string** | Phone number in e.164 format | +**omnimessageId** | **string** | Unique identifier for the Omnimessage | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Model/DeliveryResult.md b/docs/Model/DeliveryResult.md new file mode 100644 index 0000000..899243e --- /dev/null +++ b/docs/Model/DeliveryResult.md @@ -0,0 +1,15 @@ +# DeliveryResult + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**status** | [**\Messente\Api\Model\Status**](Status.md) | | [optional] +**channel** | [**\Messente\Api\Model\Channel**](Channel.md) | | [optional] +**messageId** | **string** | Unique identifier for the message | [optional] +**error** | **string** | Human-readable description of what went wrong, *null* in case of success or if the messages has not been processed yet | [optional] +**err** | [**\Messente\Api\Model\ErrorCodeOmnichannelMachine**](ErrorCodeOmnichannelMachine.md) | | [optional] +**timestamp** | [**\DateTime**](\DateTime.md) | When this status was received by Omnichannel API | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Model/ErrorCodeOmnichannel.md b/docs/Model/ErrorCodeOmnichannel.md new file mode 100644 index 0000000..c1b0288 --- /dev/null +++ b/docs/Model/ErrorCodeOmnichannel.md @@ -0,0 +1,9 @@ +# ErrorCodeOmnichannel + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Model/ErrorCodeOmnichannelMachine.md b/docs/Model/ErrorCodeOmnichannelMachine.md new file mode 100644 index 0000000..7efcc02 --- /dev/null +++ b/docs/Model/ErrorCodeOmnichannelMachine.md @@ -0,0 +1,9 @@ +# ErrorCodeOmnichannelMachine + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Model/ErrorCodePhonebook.md b/docs/Model/ErrorCodePhonebook.md new file mode 100644 index 0000000..fdc5ce8 --- /dev/null +++ b/docs/Model/ErrorCodePhonebook.md @@ -0,0 +1,9 @@ +# ErrorCodePhonebook + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Model/ErrorItemOmnichannel.md b/docs/Model/ErrorItemOmnichannel.md new file mode 100644 index 0000000..aa44c16 --- /dev/null +++ b/docs/Model/ErrorItemOmnichannel.md @@ -0,0 +1,13 @@ +# ErrorItemOmnichannel + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**title** | [**\Messente\Api\Model\ErrorTitleOmnichannel**](ErrorTitleOmnichannel.md) | | +**detail** | **string** | Free form more detailed description of the error. | +**code** | [**\Messente\Api\Model\ErrorCodeOmnichannel**](ErrorCodeOmnichannel.md) | | +**source** | **string** | Describes which field is causing the issue in the payload, null for non 400 status code responses | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Model/ErrorItemPhonebook.md b/docs/Model/ErrorItemPhonebook.md new file mode 100644 index 0000000..1082fd3 --- /dev/null +++ b/docs/Model/ErrorItemPhonebook.md @@ -0,0 +1,12 @@ +# ErrorItemPhonebook + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**title** | [**\Messente\Api\Model\ErrorTitlePhonebook**](ErrorTitlePhonebook.md) | | +**detail** | **string** | Free form more detailed description of the error. | +**code** | [**\Messente\Api\Model\ErrorCodePhonebook**](ErrorCodePhonebook.md) | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Model/ErrorOmnichannel.md b/docs/Model/ErrorOmnichannel.md new file mode 100644 index 0000000..9dfc420 --- /dev/null +++ b/docs/Model/ErrorOmnichannel.md @@ -0,0 +1,10 @@ +# ErrorOmnichannel + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**errors** | [**\Messente\Api\Model\ErrorItemOmnichannel[]**](ErrorItemOmnichannel.md) | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Model/ErrorPhonebook.md b/docs/Model/ErrorPhonebook.md new file mode 100644 index 0000000..02394b9 --- /dev/null +++ b/docs/Model/ErrorPhonebook.md @@ -0,0 +1,10 @@ +# ErrorPhonebook + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**errors** | [**\Messente\Api\Model\ErrorItemPhonebook[]**](ErrorItemPhonebook.md) | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Model/ErrorTitleOmnichannel.md b/docs/Model/ErrorTitleOmnichannel.md new file mode 100644 index 0000000..4988d32 --- /dev/null +++ b/docs/Model/ErrorTitleOmnichannel.md @@ -0,0 +1,9 @@ +# ErrorTitleOmnichannel + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Model/ErrorTitlePhonebook.md b/docs/Model/ErrorTitlePhonebook.md new file mode 100644 index 0000000..cbd0cee --- /dev/null +++ b/docs/Model/ErrorTitlePhonebook.md @@ -0,0 +1,9 @@ +# ErrorTitlePhonebook + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Model/FetchBlacklistSuccess.md b/docs/Model/FetchBlacklistSuccess.md new file mode 100644 index 0000000..8ac35c1 --- /dev/null +++ b/docs/Model/FetchBlacklistSuccess.md @@ -0,0 +1,10 @@ +# FetchBlacklistSuccess + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**phoneNumbers** | **string[]** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Model/GroupEnvelope.md b/docs/Model/GroupEnvelope.md new file mode 100644 index 0000000..0059d8f --- /dev/null +++ b/docs/Model/GroupEnvelope.md @@ -0,0 +1,10 @@ +# GroupEnvelope + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**group** | [**\Messente\Api\Model\GroupResponseFields**](GroupResponseFields.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Model/GroupListEnvelope.md b/docs/Model/GroupListEnvelope.md new file mode 100644 index 0000000..4d238b5 --- /dev/null +++ b/docs/Model/GroupListEnvelope.md @@ -0,0 +1,10 @@ +# GroupListEnvelope + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**groups** | [**\Messente\Api\Model\GroupResponseFields[]**](GroupResponseFields.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Model/GroupName.md b/docs/Model/GroupName.md new file mode 100644 index 0000000..e804200 --- /dev/null +++ b/docs/Model/GroupName.md @@ -0,0 +1,10 @@ +# GroupName + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **string** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Model/GroupResponseFields.md b/docs/Model/GroupResponseFields.md new file mode 100644 index 0000000..f2ec4eb --- /dev/null +++ b/docs/Model/GroupResponseFields.md @@ -0,0 +1,13 @@ +# GroupResponseFields + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **string** | Id string in uuid format | +**name** | **string** | | +**createdOn** | **string** | format %Y-%m-%dT%H:%M:%S.%fZ | [optional] +**contactsCount** | **int** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Model/MessageResult.md b/docs/Model/MessageResult.md new file mode 100644 index 0000000..d41f119 --- /dev/null +++ b/docs/Model/MessageResult.md @@ -0,0 +1,12 @@ +# MessageResult + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**messageId** | **string** | Unique identifier for the message | +**channel** | [**\Messente\Api\Model\Channel**](Channel.md) | | +**sender** | **string** | Sender that was used for the message | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Model/NumberToBlacklist.md b/docs/Model/NumberToBlacklist.md new file mode 100644 index 0000000..5c474cd --- /dev/null +++ b/docs/Model/NumberToBlacklist.md @@ -0,0 +1,10 @@ +# NumberToBlacklist + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**phoneNumber** | **string** | Phone number in e.164 format | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Model/OmniMessageCreateSuccessResponse.md b/docs/Model/OmniMessageCreateSuccessResponse.md new file mode 100644 index 0000000..29f6f61 --- /dev/null +++ b/docs/Model/OmniMessageCreateSuccessResponse.md @@ -0,0 +1,12 @@ +# OmniMessageCreateSuccessResponse + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**messages** | [**\Messente\Api\Model\MessageResult[]**](MessageResult.md) | List of messages that compose the Omnimessage | +**to** | **string** | Phone number in e.164 format | +**omnimessageId** | **string** | Unique identifier for the Omnimessage | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Model/Omnimessage.md b/docs/Model/Omnimessage.md new file mode 100644 index 0000000..790ffa3 --- /dev/null +++ b/docs/Model/Omnimessage.md @@ -0,0 +1,13 @@ +# Omnimessage + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**to** | **string** | Phone number in e.164 format | +**messages** | [**OneOfViberSMSWhatsApp[]**](OneOfViberSMSWhatsApp.md) | | +**dlrUrl** | **string** | URL where the delivery report will be sent | [optional] +**timeToSend** | [**\DateTime**](\DateTime.md) | Optional parameter for sending messages at some specific time in the future. Time must be specified in the 8601 format. If no timezone is specified, then the timezone is assumed to be UTC. Examples: * Time specified with timezone: 2018-06-22T09:05:07+00:00 Time specified in UTC: 2018-06-22T09:05:07Z * Time specified without timezone: 2018-06-22T09:05 (equivalent to 2018-06-22T09:05+00:00) | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Model/SMS.md b/docs/Model/SMS.md new file mode 100644 index 0000000..fe12231 --- /dev/null +++ b/docs/Model/SMS.md @@ -0,0 +1,15 @@ +# SMS + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**text** | **string** | Text content of the SMS | +**sender** | **string** | Phone number or alphanumeric sender name | [optional] +**validity** | **int** | After how many minutes this channel is considered as failed and the next channel is attempted | [optional] +**autoconvert** | **string** | Defines how non-GSM characters will be treated: - \"on\" Use replacement settings from the account's [API Auto Replace settings page](https://dashboard.messente.com/api-settings/auto-replace)(default) - \"full\" All non GSM 03.38 characters will be replaced with suitable alternatives - \"off\" Message content is not modified in any way | [optional] +**udh** | **string** | hex-encoded string containing SMS UDH | [optional] +**channel** | **string** | | [optional] [default to 'sms'] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Model/Status.md b/docs/Model/Status.md new file mode 100644 index 0000000..347eb0b --- /dev/null +++ b/docs/Model/Status.md @@ -0,0 +1,9 @@ +# Status + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Model/Viber.md b/docs/Model/Viber.md new file mode 100644 index 0000000..338417f --- /dev/null +++ b/docs/Model/Viber.md @@ -0,0 +1,16 @@ +# Viber + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**sender** | **string** | Phone number or alphanumeric sender name | [optional] +**validity** | **int** | After how many minutes this channel is considered as failed and the next channel is attempted | [optional] +**text** | **string** | Plaintext content for Viber | [optional] +**imageUrl** | **string** | URL for the embedded image. Valid combinations: 1) image_url, 2) text, image_url, button_url, button_text | [optional] +**buttonUrl** | **string** | URL of the button, must be specified along with ''text'', ''button_text'' and ''image_url'' (optional) | [optional] +**buttonText** | **string** | Must be specified along with ''text'', ''button_url'', ''button_text'', ''image_url'' (optional) | [optional] +**channel** | **string** | | [optional] [default to 'viber'] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Model/WhatsApp.md b/docs/Model/WhatsApp.md new file mode 100644 index 0000000..8ef9bec --- /dev/null +++ b/docs/Model/WhatsApp.md @@ -0,0 +1,16 @@ +# WhatsApp + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**sender** | **string** | Phone number or alphanumeric sender name | [optional] +**validity** | **int** | After how many minutes this channel is considered as failed and the next channel is attempted | [optional] +**text** | [**\Messente\Api\Model\WhatsAppText**](WhatsAppText.md) | | [optional] +**image** | [**\Messente\Api\Model\WhatsAppImage**](WhatsAppImage.md) | | [optional] +**document** | [**\Messente\Api\Model\WhatsAppDocument**](WhatsAppDocument.md) | | [optional] +**audio** | [**\Messente\Api\Model\WhatsAppAudio**](WhatsAppAudio.md) | | [optional] +**channel** | **string** | | [optional] [default to 'whatsapp'] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Model/WhatsAppAudio.md b/docs/Model/WhatsAppAudio.md new file mode 100644 index 0000000..bd4b331 --- /dev/null +++ b/docs/Model/WhatsAppAudio.md @@ -0,0 +1,10 @@ +# WhatsAppAudio + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**content** | **string** | Base64-encoded audio | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Model/WhatsAppDocument.md b/docs/Model/WhatsAppDocument.md new file mode 100644 index 0000000..5d2b1e5 --- /dev/null +++ b/docs/Model/WhatsAppDocument.md @@ -0,0 +1,11 @@ +# WhatsAppDocument + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**caption** | **string** | Description for the document | [optional] +**content** | **string** | Base64-encoded image | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Model/WhatsAppImage.md b/docs/Model/WhatsAppImage.md new file mode 100644 index 0000000..757b9a6 --- /dev/null +++ b/docs/Model/WhatsAppImage.md @@ -0,0 +1,11 @@ +# WhatsAppImage + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**caption** | **string** | Description for the image | [optional] +**content** | **string** | Base64-encoded image | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Model/WhatsAppText.md b/docs/Model/WhatsAppText.md new file mode 100644 index 0000000..687abcd --- /dev/null +++ b/docs/Model/WhatsAppText.md @@ -0,0 +1,11 @@ +# WhatsAppText + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**previewUrl** | **bool** | Whether to display link preview if the message contains a hyperlink. | [optional] [default to true] +**body** | **string** | Plaintext content for WhatsApp, can contain URLs, emojis and formatting | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/git_push.sh b/git_push.sh new file mode 100644 index 0000000..7a23503 --- /dev/null +++ b/git_push.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="messente" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="messente-api-php" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/lib/Api/BlacklistApi.php b/lib/Api/BlacklistApi.php new file mode 100644 index 0000000..9b8bfe2 --- /dev/null +++ b/lib/Api/BlacklistApi.php @@ -0,0 +1,1172 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation addToBlacklist + * + * Adds a phone number to the blacklist. + * + * @param \Messente\Api\Model\NumberToBlacklist $numberToBlacklist Phone number to be blacklisted (required) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function addToBlacklist($numberToBlacklist) + { + $this->addToBlacklistWithHttpInfo($numberToBlacklist); + } + + /** + * Operation addToBlacklistWithHttpInfo + * + * Adds a phone number to the blacklist. + * + * @param \Messente\Api\Model\NumberToBlacklist $numberToBlacklist Phone number to be blacklisted (required) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of null, HTTP status code, HTTP response headers (array of strings) + */ + public function addToBlacklistWithHttpInfo($numberToBlacklist) + { + $request = $this->addToBlacklistRequest($numberToBlacklist); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + return [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 409: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation addToBlacklistAsync + * + * Adds a phone number to the blacklist. + * + * @param \Messente\Api\Model\NumberToBlacklist $numberToBlacklist Phone number to be blacklisted (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addToBlacklistAsync($numberToBlacklist) + { + return $this->addToBlacklistAsyncWithHttpInfo($numberToBlacklist) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation addToBlacklistAsyncWithHttpInfo + * + * Adds a phone number to the blacklist. + * + * @param \Messente\Api\Model\NumberToBlacklist $numberToBlacklist Phone number to be blacklisted (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addToBlacklistAsyncWithHttpInfo($numberToBlacklist) + { + $returnType = ''; + $request = $this->addToBlacklistRequest($numberToBlacklist); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'addToBlacklist' + * + * @param \Messente\Api\Model\NumberToBlacklist $numberToBlacklist Phone number to be blacklisted (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function addToBlacklistRequest($numberToBlacklist) + { + // verify the required parameter 'numberToBlacklist' is set + if ($numberToBlacklist === null || (is_array($numberToBlacklist) && count($numberToBlacklist) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $numberToBlacklist when calling addToBlacklist' + ); + } + + $resourcePath = '/phonebook/blacklist'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // body params + $_tempBody = null; + if (isset($numberToBlacklist)) { + $_tempBody = $numberToBlacklist; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($_tempBody)); + } else { + $httpBody = $_tempBody; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires HTTP basic authentication + if ($this->config->getUsername() !== null || $this->config->getPassword() !== null) { + $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deleteFromBlacklist + * + * Deletes a phone number from the blacklist. + * + * @param string $phone A phone number (required) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function deleteFromBlacklist($phone) + { + $this->deleteFromBlacklistWithHttpInfo($phone); + } + + /** + * Operation deleteFromBlacklistWithHttpInfo + * + * Deletes a phone number from the blacklist. + * + * @param string $phone A phone number (required) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of null, HTTP status code, HTTP response headers (array of strings) + */ + public function deleteFromBlacklistWithHttpInfo($phone) + { + $request = $this->deleteFromBlacklistRequest($phone); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + return [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deleteFromBlacklistAsync + * + * Deletes a phone number from the blacklist. + * + * @param string $phone A phone number (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteFromBlacklistAsync($phone) + { + return $this->deleteFromBlacklistAsyncWithHttpInfo($phone) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteFromBlacklistAsyncWithHttpInfo + * + * Deletes a phone number from the blacklist. + * + * @param string $phone A phone number (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteFromBlacklistAsyncWithHttpInfo($phone) + { + $returnType = ''; + $request = $this->deleteFromBlacklistRequest($phone); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteFromBlacklist' + * + * @param string $phone A phone number (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function deleteFromBlacklistRequest($phone) + { + // verify the required parameter 'phone' is set + if ($phone === null || (is_array($phone) && count($phone) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $phone when calling deleteFromBlacklist' + ); + } + + $resourcePath = '/blacklist/{phone}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + // path params + if ($phone !== null) { + $resourcePath = str_replace( + '{' . 'phone' . '}', + ObjectSerializer::toPathValue($phone), + $resourcePath + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($_tempBody)); + } else { + $httpBody = $_tempBody; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires HTTP basic authentication + if ($this->config->getUsername() !== null || $this->config->getPassword() !== null) { + $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'DELETE', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation fetchBlacklist + * + * Returns all blacklisted phone numbers. + * + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Messente\Api\Model\FetchBlacklistSuccess|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook + */ + public function fetchBlacklist() + { + list($response) = $this->fetchBlacklistWithHttpInfo(); + return $response; + } + + /** + * Operation fetchBlacklistWithHttpInfo + * + * Returns all blacklisted phone numbers. + * + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Messente\Api\Model\FetchBlacklistSuccess|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook, HTTP status code, HTTP response headers (array of strings) + */ + public function fetchBlacklistWithHttpInfo() + { + $request = $this->fetchBlacklistRequest(); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + switch($statusCode) { + case 200: + if ('\Messente\Api\Model\FetchBlacklistSuccess' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\FetchBlacklistSuccess', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Messente\Api\Model\ErrorPhonebook' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorPhonebook', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + default: + if ('\Messente\Api\Model\ErrorPhonebook' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorPhonebook', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Messente\Api\Model\FetchBlacklistSuccess'; + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\FetchBlacklistSuccess', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation fetchBlacklistAsync + * + * Returns all blacklisted phone numbers. + * + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function fetchBlacklistAsync() + { + return $this->fetchBlacklistAsyncWithHttpInfo() + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation fetchBlacklistAsyncWithHttpInfo + * + * Returns all blacklisted phone numbers. + * + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function fetchBlacklistAsyncWithHttpInfo() + { + $returnType = '\Messente\Api\Model\FetchBlacklistSuccess'; + $request = $this->fetchBlacklistRequest(); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'fetchBlacklist' + * + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function fetchBlacklistRequest() + { + + $resourcePath = '/phonebook/blacklist'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($_tempBody)); + } else { + $httpBody = $_tempBody; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires HTTP basic authentication + if ($this->config->getUsername() !== null || $this->config->getPassword() !== null) { + $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation isBlacklisted + * + * Checks if a phone number is blacklisted. + * + * @param string $phone A phone number (required) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function isBlacklisted($phone) + { + $this->isBlacklistedWithHttpInfo($phone); + } + + /** + * Operation isBlacklistedWithHttpInfo + * + * Checks if a phone number is blacklisted. + * + * @param string $phone A phone number (required) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of null, HTTP status code, HTTP response headers (array of strings) + */ + public function isBlacklistedWithHttpInfo($phone) + { + $request = $this->isBlacklistedRequest($phone); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + return [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation isBlacklistedAsync + * + * Checks if a phone number is blacklisted. + * + * @param string $phone A phone number (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function isBlacklistedAsync($phone) + { + return $this->isBlacklistedAsyncWithHttpInfo($phone) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation isBlacklistedAsyncWithHttpInfo + * + * Checks if a phone number is blacklisted. + * + * @param string $phone A phone number (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function isBlacklistedAsyncWithHttpInfo($phone) + { + $returnType = ''; + $request = $this->isBlacklistedRequest($phone); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'isBlacklisted' + * + * @param string $phone A phone number (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function isBlacklistedRequest($phone) + { + // verify the required parameter 'phone' is set + if ($phone === null || (is_array($phone) && count($phone) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $phone when calling isBlacklisted' + ); + } + + $resourcePath = '/blacklist/{phone}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + // path params + if ($phone !== null) { + $resourcePath = str_replace( + '{' . 'phone' . '}', + ObjectSerializer::toPathValue($phone), + $resourcePath + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($_tempBody)); + } else { + $httpBody = $_tempBody; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires HTTP basic authentication + if ($this->config->getUsername() !== null || $this->config->getPassword() !== null) { + $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/lib/Api/ContactsApi.php b/lib/Api/ContactsApi.php new file mode 100644 index 0000000..309e132 --- /dev/null +++ b/lib/Api/ContactsApi.php @@ -0,0 +1,2759 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation addContactToGroup + * + * Adds a contact to a group. + * + * @param string $groupId String in uuid format. (required) + * @param string $phone A phone number (required) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return object|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook + */ + public function addContactToGroup($groupId, $phone) + { + list($response) = $this->addContactToGroupWithHttpInfo($groupId, $phone); + return $response; + } + + /** + * Operation addContactToGroupWithHttpInfo + * + * Adds a contact to a group. + * + * @param string $groupId String in uuid format. (required) + * @param string $phone A phone number (required) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of object|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook, HTTP status code, HTTP response headers (array of strings) + */ + public function addContactToGroupWithHttpInfo($groupId, $phone) + { + $request = $this->addContactToGroupRequest($groupId, $phone); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + switch($statusCode) { + case 201: + if ('object' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, 'object', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\Messente\Api\Model\ErrorPhonebook' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorPhonebook', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Messente\Api\Model\ErrorPhonebook' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorPhonebook', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\Messente\Api\Model\ErrorPhonebook' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorPhonebook', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 409: + if ('\Messente\Api\Model\ErrorPhonebook' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorPhonebook', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + default: + if ('\Messente\Api\Model\ErrorPhonebook' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorPhonebook', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = 'object'; + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 201: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + 'object', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 409: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation addContactToGroupAsync + * + * Adds a contact to a group. + * + * @param string $groupId String in uuid format. (required) + * @param string $phone A phone number (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addContactToGroupAsync($groupId, $phone) + { + return $this->addContactToGroupAsyncWithHttpInfo($groupId, $phone) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation addContactToGroupAsyncWithHttpInfo + * + * Adds a contact to a group. + * + * @param string $groupId String in uuid format. (required) + * @param string $phone A phone number (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addContactToGroupAsyncWithHttpInfo($groupId, $phone) + { + $returnType = 'object'; + $request = $this->addContactToGroupRequest($groupId, $phone); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'addContactToGroup' + * + * @param string $groupId String in uuid format. (required) + * @param string $phone A phone number (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function addContactToGroupRequest($groupId, $phone) + { + // verify the required parameter 'groupId' is set + if ($groupId === null || (is_array($groupId) && count($groupId) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $groupId when calling addContactToGroup' + ); + } + // verify the required parameter 'phone' is set + if ($phone === null || (is_array($phone) && count($phone) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $phone when calling addContactToGroup' + ); + } + + $resourcePath = '/groups/{groupId}/contacts/{phone}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + // path params + if ($groupId !== null) { + $resourcePath = str_replace( + '{' . 'groupId' . '}', + ObjectSerializer::toPathValue($groupId), + $resourcePath + ); + } + // path params + if ($phone !== null) { + $resourcePath = str_replace( + '{' . 'phone' . '}', + ObjectSerializer::toPathValue($phone), + $resourcePath + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($_tempBody)); + } else { + $httpBody = $_tempBody; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires HTTP basic authentication + if ($this->config->getUsername() !== null || $this->config->getPassword() !== null) { + $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation createContact + * + * Creates a new contact. + * + * @param \Messente\Api\Model\ContactFields $contactFields contactFields (required) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Messente\Api\Model\ContactEnvelope|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook + */ + public function createContact($contactFields) + { + list($response) = $this->createContactWithHttpInfo($contactFields); + return $response; + } + + /** + * Operation createContactWithHttpInfo + * + * Creates a new contact. + * + * @param \Messente\Api\Model\ContactFields $contactFields (required) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Messente\Api\Model\ContactEnvelope|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook, HTTP status code, HTTP response headers (array of strings) + */ + public function createContactWithHttpInfo($contactFields) + { + $request = $this->createContactRequest($contactFields); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + switch($statusCode) { + case 201: + if ('\Messente\Api\Model\ContactEnvelope' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ContactEnvelope', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\Messente\Api\Model\ErrorPhonebook' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorPhonebook', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Messente\Api\Model\ErrorPhonebook' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorPhonebook', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 409: + if ('\Messente\Api\Model\ErrorPhonebook' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorPhonebook', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + default: + if ('\Messente\Api\Model\ErrorPhonebook' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorPhonebook', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Messente\Api\Model\ContactEnvelope'; + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 201: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ContactEnvelope', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 409: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation createContactAsync + * + * Creates a new contact. + * + * @param \Messente\Api\Model\ContactFields $contactFields (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createContactAsync($contactFields) + { + return $this->createContactAsyncWithHttpInfo($contactFields) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation createContactAsyncWithHttpInfo + * + * Creates a new contact. + * + * @param \Messente\Api\Model\ContactFields $contactFields (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createContactAsyncWithHttpInfo($contactFields) + { + $returnType = '\Messente\Api\Model\ContactEnvelope'; + $request = $this->createContactRequest($contactFields); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'createContact' + * + * @param \Messente\Api\Model\ContactFields $contactFields (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function createContactRequest($contactFields) + { + // verify the required parameter 'contactFields' is set + if ($contactFields === null || (is_array($contactFields) && count($contactFields) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $contactFields when calling createContact' + ); + } + + $resourcePath = '/contacts'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // body params + $_tempBody = null; + if (isset($contactFields)) { + $_tempBody = $contactFields; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($_tempBody)); + } else { + $httpBody = $_tempBody; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires HTTP basic authentication + if ($this->config->getUsername() !== null || $this->config->getPassword() !== null) { + $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deleteContact + * + * Deletes a contact. + * + * @param string $phone A phone number (required) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function deleteContact($phone) + { + $this->deleteContactWithHttpInfo($phone); + } + + /** + * Operation deleteContactWithHttpInfo + * + * Deletes a contact. + * + * @param string $phone A phone number (required) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of null, HTTP status code, HTTP response headers (array of strings) + */ + public function deleteContactWithHttpInfo($phone) + { + $request = $this->deleteContactRequest($phone); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + return [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deleteContactAsync + * + * Deletes a contact. + * + * @param string $phone A phone number (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteContactAsync($phone) + { + return $this->deleteContactAsyncWithHttpInfo($phone) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteContactAsyncWithHttpInfo + * + * Deletes a contact. + * + * @param string $phone A phone number (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteContactAsyncWithHttpInfo($phone) + { + $returnType = ''; + $request = $this->deleteContactRequest($phone); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteContact' + * + * @param string $phone A phone number (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function deleteContactRequest($phone) + { + // verify the required parameter 'phone' is set + if ($phone === null || (is_array($phone) && count($phone) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $phone when calling deleteContact' + ); + } + + $resourcePath = '/contacts/{phone}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + // path params + if ($phone !== null) { + $resourcePath = str_replace( + '{' . 'phone' . '}', + ObjectSerializer::toPathValue($phone), + $resourcePath + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($_tempBody)); + } else { + $httpBody = $_tempBody; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires HTTP basic authentication + if ($this->config->getUsername() !== null || $this->config->getPassword() !== null) { + $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'DELETE', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation fetchContact + * + * Lists a contact. + * + * @param string $phone A phone number (required) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Messente\Api\Model\ContactEnvelope|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook + */ + public function fetchContact($phone) + { + list($response) = $this->fetchContactWithHttpInfo($phone); + return $response; + } + + /** + * Operation fetchContactWithHttpInfo + * + * Lists a contact. + * + * @param string $phone A phone number (required) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Messente\Api\Model\ContactEnvelope|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook, HTTP status code, HTTP response headers (array of strings) + */ + public function fetchContactWithHttpInfo($phone) + { + $request = $this->fetchContactRequest($phone); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + switch($statusCode) { + case 200: + if ('\Messente\Api\Model\ContactEnvelope' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ContactEnvelope', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\Messente\Api\Model\ErrorPhonebook' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorPhonebook', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Messente\Api\Model\ErrorPhonebook' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorPhonebook', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\Messente\Api\Model\ErrorPhonebook' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorPhonebook', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Messente\Api\Model\ContactEnvelope'; + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ContactEnvelope', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation fetchContactAsync + * + * Lists a contact. + * + * @param string $phone A phone number (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function fetchContactAsync($phone) + { + return $this->fetchContactAsyncWithHttpInfo($phone) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation fetchContactAsyncWithHttpInfo + * + * Lists a contact. + * + * @param string $phone A phone number (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function fetchContactAsyncWithHttpInfo($phone) + { + $returnType = '\Messente\Api\Model\ContactEnvelope'; + $request = $this->fetchContactRequest($phone); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'fetchContact' + * + * @param string $phone A phone number (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function fetchContactRequest($phone) + { + // verify the required parameter 'phone' is set + if ($phone === null || (is_array($phone) && count($phone) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $phone when calling fetchContact' + ); + } + + $resourcePath = '/contacts/{phone}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + // path params + if ($phone !== null) { + $resourcePath = str_replace( + '{' . 'phone' . '}', + ObjectSerializer::toPathValue($phone), + $resourcePath + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($_tempBody)); + } else { + $httpBody = $_tempBody; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires HTTP basic authentication + if ($this->config->getUsername() !== null || $this->config->getPassword() !== null) { + $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation fetchContactGroups + * + * Lists groups of a contact. + * + * @param string $phone A phone number (required) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Messente\Api\Model\GroupListEnvelope|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook + */ + public function fetchContactGroups($phone) + { + list($response) = $this->fetchContactGroupsWithHttpInfo($phone); + return $response; + } + + /** + * Operation fetchContactGroupsWithHttpInfo + * + * Lists groups of a contact. + * + * @param string $phone A phone number (required) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Messente\Api\Model\GroupListEnvelope|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook, HTTP status code, HTTP response headers (array of strings) + */ + public function fetchContactGroupsWithHttpInfo($phone) + { + $request = $this->fetchContactGroupsRequest($phone); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + switch($statusCode) { + case 200: + if ('\Messente\Api\Model\GroupListEnvelope' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\GroupListEnvelope', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\Messente\Api\Model\ErrorPhonebook' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorPhonebook', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Messente\Api\Model\ErrorPhonebook' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorPhonebook', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\Messente\Api\Model\ErrorPhonebook' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorPhonebook', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Messente\Api\Model\GroupListEnvelope'; + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\GroupListEnvelope', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation fetchContactGroupsAsync + * + * Lists groups of a contact. + * + * @param string $phone A phone number (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function fetchContactGroupsAsync($phone) + { + return $this->fetchContactGroupsAsyncWithHttpInfo($phone) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation fetchContactGroupsAsyncWithHttpInfo + * + * Lists groups of a contact. + * + * @param string $phone A phone number (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function fetchContactGroupsAsyncWithHttpInfo($phone) + { + $returnType = '\Messente\Api\Model\GroupListEnvelope'; + $request = $this->fetchContactGroupsRequest($phone); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'fetchContactGroups' + * + * @param string $phone A phone number (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function fetchContactGroupsRequest($phone) + { + // verify the required parameter 'phone' is set + if ($phone === null || (is_array($phone) && count($phone) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $phone when calling fetchContactGroups' + ); + } + + $resourcePath = '/contacts/{phone}/groups'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + // path params + if ($phone !== null) { + $resourcePath = str_replace( + '{' . 'phone' . '}', + ObjectSerializer::toPathValue($phone), + $resourcePath + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($_tempBody)); + } else { + $httpBody = $_tempBody; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires HTTP basic authentication + if ($this->config->getUsername() !== null || $this->config->getPassword() !== null) { + $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation fetchContacts + * + * Returns all contacts. + * + * @param string[] $groupIds Optional one or many group id strings in uuid format. For example: \"/contacts?groupIds=group_id_one&groupIds=group_id_two\" (optional) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Messente\Api\Model\ContactListEnvelope|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook + */ + public function fetchContacts($groupIds = null) + { + list($response) = $this->fetchContactsWithHttpInfo($groupIds); + return $response; + } + + /** + * Operation fetchContactsWithHttpInfo + * + * Returns all contacts. + * + * @param string[] $groupIds Optional one or many group id strings in uuid format. For example: \"/contacts?groupIds=group_id_one&groupIds=group_id_two\" (optional) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Messente\Api\Model\ContactListEnvelope|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook, HTTP status code, HTTP response headers (array of strings) + */ + public function fetchContactsWithHttpInfo($groupIds = null) + { + $request = $this->fetchContactsRequest($groupIds); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + switch($statusCode) { + case 200: + if ('\Messente\Api\Model\ContactListEnvelope' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ContactListEnvelope', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\Messente\Api\Model\ErrorPhonebook' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorPhonebook', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Messente\Api\Model\ErrorPhonebook' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorPhonebook', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + default: + if ('\Messente\Api\Model\ErrorPhonebook' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorPhonebook', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Messente\Api\Model\ContactListEnvelope'; + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ContactListEnvelope', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation fetchContactsAsync + * + * Returns all contacts. + * + * @param string[] $groupIds Optional one or many group id strings in uuid format. For example: \"/contacts?groupIds=group_id_one&groupIds=group_id_two\" (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function fetchContactsAsync($groupIds = null) + { + return $this->fetchContactsAsyncWithHttpInfo($groupIds) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation fetchContactsAsyncWithHttpInfo + * + * Returns all contacts. + * + * @param string[] $groupIds Optional one or many group id strings in uuid format. For example: \"/contacts?groupIds=group_id_one&groupIds=group_id_two\" (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function fetchContactsAsyncWithHttpInfo($groupIds = null) + { + $returnType = '\Messente\Api\Model\ContactListEnvelope'; + $request = $this->fetchContactsRequest($groupIds); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'fetchContacts' + * + * @param string[] $groupIds Optional one or many group id strings in uuid format. For example: \"/contacts?groupIds=group_id_one&groupIds=group_id_two\" (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function fetchContactsRequest($groupIds = null) + { + + $resourcePath = '/contacts'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams['groupIds'] = $groupIds; + + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($_tempBody)); + } else { + $httpBody = $_tempBody; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires HTTP basic authentication + if ($this->config->getUsername() !== null || $this->config->getPassword() !== null) { + $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation removeContactFromGroup + * + * Removes a contact from a group. + * + * @param string $groupId String in uuid format. (required) + * @param string $phone A phone number (required) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function removeContactFromGroup($groupId, $phone) + { + $this->removeContactFromGroupWithHttpInfo($groupId, $phone); + } + + /** + * Operation removeContactFromGroupWithHttpInfo + * + * Removes a contact from a group. + * + * @param string $groupId String in uuid format. (required) + * @param string $phone A phone number (required) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of null, HTTP status code, HTTP response headers (array of strings) + */ + public function removeContactFromGroupWithHttpInfo($groupId, $phone) + { + $request = $this->removeContactFromGroupRequest($groupId, $phone); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + return [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation removeContactFromGroupAsync + * + * Removes a contact from a group. + * + * @param string $groupId String in uuid format. (required) + * @param string $phone A phone number (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function removeContactFromGroupAsync($groupId, $phone) + { + return $this->removeContactFromGroupAsyncWithHttpInfo($groupId, $phone) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation removeContactFromGroupAsyncWithHttpInfo + * + * Removes a contact from a group. + * + * @param string $groupId String in uuid format. (required) + * @param string $phone A phone number (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function removeContactFromGroupAsyncWithHttpInfo($groupId, $phone) + { + $returnType = ''; + $request = $this->removeContactFromGroupRequest($groupId, $phone); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'removeContactFromGroup' + * + * @param string $groupId String in uuid format. (required) + * @param string $phone A phone number (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function removeContactFromGroupRequest($groupId, $phone) + { + // verify the required parameter 'groupId' is set + if ($groupId === null || (is_array($groupId) && count($groupId) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $groupId when calling removeContactFromGroup' + ); + } + // verify the required parameter 'phone' is set + if ($phone === null || (is_array($phone) && count($phone) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $phone when calling removeContactFromGroup' + ); + } + + $resourcePath = '/groups/{groupId}/contacts/{phone}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + // path params + if ($groupId !== null) { + $resourcePath = str_replace( + '{' . 'groupId' . '}', + ObjectSerializer::toPathValue($groupId), + $resourcePath + ); + } + // path params + if ($phone !== null) { + $resourcePath = str_replace( + '{' . 'phone' . '}', + ObjectSerializer::toPathValue($phone), + $resourcePath + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($_tempBody)); + } else { + $httpBody = $_tempBody; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires HTTP basic authentication + if ($this->config->getUsername() !== null || $this->config->getPassword() !== null) { + $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'DELETE', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateContact + * + * Updates a contact. + * + * @param string $phone A phone number (required) + * @param \Messente\Api\Model\ContactUpdateFields $contactUpdateFields contactUpdateFields (required) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Messente\Api\Model\ContactEnvelope|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook + */ + public function updateContact($phone, $contactUpdateFields) + { + list($response) = $this->updateContactWithHttpInfo($phone, $contactUpdateFields); + return $response; + } + + /** + * Operation updateContactWithHttpInfo + * + * Updates a contact. + * + * @param string $phone A phone number (required) + * @param \Messente\Api\Model\ContactUpdateFields $contactUpdateFields (required) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Messente\Api\Model\ContactEnvelope|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook, HTTP status code, HTTP response headers (array of strings) + */ + public function updateContactWithHttpInfo($phone, $contactUpdateFields) + { + $request = $this->updateContactRequest($phone, $contactUpdateFields); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + switch($statusCode) { + case 200: + if ('\Messente\Api\Model\ContactEnvelope' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ContactEnvelope', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\Messente\Api\Model\ErrorPhonebook' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorPhonebook', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Messente\Api\Model\ErrorPhonebook' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorPhonebook', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\Messente\Api\Model\ErrorPhonebook' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorPhonebook', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + default: + if ('\Messente\Api\Model\ErrorPhonebook' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorPhonebook', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Messente\Api\Model\ContactEnvelope'; + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ContactEnvelope', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateContactAsync + * + * Updates a contact. + * + * @param string $phone A phone number (required) + * @param \Messente\Api\Model\ContactUpdateFields $contactUpdateFields (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateContactAsync($phone, $contactUpdateFields) + { + return $this->updateContactAsyncWithHttpInfo($phone, $contactUpdateFields) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateContactAsyncWithHttpInfo + * + * Updates a contact. + * + * @param string $phone A phone number (required) + * @param \Messente\Api\Model\ContactUpdateFields $contactUpdateFields (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateContactAsyncWithHttpInfo($phone, $contactUpdateFields) + { + $returnType = '\Messente\Api\Model\ContactEnvelope'; + $request = $this->updateContactRequest($phone, $contactUpdateFields); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateContact' + * + * @param string $phone A phone number (required) + * @param \Messente\Api\Model\ContactUpdateFields $contactUpdateFields (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function updateContactRequest($phone, $contactUpdateFields) + { + // verify the required parameter 'phone' is set + if ($phone === null || (is_array($phone) && count($phone) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $phone when calling updateContact' + ); + } + // verify the required parameter 'contactUpdateFields' is set + if ($contactUpdateFields === null || (is_array($contactUpdateFields) && count($contactUpdateFields) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $contactUpdateFields when calling updateContact' + ); + } + + $resourcePath = '/contacts/{phone}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + // path params + if ($phone !== null) { + $resourcePath = str_replace( + '{' . 'phone' . '}', + ObjectSerializer::toPathValue($phone), + $resourcePath + ); + } + + // body params + $_tempBody = null; + if (isset($contactUpdateFields)) { + $_tempBody = $contactUpdateFields; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($_tempBody)); + } else { + $httpBody = $_tempBody; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires HTTP basic authentication + if ($this->config->getUsername() !== null || $this->config->getPassword() !== null) { + $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'PATCH', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/lib/Api/DeliveryReportApi.php b/lib/Api/DeliveryReportApi.php new file mode 100644 index 0000000..57c96be --- /dev/null +++ b/lib/Api/DeliveryReportApi.php @@ -0,0 +1,404 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation retrieveDeliveryReport + * + * Retrieves the delivery report for the Omnimessage. + * + * @param string $omnimessageId UUID of the Omnimessage to for which the delivery report is to be retrieved (required) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Messente\Api\Model\DeliveryReportResponse|\Messente\Api\Model\ErrorOmnichannel + */ + public function retrieveDeliveryReport($omnimessageId) + { + list($response) = $this->retrieveDeliveryReportWithHttpInfo($omnimessageId); + return $response; + } + + /** + * Operation retrieveDeliveryReportWithHttpInfo + * + * Retrieves the delivery report for the Omnimessage. + * + * @param string $omnimessageId UUID of the Omnimessage to for which the delivery report is to be retrieved (required) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Messente\Api\Model\DeliveryReportResponse|\Messente\Api\Model\ErrorOmnichannel, HTTP status code, HTTP response headers (array of strings) + */ + public function retrieveDeliveryReportWithHttpInfo($omnimessageId) + { + $request = $this->retrieveDeliveryReportRequest($omnimessageId); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + switch($statusCode) { + case 200: + if ('\Messente\Api\Model\DeliveryReportResponse' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\DeliveryReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\Messente\Api\Model\ErrorOmnichannel' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorOmnichannel', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Messente\Api\Model\DeliveryReportResponse'; + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\DeliveryReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorOmnichannel', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation retrieveDeliveryReportAsync + * + * Retrieves the delivery report for the Omnimessage. + * + * @param string $omnimessageId UUID of the Omnimessage to for which the delivery report is to be retrieved (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function retrieveDeliveryReportAsync($omnimessageId) + { + return $this->retrieveDeliveryReportAsyncWithHttpInfo($omnimessageId) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation retrieveDeliveryReportAsyncWithHttpInfo + * + * Retrieves the delivery report for the Omnimessage. + * + * @param string $omnimessageId UUID of the Omnimessage to for which the delivery report is to be retrieved (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function retrieveDeliveryReportAsyncWithHttpInfo($omnimessageId) + { + $returnType = '\Messente\Api\Model\DeliveryReportResponse'; + $request = $this->retrieveDeliveryReportRequest($omnimessageId); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'retrieveDeliveryReport' + * + * @param string $omnimessageId UUID of the Omnimessage to for which the delivery report is to be retrieved (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function retrieveDeliveryReportRequest($omnimessageId) + { + // verify the required parameter 'omnimessageId' is set + if ($omnimessageId === null || (is_array($omnimessageId) && count($omnimessageId) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $omnimessageId when calling retrieveDeliveryReport' + ); + } + + $resourcePath = '/omnimessage/{omnimessageId}/status'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + // path params + if ($omnimessageId !== null) { + $resourcePath = str_replace( + '{' . 'omnimessageId' . '}', + ObjectSerializer::toPathValue($omnimessageId), + $resourcePath + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['*/*'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['*/*'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($_tempBody)); + } else { + $httpBody = $_tempBody; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires HTTP basic authentication + if ($this->config->getUsername() !== null || $this->config->getPassword() !== null) { + $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/lib/Api/GroupsApi.php b/lib/Api/GroupsApi.php new file mode 100644 index 0000000..ef54825 --- /dev/null +++ b/lib/Api/GroupsApi.php @@ -0,0 +1,1674 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation createGroup + * + * Creates a new group with the provided name. + * + * @param \Messente\Api\Model\GroupName $groupName groupName (required) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Messente\Api\Model\GroupEnvelope|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook + */ + public function createGroup($groupName) + { + list($response) = $this->createGroupWithHttpInfo($groupName); + return $response; + } + + /** + * Operation createGroupWithHttpInfo + * + * Creates a new group with the provided name. + * + * @param \Messente\Api\Model\GroupName $groupName (required) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Messente\Api\Model\GroupEnvelope|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook, HTTP status code, HTTP response headers (array of strings) + */ + public function createGroupWithHttpInfo($groupName) + { + $request = $this->createGroupRequest($groupName); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + switch($statusCode) { + case 201: + if ('\Messente\Api\Model\GroupEnvelope' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\GroupEnvelope', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\Messente\Api\Model\ErrorPhonebook' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorPhonebook', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Messente\Api\Model\ErrorPhonebook' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorPhonebook', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + default: + if ('\Messente\Api\Model\ErrorPhonebook' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorPhonebook', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Messente\Api\Model\GroupEnvelope'; + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 201: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\GroupEnvelope', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation createGroupAsync + * + * Creates a new group with the provided name. + * + * @param \Messente\Api\Model\GroupName $groupName (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createGroupAsync($groupName) + { + return $this->createGroupAsyncWithHttpInfo($groupName) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation createGroupAsyncWithHttpInfo + * + * Creates a new group with the provided name. + * + * @param \Messente\Api\Model\GroupName $groupName (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createGroupAsyncWithHttpInfo($groupName) + { + $returnType = '\Messente\Api\Model\GroupEnvelope'; + $request = $this->createGroupRequest($groupName); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'createGroup' + * + * @param \Messente\Api\Model\GroupName $groupName (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function createGroupRequest($groupName) + { + // verify the required parameter 'groupName' is set + if ($groupName === null || (is_array($groupName) && count($groupName) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $groupName when calling createGroup' + ); + } + + $resourcePath = '/groups'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // body params + $_tempBody = null; + if (isset($groupName)) { + $_tempBody = $groupName; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($_tempBody)); + } else { + $httpBody = $_tempBody; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires HTTP basic authentication + if ($this->config->getUsername() !== null || $this->config->getPassword() !== null) { + $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deleteGroup + * + * Deletes a group. + * + * @param string $groupId String in uuid format. (required) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function deleteGroup($groupId) + { + $this->deleteGroupWithHttpInfo($groupId); + } + + /** + * Operation deleteGroupWithHttpInfo + * + * Deletes a group. + * + * @param string $groupId String in uuid format. (required) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of null, HTTP status code, HTTP response headers (array of strings) + */ + public function deleteGroupWithHttpInfo($groupId) + { + $request = $this->deleteGroupRequest($groupId); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + return [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deleteGroupAsync + * + * Deletes a group. + * + * @param string $groupId String in uuid format. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteGroupAsync($groupId) + { + return $this->deleteGroupAsyncWithHttpInfo($groupId) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteGroupAsyncWithHttpInfo + * + * Deletes a group. + * + * @param string $groupId String in uuid format. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteGroupAsyncWithHttpInfo($groupId) + { + $returnType = ''; + $request = $this->deleteGroupRequest($groupId); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteGroup' + * + * @param string $groupId String in uuid format. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function deleteGroupRequest($groupId) + { + // verify the required parameter 'groupId' is set + if ($groupId === null || (is_array($groupId) && count($groupId) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $groupId when calling deleteGroup' + ); + } + + $resourcePath = '/groups/{groupId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + // path params + if ($groupId !== null) { + $resourcePath = str_replace( + '{' . 'groupId' . '}', + ObjectSerializer::toPathValue($groupId), + $resourcePath + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($_tempBody)); + } else { + $httpBody = $_tempBody; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires HTTP basic authentication + if ($this->config->getUsername() !== null || $this->config->getPassword() !== null) { + $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'DELETE', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation fetchGroup + * + * Lists a group. + * + * @param string $groupId String in uuid format. (required) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Messente\Api\Model\GroupEnvelope|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook + */ + public function fetchGroup($groupId) + { + list($response) = $this->fetchGroupWithHttpInfo($groupId); + return $response; + } + + /** + * Operation fetchGroupWithHttpInfo + * + * Lists a group. + * + * @param string $groupId String in uuid format. (required) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Messente\Api\Model\GroupEnvelope|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook, HTTP status code, HTTP response headers (array of strings) + */ + public function fetchGroupWithHttpInfo($groupId) + { + $request = $this->fetchGroupRequest($groupId); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + switch($statusCode) { + case 200: + if ('\Messente\Api\Model\GroupEnvelope' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\GroupEnvelope', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Messente\Api\Model\ErrorPhonebook' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorPhonebook', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\Messente\Api\Model\ErrorPhonebook' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorPhonebook', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Messente\Api\Model\GroupEnvelope'; + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\GroupEnvelope', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation fetchGroupAsync + * + * Lists a group. + * + * @param string $groupId String in uuid format. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function fetchGroupAsync($groupId) + { + return $this->fetchGroupAsyncWithHttpInfo($groupId) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation fetchGroupAsyncWithHttpInfo + * + * Lists a group. + * + * @param string $groupId String in uuid format. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function fetchGroupAsyncWithHttpInfo($groupId) + { + $returnType = '\Messente\Api\Model\GroupEnvelope'; + $request = $this->fetchGroupRequest($groupId); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'fetchGroup' + * + * @param string $groupId String in uuid format. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function fetchGroupRequest($groupId) + { + // verify the required parameter 'groupId' is set + if ($groupId === null || (is_array($groupId) && count($groupId) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $groupId when calling fetchGroup' + ); + } + + $resourcePath = '/groups/{groupId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + // path params + if ($groupId !== null) { + $resourcePath = str_replace( + '{' . 'groupId' . '}', + ObjectSerializer::toPathValue($groupId), + $resourcePath + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($_tempBody)); + } else { + $httpBody = $_tempBody; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires HTTP basic authentication + if ($this->config->getUsername() !== null || $this->config->getPassword() !== null) { + $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation fetchGroups + * + * Returns all groups. + * + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Messente\Api\Model\GroupListEnvelope|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook + */ + public function fetchGroups() + { + list($response) = $this->fetchGroupsWithHttpInfo(); + return $response; + } + + /** + * Operation fetchGroupsWithHttpInfo + * + * Returns all groups. + * + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Messente\Api\Model\GroupListEnvelope|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook, HTTP status code, HTTP response headers (array of strings) + */ + public function fetchGroupsWithHttpInfo() + { + $request = $this->fetchGroupsRequest(); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + switch($statusCode) { + case 200: + if ('\Messente\Api\Model\GroupListEnvelope' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\GroupListEnvelope', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Messente\Api\Model\ErrorPhonebook' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorPhonebook', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + default: + if ('\Messente\Api\Model\ErrorPhonebook' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorPhonebook', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Messente\Api\Model\GroupListEnvelope'; + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\GroupListEnvelope', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation fetchGroupsAsync + * + * Returns all groups. + * + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function fetchGroupsAsync() + { + return $this->fetchGroupsAsyncWithHttpInfo() + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation fetchGroupsAsyncWithHttpInfo + * + * Returns all groups. + * + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function fetchGroupsAsyncWithHttpInfo() + { + $returnType = '\Messente\Api\Model\GroupListEnvelope'; + $request = $this->fetchGroupsRequest(); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'fetchGroups' + * + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function fetchGroupsRequest() + { + + $resourcePath = '/groups'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($_tempBody)); + } else { + $httpBody = $_tempBody; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires HTTP basic authentication + if ($this->config->getUsername() !== null || $this->config->getPassword() !== null) { + $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateGroup + * + * Updates a group with the provided name. + * + * @param string $groupId String in uuid format. (required) + * @param \Messente\Api\Model\GroupName $groupName groupName (required) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Messente\Api\Model\GroupEnvelope|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook + */ + public function updateGroup($groupId, $groupName) + { + list($response) = $this->updateGroupWithHttpInfo($groupId, $groupName); + return $response; + } + + /** + * Operation updateGroupWithHttpInfo + * + * Updates a group with the provided name. + * + * @param string $groupId String in uuid format. (required) + * @param \Messente\Api\Model\GroupName $groupName (required) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Messente\Api\Model\GroupEnvelope|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook|\Messente\Api\Model\ErrorPhonebook, HTTP status code, HTTP response headers (array of strings) + */ + public function updateGroupWithHttpInfo($groupId, $groupName) + { + $request = $this->updateGroupRequest($groupId, $groupName); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + switch($statusCode) { + case 200: + if ('\Messente\Api\Model\GroupEnvelope' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\GroupEnvelope', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\Messente\Api\Model\ErrorPhonebook' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorPhonebook', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Messente\Api\Model\ErrorPhonebook' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorPhonebook', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\Messente\Api\Model\ErrorPhonebook' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorPhonebook', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + default: + if ('\Messente\Api\Model\ErrorPhonebook' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorPhonebook', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Messente\Api\Model\GroupEnvelope'; + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\GroupEnvelope', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorPhonebook', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateGroupAsync + * + * Updates a group with the provided name. + * + * @param string $groupId String in uuid format. (required) + * @param \Messente\Api\Model\GroupName $groupName (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateGroupAsync($groupId, $groupName) + { + return $this->updateGroupAsyncWithHttpInfo($groupId, $groupName) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateGroupAsyncWithHttpInfo + * + * Updates a group with the provided name. + * + * @param string $groupId String in uuid format. (required) + * @param \Messente\Api\Model\GroupName $groupName (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateGroupAsyncWithHttpInfo($groupId, $groupName) + { + $returnType = '\Messente\Api\Model\GroupEnvelope'; + $request = $this->updateGroupRequest($groupId, $groupName); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateGroup' + * + * @param string $groupId String in uuid format. (required) + * @param \Messente\Api\Model\GroupName $groupName (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function updateGroupRequest($groupId, $groupName) + { + // verify the required parameter 'groupId' is set + if ($groupId === null || (is_array($groupId) && count($groupId) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $groupId when calling updateGroup' + ); + } + // verify the required parameter 'groupName' is set + if ($groupName === null || (is_array($groupName) && count($groupName) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $groupName when calling updateGroup' + ); + } + + $resourcePath = '/groups/{groupId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + // path params + if ($groupId !== null) { + $resourcePath = str_replace( + '{' . 'groupId' . '}', + ObjectSerializer::toPathValue($groupId), + $resourcePath + ); + } + + // body params + $_tempBody = null; + if (isset($groupName)) { + $_tempBody = $groupName; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($_tempBody)); + } else { + $httpBody = $_tempBody; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires HTTP basic authentication + if ($this->config->getUsername() !== null || $this->config->getPassword() !== null) { + $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'PUT', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/lib/Api/OmnimessageApi.php b/lib/Api/OmnimessageApi.php new file mode 100644 index 0000000..d467157 --- /dev/null +++ b/lib/Api/OmnimessageApi.php @@ -0,0 +1,635 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation cancelScheduledMessage + * + * Cancels a scheduled Omnimessage. + * + * @param string $omnimessageId UUID of the scheduled Omnimessage to be cancelled (required) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function cancelScheduledMessage($omnimessageId) + { + $this->cancelScheduledMessageWithHttpInfo($omnimessageId); + } + + /** + * Operation cancelScheduledMessageWithHttpInfo + * + * Cancels a scheduled Omnimessage. + * + * @param string $omnimessageId UUID of the scheduled Omnimessage to be cancelled (required) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of null, HTTP status code, HTTP response headers (array of strings) + */ + public function cancelScheduledMessageWithHttpInfo($omnimessageId) + { + $request = $this->cancelScheduledMessageRequest($omnimessageId); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + return [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorOmnichannel', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation cancelScheduledMessageAsync + * + * Cancels a scheduled Omnimessage. + * + * @param string $omnimessageId UUID of the scheduled Omnimessage to be cancelled (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function cancelScheduledMessageAsync($omnimessageId) + { + return $this->cancelScheduledMessageAsyncWithHttpInfo($omnimessageId) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation cancelScheduledMessageAsyncWithHttpInfo + * + * Cancels a scheduled Omnimessage. + * + * @param string $omnimessageId UUID of the scheduled Omnimessage to be cancelled (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function cancelScheduledMessageAsyncWithHttpInfo($omnimessageId) + { + $returnType = ''; + $request = $this->cancelScheduledMessageRequest($omnimessageId); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'cancelScheduledMessage' + * + * @param string $omnimessageId UUID of the scheduled Omnimessage to be cancelled (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function cancelScheduledMessageRequest($omnimessageId) + { + // verify the required parameter 'omnimessageId' is set + if ($omnimessageId === null || (is_array($omnimessageId) && count($omnimessageId) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $omnimessageId when calling cancelScheduledMessage' + ); + } + + $resourcePath = '/omnimessage/{omnimessageId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + // path params + if ($omnimessageId !== null) { + $resourcePath = str_replace( + '{' . 'omnimessageId' . '}', + ObjectSerializer::toPathValue($omnimessageId), + $resourcePath + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($_tempBody)); + } else { + $httpBody = $_tempBody; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires HTTP basic authentication + if ($this->config->getUsername() !== null || $this->config->getPassword() !== null) { + $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'DELETE', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation sendOmnimessage + * + * Sends an Omnimessage. + * + * @param \Messente\Api\Model\Omnimessage $omnimessage Omnimessage to be sent (required) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Messente\Api\Model\OmniMessageCreateSuccessResponse|\Messente\Api\Model\ErrorOmnichannel + */ + public function sendOmnimessage($omnimessage) + { + list($response) = $this->sendOmnimessageWithHttpInfo($omnimessage); + return $response; + } + + /** + * Operation sendOmnimessageWithHttpInfo + * + * Sends an Omnimessage. + * + * @param \Messente\Api\Model\Omnimessage $omnimessage Omnimessage to be sent (required) + * + * @throws \Messente\Api\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Messente\Api\Model\OmniMessageCreateSuccessResponse|\Messente\Api\Model\ErrorOmnichannel, HTTP status code, HTTP response headers (array of strings) + */ + public function sendOmnimessageWithHttpInfo($omnimessage) + { + $request = $this->sendOmnimessageRequest($omnimessage); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + switch($statusCode) { + case 201: + if ('\Messente\Api\Model\OmniMessageCreateSuccessResponse' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\OmniMessageCreateSuccessResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\Messente\Api\Model\ErrorOmnichannel' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\Messente\Api\Model\ErrorOmnichannel', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Messente\Api\Model\OmniMessageCreateSuccessResponse'; + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 201: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\OmniMessageCreateSuccessResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Messente\Api\Model\ErrorOmnichannel', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation sendOmnimessageAsync + * + * Sends an Omnimessage. + * + * @param \Messente\Api\Model\Omnimessage $omnimessage Omnimessage to be sent (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function sendOmnimessageAsync($omnimessage) + { + return $this->sendOmnimessageAsyncWithHttpInfo($omnimessage) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation sendOmnimessageAsyncWithHttpInfo + * + * Sends an Omnimessage. + * + * @param \Messente\Api\Model\Omnimessage $omnimessage Omnimessage to be sent (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function sendOmnimessageAsyncWithHttpInfo($omnimessage) + { + $returnType = '\Messente\Api\Model\OmniMessageCreateSuccessResponse'; + $request = $this->sendOmnimessageRequest($omnimessage); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'sendOmnimessage' + * + * @param \Messente\Api\Model\Omnimessage $omnimessage Omnimessage to be sent (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function sendOmnimessageRequest($omnimessage) + { + // verify the required parameter 'omnimessage' is set + if ($omnimessage === null || (is_array($omnimessage) && count($omnimessage) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $omnimessage when calling sendOmnimessage' + ); + } + + $resourcePath = '/omnimessage'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // body params + $_tempBody = null; + if (isset($omnimessage)) { + $_tempBody = $omnimessage; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($_tempBody)); + } else { + $httpBody = $_tempBody; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires HTTP basic authentication + if ($this->config->getUsername() !== null || $this->config->getPassword() !== null) { + $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/lib/ApiException.php b/lib/ApiException.php new file mode 100644 index 0000000..cf83581 --- /dev/null +++ b/lib/ApiException.php @@ -0,0 +1,121 @@ +responseHeaders = $responseHeaders; + $this->responseBody = $responseBody; + } + + /** + * Gets the HTTP response header + * + * @return string[]|null HTTP response header + */ + public function getResponseHeaders() + { + return $this->responseHeaders; + } + + /** + * Gets the HTTP body of the server response either as Json or string + * + * @return mixed HTTP body of the server response either as \stdClass or string + */ + public function getResponseBody() + { + return $this->responseBody; + } + + /** + * Sets the deseralized response object (during deserialization) + * + * @param mixed $obj Deserialized response object + * + * @return void + */ + public function setResponseObject($obj) + { + $this->responseObject = $obj; + } + + /** + * Gets the deseralized response object (during deserialization) + * + * @return mixed the deserialized response object + */ + public function getResponseObject() + { + return $this->responseObject; + } +} diff --git a/lib/Configuration.php b/lib/Configuration.php new file mode 100644 index 0000000..741a0fd --- /dev/null +++ b/lib/Configuration.php @@ -0,0 +1,485 @@ +tempFolderPath = sys_get_temp_dir(); + } + + /** + * Sets API key + * + * @param string $apiKeyIdentifier API key identifier (authentication scheme) + * @param string $key API key or token + * + * @return $this + */ + public function setApiKey($apiKeyIdentifier, $key) + { + $this->apiKeys[$apiKeyIdentifier] = $key; + return $this; + } + + /** + * Gets API key + * + * @param string $apiKeyIdentifier API key identifier (authentication scheme) + * + * @return string API key or token + */ + public function getApiKey($apiKeyIdentifier) + { + return isset($this->apiKeys[$apiKeyIdentifier]) ? $this->apiKeys[$apiKeyIdentifier] : null; + } + + /** + * Sets the prefix for API key (e.g. Bearer) + * + * @param string $apiKeyIdentifier API key identifier (authentication scheme) + * @param string $prefix API key prefix, e.g. Bearer + * + * @return $this + */ + public function setApiKeyPrefix($apiKeyIdentifier, $prefix) + { + $this->apiKeyPrefixes[$apiKeyIdentifier] = $prefix; + return $this; + } + + /** + * Gets API key prefix + * + * @param string $apiKeyIdentifier API key identifier (authentication scheme) + * + * @return string + */ + public function getApiKeyPrefix($apiKeyIdentifier) + { + return isset($this->apiKeyPrefixes[$apiKeyIdentifier]) ? $this->apiKeyPrefixes[$apiKeyIdentifier] : null; + } + + /** + * Sets the access token for OAuth + * + * @param string $accessToken Token for OAuth + * + * @return $this + */ + public function setAccessToken($accessToken) + { + $this->accessToken = $accessToken; + return $this; + } + + /** + * Gets the access token for OAuth + * + * @return string Access token for OAuth + */ + public function getAccessToken() + { + return $this->accessToken; + } + + /** + * Sets the username for HTTP basic authentication + * + * @param string $username Username for HTTP basic authentication + * + * @return $this + */ + public function setUsername($username) + { + $this->username = $username; + return $this; + } + + /** + * Gets the username for HTTP basic authentication + * + * @return string Username for HTTP basic authentication + */ + public function getUsername() + { + return $this->username; + } + + /** + * Sets the password for HTTP basic authentication + * + * @param string $password Password for HTTP basic authentication + * + * @return $this + */ + public function setPassword($password) + { + $this->password = $password; + return $this; + } + + /** + * Gets the password for HTTP basic authentication + * + * @return string Password for HTTP basic authentication + */ + public function getPassword() + { + return $this->password; + } + + /** + * Sets the host + * + * @param string $host Host + * + * @return $this + */ + public function setHost($host) + { + $this->host = $host; + return $this; + } + + /** + * Gets the host + * + * @return string Host + */ + public function getHost() + { + return $this->host; + } + + /** + * Sets the user agent of the api client + * + * @param string $userAgent the user agent of the api client + * + * @throws \InvalidArgumentException + * @return $this + */ + public function setUserAgent($userAgent) + { + if (!is_string($userAgent)) { + throw new \InvalidArgumentException('User-agent must be a string.'); + } + + $this->userAgent = $userAgent; + return $this; + } + + /** + * Gets the user agent of the api client + * + * @return string user agent + */ + public function getUserAgent() + { + return $this->userAgent; + } + + /** + * Sets debug flag + * + * @param bool $debug Debug flag + * + * @return $this + */ + public function setDebug($debug) + { + $this->debug = $debug; + return $this; + } + + /** + * Gets the debug flag + * + * @return bool + */ + public function getDebug() + { + return $this->debug; + } + + /** + * Sets the debug file + * + * @param string $debugFile Debug file + * + * @return $this + */ + public function setDebugFile($debugFile) + { + $this->debugFile = $debugFile; + return $this; + } + + /** + * Gets the debug file + * + * @return string + */ + public function getDebugFile() + { + return $this->debugFile; + } + + /** + * Sets the temp folder path + * + * @param string $tempFolderPath Temp folder path + * + * @return $this + */ + public function setTempFolderPath($tempFolderPath) + { + $this->tempFolderPath = $tempFolderPath; + return $this; + } + + /** + * Gets the temp folder path + * + * @return string Temp folder path + */ + public function getTempFolderPath() + { + return $this->tempFolderPath; + } + + /** + * Gets the default configuration instance + * + * @return Configuration + */ + public static function getDefaultConfiguration() + { + if (self::$defaultConfiguration === null) { + self::$defaultConfiguration = new Configuration(); + } + + return self::$defaultConfiguration; + } + + /** + * Sets the detault configuration instance + * + * @param Configuration $config An instance of the Configuration Object + * + * @return void + */ + public static function setDefaultConfiguration(Configuration $config) + { + self::$defaultConfiguration = $config; + } + + /** + * Gets the essential information for debugging + * + * @return string The report for debugging + */ + public static function toDebugReport() + { + $report = 'PHP SDK (Messente\Api) Debug Report:' . PHP_EOL; + $report .= ' OS: ' . php_uname() . PHP_EOL; + $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; + $report .= ' OpenAPI Spec Version: 1.0.0' . PHP_EOL; + $report .= ' SDK Package Version: 1.0.0' . PHP_EOL; + $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; + + return $report; + } + + /** + * Get API key (with prefix if set) + * + * @param string $apiKeyIdentifier name of apikey + * + * @return string API key with the prefix + */ + public function getApiKeyWithPrefix($apiKeyIdentifier) + { + $prefix = $this->getApiKeyPrefix($apiKeyIdentifier); + $apiKey = $this->getApiKey($apiKeyIdentifier); + + if ($apiKey === null) { + return null; + } + + if ($prefix === null) { + $keyWithPrefix = $apiKey; + } else { + $keyWithPrefix = $prefix . ' ' . $apiKey; + } + + return $keyWithPrefix; + } + + /** + * Returns an array of host settings + * + * @return an array of host settings + */ + public function getHostSettings() + { + return array( + array( + "url" => "https://api.messente.com/v1", + "description" => "No description provided", + ) + ); + } + + /** + * Returns URL based on the index and variables + * + * @param index array index of the host settings + * @param variables hash of variable and the corresponding value (optional) + * @return URL based on host settings + */ + public function getHostFromSettings($index, $variables = null) + { + if (null === $variables) { + $variables = array(); + } + + $hosts = $this->getHostSettings(); + + // check array index out of bound + if ($index < 0 || $index >= sizeof($hosts)) { + throw new \InvalidArgumentException("Invalid index $index when selecting the host. Must be less than ".sizeof($hosts)); + } + + $host = $hosts[$index]; + $url = $host["url"]; + + // go through variable and assign a value + foreach ($host["variables"] as $name => $variable) { + if (array_key_exists($name, $variables)) { // check to see if it's in the variables provided by the user + if (in_array($variables[$name], $variable["enum_values"])) { // check to see if the value is in the enum + $url = str_replace("{".$name."}", $variables[$name], $url); + } else { + throw new \InvalidArgumentException("The variable `$name` in the host URL has invalid value ".$variables[$name].". Must be ".join(',', $variable["enum_values"])."."); + } + } else { + // use default value + $url = str_replace("{".$name."}", $variable["default_value"], $url); + } + } + + return $url; + } +} diff --git a/lib/HeaderSelector.php b/lib/HeaderSelector.php new file mode 100644 index 0000000..74421b3 --- /dev/null +++ b/lib/HeaderSelector.php @@ -0,0 +1,110 @@ +selectAcceptHeader($accept); + if ($accept !== null) { + $headers['Accept'] = $accept; + } + + $headers['Content-Type'] = $this->selectContentTypeHeader($contentTypes); + return $headers; + } + + /** + * @param string[] $accept + * @return array + */ + public function selectHeadersForMultipart($accept) + { + $headers = $this->selectHeaders($accept, []); + + unset($headers['Content-Type']); + return $headers; + } + + /** + * Return the header 'Accept' based on an array of Accept provided + * + * @param string[] $accept Array of header + * + * @return string Accept (e.g. application/json) + */ + private function selectAcceptHeader($accept) + { + if (count($accept) === 0 || (count($accept) === 1 && $accept[0] === '')) { + return null; + } elseif (preg_grep("/application\/json/i", $accept)) { + return 'application/json'; + } else { + return implode(',', $accept); + } + } + + /** + * Return the content type based on an array of content-type provided + * + * @param string[] $contentType Array fo content-type + * + * @return string Content-Type (e.g. application/json) + */ + private function selectContentTypeHeader($contentType) + { + if (count($contentType) === 0 || (count($contentType) === 1 && $contentType[0] === '')) { + return 'application/json'; + } elseif (preg_grep("/application\/json/i", $contentType)) { + return 'application/json'; + } else { + return implode(',', $contentType); + } + } +} + diff --git a/lib/Model/Channel.php b/lib/Model/Channel.php new file mode 100644 index 0000000..51764f1 --- /dev/null +++ b/lib/Model/Channel.php @@ -0,0 +1,65 @@ + '\Messente\Api\Model\ContactFields' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'contact' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'contact' => 'contact' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'contact' => 'setContact' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'contact' => 'getContact' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['contact'] = isset($data['contact']) ? $data['contact'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets contact + * + * @return \Messente\Api\Model\ContactFields|null + */ + public function getContact() + { + return $this->container['contact']; + } + + /** + * Sets contact + * + * @param \Messente\Api\Model\ContactFields|null $contact contact + * + * @return $this + */ + public function setContact($contact) + { + $this->container['contact'] = $contact; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/lib/Model/ContactFields.php b/lib/Model/ContactFields.php new file mode 100644 index 0000000..69e6a791 --- /dev/null +++ b/lib/Model/ContactFields.php @@ -0,0 +1,570 @@ + 'string', + 'email' => 'string', + 'firstName' => 'string', + 'lastName' => 'string', + 'company' => 'string', + 'title' => 'string', + 'custom' => 'string', + 'custom2' => 'string', + 'custom3' => 'string', + 'custom4' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'phoneNumber' => null, + 'email' => null, + 'firstName' => null, + 'lastName' => null, + 'company' => null, + 'title' => null, + 'custom' => null, + 'custom2' => null, + 'custom3' => null, + 'custom4' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'phoneNumber' => 'phoneNumber', + 'email' => 'email', + 'firstName' => 'firstName', + 'lastName' => 'lastName', + 'company' => 'company', + 'title' => 'title', + 'custom' => 'custom', + 'custom2' => 'custom2', + 'custom3' => 'custom3', + 'custom4' => 'custom4' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'phoneNumber' => 'setPhoneNumber', + 'email' => 'setEmail', + 'firstName' => 'setFirstName', + 'lastName' => 'setLastName', + 'company' => 'setCompany', + 'title' => 'setTitle', + 'custom' => 'setCustom', + 'custom2' => 'setCustom2', + 'custom3' => 'setCustom3', + 'custom4' => 'setCustom4' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'phoneNumber' => 'getPhoneNumber', + 'email' => 'getEmail', + 'firstName' => 'getFirstName', + 'lastName' => 'getLastName', + 'company' => 'getCompany', + 'title' => 'getTitle', + 'custom' => 'getCustom', + 'custom2' => 'getCustom2', + 'custom3' => 'getCustom3', + 'custom4' => 'getCustom4' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['phoneNumber'] = isset($data['phoneNumber']) ? $data['phoneNumber'] : null; + $this->container['email'] = isset($data['email']) ? $data['email'] : null; + $this->container['firstName'] = isset($data['firstName']) ? $data['firstName'] : null; + $this->container['lastName'] = isset($data['lastName']) ? $data['lastName'] : null; + $this->container['company'] = isset($data['company']) ? $data['company'] : null; + $this->container['title'] = isset($data['title']) ? $data['title'] : null; + $this->container['custom'] = isset($data['custom']) ? $data['custom'] : null; + $this->container['custom2'] = isset($data['custom2']) ? $data['custom2'] : null; + $this->container['custom3'] = isset($data['custom3']) ? $data['custom3'] : null; + $this->container['custom4'] = isset($data['custom4']) ? $data['custom4'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['phoneNumber'] === null) { + $invalidProperties[] = "'phoneNumber' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets phoneNumber + * + * @return string + */ + public function getPhoneNumber() + { + return $this->container['phoneNumber']; + } + + /** + * Sets phoneNumber + * + * @param string $phoneNumber Phone number in e.164 format + * + * @return $this + */ + public function setPhoneNumber($phoneNumber) + { + $this->container['phoneNumber'] = $phoneNumber; + + return $this; + } + + /** + * Gets email + * + * @return string|null + */ + public function getEmail() + { + return $this->container['email']; + } + + /** + * Sets email + * + * @param string|null $email email + * + * @return $this + */ + public function setEmail($email) + { + $this->container['email'] = $email; + + return $this; + } + + /** + * Gets firstName + * + * @return string|null + */ + public function getFirstName() + { + return $this->container['firstName']; + } + + /** + * Sets firstName + * + * @param string|null $firstName firstName + * + * @return $this + */ + public function setFirstName($firstName) + { + $this->container['firstName'] = $firstName; + + return $this; + } + + /** + * Gets lastName + * + * @return string|null + */ + public function getLastName() + { + return $this->container['lastName']; + } + + /** + * Sets lastName + * + * @param string|null $lastName lastName + * + * @return $this + */ + public function setLastName($lastName) + { + $this->container['lastName'] = $lastName; + + return $this; + } + + /** + * Gets company + * + * @return string|null + */ + public function getCompany() + { + return $this->container['company']; + } + + /** + * Sets company + * + * @param string|null $company company + * + * @return $this + */ + public function setCompany($company) + { + $this->container['company'] = $company; + + return $this; + } + + /** + * Gets title + * + * @return string|null + */ + public function getTitle() + { + return $this->container['title']; + } + + /** + * Sets title + * + * @param string|null $title title + * + * @return $this + */ + public function setTitle($title) + { + $this->container['title'] = $title; + + return $this; + } + + /** + * Gets custom + * + * @return string|null + */ + public function getCustom() + { + return $this->container['custom']; + } + + /** + * Sets custom + * + * @param string|null $custom custom + * + * @return $this + */ + public function setCustom($custom) + { + $this->container['custom'] = $custom; + + return $this; + } + + /** + * Gets custom2 + * + * @return string|null + */ + public function getCustom2() + { + return $this->container['custom2']; + } + + /** + * Sets custom2 + * + * @param string|null $custom2 custom2 + * + * @return $this + */ + public function setCustom2($custom2) + { + $this->container['custom2'] = $custom2; + + return $this; + } + + /** + * Gets custom3 + * + * @return string|null + */ + public function getCustom3() + { + return $this->container['custom3']; + } + + /** + * Sets custom3 + * + * @param string|null $custom3 custom3 + * + * @return $this + */ + public function setCustom3($custom3) + { + $this->container['custom3'] = $custom3; + + return $this; + } + + /** + * Gets custom4 + * + * @return string|null + */ + public function getCustom4() + { + return $this->container['custom4']; + } + + /** + * Sets custom4 + * + * @param string|null $custom4 custom4 + * + * @return $this + */ + public function setCustom4($custom4) + { + $this->container['custom4'] = $custom4; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/lib/Model/ContactListEnvelope.php b/lib/Model/ContactListEnvelope.php new file mode 100644 index 0000000..5389964 --- /dev/null +++ b/lib/Model/ContactListEnvelope.php @@ -0,0 +1,297 @@ + '\Messente\Api\Model\ContactFields[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'contacts' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'contacts' => 'contacts' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'contacts' => 'setContacts' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'contacts' => 'getContacts' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['contacts'] = isset($data['contacts']) ? $data['contacts'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets contacts + * + * @return \Messente\Api\Model\ContactFields[]|null + */ + public function getContacts() + { + return $this->container['contacts']; + } + + /** + * Sets contacts + * + * @param \Messente\Api\Model\ContactFields[]|null $contacts contacts + * + * @return $this + */ + public function setContacts($contacts) + { + $this->container['contacts'] = $contacts; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/lib/Model/ContactUpdateFields.php b/lib/Model/ContactUpdateFields.php new file mode 100644 index 0000000..935c592 --- /dev/null +++ b/lib/Model/ContactUpdateFields.php @@ -0,0 +1,537 @@ + 'string', + 'firstName' => 'string', + 'lastName' => 'string', + 'company' => 'string', + 'title' => 'string', + 'custom' => 'string', + 'custom2' => 'string', + 'custom3' => 'string', + 'custom4' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'email' => null, + 'firstName' => null, + 'lastName' => null, + 'company' => null, + 'title' => null, + 'custom' => null, + 'custom2' => null, + 'custom3' => null, + 'custom4' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'email' => 'email', + 'firstName' => 'firstName', + 'lastName' => 'lastName', + 'company' => 'company', + 'title' => 'title', + 'custom' => 'custom', + 'custom2' => 'custom2', + 'custom3' => 'custom3', + 'custom4' => 'custom4' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'email' => 'setEmail', + 'firstName' => 'setFirstName', + 'lastName' => 'setLastName', + 'company' => 'setCompany', + 'title' => 'setTitle', + 'custom' => 'setCustom', + 'custom2' => 'setCustom2', + 'custom3' => 'setCustom3', + 'custom4' => 'setCustom4' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'email' => 'getEmail', + 'firstName' => 'getFirstName', + 'lastName' => 'getLastName', + 'company' => 'getCompany', + 'title' => 'getTitle', + 'custom' => 'getCustom', + 'custom2' => 'getCustom2', + 'custom3' => 'getCustom3', + 'custom4' => 'getCustom4' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['email'] = isset($data['email']) ? $data['email'] : null; + $this->container['firstName'] = isset($data['firstName']) ? $data['firstName'] : null; + $this->container['lastName'] = isset($data['lastName']) ? $data['lastName'] : null; + $this->container['company'] = isset($data['company']) ? $data['company'] : null; + $this->container['title'] = isset($data['title']) ? $data['title'] : null; + $this->container['custom'] = isset($data['custom']) ? $data['custom'] : null; + $this->container['custom2'] = isset($data['custom2']) ? $data['custom2'] : null; + $this->container['custom3'] = isset($data['custom3']) ? $data['custom3'] : null; + $this->container['custom4'] = isset($data['custom4']) ? $data['custom4'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets email + * + * @return string|null + */ + public function getEmail() + { + return $this->container['email']; + } + + /** + * Sets email + * + * @param string|null $email email + * + * @return $this + */ + public function setEmail($email) + { + $this->container['email'] = $email; + + return $this; + } + + /** + * Gets firstName + * + * @return string|null + */ + public function getFirstName() + { + return $this->container['firstName']; + } + + /** + * Sets firstName + * + * @param string|null $firstName firstName + * + * @return $this + */ + public function setFirstName($firstName) + { + $this->container['firstName'] = $firstName; + + return $this; + } + + /** + * Gets lastName + * + * @return string|null + */ + public function getLastName() + { + return $this->container['lastName']; + } + + /** + * Sets lastName + * + * @param string|null $lastName lastName + * + * @return $this + */ + public function setLastName($lastName) + { + $this->container['lastName'] = $lastName; + + return $this; + } + + /** + * Gets company + * + * @return string|null + */ + public function getCompany() + { + return $this->container['company']; + } + + /** + * Sets company + * + * @param string|null $company company + * + * @return $this + */ + public function setCompany($company) + { + $this->container['company'] = $company; + + return $this; + } + + /** + * Gets title + * + * @return string|null + */ + public function getTitle() + { + return $this->container['title']; + } + + /** + * Sets title + * + * @param string|null $title title + * + * @return $this + */ + public function setTitle($title) + { + $this->container['title'] = $title; + + return $this; + } + + /** + * Gets custom + * + * @return string|null + */ + public function getCustom() + { + return $this->container['custom']; + } + + /** + * Sets custom + * + * @param string|null $custom custom + * + * @return $this + */ + public function setCustom($custom) + { + $this->container['custom'] = $custom; + + return $this; + } + + /** + * Gets custom2 + * + * @return string|null + */ + public function getCustom2() + { + return $this->container['custom2']; + } + + /** + * Sets custom2 + * + * @param string|null $custom2 custom2 + * + * @return $this + */ + public function setCustom2($custom2) + { + $this->container['custom2'] = $custom2; + + return $this; + } + + /** + * Gets custom3 + * + * @return string|null + */ + public function getCustom3() + { + return $this->container['custom3']; + } + + /** + * Sets custom3 + * + * @param string|null $custom3 custom3 + * + * @return $this + */ + public function setCustom3($custom3) + { + $this->container['custom3'] = $custom3; + + return $this; + } + + /** + * Gets custom4 + * + * @return string|null + */ + public function getCustom4() + { + return $this->container['custom4']; + } + + /** + * Sets custom4 + * + * @param string|null $custom4 custom4 + * + * @return $this + */ + public function setCustom4($custom4) + { + $this->container['custom4'] = $custom4; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/lib/Model/DeliveryReportResponse.php b/lib/Model/DeliveryReportResponse.php new file mode 100644 index 0000000..b6227b3 --- /dev/null +++ b/lib/Model/DeliveryReportResponse.php @@ -0,0 +1,366 @@ + '\Messente\Api\Model\DeliveryResult[]', + 'to' => 'string', + 'omnimessageId' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'statuses' => null, + 'to' => null, + 'omnimessageId' => 'uuid' + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'statuses' => 'statuses', + 'to' => 'to', + 'omnimessageId' => 'omnimessage_id' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'statuses' => 'setStatuses', + 'to' => 'setTo', + 'omnimessageId' => 'setOmnimessageId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'statuses' => 'getStatuses', + 'to' => 'getTo', + 'omnimessageId' => 'getOmnimessageId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['statuses'] = isset($data['statuses']) ? $data['statuses'] : null; + $this->container['to'] = isset($data['to']) ? $data['to'] : null; + $this->container['omnimessageId'] = isset($data['omnimessageId']) ? $data['omnimessageId'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['statuses'] === null) { + $invalidProperties[] = "'statuses' can't be null"; + } + if ($this->container['to'] === null) { + $invalidProperties[] = "'to' can't be null"; + } + if ($this->container['omnimessageId'] === null) { + $invalidProperties[] = "'omnimessageId' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets statuses + * + * @return \Messente\Api\Model\DeliveryResult[] + */ + public function getStatuses() + { + return $this->container['statuses']; + } + + /** + * Sets statuses + * + * @param \Messente\Api\Model\DeliveryResult[] $statuses Contains the delivery reports for each channnel, ordered by send order + * + * @return $this + */ + public function setStatuses($statuses) + { + $this->container['statuses'] = $statuses; + + return $this; + } + + /** + * Gets to + * + * @return string + */ + public function getTo() + { + return $this->container['to']; + } + + /** + * Sets to + * + * @param string $to Phone number in e.164 format + * + * @return $this + */ + public function setTo($to) + { + $this->container['to'] = $to; + + return $this; + } + + /** + * Gets omnimessageId + * + * @return string + */ + public function getOmnimessageId() + { + return $this->container['omnimessageId']; + } + + /** + * Sets omnimessageId + * + * @param string $omnimessageId Unique identifier for the Omnimessage + * + * @return $this + */ + public function setOmnimessageId($omnimessageId) + { + $this->container['omnimessageId'] = $omnimessageId; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/lib/Model/DeliveryResult.php b/lib/Model/DeliveryResult.php new file mode 100644 index 0000000..1c39c11 --- /dev/null +++ b/lib/Model/DeliveryResult.php @@ -0,0 +1,447 @@ + '\Messente\Api\Model\Status', + 'channel' => '\Messente\Api\Model\Channel', + 'messageId' => 'string', + 'error' => 'string', + 'err' => '\Messente\Api\Model\ErrorCodeOmnichannelMachine', + 'timestamp' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'status' => null, + 'channel' => null, + 'messageId' => 'uuid', + 'error' => null, + 'err' => null, + 'timestamp' => 'date-time' + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'channel' => 'channel', + 'messageId' => 'message_id', + 'error' => 'error', + 'err' => 'err', + 'timestamp' => 'timestamp' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'channel' => 'setChannel', + 'messageId' => 'setMessageId', + 'error' => 'setError', + 'err' => 'setErr', + 'timestamp' => 'setTimestamp' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'channel' => 'getChannel', + 'messageId' => 'getMessageId', + 'error' => 'getError', + 'err' => 'getErr', + 'timestamp' => 'getTimestamp' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['status'] = isset($data['status']) ? $data['status'] : null; + $this->container['channel'] = isset($data['channel']) ? $data['channel'] : null; + $this->container['messageId'] = isset($data['messageId']) ? $data['messageId'] : null; + $this->container['error'] = isset($data['error']) ? $data['error'] : null; + $this->container['err'] = isset($data['err']) ? $data['err'] : null; + $this->container['timestamp'] = isset($data['timestamp']) ? $data['timestamp'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \Messente\Api\Model\Status|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \Messente\Api\Model\Status|null $status status + * + * @return $this + */ + public function setStatus($status) + { + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets channel + * + * @return \Messente\Api\Model\Channel|null + */ + public function getChannel() + { + return $this->container['channel']; + } + + /** + * Sets channel + * + * @param \Messente\Api\Model\Channel|null $channel channel + * + * @return $this + */ + public function setChannel($channel) + { + $this->container['channel'] = $channel; + + return $this; + } + + /** + * Gets messageId + * + * @return string|null + */ + public function getMessageId() + { + return $this->container['messageId']; + } + + /** + * Sets messageId + * + * @param string|null $messageId Unique identifier for the message + * + * @return $this + */ + public function setMessageId($messageId) + { + $this->container['messageId'] = $messageId; + + return $this; + } + + /** + * Gets error + * + * @return string|null + */ + public function getError() + { + return $this->container['error']; + } + + /** + * Sets error + * + * @param string|null $error Human-readable description of what went wrong, *null* in case of success or if the messages has not been processed yet + * + * @return $this + */ + public function setError($error) + { + $this->container['error'] = $error; + + return $this; + } + + /** + * Gets err + * + * @return \Messente\Api\Model\ErrorCodeOmnichannelMachine|null + */ + public function getErr() + { + return $this->container['err']; + } + + /** + * Sets err + * + * @param \Messente\Api\Model\ErrorCodeOmnichannelMachine|null $err err + * + * @return $this + */ + public function setErr($err) + { + $this->container['err'] = $err; + + return $this; + } + + /** + * Gets timestamp + * + * @return \DateTime|null + */ + public function getTimestamp() + { + return $this->container['timestamp']; + } + + /** + * Sets timestamp + * + * @param \DateTime|null $timestamp When this status was received by Omnichannel API + * + * @return $this + */ + public function setTimestamp($timestamp) + { + $this->container['timestamp'] = $timestamp; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/lib/Model/ErrorCodeOmnichannel.php b/lib/Model/ErrorCodeOmnichannel.php new file mode 100644 index 0000000..2111ed1 --- /dev/null +++ b/lib/Model/ErrorCodeOmnichannel.php @@ -0,0 +1,73 @@ + '\Messente\Api\Model\ErrorTitleOmnichannel', + 'detail' => 'string', + 'code' => '\Messente\Api\Model\ErrorCodeOmnichannel', + 'source' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'title' => null, + 'detail' => null, + 'code' => null, + 'source' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'title' => 'title', + 'detail' => 'detail', + 'code' => 'code', + 'source' => 'source' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'title' => 'setTitle', + 'detail' => 'setDetail', + 'code' => 'setCode', + 'source' => 'setSource' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'title' => 'getTitle', + 'detail' => 'getDetail', + 'code' => 'getCode', + 'source' => 'getSource' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['title'] = isset($data['title']) ? $data['title'] : null; + $this->container['detail'] = isset($data['detail']) ? $data['detail'] : null; + $this->container['code'] = isset($data['code']) ? $data['code'] : null; + $this->container['source'] = isset($data['source']) ? $data['source'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['title'] === null) { + $invalidProperties[] = "'title' can't be null"; + } + if ($this->container['detail'] === null) { + $invalidProperties[] = "'detail' can't be null"; + } + if ($this->container['code'] === null) { + $invalidProperties[] = "'code' can't be null"; + } + if ($this->container['source'] === null) { + $invalidProperties[] = "'source' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets title + * + * @return \Messente\Api\Model\ErrorTitleOmnichannel + */ + public function getTitle() + { + return $this->container['title']; + } + + /** + * Sets title + * + * @param \Messente\Api\Model\ErrorTitleOmnichannel $title title + * + * @return $this + */ + public function setTitle($title) + { + $this->container['title'] = $title; + + return $this; + } + + /** + * Gets detail + * + * @return string + */ + public function getDetail() + { + return $this->container['detail']; + } + + /** + * Sets detail + * + * @param string $detail Free form more detailed description of the error. + * + * @return $this + */ + public function setDetail($detail) + { + $this->container['detail'] = $detail; + + return $this; + } + + /** + * Gets code + * + * @return \Messente\Api\Model\ErrorCodeOmnichannel + */ + public function getCode() + { + return $this->container['code']; + } + + /** + * Sets code + * + * @param \Messente\Api\Model\ErrorCodeOmnichannel $code code + * + * @return $this + */ + public function setCode($code) + { + $this->container['code'] = $code; + + return $this; + } + + /** + * Gets source + * + * @return string + */ + public function getSource() + { + return $this->container['source']; + } + + /** + * Sets source + * + * @param string $source Describes which field is causing the issue in the payload, null for non 400 status code responses + * + * @return $this + */ + public function setSource($source) + { + $this->container['source'] = $source; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/lib/Model/ErrorItemPhonebook.php b/lib/Model/ErrorItemPhonebook.php new file mode 100644 index 0000000..e6fedcf --- /dev/null +++ b/lib/Model/ErrorItemPhonebook.php @@ -0,0 +1,366 @@ + '\Messente\Api\Model\ErrorTitlePhonebook', + 'detail' => 'string', + 'code' => '\Messente\Api\Model\ErrorCodePhonebook' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'title' => null, + 'detail' => null, + 'code' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'title' => 'title', + 'detail' => 'detail', + 'code' => 'code' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'title' => 'setTitle', + 'detail' => 'setDetail', + 'code' => 'setCode' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'title' => 'getTitle', + 'detail' => 'getDetail', + 'code' => 'getCode' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['title'] = isset($data['title']) ? $data['title'] : null; + $this->container['detail'] = isset($data['detail']) ? $data['detail'] : null; + $this->container['code'] = isset($data['code']) ? $data['code'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['title'] === null) { + $invalidProperties[] = "'title' can't be null"; + } + if ($this->container['detail'] === null) { + $invalidProperties[] = "'detail' can't be null"; + } + if ($this->container['code'] === null) { + $invalidProperties[] = "'code' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets title + * + * @return \Messente\Api\Model\ErrorTitlePhonebook + */ + public function getTitle() + { + return $this->container['title']; + } + + /** + * Sets title + * + * @param \Messente\Api\Model\ErrorTitlePhonebook $title title + * + * @return $this + */ + public function setTitle($title) + { + $this->container['title'] = $title; + + return $this; + } + + /** + * Gets detail + * + * @return string + */ + public function getDetail() + { + return $this->container['detail']; + } + + /** + * Sets detail + * + * @param string $detail Free form more detailed description of the error. + * + * @return $this + */ + public function setDetail($detail) + { + $this->container['detail'] = $detail; + + return $this; + } + + /** + * Gets code + * + * @return \Messente\Api\Model\ErrorCodePhonebook + */ + public function getCode() + { + return $this->container['code']; + } + + /** + * Sets code + * + * @param \Messente\Api\Model\ErrorCodePhonebook $code code + * + * @return $this + */ + public function setCode($code) + { + $this->container['code'] = $code; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/lib/Model/ErrorOmnichannel.php b/lib/Model/ErrorOmnichannel.php new file mode 100644 index 0000000..03c1d18 --- /dev/null +++ b/lib/Model/ErrorOmnichannel.php @@ -0,0 +1,300 @@ + '\Messente\Api\Model\ErrorItemOmnichannel[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'errors' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'errors' => 'errors' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'errors' => 'setErrors' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'errors' => 'getErrors' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['errors'] = isset($data['errors']) ? $data['errors'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['errors'] === null) { + $invalidProperties[] = "'errors' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets errors + * + * @return \Messente\Api\Model\ErrorItemOmnichannel[] + */ + public function getErrors() + { + return $this->container['errors']; + } + + /** + * Sets errors + * + * @param \Messente\Api\Model\ErrorItemOmnichannel[] $errors errors + * + * @return $this + */ + public function setErrors($errors) + { + $this->container['errors'] = $errors; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/lib/Model/ErrorPhonebook.php b/lib/Model/ErrorPhonebook.php new file mode 100644 index 0000000..3b355a6 --- /dev/null +++ b/lib/Model/ErrorPhonebook.php @@ -0,0 +1,300 @@ + '\Messente\Api\Model\ErrorItemPhonebook[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'errors' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'errors' => 'errors' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'errors' => 'setErrors' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'errors' => 'getErrors' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['errors'] = isset($data['errors']) ? $data['errors'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['errors'] === null) { + $invalidProperties[] = "'errors' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets errors + * + * @return \Messente\Api\Model\ErrorItemPhonebook[] + */ + public function getErrors() + { + return $this->container['errors']; + } + + /** + * Sets errors + * + * @param \Messente\Api\Model\ErrorItemPhonebook[] $errors errors + * + * @return $this + */ + public function setErrors($errors) + { + $this->container['errors'] = $errors; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/lib/Model/ErrorTitleOmnichannel.php b/lib/Model/ErrorTitleOmnichannel.php new file mode 100644 index 0000000..326b2c8 --- /dev/null +++ b/lib/Model/ErrorTitleOmnichannel.php @@ -0,0 +1,73 @@ + 'string[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'phoneNumbers' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'phoneNumbers' => 'phoneNumbers' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'phoneNumbers' => 'setPhoneNumbers' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'phoneNumbers' => 'getPhoneNumbers' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['phoneNumbers'] = isset($data['phoneNumbers']) ? $data['phoneNumbers'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets phoneNumbers + * + * @return string[]|null + */ + public function getPhoneNumbers() + { + return $this->container['phoneNumbers']; + } + + /** + * Sets phoneNumbers + * + * @param string[]|null $phoneNumbers phoneNumbers + * + * @return $this + */ + public function setPhoneNumbers($phoneNumbers) + { + $this->container['phoneNumbers'] = $phoneNumbers; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/lib/Model/GroupEnvelope.php b/lib/Model/GroupEnvelope.php new file mode 100644 index 0000000..b6f9992 --- /dev/null +++ b/lib/Model/GroupEnvelope.php @@ -0,0 +1,297 @@ + '\Messente\Api\Model\GroupResponseFields' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'group' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'group' => 'group' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'group' => 'setGroup' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'group' => 'getGroup' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['group'] = isset($data['group']) ? $data['group'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets group + * + * @return \Messente\Api\Model\GroupResponseFields|null + */ + public function getGroup() + { + return $this->container['group']; + } + + /** + * Sets group + * + * @param \Messente\Api\Model\GroupResponseFields|null $group group + * + * @return $this + */ + public function setGroup($group) + { + $this->container['group'] = $group; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/lib/Model/GroupListEnvelope.php b/lib/Model/GroupListEnvelope.php new file mode 100644 index 0000000..9fc0ae2 --- /dev/null +++ b/lib/Model/GroupListEnvelope.php @@ -0,0 +1,297 @@ + '\Messente\Api\Model\GroupResponseFields[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'groups' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'groups' => 'groups' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'groups' => 'setGroups' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'groups' => 'getGroups' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['groups'] = isset($data['groups']) ? $data['groups'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets groups + * + * @return \Messente\Api\Model\GroupResponseFields[]|null + */ + public function getGroups() + { + return $this->container['groups']; + } + + /** + * Sets groups + * + * @param \Messente\Api\Model\GroupResponseFields[]|null $groups groups + * + * @return $this + */ + public function setGroups($groups) + { + $this->container['groups'] = $groups; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/lib/Model/GroupName.php b/lib/Model/GroupName.php new file mode 100644 index 0000000..c7d0a37 --- /dev/null +++ b/lib/Model/GroupName.php @@ -0,0 +1,309 @@ + 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'name' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'name' => 'name' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'name' => 'setName' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'name' => 'getName' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['name'] = isset($data['name']) ? $data['name'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['name'] === null) { + $invalidProperties[] = "'name' can't be null"; + } + if ((mb_strlen($this->container['name']) < 1)) { + $invalidProperties[] = "invalid value for 'name', the character length must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets name + * + * @return string + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string $name name + * + * @return $this + */ + public function setName($name) + { + + if ((mb_strlen($name) < 1)) { + throw new \InvalidArgumentException('invalid length for $name when calling GroupName., must be bigger than or equal to 1.'); + } + + $this->container['name'] = $name; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/lib/Model/GroupResponseFields.php b/lib/Model/GroupResponseFields.php new file mode 100644 index 0000000..633ae41 --- /dev/null +++ b/lib/Model/GroupResponseFields.php @@ -0,0 +1,396 @@ + 'string', + 'name' => 'string', + 'createdOn' => 'string', + 'contactsCount' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'id' => null, + 'name' => null, + 'createdOn' => null, + 'contactsCount' => 'int32' + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'name' => 'name', + 'createdOn' => 'createdOn', + 'contactsCount' => 'contactsCount' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'name' => 'setName', + 'createdOn' => 'setCreatedOn', + 'contactsCount' => 'setContactsCount' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'name' => 'getName', + 'createdOn' => 'getCreatedOn', + 'contactsCount' => 'getContactsCount' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['id'] = isset($data['id']) ? $data['id'] : null; + $this->container['name'] = isset($data['name']) ? $data['name'] : null; + $this->container['createdOn'] = isset($data['createdOn']) ? $data['createdOn'] : null; + $this->container['contactsCount'] = isset($data['contactsCount']) ? $data['contactsCount'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['id'] === null) { + $invalidProperties[] = "'id' can't be null"; + } + if ($this->container['name'] === null) { + $invalidProperties[] = "'name' can't be null"; + } + if ($this->container['contactsCount'] === null) { + $invalidProperties[] = "'contactsCount' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return string + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string $id Id string in uuid format + * + * @return $this + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets name + * + * @return string + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string $name name + * + * @return $this + */ + public function setName($name) + { + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets createdOn + * + * @return string|null + */ + public function getCreatedOn() + { + return $this->container['createdOn']; + } + + /** + * Sets createdOn + * + * @param string|null $createdOn format %Y-%m-%dT%H:%M:%S.%fZ + * + * @return $this + */ + public function setCreatedOn($createdOn) + { + $this->container['createdOn'] = $createdOn; + + return $this; + } + + /** + * Gets contactsCount + * + * @return int + */ + public function getContactsCount() + { + return $this->container['contactsCount']; + } + + /** + * Sets contactsCount + * + * @param int $contactsCount contactsCount + * + * @return $this + */ + public function setContactsCount($contactsCount) + { + $this->container['contactsCount'] = $contactsCount; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/lib/Model/MessageResult.php b/lib/Model/MessageResult.php new file mode 100644 index 0000000..8fa1655 --- /dev/null +++ b/lib/Model/MessageResult.php @@ -0,0 +1,366 @@ + 'string', + 'channel' => '\Messente\Api\Model\Channel', + 'sender' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'messageId' => 'uuid', + 'channel' => null, + 'sender' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'messageId' => 'message_id', + 'channel' => 'channel', + 'sender' => 'sender' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'messageId' => 'setMessageId', + 'channel' => 'setChannel', + 'sender' => 'setSender' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'messageId' => 'getMessageId', + 'channel' => 'getChannel', + 'sender' => 'getSender' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['messageId'] = isset($data['messageId']) ? $data['messageId'] : null; + $this->container['channel'] = isset($data['channel']) ? $data['channel'] : null; + $this->container['sender'] = isset($data['sender']) ? $data['sender'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['messageId'] === null) { + $invalidProperties[] = "'messageId' can't be null"; + } + if ($this->container['channel'] === null) { + $invalidProperties[] = "'channel' can't be null"; + } + if ($this->container['sender'] === null) { + $invalidProperties[] = "'sender' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets messageId + * + * @return string + */ + public function getMessageId() + { + return $this->container['messageId']; + } + + /** + * Sets messageId + * + * @param string $messageId Unique identifier for the message + * + * @return $this + */ + public function setMessageId($messageId) + { + $this->container['messageId'] = $messageId; + + return $this; + } + + /** + * Gets channel + * + * @return \Messente\Api\Model\Channel + */ + public function getChannel() + { + return $this->container['channel']; + } + + /** + * Sets channel + * + * @param \Messente\Api\Model\Channel $channel channel + * + * @return $this + */ + public function setChannel($channel) + { + $this->container['channel'] = $channel; + + return $this; + } + + /** + * Gets sender + * + * @return string + */ + public function getSender() + { + return $this->container['sender']; + } + + /** + * Sets sender + * + * @param string $sender Sender that was used for the message + * + * @return $this + */ + public function setSender($sender) + { + $this->container['sender'] = $sender; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/lib/Model/ModelInterface.php b/lib/Model/ModelInterface.php new file mode 100644 index 0000000..f9fa979 --- /dev/null +++ b/lib/Model/ModelInterface.php @@ -0,0 +1,96 @@ + 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'phoneNumber' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'phoneNumber' => 'phoneNumber' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'phoneNumber' => 'setPhoneNumber' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'phoneNumber' => 'getPhoneNumber' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['phoneNumber'] = isset($data['phoneNumber']) ? $data['phoneNumber'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['phoneNumber'] === null) { + $invalidProperties[] = "'phoneNumber' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets phoneNumber + * + * @return string + */ + public function getPhoneNumber() + { + return $this->container['phoneNumber']; + } + + /** + * Sets phoneNumber + * + * @param string $phoneNumber Phone number in e.164 format + * + * @return $this + */ + public function setPhoneNumber($phoneNumber) + { + $this->container['phoneNumber'] = $phoneNumber; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/lib/Model/OmniMessageCreateSuccessResponse.php b/lib/Model/OmniMessageCreateSuccessResponse.php new file mode 100644 index 0000000..4016bb2 --- /dev/null +++ b/lib/Model/OmniMessageCreateSuccessResponse.php @@ -0,0 +1,366 @@ + '\Messente\Api\Model\MessageResult[]', + 'to' => 'string', + 'omnimessageId' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'messages' => null, + 'to' => null, + 'omnimessageId' => 'uuid' + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'messages' => 'messages', + 'to' => 'to', + 'omnimessageId' => 'omnimessage_id' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'messages' => 'setMessages', + 'to' => 'setTo', + 'omnimessageId' => 'setOmnimessageId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'messages' => 'getMessages', + 'to' => 'getTo', + 'omnimessageId' => 'getOmnimessageId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['messages'] = isset($data['messages']) ? $data['messages'] : null; + $this->container['to'] = isset($data['to']) ? $data['to'] : null; + $this->container['omnimessageId'] = isset($data['omnimessageId']) ? $data['omnimessageId'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['messages'] === null) { + $invalidProperties[] = "'messages' can't be null"; + } + if ($this->container['to'] === null) { + $invalidProperties[] = "'to' can't be null"; + } + if ($this->container['omnimessageId'] === null) { + $invalidProperties[] = "'omnimessageId' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets messages + * + * @return \Messente\Api\Model\MessageResult[] + */ + public function getMessages() + { + return $this->container['messages']; + } + + /** + * Sets messages + * + * @param \Messente\Api\Model\MessageResult[] $messages List of messages that compose the Omnimessage + * + * @return $this + */ + public function setMessages($messages) + { + $this->container['messages'] = $messages; + + return $this; + } + + /** + * Gets to + * + * @return string + */ + public function getTo() + { + return $this->container['to']; + } + + /** + * Sets to + * + * @param string $to Phone number in e.164 format + * + * @return $this + */ + public function setTo($to) + { + $this->container['to'] = $to; + + return $this; + } + + /** + * Gets omnimessageId + * + * @return string + */ + public function getOmnimessageId() + { + return $this->container['omnimessageId']; + } + + /** + * Sets omnimessageId + * + * @param string $omnimessageId Unique identifier for the Omnimessage + * + * @return $this + */ + public function setOmnimessageId($omnimessageId) + { + $this->container['omnimessageId'] = $omnimessageId; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/lib/Model/Omnimessage.php b/lib/Model/Omnimessage.php new file mode 100644 index 0000000..ca9024e --- /dev/null +++ b/lib/Model/Omnimessage.php @@ -0,0 +1,393 @@ + 'string', + 'messages' => 'OneOfViberSMSWhatsApp[]', + 'dlrUrl' => 'string', + 'timeToSend' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'to' => null, + 'messages' => null, + 'dlrUrl' => 'url', + 'timeToSend' => 'date-time' + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'to' => 'to', + 'messages' => 'messages', + 'dlrUrl' => 'dlr_url', + 'timeToSend' => 'time_to_send' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'to' => 'setTo', + 'messages' => 'setMessages', + 'dlrUrl' => 'setDlrUrl', + 'timeToSend' => 'setTimeToSend' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'to' => 'getTo', + 'messages' => 'getMessages', + 'dlrUrl' => 'getDlrUrl', + 'timeToSend' => 'getTimeToSend' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['to'] = isset($data['to']) ? $data['to'] : null; + $this->container['messages'] = isset($data['messages']) ? $data['messages'] : null; + $this->container['dlrUrl'] = isset($data['dlrUrl']) ? $data['dlrUrl'] : null; + $this->container['timeToSend'] = isset($data['timeToSend']) ? $data['timeToSend'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['to'] === null) { + $invalidProperties[] = "'to' can't be null"; + } + if ($this->container['messages'] === null) { + $invalidProperties[] = "'messages' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets to + * + * @return string + */ + public function getTo() + { + return $this->container['to']; + } + + /** + * Sets to + * + * @param string $to Phone number in e.164 format + * + * @return $this + */ + public function setTo($to) + { + $this->container['to'] = $to; + + return $this; + } + + /** + * Gets messages + * + * @return OneOfViberSMSWhatsApp[] + */ + public function getMessages() + { + return $this->container['messages']; + } + + /** + * Sets messages + * + * @param OneOfViberSMSWhatsApp[] $messages messages + * + * @return $this + */ + public function setMessages($messages) + { + $this->container['messages'] = $messages; + + return $this; + } + + /** + * Gets dlrUrl + * + * @return string|null + */ + public function getDlrUrl() + { + return $this->container['dlrUrl']; + } + + /** + * Sets dlrUrl + * + * @param string|null $dlrUrl URL where the delivery report will be sent + * + * @return $this + */ + public function setDlrUrl($dlrUrl) + { + $this->container['dlrUrl'] = $dlrUrl; + + return $this; + } + + /** + * Gets timeToSend + * + * @return \DateTime|null + */ + public function getTimeToSend() + { + return $this->container['timeToSend']; + } + + /** + * Sets timeToSend + * + * @param \DateTime|null $timeToSend Optional parameter for sending messages at some specific time in the future. Time must be specified in the 8601 format. If no timezone is specified, then the timezone is assumed to be UTC. Examples: * Time specified with timezone: 2018-06-22T09:05:07+00:00 Time specified in UTC: 2018-06-22T09:05:07Z * Time specified without timezone: 2018-06-22T09:05 (equivalent to 2018-06-22T09:05+00:00) + * + * @return $this + */ + public function setTimeToSend($timeToSend) + { + $this->container['timeToSend'] = $timeToSend; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/lib/Model/SMS.php b/lib/Model/SMS.php new file mode 100644 index 0000000..a00eae7 --- /dev/null +++ b/lib/Model/SMS.php @@ -0,0 +1,515 @@ + 'string', + 'sender' => 'string', + 'validity' => 'int', + 'autoconvert' => 'string', + 'udh' => 'string', + 'channel' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'text' => null, + 'sender' => null, + 'validity' => 'int32', + 'autoconvert' => null, + 'udh' => null, + 'channel' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'text' => 'text', + 'sender' => 'sender', + 'validity' => 'validity', + 'autoconvert' => 'autoconvert', + 'udh' => 'udh', + 'channel' => 'channel' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'text' => 'setText', + 'sender' => 'setSender', + 'validity' => 'setValidity', + 'autoconvert' => 'setAutoconvert', + 'udh' => 'setUdh', + 'channel' => 'setChannel' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'text' => 'getText', + 'sender' => 'getSender', + 'validity' => 'getValidity', + 'autoconvert' => 'getAutoconvert', + 'udh' => 'getUdh', + 'channel' => 'getChannel' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + const AUTOCONVERT_FULL = 'full'; + const AUTOCONVERT_ON = 'on'; + const AUTOCONVERT_OFF = 'off'; + const CHANNEL_SMS = 'sms'; + + + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getAutoconvertAllowableValues() + { + return [ + self::AUTOCONVERT_FULL, + self::AUTOCONVERT_ON, + self::AUTOCONVERT_OFF, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getChannelAllowableValues() + { + return [ + self::CHANNEL_SMS, + ]; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['text'] = isset($data['text']) ? $data['text'] : null; + $this->container['sender'] = isset($data['sender']) ? $data['sender'] : null; + $this->container['validity'] = isset($data['validity']) ? $data['validity'] : null; + $this->container['autoconvert'] = isset($data['autoconvert']) ? $data['autoconvert'] : null; + $this->container['udh'] = isset($data['udh']) ? $data['udh'] : null; + $this->container['channel'] = isset($data['channel']) ? $data['channel'] : 'sms'; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['text'] === null) { + $invalidProperties[] = "'text' can't be null"; + } + $allowedValues = $this->getAutoconvertAllowableValues(); + if (!is_null($this->container['autoconvert']) && !in_array($this->container['autoconvert'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value for 'autoconvert', must be one of '%s'", + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getChannelAllowableValues(); + if (!is_null($this->container['channel']) && !in_array($this->container['channel'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value for 'channel', must be one of '%s'", + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets text + * + * @return string + */ + public function getText() + { + return $this->container['text']; + } + + /** + * Sets text + * + * @param string $text Text content of the SMS + * + * @return $this + */ + public function setText($text) + { + $this->container['text'] = $text; + + return $this; + } + + /** + * Gets sender + * + * @return string|null + */ + public function getSender() + { + return $this->container['sender']; + } + + /** + * Sets sender + * + * @param string|null $sender Phone number or alphanumeric sender name + * + * @return $this + */ + public function setSender($sender) + { + $this->container['sender'] = $sender; + + return $this; + } + + /** + * Gets validity + * + * @return int|null + */ + public function getValidity() + { + return $this->container['validity']; + } + + /** + * Sets validity + * + * @param int|null $validity After how many minutes this channel is considered as failed and the next channel is attempted + * + * @return $this + */ + public function setValidity($validity) + { + $this->container['validity'] = $validity; + + return $this; + } + + /** + * Gets autoconvert + * + * @return string|null + */ + public function getAutoconvert() + { + return $this->container['autoconvert']; + } + + /** + * Sets autoconvert + * + * @param string|null $autoconvert Defines how non-GSM characters will be treated: - \"on\" Use replacement settings from the account's [API Auto Replace settings page](https://dashboard.messente.com/api-settings/auto-replace)(default) - \"full\" All non GSM 03.38 characters will be replaced with suitable alternatives - \"off\" Message content is not modified in any way + * + * @return $this + */ + public function setAutoconvert($autoconvert) + { + $allowedValues = $this->getAutoconvertAllowableValues(); + if (!is_null($autoconvert) && !in_array($autoconvert, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for 'autoconvert', must be one of '%s'", + implode("', '", $allowedValues) + ) + ); + } + $this->container['autoconvert'] = $autoconvert; + + return $this; + } + + /** + * Gets udh + * + * @return string|null + */ + public function getUdh() + { + return $this->container['udh']; + } + + /** + * Sets udh + * + * @param string|null $udh hex-encoded string containing SMS UDH + * + * @return $this + */ + public function setUdh($udh) + { + $this->container['udh'] = $udh; + + return $this; + } + + /** + * Gets channel + * + * @return string|null + */ + public function getChannel() + { + return $this->container['channel']; + } + + /** + * Sets channel + * + * @param string|null $channel channel + * + * @return $this + */ + public function setChannel($channel) + { + $allowedValues = $this->getChannelAllowableValues(); + if (!is_null($channel) && !in_array($channel, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for 'channel', must be one of '%s'", + implode("', '", $allowedValues) + ) + ); + } + $this->container['channel'] = $channel; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/lib/Model/Status.php b/lib/Model/Status.php new file mode 100644 index 0000000..4a47f71 --- /dev/null +++ b/lib/Model/Status.php @@ -0,0 +1,81 @@ + 'string', + 'validity' => 'int', + 'text' => 'string', + 'imageUrl' => 'string', + 'buttonUrl' => 'string', + 'buttonText' => 'string', + 'channel' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'sender' => null, + 'validity' => 'int32', + 'text' => null, + 'imageUrl' => null, + 'buttonUrl' => null, + 'buttonText' => null, + 'channel' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'sender' => 'sender', + 'validity' => 'validity', + 'text' => 'text', + 'imageUrl' => 'image_url', + 'buttonUrl' => 'button_url', + 'buttonText' => 'button_text', + 'channel' => 'channel' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'sender' => 'setSender', + 'validity' => 'setValidity', + 'text' => 'setText', + 'imageUrl' => 'setImageUrl', + 'buttonUrl' => 'setButtonUrl', + 'buttonText' => 'setButtonText', + 'channel' => 'setChannel' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'sender' => 'getSender', + 'validity' => 'getValidity', + 'text' => 'getText', + 'imageUrl' => 'getImageUrl', + 'buttonUrl' => 'getButtonUrl', + 'buttonText' => 'getButtonText', + 'channel' => 'getChannel' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + const CHANNEL_VIBER = 'viber'; + + + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getChannelAllowableValues() + { + return [ + self::CHANNEL_VIBER, + ]; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['sender'] = isset($data['sender']) ? $data['sender'] : null; + $this->container['validity'] = isset($data['validity']) ? $data['validity'] : null; + $this->container['text'] = isset($data['text']) ? $data['text'] : null; + $this->container['imageUrl'] = isset($data['imageUrl']) ? $data['imageUrl'] : null; + $this->container['buttonUrl'] = isset($data['buttonUrl']) ? $data['buttonUrl'] : null; + $this->container['buttonText'] = isset($data['buttonText']) ? $data['buttonText'] : null; + $this->container['channel'] = isset($data['channel']) ? $data['channel'] : 'viber'; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getChannelAllowableValues(); + if (!is_null($this->container['channel']) && !in_array($this->container['channel'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value for 'channel', must be one of '%s'", + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets sender + * + * @return string|null + */ + public function getSender() + { + return $this->container['sender']; + } + + /** + * Sets sender + * + * @param string|null $sender Phone number or alphanumeric sender name + * + * @return $this + */ + public function setSender($sender) + { + $this->container['sender'] = $sender; + + return $this; + } + + /** + * Gets validity + * + * @return int|null + */ + public function getValidity() + { + return $this->container['validity']; + } + + /** + * Sets validity + * + * @param int|null $validity After how many minutes this channel is considered as failed and the next channel is attempted + * + * @return $this + */ + public function setValidity($validity) + { + $this->container['validity'] = $validity; + + return $this; + } + + /** + * Gets text + * + * @return string|null + */ + public function getText() + { + return $this->container['text']; + } + + /** + * Sets text + * + * @param string|null $text Plaintext content for Viber + * + * @return $this + */ + public function setText($text) + { + $this->container['text'] = $text; + + return $this; + } + + /** + * Gets imageUrl + * + * @return string|null + */ + public function getImageUrl() + { + return $this->container['imageUrl']; + } + + /** + * Sets imageUrl + * + * @param string|null $imageUrl URL for the embedded image. Valid combinations: 1) image_url, 2) text, image_url, button_url, button_text + * + * @return $this + */ + public function setImageUrl($imageUrl) + { + $this->container['imageUrl'] = $imageUrl; + + return $this; + } + + /** + * Gets buttonUrl + * + * @return string|null + */ + public function getButtonUrl() + { + return $this->container['buttonUrl']; + } + + /** + * Sets buttonUrl + * + * @param string|null $buttonUrl URL of the button, must be specified along with ''text'', ''button_text'' and ''image_url'' (optional) + * + * @return $this + */ + public function setButtonUrl($buttonUrl) + { + $this->container['buttonUrl'] = $buttonUrl; + + return $this; + } + + /** + * Gets buttonText + * + * @return string|null + */ + public function getButtonText() + { + return $this->container['buttonText']; + } + + /** + * Sets buttonText + * + * @param string|null $buttonText Must be specified along with ''text'', ''button_url'', ''button_text'', ''image_url'' (optional) + * + * @return $this + */ + public function setButtonText($buttonText) + { + $this->container['buttonText'] = $buttonText; + + return $this; + } + + /** + * Gets channel + * + * @return string|null + */ + public function getChannel() + { + return $this->container['channel']; + } + + /** + * Sets channel + * + * @param string|null $channel channel + * + * @return $this + */ + public function setChannel($channel) + { + $allowedValues = $this->getChannelAllowableValues(); + if (!is_null($channel) && !in_array($channel, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for 'channel', must be one of '%s'", + implode("', '", $allowedValues) + ) + ); + } + $this->container['channel'] = $channel; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/lib/Model/WhatsApp.php b/lib/Model/WhatsApp.php new file mode 100644 index 0000000..ee9d433 --- /dev/null +++ b/lib/Model/WhatsApp.php @@ -0,0 +1,508 @@ + 'string', + 'validity' => 'int', + 'text' => '\Messente\Api\Model\WhatsAppText', + 'image' => '\Messente\Api\Model\WhatsAppImage', + 'document' => '\Messente\Api\Model\WhatsAppDocument', + 'audio' => '\Messente\Api\Model\WhatsAppAudio', + 'channel' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'sender' => null, + 'validity' => 'int32', + 'text' => null, + 'image' => null, + 'document' => null, + 'audio' => null, + 'channel' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'sender' => 'sender', + 'validity' => 'validity', + 'text' => 'text', + 'image' => 'image', + 'document' => 'document', + 'audio' => 'audio', + 'channel' => 'channel' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'sender' => 'setSender', + 'validity' => 'setValidity', + 'text' => 'setText', + 'image' => 'setImage', + 'document' => 'setDocument', + 'audio' => 'setAudio', + 'channel' => 'setChannel' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'sender' => 'getSender', + 'validity' => 'getValidity', + 'text' => 'getText', + 'image' => 'getImage', + 'document' => 'getDocument', + 'audio' => 'getAudio', + 'channel' => 'getChannel' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + const CHANNEL_WHATSAPP = 'whatsapp'; + + + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getChannelAllowableValues() + { + return [ + self::CHANNEL_WHATSAPP, + ]; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['sender'] = isset($data['sender']) ? $data['sender'] : null; + $this->container['validity'] = isset($data['validity']) ? $data['validity'] : null; + $this->container['text'] = isset($data['text']) ? $data['text'] : null; + $this->container['image'] = isset($data['image']) ? $data['image'] : null; + $this->container['document'] = isset($data['document']) ? $data['document'] : null; + $this->container['audio'] = isset($data['audio']) ? $data['audio'] : null; + $this->container['channel'] = isset($data['channel']) ? $data['channel'] : 'whatsapp'; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getChannelAllowableValues(); + if (!is_null($this->container['channel']) && !in_array($this->container['channel'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value for 'channel', must be one of '%s'", + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets sender + * + * @return string|null + */ + public function getSender() + { + return $this->container['sender']; + } + + /** + * Sets sender + * + * @param string|null $sender Phone number or alphanumeric sender name + * + * @return $this + */ + public function setSender($sender) + { + $this->container['sender'] = $sender; + + return $this; + } + + /** + * Gets validity + * + * @return int|null + */ + public function getValidity() + { + return $this->container['validity']; + } + + /** + * Sets validity + * + * @param int|null $validity After how many minutes this channel is considered as failed and the next channel is attempted + * + * @return $this + */ + public function setValidity($validity) + { + $this->container['validity'] = $validity; + + return $this; + } + + /** + * Gets text + * + * @return \Messente\Api\Model\WhatsAppText|null + */ + public function getText() + { + return $this->container['text']; + } + + /** + * Sets text + * + * @param \Messente\Api\Model\WhatsAppText|null $text text + * + * @return $this + */ + public function setText($text) + { + $this->container['text'] = $text; + + return $this; + } + + /** + * Gets image + * + * @return \Messente\Api\Model\WhatsAppImage|null + */ + public function getImage() + { + return $this->container['image']; + } + + /** + * Sets image + * + * @param \Messente\Api\Model\WhatsAppImage|null $image image + * + * @return $this + */ + public function setImage($image) + { + $this->container['image'] = $image; + + return $this; + } + + /** + * Gets document + * + * @return \Messente\Api\Model\WhatsAppDocument|null + */ + public function getDocument() + { + return $this->container['document']; + } + + /** + * Sets document + * + * @param \Messente\Api\Model\WhatsAppDocument|null $document document + * + * @return $this + */ + public function setDocument($document) + { + $this->container['document'] = $document; + + return $this; + } + + /** + * Gets audio + * + * @return \Messente\Api\Model\WhatsAppAudio|null + */ + public function getAudio() + { + return $this->container['audio']; + } + + /** + * Sets audio + * + * @param \Messente\Api\Model\WhatsAppAudio|null $audio audio + * + * @return $this + */ + public function setAudio($audio) + { + $this->container['audio'] = $audio; + + return $this; + } + + /** + * Gets channel + * + * @return string|null + */ + public function getChannel() + { + return $this->container['channel']; + } + + /** + * Sets channel + * + * @param string|null $channel channel + * + * @return $this + */ + public function setChannel($channel) + { + $allowedValues = $this->getChannelAllowableValues(); + if (!is_null($channel) && !in_array($channel, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for 'channel', must be one of '%s'", + implode("', '", $allowedValues) + ) + ); + } + $this->container['channel'] = $channel; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/lib/Model/WhatsAppAudio.php b/lib/Model/WhatsAppAudio.php new file mode 100644 index 0000000..014ebdf --- /dev/null +++ b/lib/Model/WhatsAppAudio.php @@ -0,0 +1,300 @@ + 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'content' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'content' => 'content' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'content' => 'setContent' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'content' => 'getContent' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['content'] = isset($data['content']) ? $data['content'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['content'] === null) { + $invalidProperties[] = "'content' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets content + * + * @return string + */ + public function getContent() + { + return $this->container['content']; + } + + /** + * Sets content + * + * @param string $content Base64-encoded audio + * + * @return $this + */ + public function setContent($content) + { + $this->container['content'] = $content; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/lib/Model/WhatsAppDocument.php b/lib/Model/WhatsAppDocument.php new file mode 100644 index 0000000..8dcb9b8 --- /dev/null +++ b/lib/Model/WhatsAppDocument.php @@ -0,0 +1,330 @@ + 'string', + 'content' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'caption' => null, + 'content' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'caption' => 'caption', + 'content' => 'content' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'caption' => 'setCaption', + 'content' => 'setContent' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'caption' => 'getCaption', + 'content' => 'getContent' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['caption'] = isset($data['caption']) ? $data['caption'] : null; + $this->container['content'] = isset($data['content']) ? $data['content'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['content'] === null) { + $invalidProperties[] = "'content' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets caption + * + * @return string|null + */ + public function getCaption() + { + return $this->container['caption']; + } + + /** + * Sets caption + * + * @param string|null $caption Description for the document + * + * @return $this + */ + public function setCaption($caption) + { + $this->container['caption'] = $caption; + + return $this; + } + + /** + * Gets content + * + * @return string + */ + public function getContent() + { + return $this->container['content']; + } + + /** + * Sets content + * + * @param string $content Base64-encoded image + * + * @return $this + */ + public function setContent($content) + { + $this->container['content'] = $content; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/lib/Model/WhatsAppImage.php b/lib/Model/WhatsAppImage.php new file mode 100644 index 0000000..ed101cd --- /dev/null +++ b/lib/Model/WhatsAppImage.php @@ -0,0 +1,330 @@ + 'string', + 'content' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'caption' => null, + 'content' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'caption' => 'caption', + 'content' => 'content' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'caption' => 'setCaption', + 'content' => 'setContent' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'caption' => 'getCaption', + 'content' => 'getContent' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['caption'] = isset($data['caption']) ? $data['caption'] : null; + $this->container['content'] = isset($data['content']) ? $data['content'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['content'] === null) { + $invalidProperties[] = "'content' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets caption + * + * @return string|null + */ + public function getCaption() + { + return $this->container['caption']; + } + + /** + * Sets caption + * + * @param string|null $caption Description for the image + * + * @return $this + */ + public function setCaption($caption) + { + $this->container['caption'] = $caption; + + return $this; + } + + /** + * Gets content + * + * @return string + */ + public function getContent() + { + return $this->container['content']; + } + + /** + * Sets content + * + * @param string $content Base64-encoded image + * + * @return $this + */ + public function setContent($content) + { + $this->container['content'] = $content; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/lib/Model/WhatsAppText.php b/lib/Model/WhatsAppText.php new file mode 100644 index 0000000..f678245 --- /dev/null +++ b/lib/Model/WhatsAppText.php @@ -0,0 +1,330 @@ + 'bool', + 'body' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'previewUrl' => null, + 'body' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'previewUrl' => 'preview_url', + 'body' => 'body' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'previewUrl' => 'setPreviewUrl', + 'body' => 'setBody' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'previewUrl' => 'getPreviewUrl', + 'body' => 'getBody' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['previewUrl'] = isset($data['previewUrl']) ? $data['previewUrl'] : true; + $this->container['body'] = isset($data['body']) ? $data['body'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['body'] === null) { + $invalidProperties[] = "'body' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets previewUrl + * + * @return bool|null + */ + public function getPreviewUrl() + { + return $this->container['previewUrl']; + } + + /** + * Sets previewUrl + * + * @param bool|null $previewUrl Whether to display link preview if the message contains a hyperlink. + * + * @return $this + */ + public function setPreviewUrl($previewUrl) + { + $this->container['previewUrl'] = $previewUrl; + + return $this; + } + + /** + * Gets body + * + * @return string + */ + public function getBody() + { + return $this->container['body']; + } + + /** + * Sets body + * + * @param string $body Plaintext content for WhatsApp, can contain URLs, emojis and formatting + * + * @return $this + */ + public function setBody($body) + { + $this->container['body'] = $body; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/lib/ObjectSerializer.php b/lib/ObjectSerializer.php new file mode 100644 index 0000000..3c6d0ed --- /dev/null +++ b/lib/ObjectSerializer.php @@ -0,0 +1,329 @@ +format('Y-m-d') : $data->format(\DateTime::ATOM); + } elseif (is_array($data)) { + foreach ($data as $property => $value) { + $data[$property] = self::sanitizeForSerialization($value); + } + return $data; + } elseif (is_object($data)) { + $values = []; + if ($data instanceof ModelInterface) { + $formats = $data::openAPIFormats(); + foreach ($data::openAPITypes() as $property => $openAPIType) { + $getter = $data::getters()[$property]; + $value = $data->$getter(); + if ($value !== null + && !in_array($openAPIType, ['DateTime', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true) + && method_exists($openAPIType, 'getAllowableEnumValues') + && !in_array($value, $openAPIType::getAllowableEnumValues(), true)) { + $imploded = implode("', '", $openAPIType::getAllowableEnumValues()); + throw new \InvalidArgumentException("Invalid value for enum '$openAPIType', must be one of: '$imploded'"); + } + + $values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value, $openAPIType, $formats[$property]); + + } + } else { + foreach($data as $property => $value) { + $values[$property] = self::sanitizeForSerialization($value); + } + } + return (object)$values; + } else { + return (string)$data; + } + } + + /** + * Sanitize filename by removing path. + * e.g. ../../sun.gif becomes sun.gif + * + * @param string $filename filename to be sanitized + * + * @return string the sanitized filename + */ + public static function sanitizeFilename($filename) + { + if (preg_match("/.*[\/\\\\](.*)$/", $filename, $match)) { + return $match[1]; + } else { + return $filename; + } + } + + /** + * Take value and turn it into a string suitable for inclusion in + * the path, by url-encoding. + * + * @param string $value a string which will be part of the path + * + * @return string the serialized object + */ + public static function toPathValue($value) + { + return rawurlencode(self::toString($value)); + } + + /** + * Take value and turn it into a string suitable for inclusion in + * the query, by imploding comma-separated if it's an object. + * If it's a string, pass through unchanged. It will be url-encoded + * later. + * + * @param string[]|string|\DateTime $object an object to be serialized to a string + * + * @return string the serialized object + */ + public static function toQueryValue($object) + { + if (is_array($object)) { + return implode(',', $object); + } else { + return self::toString($object); + } + } + + /** + * Take value and turn it into a string suitable for inclusion in + * the header. If it's a string, pass through unchanged + * If it's a datetime object, format it in ISO8601 + * + * @param string $value a string which will be part of the header + * + * @return string the header string + */ + public static function toHeaderValue($value) + { + return self::toString($value); + } + + /** + * Take value and turn it into a string suitable for inclusion in + * the http body (form parameter). If it's a string, pass through unchanged + * If it's a datetime object, format it in ISO8601 + * + * @param string|\SplFileObject $value the value of the form parameter + * + * @return string the form string + */ + public static function toFormValue($value) + { + if ($value instanceof \SplFileObject) { + return $value->getRealPath(); + } else { + return self::toString($value); + } + } + + /** + * Take value and turn it into a string suitable for inclusion in + * the parameter. If it's a string, pass through unchanged + * If it's a datetime object, format it in ISO8601 + * + * @param string|\DateTime $value the value of the parameter + * + * @return string the header string + */ + public static function toString($value) + { + if ($value instanceof \DateTime) { // datetime in ISO8601 format + return $value->format(\DateTime::ATOM); + } else { + return $value; + } + } + + /** + * Serialize an array to a string. + * + * @param array $collection collection to serialize to a string + * @param string $collectionFormat the format use for serialization (csv, + * ssv, tsv, pipes, multi) + * @param bool $allowCollectionFormatMulti allow collection format to be a multidimensional array + * + * @return string + */ + public static function serializeCollection(array $collection, $collectionFormat, $allowCollectionFormatMulti = false) + { + if ($allowCollectionFormatMulti && ('multi' === $collectionFormat)) { + // http_build_query() almost does the job for us. We just + // need to fix the result of multidimensional arrays. + return preg_replace('/%5B[0-9]+%5D=/', '=', http_build_query($collection, '', '&')); + } + switch ($collectionFormat) { + case 'pipes': + return implode('|', $collection); + + case 'tsv': + return implode("\t", $collection); + + case 'ssv': + return implode(' ', $collection); + + case 'csv': + // Deliberate fall through. CSV is default format. + default: + return implode(',', $collection); + } + } + + /** + * Deserialize a JSON string into an object + * + * @param mixed $data object or primitive to be deserialized + * @param string $class class name is passed as a string + * @param string[] $httpHeaders HTTP headers + * @param string $discriminator discriminator if polymorphism is used + * + * @return object|array|null a single or an array of $class instances + */ + public static function deserialize($data, $class, $httpHeaders = null) + { + if (null === $data) { + return null; + } elseif (substr($class, 0, 4) === 'map[') { // for associative array e.g. map[string,int] + $data = is_string($data) ? json_decode($data) : $data; + settype($data, 'array'); + $inner = substr($class, 4, -1); + $deserialized = []; + if (strrpos($inner, ",") !== false) { + $subClass_array = explode(',', $inner, 2); + $subClass = $subClass_array[1]; + foreach ($data as $key => $value) { + $deserialized[$key] = self::deserialize($value, $subClass, null); + } + } + return $deserialized; + } elseif (strcasecmp(substr($class, -2), '[]') === 0) { + $data = is_string($data) ? json_decode($data) : $data; + $subClass = substr($class, 0, -2); + $values = []; + foreach ($data as $key => $value) { + $values[] = self::deserialize($value, $subClass, null); + } + return $values; + } elseif ($class === 'object') { + settype($data, 'array'); + return $data; + } elseif ($class === '\DateTime') { + // Some API's return an invalid, empty string as a + // date-time property. DateTime::__construct() will return + // the current time for empty input which is probably not + // what is meant. The invalid empty string is probably to + // be interpreted as a missing field/value. Let's handle + // this graceful. + if (!empty($data)) { + return new \DateTime($data); + } else { + return null; + } + } elseif (in_array($class, ['DateTime', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) { + settype($data, $class); + return $data; + } elseif ($class === '\SplFileObject') { + /** @var \Psr\Http\Message\StreamInterface $data */ + + // determine file name + if (array_key_exists('Content-Disposition', $httpHeaders) && + preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeaders['Content-Disposition'], $match)) { + $filename = Configuration::getDefaultConfiguration()->getTempFolderPath() . DIRECTORY_SEPARATOR . self::sanitizeFilename($match[1]); + } else { + $filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), ''); + } + + $file = fopen($filename, 'w'); + while ($chunk = $data->read(200)) { + fwrite($file, $chunk); + } + fclose($file); + + return new \SplFileObject($filename, 'r'); + } elseif (method_exists($class, 'getAllowableEnumValues')) { + if (!in_array($data, $class::getAllowableEnumValues(), true)) { + $imploded = implode("', '", $class::getAllowableEnumValues()); + throw new \InvalidArgumentException("Invalid value for enum '$class', must be one of: '$imploded'"); + } + return $data; + } else { + $data = is_string($data) ? json_decode($data) : $data; + // If a discriminator is defined and points to a valid subclass, use it. + $discriminator = $class::DISCRIMINATOR; + if (!empty($discriminator) && isset($data->{$discriminator}) && is_string($data->{$discriminator})) { + $subclass = '\Messente\Api\Model\\' . $data->{$discriminator}; + if (is_subclass_of($subclass, $class)) { + $class = $subclass; + } + } + $instance = new $class(); + foreach ($instance::openAPITypes() as $property => $type) { + $propertySetter = $instance::setters()[$property]; + + if (!isset($propertySetter) || !isset($data->{$instance::attributeMap()[$property]})) { + continue; + } + + $propertyValue = $data->{$instance::attributeMap()[$property]}; + if (isset($propertyValue)) { + $instance->$propertySetter(self::deserialize($propertyValue, $type, null)); + } + } + return $instance; + } + } +} diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..08f78fa --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,21 @@ + + + + + ./test/Api + ./test/Model + + + + + + ./lib/Api + ./lib/Model + + + diff --git a/test/Api/BlacklistApiTest.php b/test/Api/BlacklistApiTest.php new file mode 100644 index 0000000..1d14e5a --- /dev/null +++ b/test/Api/BlacklistApiTest.php @@ -0,0 +1,114 @@ +