From 9b871bef014e462f3f26eb3ddce1515446817136 Mon Sep 17 00:00:00 2001 From: Cloudmersive <35204726+Cloudmersive@users.noreply.github.com> Date: Sun, 5 Aug 2018 22:45:58 -0700 Subject: [PATCH] Added --- .php_cs | 18 + .swagger-codegen-ignore | 23 + .swagger-codegen/VERSION | 1 + .travis.yml | 10 + README.md | 124 +++ build.ps1 | 6 +- composer.json | 37 + docs/Api/DomainApi.md | 120 +++ docs/Api/EmailApi.md | 176 ++++ docs/Api/IPAddressApi.md | 64 ++ docs/Api/VatApi.md | 64 ++ docs/Model/AddressGetServersResponse.md | 11 + docs/Model/AddressVerifySyntaxOnlyResponse.md | 10 + docs/Model/CheckResponse.md | 10 + docs/Model/FullEmailValidationResponse.md | 11 + docs/Model/GeolocateResponse.md | 18 + docs/Model/VatLookupRequest.md | 10 + docs/Model/VatLookupResponse.md | 14 + docs/Model/WhoisResponse.md | 13 + git_push.sh | 52 + lib/Api/DomainApi.php | 627 ++++++++++++ lib/Api/EmailApi.php | 889 ++++++++++++++++++ lib/Api/IPAddressApi.php | 365 +++++++ lib/Api/VatApi.php | 365 +++++++ lib/ApiException.php | 121 +++ lib/Configuration.php | 430 +++++++++ lib/HeaderSelector.php | 110 +++ lib/Model/AddressGetServersResponse.php | 333 +++++++ lib/Model/AddressVerifySyntaxOnlyResponse.php | 303 ++++++ lib/Model/CheckResponse.php | 303 ++++++ lib/Model/FullEmailValidationResponse.php | 333 +++++++ lib/Model/GeolocateResponse.php | 543 +++++++++++ lib/Model/ModelInterface.php | 96 ++ lib/Model/VatLookupRequest.php | 303 ++++++ lib/Model/VatLookupResponse.php | 422 +++++++++ lib/Model/WhoisResponse.php | 393 ++++++++ lib/ObjectSerializer.php | 317 +++++++ packageconfig.json | 6 +- phpunit.xml.dist | 21 + test/Api/DomainApiTest.php | 93 ++ test/Api/EmailApiTest.php | 103 ++ test/Api/IPAddressApiTest.php | 83 ++ test/Api/VatApiTest.php | 83 ++ test/Model/AddressGetServersResponseTest.php | 93 ++ .../AddressVerifySyntaxOnlyResponseTest.php | 86 ++ test/Model/CheckResponseTest.php | 86 ++ .../Model/FullEmailValidationResponseTest.php | 93 ++ test/Model/GeolocateResponseTest.php | 142 +++ test/Model/VatLookupRequestTest.php | 86 ++ test/Model/VatLookupResponseTest.php | 114 +++ test/Model/WhoisResponseTest.php | 107 +++ 51 files changed, 8235 insertions(+), 6 deletions(-) create mode 100644 .php_cs create mode 100644 .swagger-codegen-ignore create mode 100644 .swagger-codegen/VERSION create mode 100644 .travis.yml create mode 100644 README.md create mode 100644 composer.json create mode 100644 docs/Api/DomainApi.md create mode 100644 docs/Api/EmailApi.md create mode 100644 docs/Api/IPAddressApi.md create mode 100644 docs/Api/VatApi.md create mode 100644 docs/Model/AddressGetServersResponse.md create mode 100644 docs/Model/AddressVerifySyntaxOnlyResponse.md create mode 100644 docs/Model/CheckResponse.md create mode 100644 docs/Model/FullEmailValidationResponse.md create mode 100644 docs/Model/GeolocateResponse.md create mode 100644 docs/Model/VatLookupRequest.md create mode 100644 docs/Model/VatLookupResponse.md create mode 100644 docs/Model/WhoisResponse.md create mode 100644 git_push.sh create mode 100644 lib/Api/DomainApi.php create mode 100644 lib/Api/EmailApi.php create mode 100644 lib/Api/IPAddressApi.php create mode 100644 lib/Api/VatApi.php create mode 100644 lib/ApiException.php create mode 100644 lib/Configuration.php create mode 100644 lib/HeaderSelector.php create mode 100644 lib/Model/AddressGetServersResponse.php create mode 100644 lib/Model/AddressVerifySyntaxOnlyResponse.php create mode 100644 lib/Model/CheckResponse.php create mode 100644 lib/Model/FullEmailValidationResponse.php create mode 100644 lib/Model/GeolocateResponse.php create mode 100644 lib/Model/ModelInterface.php create mode 100644 lib/Model/VatLookupRequest.php create mode 100644 lib/Model/VatLookupResponse.php create mode 100644 lib/Model/WhoisResponse.php create mode 100644 lib/ObjectSerializer.php create mode 100644 phpunit.xml.dist create mode 100644 test/Api/DomainApiTest.php create mode 100644 test/Api/EmailApiTest.php create mode 100644 test/Api/IPAddressApiTest.php create mode 100644 test/Api/VatApiTest.php create mode 100644 test/Model/AddressGetServersResponseTest.php create mode 100644 test/Model/AddressVerifySyntaxOnlyResponseTest.php create mode 100644 test/Model/CheckResponseTest.php create mode 100644 test/Model/FullEmailValidationResponseTest.php create mode 100644 test/Model/GeolocateResponseTest.php create mode 100644 test/Model/VatLookupRequestTest.php create mode 100644 test/Model/VatLookupResponseTest.php create mode 100644 test/Model/WhoisResponseTest.php diff --git a/.php_cs b/.php_cs new file mode 100644 index 0000000..6b8e23c --- /dev/null +++ b/.php_cs @@ -0,0 +1,18 @@ +level(Symfony\CS\FixerInterface::PSR2_LEVEL) + ->setUsingCache(true) + ->fixers( + [ + 'ordered_use', + 'phpdoc_order', + 'short_array_syntax', + 'strict', + 'strict_param' + ] + ) + ->finder( + Symfony\CS\Finder\DefaultFinder::create() + ->in(__DIR__) + ); diff --git a/.swagger-codegen-ignore b/.swagger-codegen-ignore new file mode 100644 index 0000000..c5fa491 --- /dev/null +++ b/.swagger-codegen-ignore @@ -0,0 +1,23 @@ +# Swagger Codegen Ignore +# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen + +# 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 Swagger Codgen 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/.swagger-codegen/VERSION b/.swagger-codegen/VERSION new file mode 100644 index 0000000..717311e --- /dev/null +++ b/.swagger-codegen/VERSION @@ -0,0 +1 @@ +unset \ No newline at end of file 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 new file mode 100644 index 0000000..67b1aa1 --- /dev/null +++ b/README.md @@ -0,0 +1,124 @@ +# cloudmersive_validate_api_client +The validation APIs help you validate data. Check if an E-mail address is real. Check if a domain is real. Check up on an IP address, and even where it is located. All this and much more is available in the validation API. + +This PHP package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: + +- API version: v1 +- Package version: 1.3.9 +- Build package: io.swagger.codegen.languages.PhpClientCodegen + +## Requirements + +PHP 5.5 and later + +## Installation & Usage +### Composer + +To install the bindings via [Composer](http://getcomposer.org/), add the following to `composer.json`: + +``` +{ + "repositories": [ + { + "type": "git", + "url": "https://github.com/cloudmersive/cloudmersive_validate_api_client.git" + } + ], + "require": { + "cloudmersive/cloudmersive_validate_api_client": "*@dev" + } +} +``` + +Then run `composer install` + +### Manual Installation + +Download the files and include `autoload.php`: + +```php + require_once('/path/to/cloudmersive_validate_api_client/vendor/autoload.php'); +``` + +## Tests + +To run the unit tests: + +``` +composer install +./vendor/bin/phpunit +``` + +## Getting Started + +Please follow the [installation procedure](#installation--usage) and then run the following: + +```php +setApiKey('Apikey', 'YOUR_API_KEY'); +// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +// $config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('Apikey', 'Bearer'); + +$apiInstance = new Swagger\Client\Api\DomainApi( + // 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 +); +$domain = "domain_example"; // string | Domain name to check, for example \"cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. + +try { + $result = $apiInstance->domainCheck($domain); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling DomainApi->domainCheck: ', $e->getMessage(), PHP_EOL; +} + +?> +``` + +## Documentation for API Endpoints + +All URIs are relative to *https://api.cloudmersive.com* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*DomainApi* | [**domainCheck**](docs/Api/DomainApi.md#domaincheck) | **POST** /validate/domain/check | Validate a domain name +*DomainApi* | [**domainPost**](docs/Api/DomainApi.md#domainpost) | **POST** /validate/domain/whois | Get WHOIS information for a domain +*EmailApi* | [**emailAddressGetServers**](docs/Api/EmailApi.md#emailaddressgetservers) | **POST** /validate/email/address/servers | Partially check whether an email address is valid +*EmailApi* | [**emailFullValidation**](docs/Api/EmailApi.md#emailfullvalidation) | **POST** /validate/email/address/full | Fully validate an email address +*EmailApi* | [**emailPost**](docs/Api/EmailApi.md#emailpost) | **POST** /validate/email/address/syntaxOnly | Validate email adddress for syntactic correctness only +*IPAddressApi* | [**iPAddressPost**](docs/Api/IPAddressApi.md#ipaddresspost) | **POST** /validate/ip/geolocate | Geolocate an IP address +*VatApi* | [**vatVatLookup**](docs/Api/VatApi.md#vatvatlookup) | **POST** /validate/vat/lookup | Lookup a VAT code + + +## Documentation For Models + + - [AddressGetServersResponse](docs/Model/AddressGetServersResponse.md) + - [AddressVerifySyntaxOnlyResponse](docs/Model/AddressVerifySyntaxOnlyResponse.md) + - [CheckResponse](docs/Model/CheckResponse.md) + - [FullEmailValidationResponse](docs/Model/FullEmailValidationResponse.md) + - [GeolocateResponse](docs/Model/GeolocateResponse.md) + - [VatLookupRequest](docs/Model/VatLookupRequest.md) + - [VatLookupResponse](docs/Model/VatLookupResponse.md) + - [WhoisResponse](docs/Model/WhoisResponse.md) + + +## Documentation For Authorization + + +## Apikey + +- **Type**: API key +- **API key parameter name**: Apikey +- **Location**: HTTP header + + +## Author + + + + diff --git a/build.ps1 b/build.ps1 index 045b468..bb0689b 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,8 +1,8 @@ #Remove-Item –path ./ –recurse -& java -jar swagger-codegen-cli.jar generate -i https://api.cloudmersive.com/swagger/api/ocr -l php -c packageconfig.json +& java -jar swagger-codegen-cli.jar generate -i https://api.cloudmersive.com/swagger/api/validate -l php -c packageconfig.json #(Get-Content ./client/package.json).replace('v1', '1.0.1') | Set-Content ./client/package.json -Copy-Item ./cloudmersive_ocr_api_client/* -Destination . -Recurse -Force -Remove-Item –path ./cloudmersive_ocr_api_client –recurse +Copy-Item ./cloudmersive_validate_api_client/* -Destination . -Recurse -Force +Remove-Item –path ./cloudmersive_validate_api_client –recurse # Bug fix diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..94d8357 --- /dev/null +++ b/composer.json @@ -0,0 +1,37 @@ +{ + "name": "cloudmersive/cloudmersive_validate_api_client", + "version": "1.3.9", + "description": "", + "keywords": [ + "swagger", + "php", + "sdk", + "api" + ], + "homepage": "http://swagger.io", + "license": "proprietary", + "authors": [ + { + "name": "Swagger and contributors", + "homepage": "https://github.com/swagger-api/swagger-codegen" + } + ], + "require": { + "php": ">=5.5", + "ext-curl": "*", + "ext-json": "*", + "ext-mbstring": "*", + "guzzlehttp/guzzle": "^6.2" + }, + "require-dev": { + "phpunit/phpunit": "^4.8", + "squizlabs/php_codesniffer": "~2.6", + "friendsofphp/php-cs-fixer": "~1.12" + }, + "autoload": { + "psr-4": { "Swagger\\Client\\" : "lib/" } + }, + "autoload-dev": { + "psr-4": { "Swagger\\Client\\" : "test/" } + } +} diff --git a/docs/Api/DomainApi.md b/docs/Api/DomainApi.md new file mode 100644 index 0000000..2ef0649 --- /dev/null +++ b/docs/Api/DomainApi.md @@ -0,0 +1,120 @@ +# Swagger\Client\DomainApi + +All URIs are relative to *https://api.cloudmersive.com* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**domainCheck**](DomainApi.md#domainCheck) | **POST** /validate/domain/check | Validate a domain name +[**domainPost**](DomainApi.md#domainPost) | **POST** /validate/domain/whois | Get WHOIS information for a domain + + +# **domainCheck** +> \Swagger\Client\Model\CheckResponse domainCheck($domain) + +Validate a domain name + +Check whether a domain name is valid or not. API performs a live validation by contacting DNS services to validate the existence of the domain name. + +### Example +```php +setApiKey('Apikey', 'YOUR_API_KEY'); +// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +// $config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('Apikey', 'Bearer'); + +$apiInstance = new Swagger\Client\Api\DomainApi( + // 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 +); +$domain = "domain_example"; // string | Domain name to check, for example \"cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. + +try { + $result = $apiInstance->domainCheck($domain); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling DomainApi->domainCheck: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **domain** | **string**| Domain name to check, for example \"cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. | + +### Return type + +[**\Swagger\Client\Model\CheckResponse**](../Model/CheckResponse.md) + +### Authorization + +[Apikey](../../README.md#Apikey) + +### HTTP request headers + + - **Content-Type**: application/json, text/json, application/xml, text/xml, application/x-www-form-urlencoded + - **Accept**: application/json, text/json, application/xml, text/xml + +[[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) + +# **domainPost** +> \Swagger\Client\Model\WhoisResponse domainPost($domain) + +Get WHOIS information for a domain + +Validate whether a domain name exists, and also return the full WHOIS record for that domain name. WHOIS records include all the registration details of the domain name, such as information about the domain's owners. + +### Example +```php +setApiKey('Apikey', 'YOUR_API_KEY'); +// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +// $config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('Apikey', 'Bearer'); + +$apiInstance = new Swagger\Client\Api\DomainApi( + // 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 +); +$domain = "domain_example"; // string | Domain name to check, for example \"cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. + +try { + $result = $apiInstance->domainPost($domain); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling DomainApi->domainPost: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **domain** | **string**| Domain name to check, for example \"cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. | + +### Return type + +[**\Swagger\Client\Model\WhoisResponse**](../Model/WhoisResponse.md) + +### Authorization + +[Apikey](../../README.md#Apikey) + +### HTTP request headers + + - **Content-Type**: application/json, text/json, application/xml, text/xml, application/x-www-form-urlencoded + - **Accept**: application/json, text/json, application/xml, text/xml + +[[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/EmailApi.md b/docs/Api/EmailApi.md new file mode 100644 index 0000000..12d9b02 --- /dev/null +++ b/docs/Api/EmailApi.md @@ -0,0 +1,176 @@ +# Swagger\Client\EmailApi + +All URIs are relative to *https://api.cloudmersive.com* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**emailAddressGetServers**](EmailApi.md#emailAddressGetServers) | **POST** /validate/email/address/servers | Partially check whether an email address is valid +[**emailFullValidation**](EmailApi.md#emailFullValidation) | **POST** /validate/email/address/full | Fully validate an email address +[**emailPost**](EmailApi.md#emailPost) | **POST** /validate/email/address/syntaxOnly | Validate email adddress for syntactic correctness only + + +# **emailAddressGetServers** +> \Swagger\Client\Model\AddressGetServersResponse emailAddressGetServers($email) + +Partially check whether an email address is valid + +Validate an email address by identifying whether its parent domain has email servers defined. This call is less limited than syntaxOnly but not as comprehensive as address/full. + +### Example +```php +setApiKey('Apikey', 'YOUR_API_KEY'); +// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +// $config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('Apikey', 'Bearer'); + +$apiInstance = new Swagger\Client\Api\EmailApi( + // 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 +); +$email = "email_example"; // string | Email address to validate, e.g. \"support@cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. + +try { + $result = $apiInstance->emailAddressGetServers($email); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling EmailApi->emailAddressGetServers: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **email** | **string**| Email address to validate, e.g. \"support@cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. | + +### Return type + +[**\Swagger\Client\Model\AddressGetServersResponse**](../Model/AddressGetServersResponse.md) + +### Authorization + +[Apikey](../../README.md#Apikey) + +### HTTP request headers + + - **Content-Type**: application/json, text/json, application/xml, text/xml, application/x-www-form-urlencoded + - **Accept**: application/json, text/json, application/xml, text/xml + +[[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) + +# **emailFullValidation** +> \Swagger\Client\Model\FullEmailValidationResponse emailFullValidation($email) + +Fully validate an email address + +Performs a full validation of the email address. Checks for syntactic correctness, identifies the mail server in question if any, and then contacts the email server to validate the existence of the account - without sending any emails. + +### Example +```php +setApiKey('Apikey', 'YOUR_API_KEY'); +// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +// $config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('Apikey', 'Bearer'); + +$apiInstance = new Swagger\Client\Api\EmailApi( + // 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 +); +$email = "email_example"; // string | Email address to validate, e.g. \"support@cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. + +try { + $result = $apiInstance->emailFullValidation($email); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling EmailApi->emailFullValidation: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **email** | **string**| Email address to validate, e.g. \"support@cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. | + +### Return type + +[**\Swagger\Client\Model\FullEmailValidationResponse**](../Model/FullEmailValidationResponse.md) + +### Authorization + +[Apikey](../../README.md#Apikey) + +### HTTP request headers + + - **Content-Type**: application/json, text/json, application/xml, text/xml, application/x-www-form-urlencoded + - **Accept**: application/json, text/json, application/xml, text/xml + +[[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) + +# **emailPost** +> \Swagger\Client\Model\AddressVerifySyntaxOnlyResponse emailPost($value) + +Validate email adddress for syntactic correctness only + +Validate whether a given email address is syntactically correct via a limited local-only check. Use the address/full API to do a full validation. + +### Example +```php +setApiKey('Apikey', 'YOUR_API_KEY'); +// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +// $config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('Apikey', 'Bearer'); + +$apiInstance = new Swagger\Client\Api\EmailApi( + // 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 +); +$value = "value_example"; // string | Email address to validate, e.g. \"support@cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. + +try { + $result = $apiInstance->emailPost($value); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling EmailApi->emailPost: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **value** | **string**| Email address to validate, e.g. \"support@cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. | + +### Return type + +[**\Swagger\Client\Model\AddressVerifySyntaxOnlyResponse**](../Model/AddressVerifySyntaxOnlyResponse.md) + +### Authorization + +[Apikey](../../README.md#Apikey) + +### HTTP request headers + + - **Content-Type**: application/json, text/json, application/xml, text/xml, application/x-www-form-urlencoded + - **Accept**: application/json, text/json, application/xml, text/xml + +[[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/IPAddressApi.md b/docs/Api/IPAddressApi.md new file mode 100644 index 0000000..0631a87 --- /dev/null +++ b/docs/Api/IPAddressApi.md @@ -0,0 +1,64 @@ +# Swagger\Client\IPAddressApi + +All URIs are relative to *https://api.cloudmersive.com* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**iPAddressPost**](IPAddressApi.md#iPAddressPost) | **POST** /validate/ip/geolocate | Geolocate an IP address + + +# **iPAddressPost** +> \Swagger\Client\Model\GeolocateResponse iPAddressPost($value) + +Geolocate an IP address + +Identify an IP address Country, State/Provence, City, Zip/Postal Code, etc. Useful for security and UX applications. + +### Example +```php +setApiKey('Apikey', 'YOUR_API_KEY'); +// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +// $config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('Apikey', 'Bearer'); + +$apiInstance = new Swagger\Client\Api\IPAddressApi( + // 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 +); +$value = "value_example"; // string | IP address to geolocate, e.g. \"55.55.55.55\". The input is a string so be sure to enclose it in double-quotes. + +try { + $result = $apiInstance->iPAddressPost($value); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling IPAddressApi->iPAddressPost: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **value** | **string**| IP address to geolocate, e.g. \"55.55.55.55\". The input is a string so be sure to enclose it in double-quotes. | + +### Return type + +[**\Swagger\Client\Model\GeolocateResponse**](../Model/GeolocateResponse.md) + +### Authorization + +[Apikey](../../README.md#Apikey) + +### HTTP request headers + + - **Content-Type**: application/json, text/json, application/xml, text/xml, application/x-www-form-urlencoded + - **Accept**: application/json, text/json, application/xml, text/xml + +[[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/VatApi.md b/docs/Api/VatApi.md new file mode 100644 index 0000000..b409540 --- /dev/null +++ b/docs/Api/VatApi.md @@ -0,0 +1,64 @@ +# Swagger\Client\VatApi + +All URIs are relative to *https://api.cloudmersive.com* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**vatVatLookup**](VatApi.md#vatVatLookup) | **POST** /validate/vat/lookup | Lookup a VAT code + + +# **vatVatLookup** +> \Swagger\Client\Model\VatLookupResponse vatVatLookup($input) + +Lookup a VAT code + +Checks if a VAT code is valid, and if it is, returns more information about it + +### Example +```php +setApiKey('Apikey', 'YOUR_API_KEY'); +// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +// $config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('Apikey', 'Bearer'); + +$apiInstance = new Swagger\Client\Api\VatApi( + // 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 +); +$input = new \Swagger\Client\Model\VatLookupRequest(); // \Swagger\Client\Model\VatLookupRequest | Input VAT code + +try { + $result = $apiInstance->vatVatLookup($input); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling VatApi->vatVatLookup: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **input** | [**\Swagger\Client\Model\VatLookupRequest**](../Model/VatLookupRequest.md)| Input VAT code | + +### Return type + +[**\Swagger\Client\Model\VatLookupResponse**](../Model/VatLookupResponse.md) + +### Authorization + +[Apikey](../../README.md#Apikey) + +### HTTP request headers + + - **Content-Type**: application/json, text/json, application/xml, text/xml, application/x-www-form-urlencoded + - **Accept**: application/json, text/json, application/xml, text/xml + +[[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/AddressGetServersResponse.md b/docs/Model/AddressGetServersResponse.md new file mode 100644 index 0000000..a60ba68 --- /dev/null +++ b/docs/Model/AddressGetServersResponse.md @@ -0,0 +1,11 @@ +# AddressGetServersResponse + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**success** | **bool** | | [optional] +**servers** | **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/AddressVerifySyntaxOnlyResponse.md b/docs/Model/AddressVerifySyntaxOnlyResponse.md new file mode 100644 index 0000000..1702a9a --- /dev/null +++ b/docs/Model/AddressVerifySyntaxOnlyResponse.md @@ -0,0 +1,10 @@ +# AddressVerifySyntaxOnlyResponse + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**valid_address** | **bool** | True if the email address is syntactically valid, false if it is not | [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/CheckResponse.md b/docs/Model/CheckResponse.md new file mode 100644 index 0000000..794bad3 --- /dev/null +++ b/docs/Model/CheckResponse.md @@ -0,0 +1,10 @@ +# CheckResponse + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**valid_domain** | **bool** | True if the domain name was valid, false if it is not | [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/FullEmailValidationResponse.md b/docs/Model/FullEmailValidationResponse.md new file mode 100644 index 0000000..92c93e3 --- /dev/null +++ b/docs/Model/FullEmailValidationResponse.md @@ -0,0 +1,11 @@ +# FullEmailValidationResponse + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**valid_address** | **bool** | True if the email address is valid, false otherwise | [optional] +**mail_server_used_for_validation** | **string** | Email server connected to for verification | [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/GeolocateResponse.md b/docs/Model/GeolocateResponse.md new file mode 100644 index 0000000..479d35a --- /dev/null +++ b/docs/Model/GeolocateResponse.md @@ -0,0 +1,18 @@ +# GeolocateResponse + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**country_code** | **string** | Two-letter country code of IP address | [optional] +**country_name** | **string** | Country name of IP address | [optional] +**city** | **string** | City of IP address | [optional] +**region_code** | **string** | State/region code of IP address | [optional] +**region_name** | **string** | State/region of IP address | [optional] +**zip_code** | **string** | Zip or postal code of IP address | [optional] +**timezone_standard_name** | **string** | Timezone of IP address | [optional] +**latitude** | **double** | Latitude of IP address | [optional] +**longitude** | **double** | Longitude of IP address | [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/VatLookupRequest.md b/docs/Model/VatLookupRequest.md new file mode 100644 index 0000000..a238a5d --- /dev/null +++ b/docs/Model/VatLookupRequest.md @@ -0,0 +1,10 @@ +# VatLookupRequest + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**vat_code** | **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/VatLookupResponse.md b/docs/Model/VatLookupResponse.md new file mode 100644 index 0000000..99fdb92 --- /dev/null +++ b/docs/Model/VatLookupResponse.md @@ -0,0 +1,14 @@ +# VatLookupResponse + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**country_code** | **string** | | [optional] +**vat_number** | **string** | | [optional] +**is_valid** | **bool** | | [optional] +**business_name** | **string** | | [optional] +**business_address** | **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/WhoisResponse.md b/docs/Model/WhoisResponse.md new file mode 100644 index 0000000..cc9a778 --- /dev/null +++ b/docs/Model/WhoisResponse.md @@ -0,0 +1,13 @@ +# WhoisResponse + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**valid_domain** | **bool** | True if the domain is valid, false if it is not | [optional] +**whois_server** | **string** | Server used to lookup WHOIS information (may change based on lookup). | [optional] +**raw_text_record** | **string** | WHOIS raw text record | [optional] +**created_dt** | [**\DateTime**](\DateTime.md) | Creation date for the record | [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/git_push.sh b/git_push.sh new file mode 100644 index 0000000..3909755 --- /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 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="Cloudmersive" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="Cloudmersive.APIClient.PHP.Validate" + 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/DomainApi.php b/lib/Api/DomainApi.php new file mode 100644 index 0000000..866879a --- /dev/null +++ b/lib/Api/DomainApi.php @@ -0,0 +1,627 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation domainCheck + * + * Validate a domain name + * + * @param string $domain Domain name to check, for example \"cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. (required) + * + * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Swagger\Client\Model\CheckResponse + */ + public function domainCheck($domain) + { + list($response) = $this->domainCheckWithHttpInfo($domain); + return $response; + } + + /** + * Operation domainCheckWithHttpInfo + * + * Validate a domain name + * + * @param string $domain Domain name to check, for example \"cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. (required) + * + * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Swagger\Client\Model\CheckResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function domainCheckWithHttpInfo($domain) + { + $returnType = '\Swagger\Client\Model\CheckResponse'; + $request = $this->domainCheckRequest($domain); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Swagger\Client\Model\CheckResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation domainCheckAsync + * + * Validate a domain name + * + * @param string $domain Domain name to check, for example \"cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function domainCheckAsync($domain) + { + return $this->domainCheckAsyncWithHttpInfo($domain) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation domainCheckAsyncWithHttpInfo + * + * Validate a domain name + * + * @param string $domain Domain name to check, for example \"cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function domainCheckAsyncWithHttpInfo($domain) + { + $returnType = '\Swagger\Client\Model\CheckResponse'; + $request = $this->domainCheckRequest($domain); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'domainCheck' + * + * @param string $domain Domain name to check, for example \"cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function domainCheckRequest($domain) + { + // verify the required parameter 'domain' is set + if ($domain === null) { + throw new \InvalidArgumentException( + 'Missing the required parameter $domain when calling domainCheck' + ); + } + + $resourcePath = '/validate/domain/check'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // body params + $_tempBody = null; + if (isset($domain)) { + $_tempBody = $domain; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json', 'text/json', 'application/xml', 'text/xml'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json', 'text/json', 'application/xml', 'text/xml'], + ['application/json', 'text/json', 'application/xml', 'text/xml', 'application/x-www-form-urlencoded'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Apikey'); + if ($apiKey !== null) { + $headers['Apikey'] = $apiKey; + } + + $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 domainPost + * + * Get WHOIS information for a domain + * + * @param string $domain Domain name to check, for example \"cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. (required) + * + * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Swagger\Client\Model\WhoisResponse + */ + public function domainPost($domain) + { + list($response) = $this->domainPostWithHttpInfo($domain); + return $response; + } + + /** + * Operation domainPostWithHttpInfo + * + * Get WHOIS information for a domain + * + * @param string $domain Domain name to check, for example \"cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. (required) + * + * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Swagger\Client\Model\WhoisResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function domainPostWithHttpInfo($domain) + { + $returnType = '\Swagger\Client\Model\WhoisResponse'; + $request = $this->domainPostRequest($domain); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Swagger\Client\Model\WhoisResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation domainPostAsync + * + * Get WHOIS information for a domain + * + * @param string $domain Domain name to check, for example \"cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function domainPostAsync($domain) + { + return $this->domainPostAsyncWithHttpInfo($domain) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation domainPostAsyncWithHttpInfo + * + * Get WHOIS information for a domain + * + * @param string $domain Domain name to check, for example \"cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function domainPostAsyncWithHttpInfo($domain) + { + $returnType = '\Swagger\Client\Model\WhoisResponse'; + $request = $this->domainPostRequest($domain); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'domainPost' + * + * @param string $domain Domain name to check, for example \"cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function domainPostRequest($domain) + { + // verify the required parameter 'domain' is set + if ($domain === null) { + throw new \InvalidArgumentException( + 'Missing the required parameter $domain when calling domainPost' + ); + } + + $resourcePath = '/validate/domain/whois'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // body params + $_tempBody = null; + if (isset($domain)) { + $_tempBody = $domain; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json', 'text/json', 'application/xml', 'text/xml'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json', 'text/json', 'application/xml', 'text/xml'], + ['application/json', 'text/json', 'application/xml', 'text/xml', 'application/x-www-form-urlencoded'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Apikey'); + if ($apiKey !== null) { + $headers['Apikey'] = $apiKey; + } + + $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/Api/EmailApi.php b/lib/Api/EmailApi.php new file mode 100644 index 0000000..651789b --- /dev/null +++ b/lib/Api/EmailApi.php @@ -0,0 +1,889 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation emailAddressGetServers + * + * Partially check whether an email address is valid + * + * @param string $email Email address to validate, e.g. \"support@cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. (required) + * + * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Swagger\Client\Model\AddressGetServersResponse + */ + public function emailAddressGetServers($email) + { + list($response) = $this->emailAddressGetServersWithHttpInfo($email); + return $response; + } + + /** + * Operation emailAddressGetServersWithHttpInfo + * + * Partially check whether an email address is valid + * + * @param string $email Email address to validate, e.g. \"support@cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. (required) + * + * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Swagger\Client\Model\AddressGetServersResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function emailAddressGetServersWithHttpInfo($email) + { + $returnType = '\Swagger\Client\Model\AddressGetServersResponse'; + $request = $this->emailAddressGetServersRequest($email); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Swagger\Client\Model\AddressGetServersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation emailAddressGetServersAsync + * + * Partially check whether an email address is valid + * + * @param string $email Email address to validate, e.g. \"support@cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function emailAddressGetServersAsync($email) + { + return $this->emailAddressGetServersAsyncWithHttpInfo($email) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation emailAddressGetServersAsyncWithHttpInfo + * + * Partially check whether an email address is valid + * + * @param string $email Email address to validate, e.g. \"support@cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function emailAddressGetServersAsyncWithHttpInfo($email) + { + $returnType = '\Swagger\Client\Model\AddressGetServersResponse'; + $request = $this->emailAddressGetServersRequest($email); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'emailAddressGetServers' + * + * @param string $email Email address to validate, e.g. \"support@cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function emailAddressGetServersRequest($email) + { + // verify the required parameter 'email' is set + if ($email === null) { + throw new \InvalidArgumentException( + 'Missing the required parameter $email when calling emailAddressGetServers' + ); + } + + $resourcePath = '/validate/email/address/servers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // body params + $_tempBody = null; + if (isset($email)) { + $_tempBody = $email; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json', 'text/json', 'application/xml', 'text/xml'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json', 'text/json', 'application/xml', 'text/xml'], + ['application/json', 'text/json', 'application/xml', 'text/xml', 'application/x-www-form-urlencoded'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Apikey'); + if ($apiKey !== null) { + $headers['Apikey'] = $apiKey; + } + + $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 emailFullValidation + * + * Fully validate an email address + * + * @param string $email Email address to validate, e.g. \"support@cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. (required) + * + * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Swagger\Client\Model\FullEmailValidationResponse + */ + public function emailFullValidation($email) + { + list($response) = $this->emailFullValidationWithHttpInfo($email); + return $response; + } + + /** + * Operation emailFullValidationWithHttpInfo + * + * Fully validate an email address + * + * @param string $email Email address to validate, e.g. \"support@cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. (required) + * + * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Swagger\Client\Model\FullEmailValidationResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function emailFullValidationWithHttpInfo($email) + { + $returnType = '\Swagger\Client\Model\FullEmailValidationResponse'; + $request = $this->emailFullValidationRequest($email); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Swagger\Client\Model\FullEmailValidationResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation emailFullValidationAsync + * + * Fully validate an email address + * + * @param string $email Email address to validate, e.g. \"support@cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function emailFullValidationAsync($email) + { + return $this->emailFullValidationAsyncWithHttpInfo($email) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation emailFullValidationAsyncWithHttpInfo + * + * Fully validate an email address + * + * @param string $email Email address to validate, e.g. \"support@cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function emailFullValidationAsyncWithHttpInfo($email) + { + $returnType = '\Swagger\Client\Model\FullEmailValidationResponse'; + $request = $this->emailFullValidationRequest($email); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'emailFullValidation' + * + * @param string $email Email address to validate, e.g. \"support@cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function emailFullValidationRequest($email) + { + // verify the required parameter 'email' is set + if ($email === null) { + throw new \InvalidArgumentException( + 'Missing the required parameter $email when calling emailFullValidation' + ); + } + + $resourcePath = '/validate/email/address/full'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // body params + $_tempBody = null; + if (isset($email)) { + $_tempBody = $email; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json', 'text/json', 'application/xml', 'text/xml'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json', 'text/json', 'application/xml', 'text/xml'], + ['application/json', 'text/json', 'application/xml', 'text/xml', 'application/x-www-form-urlencoded'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Apikey'); + if ($apiKey !== null) { + $headers['Apikey'] = $apiKey; + } + + $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 emailPost + * + * Validate email adddress for syntactic correctness only + * + * @param string $value Email address to validate, e.g. \"support@cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. (required) + * + * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Swagger\Client\Model\AddressVerifySyntaxOnlyResponse + */ + public function emailPost($value) + { + list($response) = $this->emailPostWithHttpInfo($value); + return $response; + } + + /** + * Operation emailPostWithHttpInfo + * + * Validate email adddress for syntactic correctness only + * + * @param string $value Email address to validate, e.g. \"support@cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. (required) + * + * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Swagger\Client\Model\AddressVerifySyntaxOnlyResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function emailPostWithHttpInfo($value) + { + $returnType = '\Swagger\Client\Model\AddressVerifySyntaxOnlyResponse'; + $request = $this->emailPostRequest($value); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Swagger\Client\Model\AddressVerifySyntaxOnlyResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation emailPostAsync + * + * Validate email adddress for syntactic correctness only + * + * @param string $value Email address to validate, e.g. \"support@cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function emailPostAsync($value) + { + return $this->emailPostAsyncWithHttpInfo($value) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation emailPostAsyncWithHttpInfo + * + * Validate email adddress for syntactic correctness only + * + * @param string $value Email address to validate, e.g. \"support@cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function emailPostAsyncWithHttpInfo($value) + { + $returnType = '\Swagger\Client\Model\AddressVerifySyntaxOnlyResponse'; + $request = $this->emailPostRequest($value); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'emailPost' + * + * @param string $value Email address to validate, e.g. \"support@cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function emailPostRequest($value) + { + // verify the required parameter 'value' is set + if ($value === null) { + throw new \InvalidArgumentException( + 'Missing the required parameter $value when calling emailPost' + ); + } + + $resourcePath = '/validate/email/address/syntaxOnly'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // body params + $_tempBody = null; + if (isset($value)) { + $_tempBody = $value; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json', 'text/json', 'application/xml', 'text/xml'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json', 'text/json', 'application/xml', 'text/xml'], + ['application/json', 'text/json', 'application/xml', 'text/xml', 'application/x-www-form-urlencoded'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Apikey'); + if ($apiKey !== null) { + $headers['Apikey'] = $apiKey; + } + + $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/Api/IPAddressApi.php b/lib/Api/IPAddressApi.php new file mode 100644 index 0000000..6a99074 --- /dev/null +++ b/lib/Api/IPAddressApi.php @@ -0,0 +1,365 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation iPAddressPost + * + * Geolocate an IP address + * + * @param string $value IP address to geolocate, e.g. \"55.55.55.55\". The input is a string so be sure to enclose it in double-quotes. (required) + * + * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Swagger\Client\Model\GeolocateResponse + */ + public function iPAddressPost($value) + { + list($response) = $this->iPAddressPostWithHttpInfo($value); + return $response; + } + + /** + * Operation iPAddressPostWithHttpInfo + * + * Geolocate an IP address + * + * @param string $value IP address to geolocate, e.g. \"55.55.55.55\". The input is a string so be sure to enclose it in double-quotes. (required) + * + * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Swagger\Client\Model\GeolocateResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function iPAddressPostWithHttpInfo($value) + { + $returnType = '\Swagger\Client\Model\GeolocateResponse'; + $request = $this->iPAddressPostRequest($value); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Swagger\Client\Model\GeolocateResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation iPAddressPostAsync + * + * Geolocate an IP address + * + * @param string $value IP address to geolocate, e.g. \"55.55.55.55\". The input is a string so be sure to enclose it in double-quotes. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function iPAddressPostAsync($value) + { + return $this->iPAddressPostAsyncWithHttpInfo($value) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation iPAddressPostAsyncWithHttpInfo + * + * Geolocate an IP address + * + * @param string $value IP address to geolocate, e.g. \"55.55.55.55\". The input is a string so be sure to enclose it in double-quotes. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function iPAddressPostAsyncWithHttpInfo($value) + { + $returnType = '\Swagger\Client\Model\GeolocateResponse'; + $request = $this->iPAddressPostRequest($value); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'iPAddressPost' + * + * @param string $value IP address to geolocate, e.g. \"55.55.55.55\". The input is a string so be sure to enclose it in double-quotes. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function iPAddressPostRequest($value) + { + // verify the required parameter 'value' is set + if ($value === null) { + throw new \InvalidArgumentException( + 'Missing the required parameter $value when calling iPAddressPost' + ); + } + + $resourcePath = '/validate/ip/geolocate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // body params + $_tempBody = null; + if (isset($value)) { + $_tempBody = $value; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json', 'text/json', 'application/xml', 'text/xml'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json', 'text/json', 'application/xml', 'text/xml'], + ['application/json', 'text/json', 'application/xml', 'text/xml', 'application/x-www-form-urlencoded'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Apikey'); + if ($apiKey !== null) { + $headers['Apikey'] = $apiKey; + } + + $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/Api/VatApi.php b/lib/Api/VatApi.php new file mode 100644 index 0000000..0b2a52a --- /dev/null +++ b/lib/Api/VatApi.php @@ -0,0 +1,365 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation vatVatLookup + * + * Lookup a VAT code + * + * @param \Swagger\Client\Model\VatLookupRequest $input Input VAT code (required) + * + * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Swagger\Client\Model\VatLookupResponse + */ + public function vatVatLookup($input) + { + list($response) = $this->vatVatLookupWithHttpInfo($input); + return $response; + } + + /** + * Operation vatVatLookupWithHttpInfo + * + * Lookup a VAT code + * + * @param \Swagger\Client\Model\VatLookupRequest $input Input VAT code (required) + * + * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Swagger\Client\Model\VatLookupResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function vatVatLookupWithHttpInfo($input) + { + $returnType = '\Swagger\Client\Model\VatLookupResponse'; + $request = $this->vatVatLookupRequest($input); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Swagger\Client\Model\VatLookupResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation vatVatLookupAsync + * + * Lookup a VAT code + * + * @param \Swagger\Client\Model\VatLookupRequest $input Input VAT code (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function vatVatLookupAsync($input) + { + return $this->vatVatLookupAsyncWithHttpInfo($input) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation vatVatLookupAsyncWithHttpInfo + * + * Lookup a VAT code + * + * @param \Swagger\Client\Model\VatLookupRequest $input Input VAT code (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function vatVatLookupAsyncWithHttpInfo($input) + { + $returnType = '\Swagger\Client\Model\VatLookupResponse'; + $request = $this->vatVatLookupRequest($input); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'vatVatLookup' + * + * @param \Swagger\Client\Model\VatLookupRequest $input Input VAT code (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function vatVatLookupRequest($input) + { + // verify the required parameter 'input' is set + if ($input === null) { + throw new \InvalidArgumentException( + 'Missing the required parameter $input when calling vatVatLookup' + ); + } + + $resourcePath = '/validate/vat/lookup'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // body params + $_tempBody = null; + if (isset($input)) { + $_tempBody = $input; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json', 'text/json', 'application/xml', 'text/xml'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json', 'text/json', 'application/xml', 'text/xml'], + ['application/json', 'text/json', 'application/xml', 'text/xml', 'application/x-www-form-urlencoded'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Apikey'); + if ($apiKey !== null) { + $headers['Apikey'] = $apiKey; + } + + $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..beeba5e --- /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..ff9bc15 --- /dev/null +++ b/lib/Configuration.php @@ -0,0 +1,430 @@ +tempFolderPath = sys_get_temp_dir(); + } + + /** + * Sets API key + * + * @param string $apiKeyIdentifier API key identifier (authentication scheme) + * @param string $key API key or token + * + * @return $this + */ + public function setApiKey($apiKeyIdentifier, $key) + { + $this->apiKeys[$apiKeyIdentifier] = $key; + return $this; + } + + /** + * Gets API key + * + * @param string $apiKeyIdentifier API key identifier (authentication scheme) + * + * @return string API key or token + */ + public function getApiKey($apiKeyIdentifier) + { + return isset($this->apiKeys[$apiKeyIdentifier]) ? $this->apiKeys[$apiKeyIdentifier] : null; + } + + /** + * Sets the prefix for API key (e.g. Bearer) + * + * @param string $apiKeyIdentifier API key identifier (authentication scheme) + * @param string $prefix API key prefix, e.g. Bearer + * + * @return $this + */ + public function setApiKeyPrefix($apiKeyIdentifier, $prefix) + { + $this->apiKeyPrefixes[$apiKeyIdentifier] = $prefix; + return $this; + } + + /** + * Gets API key prefix + * + * @param string $apiKeyIdentifier API key identifier (authentication scheme) + * + * @return string + */ + public function getApiKeyPrefix($apiKeyIdentifier) + { + return isset($this->apiKeyPrefixes[$apiKeyIdentifier]) ? $this->apiKeyPrefixes[$apiKeyIdentifier] : null; + } + + /** + * Sets the access token for OAuth + * + * @param string $accessToken Token for OAuth + * + * @return $this + */ + public function setAccessToken($accessToken) + { + $this->accessToken = $accessToken; + return $this; + } + + /** + * Gets the access token for OAuth + * + * @return string Access token for OAuth + */ + public function getAccessToken() + { + return $this->accessToken; + } + + /** + * Sets the username for HTTP basic authentication + * + * @param string $username Username for HTTP basic authentication + * + * @return $this + */ + public function setUsername($username) + { + $this->username = $username; + return $this; + } + + /** + * Gets the username for HTTP basic authentication + * + * @return string Username for HTTP basic authentication + */ + public function getUsername() + { + return $this->username; + } + + /** + * Sets the password for HTTP basic authentication + * + * @param string $password Password for HTTP basic authentication + * + * @return $this + */ + public function setPassword($password) + { + $this->password = $password; + return $this; + } + + /** + * Gets the password for HTTP basic authentication + * + * @return string Password for HTTP basic authentication + */ + public function getPassword() + { + return $this->password; + } + + /** + * Sets the host + * + * @param string $host Host + * + * @return $this + */ + public function setHost($host) + { + $this->host = $host; + return $this; + } + + /** + * Gets the host + * + * @return string Host + */ + public function getHost() + { + return $this->host; + } + + /** + * Sets the user agent of the api client + * + * @param string $userAgent the user agent of the api client + * + * @throws \InvalidArgumentException + * @return $this + */ + public function setUserAgent($userAgent) + { + if (!is_string($userAgent)) { + throw new \InvalidArgumentException('User-agent must be a string.'); + } + + $this->userAgent = $userAgent; + return $this; + } + + /** + * Gets the user agent of the api client + * + * @return string user agent + */ + public function getUserAgent() + { + return $this->userAgent; + } + + /** + * Sets debug flag + * + * @param bool $debug Debug flag + * + * @return $this + */ + public function setDebug($debug) + { + $this->debug = $debug; + return $this; + } + + /** + * Gets the debug flag + * + * @return bool + */ + public function getDebug() + { + return $this->debug; + } + + /** + * Sets the debug file + * + * @param string $debugFile Debug file + * + * @return $this + */ + public function setDebugFile($debugFile) + { + $this->debugFile = $debugFile; + return $this; + } + + /** + * Gets the debug file + * + * @return string + */ + public function getDebugFile() + { + return $this->debugFile; + } + + /** + * Sets the temp folder path + * + * @param string $tempFolderPath Temp folder path + * + * @return $this + */ + public function setTempFolderPath($tempFolderPath) + { + $this->tempFolderPath = $tempFolderPath; + return $this; + } + + /** + * Gets the temp folder path + * + * @return string Temp folder path + */ + public function getTempFolderPath() + { + return $this->tempFolderPath; + } + + /** + * Gets the default configuration instance + * + * @return Configuration + */ + public static function getDefaultConfiguration() + { + if (self::$defaultConfiguration === null) { + self::$defaultConfiguration = new Configuration(); + } + + return self::$defaultConfiguration; + } + + /** + * Sets the detault configuration instance + * + * @param Configuration $config An instance of the Configuration Object + * + * @return void + */ + public static function setDefaultConfiguration(Configuration $config) + { + self::$defaultConfiguration = $config; + } + + /** + * Gets the essential information for debugging + * + * @return string The report for debugging + */ + public static function toDebugReport() + { + $report = 'PHP SDK (Swagger\Client) Debug Report:' . PHP_EOL; + $report .= ' OS: ' . php_uname() . PHP_EOL; + $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; + $report .= ' OpenAPI Spec Version: v1' . PHP_EOL; + $report .= ' SDK Package Version: 1.3.9' . PHP_EOL; + $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; + + return $report; + } + + /** + * Get API key (with prefix if set) + * + * @param string $apiKeyIdentifier name of apikey + * + * @return string API key with the prefix + */ + public function getApiKeyWithPrefix($apiKeyIdentifier) + { + $prefix = $this->getApiKeyPrefix($apiKeyIdentifier); + $apiKey = $this->getApiKey($apiKeyIdentifier); + + if ($apiKey === null) { + return null; + } + + if ($prefix === null) { + $keyWithPrefix = $apiKey; + } else { + $keyWithPrefix = $prefix . ' ' . $apiKey; + } + + return $keyWithPrefix; + } +} diff --git a/lib/HeaderSelector.php b/lib/HeaderSelector.php new file mode 100644 index 0000000..cab98d0 --- /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/AddressGetServersResponse.php b/lib/Model/AddressGetServersResponse.php new file mode 100644 index 0000000..5682b39 --- /dev/null +++ b/lib/Model/AddressGetServersResponse.php @@ -0,0 +1,333 @@ + 'bool', + 'servers' => 'string[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $swaggerFormats = [ + 'success' => null, + 'servers' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerTypes() + { + return self::$swaggerTypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerFormats() + { + return self::$swaggerFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'success' => 'Success', + 'servers' => 'Servers' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'success' => 'setSuccess', + 'servers' => 'setServers' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'success' => 'getSuccess', + 'servers' => 'getServers' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$swaggerModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['success'] = isset($data['success']) ? $data['success'] : null; + $this->container['servers'] = isset($data['servers']) ? $data['servers'] : 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 true; + } + + + /** + * Gets success + * + * @return bool + */ + public function getSuccess() + { + return $this->container['success']; + } + + /** + * Sets success + * + * @param bool $success success + * + * @return $this + */ + public function setSuccess($success) + { + $this->container['success'] = $success; + + return $this; + } + + /** + * Gets servers + * + * @return string[] + */ + public function getServers() + { + return $this->container['servers']; + } + + /** + * Sets servers + * + * @param string[] $servers servers + * + * @return $this + */ + public function setServers($servers) + { + $this->container['servers'] = $servers; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/AddressVerifySyntaxOnlyResponse.php b/lib/Model/AddressVerifySyntaxOnlyResponse.php new file mode 100644 index 0000000..c8c3372 --- /dev/null +++ b/lib/Model/AddressVerifySyntaxOnlyResponse.php @@ -0,0 +1,303 @@ + 'bool' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $swaggerFormats = [ + 'valid_address' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerTypes() + { + return self::$swaggerTypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerFormats() + { + return self::$swaggerFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'valid_address' => 'ValidAddress' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'valid_address' => 'setValidAddress' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'valid_address' => 'getValidAddress' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$swaggerModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['valid_address'] = isset($data['valid_address']) ? $data['valid_address'] : 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 true; + } + + + /** + * Gets valid_address + * + * @return bool + */ + public function getValidAddress() + { + return $this->container['valid_address']; + } + + /** + * Sets valid_address + * + * @param bool $valid_address True if the email address is syntactically valid, false if it is not + * + * @return $this + */ + public function setValidAddress($valid_address) + { + $this->container['valid_address'] = $valid_address; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/CheckResponse.php b/lib/Model/CheckResponse.php new file mode 100644 index 0000000..e151059 --- /dev/null +++ b/lib/Model/CheckResponse.php @@ -0,0 +1,303 @@ + 'bool' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $swaggerFormats = [ + 'valid_domain' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerTypes() + { + return self::$swaggerTypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerFormats() + { + return self::$swaggerFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'valid_domain' => 'ValidDomain' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'valid_domain' => 'setValidDomain' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'valid_domain' => 'getValidDomain' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$swaggerModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['valid_domain'] = isset($data['valid_domain']) ? $data['valid_domain'] : 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 true; + } + + + /** + * Gets valid_domain + * + * @return bool + */ + public function getValidDomain() + { + return $this->container['valid_domain']; + } + + /** + * Sets valid_domain + * + * @param bool $valid_domain True if the domain name was valid, false if it is not + * + * @return $this + */ + public function setValidDomain($valid_domain) + { + $this->container['valid_domain'] = $valid_domain; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/FullEmailValidationResponse.php b/lib/Model/FullEmailValidationResponse.php new file mode 100644 index 0000000..7635b71 --- /dev/null +++ b/lib/Model/FullEmailValidationResponse.php @@ -0,0 +1,333 @@ + 'bool', + 'mail_server_used_for_validation' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $swaggerFormats = [ + 'valid_address' => null, + 'mail_server_used_for_validation' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerTypes() + { + return self::$swaggerTypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerFormats() + { + return self::$swaggerFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'valid_address' => 'ValidAddress', + 'mail_server_used_for_validation' => 'MailServerUsedForValidation' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'valid_address' => 'setValidAddress', + 'mail_server_used_for_validation' => 'setMailServerUsedForValidation' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'valid_address' => 'getValidAddress', + 'mail_server_used_for_validation' => 'getMailServerUsedForValidation' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$swaggerModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['valid_address'] = isset($data['valid_address']) ? $data['valid_address'] : null; + $this->container['mail_server_used_for_validation'] = isset($data['mail_server_used_for_validation']) ? $data['mail_server_used_for_validation'] : 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 true; + } + + + /** + * Gets valid_address + * + * @return bool + */ + public function getValidAddress() + { + return $this->container['valid_address']; + } + + /** + * Sets valid_address + * + * @param bool $valid_address True if the email address is valid, false otherwise + * + * @return $this + */ + public function setValidAddress($valid_address) + { + $this->container['valid_address'] = $valid_address; + + return $this; + } + + /** + * Gets mail_server_used_for_validation + * + * @return string + */ + public function getMailServerUsedForValidation() + { + return $this->container['mail_server_used_for_validation']; + } + + /** + * Sets mail_server_used_for_validation + * + * @param string $mail_server_used_for_validation Email server connected to for verification + * + * @return $this + */ + public function setMailServerUsedForValidation($mail_server_used_for_validation) + { + $this->container['mail_server_used_for_validation'] = $mail_server_used_for_validation; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/GeolocateResponse.php b/lib/Model/GeolocateResponse.php new file mode 100644 index 0000000..b088a65 --- /dev/null +++ b/lib/Model/GeolocateResponse.php @@ -0,0 +1,543 @@ + 'string', + 'country_name' => 'string', + 'city' => 'string', + 'region_code' => 'string', + 'region_name' => 'string', + 'zip_code' => 'string', + 'timezone_standard_name' => 'string', + 'latitude' => 'double', + 'longitude' => 'double' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $swaggerFormats = [ + 'country_code' => null, + 'country_name' => null, + 'city' => null, + 'region_code' => null, + 'region_name' => null, + 'zip_code' => null, + 'timezone_standard_name' => null, + 'latitude' => 'double', + 'longitude' => 'double' + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerTypes() + { + return self::$swaggerTypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerFormats() + { + return self::$swaggerFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'country_code' => 'CountryCode', + 'country_name' => 'CountryName', + 'city' => 'City', + 'region_code' => 'RegionCode', + 'region_name' => 'RegionName', + 'zip_code' => 'ZipCode', + 'timezone_standard_name' => 'TimezoneStandardName', + 'latitude' => 'Latitude', + 'longitude' => 'Longitude' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'country_code' => 'setCountryCode', + 'country_name' => 'setCountryName', + 'city' => 'setCity', + 'region_code' => 'setRegionCode', + 'region_name' => 'setRegionName', + 'zip_code' => 'setZipCode', + 'timezone_standard_name' => 'setTimezoneStandardName', + 'latitude' => 'setLatitude', + 'longitude' => 'setLongitude' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'country_code' => 'getCountryCode', + 'country_name' => 'getCountryName', + 'city' => 'getCity', + 'region_code' => 'getRegionCode', + 'region_name' => 'getRegionName', + 'zip_code' => 'getZipCode', + 'timezone_standard_name' => 'getTimezoneStandardName', + 'latitude' => 'getLatitude', + 'longitude' => 'getLongitude' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$swaggerModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['country_code'] = isset($data['country_code']) ? $data['country_code'] : null; + $this->container['country_name'] = isset($data['country_name']) ? $data['country_name'] : null; + $this->container['city'] = isset($data['city']) ? $data['city'] : null; + $this->container['region_code'] = isset($data['region_code']) ? $data['region_code'] : null; + $this->container['region_name'] = isset($data['region_name']) ? $data['region_name'] : null; + $this->container['zip_code'] = isset($data['zip_code']) ? $data['zip_code'] : null; + $this->container['timezone_standard_name'] = isset($data['timezone_standard_name']) ? $data['timezone_standard_name'] : null; + $this->container['latitude'] = isset($data['latitude']) ? $data['latitude'] : null; + $this->container['longitude'] = isset($data['longitude']) ? $data['longitude'] : 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 true; + } + + + /** + * Gets country_code + * + * @return string + */ + public function getCountryCode() + { + return $this->container['country_code']; + } + + /** + * Sets country_code + * + * @param string $country_code Two-letter country code of IP address + * + * @return $this + */ + public function setCountryCode($country_code) + { + $this->container['country_code'] = $country_code; + + return $this; + } + + /** + * Gets country_name + * + * @return string + */ + public function getCountryName() + { + return $this->container['country_name']; + } + + /** + * Sets country_name + * + * @param string $country_name Country name of IP address + * + * @return $this + */ + public function setCountryName($country_name) + { + $this->container['country_name'] = $country_name; + + return $this; + } + + /** + * Gets city + * + * @return string + */ + public function getCity() + { + return $this->container['city']; + } + + /** + * Sets city + * + * @param string $city City of IP address + * + * @return $this + */ + public function setCity($city) + { + $this->container['city'] = $city; + + return $this; + } + + /** + * Gets region_code + * + * @return string + */ + public function getRegionCode() + { + return $this->container['region_code']; + } + + /** + * Sets region_code + * + * @param string $region_code State/region code of IP address + * + * @return $this + */ + public function setRegionCode($region_code) + { + $this->container['region_code'] = $region_code; + + return $this; + } + + /** + * Gets region_name + * + * @return string + */ + public function getRegionName() + { + return $this->container['region_name']; + } + + /** + * Sets region_name + * + * @param string $region_name State/region of IP address + * + * @return $this + */ + public function setRegionName($region_name) + { + $this->container['region_name'] = $region_name; + + return $this; + } + + /** + * Gets zip_code + * + * @return string + */ + public function getZipCode() + { + return $this->container['zip_code']; + } + + /** + * Sets zip_code + * + * @param string $zip_code Zip or postal code of IP address + * + * @return $this + */ + public function setZipCode($zip_code) + { + $this->container['zip_code'] = $zip_code; + + return $this; + } + + /** + * Gets timezone_standard_name + * + * @return string + */ + public function getTimezoneStandardName() + { + return $this->container['timezone_standard_name']; + } + + /** + * Sets timezone_standard_name + * + * @param string $timezone_standard_name Timezone of IP address + * + * @return $this + */ + public function setTimezoneStandardName($timezone_standard_name) + { + $this->container['timezone_standard_name'] = $timezone_standard_name; + + return $this; + } + + /** + * Gets latitude + * + * @return double + */ + public function getLatitude() + { + return $this->container['latitude']; + } + + /** + * Sets latitude + * + * @param double $latitude Latitude of IP address + * + * @return $this + */ + public function setLatitude($latitude) + { + $this->container['latitude'] = $latitude; + + return $this; + } + + /** + * Gets longitude + * + * @return double + */ + public function getLongitude() + { + return $this->container['longitude']; + } + + /** + * Sets longitude + * + * @param double $longitude Longitude of IP address + * + * @return $this + */ + public function setLongitude($longitude) + { + $this->container['longitude'] = $longitude; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/ModelInterface.php b/lib/Model/ModelInterface.php new file mode 100644 index 0000000..a58da10 --- /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 $swaggerFormats = [ + 'vat_code' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerTypes() + { + return self::$swaggerTypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerFormats() + { + return self::$swaggerFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'vat_code' => 'VatCode' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'vat_code' => 'setVatCode' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'vat_code' => 'getVatCode' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$swaggerModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['vat_code'] = isset($data['vat_code']) ? $data['vat_code'] : 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 true; + } + + + /** + * Gets vat_code + * + * @return string + */ + public function getVatCode() + { + return $this->container['vat_code']; + } + + /** + * Sets vat_code + * + * @param string $vat_code vat_code + * + * @return $this + */ + public function setVatCode($vat_code) + { + $this->container['vat_code'] = $vat_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() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/VatLookupResponse.php b/lib/Model/VatLookupResponse.php new file mode 100644 index 0000000..f5e6d5f --- /dev/null +++ b/lib/Model/VatLookupResponse.php @@ -0,0 +1,422 @@ + 'string', + 'vat_number' => 'string', + 'is_valid' => 'bool', + 'business_name' => 'string', + 'business_address' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $swaggerFormats = [ + 'country_code' => null, + 'vat_number' => null, + 'is_valid' => null, + 'business_name' => null, + 'business_address' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerTypes() + { + return self::$swaggerTypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerFormats() + { + return self::$swaggerFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'country_code' => 'CountryCode', + 'vat_number' => 'VatNumber', + 'is_valid' => 'IsValid', + 'business_name' => 'BusinessName', + 'business_address' => 'BusinessAddress' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'country_code' => 'setCountryCode', + 'vat_number' => 'setVatNumber', + 'is_valid' => 'setIsValid', + 'business_name' => 'setBusinessName', + 'business_address' => 'setBusinessAddress' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'country_code' => 'getCountryCode', + 'vat_number' => 'getVatNumber', + 'is_valid' => 'getIsValid', + 'business_name' => 'getBusinessName', + 'business_address' => 'getBusinessAddress' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$swaggerModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['country_code'] = isset($data['country_code']) ? $data['country_code'] : null; + $this->container['vat_number'] = isset($data['vat_number']) ? $data['vat_number'] : null; + $this->container['is_valid'] = isset($data['is_valid']) ? $data['is_valid'] : null; + $this->container['business_name'] = isset($data['business_name']) ? $data['business_name'] : null; + $this->container['business_address'] = isset($data['business_address']) ? $data['business_address'] : 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 true; + } + + + /** + * Gets country_code + * + * @return string + */ + public function getCountryCode() + { + return $this->container['country_code']; + } + + /** + * Sets country_code + * + * @param string $country_code country_code + * + * @return $this + */ + public function setCountryCode($country_code) + { + $this->container['country_code'] = $country_code; + + return $this; + } + + /** + * Gets vat_number + * + * @return string + */ + public function getVatNumber() + { + return $this->container['vat_number']; + } + + /** + * Sets vat_number + * + * @param string $vat_number vat_number + * + * @return $this + */ + public function setVatNumber($vat_number) + { + $this->container['vat_number'] = $vat_number; + + return $this; + } + + /** + * Gets is_valid + * + * @return bool + */ + public function getIsValid() + { + return $this->container['is_valid']; + } + + /** + * Sets is_valid + * + * @param bool $is_valid is_valid + * + * @return $this + */ + public function setIsValid($is_valid) + { + $this->container['is_valid'] = $is_valid; + + return $this; + } + + /** + * Gets business_name + * + * @return string + */ + public function getBusinessName() + { + return $this->container['business_name']; + } + + /** + * Sets business_name + * + * @param string $business_name business_name + * + * @return $this + */ + public function setBusinessName($business_name) + { + $this->container['business_name'] = $business_name; + + return $this; + } + + /** + * Gets business_address + * + * @return string + */ + public function getBusinessAddress() + { + return $this->container['business_address']; + } + + /** + * Sets business_address + * + * @param string $business_address business_address + * + * @return $this + */ + public function setBusinessAddress($business_address) + { + $this->container['business_address'] = $business_address; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/WhoisResponse.php b/lib/Model/WhoisResponse.php new file mode 100644 index 0000000..c53d772 --- /dev/null +++ b/lib/Model/WhoisResponse.php @@ -0,0 +1,393 @@ + 'bool', + 'whois_server' => 'string', + 'raw_text_record' => 'string', + 'created_dt' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $swaggerFormats = [ + 'valid_domain' => null, + 'whois_server' => null, + 'raw_text_record' => null, + 'created_dt' => 'date-time' + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerTypes() + { + return self::$swaggerTypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerFormats() + { + return self::$swaggerFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'valid_domain' => 'ValidDomain', + 'whois_server' => 'WhoisServer', + 'raw_text_record' => 'RawTextRecord', + 'created_dt' => 'CreatedDt' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'valid_domain' => 'setValidDomain', + 'whois_server' => 'setWhoisServer', + 'raw_text_record' => 'setRawTextRecord', + 'created_dt' => 'setCreatedDt' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'valid_domain' => 'getValidDomain', + 'whois_server' => 'getWhoisServer', + 'raw_text_record' => 'getRawTextRecord', + 'created_dt' => 'getCreatedDt' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$swaggerModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['valid_domain'] = isset($data['valid_domain']) ? $data['valid_domain'] : null; + $this->container['whois_server'] = isset($data['whois_server']) ? $data['whois_server'] : null; + $this->container['raw_text_record'] = isset($data['raw_text_record']) ? $data['raw_text_record'] : null; + $this->container['created_dt'] = isset($data['created_dt']) ? $data['created_dt'] : 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 true; + } + + + /** + * Gets valid_domain + * + * @return bool + */ + public function getValidDomain() + { + return $this->container['valid_domain']; + } + + /** + * Sets valid_domain + * + * @param bool $valid_domain True if the domain is valid, false if it is not + * + * @return $this + */ + public function setValidDomain($valid_domain) + { + $this->container['valid_domain'] = $valid_domain; + + return $this; + } + + /** + * Gets whois_server + * + * @return string + */ + public function getWhoisServer() + { + return $this->container['whois_server']; + } + + /** + * Sets whois_server + * + * @param string $whois_server Server used to lookup WHOIS information (may change based on lookup). + * + * @return $this + */ + public function setWhoisServer($whois_server) + { + $this->container['whois_server'] = $whois_server; + + return $this; + } + + /** + * Gets raw_text_record + * + * @return string + */ + public function getRawTextRecord() + { + return $this->container['raw_text_record']; + } + + /** + * Sets raw_text_record + * + * @param string $raw_text_record WHOIS raw text record + * + * @return $this + */ + public function setRawTextRecord($raw_text_record) + { + $this->container['raw_text_record'] = $raw_text_record; + + return $this; + } + + /** + * Gets created_dt + * + * @return \DateTime + */ + public function getCreatedDt() + { + return $this->container['created_dt']; + } + + /** + * Sets created_dt + * + * @param \DateTime $created_dt Creation date for the record + * + * @return $this + */ + public function setCreatedDt($created_dt) + { + $this->container['created_dt'] = $created_dt; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/ObjectSerializer.php b/lib/ObjectSerializer.php new file mode 100644 index 0000000..7036c9e --- /dev/null +++ b/lib/ObjectSerializer.php @@ -0,0 +1,317 @@ +format('Y-m-d') : $data->format(\DateTime::ATOM); + } elseif (is_array($data)) { + foreach ($data as $property => $value) { + $data[$property] = self::sanitizeForSerialization($value); + } + return $data; + } elseif (is_object($data)) { + $values = []; + $formats = $data::swaggerFormats(); + foreach ($data::swaggerTypes() as $property => $swaggerType) { + $getter = $data::getters()[$property]; + $value = $data->$getter(); + if ($value !== null + && !in_array($swaggerType, ['DateTime', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true) + && method_exists($swaggerType, 'getAllowableEnumValues') + && !in_array($value, $swaggerType::getAllowableEnumValues())) { + $imploded = implode("', '", $swaggerType::getAllowableEnumValues()); + throw new \InvalidArgumentException("Invalid value for enum '$swaggerType', must be one of: '$imploded'"); + } + if ($value !== null) { + $values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value, $swaggerType, $formats[$property]); + } + } + return (object)$values; + } else { + return (string)$data; + } + } + + /** + * Sanitize filename by removing path. + * e.g. ../../sun.gif becomes sun.gif + * + * @param string $filename filename to be sanitized + * + * @return string the sanitized filename + */ + public static function sanitizeFilename($filename) + { + if (preg_match("/.*[\/\\\\](.*)$/", $filename, $match)) { + return $match[1]; + } else { + return $filename; + } + } + + /** + * Take value and turn it into a string suitable for inclusion in + * the path, by url-encoding. + * + * @param string $value a string which will be part of the path + * + * @return string the serialized object + */ + public static function toPathValue($value) + { + return rawurlencode(self::toString($value)); + } + + /** + * Take value and turn it into a string suitable for inclusion in + * the query, by imploding comma-separated if it's an object. + * If it's a string, pass through unchanged. It will be url-encoded + * later. + * + * @param string[]|string|\DateTime $object an object to be serialized to a string + * + * @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 an single or an array of $class instances + */ + public static function deserialize($data, $class, $httpHeaders = null) + { + if (null === $data) { + return null; + } elseif (substr($class, 0, 4) === 'map[') { // for associative array e.g. map[string,int] + $inner = substr($class, 4, -1); + $deserialized = []; + if (strrpos($inner, ",") !== false) { + $subClass_array = explode(',', $inner, 2); + $subClass = $subClass_array[1]; + foreach ($data as $key => $value) { + $deserialized[$key] = self::deserialize($value, $subClass, null); + } + } + return $deserialized; + } elseif (strcasecmp(substr($class, -2), '[]') === 0) { + $subClass = substr($class, 0, -2); + $values = []; + foreach ($data as $key => $value) { + $values[] = self::deserialize($value, $subClass, null); + } + return $values; + } elseif ($class === 'object') { + settype($data, 'array'); + return $data; + } elseif ($class === '\DateTime') { + // Some API's return an invalid, empty string as a + // date-time property. DateTime::__construct() will return + // the current time for empty input which is probably not + // what is meant. The invalid empty string is probably to + // be interpreted as a missing field/value. Let's handle + // this graceful. + if (!empty($data)) { + return new \DateTime($data); + } else { + return null; + } + } elseif (in_array($class, ['DateTime', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) { + settype($data, $class); + return $data; + } elseif ($class === '\SplFileObject') { + /** @var \Psr\Http\Message\StreamInterface $data */ + + // determine file name + if (array_key_exists('Content-Disposition', $httpHeaders) && + preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeaders['Content-Disposition'], $match)) { + $filename = Configuration::getDefaultConfiguration()->getTempFolderPath() . self::sanitizeFilename($match[1]); + } else { + $filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), ''); + } + + $file = fopen($filename, 'w'); + while ($chunk = $data->read(200)) { + fwrite($file, $chunk); + } + fclose($file); + + return new \SplFileObject($filename, 'r'); + } elseif (method_exists($class, 'getAllowableEnumValues')) { + if (!in_array($data, $class::getAllowableEnumValues())) { + $imploded = implode("', '", $class::getAllowableEnumValues()); + throw new \InvalidArgumentException("Invalid value for enum '$class', must be one of: '$imploded'"); + } + return $data; + } else { + // If a discriminator is defined and points to a valid subclass, use it. + $discriminator = $class::DISCRIMINATOR; + if (!empty($discriminator) && isset($data->{$discriminator}) && is_string($data->{$discriminator})) { + $subclass = '\Swagger\Client\Model\\' . $data->{$discriminator}; + if (is_subclass_of($subclass, $class)) { + $class = $subclass; + } + } + $instance = new $class(); + foreach ($instance::swaggerTypes() as $property => $type) { + $propertySetter = $instance::setters()[$property]; + + if (!isset($propertySetter) || !isset($data->{$instance::attributeMap()[$property]})) { + continue; + } + + $propertyValue = $data->{$instance::attributeMap()[$property]}; + if (isset($propertyValue)) { + $instance->$propertySetter(self::deserialize($propertyValue, $type, null)); + } + } + return $instance; + } + } +} diff --git a/packageconfig.json b/packageconfig.json index bfb212b..8c9d59d 100644 --- a/packageconfig.json +++ b/packageconfig.json @@ -1,9 +1,9 @@ { "artifactVersion": "1.3.9", "gitUserId": "Cloudmersive", - "gitRepoId": "Cloudmersive.APIClient.PHP.OCR", + "gitRepoId": "Cloudmersive.APIClient.PHP.Validate", "composerVendorName": "cloudmersive", - "composerProjectName": "cloudmersive_ocr_api_client", - "packagePath": "cloudmersive_ocr_api_client" + "composerProjectName": "cloudmersive_validate_api_client", + "packagePath": "cloudmersive_validate_api_client" } \ No newline at end of file diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..cadedbc --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,21 @@ + + + + + ./test/Api + ./test/Model + + + + + + ./lib\Api + ./lib\Model + + + diff --git a/test/Api/DomainApiTest.php b/test/Api/DomainApiTest.php new file mode 100644 index 0000000..286d649 --- /dev/null +++ b/test/Api/DomainApiTest.php @@ -0,0 +1,93 @@ +