diff --git a/.gitignore b/.gitignore index cffad6b..c832843 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ -# ref: https://github.com/github/gitignore/blob/master/Composer.gitignore - composer.phar /vendor/ diff --git a/README.md b/README.md index 3b23280..e80784d 100644 --- a/README.md +++ b/README.md @@ -27,12 +27,13 @@ require __DIR__ . '/../vendor/autoload.php'; $privateKeyLocation = __DIR__ . "/private_key.pem"; $config = new Gr4vy\Gr4vyConfig("[YOUR_GR4VY_ID]", $privateKeyLocation); +$apiInstance = new Gr4vy\Api\BuyersApi(new GuzzleHttp\Client(),$config->getConfig()); try { - $result = $config->listBuyers(); + $result = $apiInstance->listBuyers(); print_r($result); } catch (Exception $e) { - echo 'Exception when calling listBuyers: ', $e->getMessage(), PHP_EOL; + echo 'Exception when calling BuyersApi->listBuyers: ', $e->getMessage(), PHP_EOL; } ``` @@ -51,24 +52,10 @@ $config = new Gr4vy\Gr4vyConfig("[YOUR_GR4VY_ID]", $privateKeyLocation, false, " ## Gr4vy Embed To create a token for Gr4vy Embed, call the `config->getEmbedToken()` function -with the amount, currency, optional buyer information and optional checkout session for Gr4vy Embed. +with the amount, currency, and optional buyer information for Gr4vy Embed. ```php -//A checkout session allows multiple transaction attempts to be tied together -$checkoutSession = $config->newCheckoutSession(); - echo $config->getEmbedToken( - array( - "amount"=> 200, - "currency" => "USD", - "buyer_id"=> "d757c76a-cbd7-4b56-95a3-40125b51b29c" - ), - $checkoutSession["id"] -); -``` -Or, generate a checkout session and Embed Token with a single call: -```php -echo $config->getEmbedTokenWithCheckoutSession( array( "amount"=> 200, "currency" => "USD", @@ -77,7 +64,7 @@ echo $config->getEmbedTokenWithCheckoutSession( ); ``` -You can now pass this token to your front end where it can be used to +You can now pass this token to your frontend where it can be used to authenticate Gr4vy Embed. The `buyerId` and `buyerExternalIdentifier` fields can be used to allow the @@ -86,31 +73,15 @@ be created before it can be used in this way. ```php $config = new Gr4vy\Gr4vyConfig("[YOUR_GR4VY_ID]", $privateKeyLocation); +$apiInstance = new Gr4vy\Api\BuyersApi(new GuzzleHttp\Client(),$config->getConfig()); $buyer_request = array("external_identifier"=>"412231123","display_name"=>"Tester T."); -$buyer = $config->addBuyer($buyer_request); +$buyer = $apiInstance->addBuyer($buyer_request); -$embed = array("amount"=> 200, "currency" => "USD", "buyer_id"=> $buyer["id"]); +$embed = array("amount"=> 200, "currency" => "USD", "buyer_id"=> $buyer->getId()); $embedToken = $config->getEmbedToken($embed); ``` -## Checkout Sessions - -A checkout session can be used across Embed sessions to track retries or shopping cart updates. To achieve this the same `checkoutSessionId` can be used in multiple `getEmbedToken` calls. - -NOTE: a checkout session is valid for 1h from creation. - -```php -$config->getEmbedToken( - array( - "amount"=> 200, - "currency" => "USD", - "buyer_id"=> "d757c76a-cbd7-4b56-95a3-40125b51b29c" - ), - $storedCheckoutSessionId -); -``` - ## Initialization The client can be initialized with the Gr4vy ID (`gr4vyId`) and the private key. @@ -130,12 +101,12 @@ Your API key can be created in your admin panel on the **Integrations** tab. ## Multi merchant -In a multi-merchant environment, the merchant account ID can be set by passing `merchantAccountId` to the Config: +In a multi-merchant environment, the merchant account ID can be set by passing `MerchantAccountHeaderSelector` to the Api: ```php -$config = new Gr4vy\Gr4vyConfig("[YOUR_GR4VY_ID]", $privateKeyLocation, false, "sandbox", "default"); - -$config = new Gr4vy\Gr4vyConfig("[YOUR_GR4VY_ID]", $privateKeyLocation, false, "sandbox", "my_merchant_account_id"); +$headerSelector = new MerchantAccountHeaderSelector("my_merchant_account_id"); +$config = new Gr4vyConfig(self::$gr4vyId, self::$privateKeyLocation); +$apiInstance = new BuyersApi(new Client(),$config->getConfig(), $headerSelector); ``` ## Making API calls @@ -143,21 +114,21 @@ $config = new Gr4vy\Gr4vyConfig("[YOUR_GR4VY_ID]", $privateKeyLocation, false, " This library conveniently maps every API path to a seperate function. For example, `GET /buyers?limit=100` would be: ```php -$result = $config->listBuyers(100); +$result = $apiInstance->listBuyers(100); ``` To create or update a resource an `array` should be sent with the request data. ```php $buyer_request = array("external_identifier"=>"412231123","display_name"=>"Tester T."); -$buyer = $config->addBuyer($buyer_request); +$buyer = $apiInstance->addBuyer($buyer_request); ``` Similarly, to update a buyer you will need to pass in the `BuyerUpdateRequest`. ```php $buyer_update = array("external_identifier"=>"testUpdateBuyer"); -$result = $config->updateBuyer($result["id"], $buyer_update); +$result = $apiInstance->updateBuyer($result->getId(), $buyer_update); ``` ## Generate API bearer token @@ -166,7 +137,7 @@ The SDK can be used to create API access tokens for use with other request libraries. ```php -$bearerToken = Gr4vyConfig::getToken($privateKeyLocation, array("*.read", "*.write"))->toString(); +$bearerToken = Gr4vyConfig::getToken($privateKeyLocation, array("*.read"))->toString(); ``` The first parameter is the location of your private key. The second @@ -202,6 +173,15 @@ composer install ./vendor/bin/phpunit test/ ``` +### Adding new APIs + +To add new APIs, run the following command to update the models and APIs based +on the API spec. + +```sh +./openapi-generator-generate.sh +``` + ### Publishing Publishing of this project is done through [Packagist][packagist]. New versions diff --git a/composer.json b/composer.json index 78c5430..64728c0 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,9 @@ }, "autoload": { "psr-4": { - "Gr4vy\\": "lib/" + "Gr4vy\\": "lib/", + "Gr4vy\\Api\\": "lib/api/", + "Gr4vy\\Model\\": "lib/model/" } }, "autoload-dev": { diff --git a/composer.lock b/composer.lock index 27da8da..9b35f05 100644 --- a/composer.lock +++ b/composer.lock @@ -4760,4 +4760,4 @@ }, "platform-dev": [], "plugin-api-version": "2.3.0" -} \ No newline at end of file +} diff --git a/docs/Api/AntiFraudServicesApi.md b/docs/Api/AntiFraudServicesApi.md new file mode 100644 index 0000000..95c7cf3 --- /dev/null +++ b/docs/Api/AntiFraudServicesApi.md @@ -0,0 +1,252 @@ +# Gr4vy\AntiFraudServicesApi + +All URIs are relative to https://api.plantly.gr4vy.app. + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**addAntiFraudService()**](AntiFraudServicesApi.md#addAntiFraudService) | **POST** /anti-fraud-services | New anti-fraud service +[**deleteAntiFraudService()**](AntiFraudServicesApi.md#deleteAntiFraudService) | **DELETE** /anti-fraud-services/{anti_fraud_service_id} | Delete anti-fraud service +[**getAntiFraudService()**](AntiFraudServicesApi.md#getAntiFraudService) | **GET** /anti-fraud-services/{anti_fraud_service_id} | Get anti-fraud service +[**updateAntiFraudService()**](AntiFraudServicesApi.md#updateAntiFraudService) | **PUT** /anti-fraud-services/{anti_fraud_service_id} | Update anti-fraud service + + +## `addAntiFraudService()` + +```php +addAntiFraudService($anti_fraud_service_create): \Gr4vy\model\AntiFraudService +``` + +New anti-fraud service + +Adds an anti-fraud service, enabling merchants to determine risky transactions and prevent chargebacks. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\AntiFraudServicesApi( + // 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 +); +$anti_fraud_service_create = {"anti_fraud_service_definition_id":"sift","display_name":"Sift Anti-Fraud Service.","active":true,"fields":[{"key":"api_key","value":"sk_test_26PHem9AhJZvU623DfE1x4sd"},{"key":"account_id","value":"26PHem9AhJZvU623DfE1x4sd"}]}; // \Gr4vy\model\AntiFraudServiceCreate + +try { + $result = $apiInstance->addAntiFraudService($anti_fraud_service_create); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling AntiFraudServicesApi->addAntiFraudService: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **anti_fraud_service_create** | [**\Gr4vy\model\AntiFraudServiceCreate**](../Model/AntiFraudServiceCreate.md)| | [optional] + +### Return type + +[**\Gr4vy\model\AntiFraudService**](../Model/AntiFraudService.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: `application/json` +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `deleteAntiFraudService()` + +```php +deleteAntiFraudService($anti_fraud_service_id) +``` + +Delete anti-fraud service + +Deletes an anti-fraud service record. Any associated credentials will also be deleted. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\AntiFraudServicesApi( + // 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 +); +$anti_fraud_service_id = 8724fd24-5489-4a5d-90fd-0604df7d3b83; // string | The unique ID for an anti-fraud service. + +try { + $apiInstance->deleteAntiFraudService($anti_fraud_service_id); +} catch (Exception $e) { + echo 'Exception when calling AntiFraudServicesApi->deleteAntiFraudService: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **anti_fraud_service_id** | **string**| The unique ID for an anti-fraud service. | + +### Return type + +void (empty response body) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `getAntiFraudService()` + +```php +getAntiFraudService($anti_fraud_service_id): \Gr4vy\model\AntiFraudService +``` + +Get anti-fraud service + +Gets the information about an anti-fraud service. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\AntiFraudServicesApi( + // 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 +); +$anti_fraud_service_id = 8724fd24-5489-4a5d-90fd-0604df7d3b83; // string | The unique ID for an anti-fraud service. + +try { + $result = $apiInstance->getAntiFraudService($anti_fraud_service_id); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling AntiFraudServicesApi->getAntiFraudService: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **anti_fraud_service_id** | **string**| The unique ID for an anti-fraud service. | + +### Return type + +[**\Gr4vy\model\AntiFraudService**](../Model/AntiFraudService.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `updateAntiFraudService()` + +```php +updateAntiFraudService($anti_fraud_service_id, $anti_fraud_service_update): \Gr4vy\model\AntiFraudService +``` + +Update anti-fraud service + +Update an anti-fraud service, enabling merchants to determine risky transactions and prevent chargebacks. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\AntiFraudServicesApi( + // 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 +); +$anti_fraud_service_id = 8724fd24-5489-4a5d-90fd-0604df7d3b83; // string | The unique ID for an anti-fraud service. +$anti_fraud_service_update = {"anti_fraud_service_definition_id":"sift","display_name":"Sift Anti-Fraud Service.","active":true,"fields":[{"key":"api_key","value":"sk_test_26PHem9AhJZvU623DfE1x4sd"},{"key":"account_id","value":"26PHem9AhJZvU623DfE1x4sd"}]}; // \Gr4vy\model\AntiFraudServiceUpdate + +try { + $result = $apiInstance->updateAntiFraudService($anti_fraud_service_id, $anti_fraud_service_update); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling AntiFraudServicesApi->updateAntiFraudService: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **anti_fraud_service_id** | **string**| The unique ID for an anti-fraud service. | + **anti_fraud_service_update** | [**\Gr4vy\model\AntiFraudServiceUpdate**](../Model/AntiFraudServiceUpdate.md)| | [optional] + +### Return type + +[**\Gr4vy\model\AntiFraudService**](../Model/AntiFraudService.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: `application/json` +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) diff --git a/docs/Api/AuditLogsApi.md b/docs/Api/AuditLogsApi.md new file mode 100644 index 0000000..53a7d1e --- /dev/null +++ b/docs/Api/AuditLogsApi.md @@ -0,0 +1,70 @@ +# Gr4vy\AuditLogsApi + +All URIs are relative to https://api.plantly.gr4vy.app. + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**listAuditLogs()**](AuditLogsApi.md#listAuditLogs) | **GET** /audit-logs | List Audit Logs + + +## `listAuditLogs()` + +```php +listAuditLogs($limit, $cursor): \Gr4vy\model\AuditLogs +``` + +List Audit Logs + +Returns a list of audit logs. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\AuditLogsApi( + // 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 +); +$limit = 1; // int | Defines the maximum number of items to return for this request. +$cursor = ZXhhbXBsZTE; // string | A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. + +try { + $result = $apiInstance->listAuditLogs($limit, $cursor); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling AuditLogsApi->listAuditLogs: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **limit** | **int**| Defines the maximum number of items to return for this request. | [optional] [default to 20] + **cursor** | **string**| A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. | [optional] + +### Return type + +[**\Gr4vy\model\AuditLogs**](../Model/AuditLogs.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) diff --git a/docs/Api/BuyersApi.md b/docs/Api/BuyersApi.md new file mode 100644 index 0000000..57d8301 --- /dev/null +++ b/docs/Api/BuyersApi.md @@ -0,0 +1,317 @@ +# Gr4vy\BuyersApi + +All URIs are relative to https://api.plantly.gr4vy.app. + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**addBuyer()**](BuyersApi.md#addBuyer) | **POST** /buyers | New buyer +[**deleteBuyer()**](BuyersApi.md#deleteBuyer) | **DELETE** /buyers/{buyer_id} | Delete buyer +[**getBuyer()**](BuyersApi.md#getBuyer) | **GET** /buyers/{buyer_id} | Get buyer +[**listBuyers()**](BuyersApi.md#listBuyers) | **GET** /buyers | List buyers +[**updateBuyer()**](BuyersApi.md#updateBuyer) | **PUT** /buyers/{buyer_id} | Update buyer + + +## `addBuyer()` + +```php +addBuyer($buyer_request): \Gr4vy\model\Buyer +``` + +New buyer + +Adds a buyer, allowing for payment methods and transactions to be associated to this buyer. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\BuyersApi( + // 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 +); +$buyer_request = {"external_identifier":"412231123","display_name":"John L."}; // \Gr4vy\model\BuyerRequest + +try { + $result = $apiInstance->addBuyer($buyer_request); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling BuyersApi->addBuyer: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **buyer_request** | [**\Gr4vy\model\BuyerRequest**](../Model/BuyerRequest.md)| | [optional] + +### Return type + +[**\Gr4vy\model\Buyer**](../Model/Buyer.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: `application/json` +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `deleteBuyer()` + +```php +deleteBuyer($buyer_id) +``` + +Delete buyer + +Deletes a buyer record. Any associated tokenized payment methods will remain in the system but no longer associated to the buyer. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\BuyersApi( + // 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 +); +$buyer_id = 8724fd24-5489-4a5d-90fd-0604df7d3b83; // string | The unique ID for a buyer. + +try { + $apiInstance->deleteBuyer($buyer_id); +} catch (Exception $e) { + echo 'Exception when calling BuyersApi->deleteBuyer: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **buyer_id** | **string**| The unique ID for a buyer. | + +### Return type + +void (empty response body) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `getBuyer()` + +```php +getBuyer($buyer_id): \Gr4vy\model\Buyer +``` + +Get buyer + +Gets the information about a buyer. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\BuyersApi( + // 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 +); +$buyer_id = 8724fd24-5489-4a5d-90fd-0604df7d3b83; // string | The unique ID for a buyer. + +try { + $result = $apiInstance->getBuyer($buyer_id); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling BuyersApi->getBuyer: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **buyer_id** | **string**| The unique ID for a buyer. | + +### Return type + +[**\Gr4vy\model\Buyer**](../Model/Buyer.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `listBuyers()` + +```php +listBuyers($search, $limit, $cursor): \Gr4vy\model\Buyers +``` + +List buyers + +Returns a list of buyers. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\BuyersApi( + // 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 +); +$search = John; // string | Filters the results to only the buyers for which the `display_name` or `external_identifier` matches this value. This field allows for a partial match, matching any buyer for which either of the fields partially or completely matches. +$limit = 1; // int | Defines the maximum number of items to return for this request. +$cursor = ZXhhbXBsZTE; // string | A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. + +try { + $result = $apiInstance->listBuyers($search, $limit, $cursor); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling BuyersApi->listBuyers: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **search** | **string**| Filters the results to only the buyers for which the `display_name` or `external_identifier` matches this value. This field allows for a partial match, matching any buyer for which either of the fields partially or completely matches. | [optional] + **limit** | **int**| Defines the maximum number of items to return for this request. | [optional] [default to 20] + **cursor** | **string**| A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. | [optional] + +### Return type + +[**\Gr4vy\model\Buyers**](../Model/Buyers.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `updateBuyer()` + +```php +updateBuyer($buyer_id, $buyer_update): \Gr4vy\model\Buyer +``` + +Update buyer + +Updates a buyer's details. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\BuyersApi( + // 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 +); +$buyer_id = 8724fd24-5489-4a5d-90fd-0604df7d3b83; // string | The unique ID for a buyer. +$buyer_update = {"external_identifier":"42623266","display_name":"John D."}; // \Gr4vy\model\BuyerUpdate + +try { + $result = $apiInstance->updateBuyer($buyer_id, $buyer_update); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling BuyersApi->updateBuyer: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **buyer_id** | **string**| The unique ID for a buyer. | + **buyer_update** | [**\Gr4vy\model\BuyerUpdate**](../Model/BuyerUpdate.md)| | [optional] + +### Return type + +[**\Gr4vy\model\Buyer**](../Model/Buyer.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: `application/json` +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) diff --git a/docs/Api/CardRulesApi.md b/docs/Api/CardRulesApi.md new file mode 100644 index 0000000..548d463 --- /dev/null +++ b/docs/Api/CardRulesApi.md @@ -0,0 +1,317 @@ +# Gr4vy\CardRulesApi + +All URIs are relative to https://api.plantly.gr4vy.app. + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**addCardRule()**](CardRulesApi.md#addCardRule) | **POST** /card-rules | Create card rule +[**deleteCardRule()**](CardRulesApi.md#deleteCardRule) | **DELETE** /card-rules/{card_rule_id} | Delete card rule +[**getCardRule()**](CardRulesApi.md#getCardRule) | **GET** /card-rules/{card_rule_id} | Get card rule +[**listCardsRules()**](CardRulesApi.md#listCardsRules) | **GET** /card-rules | List card rules +[**updateCardRule()**](CardRulesApi.md#updateCardRule) | **PUT** /card-rules/{card_rule_id} | Update card rule + + +## `addCardRule()` + +```php +addCardRule($card_rule_request): \Gr4vy\model\CardRule +``` + +Create card rule + +Creates a new rule that is used for card transactions. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\CardRulesApi( + // 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 +); +$card_rule_request = new \Gr4vy\model\CardRuleRequest(); // \Gr4vy\model\CardRuleRequest + +try { + $result = $apiInstance->addCardRule($card_rule_request); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling CardRulesApi->addCardRule: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **card_rule_request** | [**\Gr4vy\model\CardRuleRequest**](../Model/CardRuleRequest.md)| | [optional] + +### Return type + +[**\Gr4vy\model\CardRule**](../Model/CardRule.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: `application/json` +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `deleteCardRule()` + +```php +deleteCardRule($card_rule_id) +``` + +Delete card rule + +Deletes a specific card rule. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\CardRulesApi( + // 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 +); +$card_rule_id = 8724fd24-5489-4a5d-90fd-0604df7d3b83; // string | The unique ID for a card rule. + +try { + $apiInstance->deleteCardRule($card_rule_id); +} catch (Exception $e) { + echo 'Exception when calling CardRulesApi->deleteCardRule: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **card_rule_id** | [**string**](../Model/.md)| The unique ID for a card rule. | + +### Return type + +void (empty response body) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `getCardRule()` + +```php +getCardRule($card_rule_id): \Gr4vy\model\CardRule +``` + +Get card rule + +Returns a rule that can be used for card transactions. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\CardRulesApi( + // 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 +); +$card_rule_id = 8724fd24-5489-4a5d-90fd-0604df7d3b83; // string | The unique ID for a card rule. + +try { + $result = $apiInstance->getCardRule($card_rule_id); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling CardRulesApi->getCardRule: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **card_rule_id** | [**string**](../Model/.md)| The unique ID for a card rule. | + +### Return type + +[**\Gr4vy\model\CardRule**](../Model/CardRule.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `listCardsRules()` + +```php +listCardsRules($limit, $cursor, $environment): \Gr4vy\model\CardRules +``` + +List card rules + +Returns a list of rules for card transactions. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\CardRulesApi( + // 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 +); +$limit = 1; // int | Defines the maximum number of items to return for this request. +$cursor = ZXhhbXBsZTE; // string | A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. +$environment = staging; // string | Filters the results to only the items available in this environment. + +try { + $result = $apiInstance->listCardsRules($limit, $cursor, $environment); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling CardRulesApi->listCardsRules: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **limit** | **int**| Defines the maximum number of items to return for this request. | [optional] [default to 20] + **cursor** | **string**| A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. | [optional] + **environment** | **string**| Filters the results to only the items available in this environment. | [optional] [default to 'production'] + +### Return type + +[**\Gr4vy\model\CardRules**](../Model/CardRules.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `updateCardRule()` + +```php +updateCardRule($card_rule_id, $card_rule_update): \Gr4vy\model\CardRule +``` + +Update card rule + +Updates a rule that can be used for card transactions. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\CardRulesApi( + // 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 +); +$card_rule_id = 8724fd24-5489-4a5d-90fd-0604df7d3b83; // string | The unique ID for a card rule. +$card_rule_update = new \Gr4vy\model\CardRuleUpdate(); // \Gr4vy\model\CardRuleUpdate + +try { + $result = $apiInstance->updateCardRule($card_rule_id, $card_rule_update); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling CardRulesApi->updateCardRule: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **card_rule_id** | [**string**](../Model/.md)| The unique ID for a card rule. | + **card_rule_update** | [**\Gr4vy\model\CardRuleUpdate**](../Model/CardRuleUpdate.md)| | [optional] + +### Return type + +[**\Gr4vy\model\CardRule**](../Model/CardRule.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: `application/json` +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) diff --git a/docs/Api/CardSchemeDefinitionsApi.md b/docs/Api/CardSchemeDefinitionsApi.md new file mode 100644 index 0000000..24765f3 --- /dev/null +++ b/docs/Api/CardSchemeDefinitionsApi.md @@ -0,0 +1,65 @@ +# Gr4vy\CardSchemeDefinitionsApi + +All URIs are relative to https://api.plantly.gr4vy.app. + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**listCardSchemeDefinitions()**](CardSchemeDefinitionsApi.md#listCardSchemeDefinitions) | **GET** /card-scheme-definitions | List card scheme definitions + + +## `listCardSchemeDefinitions()` + +```php +listCardSchemeDefinitions(): \Gr4vy\model\CardSchemeDefinitions +``` + +List card scheme definitions + +Returns a list of all available card scheme definitions. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\CardSchemeDefinitionsApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); + +try { + $result = $apiInstance->listCardSchemeDefinitions(); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling CardSchemeDefinitionsApi->listCardSchemeDefinitions: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**\Gr4vy\model\CardSchemeDefinitions**](../Model/CardSchemeDefinitions.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) diff --git a/docs/Api/CheckoutSessionsApi.md b/docs/Api/CheckoutSessionsApi.md new file mode 100644 index 0000000..a3727e5 --- /dev/null +++ b/docs/Api/CheckoutSessionsApi.md @@ -0,0 +1,248 @@ +# Gr4vy\CheckoutSessionsApi + +All URIs are relative to https://api.plantly.gr4vy.app. + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**addCheckoutSession()**](CheckoutSessionsApi.md#addCheckoutSession) | **POST** /checkout/sessions | Create a new Checkout Session +[**deleteCheckoutSession()**](CheckoutSessionsApi.md#deleteCheckoutSession) | **DELETE** /checkout/sessions/{checkout_session_id} | Delete a Checkout Session +[**getCheckoutSession()**](CheckoutSessionsApi.md#getCheckoutSession) | **GET** /checkout/sessions/{checkout_session_id} | Get a Checkout Session +[**updateCheckoutSessionFields()**](CheckoutSessionsApi.md#updateCheckoutSessionFields) | **PUT** /checkout/sessions/{checkout_session_id}/fields | Update a Checkout Session's Secure Fields + + +## `addCheckoutSession()` + +```php +addCheckoutSession(): \Gr4vy\model\CheckoutSession +``` + +Create a new Checkout Session + +Creates a new Checkout Session. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\CheckoutSessionsApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); + +try { + $result = $apiInstance->addCheckoutSession(); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling CheckoutSessionsApi->addCheckoutSession: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**\Gr4vy\model\CheckoutSession**](../Model/CheckoutSession.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `deleteCheckoutSession()` + +```php +deleteCheckoutSession($checkout_session_id) +``` + +Delete a Checkout Session + +Deletes a Checkout Session. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\CheckoutSessionsApi( + // 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 +); +$checkout_session_id = 8724fd24-5489-4a5d-90fd-0604df7d3b83; // string | The unique ID for a Checkout Session. + +try { + $apiInstance->deleteCheckoutSession($checkout_session_id); +} catch (Exception $e) { + echo 'Exception when calling CheckoutSessionsApi->deleteCheckoutSession: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **checkout_session_id** | **string**| The unique ID for a Checkout Session. | + +### Return type + +void (empty response body) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `getCheckoutSession()` + +```php +getCheckoutSession($checkout_session_id): \Gr4vy\model\CheckoutSession +``` + +Get a Checkout Session + +Gets details about a current Checkout Session. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\CheckoutSessionsApi( + // 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 +); +$checkout_session_id = 8724fd24-5489-4a5d-90fd-0604df7d3b83; // string | The unique ID for a Checkout Session. + +try { + $result = $apiInstance->getCheckoutSession($checkout_session_id); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling CheckoutSessionsApi->getCheckoutSession: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **checkout_session_id** | **string**| The unique ID for a Checkout Session. | + +### Return type + +[**\Gr4vy\model\CheckoutSession**](../Model/CheckoutSession.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `updateCheckoutSessionFields()` + +```php +updateCheckoutSessionFields($checkout_session_id, $checkout_session_secure_fields_update) +``` + +Update a Checkout Session's Secure Fields + +Updates the Secure Fields of the Checkout Session. Once the fields have been received the `expires_at` will be updated to 5 minutes from the time of receipt. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\CheckoutSessionsApi( + // 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 +); +$checkout_session_id = 8724fd24-5489-4a5d-90fd-0604df7d3b83; // string | The unique ID for a Checkout Session. +$checkout_session_secure_fields_update = new \Gr4vy\model\CheckoutSessionSecureFieldsUpdate(); // \Gr4vy\model\CheckoutSessionSecureFieldsUpdate + +try { + $apiInstance->updateCheckoutSessionFields($checkout_session_id, $checkout_session_secure_fields_update); +} catch (Exception $e) { + echo 'Exception when calling CheckoutSessionsApi->updateCheckoutSessionFields: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **checkout_session_id** | **string**| The unique ID for a Checkout Session. | + **checkout_session_secure_fields_update** | [**\Gr4vy\model\CheckoutSessionSecureFieldsUpdate**](../Model/CheckoutSessionSecureFieldsUpdate.md)| | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: `application/json` +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) diff --git a/docs/Api/DigitalWalletsApi.md b/docs/Api/DigitalWalletsApi.md new file mode 100644 index 0000000..16867db --- /dev/null +++ b/docs/Api/DigitalWalletsApi.md @@ -0,0 +1,310 @@ +# Gr4vy\DigitalWalletsApi + +All URIs are relative to https://api.plantly.gr4vy.app. + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**deregisterDigitalWallet()**](DigitalWalletsApi.md#deregisterDigitalWallet) | **DELETE** /digital-wallets/{digital_wallet_id} | De-register digital wallet +[**getDigitalWallet()**](DigitalWalletsApi.md#getDigitalWallet) | **GET** /digital-wallets/{digital_wallet_id} | Get digital wallet +[**listDigitalWallets()**](DigitalWalletsApi.md#listDigitalWallets) | **GET** /digital-wallets | List digital wallets +[**registerDigitalWallet()**](DigitalWalletsApi.md#registerDigitalWallet) | **POST** /digital-wallets | Register digital wallet +[**updateDigitalWallet()**](DigitalWalletsApi.md#updateDigitalWallet) | **PUT** /digital-wallets/{digital_wallet_id} | Update digital wallet + + +## `deregisterDigitalWallet()` + +```php +deregisterDigitalWallet($digital_wallet_id) +``` + +De-register digital wallet + +De-registers a digital wallet with a provider. Upon successful de-registration, the digital wallet's record is deleted and will no longer be available. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\DigitalWalletsApi( + // 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 +); +$digital_wallet_id = fe26475d-ec3e-4884-9553-f7356683f7f9; // string | The ID of the registered digital wallet. + +try { + $apiInstance->deregisterDigitalWallet($digital_wallet_id); +} catch (Exception $e) { + echo 'Exception when calling DigitalWalletsApi->deregisterDigitalWallet: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **digital_wallet_id** | **string**| The ID of the registered digital wallet. | + +### Return type + +void (empty response body) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `getDigitalWallet()` + +```php +getDigitalWallet($digital_wallet_id): \Gr4vy\model\DigitalWallet +``` + +Get digital wallet + +Returns a registered digital wallet. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\DigitalWalletsApi( + // 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 +); +$digital_wallet_id = fe26475d-ec3e-4884-9553-f7356683f7f9; // string | The ID of the registered digital wallet. + +try { + $result = $apiInstance->getDigitalWallet($digital_wallet_id); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling DigitalWalletsApi->getDigitalWallet: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **digital_wallet_id** | **string**| The ID of the registered digital wallet. | + +### Return type + +[**\Gr4vy\model\DigitalWallet**](../Model/DigitalWallet.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `listDigitalWallets()` + +```php +listDigitalWallets(): \Gr4vy\model\DigitalWallets +``` + +List digital wallets + +Returns a list of all registered digital wallets. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\DigitalWalletsApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); + +try { + $result = $apiInstance->listDigitalWallets(); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling DigitalWalletsApi->listDigitalWallets: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**\Gr4vy\model\DigitalWallets**](../Model/DigitalWallets.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `registerDigitalWallet()` + +```php +registerDigitalWallet($digital_wallet_request): \Gr4vy\model\DigitalWallet +``` + +Register digital wallet + +Register with a digital wallet provider. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\DigitalWalletsApi( + // 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 +); +$digital_wallet_request = new \Gr4vy\model\DigitalWalletRequest(); // \Gr4vy\model\DigitalWalletRequest + +try { + $result = $apiInstance->registerDigitalWallet($digital_wallet_request); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling DigitalWalletsApi->registerDigitalWallet: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **digital_wallet_request** | [**\Gr4vy\model\DigitalWalletRequest**](../Model/DigitalWalletRequest.md)| | [optional] + +### Return type + +[**\Gr4vy\model\DigitalWallet**](../Model/DigitalWallet.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: `application/json` +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `updateDigitalWallet()` + +```php +updateDigitalWallet($digital_wallet_id, $digital_wallet_update): \Gr4vy\model\DigitalWallet +``` + +Update digital wallet + +Updates the values a digital wallet was registered with. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\DigitalWalletsApi( + // 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 +); +$digital_wallet_id = fe26475d-ec3e-4884-9553-f7356683f7f9; // string | The ID of the registered digital wallet. +$digital_wallet_update = new \Gr4vy\model\DigitalWalletUpdate(); // \Gr4vy\model\DigitalWalletUpdate + +try { + $result = $apiInstance->updateDigitalWallet($digital_wallet_id, $digital_wallet_update); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling DigitalWalletsApi->updateDigitalWallet: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **digital_wallet_id** | **string**| The ID of the registered digital wallet. | + **digital_wallet_update** | [**\Gr4vy\model\DigitalWalletUpdate**](../Model/DigitalWalletUpdate.md)| | [optional] + +### Return type + +[**\Gr4vy\model\DigitalWallet**](../Model/DigitalWallet.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: `application/json` +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) diff --git a/docs/Api/PaymentMethodDefinitionsApi.md b/docs/Api/PaymentMethodDefinitionsApi.md new file mode 100644 index 0000000..dfb4b3a --- /dev/null +++ b/docs/Api/PaymentMethodDefinitionsApi.md @@ -0,0 +1,65 @@ +# Gr4vy\PaymentMethodDefinitionsApi + +All URIs are relative to https://api.plantly.gr4vy.app. + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**listPaymentMethodDefinitions()**](PaymentMethodDefinitionsApi.md#listPaymentMethodDefinitions) | **GET** /payment-method-definitions | List payment method definitions + + +## `listPaymentMethodDefinitions()` + +```php +listPaymentMethodDefinitions(): \Gr4vy\model\PaymentMethodDefinitions +``` + +List payment method definitions + +Returns a list of all available payment method definitions. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\PaymentMethodDefinitionsApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); + +try { + $result = $apiInstance->listPaymentMethodDefinitions(); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling PaymentMethodDefinitionsApi->listPaymentMethodDefinitions: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**\Gr4vy\model\PaymentMethodDefinitions**](../Model/PaymentMethodDefinitions.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) diff --git a/docs/Api/PaymentMethodTokensApi.md b/docs/Api/PaymentMethodTokensApi.md new file mode 100644 index 0000000..43ee12e --- /dev/null +++ b/docs/Api/PaymentMethodTokensApi.md @@ -0,0 +1,68 @@ +# Gr4vy\PaymentMethodTokensApi + +All URIs are relative to https://api.plantly.gr4vy.app. + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**listPaymentMethodTokens()**](PaymentMethodTokensApi.md#listPaymentMethodTokens) | **GET** /payment-methods/{payment_method_id}/tokens | List payment method tokens + + +## `listPaymentMethodTokens()` + +```php +listPaymentMethodTokens($payment_method_id): \Gr4vy\model\PaymentMethodTokens +``` + +List payment method tokens + +Returns a list of PSP tokens for a given payment method. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\PaymentMethodTokensApi( + // 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 +); +$payment_method_id = 46973e9d-88a7-44a6-abfe-be4ff0134ff4; // string | The ID of the payment method. + +try { + $result = $apiInstance->listPaymentMethodTokens($payment_method_id); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling PaymentMethodTokensApi->listPaymentMethodTokens: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **payment_method_id** | **string**| The ID of the payment method. | + +### Return type + +[**\Gr4vy\model\PaymentMethodTokens**](../Model/PaymentMethodTokens.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) diff --git a/docs/Api/PaymentMethodsApi.md b/docs/Api/PaymentMethodsApi.md new file mode 100644 index 0000000..996d8b4 --- /dev/null +++ b/docs/Api/PaymentMethodsApi.md @@ -0,0 +1,325 @@ +# Gr4vy\PaymentMethodsApi + +All URIs are relative to https://api.plantly.gr4vy.app. + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**deletePaymentMethod()**](PaymentMethodsApi.md#deletePaymentMethod) | **DELETE** /payment-methods/{payment_method_id} | Delete payment method +[**getPaymentMethod()**](PaymentMethodsApi.md#getPaymentMethod) | **GET** /payment-methods/{payment_method_id} | Get stored payment method +[**listBuyerPaymentMethods()**](PaymentMethodsApi.md#listBuyerPaymentMethods) | **GET** /buyers/payment-methods | List stored payment methods for a buyer +[**listPaymentMethods()**](PaymentMethodsApi.md#listPaymentMethods) | **GET** /payment-methods | List payment methods +[**storePaymentMethod()**](PaymentMethodsApi.md#storePaymentMethod) | **POST** /payment-methods | New payment method + + +## `deletePaymentMethod()` + +```php +deletePaymentMethod($payment_method_id) +``` + +Delete payment method + +Removes a stored payment method. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\PaymentMethodsApi( + // 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 +); +$payment_method_id = 46973e9d-88a7-44a6-abfe-be4ff0134ff4; // string | The ID of the payment method. + +try { + $apiInstance->deletePaymentMethod($payment_method_id); +} catch (Exception $e) { + echo 'Exception when calling PaymentMethodsApi->deletePaymentMethod: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **payment_method_id** | **string**| The ID of the payment method. | + +### Return type + +void (empty response body) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `getPaymentMethod()` + +```php +getPaymentMethod($payment_method_id): \Gr4vy\model\PaymentMethod +``` + +Get stored payment method + +Gets the details for a stored payment method. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\PaymentMethodsApi( + // 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 +); +$payment_method_id = 46973e9d-88a7-44a6-abfe-be4ff0134ff4; // string | The ID of the payment method. + +try { + $result = $apiInstance->getPaymentMethod($payment_method_id); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling PaymentMethodsApi->getPaymentMethod: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **payment_method_id** | **string**| The ID of the payment method. | + +### Return type + +[**\Gr4vy\model\PaymentMethod**](../Model/PaymentMethod.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `listBuyerPaymentMethods()` + +```php +listBuyerPaymentMethods($buyer_id, $buyer_external_identifier, $country, $currency): \Gr4vy\model\PaymentMethodsTokenized +``` + +List stored payment methods for a buyer + +Returns a list of stored (tokenized) payment methods for a buyer in a short tokenized format. Only payment methods that are compatible with at least one active payment service in that region are shown. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\PaymentMethodsApi( + // 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 +); +$buyer_id = 8724fd24-5489-4a5d-90fd-0604df7d3b83; // string | Filters the results to only the items for which the `buyer` has an `id` that matches this value. +$buyer_external_identifier = user-12345; // string | Filters the results to only the items for which the `buyer` has an `external_identifier` that matches this value. +$country = US; // string | Filters the results to only the items which support this country code. A country is formatted as 2-letter ISO country code. +$currency = USD; // string | Filters the results to only the items which support this currency code. A currency is formatted as 3-letter ISO currency code. + +try { + $result = $apiInstance->listBuyerPaymentMethods($buyer_id, $buyer_external_identifier, $country, $currency); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling PaymentMethodsApi->listBuyerPaymentMethods: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **buyer_id** | **string**| Filters the results to only the items for which the `buyer` has an `id` that matches this value. | [optional] + **buyer_external_identifier** | **string**| Filters the results to only the items for which the `buyer` has an `external_identifier` that matches this value. | [optional] + **country** | **string**| Filters the results to only the items which support this country code. A country is formatted as 2-letter ISO country code. | [optional] + **currency** | **string**| Filters the results to only the items which support this currency code. A currency is formatted as 3-letter ISO currency code. | [optional] + +### Return type + +[**\Gr4vy\model\PaymentMethodsTokenized**](../Model/PaymentMethodsTokenized.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `listPaymentMethods()` + +```php +listPaymentMethods($buyer_id, $buyer_external_identifier, $status, $limit, $cursor): \Gr4vy\model\PaymentMethods +``` + +List payment methods + +Returns a list of stored (tokenized) payment methods. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\PaymentMethodsApi( + // 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 +); +$buyer_id = 8724fd24-5489-4a5d-90fd-0604df7d3b83; // string | Filters the results to only the items for which the `buyer` has an `id` that matches this value. +$buyer_external_identifier = user-12345; // string | Filters the results to only the items for which the `buyer` has an `external_identifier` that matches this value. +$status = succeeded; // string | Filters the results to only the payment methods for which the `status` matches this value. +$limit = 1; // int | Defines the maximum number of items to return for this request. +$cursor = ZXhhbXBsZTE; // string | A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. + +try { + $result = $apiInstance->listPaymentMethods($buyer_id, $buyer_external_identifier, $status, $limit, $cursor); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling PaymentMethodsApi->listPaymentMethods: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **buyer_id** | **string**| Filters the results to only the items for which the `buyer` has an `id` that matches this value. | [optional] + **buyer_external_identifier** | **string**| Filters the results to only the items for which the `buyer` has an `external_identifier` that matches this value. | [optional] + **status** | **string**| Filters the results to only the payment methods for which the `status` matches this value. | [optional] + **limit** | **int**| Defines the maximum number of items to return for this request. | [optional] [default to 20] + **cursor** | **string**| A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. | [optional] + +### Return type + +[**\Gr4vy\model\PaymentMethods**](../Model/PaymentMethods.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `storePaymentMethod()` + +```php +storePaymentMethod($payment_method_request): \Gr4vy\model\PaymentMethod +``` + +New payment method + +Stores and tokenizes a new payment method. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\PaymentMethodsApi( + // 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 +); +$payment_method_request = new \Gr4vy\model\PaymentMethodRequest(); // \Gr4vy\model\PaymentMethodRequest + +try { + $result = $apiInstance->storePaymentMethod($payment_method_request); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling PaymentMethodsApi->storePaymentMethod: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **payment_method_request** | [**\Gr4vy\model\PaymentMethodRequest**](../Model/PaymentMethodRequest.md)| | [optional] + +### Return type + +[**\Gr4vy\model\PaymentMethod**](../Model/PaymentMethod.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: `application/json` +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) diff --git a/docs/Api/PaymentOptionsApi.md b/docs/Api/PaymentOptionsApi.md new file mode 100644 index 0000000..9e459ac --- /dev/null +++ b/docs/Api/PaymentOptionsApi.md @@ -0,0 +1,76 @@ +# Gr4vy\PaymentOptionsApi + +All URIs are relative to https://api.plantly.gr4vy.app. + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**listPaymentOptions()**](PaymentOptionsApi.md#listPaymentOptions) | **GET** /payment-options | List payment options + + +## `listPaymentOptions()` + +```php +listPaymentOptions($country, $currency, $amount, $metadata, $locale): \Gr4vy\model\PaymentOptions +``` + +List payment options + +Returns a list of available payment method options for a currency and country. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\PaymentOptionsApi( + // 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 +); +$country = US; // string | Filters the results to only the items which support this country code. A country is formatted as 2-letter ISO country code. +$currency = USD; // string | Filters the results to only the items which support this currency code. A currency is formatted as 3-letter ISO currency code. +$amount = 500; // int | Used by the Flow engine to filter the results based on the transaction amount. +$metadata = {"restricted_items": "True"}; // string | Used by the Flow engine to filter available options based on various client-defined parameters. If present, this must be a string representing a valid JSON dictionary. +$locale = en-US; // string | An ISO 639-1 Language Code and optional ISO 3166 Country Code. This locale determines the language for the labels returned for every payment option. + +try { + $result = $apiInstance->listPaymentOptions($country, $currency, $amount, $metadata, $locale); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling PaymentOptionsApi->listPaymentOptions: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **country** | **string**| Filters the results to only the items which support this country code. A country is formatted as 2-letter ISO country code. | [optional] + **currency** | **string**| Filters the results to only the items which support this currency code. A currency is formatted as 3-letter ISO currency code. | [optional] + **amount** | **int**| Used by the Flow engine to filter the results based on the transaction amount. | [optional] + **metadata** | **string**| Used by the Flow engine to filter available options based on various client-defined parameters. If present, this must be a string representing a valid JSON dictionary. | [optional] + **locale** | **string**| An ISO 639-1 Language Code and optional ISO 3166 Country Code. This locale determines the language for the labels returned for every payment option. | [optional] [default to 'en-US'] + +### Return type + +[**\Gr4vy\model\PaymentOptions**](../Model/PaymentOptions.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) diff --git a/docs/Api/PaymentServiceDefinitionsApi.md b/docs/Api/PaymentServiceDefinitionsApi.md new file mode 100644 index 0000000..f3d7de4 --- /dev/null +++ b/docs/Api/PaymentServiceDefinitionsApi.md @@ -0,0 +1,131 @@ +# Gr4vy\PaymentServiceDefinitionsApi + +All URIs are relative to https://api.plantly.gr4vy.app. + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**getPaymentServiceDefinition()**](PaymentServiceDefinitionsApi.md#getPaymentServiceDefinition) | **GET** /payment-service-definitions/{payment_service_definition_id} | Get payment service definition +[**listPaymentServiceDefinitions()**](PaymentServiceDefinitionsApi.md#listPaymentServiceDefinitions) | **GET** /payment-service-definitions | List payment service definitions + + +## `getPaymentServiceDefinition()` + +```php +getPaymentServiceDefinition($payment_service_definition_id): \Gr4vy\model\PaymentServiceDefinition +``` + +Get payment service definition + +Gets the definition for a payment service. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\PaymentServiceDefinitionsApi( + // 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 +); +$payment_service_definition_id = stripe-card; // string | The unique ID of the payment service definition. + +try { + $result = $apiInstance->getPaymentServiceDefinition($payment_service_definition_id); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling PaymentServiceDefinitionsApi->getPaymentServiceDefinition: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **payment_service_definition_id** | **string**| The unique ID of the payment service definition. | + +### Return type + +[**\Gr4vy\model\PaymentServiceDefinition**](../Model/PaymentServiceDefinition.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `listPaymentServiceDefinitions()` + +```php +listPaymentServiceDefinitions($limit, $cursor): \Gr4vy\model\PaymentServiceDefinitions +``` + +List payment service definitions + +Returns a list of all available payment service definitions. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\PaymentServiceDefinitionsApi( + // 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 +); +$limit = 1; // int | Defines the maximum number of items to return for this request. +$cursor = ZXhhbXBsZTE; // string | A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. + +try { + $result = $apiInstance->listPaymentServiceDefinitions($limit, $cursor); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling PaymentServiceDefinitionsApi->listPaymentServiceDefinitions: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **limit** | **int**| Defines the maximum number of items to return for this request. | [optional] [default to 20] + **cursor** | **string**| A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. | [optional] + +### Return type + +[**\Gr4vy\model\PaymentServiceDefinitions**](../Model/PaymentServiceDefinitions.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) diff --git a/docs/Api/PaymentServicesApi.md b/docs/Api/PaymentServicesApi.md new file mode 100644 index 0000000..832fdd4 --- /dev/null +++ b/docs/Api/PaymentServicesApi.md @@ -0,0 +1,319 @@ +# Gr4vy\PaymentServicesApi + +All URIs are relative to https://api.plantly.gr4vy.app. + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**addPaymentService()**](PaymentServicesApi.md#addPaymentService) | **POST** /payment-services | New payment service +[**deletePaymentService()**](PaymentServicesApi.md#deletePaymentService) | **DELETE** /payment-services/{payment_service_id} | Delete payment service +[**getPaymentService()**](PaymentServicesApi.md#getPaymentService) | **GET** /payment-services/{payment_service_id} | Get payment service +[**listPaymentServices()**](PaymentServicesApi.md#listPaymentServices) | **GET** /payment-services | List payment services +[**updatePaymentService()**](PaymentServicesApi.md#updatePaymentService) | **PUT** /payment-services/{payment_service_id} | Update payment service + + +## `addPaymentService()` + +```php +addPaymentService($payment_service_request): \Gr4vy\model\PaymentService +``` + +New payment service + +Adds a new payment service by providing a custom name and a value for each of the required fields. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\PaymentServicesApi( + // 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 +); +$payment_service_request = new \Gr4vy\model\PaymentServiceRequest(); // \Gr4vy\model\PaymentServiceRequest + +try { + $result = $apiInstance->addPaymentService($payment_service_request); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling PaymentServicesApi->addPaymentService: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **payment_service_request** | [**\Gr4vy\model\PaymentServiceRequest**](../Model/PaymentServiceRequest.md)| | [optional] + +### Return type + +[**\Gr4vy\model\PaymentService**](../Model/PaymentService.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: `application/json` +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `deletePaymentService()` + +```php +deletePaymentService($payment_service_id) +``` + +Delete payment service + +Deletes a specific active payment service. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\PaymentServicesApi( + // 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 +); +$payment_service_id = 46973e9d-88a7-44a6-abfe-be4ff0134ff4; // string | The ID of the payment service. + +try { + $apiInstance->deletePaymentService($payment_service_id); +} catch (Exception $e) { + echo 'Exception when calling PaymentServicesApi->deletePaymentService: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **payment_service_id** | **string**| The ID of the payment service. | + +### Return type + +void (empty response body) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `getPaymentService()` + +```php +getPaymentService($payment_service_id): \Gr4vy\model\PaymentService +``` + +Get payment service + +Retrieves the details of a single configured payment service. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\PaymentServicesApi( + // 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 +); +$payment_service_id = 46973e9d-88a7-44a6-abfe-be4ff0134ff4; // string | The ID of the payment service. + +try { + $result = $apiInstance->getPaymentService($payment_service_id); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling PaymentServicesApi->getPaymentService: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **payment_service_id** | **string**| The ID of the payment service. | + +### Return type + +[**\Gr4vy\model\PaymentService**](../Model/PaymentService.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `listPaymentServices()` + +```php +listPaymentServices($limit, $cursor, $method, $deleted): \Gr4vy\model\PaymentServices +``` + +List payment services + +Lists the currently configured and activated payment services. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\PaymentServicesApi( + // 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 +); +$limit = 1; // int | Defines the maximum number of items to return for this request. +$cursor = ZXhhbXBsZTE; // string | A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. +$method = card; // string | Filters the results to only the items for which the `method` has been set to this value. +$deleted = true; // bool | Filters the results to only show items which have been deleted. By default, deleted items will not be returned. + +try { + $result = $apiInstance->listPaymentServices($limit, $cursor, $method, $deleted); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling PaymentServicesApi->listPaymentServices: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **limit** | **int**| Defines the maximum number of items to return for this request. | [optional] [default to 20] + **cursor** | **string**| A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. | [optional] + **method** | **string**| Filters the results to only the items for which the `method` has been set to this value. | [optional] + **deleted** | **bool**| Filters the results to only show items which have been deleted. By default, deleted items will not be returned. | [optional] [default to false] + +### Return type + +[**\Gr4vy\model\PaymentServices**](../Model/PaymentServices.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `updatePaymentService()` + +```php +updatePaymentService($payment_service_id, $payment_service_update): \Gr4vy\model\PaymentService +``` + +Update payment service + +Updates an existing payment service. Allows all fields to be changed except for the service ID. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\PaymentServicesApi( + // 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 +); +$payment_service_id = 46973e9d-88a7-44a6-abfe-be4ff0134ff4; // string | The ID of the payment service. +$payment_service_update = new \Gr4vy\model\PaymentServiceUpdate(); // \Gr4vy\model\PaymentServiceUpdate + +try { + $result = $apiInstance->updatePaymentService($payment_service_id, $payment_service_update); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling PaymentServicesApi->updatePaymentService: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **payment_service_id** | **string**| The ID of the payment service. | + **payment_service_update** | [**\Gr4vy\model\PaymentServiceUpdate**](../Model/PaymentServiceUpdate.md)| | [optional] + +### Return type + +[**\Gr4vy\model\PaymentService**](../Model/PaymentService.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: `application/json` +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) diff --git a/docs/Api/TransactionsApi.md b/docs/Api/TransactionsApi.md new file mode 100644 index 0000000..927bc1c --- /dev/null +++ b/docs/Api/TransactionsApi.md @@ -0,0 +1,555 @@ +# Gr4vy\TransactionsApi + +All URIs are relative to https://api.plantly.gr4vy.app. + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**authorizeNewTransaction()**](TransactionsApi.md#authorizeNewTransaction) | **POST** /transactions | New transaction +[**captureTransaction()**](TransactionsApi.md#captureTransaction) | **POST** /transactions/{transaction_id}/capture | Capture transaction +[**getTransaction()**](TransactionsApi.md#getTransaction) | **GET** /transactions/{transaction_id} | Get transaction +[**getTransactionRefund()**](TransactionsApi.md#getTransactionRefund) | **GET** /transactions/{transaction_id}/refunds/{refund_id} | Get transaction refund +[**listTransactionRefunds()**](TransactionsApi.md#listTransactionRefunds) | **GET** /transactions/{transaction_id}/refunds | List transaction refunds +[**listTransactions()**](TransactionsApi.md#listTransactions) | **GET** /transactions | List transactions +[**refundTransaction()**](TransactionsApi.md#refundTransaction) | **POST** /transactions/{transaction_id}/refunds | Refund transaction +[**voidTransaction()**](TransactionsApi.md#voidTransaction) | **POST** /transactions/{transaction_id}/void | Void transaction + + +## `authorizeNewTransaction()` + +```php +authorizeNewTransaction($transaction_request): \Gr4vy\model\Transaction +``` + +New transaction + +Attempts to create an authorization for a payment method. In some cases it is not possible to create the authorization without redirecting the user for their authorization. In these cases the status is set to `buyer_approval_pending` and an `approval_url` is returned. Additionally, this endpoint accepts a few additional fields that allow for simultaneous capturing and storage of the payment method. * `store` - Use this field to store the payment method for future use. Not all payment methods support this feature. * `capture` - Use this method to also perform a capture of the transaction after it has been authorized. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\TransactionsApi( + // 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 +); +$transaction_request = {"amount":1299,"currency":"USD","payment_method":{"method":"card","number":"4111111111111111","expiration_date":"11/25","security_code":"123","redirect_url":"https://example.com/callback"}}; // \Gr4vy\model\TransactionRequest + +try { + $result = $apiInstance->authorizeNewTransaction($transaction_request); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling TransactionsApi->authorizeNewTransaction: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **transaction_request** | [**\Gr4vy\model\TransactionRequest**](../Model/TransactionRequest.md)| | [optional] + +### Return type + +[**\Gr4vy\model\Transaction**](../Model/Transaction.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: `application/json` +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `captureTransaction()` + +```php +captureTransaction($transaction_id, $transaction_capture_request): \Gr4vy\model\Transaction +``` + +Capture transaction + +Captures a previously authorized transaction. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\TransactionsApi( + // 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 +); +$transaction_id = fe26475d-ec3e-4884-9553-f7356683f7f9; // string | The ID for the transaction to get the information for. +$transaction_capture_request = {"amount":1299}; // \Gr4vy\model\TransactionCaptureRequest + +try { + $result = $apiInstance->captureTransaction($transaction_id, $transaction_capture_request); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling TransactionsApi->captureTransaction: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **transaction_id** | **string**| The ID for the transaction to get the information for. | + **transaction_capture_request** | [**\Gr4vy\model\TransactionCaptureRequest**](../Model/TransactionCaptureRequest.md)| | [optional] + +### Return type + +[**\Gr4vy\model\Transaction**](../Model/Transaction.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: `application/json` +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `getTransaction()` + +```php +getTransaction($transaction_id): \Gr4vy\model\Transaction +``` + +Get transaction + +Get information about a transaction. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\TransactionsApi( + // 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 +); +$transaction_id = fe26475d-ec3e-4884-9553-f7356683f7f9; // string | The ID for the transaction to get the information for. + +try { + $result = $apiInstance->getTransaction($transaction_id); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling TransactionsApi->getTransaction: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **transaction_id** | **string**| The ID for the transaction to get the information for. | + +### Return type + +[**\Gr4vy\model\Transaction**](../Model/Transaction.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `getTransactionRefund()` + +```php +getTransactionRefund($transaction_id, $refund_id): \Gr4vy\model\Refund +``` + +Get transaction refund + +Gets information about a refund associated with a certain transaction. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\TransactionsApi( + // 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 +); +$transaction_id = fe26475d-ec3e-4884-9553-f7356683f7f9; // string | The ID for the transaction to get the information for. +$refund_id = 8724fd24-5489-4a5d-90fd-0604df7d3b83; // string | The unique ID of the refund. + +try { + $result = $apiInstance->getTransactionRefund($transaction_id, $refund_id); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling TransactionsApi->getTransactionRefund: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **transaction_id** | **string**| The ID for the transaction to get the information for. | + **refund_id** | **string**| The unique ID of the refund. | + +### Return type + +[**\Gr4vy\model\Refund**](../Model/Refund.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `listTransactionRefunds()` + +```php +listTransactionRefunds($transaction_id, $limit, $cursor): \Gr4vy\model\Refunds +``` + +List transaction refunds + +Lists all refunds associated with a certain transaction. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\TransactionsApi( + // 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 +); +$transaction_id = fe26475d-ec3e-4884-9553-f7356683f7f9; // string | The ID for the transaction to get the information for. +$limit = 1; // int | Defines the maximum number of items to return for this request. +$cursor = ZXhhbXBsZTE; // string | A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. + +try { + $result = $apiInstance->listTransactionRefunds($transaction_id, $limit, $cursor); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling TransactionsApi->listTransactionRefunds: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **transaction_id** | **string**| The ID for the transaction to get the information for. | + **limit** | **int**| Defines the maximum number of items to return for this request. | [optional] [default to 20] + **cursor** | **string**| A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. | [optional] + +### Return type + +[**\Gr4vy\model\Refunds**](../Model/Refunds.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `listTransactions()` + +```php +listTransactions($buyer_external_identifier, $buyer_id, $cursor, $limit, $amount_eq, $amount_gte, $amount_lte, $created_at_gte, $created_at_lte, $currency, $external_identifier, $has_refunds, $id, $metadata, $method, $payment_service_id, $payment_service_transaction_id, $search, $status, $updated_at_gte, $updated_at_lte, $before_created_at, $after_created_at, $before_updated_at, $after_updated_at, $transaction_status): \Gr4vy\model\Transactions +``` + +List transactions + +Lists all transactions for an account. Sorted by last `updated_at` status. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\TransactionsApi( + // 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 +); +$buyer_external_identifier = user-12345; // string | Filters the results to only the items for which the `buyer` has an `external_identifier` that matches this value. +$buyer_id = 8724fd24-5489-4a5d-90fd-0604df7d3b83; // string | Filters the results to only the items for which the `buyer` has an `id` that matches this value. +$cursor = ZXhhbXBsZTE; // string | A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. +$limit = 1; // int | Defines the maximum number of items to return for this request. +$amount_eq = 500; // int | Filters for transactions that have an `amount` that is equal to the provided `amount_eq` value. +$amount_gte = 500; // int | Filters for transactions that have an `amount` that is greater than or equal to the `amount_gte` value. +$amount_lte = 500; // int | Filters for transactions that have an `amount` that is less than or equal to the `amount_lte` value. +$created_at_gte = new \DateTime("2013-10-20T19:20:30+01:00"); // \DateTime | Filters the results to only transactions created after this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. +$created_at_lte = new \DateTime("2013-10-20T19:20:30+01:00"); // \DateTime | Filters the results to only transactions created before this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. +$currency = ["USD","GBP"]; // string[] | Filters for transactions that have matching `currency` values. The `currency` values provided must be formatted as 3-letter ISO currency code. +$external_identifier = user-12345; // string | Filters the results to only the items for which the `external_identifier` matches this value. +$has_refunds = true; // bool | When set to `true`, filter for transactions that have at least one refund in any state associated with it. When set to `false`, filter for transactions that have no refunds. +$id = be828248-56de-481e-a580-44b6e1d4df81; // string | Filters for the transaction that has a matching `id` value. +$metadata = ["{\"key\": \"value\"}","{\"key_one\": \"value\", \"key_two\": \"value\"}"]; // string[] | Filters for transactions where their `metadata` values contain all of the provided `metadata` keys. The value sent for `metadata` must be formatted as a JSON string, and all keys and values must be strings. This value should also be URL encoded. Duplicate keys are not supported. If a key is duplicated, only the last appearing value will be used. +$method = array('method_example'); // string[] | Filters the results to only the items for which the `method` has been set to this value. +$payment_service_id = ["46973e9d-88a7-44a6-abfe-be4ff0134ff4"]; // string[] | Filters for transactions that were processed by the provided `payment_service_id` values. +$payment_service_transaction_id = transaction_123; // string | Filters for transactions that have a matching `payment_service_transaction_id` value. The `payment_service_transaction_id` is the identifier of the transaction given by the payment service. +$search = be828248-56de-481e-a580-44b6e1d4df81; // string | Filters for transactions that have one of the following fields match exactly with the provided `search` value: * `buyer_external_identifier` * `buyer_id` * `external_identifier` * `id` * `payment_service_transaction_id` +$status = ["capture_succeeded","processing"]; // string[] | Filters the results to only the transactions that have a `status` that matches with any of the provided status values. +$updated_at_gte = new \DateTime("2013-10-20T19:20:30+01:00"); // \DateTime | Filters the results to only transactions last updated after this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. +$updated_at_lte = new \DateTime("2013-10-20T19:20:30+01:00"); // \DateTime | Filters the results to only transactions last updated before this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. +$before_created_at = new \DateTime("2013-10-20T19:20:30+01:00"); // \DateTime | Filters the results to only transactions created before this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. **WARNING** This filter is deprecated and may be removed eventually, use `created_at_lte` instead. +$after_created_at = new \DateTime("2013-10-20T19:20:30+01:00"); // \DateTime | Filters the results to only transactions created after this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. **WARNING** This filter is deprecated and may be removed eventually, use `created_at_gte` instead. +$before_updated_at = new \DateTime("2013-10-20T19:20:30+01:00"); // \DateTime | Filters the results to only transactions last updated before this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. **WARNING** This filter is deprecated and may be removed eventually, use `updated_at_lte` instead. +$after_updated_at = new \DateTime("2013-10-20T19:20:30+01:00"); // \DateTime | Filters the results to only transactions last updated after this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. **WARNING** This filter is deprecated and may be removed eventually, use `updated_at_gte` instead. +$transaction_status = capture_succeeded; // string | Filters the results to only the transactions for which the `status` matches this value. **WARNING** This filter is deprecated and may be removed eventually, use `status` instead. + +try { + $result = $apiInstance->listTransactions($buyer_external_identifier, $buyer_id, $cursor, $limit, $amount_eq, $amount_gte, $amount_lte, $created_at_gte, $created_at_lte, $currency, $external_identifier, $has_refunds, $id, $metadata, $method, $payment_service_id, $payment_service_transaction_id, $search, $status, $updated_at_gte, $updated_at_lte, $before_created_at, $after_created_at, $before_updated_at, $after_updated_at, $transaction_status); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling TransactionsApi->listTransactions: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **buyer_external_identifier** | **string**| Filters the results to only the items for which the `buyer` has an `external_identifier` that matches this value. | [optional] + **buyer_id** | **string**| Filters the results to only the items for which the `buyer` has an `id` that matches this value. | [optional] + **cursor** | **string**| A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. | [optional] + **limit** | **int**| Defines the maximum number of items to return for this request. | [optional] [default to 20] + **amount_eq** | **int**| Filters for transactions that have an `amount` that is equal to the provided `amount_eq` value. | [optional] + **amount_gte** | **int**| Filters for transactions that have an `amount` that is greater than or equal to the `amount_gte` value. | [optional] + **amount_lte** | **int**| Filters for transactions that have an `amount` that is less than or equal to the `amount_lte` value. | [optional] + **created_at_gte** | **\DateTime**| Filters the results to only transactions created after this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. | [optional] + **created_at_lte** | **\DateTime**| Filters the results to only transactions created before this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. | [optional] + **currency** | [**string[]**](../Model/string.md)| Filters for transactions that have matching `currency` values. The `currency` values provided must be formatted as 3-letter ISO currency code. | [optional] + **external_identifier** | **string**| Filters the results to only the items for which the `external_identifier` matches this value. | [optional] + **has_refunds** | **bool**| When set to `true`, filter for transactions that have at least one refund in any state associated with it. When set to `false`, filter for transactions that have no refunds. | [optional] + **id** | **string**| Filters for the transaction that has a matching `id` value. | [optional] + **metadata** | [**string[]**](../Model/string.md)| Filters for transactions where their `metadata` values contain all of the provided `metadata` keys. The value sent for `metadata` must be formatted as a JSON string, and all keys and values must be strings. This value should also be URL encoded. Duplicate keys are not supported. If a key is duplicated, only the last appearing value will be used. | [optional] + **method** | [**string[]**](../Model/string.md)| Filters the results to only the items for which the `method` has been set to this value. | [optional] + **payment_service_id** | [**string[]**](../Model/string.md)| Filters for transactions that were processed by the provided `payment_service_id` values. | [optional] + **payment_service_transaction_id** | **string**| Filters for transactions that have a matching `payment_service_transaction_id` value. The `payment_service_transaction_id` is the identifier of the transaction given by the payment service. | [optional] + **search** | **string**| Filters for transactions that have one of the following fields match exactly with the provided `search` value: * `buyer_external_identifier` * `buyer_id` * `external_identifier` * `id` * `payment_service_transaction_id` | [optional] + **status** | [**string[]**](../Model/string.md)| Filters the results to only the transactions that have a `status` that matches with any of the provided status values. | [optional] + **updated_at_gte** | **\DateTime**| Filters the results to only transactions last updated after this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. | [optional] + **updated_at_lte** | **\DateTime**| Filters the results to only transactions last updated before this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. | [optional] + **before_created_at** | **\DateTime**| Filters the results to only transactions created before this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. **WARNING** This filter is deprecated and may be removed eventually, use `created_at_lte` instead. | [optional] + **after_created_at** | **\DateTime**| Filters the results to only transactions created after this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. **WARNING** This filter is deprecated and may be removed eventually, use `created_at_gte` instead. | [optional] + **before_updated_at** | **\DateTime**| Filters the results to only transactions last updated before this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. **WARNING** This filter is deprecated and may be removed eventually, use `updated_at_lte` instead. | [optional] + **after_updated_at** | **\DateTime**| Filters the results to only transactions last updated after this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. **WARNING** This filter is deprecated and may be removed eventually, use `updated_at_gte` instead. | [optional] + **transaction_status** | **string**| Filters the results to only the transactions for which the `status` matches this value. **WARNING** This filter is deprecated and may be removed eventually, use `status` instead. | [optional] + +### Return type + +[**\Gr4vy\model\Transactions**](../Model/Transactions.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `refundTransaction()` + +```php +refundTransaction($transaction_id, $transaction_refund_request): \Gr4vy\model\Refund +``` + +Refund transaction + +Refunds a transaction, fully or partially. If the transaction was not yet successfully captured, the refund will not be processed. Authorized transactions can be [voided](#operation/void-transaction) instead. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\TransactionsApi( + // 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 +); +$transaction_id = fe26475d-ec3e-4884-9553-f7356683f7f9; // string | The ID for the transaction to get the information for. +$transaction_refund_request = {}; // \Gr4vy\model\TransactionRefundRequest + +try { + $result = $apiInstance->refundTransaction($transaction_id, $transaction_refund_request); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling TransactionsApi->refundTransaction: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **transaction_id** | **string**| The ID for the transaction to get the information for. | + **transaction_refund_request** | [**\Gr4vy\model\TransactionRefundRequest**](../Model/TransactionRefundRequest.md)| | [optional] + +### Return type + +[**\Gr4vy\model\Refund**](../Model/Refund.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: `application/json` +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `voidTransaction()` + +```php +voidTransaction($transaction_id): \Gr4vy\model\Transaction +``` + +Void transaction + +Voids a transaction. If the transaction was not yet successfully authorized, or was already captured, the void will not be processed. Captured transactions can be [refunded](#operation/refund-transaction) instead. Voiding zero-amount authorized transactions is not supported. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\TransactionsApi( + // 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 +); +$transaction_id = fe26475d-ec3e-4884-9553-f7356683f7f9; // string | The ID for the transaction to get the information for. + +try { + $result = $apiInstance->voidTransaction($transaction_id); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling TransactionsApi->voidTransaction: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **transaction_id** | **string**| The ID for the transaction to get the information for. | + +### Return type + +[**\Gr4vy\model\Transaction**](../Model/Transaction.md) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) diff --git a/docs/Api/UsersApi.md b/docs/Api/UsersApi.md new file mode 100644 index 0000000..94b5d3f --- /dev/null +++ b/docs/Api/UsersApi.md @@ -0,0 +1,67 @@ +# Gr4vy\UsersApi + +All URIs are relative to https://api.plantly.gr4vy.app. + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**deleteUser()**](UsersApi.md#deleteUser) | **DELETE** /users/{user_id} | Delete user + + +## `deleteUser()` + +```php +deleteUser($user_id) +``` + +Delete user + +Deletes a user record. Any associated sessions will also be deleted. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Gr4vy\Api\UsersApi( + // 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 +); +$user_id = 8724fd24-5489-4a5d-90fd-0604df7d3b83; // string | The unique ID for a user. + +try { + $apiInstance->deleteUser($user_id); +} catch (Exception $e) { + echo 'Exception when calling UsersApi->deleteUser: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **user_id** | [**string**](../Model/.md)| The unique ID for a user. | + +### Return type + +void (empty response body) + +### Authorization + +[BearerAuth](../../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) diff --git a/docs/Model/Action.md b/docs/Model/Action.md new file mode 100644 index 0000000..ea83f6c --- /dev/null +++ b/docs/Model/Action.md @@ -0,0 +1,14 @@ +# # Action + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | The type of this resource. Is always `action`. | [optional] +**id** | **string** | The identifier for the action. | [optional] +**flow** | **string** | The related flow for the action. | [optional] +**rule_id** | **string** | The unique ID of the rule triggered. | [optional] +**created_at** | **\DateTime** | The date and time when this action was created. | [optional] +**outcome** | [**\Gr4vy\model\Undefined**](Undefined.md) | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/Actions.md b/docs/Model/Actions.md new file mode 100644 index 0000000..4211c95 --- /dev/null +++ b/docs/Model/Actions.md @@ -0,0 +1,9 @@ +# # Actions + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**items** | [**\Gr4vy\model\Action[]**](Action.md) | A list of actions. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/Address.md b/docs/Model/Address.md new file mode 100644 index 0000000..f71d250 --- /dev/null +++ b/docs/Model/Address.md @@ -0,0 +1,17 @@ +# # Address + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**city** | **string** | The city for the billing address. | [optional] +**country** | **string** | The country for the billing address. | [optional] +**postal_code** | **string** | The postal code or zip code for the billing address. | [optional] +**state** | **string** | The state, county, or province for the billing address. | [optional] +**state_code** | **string** | The code of state, county, or province for the billing address in ISO 3166-2 format. | [optional] +**house_number_or_name** | **string** | The house number or name for the billing address. Not all payment services use this field but some do. | [optional] +**line1** | **string** | The first line of the billing address. | [optional] +**line2** | **string** | The second line of the billing address. | [optional] +**organization** | **string** | The optional name of the company or organisation to add to the billing address. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/AddressUpdate.md b/docs/Model/AddressUpdate.md new file mode 100644 index 0000000..207ad58 --- /dev/null +++ b/docs/Model/AddressUpdate.md @@ -0,0 +1,17 @@ +# # AddressUpdate + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**city** | **string** | The city for the billing address. | [optional] +**country** | **string** | The country for the billing address. | [optional] +**postal_code** | **string** | The postal code or zip code for the billing address. | [optional] +**state** | **string** | The state, county, or province for the billing address. | [optional] +**state_code** | **string** | The code of state, county, or province for the billing address in ISO 3166-2 format. | [optional] +**house_number_or_name** | **string** | The house number or name for the billing address. Not all payment services use this field but some do. | [optional] +**line1** | **string** | The first line of the billing address. | [optional] +**line2** | **string** | The second line of the billing address. | [optional] +**organization** | **string** | The optional name of the company or organisation to add to the billing address. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/AntiFraudService.md b/docs/Model/AntiFraudService.md new file mode 100644 index 0000000..7f113ca --- /dev/null +++ b/docs/Model/AntiFraudService.md @@ -0,0 +1,16 @@ +# # AntiFraudService + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | The type of this resource. Is always `anti-fraud-service`. | [optional] +**id** | **string** | The unique Gr4vy ID for this anti-fraud service. | [optional] +**anti_fraud_service_definition_id** | **string** | The name of the Anti-Fraud service provider. During update request, this value is used for validation only but the underlying service can not be changed for an existing service. | [optional] +**display_name** | **string** | A unique name for this anti-fraud service which is used in the Gr4vy admin panel to give a anti-fraud service a human readable name. | [optional] +**active** | **bool** | Defines if this service is currently active or not. | [optional] [default to true] +**fields** | [**\Gr4vy\model\AntiFraudServiceFieldsInner[]**](AntiFraudServiceFieldsInner.md) | A list of fields, each containing a key-value pair for anti-fraud service decision mapping e.g. for sift `approve_decision` will be in the response. | [optional] +**created_at** | **\DateTime** | The date and time when this anti-fraud service was created in our system. | [optional] +**updated_at** | **\DateTime** | The date and time when this anti-fraud service was last updated in our system. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/AntiFraudServiceCreate.md b/docs/Model/AntiFraudServiceCreate.md new file mode 100644 index 0000000..f573f20 --- /dev/null +++ b/docs/Model/AntiFraudServiceCreate.md @@ -0,0 +1,12 @@ +# # AntiFraudServiceCreate + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**anti_fraud_service_definition_id** | **string** | The name of the Anti-Fraud service provider. During update request, this value is used for validation only but the underlying service can not be changed for an existing service. | +**display_name** | **string** | A unique name for this anti-fraud service which is used in the Gr4vy admin panel to give a anti-fraud Service a human readable name. | +**active** | **bool** | Defines if this service is currently active or not. | [optional] [default to true] +**fields** | [**\Gr4vy\model\AntiFraudServiceUpdateFieldsInner[]**](AntiFraudServiceUpdateFieldsInner.md) | A list of fields, each containing a key-value pair for each field defined by the definition for this anti-fraud service e.g. for sift `api_key` must be sent within this field when creating the service. For updates, only the fields sent here will be updated, existing ones will not be affected if not present. | + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/AntiFraudServiceFieldsInner.md b/docs/Model/AntiFraudServiceFieldsInner.md new file mode 100644 index 0000000..346ecbe --- /dev/null +++ b/docs/Model/AntiFraudServiceFieldsInner.md @@ -0,0 +1,10 @@ +# # AntiFraudServiceFieldsInner + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**key** | **string** | The key of the field to set a value for. | +**value** | **string** | The value of a field to set. | + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/AntiFraudServiceUpdate.md b/docs/Model/AntiFraudServiceUpdate.md new file mode 100644 index 0000000..d480891 --- /dev/null +++ b/docs/Model/AntiFraudServiceUpdate.md @@ -0,0 +1,12 @@ +# # AntiFraudServiceUpdate + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**anti_fraud_service_definition_id** | **string** | The name of the Anti-Fraud service provider. During update request, this value is used for validation only but the underlying service can not be changed for an existing service. | +**display_name** | **string** | A unique name for this anti-fraud service which is used in the Gr4vy admin panel to give a anti-fraud Service a human readable name. | [optional] +**active** | **bool** | Defines if this service is currently active or not. | [optional] [default to true] +**fields** | [**\Gr4vy\model\AntiFraudServiceUpdateFieldsInner[]**](AntiFraudServiceUpdateFieldsInner.md) | A list of fields, each containing a key-value pair for each field defined by the definition for this anti-fraud service e.g. for sift `api_key` must be sent within this field when creating the service. For updates, only the fields sent here will be updated, existing ones will not be affected if not present. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/AntiFraudServiceUpdateFieldsInner.md b/docs/Model/AntiFraudServiceUpdateFieldsInner.md new file mode 100644 index 0000000..43e2e88 --- /dev/null +++ b/docs/Model/AntiFraudServiceUpdateFieldsInner.md @@ -0,0 +1,10 @@ +# # AntiFraudServiceUpdateFieldsInner + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**key** | **string** | The key of the field to set a value for. | +**value** | **string** | The value of a field to set. | + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/ApplePayRequest.md b/docs/Model/ApplePayRequest.md new file mode 100644 index 0000000..aba0fec --- /dev/null +++ b/docs/Model/ApplePayRequest.md @@ -0,0 +1,10 @@ +# # ApplePayRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**method** | **string** | `applepay`. | +**token** | **object** | The encrypted (opaque) token that was passed to the `onpaymentauthorized` callback by the Apple Pay integration. | + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/ApplePaySessionRequest.md b/docs/Model/ApplePaySessionRequest.md new file mode 100644 index 0000000..895416d --- /dev/null +++ b/docs/Model/ApplePaySessionRequest.md @@ -0,0 +1,10 @@ +# # ApplePaySessionRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**validation_url** | **string** | Validation URL obtained from the event passed to a `onvalidatemerchant` callback. | +**domain_name** | **string** | Fully qualified domain name of the merchant. | + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/AuditLog.md b/docs/Model/AuditLog.md new file mode 100644 index 0000000..d343ce2 --- /dev/null +++ b/docs/Model/AuditLog.md @@ -0,0 +1,14 @@ +# # AuditLog + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | `audit-log`. | [optional] +**id** | **string** | The ID of the audit log entry. | [optional] +**timestamp** | **string** | The date and time that the action was performed. | [optional] +**action** | **string** | The action that was performed. | [optional] +**user** | [**\Gr4vy\model\AuditLogUser**](AuditLogUser.md) | | [optional] +**resource** | [**\Gr4vy\model\AuditLogResource**](AuditLogResource.md) | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/AuditLogResource.md b/docs/Model/AuditLogResource.md new file mode 100644 index 0000000..66c05d1 --- /dev/null +++ b/docs/Model/AuditLogResource.md @@ -0,0 +1,11 @@ +# # AuditLogResource + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | The type of the resource. | [optional] +**id** | **string** | The ID of the resource. | [optional] +**name** | **string** | The descriptive name of the resource. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/AuditLogUser.md b/docs/Model/AuditLogUser.md new file mode 100644 index 0000000..40eace8 --- /dev/null +++ b/docs/Model/AuditLogUser.md @@ -0,0 +1,11 @@ +# # AuditLogUser + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **string** | The ID of the user. | [optional] +**name** | **string** | The name of the user. | [optional] +**staff** | **bool** | Whether the user is Gr4vy staff. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/AuditLogs.md b/docs/Model/AuditLogs.md new file mode 100644 index 0000000..376dc7c --- /dev/null +++ b/docs/Model/AuditLogs.md @@ -0,0 +1,12 @@ +# # AuditLogs + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**items** | [**\Gr4vy\model\AuditLog[]**](AuditLog.md) | A list of audit log entries. | [optional] +**limit** | **int** | The limit applied to request. This represents the number of items that are at maximum returned by this request. | [optional] [default to 20] +**next_cursor** | **string** | The cursor that represents the next page of results. Use the `cursor` query parameter to fetch this page of items. | [optional] +**previous_cursor** | **string** | The cursor that represents the next page of results. Use the `cursor` query parameter to fetch this page of items. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/BillingDetails.md b/docs/Model/BillingDetails.md new file mode 100644 index 0000000..c4054ec --- /dev/null +++ b/docs/Model/BillingDetails.md @@ -0,0 +1,15 @@ +# # BillingDetails + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | The type of this resource. Is always `billing-details`. | [optional] +**first_name** | **string** | The first name(s) or given name of the buyer. | [optional] +**last_name** | **string** | The last name, or family name, of the buyer. | [optional] +**email_address** | **string** | The email address of the buyer. | [optional] +**phone_number** | **string** | The phone number of the buyer. This number is formatted according to the [E164 number standard](https://www.twilio.com/docs/glossary/what-e164). | [optional] +**address** | [**\Gr4vy\model\BillingDetailsAddress**](BillingDetailsAddress.md) | | [optional] +**tax_id** | [**\Gr4vy\model\BillingDetailsTaxId**](BillingDetailsTaxId.md) | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/BillingDetailsAddress.md b/docs/Model/BillingDetailsAddress.md new file mode 100644 index 0000000..4cb5722 --- /dev/null +++ b/docs/Model/BillingDetailsAddress.md @@ -0,0 +1,17 @@ +# # BillingDetailsAddress + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**city** | **string** | The city for the billing address. | [optional] +**country** | **string** | The country for the billing address. | [optional] +**postal_code** | **string** | The postal code or zip code for the billing address. | [optional] +**state** | **string** | The state, county, or province for the billing address. | [optional] +**state_code** | **string** | The code of state, county, or province for the billing address in ISO 3166-2 format. | [optional] +**house_number_or_name** | **string** | The house number or name for the billing address. Not all payment services use this field but some do. | [optional] +**line1** | **string** | The first line of the billing address. | [optional] +**line2** | **string** | The second line of the billing address. | [optional] +**organization** | **string** | The optional name of the company or organisation to add to the billing address. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/BillingDetailsRequest.md b/docs/Model/BillingDetailsRequest.md new file mode 100644 index 0000000..cab19c8 --- /dev/null +++ b/docs/Model/BillingDetailsRequest.md @@ -0,0 +1,14 @@ +# # BillingDetailsRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**first_name** | **string** | The first name(s) or given name for the buyer. | [optional] +**last_name** | **string** | The last name, or family name, of the buyer. | [optional] +**email_address** | **string** | The email address for the buyer. | [optional] +**phone_number** | **string** | The phone number for the buyer which should be formatted according to the [E164 number standard](https://www.twilio.com/docs/glossary/what-e164). | [optional] +**address** | [**\Gr4vy\model\BillingDetailsRequestAddress**](BillingDetailsRequestAddress.md) | | [optional] +**tax_id** | [**\Gr4vy\model\BillingDetailsTaxId**](BillingDetailsTaxId.md) | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/BillingDetailsRequestAddress.md b/docs/Model/BillingDetailsRequestAddress.md new file mode 100644 index 0000000..8701f93 --- /dev/null +++ b/docs/Model/BillingDetailsRequestAddress.md @@ -0,0 +1,17 @@ +# # BillingDetailsRequestAddress + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**city** | **string** | The city for the billing address. | +**country** | **string** | The country for the billing address. | +**postal_code** | **string** | The postal code or zip code for the billing address. | +**state** | **string** | The state, county, or province for the billing address. | +**state_code** | **string** | The code of state, county, or province for the billing address in ISO 3166-2 format. | [optional] +**house_number_or_name** | **string** | The house number or name for the billing address. Not all payment services use this field but some do. | [optional] +**line1** | **string** | The first line of the billing address. | +**line2** | **string** | The second line of the billing address. | [optional] +**organization** | **string** | The optional name of the company or organisation to add to the billing address. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/BillingDetailsTaxId.md b/docs/Model/BillingDetailsTaxId.md new file mode 100644 index 0000000..7ce9a34 --- /dev/null +++ b/docs/Model/BillingDetailsTaxId.md @@ -0,0 +1,10 @@ +# # BillingDetailsTaxId + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**value** | **string** | The tax ID for the buyer. | +**kind** | **string** | The kind of tax ID. | + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/BillingDetailsUpdateRequest.md b/docs/Model/BillingDetailsUpdateRequest.md new file mode 100644 index 0000000..f5a50af --- /dev/null +++ b/docs/Model/BillingDetailsUpdateRequest.md @@ -0,0 +1,14 @@ +# # BillingDetailsUpdateRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**first_name** | **string** | The first name(s) or given name for the buyer. | [optional] +**last_name** | **string** | The last name, or family name, of the buyer. | [optional] +**email_address** | **string** | The email address for the buyer. | [optional] +**phone_number** | **string** | The phone number for the buyer which should be formatted according to the [E164 number standard](https://www.twilio.com/docs/glossary/what-e164). | [optional] +**address** | [**\Gr4vy\model\BillingDetailsUpdateRequestAddress**](BillingDetailsUpdateRequestAddress.md) | | [optional] +**tax_id** | [**\Gr4vy\model\BillingDetailsTaxId**](BillingDetailsTaxId.md) | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/BillingDetailsUpdateRequestAddress.md b/docs/Model/BillingDetailsUpdateRequestAddress.md new file mode 100644 index 0000000..084128e --- /dev/null +++ b/docs/Model/BillingDetailsUpdateRequestAddress.md @@ -0,0 +1,17 @@ +# # BillingDetailsUpdateRequestAddress + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**city** | **string** | The city for the billing address. | [optional] +**country** | **string** | The country for the billing address. | [optional] +**postal_code** | **string** | The postal code or zip code for the billing address. | [optional] +**state** | **string** | The state, county, or province for the billing address. | [optional] +**state_code** | **string** | The code of state, county, or province for the billing address in ISO 3166-2 format. | [optional] +**house_number_or_name** | **string** | The house number or name for the billing address. Not all payment services use this field but some do. | [optional] +**line1** | **string** | The first line of the billing address. | [optional] +**line2** | **string** | The second line of the billing address. | [optional] +**organization** | **string** | The optional name of the company or organisation to add to the billing address. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/BrowserInfo.md b/docs/Model/BrowserInfo.md new file mode 100644 index 0000000..cd485d2 --- /dev/null +++ b/docs/Model/BrowserInfo.md @@ -0,0 +1,18 @@ +# # BrowserInfo + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**java_enabled** | **bool** | Indicates whether the client browser supports Java. | +**javascript_enabled** | **bool** | Indicates whether the client browser supports JavaScript. | +**language** | **string** | The preferred language of the buyer, usually the language of the browser UI. | +**color_depth** | **float** | The color depth of the screen. | +**screen_height** | **float** | The height of the screen in pixels. | +**screen_width** | **float** | The width of the screen in pixels. | +**time_zone_offset** | **float** | Time-zone offset in minutes between UTC and buyer location. | +**user_device** | **string** | The platform that is being used to access the website. | +**user_agent** | **string** | The user agent string for the current browser. | +**accept_header** | **string** | The `Accept` header of the request from the buyer's browser. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/Buyer.md b/docs/Model/Buyer.md new file mode 100644 index 0000000..8d0c785 --- /dev/null +++ b/docs/Model/Buyer.md @@ -0,0 +1,15 @@ +# # Buyer + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | The type of this resource. Is always `buyer`. | [optional] +**id** | **string** | The unique Gr4vy ID for this buyer. | [optional] +**external_identifier** | **string** | An external identifier that can be used to match the buyer against your own records. | [optional] +**display_name** | **string** | A unique name for this buyer which is used in the Gr4vy admin panel to give a buyer a human readable name. | [optional] +**billing_details** | [**\Gr4vy\model\BuyerBillingDetails**](BuyerBillingDetails.md) | | [optional] +**created_at** | **\DateTime** | The date and time when this buyer was created in our system. | [optional] +**updated_at** | **\DateTime** | The date and time when this buyer was last updated in our system. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/BuyerBillingDetails.md b/docs/Model/BuyerBillingDetails.md new file mode 100644 index 0000000..8dd30d5 --- /dev/null +++ b/docs/Model/BuyerBillingDetails.md @@ -0,0 +1,15 @@ +# # BuyerBillingDetails + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | The type of this resource. Is always `billing-details`. | [optional] +**first_name** | **string** | The first name(s) or given name of the buyer. | [optional] +**last_name** | **string** | The last name, or family name, of the buyer. | [optional] +**email_address** | **string** | The email address of the buyer. | [optional] +**phone_number** | **string** | The phone number of the buyer. This number is formatted according to the [E164 number standard](https://www.twilio.com/docs/glossary/what-e164). | [optional] +**address** | [**\Gr4vy\model\BillingDetailsAddress**](BillingDetailsAddress.md) | | [optional] +**tax_id** | [**\Gr4vy\model\BillingDetailsTaxId**](BillingDetailsTaxId.md) | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/BuyerRequest.md b/docs/Model/BuyerRequest.md new file mode 100644 index 0000000..4a679e2 --- /dev/null +++ b/docs/Model/BuyerRequest.md @@ -0,0 +1,11 @@ +# # BuyerRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**external_identifier** | **string** | An external identifier that can be used to match the buyer against your own records. This value needs to be unique for all buyers. | [optional] +**display_name** | **string** | A unique name for this buyer which is used in the Gr4vy admin panel to give a buyer a human readable name. | [optional] +**billing_details** | [**\Gr4vy\model\BuyerRequestBillingDetails**](BuyerRequestBillingDetails.md) | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/BuyerRequestBillingDetails.md b/docs/Model/BuyerRequestBillingDetails.md new file mode 100644 index 0000000..8de6d6f --- /dev/null +++ b/docs/Model/BuyerRequestBillingDetails.md @@ -0,0 +1,14 @@ +# # BuyerRequestBillingDetails + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**first_name** | **string** | The first name(s) or given name for the buyer. | [optional] +**last_name** | **string** | The last name, or family name, of the buyer. | [optional] +**email_address** | **string** | The email address for the buyer. | [optional] +**phone_number** | **string** | The phone number for the buyer which should be formatted according to the [E164 number standard](https://www.twilio.com/docs/glossary/what-e164). | [optional] +**address** | [**\Gr4vy\model\BillingDetailsRequestAddress**](BillingDetailsRequestAddress.md) | | [optional] +**tax_id** | [**\Gr4vy\model\BillingDetailsTaxId**](BillingDetailsTaxId.md) | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/BuyerSnapshot.md b/docs/Model/BuyerSnapshot.md new file mode 100644 index 0000000..705bb9c --- /dev/null +++ b/docs/Model/BuyerSnapshot.md @@ -0,0 +1,13 @@ +# # BuyerSnapshot + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | The type of this resource. Is always `buyer`. | [optional] +**id** | **string** | The unique Gr4vy ID for this buyer. | [optional] +**external_identifier** | **string** | An external identifier that can be used to match the buyer against your own records. | [optional] +**display_name** | **string** | A unique name for this buyer which is used in the Gr4vy admin panel to give a buyer a human readable name. | [optional] +**billing_details** | [**\Gr4vy\model\BuyerSnapshotBillingDetails**](BuyerSnapshotBillingDetails.md) | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/BuyerSnapshotBillingDetails.md b/docs/Model/BuyerSnapshotBillingDetails.md new file mode 100644 index 0000000..ebfe427 --- /dev/null +++ b/docs/Model/BuyerSnapshotBillingDetails.md @@ -0,0 +1,15 @@ +# # BuyerSnapshotBillingDetails + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | The type of this resource. Is always `billing-details`. | [optional] +**first_name** | **string** | The first name(s) or given name of the buyer. | [optional] +**last_name** | **string** | The last name, or family name, of the buyer. | [optional] +**email_address** | **string** | The email address of the buyer. | [optional] +**phone_number** | **string** | The phone number of the buyer. This number is formatted according to the [E164 number standard](https://www.twilio.com/docs/glossary/what-e164). | [optional] +**address** | [**\Gr4vy\model\BillingDetailsAddress**](BillingDetailsAddress.md) | | [optional] +**tax_id** | [**\Gr4vy\model\BillingDetailsTaxId**](BillingDetailsTaxId.md) | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/BuyerUpdate.md b/docs/Model/BuyerUpdate.md new file mode 100644 index 0000000..9ae866a --- /dev/null +++ b/docs/Model/BuyerUpdate.md @@ -0,0 +1,11 @@ +# # BuyerUpdate + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**external_identifier** | **string** | An external identifier that can be used to match the buyer against your own records. This value needs to be unique for all buyers. | [optional] +**display_name** | **string** | A unique name for this buyer which is used in the Gr4vy admin panel to give a buyer a human readable name. | [optional] +**billing_details** | [**\Gr4vy\model\BuyerUpdateBillingDetails**](BuyerUpdateBillingDetails.md) | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/BuyerUpdateBillingDetails.md b/docs/Model/BuyerUpdateBillingDetails.md new file mode 100644 index 0000000..34b4e0e --- /dev/null +++ b/docs/Model/BuyerUpdateBillingDetails.md @@ -0,0 +1,14 @@ +# # BuyerUpdateBillingDetails + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**first_name** | **string** | The first name(s) or given name for the buyer. | [optional] +**last_name** | **string** | The last name, or family name, of the buyer. | [optional] +**email_address** | **string** | The email address for the buyer. | [optional] +**phone_number** | **string** | The phone number for the buyer which should be formatted according to the [E164 number standard](https://www.twilio.com/docs/glossary/what-e164). | [optional] +**address** | [**\Gr4vy\model\BillingDetailsUpdateRequestAddress**](BillingDetailsUpdateRequestAddress.md) | | [optional] +**tax_id** | [**\Gr4vy\model\BillingDetailsTaxId**](BillingDetailsTaxId.md) | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/Buyers.md b/docs/Model/Buyers.md new file mode 100644 index 0000000..e9e8640 --- /dev/null +++ b/docs/Model/Buyers.md @@ -0,0 +1,12 @@ +# # Buyers + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**items** | [**\Gr4vy\model\Buyer[]**](Buyer.md) | A list of buyers. | [optional] +**limit** | **int** | The limit applied to request. This represents the number of items that are at maximum returned by this request. | [optional] [default to 20] +**next_cursor** | **string** | The cursor that represents the next page of results. Use the `cursor` query parameter to fetch this page of items. | [optional] +**previous_cursor** | **string** | The cursor that represents the next page of results. Use the `cursor` query parameter to fetch this page of items. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/Card.md b/docs/Model/Card.md new file mode 100644 index 0000000..bc226fb --- /dev/null +++ b/docs/Model/Card.md @@ -0,0 +1,18 @@ +# # Card + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | `payment-method`. | [optional] +**id** | **string** | The unique ID of the payment method. | [optional] +**status** | **string** | The state of the card tokenization. | [optional] +**method** | **string** | `card`. | [optional] +**created_at** | [**\DateTime**](\DateTime.md) | The date and time when this payment method was first created in our system. | [optional] +**updated_at** | [**\DateTime**](\DateTime.md) | The date and time when this payment method was last updated in our system. | [optional] +**external_identifier** | **string** | An external identifier that can be used to match the payment method against your own records. | [optional] +**buyer** | [**Buyer**](Buyer.md) | The optional buyer for which this payment method has been stored. | [optional] +**details** | [**\Gr4vy\model\CardDetails**](CardDetails.md) | | [optional] +**environment** | **string** | The environment this payment method has been stored for. This will be null of the payment method was not stored. | [optional] [default to ENVIRONMENT_PRODUCTION] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/CardDetails.md b/docs/Model/CardDetails.md new file mode 100644 index 0000000..c32dc9b --- /dev/null +++ b/docs/Model/CardDetails.md @@ -0,0 +1,14 @@ +# # CardDetails + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | `card-detail`. | [optional] +**id** | **string** | The 8 digit BIN of the card. When looking up card details using a `payment_method_id` this value will be `null`. | [optional] +**card_type** | **string** | The type of card. | [optional] +**scheme** | **string** | The scheme/brand of the card. | [optional] +**country** | **string** | The 2-letter ISO code of the issuing country of the card. | [optional] +**required_fields** | [**\Gr4vy\model\RequiredFields**](RequiredFields.md) | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/CardRequest.md b/docs/Model/CardRequest.md new file mode 100644 index 0000000..b176a1a --- /dev/null +++ b/docs/Model/CardRequest.md @@ -0,0 +1,15 @@ +# # CardRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**method** | **string** | `card`. | +**number** | **string** | The 13-19 digit number for this card as it can be found on the front of the card. | +**expiration_date** | **string** | The expiration date of the card, formatted `MM/YY`. | +**security_code** | **string** | The 3 or 4 digit security code often found on the card. This often referred to as the CVV or CVD. | +**external_identifier** | **string** | An external identifier that can be used to match the card against your own records. | [optional] +**buyer_id** | **string** | The ID of the buyer to associate this payment method to. If this field is provided then the `buyer_external_identifier` field needs to be unset. | [optional] +**buyer_external_identifier** | **string** | The `external_identifier` of the buyer to associate this payment method to. If this field is provided then the `buyer_id` field needs to be unset. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/CardRequiredFields.md b/docs/Model/CardRequiredFields.md new file mode 100644 index 0000000..2ce6016 --- /dev/null +++ b/docs/Model/CardRequiredFields.md @@ -0,0 +1,14 @@ +# # CardRequiredFields + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**first_name** | **bool** | The first (given) name of the buyer. | [optional] [readonly] +**last_name** | **bool** | The last (family) name of the buyer. | [optional] [readonly] +**email_address** | **bool** | The email address of the buyer. | [optional] [readonly] +**phone_number** | **bool** | The phone number of the buyer. | [optional] [readonly] +**address** | [**\Gr4vy\model\CardRequiredFieldsAddress**](CardRequiredFieldsAddress.md) | | [optional] +**tax_id** | **bool** | The tax id code associated with the billing details. | [optional] [readonly] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/CardRequiredFieldsAddress.md b/docs/Model/CardRequiredFieldsAddress.md new file mode 100644 index 0000000..6a05127 --- /dev/null +++ b/docs/Model/CardRequiredFieldsAddress.md @@ -0,0 +1,14 @@ +# # CardRequiredFieldsAddress + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**city** | **bool** | The city for the billing address. | [optional] [readonly] +**country** | **bool** | The country for the billing address. | [optional] [readonly] +**postal_code** | **bool** | The postal code or zip code for the billing address. | [optional] [readonly] +**state** | **bool** | The state, county, or province for the billing address. | [optional] [readonly] +**house_number_or_name** | **bool** | The house number or name for the billing address. Not all payment services use this field but some do. | [optional] [readonly] +**line1** | **bool** | The first line of the billing address. | [optional] [readonly] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/CardRule.md b/docs/Model/CardRule.md new file mode 100644 index 0000000..42b1f6b --- /dev/null +++ b/docs/Model/CardRule.md @@ -0,0 +1,19 @@ +# # CardRule + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | `card-rule`. | [optional] +**id** | **string** | The ID of the rule. | [optional] +**active** | **bool** | Whether this rule is currently in use. Rules can be deactivated to allow for them to be kept around and re-activated at a later date. | [optional] +**environment** | **string** | The environment to use this rule in. This rule will only be used for transactions created in that environment. | [optional] [default to ENVIRONMENT_PRODUCTION] +**conditions** | [**\Gr4vy\model\CardRuleCondition[]**](CardRuleCondition.md) | One or more conditions that apply for this rule. Each condition needs to match for this rule to go into effect. | [optional] +**payment_service_ids** | **string[]** | A list of IDs for the payment services to use, in order of priority. The payment services all need to process cards. | [optional] +**position** | **float** | The numeric rank of a rule. Rules with a lower position value are processed first. | [optional] +**unprocessable_fallback_strategy** | **string** | Defines what strategy to use when all of the payment services defined in this rule declined or otherwise were not able to process the card. * `use_all_providers` - Try all payment services enabled for this currency in order of priority, even if they are not listed in this rule. This is the default behaviour for a rule. * `decline` - Decline the transaction. | [optional] [default to UNPROCESSABLE_FALLBACK_STRATEGY_USE_ALL_PROVIDERS] +**invalid_rule_fallback_strategy** | **string** | Defines what strategy to use when this rule is not valid. This can happen when the rule has triggered for a certain transaction but none of the listed payment services are eligible to process that transaction currency. * `use_all_providers` - Try all payment services enabled for this currency in order of priority, even if they are not listed in this rule. This is the default behaviour for a rule. * `skip` - Skip this rule and instead move on to the next highest priority rule. * `decline` - Decline the transaction. | [optional] [default to INVALID_RULE_FALLBACK_STRATEGY_USE_ALL_PROVIDERS] +**created_at** | [**\DateTime**](\DateTime.md) | The date and time when this rule was created. | [optional] +**updated_at** | [**\DateTime**](\DateTime.md) | The date and time when this rule was last updated. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/CardRuleCondition.md b/docs/Model/CardRuleCondition.md new file mode 100644 index 0000000..08de910 --- /dev/null +++ b/docs/Model/CardRuleCondition.md @@ -0,0 +1,12 @@ +# # CardRuleCondition + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**match** | **string** | The type of match made for this rule. | +**key** | **string** | The transaction field to filter by. | +**operator** | **string** | The comparison to make to `value` property. | +**value** | [**\Gr4vy\model\Undefined**](Undefined.md) | | + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/CardRuleNumberCondition.md b/docs/Model/CardRuleNumberCondition.md new file mode 100644 index 0000000..7910f9a --- /dev/null +++ b/docs/Model/CardRuleNumberCondition.md @@ -0,0 +1,12 @@ +# # CardRuleNumberCondition + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**match** | **string** | `number`. | +**key** | **string** | The transaction field to filter by. | +**operator** | **string** | The comparison to make to `value` property. | +**value** | **float** | The values to compare the `key` to. | + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/CardRuleRequest.md b/docs/Model/CardRuleRequest.md new file mode 100644 index 0000000..cc8070c --- /dev/null +++ b/docs/Model/CardRuleRequest.md @@ -0,0 +1,15 @@ +# # CardRuleRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**active** | **bool** | Whether this rule is currently in use. Rules can be deactivated to allow for them to be kept around and re-activated at a later date. | [optional] +**environment** | **string** | The environment to use this rule in. This rule will only be used for transactions created in that environment. | [optional] [default to ENVIRONMENT_PRODUCTION] +**position** | **float** | The numeric rank of a rule. Rules with a lower position value are processed first. When a rule is inserted at a position, any rules with the the same value or higher are down a position accordingly. When left out, the rule is inserted at the end of the list. | [optional] +**conditions** | [**\Gr4vy\model\CardRuleCondition[]**](CardRuleCondition.md) | One or more conditions that apply for this rule. Each condition needs to match for this rule to go into effect. | +**payment_service_ids** | **string[]** | A list of IDs for the payment services to use, in order of priority. The payment services all need to process cards. | +**unprocessable_fallback_strategy** | **string** | Defines what strategy to use when all of the payment services defined in this rule declined or otherwise were not able to process the card. * `use_all_providers` - Try all payment services enabled for this currency in order of priority, even if they are not listed in this rule. This is the default behaviour for a rule. * `decline` - Decline the transaction. | [optional] [default to UNPROCESSABLE_FALLBACK_STRATEGY_USE_ALL_PROVIDERS] +**invalid_rule_fallback_strategy** | **string** | Defines what strategy to use when this rule is not valid. This can happen when the rule has triggered for a certain transaction but none of the listed payment services are eligible to process that transaction currency. * `use_all_providers` - Try all payment services enabled for this currency in order of priority, even if they are not listed in this rule. This is the default behaviour for a rule. * `skip` - Skip this rule and instead move on to the next highest priority rule. * `decline` - Decline the transaction. | [optional] [default to INVALID_RULE_FALLBACK_STRATEGY_USE_ALL_PROVIDERS] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/CardRuleTextCondition.md b/docs/Model/CardRuleTextCondition.md new file mode 100644 index 0000000..74f4baa --- /dev/null +++ b/docs/Model/CardRuleTextCondition.md @@ -0,0 +1,12 @@ +# # CardRuleTextCondition + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**match** | **string** | `text`. | +**key** | **string** | The transaction field to filter by. | +**operator** | **string** | The comparison to make to `value` property. | +**value** | **string[]** | The values to compare the `key` to. | + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/CardRuleUpdate.md b/docs/Model/CardRuleUpdate.md new file mode 100644 index 0000000..10107d5 --- /dev/null +++ b/docs/Model/CardRuleUpdate.md @@ -0,0 +1,15 @@ +# # CardRuleUpdate + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**active** | **bool** | Whether this rule is currently in use. Rules can be deactivated to allow for them to be kept around and re-activated at a later date. | [optional] +**environment** | **string** | The environment to use this rule in. This rule will only be used for transactions created in that environment. | [optional] [default to ENVIRONMENT_PRODUCTION] +**position** | **float** | The numeric rank of a rule. Rules with a lower position value are processed first. When a rule is inserted at a position, any rules with the the same value or higher are down a position accordingly. | [optional] +**conditions** | [**\Gr4vy\model\CardRuleCondition[]**](CardRuleCondition.md) | One or more conditions that apply for this rule. Each condition needs to match for this rule to go into effect. | [optional] +**payment_service_ids** | **string[]** | A list of IDs for the payment services to use, in order of priority. The payment services all need to process cards. | [optional] +**unprocessable_fallback_strategy** | **string** | Defines what strategy to use when all of the payment services defined in this rule declined or otherwise were not able to process the card. * `use_all_providers` - Try all payment services enabled for this currency in order of priority, even if they are not listed in this rule. This is the default behaviour for a rule. * `decline` - Decline the transaction. | [optional] [default to UNPROCESSABLE_FALLBACK_STRATEGY_USE_ALL_PROVIDERS] +**invalid_rule_fallback_strategy** | **string** | Defines what strategy to use when this rule is not valid. This can happen when the rule has triggered for a certain transaction but none of the listed payment services are eligible to process that transaction currency. * `use_all_providers` - Try all payment services enabled for this currency in order of priority, even if they are not listed in this rule. This is the default behaviour for a rule. * `skip` - Skip this rule and instead move on to the next highest priority rule. * `decline` - Decline the transaction. | [optional] [default to INVALID_RULE_FALLBACK_STRATEGY_USE_ALL_PROVIDERS] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/CardRules.md b/docs/Model/CardRules.md new file mode 100644 index 0000000..609a017 --- /dev/null +++ b/docs/Model/CardRules.md @@ -0,0 +1,12 @@ +# # CardRules + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**items** | [**\Gr4vy\model\CardRule[]**](CardRule.md) | A list of card rules. | [optional] +**limit** | **int** | The limit applied to request. This represents the number of items that are at maximum returned by this request. | [optional] [default to 20] +**next_cursor** | **string** | The cursor that represents the next page of results. Use the `cursor` query parameter to fetch this page of items. | [optional] +**previous_cursor** | **string** | The cursor that represents the next page of results. Use the `cursor` query parameter to fetch this page of items. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/CardSchemeDefinition.md b/docs/Model/CardSchemeDefinition.md new file mode 100644 index 0000000..0e5e6b2 --- /dev/null +++ b/docs/Model/CardSchemeDefinition.md @@ -0,0 +1,12 @@ +# # CardSchemeDefinition + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | `card-scheme-definition`. | [optional] +**id** | **string** | The name of this card scheme. | [optional] +**icon_url** | **string** | The icon for this card scheme. | [optional] +**display_name** | **string** | The display name of this card scheme. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/CardSchemeDefinitions.md b/docs/Model/CardSchemeDefinitions.md new file mode 100644 index 0000000..02ab156 --- /dev/null +++ b/docs/Model/CardSchemeDefinitions.md @@ -0,0 +1,9 @@ +# # CardSchemeDefinitions + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**items** | [**\Gr4vy\model\CardSchemeDefinition[]**](CardSchemeDefinition.md) | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/CardTokenized.md b/docs/Model/CardTokenized.md new file mode 100644 index 0000000..b50b8ae --- /dev/null +++ b/docs/Model/CardTokenized.md @@ -0,0 +1,12 @@ +# # CardTokenized + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | `payment-method`. | [optional] +**id** | **string** | The unique ID of the payment method. | [optional] +**method** | **string** | `card`. | [optional] +**details** | [**\Gr4vy\model\CardDetails**](CardDetails.md) | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/CartItem.md b/docs/Model/CartItem.md new file mode 100644 index 0000000..61222eb --- /dev/null +++ b/docs/Model/CartItem.md @@ -0,0 +1,19 @@ +# # CartItem + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **string** | The name of the cart item. The value you set for this property may be truncated if the maximum length accepted by a payment service provider is less than 255 characters. | +**quantity** | **int** | The quantity of this item in the cart. This value cannot be negative or zero. | +**unit_amount** | **int** | The amount for an individual item represented as a monetary amount in the smallest currency unit for the given currency, for example `1299` USD cents represents `$12.99`. | +**discount_amount** | **int** | The amount discounted for this item represented as a monetary amount in the smallest currency unit for the given currency, for example `1299` USD cents represents `$12.99`. Please note that this amount is for the total of the cart item and not for an individual item. For example, if the quantity is 5, this value should be the total discount amount for 5 of the cart item. You might see unexpected failed transactions if the `discount_amount` can not be equally divided by the `quantity` value. This is due to the fact that some payment services require this amount to be specified per unit. In this situation we recommend splitting this item into separate items, each with their own specific discount. | [optional] [default to 0] +**tax_amount** | **int** | The tax amount for this item represented as a monetary amount in the smallest currency unit for the given currency, for example `1299` USD cents represents `$12.99`. Please not that this amount is for the total of the cart item and not for an individual item. For example, if the quantity is 5, this value should be the total tax amount for 5 of the cart item. You might see unexpected failed transactions if the `tax_amount` can not be equally divided by the `quantity` value. This is due to the fact that some payment services require this amount to be specified per unit. In this situation we recommend splitting this item into separate items, each with their own specific tax amount. | [optional] [default to 0] +**external_identifier** | **string** | An external identifier for the cart item. This can be set to any value and is not sent to the payment service. | [optional] +**sku** | **string** | The SKU for the item. | [optional] +**product_url** | **string** | The product URL for the item. | [optional] +**image_url** | **string** | The URL for the image of the item. | [optional] +**categories** | **string[]** | A list of strings containing product categories for the item. Max length per item: 50. | [optional] +**product_type** | **string** | The product type of the cart item. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/CheckoutSession.md b/docs/Model/CheckoutSession.md new file mode 100644 index 0000000..8576ec5 --- /dev/null +++ b/docs/Model/CheckoutSession.md @@ -0,0 +1,11 @@ +# # CheckoutSession + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | `checkout-session`. | [optional] +**id** | **string** | The ID of the Checkout Session. | [optional] +**expires_at** | **string** | The date and time when the Checkout Session will expire. By default this will be set to 1 hour from the date of creation. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/CheckoutSessionRequest.md b/docs/Model/CheckoutSessionRequest.md new file mode 100644 index 0000000..a6dbdfb --- /dev/null +++ b/docs/Model/CheckoutSessionRequest.md @@ -0,0 +1,10 @@ +# # CheckoutSessionRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**method** | **string** | `checkout-session`. | +**id** | **string** | The ID of the Checkout Session. | + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/CheckoutSessionSecureFieldsUpdate.md b/docs/Model/CheckoutSessionSecureFieldsUpdate.md new file mode 100644 index 0000000..afa1928 --- /dev/null +++ b/docs/Model/CheckoutSessionSecureFieldsUpdate.md @@ -0,0 +1,9 @@ +# # CheckoutSessionSecureFieldsUpdate + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**payment_method** | [**\Gr4vy\model\CardRequest**](CardRequest.md) | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/Connection.md b/docs/Model/Connection.md new file mode 100644 index 0000000..6c8ba88 --- /dev/null +++ b/docs/Model/Connection.md @@ -0,0 +1,13 @@ +# # Connection + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **string** | The ID of the connection. | [optional] +**type** | **string** | `connection`. | [optional] [default to 'connection'] +**name** | **string** | The name of this connection. | [optional] +**active** | **bool** | Whether this connection is currently in use. Connections can be deactivated to allow for them to be kept around and re-activated at a later date. | [optional] +**definition** | [**\Gr4vy\model\ConnectionDefinition**](ConnectionDefinition.md) | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/ConnectionDefinition.md b/docs/Model/ConnectionDefinition.md new file mode 100644 index 0000000..cf46aed --- /dev/null +++ b/docs/Model/ConnectionDefinition.md @@ -0,0 +1,16 @@ +# # ConnectionDefinition + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **string** | The ID of the connection. | [optional] +**type** | **string** | `connection-definition`. | [optional] [default to 'connection-definition'] +**name** | **string** | The name of this connection. | [optional] +**count** | **float** | The number of configured connections. | [optional] +**group** | **string** | | [optional] +**category** | **string** | | [optional] +**icon_url** | **string** | An icon to display for the connection. | [optional] +**provider** | **string** | The provider for this connection. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/ConnectionDefinitions.md b/docs/Model/ConnectionDefinitions.md new file mode 100644 index 0000000..82f7bec --- /dev/null +++ b/docs/Model/ConnectionDefinitions.md @@ -0,0 +1,9 @@ +# # ConnectionDefinitions + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**items** | [**\Gr4vy\model\ConnectionDefinition[]**](ConnectionDefinition.md) | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/Connections.md b/docs/Model/Connections.md new file mode 100644 index 0000000..d544fc9 --- /dev/null +++ b/docs/Model/Connections.md @@ -0,0 +1,9 @@ +# # Connections + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**items** | [**\Gr4vy\model\Connection[]**](Connection.md) | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/DigitalWallet.md b/docs/Model/DigitalWallet.md new file mode 100644 index 0000000..4f6d9c2 --- /dev/null +++ b/docs/Model/DigitalWallet.md @@ -0,0 +1,16 @@ +# # DigitalWallet + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | `digital-wallet`. | [optional] +**provider** | **string** | The name of the digital wallet provider. | [optional] +**id** | **string** | The ID of the registered digital wallet. | [optional] +**merchant_name** | **string** | The name of the merchant the digital wallet is registered to. | [optional] +**merchant_url** | **string** | The main URL of the merchant. | [optional] +**domain_names** | **string[]** | The list of domain names that a digital wallet can be used on. To use a digital wallet on a website, the domain of the site is required to be in this list. | [optional] +**created_at** | **\DateTime** | The date and time when this digital wallet was registered. | [optional] +**updated_at** | **\DateTime** | The date and time when this digital wallet was last updated. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/DigitalWalletRequest.md b/docs/Model/DigitalWalletRequest.md new file mode 100644 index 0000000..65ff48f --- /dev/null +++ b/docs/Model/DigitalWalletRequest.md @@ -0,0 +1,13 @@ +# # DigitalWalletRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**provider** | **string** | The name of the digital wallet provider. | +**merchant_name** | **string** | The name of the merchant. This is used to register the merchant with a digital wallet provider and this name is not displayed to the buyer. | +**merchant_url** | **string** | The main URL of the merchant. This is used to register the merchant with a digital wallet provider and this URL is not displayed to the buyer. | [optional] +**domain_names** | **string[]** | The list of domain names that a digital wallet can be used on. To use a digital wallet on a website, the domain of the site is required to be in this list. | +**accept_terms_and_conditions** | **bool** | The explicit acceptance of the digital wallet provider's terms and conditions by the merchant. Needs to be `true` to register a new digital wallet. | + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/DigitalWalletUpdate.md b/docs/Model/DigitalWalletUpdate.md new file mode 100644 index 0000000..a832c1e --- /dev/null +++ b/docs/Model/DigitalWalletUpdate.md @@ -0,0 +1,10 @@ +# # DigitalWalletUpdate + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**merchant_name** | **string** | The name of the merchant. This is used to update the value initially used to register with a digital wallet provider and this name is not displayed to the buyer. | [optional] +**domain_names** | **string[]** | The list of domain names that a digital wallet can be used on. To use a digital wallet on a website, the domain of the site is required to be in this list. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/DigitalWallets.md b/docs/Model/DigitalWallets.md new file mode 100644 index 0000000..94144a0 --- /dev/null +++ b/docs/Model/DigitalWallets.md @@ -0,0 +1,9 @@ +# # DigitalWallets + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**items** | [**\Gr4vy\model\DigitalWallet[]**](DigitalWallet.md) | A list of registered digital wallets. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/Error400BadRequest.md b/docs/Model/Error400BadRequest.md new file mode 100644 index 0000000..4102d60 --- /dev/null +++ b/docs/Model/Error400BadRequest.md @@ -0,0 +1,13 @@ +# # Error400BadRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | `error`. | [optional] +**code** | **string** | `bad_request`. | [optional] +**status** | **int** | `400`. | [optional] +**message** | **string** | Describes the fields that are missing or incorrectly formatted in the API request. | [optional] +**details** | [**\Gr4vy\model\ErrorDetail[]**](ErrorDetail.md) | A list of detail objects that further clarify the reason for the error. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/Error400IncorrectJson.md b/docs/Model/Error400IncorrectJson.md new file mode 100644 index 0000000..b5db37e --- /dev/null +++ b/docs/Model/Error400IncorrectJson.md @@ -0,0 +1,13 @@ +# # Error400IncorrectJson + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | `error`. | [optional] +**code** | **string** | `incorrect_json`. | [optional] +**status** | **int** | `400`. | [optional] +**message** | **string** | Incorrect JSON. The request body could not be parsed as valid JSON. | [optional] +**details** | [**\Gr4vy\model\ErrorDetail[]**](ErrorDetail.md) | A list of detail objects that further clarify the reason for the error. Not every error supports more detail. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/Error400InvalidCredentials.md b/docs/Model/Error400InvalidCredentials.md new file mode 100644 index 0000000..f5f969b --- /dev/null +++ b/docs/Model/Error400InvalidCredentials.md @@ -0,0 +1,12 @@ +# # Error400InvalidCredentials + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | `error`. | [optional] +**code** | **string** | `invalid_credentials`. | [optional] +**status** | **int** | `400`. | [optional] +**message** | **string** | The provided credentials are invalid. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/Error401Unauthorized.md b/docs/Model/Error401Unauthorized.md new file mode 100644 index 0000000..ecbb774 --- /dev/null +++ b/docs/Model/Error401Unauthorized.md @@ -0,0 +1,13 @@ +# # Error401Unauthorized + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | `error`. | [optional] +**code** | **string** | `unauthorized`. | [optional] +**status** | **int** | `401`. | [optional] +**message** | **string** | No valid API authentication found. | [optional] +**details** | [**\Gr4vy\model\ErrorDetail[]**](ErrorDetail.md) | A list of detail objects that further clarify the reason for the error. Not every error supports more detail. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/Error403Forbidden.md b/docs/Model/Error403Forbidden.md new file mode 100644 index 0000000..bde7104 --- /dev/null +++ b/docs/Model/Error403Forbidden.md @@ -0,0 +1,13 @@ +# # Error403Forbidden + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | `error`. | [optional] +**code** | **string** | `forbidden`. | [optional] +**status** | **int** | `403`. | [optional] +**message** | **string** | Invalid credentials. | [optional] +**details** | [**\Gr4vy\model\ErrorDetail[]**](ErrorDetail.md) | A list of detail objects that further clarify the reason for the error. Not every error supports more detail. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/Error404NotFound.md b/docs/Model/Error404NotFound.md new file mode 100644 index 0000000..a0de1e8 --- /dev/null +++ b/docs/Model/Error404NotFound.md @@ -0,0 +1,13 @@ +# # Error404NotFound + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | `error`. | [optional] +**code** | **string** | `not_found`. | [optional] +**status** | **int** | `404`. | [optional] +**message** | **string** | The resource could not be found. | [optional] +**details** | [**\Gr4vy\model\ErrorDetail[]**](ErrorDetail.md) | A list of detail objects that further clarify the reason for the error. Not every error supports more detail. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/Error404PendingCreation.md b/docs/Model/Error404PendingCreation.md new file mode 100644 index 0000000..6580774 --- /dev/null +++ b/docs/Model/Error404PendingCreation.md @@ -0,0 +1,13 @@ +# # Error404PendingCreation + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | `error`. | [optional] +**code** | **string** | `pending_creation`. | [optional] +**status** | **int** | `404`. | [optional] +**message** | **string** | The resource is still pending. | [optional] +**details** | [**\Gr4vy\model\ErrorDetail[]**](ErrorDetail.md) | A list of detail objects that further clarify the reason for the error. Not every error supports more detail. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/Error409DuplicateRecord.md b/docs/Model/Error409DuplicateRecord.md new file mode 100644 index 0000000..9ef0ff6 --- /dev/null +++ b/docs/Model/Error409DuplicateRecord.md @@ -0,0 +1,13 @@ +# # Error409DuplicateRecord + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | `error`. | [optional] +**code** | **string** | `duplicate_record`. | [optional] +**status** | **int** | `409`. | [optional] +**message** | **string** | Further details on the field that triggered the error. | [optional] +**details** | [**\Gr4vy\model\ErrorDetail[]**](ErrorDetail.md) | A list of detail objects that further clarify the reason for the error. Not every error supports more detail. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/ErrorDetail.md b/docs/Model/ErrorDetail.md new file mode 100644 index 0000000..ce68fb4 --- /dev/null +++ b/docs/Model/ErrorDetail.md @@ -0,0 +1,12 @@ +# # ErrorDetail + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**location** | **string** | The location where the error caused an issue. | [optional] +**type** | **string** | A unique identifier for the type of error that occurred. | [optional] +**pointer** | **string** | The exact item for which the validation did not succeed. This is a JSON pointer for request bodies, while for query, path, and header parameters it is the name of the parameter. | [optional] +**message** | **string** | A human readable message for this error detail. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/ErrorGeneric.md b/docs/Model/ErrorGeneric.md new file mode 100644 index 0000000..a3280ba --- /dev/null +++ b/docs/Model/ErrorGeneric.md @@ -0,0 +1,13 @@ +# # ErrorGeneric + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | The type of this object. This is always `error`. | [optional] [default to 'error'] +**code** | **string** | A custom code to further describe the type of error being returned. This code provides further specification within the HTTP `status` code and can be used by a program to define logic based on the error. | [optional] +**status** | **int** | The HTTP status code of this error. | [optional] +**message** | **string** | A human readable message that describes the error. The content of this field should not be used to determine any business logic. | [optional] +**details** | [**\Gr4vy\model\ErrorDetail[]**](ErrorDetail.md) | A list of detail objects that further clarify the reason for the error. Not every error supports more detail. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/FlowPaymentOptionOutcome.md b/docs/Model/FlowPaymentOptionOutcome.md new file mode 100644 index 0000000..068fc1c --- /dev/null +++ b/docs/Model/FlowPaymentOptionOutcome.md @@ -0,0 +1,14 @@ +# # FlowPaymentOptionOutcome + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | The type of this resource. Is always `action`. | [optional] +**id** | **string** | Payment option identifier. | [optional] +**label** | **string** | Verbose payment option name. | [optional] +**active** | **bool** | The status of the payment option, true if at least one underlying connection is active, otherwise false. | [optional] +**group** | **string** | Optional group label for a given payment option, e.g. `Bank`. | [optional] +**icon_url** | **string** | Payment option icon URL. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/FlowRuleBooleanOutcome.md b/docs/Model/FlowRuleBooleanOutcome.md new file mode 100644 index 0000000..7af79db --- /dev/null +++ b/docs/Model/FlowRuleBooleanOutcome.md @@ -0,0 +1,10 @@ +# # FlowRuleBooleanOutcome + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | The type of action outcome for the given rule. | +**result** | **bool** | Results for a given flow action. | + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/FlowRuleMethodOutcome.md b/docs/Model/FlowRuleMethodOutcome.md new file mode 100644 index 0000000..f1a6312 --- /dev/null +++ b/docs/Model/FlowRuleMethodOutcome.md @@ -0,0 +1,10 @@ +# # FlowRuleMethodOutcome + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | The type of action outcome for the given rule. | +**result** | **string[]** | Results for a given flow action. | + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/FlowRuleServiceOutcome.md b/docs/Model/FlowRuleServiceOutcome.md new file mode 100644 index 0000000..f90ee4c --- /dev/null +++ b/docs/Model/FlowRuleServiceOutcome.md @@ -0,0 +1,10 @@ +# # FlowRuleServiceOutcome + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | The type of action outcome for the given rule. | +**result** | **string[]** | Results for a given flow action. | + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/GooglePayRequest.md b/docs/Model/GooglePayRequest.md new file mode 100644 index 0000000..3bf01f4 --- /dev/null +++ b/docs/Model/GooglePayRequest.md @@ -0,0 +1,10 @@ +# # GooglePayRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**method** | **string** | `googlepay`. | +**token** | **object** | The encrypted (opaque) token returned by the Google Pay API that represents a payment method. | + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/GooglePaySessionRequest.md b/docs/Model/GooglePaySessionRequest.md new file mode 100644 index 0000000..6c28212 --- /dev/null +++ b/docs/Model/GooglePaySessionRequest.md @@ -0,0 +1,9 @@ +# # GooglePaySessionRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**origin_domain** | **string** | Fully qualified domain name of the merchant. | + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/Methods.md b/docs/Model/Methods.md new file mode 100644 index 0000000..4b9cc00 --- /dev/null +++ b/docs/Model/Methods.md @@ -0,0 +1,8 @@ +# # Methods + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/Modes.md b/docs/Model/Modes.md new file mode 100644 index 0000000..74e4f62 --- /dev/null +++ b/docs/Model/Modes.md @@ -0,0 +1,8 @@ +# # Modes + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PayPal.md b/docs/Model/PayPal.md new file mode 100644 index 0000000..426f287 --- /dev/null +++ b/docs/Model/PayPal.md @@ -0,0 +1,18 @@ +# # PayPal + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | `payment-method`. | [optional] +**id** | **string** | The unique ID of the payment method. | [optional] +**status** | **string** | The state of the account tokenization. After the first call this will be set to `buyer_approval_pending` and the response will include an `approval_url`. The buyer needs to be redirected to this URL to authorize the future payments. | [optional] +**method** | **string** | `paypal`. | [optional] +**created_at** | [**\DateTime**](\DateTime.md) | The date and time when this payment method was first created in our system. | [optional] +**updated_at** | [**\DateTime**](\DateTime.md) | The date and time when this payment method was last updated in our system. | [optional] +**external_identifier** | **string** | An external identifier that can be used to match the payment method against your own records. | [optional] +**buyer** | [**Buyer**](Buyer.md) | The optional buyer for which this payment method has been stored. | [optional] +**details** | [**\Gr4vy\model\PayPalDetails**](PayPalDetails.md) | | [optional] +**environment** | **string** | The environment this payment method has been stored for. This will be null of the payment method was not stored. | [optional] [default to ENVIRONMENT_PRODUCTION] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PayPalDetails.md b/docs/Model/PayPalDetails.md new file mode 100644 index 0000000..8130f8d --- /dev/null +++ b/docs/Model/PayPalDetails.md @@ -0,0 +1,10 @@ +# # PayPalDetails + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**email_address** | **string** | The email address associated to the PayPal account. | [optional] +**approval_url** | **string** | The optional URL that the buyer needs to be redirected to to further authorize their PayPal payments. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PayPalRequest.md b/docs/Model/PayPalRequest.md new file mode 100644 index 0000000..09298fa --- /dev/null +++ b/docs/Model/PayPalRequest.md @@ -0,0 +1,13 @@ +# # PayPalRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**method** | **string** | `paypal`. | +**redirect_url** | **string** | The redirect URL to redirect a buyer to after they have authorized their PayPal transaction. | +**external_identifier** | **string** | An external identifier that can be used to match the account against your own records. | [optional] +**buyer_id** | **string** | The ID of the buyer to associate this payment method to. If this field is provided then the `buyer_external_identifier` field needs to be unset. | [optional] +**buyer_external_identifier** | **string** | The `external_identifier` of the buyer to associate this payment method to. If this field is provided then the `buyer_id` field needs to be unset. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentMethod.md b/docs/Model/PaymentMethod.md new file mode 100644 index 0000000..44c32a8 --- /dev/null +++ b/docs/Model/PaymentMethod.md @@ -0,0 +1,25 @@ +# # PaymentMethod + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | `payment-method`. | [optional] +**id** | **string** | The unique ID of the payment method. | [optional] +**status** | **string** | The state of the payment method. - `processing` - The payment method is still being stored. - `buyer_approval_required` - Storing the payment method requires the buyer to provide approval. Follow the `approval_url` for next steps. - `succeeded` - The payment method is approved and stored with all relevant payment services. - `failed` - Storing the payment method did not succeed. | [optional] +**method** | **string** | | [optional] +**mode** | **string** | | [optional] +**created_at** | **\DateTime** | The date and time when this payment method was first created in our system. | [optional] +**updated_at** | **\DateTime** | The date and time when this payment method was last updated in our system. | [optional] +**external_identifier** | **string** | An external identifier that can be used to match the payment method against your own records. | [optional] +**buyer** | [**\Gr4vy\model\PaymentMethodBuyer**](PaymentMethodBuyer.md) | | [optional] +**label** | **string** | A label for the card or the account. For a `paypal` payment method this is the user's email address. For a card it is the last 4 digits of the card. | [optional] +**scheme** | **string** | The scheme of the card. Only applies to card payments. | [optional] +**expiration_date** | **string** | The expiration date for the payment method. | [optional] +**approval_target** | **string** | The browser target that an approval URL must be opened in. If `any` or `null`, then there is no specific requirement. | [optional] +**approval_url** | **string** | The optional URL that the buyer needs to be redirected to to further authorize their payment. | [optional] +**currency** | **string** | The ISO-4217 currency code that this payment method can be used for. If this value is `null` the payment method may be used for multiple currencies. | [optional] +**country** | **string** | The 2-letter ISO code of the country this payment method can be used for. If this value is `null` the payment method may be used in multiple countries. | [optional] +**details** | [**\Gr4vy\model\PaymentMethodDetailsCard**](PaymentMethodDetailsCard.md) | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentMethodBuyer.md b/docs/Model/PaymentMethodBuyer.md new file mode 100644 index 0000000..e50e666 --- /dev/null +++ b/docs/Model/PaymentMethodBuyer.md @@ -0,0 +1,15 @@ +# # PaymentMethodBuyer + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | The type of this resource. Is always `buyer`. | [optional] +**id** | **string** | The unique Gr4vy ID for this buyer. | [optional] +**external_identifier** | **string** | An external identifier that can be used to match the buyer against your own records. | [optional] +**display_name** | **string** | A unique name for this buyer which is used in the Gr4vy admin panel to give a buyer a human readable name. | [optional] +**billing_details** | [**\Gr4vy\model\BuyerBillingDetails**](BuyerBillingDetails.md) | | [optional] +**created_at** | **\DateTime** | The date and time when this buyer was created in our system. | [optional] +**updated_at** | **\DateTime** | The date and time when this buyer was last updated in our system. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentMethodDefinition.md b/docs/Model/PaymentMethodDefinition.md new file mode 100644 index 0000000..8d231b1 --- /dev/null +++ b/docs/Model/PaymentMethodDefinition.md @@ -0,0 +1,13 @@ +# # PaymentMethodDefinition + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **string** | The mode of this payment method. | [optional] +**icon_url** | **string** | The icon for this payment method. | [optional] +**display_name** | **string** | The display name of this payment method. | [optional] +**long_display_name** | **string** | The long display name of this payment method. | [optional] +**method** | **string** | The method, or type, for this payment method. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentMethodDefinitions.md b/docs/Model/PaymentMethodDefinitions.md new file mode 100644 index 0000000..74048b5 --- /dev/null +++ b/docs/Model/PaymentMethodDefinitions.md @@ -0,0 +1,9 @@ +# # PaymentMethodDefinitions + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**items** | [**\Gr4vy\model\PaymentMethodDefinition[]**](PaymentMethodDefinition.md) | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentMethodDetails.md b/docs/Model/PaymentMethodDetails.md new file mode 100644 index 0000000..b6cbb95 --- /dev/null +++ b/docs/Model/PaymentMethodDetails.md @@ -0,0 +1,13 @@ +# # PaymentMethodDetails + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**number** | **string** | Partial number details for a stored card, hiding all but the last few numbers. | [optional] +**scheme** | **string** | The type of the card. | [optional] +**expiration_date** | **string** | The expiration date for a card. | [optional] +**email_address** | **string** | The email address associated to the payment method. | [optional] +**approval_url** | **string** | The optional URL that the buyer needs to be redirected to to further authorize the payment method. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentMethodDetailsCard.md b/docs/Model/PaymentMethodDetailsCard.md new file mode 100644 index 0000000..fdabd41 --- /dev/null +++ b/docs/Model/PaymentMethodDetailsCard.md @@ -0,0 +1,10 @@ +# # PaymentMethodDetailsCard + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**card_type** | **string** | The type of card, one of `credit`, `debit` or `prepaid`. | [optional] +**bin** | **string** | The first 6 digits of the full card number (the BIN). | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentMethodRequest.md b/docs/Model/PaymentMethodRequest.md new file mode 100644 index 0000000..8190e0a --- /dev/null +++ b/docs/Model/PaymentMethodRequest.md @@ -0,0 +1,18 @@ +# # PaymentMethodRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**method** | **string** | | +**number** | **string** | The 13-19 digit number for this credit card as it can be found on the front of the card. If a card has been stored with us previously, this number will represent the unique tokenized card ID provided via our API. | [optional] +**expiration_date** | **string** | The expiration date of the card, formatted `MM/YY`. If a card has been previously stored with us this value is optional. If the `number` of this card represents a tokenized card, then this value is ignored. | [optional] +**security_code** | **string** | The 3 or 4 digit security code often found on the card. This often referred to as the CVV or CVD. If the `number` of this card represents a tokenized card, then this value is ignored. | [optional] +**external_identifier** | **string** | An external identifier that can be used to match the card against your own records. | [optional] +**buyer_id** | **string** | The ID of the buyer to associate this payment method to. If this field is provided then the `buyer_external_identifier` field needs to be unset. | [optional] +**buyer_external_identifier** | **string** | The `external_identifier` of the buyer to associate this payment method to. If this field is provided then the `buyer_id` field needs to be unset. | [optional] +**redirect_url** | **string** | The redirect URL to redirect a buyer to after they have authorized their transaction or payment method. This only applies to payment methods that require buyer approval. | [optional] +**currency** | **string** | The ISO-4217 currency code to store this payment method for. This is used to select the payment service to use. This only applies to `redirect` mode payment methods like `gocardless`. | [optional] +**country** | **string** | The 2-letter ISO code of the country to store this payment method for. This is used to select the payment service to use. This only applies to `redirect` mode payment methods like `gocardless`. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentMethodSnapshot.md b/docs/Model/PaymentMethodSnapshot.md new file mode 100644 index 0000000..0f1fc1b --- /dev/null +++ b/docs/Model/PaymentMethodSnapshot.md @@ -0,0 +1,20 @@ +# # PaymentMethodSnapshot + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | `payment-method`. | [optional] +**id** | **string** | The unique ID of the payment method. | [optional] +**method** | **string** | | [optional] +**external_identifier** | **string** | An external identifier that can be used to match the payment method against your own records. | [optional] +**label** | **string** | A label for the payment method. This can be the last 4 digits for a card, or the email address for an alternative payment method. | [optional] +**scheme** | **string** | An additional label used to differentiate different sub-types of a payment method. Most notably this can include the type of card used in a transaction. | [optional] +**expiration_date** | **string** | The expiration date for this payment method. This is mostly used by cards where the card might have an expiration date. | [optional] +**approval_target** | **string** | The browser target that an approval URL must be opened in. If `any` or `null`, then there is no specific requirement. | [optional] +**approval_url** | **string** | The optional URL that the buyer needs to be redirected to to further authorize their payment. | [optional] +**currency** | **string** | The ISO-4217 currency code that this payment method can be used for. If this value is `null` the payment method may be used for multiple currencies. | [optional] +**country** | **string** | The 2-letter ISO code of the country this payment method can be used for. If this value is `null` the payment method may be used in multiple countries. | [optional] +**details** | [**\Gr4vy\model\PaymentMethodDetailsCard**](PaymentMethodDetailsCard.md) | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentMethodToken.md b/docs/Model/PaymentMethodToken.md new file mode 100644 index 0000000..0ec5836 --- /dev/null +++ b/docs/Model/PaymentMethodToken.md @@ -0,0 +1,13 @@ +# # PaymentMethodToken + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | `payment-method-token`. | [optional] +**id** | **string** | The external ID of this payment method as it has been registered with the payment service, which can be used directly in combination with the `token` without the need to go through Gr4vy for a transaction. In some cases this is a different value to the `token` while in others this value is identical. Please see the documentation for the payment service for more details. | [optional] +**token** | **string** | The token of this payment method as it has been registered with the payment service, which can be used directly in combination with the `id` without the need to go through Gr4vy for a transaction. In some cases this is a different value to the `id` while in others this value is identical. Please see the documentation for the payment service for more details. | [optional] +**status** | **string** | The state of the payment method. - `processing` - The payment method is still being stored. - `buyer_approval_required` - The buyer still needs to provide approval before the payment method can be stored. - `succeeded` - The payment method is approved and stored with all relevant payment services. - `failed` - Storing the payment method did not succeed. | [optional] +**payment_service** | [**\Gr4vy\model\PaymentMethodTokenPaymentService**](PaymentMethodTokenPaymentService.md) | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentMethodTokenPaymentService.md b/docs/Model/PaymentMethodTokenPaymentService.md new file mode 100644 index 0000000..36cc807 --- /dev/null +++ b/docs/Model/PaymentMethodTokenPaymentService.md @@ -0,0 +1,13 @@ +# # PaymentMethodTokenPaymentService + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **string** | The ID of this payment service. | [optional] +**type** | **string** | The type of this resource. | [optional] +**payment_service_definition_id** | **string** | The ID of the payment service definition used to create this service. | [optional] +**method** | **string** | | [optional] +**display_name** | **string** | The custom name set for this service. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentMethodTokenized.md b/docs/Model/PaymentMethodTokenized.md new file mode 100644 index 0000000..045d94c --- /dev/null +++ b/docs/Model/PaymentMethodTokenized.md @@ -0,0 +1,18 @@ +# # PaymentMethodTokenized + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | `payment-method`. | [optional] +**id** | **string** | The unique ID of the payment method. | [optional] +**method** | **string** | | [optional] +**label** | **string** | A label for the payment method. For a `card` payment method this is the last 4 digits on the card. For others it would be the email address. | [optional] +**scheme** | **string** | The type of the card, if the payment method is a card. | [optional] +**expiration_date** | **string** | The expiration date for the payment method. | [optional] +**approval_target** | **string** | The browser target that an approval URL must be opened in. If `any` or `null`, then there is no specific requirement. | [optional] +**approval_url** | **string** | The optional URL that the buyer needs to be redirected to to further authorize their payment. | [optional] +**currency** | **string** | The ISO-4217 currency code that this payment method can be used for. If this value is `null` the payment method may be used for multiple currencies. | [optional] +**country** | **string** | The 2-letter ISO code of the country this payment method can be used for. If this value is `null` the payment method may be used in multiple countries. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentMethodTokens.md b/docs/Model/PaymentMethodTokens.md new file mode 100644 index 0000000..f1bb55d --- /dev/null +++ b/docs/Model/PaymentMethodTokens.md @@ -0,0 +1,9 @@ +# # PaymentMethodTokens + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**items** | [**\Gr4vy\model\PaymentMethodToken[]**](PaymentMethodToken.md) | A list of stored tokens for payment methods. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentMethods.md b/docs/Model/PaymentMethods.md new file mode 100644 index 0000000..675dbe7 --- /dev/null +++ b/docs/Model/PaymentMethods.md @@ -0,0 +1,12 @@ +# # PaymentMethods + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**items** | [**\Gr4vy\model\PaymentMethod[]**](PaymentMethod.md) | A list of stored payment methods. | [optional] +**limit** | **int** | The limit applied to request. This represents the number of items that are at maximum returned by this request. | [optional] [default to 20] +**next_cursor** | **string** | The cursor that represents the next page of results. Use the `cursor` query parameter to fetch this page of items. | [optional] +**previous_cursor** | **string** | The cursor that represents the next page of results. Use the `cursor` query parameter to fetch this page of items. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentMethodsTokenized.md b/docs/Model/PaymentMethodsTokenized.md new file mode 100644 index 0000000..9c9d407 --- /dev/null +++ b/docs/Model/PaymentMethodsTokenized.md @@ -0,0 +1,9 @@ +# # PaymentMethodsTokenized + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**items** | [**\Gr4vy\model\PaymentMethodTokenized[]**](PaymentMethodTokenized.md) | A list of stored payment methods in token format. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentOption.md b/docs/Model/PaymentOption.md new file mode 100644 index 0000000..e2422a4 --- /dev/null +++ b/docs/Model/PaymentOption.md @@ -0,0 +1,15 @@ +# # PaymentOption + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | `payment-option`. | [optional] +**method** | **string** | | [optional] +**icon_url** | **string** | An icon to display for the payment option. | [optional] +**mode** | **string** | | [optional] +**label** | **string** | A label that describes this payment option. This label is returned in the language defined by the `locale` query parameter. The label can be used to display a list of payment options to the buyer in their language. | [optional] +**can_store_payment_method** | **bool** | A flag to indicate if storing the payment method is supported. | [optional] +**context** | [**\Gr4vy\model\PaymentOptionContext**](PaymentOptionContext.md) | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentOptionApprovalUI.md b/docs/Model/PaymentOptionApprovalUI.md new file mode 100644 index 0000000..f3e6146 --- /dev/null +++ b/docs/Model/PaymentOptionApprovalUI.md @@ -0,0 +1,10 @@ +# # PaymentOptionApprovalUI + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**height** | **string** | Height of the approval interface in either pixels or view height (vh). | [optional] +**width** | **string** | Width of the approval interface in either pixels or view width (vw). | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentOptionCardSchemeApplePay.md b/docs/Model/PaymentOptionCardSchemeApplePay.md new file mode 100644 index 0000000..d4282a1 --- /dev/null +++ b/docs/Model/PaymentOptionCardSchemeApplePay.md @@ -0,0 +1,8 @@ +# # PaymentOptionCardSchemeApplePay + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentOptionCardSchemeGooglePay.md b/docs/Model/PaymentOptionCardSchemeGooglePay.md new file mode 100644 index 0000000..e05a8c7 --- /dev/null +++ b/docs/Model/PaymentOptionCardSchemeGooglePay.md @@ -0,0 +1,8 @@ +# # PaymentOptionCardSchemeGooglePay + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentOptionContext.md b/docs/Model/PaymentOptionContext.md new file mode 100644 index 0000000..89ccfad --- /dev/null +++ b/docs/Model/PaymentOptionContext.md @@ -0,0 +1,12 @@ +# # PaymentOptionContext + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**merchant_name** | **string** | Display name of the merchant as registered with the digital wallet provider. | [optional] +**supported_schemes** | **string[]** | Card schemes supported by the digital wallet provider. | [optional] +**approval_ui** | [**\Gr4vy\model\PaymentOptionApprovalUI**](PaymentOptionApprovalUI.md) | | [optional] +**required_fields** | [**\Gr4vy\model\RequiredFields**](RequiredFields.md) | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentOptions.md b/docs/Model/PaymentOptions.md new file mode 100644 index 0000000..bf9ba01 --- /dev/null +++ b/docs/Model/PaymentOptions.md @@ -0,0 +1,9 @@ +# # PaymentOptions + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**items** | [**\Gr4vy\model\PaymentOption[]**](PaymentOption.md) | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentService.md b/docs/Model/PaymentService.md new file mode 100644 index 0000000..ffd5d75 --- /dev/null +++ b/docs/Model/PaymentService.md @@ -0,0 +1,33 @@ +# # PaymentService + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **string** | The ID of this payment service. | [optional] +**type** | **string** | The type of this resource. | [optional] +**payment_service_definition_id** | **string** | The ID of the payment service definition used to create this service. | [optional] +**method** | **string** | | [optional] +**display_name** | **string** | The custom name set for this service. | [optional] +**status** | **string** | The current status of this service. This will start off as pending, move to created, and might eventually move to an error status if and when the credentials are no longer valid. | [optional] +**accepted_currencies** | **string[]** | A list of currencies for which this service is enabled, in ISO 4217 three-letter code format. | [optional] +**accepted_countries** | **string[]** | A list of countries for which this service is enabled, in ISO two-letter code format. | [optional] +**three_d_secure_enabled** | **bool** | Defines if 3-D Secure is enabled for the service (can only be enabled if the payment service definition supports the `three_d_secure_hosted` feature). This does not affect pass through 3-D Secure data. | [optional] [default to false] +**acquirer_bin_visa** | **string** | Acquiring institution identification code for VISA. | [optional] +**acquirer_bin_mastercard** | **string** | Acquiring institution identification code for Mastercard. | [optional] +**acquirer_bin_amex** | **string** | Acquiring institution identification code for Amex. | [optional] +**acquirer_bin_discover** | **string** | Acquiring institution identification code for Discover. | [optional] +**acquirer_merchant_id** | **string** | Merchant identifier used in authorisation requests (assigned by the acquirer). | [optional] +**merchant_name** | **string** | Merchant name (assigned by the acquirer). | [optional] +**merchant_country_code** | **string** | ISO 3166-1 numeric three-digit country code. | [optional] +**merchant_category_code** | **string** | Merchant category code that describes the business. | [optional] +**merchant_url** | **string** | Fully qualified URL of 3-D Secure requestor website or customer care site. | [optional] +**active** | **bool** | Defines if this service is currently active or not. | [optional] [default to true] +**position** | **float** | The numeric rank of a payment service. Payment services with a lower position value are processed first. | [optional] +**payment_method_tokenization_enabled** | **bool** | Defines if tokenization is enabled for the service (can only be enabled if the payment service definition supports it). | [optional] [default to false] +**created_at** | **\DateTime** | The date and time when this service was created. | [optional] +**updated_at** | **\DateTime** | The date and time when this service was last updated. | [optional] +**webhook_url** | **string** | The URL that needs to be configured with this payment service as the receiving endpoint for webhooks from the service to Gr4vy. Currently, Gr4vy does not yet automatically register webhooks on setup, and therefore webhooks need to be registered manually by the merchant. | [optional] +**fields** | [**\Gr4vy\model\PaymentServiceFieldsInner[]**](PaymentServiceFieldsInner.md) | A list of fields, each containing a key-value pair for each field configured for this payment service. Fields marked as `secret` (see Payment Service Definition) are not returned. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentServiceDefinition.md b/docs/Model/PaymentServiceDefinition.md new file mode 100644 index 0000000..9a3d004 --- /dev/null +++ b/docs/Model/PaymentServiceDefinition.md @@ -0,0 +1,19 @@ +# # PaymentServiceDefinition + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **string** | The ID of the payment service. This is the underlying provider followed by a dash followed by the payment method ID. | [optional] +**type** | **string** | `payment-service-definition`. | [optional] [default to 'payment-service-definition'] +**display_name** | **string** | The display name of this service. | [optional] +**method** | **string** | | [optional] +**fields** | [**\Gr4vy\model\PaymentServiceDefinitionFieldsInner[]**](PaymentServiceDefinitionFieldsInner.md) | A list of fields that need to be submitted when activating the payment. service. | [optional] +**supported_currencies** | **string[]** | A list of three-letter ISO currency codes that this service supports. | [optional] +**supported_countries** | **string[]** | A list of two-letter ISO country codes that this service supports. | [optional] +**mode** | **string** | | [optional] +**supported_features** | [**\Gr4vy\model\PaymentServiceDefinitionSupportedFeatures**](PaymentServiceDefinitionSupportedFeatures.md) | | [optional] +**icon_url** | **string** | An icon to display for the payment service. | [optional] +**configuration** | [**\Gr4vy\model\PaymentServiceDefinitionConfiguration**](PaymentServiceDefinitionConfiguration.md) | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentServiceDefinitionConfiguration.md b/docs/Model/PaymentServiceDefinitionConfiguration.md new file mode 100644 index 0000000..9e3d542 --- /dev/null +++ b/docs/Model/PaymentServiceDefinitionConfiguration.md @@ -0,0 +1,11 @@ +# # PaymentServiceDefinitionConfiguration + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**approval_ui_height** | **string** | Height of the approval interface in either pixels or view height (vh). | [optional] +**approval_ui_width** | **string** | Width of the approval interface in either pixels or view width (vw). | [optional] +**approval_ui_target** | **string** | The browser target that an approval URL must be opened in. If `any` or `null`, then there is no specific requirement. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentServiceDefinitionFields.md b/docs/Model/PaymentServiceDefinitionFields.md new file mode 100644 index 0000000..c173d40 --- /dev/null +++ b/docs/Model/PaymentServiceDefinitionFields.md @@ -0,0 +1,13 @@ +# # PaymentServiceDefinitionFields + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**key** | **string** | The key of a field that needs to be submitted. | [optional] +**display_name** | **string** | The name to display for a field in the dashboard. | [optional] +**required** | **bool** | Defines if this field is required when the service is created. | [optional] +**format** | **string** | Defines the type of input that needs to be rendered for this field. | [optional] +**secret** | **bool** | Defines if this field is secret. When `true` the field is not returned when querying the payment service. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentServiceDefinitionFieldsInner.md b/docs/Model/PaymentServiceDefinitionFieldsInner.md new file mode 100644 index 0000000..cbf1f3e --- /dev/null +++ b/docs/Model/PaymentServiceDefinitionFieldsInner.md @@ -0,0 +1,13 @@ +# # PaymentServiceDefinitionFieldsInner + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**key** | **string** | The key of a field that needs to be submitted. | [optional] +**display_name** | **string** | The name to display for a field in the dashboard. | [optional] +**required** | **bool** | Defines if this field is required when the service is created. | [optional] +**format** | **string** | Defines the type of input that needs to be rendered for this field. | [optional] +**secret** | **bool** | Defines if this field is secret. When `true` the field is not returned when querying the payment service. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentServiceDefinitionSupportedFeatures.md b/docs/Model/PaymentServiceDefinitionSupportedFeatures.md new file mode 100644 index 0000000..5056921 --- /dev/null +++ b/docs/Model/PaymentServiceDefinitionSupportedFeatures.md @@ -0,0 +1,18 @@ +# # PaymentServiceDefinitionSupportedFeatures + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**delayed_capture** | **bool** | Supports [capturing](#operation/capture-transaction) authorized transactions. | [optional] +**network_tokens** | **bool** | Supports passing decrypted digital wallet (e.g. Apple Pay) tokens to the underlying processor. | [optional] +**partial_refunds** | **bool** | Supports [partially refunding](#operation/refund-transaction) captured transactions. | [optional] +**payment_method_tokenization** | **bool** | Supports storing a payment method via tokenization. | [optional] +**payment_method_tokenization_toggle** | **bool** | Supports toggling tokenization for a payment method on or off from the dashboard. | [optional] +**refunds** | **bool** | Supports [refunding](#operation/refund-transaction) captured transactions. | [optional] +**three_d_secure_hosted** | **bool** | Supports hosted 3-D Secure with a redirect. | [optional] +**three_d_secure_pass_through** | **bool** | Supports passing 3-D Secure data to the underlying processor. | [optional] +**verify_credentials** | **bool** | Supports verifying the credentials entered while setting up the underlying processor. This is for internal use only. | [optional] +**void** | **bool** | Supports [voiding](#operation/void-transaction) authorized transactions. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentServiceDefinitions.md b/docs/Model/PaymentServiceDefinitions.md new file mode 100644 index 0000000..4cc9dd7 --- /dev/null +++ b/docs/Model/PaymentServiceDefinitions.md @@ -0,0 +1,12 @@ +# # PaymentServiceDefinitions + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**items** | [**\Gr4vy\model\PaymentServiceDefinition[]**](PaymentServiceDefinition.md) | | [optional] +**limit** | **int** | The limit applied to request. This represents the number of items that are at maximum returned by this request. | [optional] [default to 20] +**next_cursor** | **string** | The cursor that represents the next page of results. Use the `cursor` query parameter to fetch this page of items. | [optional] +**previous_cursor** | **string** | The cursor that represents the next page of results. Use the `cursor` query parameter to fetch this page of items. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentServiceFields.md b/docs/Model/PaymentServiceFields.md new file mode 100644 index 0000000..24090be --- /dev/null +++ b/docs/Model/PaymentServiceFields.md @@ -0,0 +1,10 @@ +# # PaymentServiceFields + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**key** | **string** | The key of the field. | [optional] +**value** | **string** | The value of the field. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentServiceFieldsInner.md b/docs/Model/PaymentServiceFieldsInner.md new file mode 100644 index 0000000..2e8cbbd --- /dev/null +++ b/docs/Model/PaymentServiceFieldsInner.md @@ -0,0 +1,10 @@ +# # PaymentServiceFieldsInner + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**key** | **string** | The key of the field. | [optional] +**value** | **string** | The value of the field. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentServiceRequest.md b/docs/Model/PaymentServiceRequest.md new file mode 100644 index 0000000..d9c7b81 --- /dev/null +++ b/docs/Model/PaymentServiceRequest.md @@ -0,0 +1,26 @@ +# # PaymentServiceRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**display_name** | **string** | A custom name for the payment service. This will be shown in the Admin UI. | +**fields** | [**\Gr4vy\model\PaymentServiceUpdateFieldsInner[]**](PaymentServiceUpdateFieldsInner.md) | A list of fields, each containing a key-value pair for each field defined by the definition for this payment service e.g. for stripe-card `secret_key` is required and so must be sent within this field. | +**accepted_countries** | **string[]** | A list of countries that this payment service needs to support in ISO two-letter code format. | +**accepted_currencies** | **string[]** | A list of currencies that this payment service needs to support in ISO 4217 three-letter code format. | +**three_d_secure_enabled** | **bool** | Defines if 3-D Secure is enabled for the service (can only be enabled if the payment service definition supports the `three_d_secure_hosted` feature). This does not affect pass through 3-D Secure data. | [optional] [default to false] +**acquirer_bin_visa** | **string** | Acquiring institution identification code for VISA. | [optional] +**acquirer_bin_mastercard** | **string** | Acquiring institution identification code for Mastercard. | [optional] +**acquirer_bin_amex** | **string** | Acquiring institution identification code for Amex. | [optional] +**acquirer_bin_discover** | **string** | Acquiring institution identification code for Discover. | [optional] +**acquirer_merchant_id** | **string** | Merchant identifier used in authorisation requests (assigned by the acquirer). | [optional] +**merchant_name** | **string** | Merchant name (assigned by the acquirer). | [optional] +**merchant_country_code** | **string** | ISO 3166-1 numeric three-digit country code. | [optional] +**merchant_category_code** | **string** | Merchant category code that describes the business. | [optional] +**merchant_url** | **string** | Fully qualified URL of 3-D Secure requestor website or customer care site. | [optional] +**active** | **bool** | Defines if this service is currently active or not. | [optional] [default to true] +**position** | **float** | The numeric rank of a payment service. Payment services with a lower position value are processed first. When a payment services is inserted at a position, any payment services with the the same value or higher are shifted down a position accordingly. When left out, the payment service is inserted at the end of the list. | [optional] +**payment_method_tokenization_enabled** | **bool** | Defines if tokenization is enabled for the service (can only be enabled if the payment service definition supports it). | [optional] [default to false] +**payment_service_definition_id** | **string** | The ID of the payment service to use. | + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentServiceRequestAllOf.md b/docs/Model/PaymentServiceRequestAllOf.md new file mode 100644 index 0000000..1c117de --- /dev/null +++ b/docs/Model/PaymentServiceRequestAllOf.md @@ -0,0 +1,9 @@ +# # PaymentServiceRequestAllOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**payment_service_definition_id** | **string** | The ID of the payment service to use. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentServiceSnapshot.md b/docs/Model/PaymentServiceSnapshot.md new file mode 100644 index 0000000..f3a7179 --- /dev/null +++ b/docs/Model/PaymentServiceSnapshot.md @@ -0,0 +1,13 @@ +# # PaymentServiceSnapshot + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **string** | The ID of this payment service. | [optional] +**type** | **string** | The type of this resource. | [optional] +**payment_service_definition_id** | **string** | The ID of the payment service definition used to create this service. | [optional] +**method** | **string** | | [optional] +**display_name** | **string** | The custom name set for this service. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentServiceUpdate.md b/docs/Model/PaymentServiceUpdate.md new file mode 100644 index 0000000..9c20084 --- /dev/null +++ b/docs/Model/PaymentServiceUpdate.md @@ -0,0 +1,25 @@ +# # PaymentServiceUpdate + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**display_name** | **string** | A custom name for the payment service. This will be shown in the Admin UI. | [optional] +**fields** | [**\Gr4vy\model\PaymentServiceUpdateFieldsInner[]**](PaymentServiceUpdateFieldsInner.md) | A list of fields, each containing a key-value pair for each field defined by the definition for this payment service e.g. for stripe-card `secret_key` is required and so must be sent within this field. | [optional] +**accepted_countries** | **string[]** | A list of countries that this payment service needs to support in ISO two-letter code format. | [optional] +**accepted_currencies** | **string[]** | A list of currencies that this payment service needs to support in ISO 4217 three-letter code format. | [optional] +**three_d_secure_enabled** | **bool** | Defines if 3-D Secure is enabled for the service (can only be enabled if the payment service definition supports the `three_d_secure_hosted` feature). This does not affect pass through 3-D Secure data. | [optional] [default to false] +**acquirer_bin_visa** | **string** | Acquiring institution identification code for VISA. | [optional] +**acquirer_bin_mastercard** | **string** | Acquiring institution identification code for Mastercard. | [optional] +**acquirer_bin_amex** | **string** | Acquiring institution identification code for Amex. | [optional] +**acquirer_bin_discover** | **string** | Acquiring institution identification code for Discover. | [optional] +**acquirer_merchant_id** | **string** | Merchant identifier used in authorisation requests (assigned by the acquirer). | [optional] +**merchant_name** | **string** | Merchant name (assigned by the acquirer). | [optional] +**merchant_country_code** | **string** | ISO 3166-1 numeric three-digit country code. | [optional] +**merchant_category_code** | **string** | Merchant category code that describes the business. | [optional] +**merchant_url** | **string** | Fully qualified URL of 3-D Secure requestor website or customer care site. | [optional] +**active** | **bool** | Defines if this service is currently active or not. | [optional] [default to true] +**position** | **float** | The numeric rank of a payment service. Payment services with a lower position value are processed first. When a payment services is inserted at a position, any payment services with the the same value or higher are shifted down a position accordingly. When left out, the payment service is inserted at the end of the list. | [optional] +**payment_method_tokenization_enabled** | **bool** | Defines if tokenization is enabled for the service (can only be enabled if the payment service definition supports it). | [optional] [default to false] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentServiceUpdateFields.md b/docs/Model/PaymentServiceUpdateFields.md new file mode 100644 index 0000000..9c6d7cc --- /dev/null +++ b/docs/Model/PaymentServiceUpdateFields.md @@ -0,0 +1,10 @@ +# # PaymentServiceUpdateFields + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**key** | **string** | The key of the field to set a value for. | +**value** | **string** | The value of a field to set. | + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentServiceUpdateFieldsInner.md b/docs/Model/PaymentServiceUpdateFieldsInner.md new file mode 100644 index 0000000..015e525 --- /dev/null +++ b/docs/Model/PaymentServiceUpdateFieldsInner.md @@ -0,0 +1,10 @@ +# # PaymentServiceUpdateFieldsInner + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**key** | **string** | The key of the field to set a value for. | +**value** | **string** | The value of a field to set. | + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PaymentServices.md b/docs/Model/PaymentServices.md new file mode 100644 index 0000000..80caaec --- /dev/null +++ b/docs/Model/PaymentServices.md @@ -0,0 +1,12 @@ +# # PaymentServices + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**items** | [**\Gr4vy\model\PaymentService[]**](PaymentService.md) | | [optional] +**limit** | **int** | The limit applied to request. This represents the number of items that are at maximum returned by this request. | [optional] [default to 20] +**next_cursor** | **string** | The cursor that represents the next page of results. Use the `cursor` query parameter to fetch this page of items. | [optional] +**previous_cursor** | **string** | The cursor that represents the next page of results. Use the `cursor` query parameter to fetch this page of items. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/RedirectMethods.md b/docs/Model/RedirectMethods.md new file mode 100644 index 0000000..c73eeba --- /dev/null +++ b/docs/Model/RedirectMethods.md @@ -0,0 +1,8 @@ +# # RedirectMethods + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/RedirectRequest.md b/docs/Model/RedirectRequest.md new file mode 100644 index 0000000..a977bfb --- /dev/null +++ b/docs/Model/RedirectRequest.md @@ -0,0 +1,15 @@ +# # RedirectRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**method** | **string** | | +**redirect_url** | **string** | The redirect URL to redirect a buyer to after they have authorized their transaction. | +**currency** | **string** | The ISO-4217 currency code to use this payment method for. This is used to select the payment service to use. | +**country** | **string** | The 2-letter ISO code of the country to use this payment method for. This is used to select the payment service to use. | +**external_identifier** | **string** | An external identifier that can be used to match the account against your own records. | [optional] +**buyer_id** | **string** | The ID of the buyer to associate this payment method to. If this field is provided then the `buyer_external_identifier` field needs to be unset. | [optional] +**buyer_external_identifier** | **string** | The `external_identifier` of the buyer to associate this payment method to. If this field is provided then the `buyer_id` field needs to be unset. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/Refund.md b/docs/Model/Refund.md new file mode 100644 index 0000000..f4ae5fc --- /dev/null +++ b/docs/Model/Refund.md @@ -0,0 +1,16 @@ +# # Refund + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | The type of this resource. Is always `refund`. | [optional] +**id** | **string** | The unique ID of the refund. | [optional] +**transaction_id** | **string** | The ID of the transaction associated with this refund. | [optional] +**status** | **string** | The status of the refund. It may change over time as asynchronous processing events occur. - `processing` - The refund is being processed. - `succeeded` - The refund was successful. - `declined` - The refund was declined by the underlying PSP. - `failed` - The refund could not proceed due to a technical issue. - `voided` - The refund was voided and will not proceed. | [optional] +**currency** | **string** | The currency code for this refund. Will always match that of the associated transaction. | [optional] +**amount** | **int** | The amount requested for this refund. | [optional] +**created_at** | **\DateTime** | The date and time when this refund was created. | [optional] +**updated_at** | **\DateTime** | The date and time when this refund was last updated. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/Refunds.md b/docs/Model/Refunds.md new file mode 100644 index 0000000..0a74b88 --- /dev/null +++ b/docs/Model/Refunds.md @@ -0,0 +1,12 @@ +# # Refunds + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**items** | [**\Gr4vy\model\Refund[]**](Refund.md) | A list of refunds. | [optional] +**limit** | **int** | The limit applied to request. This represents the number of items that are at maximum returned by this request. | [optional] [default to 20] +**next_cursor** | **string** | The cursor that represents the next page of results. Use the `cursor` query parameter to fetch this page of items. | [optional] +**previous_cursor** | **string** | The cursor that represents the next page of results. Use the `cursor` query parameter to fetch this page of items. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/RequiredFields.md b/docs/Model/RequiredFields.md new file mode 100644 index 0000000..7674205 --- /dev/null +++ b/docs/Model/RequiredFields.md @@ -0,0 +1,14 @@ +# # RequiredFields + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**first_name** | **bool** | The first (given) name of the buyer. | [optional] [readonly] +**last_name** | **bool** | The last (family) name of the buyer. | [optional] [readonly] +**email_address** | **bool** | The email address of the buyer. | [optional] [readonly] +**phone_number** | **bool** | The phone number of the buyer. | [optional] [readonly] +**address** | [**\Gr4vy\model\RequiredFieldsAddress**](RequiredFieldsAddress.md) | | [optional] +**tax_id** | **bool** | The tax id code associated with the billing details. | [optional] [readonly] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/RequiredFieldsAddress.md b/docs/Model/RequiredFieldsAddress.md new file mode 100644 index 0000000..aab679f --- /dev/null +++ b/docs/Model/RequiredFieldsAddress.md @@ -0,0 +1,14 @@ +# # RequiredFieldsAddress + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**city** | **bool** | The city for the billing address. | [optional] [readonly] +**country** | **bool** | The country for the billing address. | [optional] [readonly] +**postal_code** | **bool** | The postal code or zip code for the billing address. | [optional] [readonly] +**state** | **bool** | The state, county, or province for the billing address. | [optional] [readonly] +**house_number_or_name** | **bool** | The house number or name for the billing address. Not all payment services use this field but some do. | [optional] [readonly] +**line1** | **bool** | The first line of the billing address. | [optional] [readonly] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/ResetPasswordRequest.md b/docs/Model/ResetPasswordRequest.md new file mode 100644 index 0000000..701e88f --- /dev/null +++ b/docs/Model/ResetPasswordRequest.md @@ -0,0 +1,9 @@ +# # ResetPasswordRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**email_address** | **string** | The email address of the user account to reset. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/SetPasswordRequest.md b/docs/Model/SetPasswordRequest.md new file mode 100644 index 0000000..68bf00f --- /dev/null +++ b/docs/Model/SetPasswordRequest.md @@ -0,0 +1,10 @@ +# # SetPasswordRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**reset_token** | **string** | Unique reset token valid for 7 days. | [optional] +**password** | **string** | The password the user to log in with. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/StatementDescriptor.md b/docs/Model/StatementDescriptor.md new file mode 100644 index 0000000..9b7ab6e --- /dev/null +++ b/docs/Model/StatementDescriptor.md @@ -0,0 +1,13 @@ +# # StatementDescriptor + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **string** | Reflects your doing business as (DBA) name. Other validations: 1. Contains only Latin characters. 2. Contain at least one letter 3. Does not contain any of the special characters `< > \\ ' \" *` 4. Supports: 1. Lower case: `a-z` 2. Upper case: `A-Z` 3. Numbers: `0-9` 4. Spaces: ` ` 5. Special characters: `. , _ - ? + /`. | [optional] +**description** | **string** | A short description about the purchase. Other validations: 1. Contains only Latin characters. 2. Contain at least one letter 3. Does not contain any of the special characters `< > \\ ' \" *` 4. Supports: 1. Lower case: `a-z` 2. Upper case: `A-Z` 3. Numbers: `0-9` 4. Spaces: ` ` 5. Special characters: `. , _ - ? + /`. | [optional] +**city** | **string** | City from which the charge originated. | [optional] +**phone_number** | **string** | The value in the phone number field of a customer's statement which should be formatted according to the [E164 number standard](https://www.twilio.com/docs/glossary/what-e164). | [optional] +**url** | **string** | The value in the URL/web address field of a customer's statement. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/Status.md b/docs/Model/Status.md new file mode 100644 index 0000000..733eebe --- /dev/null +++ b/docs/Model/Status.md @@ -0,0 +1,13 @@ +# # Status + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | The type of this object. This is always `status`. | [optional] +**status** | **string** | The status of this resource being created. This is always `pending`. | [optional] +**resource_type** | **string** | The type of the object that is pending. | [optional] +**resource_id** | **string** | The ID of the object for which this status has been created. | [optional] +**external_identifier** | **string** | An external identifier that can be used to match the record against your own records. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/Statuses.md b/docs/Model/Statuses.md new file mode 100644 index 0000000..76b5d7b --- /dev/null +++ b/docs/Model/Statuses.md @@ -0,0 +1,9 @@ +# # Statuses + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**items** | [**\Gr4vy\model\Status[]**](Status.md) | A list of authorizations. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/TaxId.md b/docs/Model/TaxId.md new file mode 100644 index 0000000..09fdf4c --- /dev/null +++ b/docs/Model/TaxId.md @@ -0,0 +1,10 @@ +# # TaxId + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**value** | **string** | The tax ID for the buyer. | +**kind** | **string** | The kind of tax ID. | + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/ThreeDSecureData.md b/docs/Model/ThreeDSecureData.md new file mode 100644 index 0000000..217a3ef --- /dev/null +++ b/docs/Model/ThreeDSecureData.md @@ -0,0 +1,12 @@ +# # ThreeDSecureData + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**cavv** | **string** | The cardholder authentication value or AAV. | +**eci** | **string** | The electronic commerce indicator for the 3DS transaction. | +**version** | **string** | The version of 3-D Secure that was used. | +**directory_response** | **string** | For 3-D Secure version 1, the enrolment response. For 3-D Secure version , the transaction status from the `ARes`. | + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/ThreeDSecureDataV1.md b/docs/Model/ThreeDSecureDataV1.md new file mode 100644 index 0000000..b3be03b --- /dev/null +++ b/docs/Model/ThreeDSecureDataV1.md @@ -0,0 +1,15 @@ +# # ThreeDSecureDataV1 + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**cavv** | **string** | The cardholder authentication value or AAV. | +**eci** | **string** | The electronic commerce indicator for the 3DS transaction. | +**version** | **string** | The version of 3-D Secure that was used. | +**directory_response** | **string** | For 3-D Secure version 1, the enrolment response. For 3-D Secure version , the transaction status from the `ARes`. | +**authentication_response** | **string** | The authentication response. | +**cavv_algorithm** | **string** | The CAVV Algorithm used. | +**xid** | **string** | The transaction identifier. | + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/ThreeDSecureDataV1AllOf.md b/docs/Model/ThreeDSecureDataV1AllOf.md new file mode 100644 index 0000000..4ff885f --- /dev/null +++ b/docs/Model/ThreeDSecureDataV1AllOf.md @@ -0,0 +1,11 @@ +# # ThreeDSecureDataV1AllOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**authentication_response** | **string** | The authentication response. | +**cavv_algorithm** | **string** | The CAVV Algorithm used. | +**xid** | **string** | The transaction identifier. | + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/ThreeDSecureDataV1V2.md b/docs/Model/ThreeDSecureDataV1V2.md new file mode 100644 index 0000000..360830f --- /dev/null +++ b/docs/Model/ThreeDSecureDataV1V2.md @@ -0,0 +1,16 @@ +# # ThreeDSecureDataV1V2 + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**cavv** | **string** | The cardholder authentication value or AAV. | +**eci** | **string** | The electronic commerce indicator for the 3DS transaction. | +**version** | **string** | The version of 3-D Secure that was used. | +**directory_response** | **string** | For 3-D Secure version 1, the enrolment response. For 3-D Secure version , the transaction status from the `ARes`. | +**authentication_response** | **string** | The transaction status from the challenge result (not required for frictionless). | +**cavv_algorithm** | **string** | The CAVV Algorithm used. | +**xid** | **string** | The transaction identifier. | +**directory_transaction_id** | **string** | The transaction identifier. | + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/ThreeDSecureDataV2.md b/docs/Model/ThreeDSecureDataV2.md new file mode 100644 index 0000000..7d2e566 --- /dev/null +++ b/docs/Model/ThreeDSecureDataV2.md @@ -0,0 +1,14 @@ +# # ThreeDSecureDataV2 + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**cavv** | **string** | The cardholder authentication value or AAV. | +**eci** | **string** | The electronic commerce indicator for the 3DS transaction. | +**version** | **string** | The version of 3-D Secure that was used. | +**directory_response** | **string** | For 3-D Secure version 1, the enrolment response. For 3-D Secure version , the transaction status from the `ARes`. | +**authentication_response** | **string** | The transaction status from the challenge result (not required for frictionless). | [optional] +**directory_transaction_id** | **string** | The transaction identifier. | + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/ThreeDSecureDataV2AllOf.md b/docs/Model/ThreeDSecureDataV2AllOf.md new file mode 100644 index 0000000..6f776fa --- /dev/null +++ b/docs/Model/ThreeDSecureDataV2AllOf.md @@ -0,0 +1,10 @@ +# # ThreeDSecureDataV2AllOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**authentication_response** | **string** | The transaction status from the challenge result (not required for frictionless). | [optional] +**directory_transaction_id** | **string** | The transaction identifier. | + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/ThreeDSecureSummary.md b/docs/Model/ThreeDSecureSummary.md new file mode 100644 index 0000000..81a7056 --- /dev/null +++ b/docs/Model/ThreeDSecureSummary.md @@ -0,0 +1,12 @@ +# # ThreeDSecureSummary + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**version** | **string** | The version of 3DS used for this transaction. | [optional] +**status** | **string** | The status of the 3DS challenge for this transaction. | [optional] +**method** | **string** | The method used for 3DS authentication for this transaction. | [optional] +**response_data** | [**\Gr4vy\model\ThreeDSecureDataV1V2**](ThreeDSecureDataV1V2.md) | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/TokenizedRequest.md b/docs/Model/TokenizedRequest.md new file mode 100644 index 0000000..0e0eb19 --- /dev/null +++ b/docs/Model/TokenizedRequest.md @@ -0,0 +1,12 @@ +# # TokenizedRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**method** | **string** | `id`. | +**id** | **string** | A ID that represents a previously tokenized payment method. This token can represent any type of payment method. | +**redirect_url** | **string** | We strongly recommended providing a `redirect_url` for stored cards when 3-D Secure is enabled and `three_d_secure_data` is not provided. This will be appended with both a transaction ID and status (e.g. `https://example.com/callback? gr4vy_transaction_id=123&gr4vy_transaction_status=capture_succeeded`) after 3-D Secure has completed. | [optional] +**security_code** | **string** | The 3 or 4 digit security code often found on the card. This often referred to as the CVV or CVD. The security code can only be set if the stored payment method represents a card. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/Transaction.md b/docs/Model/Transaction.md new file mode 100644 index 0000000..cb8942d --- /dev/null +++ b/docs/Model/Transaction.md @@ -0,0 +1,40 @@ +# # Transaction + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | The type of this resource. Is always `transaction`. | [optional] +**id** | **string** | The unique identifier for this transaction. | [optional] +**status** | **string** | The status of the transaction. The status may change over time as asynchronous processing events occur. | [optional] +**intent** | **string** | The original `intent` used when the transaction was [created](#operation/authorize-new-transaction). | [optional] +**amount** | **int** | The authorized amount for this transaction. This can be more than the actual captured amount and part of this amount may be refunded. | [optional] +**captured_amount** | **int** | The captured amount for this transaction. This can be the total or a portion of the authorized amount. | [optional] +**refunded_amount** | **int** | The refunded amount for this transaction. This can be the total or a portion of the captured amount. | [optional] +**currency** | **string** | The currency code for this transaction. | [optional] +**country** | **string** | The 2-letter ISO code of the country of the transaction. This is used to filter the payment services that is used to process the transaction. | [optional] +**payment_method** | [**\Gr4vy\model\TransactionPaymentMethod**](TransactionPaymentMethod.md) | | [optional] +**buyer** | [**\Gr4vy\model\TransactionBuyer**](TransactionBuyer.md) | | [optional] +**created_at** | **\DateTime** | The date and time when this transaction was created in our system. | [optional] +**external_identifier** | **string** | An external identifier that can be used to match the transaction against your own records. | [optional] +**updated_at** | **\DateTime** | Defines when the transaction was last updated. | [optional] +**payment_service** | [**\Gr4vy\model\PaymentMethodTokenPaymentService**](PaymentMethodTokenPaymentService.md) | | [optional] +**merchant_initiated** | **bool** | Indicates whether the transaction was initiated by the merchant (true) or customer (false). | [optional] [default to false] +**payment_source** | **string** | The source of the transaction. Defaults to `ecommerce`. | [optional] +**is_subsequent_payment** | **bool** | Indicates whether the transaction represents a subsequent payment coming from a setup recurring payment. Please note there are some restrictions on how this flag may be used. The flag can only be `false` (or not set) when the transaction meets one of the following criteria: * It is not `merchant_initiated`. * `payment_source` is set to `card_on_file`. The flag can only be set to `true` when the transaction meets one of the following criteria: * It is not `merchant_initiated`. * `payment_source` is set to `recurring` or `installment` and `merchant_initiated` is set to `true`. * `payment_source` is set to `card_on_file`. | [optional] [default to false] +**statement_descriptor** | [**\Gr4vy\model\TransactionStatementDescriptor**](TransactionStatementDescriptor.md) | | [optional] +**cart_items** | [**\Gr4vy\model\CartItem[]**](CartItem.md) | An array of cart items that represents the line items of a transaction. | [optional] +**scheme_transaction_id** | **string** | An identifier for the transaction used by the scheme itself, when available. e.g. the Visa Transaction Identifier, or Mastercard Trace ID. | [optional] +**raw_response_code** | **string** | This is the response code received from the payment service. This can be set to any value and is not standardized across different payment services. | [optional] +**raw_response_description** | **string** | This is the response description received from the payment service. This can be set to any value and is not standardized across different payment services. | [optional] +**avs_response_code** | **string** | The response code received from the payment service for the Address Verification Check (AVS). This code is mapped to a standardized Gr4vy AVS response code. - `no_match` - neither address or postal code match - `match` - both address and postal code match - `partial_match_address` - address matches but postal code does not - `partial_match_postcode` - postal code matches but address does not - `unavailable ` - AVS is unavailable for card/country The value of this field can be `null` if the payment service did not provide a response. | [optional] +**cvv_response_code** | **string** | The response code received from the payment service for the Card Verification Value (CVV). This code is mapped to a standardized Gr4vy CVV response code. - `no_match` - the CVV does not match the expected value - `match` - the CVV matches the expected value - `unavailable ` - CVV check unavailable for card our country - `not_provided ` - CVV not provided The value of this field can be `null` if the payment service did not provide a response. | [optional] +**method** | **string** | | [optional] +**payment_service_transaction_id** | **string** | The payment service's unique ID for the transaction. | [optional] +**metadata** | **array** | Additional information about the transaction stored as key-value pairs. | [optional] +**three_d_secure** | [**\Gr4vy\model\ThreeDSecureSummary**](ThreeDSecureSummary.md) | | [optional] +**authorized_at** | **\DateTime** | The date and time when this transaction was authorized in the payment service. Don't use this field to determine whether the transaction was authorized. A `null` value doesn't necessarily imply that the transaction wasn't authorized, it can mean that the payment service doesn't provide this value, that it didn't provide it at the time the transaction was authorized or that the transaction was authorized before the introduction of this field. | [optional] +**captured_at** | **\DateTime** | The date and time when this transaction was captured in the payment service. Don't use this field to determine whether the transaction was captured. A `null` value doesn't necessarily imply that the transaction wasn't captured, it can mean that the payment service doesn't provide this value, that it didn't provide it at the time the transaction was captured or that the transaction was captured before the introduction of this field. | [optional] +**voided_at** | **\DateTime** | The date and time when this transaction was voided in the payment service. Don't use this field to determine whether the transaction was voided. A `null` value doesn't necessarily imply that the transaction wasn't voided, it can mean that the payment service doesn't provide this value, that it didn't provide it at the time the transaction was voided or that the transaction was voided before the introduction of this field. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/TransactionBuyer.md b/docs/Model/TransactionBuyer.md new file mode 100644 index 0000000..35481d8 --- /dev/null +++ b/docs/Model/TransactionBuyer.md @@ -0,0 +1,13 @@ +# # TransactionBuyer + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | The type of this resource. Is always `buyer`. | [optional] +**id** | **string** | The unique Gr4vy ID for this buyer. | [optional] +**external_identifier** | **string** | An external identifier that can be used to match the buyer against your own records. | [optional] +**display_name** | **string** | A unique name for this buyer which is used in the Gr4vy admin panel to give a buyer a human readable name. | [optional] +**billing_details** | [**\Gr4vy\model\BuyerSnapshotBillingDetails**](BuyerSnapshotBillingDetails.md) | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/TransactionCaptureRequest.md b/docs/Model/TransactionCaptureRequest.md new file mode 100644 index 0000000..da4123f --- /dev/null +++ b/docs/Model/TransactionCaptureRequest.md @@ -0,0 +1,9 @@ +# # TransactionCaptureRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**amount** | **int** | The monetary amount to capture an authorization for, in the smallest currency unit for the given currency, for example `1299` cents to create an authorization for `$12.99`. When omitted blank, this will capture the entire amount. Capturing an amount that is greater than the authorized amount is not supported. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/TransactionPaymentMethod.md b/docs/Model/TransactionPaymentMethod.md new file mode 100644 index 0000000..88f8429 --- /dev/null +++ b/docs/Model/TransactionPaymentMethod.md @@ -0,0 +1,20 @@ +# # TransactionPaymentMethod + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | `payment-method`. | [optional] +**id** | **string** | The unique ID of the payment method. | [optional] +**method** | **string** | | [optional] +**external_identifier** | **string** | An external identifier that can be used to match the payment method against your own records. | [optional] +**label** | **string** | A label for the payment method. This can be the last 4 digits for a card, or the email address for an alternative payment method. | [optional] +**scheme** | **string** | An additional label used to differentiate different sub-types of a payment method. Most notably this can include the type of card used in a transaction. | [optional] +**expiration_date** | **string** | The expiration date for this payment method. This is mostly used by cards where the card might have an expiration date. | [optional] +**approval_target** | **string** | The browser target that an approval URL must be opened in. If `any` or `null`, then there is no specific requirement. | [optional] +**approval_url** | **string** | The optional URL that the buyer needs to be redirected to to further authorize their payment. | [optional] +**currency** | **string** | The ISO-4217 currency code that this payment method can be used for. If this value is `null` the payment method may be used for multiple currencies. | [optional] +**country** | **string** | The 2-letter ISO code of the country this payment method can be used for. If this value is `null` the payment method may be used in multiple countries. | [optional] +**details** | [**\Gr4vy\model\PaymentMethodDetailsCard**](PaymentMethodDetailsCard.md) | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/TransactionPaymentMethodRequest.md b/docs/Model/TransactionPaymentMethodRequest.md new file mode 100644 index 0000000..9a3ce78 --- /dev/null +++ b/docs/Model/TransactionPaymentMethodRequest.md @@ -0,0 +1,17 @@ +# # TransactionPaymentMethodRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**method** | **string** | | +**number** | **string** | The 13-19 digit number for this credit card as it can be found on the front of the card. If a card has been stored with us previously, this number will represent the unique tokenized card ID provided via our API. | [optional] +**expiration_date** | **string** | The expiration date of the card, formatted `MM/YY`. If a card has been previously stored with us this value is optional. If the `number` of this card represents a tokenized card, then this value is ignored. | [optional] +**security_code** | **string** | The 3 or 4 digit security code often found on the card. This often referred to as the CVV or CVD. If the `number` of this card represents a tokenized card, then this value is ignored. | [optional] +**external_identifier** | **string** | An external identifier that can be used to match the card against your own records. | [optional] +**buyer_id** | **string** | The ID of the buyer to associate this payment method to. If this field is provided then the `buyer_external_identifier` field needs to be unset. | [optional] +**buyer_external_identifier** | **string** | The `external_identifier` of the buyer to associate this payment method to. If this field is provided then the `buyer_id` field needs to be unset. | [optional] +**redirect_url** | **string** | The redirect URL to redirect a buyer to after they have authorized their transaction or payment method. This only applies to payment methods that require buyer approval. | [optional] +**id** | **string** | An identifier for a previously tokenized payment method. This id can represent any type of payment method. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/TransactionRefundRequest.md b/docs/Model/TransactionRefundRequest.md new file mode 100644 index 0000000..2a96c59 --- /dev/null +++ b/docs/Model/TransactionRefundRequest.md @@ -0,0 +1,9 @@ +# # TransactionRefundRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**amount** | **int** | The amount requested to refund. If omitted, a full refund will be requested. Otherwise, the amount must be lower than or equal to the remaining balance in the associated transaction. Negative and zero-amount refunds are not supported. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/TransactionRefundRequestDeprecated.md b/docs/Model/TransactionRefundRequestDeprecated.md new file mode 100644 index 0000000..8252ab9 --- /dev/null +++ b/docs/Model/TransactionRefundRequestDeprecated.md @@ -0,0 +1,9 @@ +# # TransactionRefundRequestDeprecated + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**amount** | **int** | The (partial) amount to refund. When omitted blank, this will refund the entire amount. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/TransactionRequest.md b/docs/Model/TransactionRequest.md new file mode 100644 index 0000000..222af7a --- /dev/null +++ b/docs/Model/TransactionRequest.md @@ -0,0 +1,24 @@ +# # TransactionRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**amount** | **int** | The monetary amount to create an authorization for, in the smallest currency unit for the given currency, for example `1299` cents to create an authorization for `$12.99`. If the `intent` is set to `capture`, an amount greater than zero must be supplied. | +**currency** | **string** | A supported ISO-4217 currency code. For redirect requests, this value must match the one specified for `currency` in `payment_method`. | +**country** | **string** | The 2-letter ISO code of the country of the transaction. This is used to filter the payment services that is used to process the transaction. If this value is provided for redirect requests and it's not `null`, it must match the one specified for `country` in `payment_method`. Otherwise, the value specified for `country` in `payment_method` will be assumed implicitly. | [optional] +**payment_method** | [**\Gr4vy\model\TransactionPaymentMethodRequest**](TransactionPaymentMethodRequest.md) | | +**store** | **bool** | Whether or not to also try and store the payment method with us so that it can be used again for future use. This is only supported for payment methods that support this feature. There are also a few restrictions on how the flag may be set: * The flag has to be set to `true` when the `payment_source` is set to `recurring` or `installment`, and `merchant_initiated` is set to `false`. * The flag has to be set to `false` (or not set) when using a previously tokenized payment method. | [optional] [default to false] +**intent** | **string** | Defines the intent of this API call. This determines the desired initial state of the transaction. * `authorize` - (Default) Optionally approves and then authorizes a transaction but does not capture the funds. * `capture` - Optionally approves and then authorizes and captures the funds of the transaction. | [optional] [default to 'authorize'] +**external_identifier** | **string** | An external identifier that can be used to match the transaction against your own records. | [optional] +**three_d_secure_data** | [**\Gr4vy\model\ThreeDSecureDataV1V2**](ThreeDSecureDataV1V2.md) | | [optional] +**merchant_initiated** | **bool** | Indicates whether the transaction was initiated by the merchant (true) or customer (false). | [optional] [default to false] +**payment_source** | **string** | The source of the transaction. Defaults to `ecommerce`. | [optional] +**is_subsequent_payment** | **bool** | Indicates whether the transaction represents a subsequent payment coming from a setup recurring payment. Please note there are some restrictions on how this flag may be used. The flag can only be `false` (or not set) when the transaction meets one of the following criteria: * It is not `merchant_initiated`. * `payment_source` is set to `card_on_file`. The flag can only be set to `true` when the transaction meets one of the following criteria: * It is not `merchant_initiated`. * `payment_source` is set to `recurring` or `installment` and `merchant_initiated` is set to `true`. * `payment_source` is set to `card_on_file`. | [optional] [default to false] +**metadata** | **array** | Any additional information about the transaction that you would like to store as key-value pairs. This data is passed to payment service providers that support it. Please visit https://gr4vy.com/docs/ under `Connections` for more information on how specific providers support metadata. | [optional] +**statement_descriptor** | [**\Gr4vy\model\TransactionStatementDescriptor**](TransactionStatementDescriptor.md) | | [optional] +**cart_items** | [**\Gr4vy\model\CartItem[]**](CartItem.md) | An array of cart items that represents the line items of a transaction. | [optional] +**previous_scheme_transaction_id** | **string** | A scheme's transaction identifier to use in connecting a merchant initiated transaction to a previous customer initiated transaction. If not provided, and a qualifying customer initiated transaction has been previously made, then Gr4vy will populate this value with the identifier returned for that transaction. e.g. the Visa Transaction Identifier, or Mastercard Trace ID. | [optional] +**browser_info** | [**\Gr4vy\model\TransactionRequestBrowserInfo**](TransactionRequestBrowserInfo.md) | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/TransactionRequestBrowserInfo.md b/docs/Model/TransactionRequestBrowserInfo.md new file mode 100644 index 0000000..6701825 --- /dev/null +++ b/docs/Model/TransactionRequestBrowserInfo.md @@ -0,0 +1,18 @@ +# # TransactionRequestBrowserInfo + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**java_enabled** | **bool** | Indicates whether the client browser supports Java. | +**javascript_enabled** | **bool** | Indicates whether the client browser supports JavaScript. | +**language** | **string** | The preferred language of the buyer, usually the language of the browser UI. | +**color_depth** | **float** | The color depth of the screen. | +**screen_height** | **float** | The height of the screen in pixels. | +**screen_width** | **float** | The width of the screen in pixels. | +**time_zone_offset** | **float** | Time-zone offset in minutes between UTC and buyer location. | +**user_device** | **string** | The platform that is being used to access the website. | +**user_agent** | **string** | The user agent string for the current browser. | +**accept_header** | **string** | The `Accept` header of the request from the buyer's browser. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/TransactionStatementDescriptor.md b/docs/Model/TransactionStatementDescriptor.md new file mode 100644 index 0000000..de35028 --- /dev/null +++ b/docs/Model/TransactionStatementDescriptor.md @@ -0,0 +1,13 @@ +# # TransactionStatementDescriptor + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **string** | Reflects your doing business as (DBA) name. Other validations: 1. Contains only Latin characters. 2. Contain at least one letter 3. Does not contain any of the special characters `< > \\ ' \" *` 4. Supports: 1. Lower case: `a-z` 2. Upper case: `A-Z` 3. Numbers: `0-9` 4. Spaces: ` ` 5. Special characters: `. , _ - ? + /`. | [optional] +**description** | **string** | A short description about the purchase. Other validations: 1. Contains only Latin characters. 2. Contain at least one letter 3. Does not contain any of the special characters `< > \\ ' \" *` 4. Supports: 1. Lower case: `a-z` 2. Upper case: `A-Z` 3. Numbers: `0-9` 4. Spaces: ` ` 5. Special characters: `. , _ - ? + /`. | [optional] +**city** | **string** | City from which the charge originated. | [optional] +**phone_number** | **string** | The value in the phone number field of a customer's statement which should be formatted according to the [E164 number standard](https://www.twilio.com/docs/glossary/what-e164). | [optional] +**url** | **string** | The value in the URL/web address field of a customer's statement. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/TransactionSummary.md b/docs/Model/TransactionSummary.md new file mode 100644 index 0000000..8d901a5 --- /dev/null +++ b/docs/Model/TransactionSummary.md @@ -0,0 +1,26 @@ +# # TransactionSummary + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | The type of this resource. Is always `transaction`. | [optional] +**id** | **string** | The unique identifier for this transaction. | [optional] +**status** | **string** | The status of the transaction. The status may change over time as asynchronous processing events occur. | [optional] +**intent** | **string** | The original `intent` used when the transaction was [created](#operation/authorize-new-transaction). | [optional] +**amount** | **int** | The authorized amount for this transaction. This can be more than the actual captured amount and part of this amount may be refunded. | [optional] +**captured_amount** | **int** | The captured amount for this transaction. This can be the total or a portion of the authorized amount. | [optional] +**refunded_amount** | **int** | The refunded amount for this transaction. This can be the total or a portion of the captured amount. | [optional] +**currency** | **string** | The currency code for this transaction. | [optional] +**country** | **string** | The 2-letter ISO code of the country of the transaction. This is used to filter the payment services that is used to process the transaction. | [optional] +**payment_method** | [**\Gr4vy\model\TransactionPaymentMethod**](TransactionPaymentMethod.md) | | [optional] +**buyer** | [**\Gr4vy\model\TransactionBuyer**](TransactionBuyer.md) | | [optional] +**created_at** | **\DateTime** | The date and time when this transaction was created in our system. | [optional] +**external_identifier** | **string** | An external identifier that can be used to match the transaction against your own records. | [optional] +**updated_at** | **\DateTime** | Defines when the transaction was last updated. | [optional] +**payment_service** | [**\Gr4vy\model\PaymentMethodTokenPaymentService**](PaymentMethodTokenPaymentService.md) | | [optional] +**method** | **string** | | [optional] +**raw_response_code** | **string** | This is the response code received from the payment service. This can be set to any value and is not standardized across different payment services. | [optional] +**raw_response_description** | **string** | This is the response description received from the payment service. This can be set to any value and is not standardized across different payment services. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/Transactions.md b/docs/Model/Transactions.md new file mode 100644 index 0000000..a1e9173 --- /dev/null +++ b/docs/Model/Transactions.md @@ -0,0 +1,12 @@ +# # Transactions + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**items** | [**\Gr4vy\model\TransactionSummary[]**](TransactionSummary.md) | A list of transactions. | [optional] +**limit** | **int** | The limit applied to request. This represents the number of items that are at maximum returned by this request. | [optional] [default to 20] +**next_cursor** | **string** | The cursor that represents the next page of results. Use the `cursor` query parameter to fetch this page of items. | [optional] +**previous_cursor** | **string** | The cursor that represents the next page of results. Use the `cursor` query parameter to fetch this page of items. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/TransactionsBatchCaptureRequest.md b/docs/Model/TransactionsBatchCaptureRequest.md new file mode 100644 index 0000000..d80b20e --- /dev/null +++ b/docs/Model/TransactionsBatchCaptureRequest.md @@ -0,0 +1,12 @@ +# # TransactionsBatchCaptureRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**amount** | **int** | The (partial) amount to capture. When left blank, this will capture the entire amount. | +**currency** | **string** | A supported ISO-4217 currency code. | +**external_identifier** | **string** | An external identifier that can be used to match the transaction against your own records. | [optional] +**transaction_id** | **string** | The ID of the transaction to capture. | + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/UserRequest.md b/docs/Model/UserRequest.md new file mode 100644 index 0000000..ff79732 --- /dev/null +++ b/docs/Model/UserRequest.md @@ -0,0 +1,10 @@ +# # UserRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**display_name** | **string** | An external identifier that can be used to match the buyer against your own records. This value needs to be unique for all buyers. | [optional] +**email_address** | **string** | A unique name for this buyer which is used in the Gr4vy admin panel to give a buyer a human readable name. | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/lib/.DS_Store b/lib/.DS_Store new file mode 100644 index 0000000..3f367a9 Binary files /dev/null and b/lib/.DS_Store differ diff --git a/lib/ApiException.php b/lib/ApiException.php new file mode 100644 index 0000000..cde2cc9 --- /dev/null +++ b/lib/ApiException.php @@ -0,0 +1,120 @@ +responseHeaders = $responseHeaders; + $this->responseBody = $responseBody; + } + + /** + * Gets the HTTP response header + * + * @return string[]|null HTTP response header + */ + public function getResponseHeaders() + { + return $this->responseHeaders; + } + + /** + * Gets the HTTP body of the server response either as Json or string + * + * @return \stdClass|string|null HTTP body of the server response either as \stdClass or string + */ + public function getResponseBody() + { + return $this->responseBody; + } + + /** + * Sets the deserialized response object (during deserialization) + * + * @param mixed $obj Deserialized response object + * + * @return void + */ + public function setResponseObject($obj) + { + $this->responseObject = $obj; + } + + /** + * Gets the deserialized 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..9d41a04 --- /dev/null +++ b/lib/Configuration.php @@ -0,0 +1,527 @@ +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 null|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 null|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 boolean format for query string. + * + * @param string $booleanFormatForQueryString Boolean format for query string + * + * @return $this + */ + public function setBooleanFormatForQueryString(string $booleanFormat) + { + $this->booleanFormatForQueryString = $booleanFormat; + + return $this; + } + + /** + * Gets boolean format for query string. + * + * @return string Boolean format for query string + */ + public function getBooleanFormatForQueryString(): string + { + return $this->booleanFormatForQueryString; + } + + /** + * 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 default 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 (Gr4vy) Debug Report:' . PHP_EOL; + $report .= ' OS: ' . php_uname() . PHP_EOL; + $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; + $report .= ' The version of the OpenAPI document: 1.1.0-beta' . 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 null|string API key with the prefix + */ + public function getApiKeyWithPrefix($apiKeyIdentifier) + { + $prefix = $this->getApiKeyPrefix($apiKeyIdentifier); + $apiKey = $this->getApiKey($apiKeyIdentifier); + + if ($apiKey === null) { + return null; + } + + if ($prefix === null) { + $keyWithPrefix = $apiKey; + } else { + $keyWithPrefix = $prefix . ' ' . $apiKey; + } + + return $keyWithPrefix; + } + + /** + * Returns an array of host settings + * + * @return array an array of host settings + */ + public function getHostSettings() + { + return [ + [ + "url" => "https://api.{gr4vy_id}.gr4vy.app", + "description" => "No description provided", + "variables" => [ + "gr4vy_id" => [ + "description" => "The subdomain for your Gr4vy instance.", + "default_value" => "plantly", + ] + ] + ] + ]; + } + + /** + * Returns URL based on the index and variables + * + * @param int $index index of the host settings + * @param array|null $variables hash of variable and the corresponding value (optional) + * @return string URL based on host settings + */ + public function getHostFromSettings($index, $variables = null) + { + if (null === $variables) { + $variables = []; + } + + $hosts = $this->getHostSettings(); + + // check array index out of bound + if ($index < 0 || $index >= sizeof($hosts)) { + throw new \InvalidArgumentException("Invalid index $index when selecting the host. Must be less than ".sizeof($hosts)); + } + + $host = $hosts[$index]; + $url = $host["url"]; + + // go through variable and assign a value + foreach ($host["variables"] ?? [] as $name => $variable) { + if (array_key_exists($name, $variables)) { // check to see if it's in the variables provided by the user + if (in_array($variables[$name], $variable["enum_values"], true)) { // check to see if the value is in the enum + $url = str_replace("{".$name."}", $variables[$name], $url); + } else { + throw new \InvalidArgumentException("The variable `$name` in the host URL has invalid value ".$variables[$name].". Must be ".join(',', $variable["enum_values"])."."); + } + } else { + // use default value + $url = str_replace("{".$name."}", $variable["default_value"], $url); + } + } + + return $url; + } +} diff --git a/lib/Gr4vyConfig.php b/lib/Gr4vyConfig.php index b1397ab..eccd838 100644 --- a/lib/Gr4vyConfig.php +++ b/lib/Gr4vyConfig.php @@ -16,12 +16,11 @@ class Gr4vyConfig protected $host; protected $debug = false; protected $environment; - protected $merchantAccountId = ""; /** * Constructor */ - public function __construct($gr4vyId, $privateKeyLocation, $debug=false, $environment="sandbox", $merchantAccountId="") + public function __construct($gr4vyId, $privateKeyLocation, $debug=false, $environment="sandbox") { $this->gr4vyId = $gr4vyId; $this->privateKeyLocation = $privateKeyLocation; @@ -29,7 +28,6 @@ public function __construct($gr4vyId, $privateKeyLocation, $debug=false, $enviro $this->environment = $environment; $apiPrefix = $environment === "sandbox" ? "sandbox." : ""; $this->host = "https://api." . $apiPrefix . $gr4vyId .".gr4vy.app"; - $this->merchantAccountId = $merchantAccountId; } public function setGr4vyId($gr4vyId) @@ -43,17 +41,6 @@ public function getGr4vyId() return $this->$gr4vyId; } - public function setMerchantAccountId($merchantAccountId) - { - $this->merchantAccountId = $merchantAccountId; - return $this; - } - - public function getMerchantAccountId() - { - return $this->$merchantAccountId; - } - public function setPrivateKeyLocation($privateKeyLocation) { $this->privateKeyLocation = $privateKeyLocation; @@ -87,18 +74,25 @@ public function getDebug() return $this->debug; } - public function getEmbedToken($embed, $checkoutSessionId = null) { - $scopes = array("embed"); - return self::getToken($this->privateKeyLocation, $scopes, $embed, $checkoutSessionId); + public function getConfig() + { + $scopes = array("*.read", "*.write"); + $accessToken = self::getToken($this->privateKeyLocation, $scopes); + $config = Gr4vyConfiguration::getDefaultConfiguration() + ->setAccessToken($accessToken) + ->setHost($this->getHost()) + ->setUserAgent("Gr4vy SDK PHP") + ->setDebug($this->debug); + + return $config; } - public function getEmbedTokenWithCheckoutSession($embed) { + public function getEmbedToken($embed) { $scopes = array("embed"); - $checkoutSession = $this->newCheckoutSession(); - return self::getToken($this->privateKeyLocation, $scopes, $embed, $checkoutSession["id"]); + return self::getToken($this->privateKeyLocation, $scopes, $embed); } - public static function getToken($private_key, $scopes = array(), $embed = array(), $checkoutSessionId = null) { + public static function getToken($private_key, $scopes = array(), $embed = array()) { $keyVal = getenv("PRIVATE_KEY"); if (!isset($keyVal) || empty($keyVal)) { @@ -119,13 +113,13 @@ public static function getToken($private_key, $scopes = array(), $embed = array( $now = new DateTimeImmutable(); $tokenBuilder = $config->builder() // Configures the issuer (iss claim) - ->issuedBy('Gr4vy SDK 0.21.0') + ->issuedBy('Gr4vy SDK 0.14.0') // Configures the id (jti claim) ->identifiedBy(self::gen_uuid()) // Configures the time that the token was issue (iat claim) ->issuedAt($now) // Configures the time that the token can be used (nbf claim) - ->canOnlyBeUsedAfter($now)#->modify('+1 minute')) + ->canOnlyBeUsedAfter($now->modify('+1 minute')) // Configures the expiration time of the token (exp claim) ->expiresAt($now->modify('+1 hour')) // Configures a new claim, called "uid" @@ -137,10 +131,6 @@ public static function getToken($private_key, $scopes = array(), $embed = array( $tokenBuilder = $tokenBuilder->withClaim('embed', $embed); } - if (isset($checkoutSessionId)) { - $tokenBuilder = $tokenBuilder->withClaim('checkout_session_id', $checkoutSessionId); - } - return $tokenBuilder->getToken($config->signer(), $config->signingKey())->toString(); } @@ -191,6 +181,13 @@ private static function getThumbprint($private_key) { $xStr = pack('C*', ...$x_byte_array); $yStr = pack('C*', ...$y_byte_array); + // print_r("====x====\n"); + // // print_r($x_byte_array . "\n"); + // var_dump($x_byte_array); + // print_r("====y====\n"); + // // print_r($y_byte_array . "\n"); + // var_dump($y_byte_array); + $jsonData = array( 'crv' => "P-521",//$keyInfo['ec']["curve_name"], 'kty' => 'EC', @@ -202,249 +199,4 @@ private static function getThumbprint($private_key) { $b = hash("SHA256", $data, true); return rtrim(str_replace(['+', '/'], ['-', '_'], base64_encode($b)), '='); } - - private function get($endpoint, $params = array()) { - $query = ""; - if (count($params) > 0) { - $query = http_build_query($params); - } - $url = $this->host . $endpoint . "?" . $query; - - $scopes = array("*.read", "*.write"); - $accessToken = self::getToken($this->privateKeyLocation, $scopes); - - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_HTTPHEADER, array( - 'Authorization: Bearer ' . $accessToken, - 'Content-Type:application/json', - "X-GR4VY-MERCHANT-ACCOUNT-ID:" . $this->merchantAccountId - ) - ); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - $responseData = curl_exec($ch); - if(curl_errno($ch)) { - return curl_error($ch); - } - curl_close($ch); - return json_decode($responseData, true); - } - - private function post($endpoint, $data) { - $url = $this->host . $endpoint; - - $scopes = array("*.read", "*.write"); - $accessToken = self::getToken($this->privateKeyLocation, $scopes); - - $payload = json_encode($data); - - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_HTTPHEADER, array( - 'Authorization: Bearer ' . $accessToken, - 'Content-Type:application/json', - "X-GR4VY-MERCHANT-ACCOUNT-ID:" . $this->merchantAccountId - ) - ); - curl_setopt($ch, CURLOPT_POST, 1); - curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - $responseData = curl_exec($ch); - if(curl_errno($ch)) { - return curl_error($ch); - } - curl_close($ch); - return json_decode($responseData, true); - } - - private function put($endpoint, $data) { - $url = $this->host . $endpoint; - - $scopes = array("*.read", "*.write"); - $accessToken = self::getToken($this->privateKeyLocation, $scopes); - - $payload = json_encode($data); - - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_HTTPHEADER, array( - 'Authorization: Bearer ' . $accessToken, - 'Content-Type:application/json', - "X-GR4VY-MERCHANT-ACCOUNT-ID:" . $this->merchantAccountId - ) - ); - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); - curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - $responseData = curl_exec($ch); - if(curl_errno($ch)) { - return curl_error($ch); - } - curl_close($ch); - return json_decode($responseData, true); - } - - private function delete($endpoint) { - $url = $this->host . $endpoint; - $scopes = array("*.read", "*.write"); - $accessToken = self::getToken($this->privateKeyLocation, $scopes); - - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_HTTPHEADER, array( - 'Authorization: Bearer ' . $accessToken, - 'Content-Type:application/json', - "X-GR4VY-MERCHANT-ACCOUNT-ID:" . $this->merchantAccountId - ) - ); - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); - $responseData = curl_exec($ch); - $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); - if(curl_errno($ch)) { - return curl_error($ch); - } - curl_close($ch); - if ($httpcode === 204) { - return array("success"=>true); - } - return json_decode($responseData, true); - } - - public function addBuyer($buyer_request) { - $response = $this->post("/buyers", $buyer_request); - return $response; - } - public function getBuyer($buyer_id) { - $response = $this->get("/buyers/" . $buyer_id); - return $response; - } - public function updateBuyer($buyer_id, $buyer_request) { - $response = $this->put("/buyers/" . $buyer_id, $buyer_request); - return $response; - } - public function listBuyers($params = array()) { - $response = $this->get("/buyers", $params); - return $response; - } - public function deleteBuyer($buyer_id) { - $response = $this->delete("/buyers/" . $buyer_id); - return $response; - } - - public function storePaymentMethod($payment_method_request) { - $response = $this->post("/payment-methods", $payment_method_request); - return $response; - } - public function getPaymentMethod($payment_method_id) { - $response = $this->get("/payment-methods/" . $payment_method_id); - return $response; - } - public function listPaymentMethods($params = array()) { - $response = $this->get("/payment-methods", $params); - return $response; - } - public function listBuyerPaymentMethods($buyer_id) { - $response = $this->get("/buyers/payment-methods?buyer_id=" . $buyer_id); - return $response; - } - public function deletePaymentMethod($buyer_id) { - $response = $this->delete("/payment-methods/" . $buyer_id); - return $response; - } - - public function listPaymentOptions($params = array()) { - $response = $this->get("/payment-options", $params); - return $response; - } - public function postListPaymentOptions($payment_options_request) { - $response = $this->post("/payment-options", $payment_options_request); - return $response; - } - - public function listPaymentServiceDefinitions($params = array()) { - $response = $this->get("/payment-service-definitions", $params); - return $response; - } - public function getPaymentServiceDefinition($psd_id) { - $response = $this->get("/payment-service-definitions/" . $psd_id); - return $response; - } - - public function addPaymentService($payment_service_request) { - $response = $this->post("/payment-services", $payment_service_request); - return $response; - } - public function getPaymentService($payment_service_id) { - $response = $this->get("/payment-services/" . $payment_service_id); - return $response; - } - public function updatePaymentService($payment_service_id, $payment_service_request) { - $response = $this->put("/payment-services/" . $payment_service_id, $payment_service_request); - return $response; - } - public function listPaymentServices($params = array()) { - $response = $this->get("/payment-services", $params); - return $response; - } - public function deletePaymentService($payment_service_id) { - $response = $this->delete("/payment-services/" . $payment_service_id); - return $response; - } - public function authorizeNewTransaction($transaction_request) { - $response = $this->post("/transactions", $transaction_request); - return $response; - } - public function getTransaction($transaction_id) { - $response = $this->get("/transactions/" . $transaction_id); - return $response; - } - public function captureTransaction($transaction_id, $transaction_request) { - $response = $this->post("/transactions/" . $transaction_id . "/capture", $transaction_request); - return $response; - } - public function listTransactions($params = array()) { - $response = $this->get("/transactions", $params); - return $response; - } - public function getRefund($refund_id) { - $response = $this->get("/refunds/" . $refund_id); - return $response; - } - public function refundTransaction($transaction_id, $refund_request) { - $response = $this->post("/transactions/" . $transaction_id . "/refunds", $refund_request); - return $response; - } - public function voidTransaction($transaction_id, $request = array()) { - $response = $this->post("/transactions/" . $transaction_id . "/void", $request); - return $response; - } - public function newCheckoutSession($request = array()) { - $response = $this->post("/checkout/sessions", $request); - return $response; - } - public function updateCheckoutSession($checkout_session_id, $request = array()) { - $response = $this->put("/checkout/sessions/" . $checkout_session_id, $request); - return $response; - } - public function updateCheckoutSessionFields($checkout_session_id, $request = array()) { - $response = $this->put("/checkout/sessions/" . $checkout_session_id . "/fields", $request); - return $response; - } - public function deleteCheckoutSession($checkout_session_id) { - $response = $this->delete("/checkout/sessions/" . $checkout_session_id); - return $response; - } - public function getReportExecution($report_execution_id) { - $response = $this->get("/report-executions/" . $report_execution_id); - return $response; - } - public function generateReportDownloadUrl($report_id, $report_execution_id, $request = array()) { - $response = $this->post("/reports/". $report_id . "/executions/" . $report_execution_id . "/url", $request); - return $response; - } } diff --git a/lib/HeaderSelector.php b/lib/HeaderSelector.php new file mode 100644 index 0000000..682560e --- /dev/null +++ b/lib/HeaderSelector.php @@ -0,0 +1,109 @@ +selectAcceptHeader($accept); + if ($accept !== null) { + $headers['Accept'] = $accept; + } + + $headers['Content-Type'] = $this->selectContentTypeHeader($contentTypes); + $headers['X-GR4VY-MERCHANT-ACCOUNT-ID'] = "default"; + 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 null|string Accept (e.g. application/json) + */ + private function selectAcceptHeader($accept) + { + if (count($accept) === 0 || (count($accept) === 1 && $accept[0] === '')) { + return null; + } elseif ($jsonAccept = preg_grep('~(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$~', $accept)) { + return implode(',', $jsonAccept); + } 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/MerchantAccountHeaderSelector.php b/lib/MerchantAccountHeaderSelector.php new file mode 100644 index 0000000..0071791 --- /dev/null +++ b/lib/MerchantAccountHeaderSelector.php @@ -0,0 +1,116 @@ +merchantAccountId = $merchantAccountId; + } + + /** + * @param string[] $accept + * @param string[] $contentTypes + * @return array + */ + public function selectHeaders($accept, $contentTypes) + { + $headers = []; + + $accept = $this->selectAcceptHeader($accept); + if ($accept !== null) { + $headers['Accept'] = $accept; + } + + $headers['Content-Type'] = $this->selectContentTypeHeader($contentTypes); + $headers['X-GR4VY-MERCHANT-ACCOUNT-ID'] = $this->merchantAccountId; + 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 null|string Accept (e.g. application/json) + */ + private function selectAcceptHeader($accept) + { + if (count($accept) === 0 || (count($accept) === 1 && $accept[0] === '')) { + return null; + } elseif ($jsonAccept = preg_grep('~(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$~', $accept)) { + return implode(',', $jsonAccept); + } else { + return implode(',', $accept); + } + } + + /** + * Return the content type based on an array of content-type provided + * + * @param string[] $contentType Array fo content-type + * + * @return string Content-Type (e.g. application/json) + */ + private function selectContentTypeHeader($contentType) + { + if (count($contentType) === 0 || (count($contentType) === 1 && $contentType[0] === '')) { + return 'application/json'; + } elseif (preg_grep("/application\/json/i", $contentType)) { + return 'application/json'; + } else { + return implode(',', $contentType); + } + } +} diff --git a/lib/ObjectSerializer.php b/lib/ObjectSerializer.php new file mode 100644 index 0000000..914895e --- /dev/null +++ b/lib/ObjectSerializer.php @@ -0,0 +1,505 @@ +format('Y-m-d') : $data->format(self::$dateTimeFormat); + } + + if (is_array($data)) { + foreach ($data as $property => $value) { + $data[$property] = self::sanitizeForSerialization($value); + } + return $data; + } + + if (is_object($data)) { + $values = []; + if ($data instanceof ModelInterface) { + $formats = $data::openAPIFormats(); + foreach ($data::openAPITypes() as $property => $openAPIType) { + $getter = $data::getters()[$property]; + $value = $data->$getter(); + if ($value !== null && !in_array($openAPIType, ['\DateTime', '\SplFileObject', 'array', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) { + $callable = [$openAPIType, 'getAllowableEnumValues']; + if (is_callable($callable)) { + /** array $callable */ + $allowedEnumTypes = $callable(); + if (!in_array($value, $allowedEnumTypes, true)) { + $imploded = implode("', '", $allowedEnumTypes); + throw new \InvalidArgumentException("Invalid value for enum '$openAPIType', must be one of: '$imploded'"); + } + } + } + if ($value !== null) { + $values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value, $openAPIType, $formats[$property]); + } + } + } else { + foreach($data as $property => $value) { + $values[$property] = self::sanitizeForSerialization($value); + } + } + return (object)$values; + } else { + return (string)$data; + } + } + + /** + * Sanitize filename by removing path. + * e.g. ../../sun.gif becomes sun.gif + * + * @param string $filename filename to be sanitized + * + * @return string the sanitized filename + */ + public static function sanitizeFilename($filename) + { + if (preg_match("/.*[\/\\\\](.*)$/", $filename, $match)) { + return $match[1]; + } else { + return $filename; + } + } + + /** + * Shorter timestamp microseconds to 6 digits length. + * + * @param string $timestamp Original timestamp + * + * @return string the shorten timestamp + */ + public static function sanitizeTimestamp($timestamp) + { + if (!is_string($timestamp)) return $timestamp; + + return preg_replace('/(:\d{2}.\d{6})\d*/', '$1', $timestamp); + } + + /** + * 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 query parameter properties and turn it into an array suitable for + * native http_build_query or GuzzleHttp\Psr7\Query::build. + * + * @param mixed $value Parameter value + * @param string $paramName Parameter name + * @param string $openApiType OpenAPIType eg. array or object + * @param string $style Parameter serialization style + * @param bool $explode Parameter explode option + * @param bool $required Whether query param is required or not + * + * @return array + */ + public static function toQueryValue( + $value, + string $paramName, + string $openApiType = 'string', + string $style = 'form', + bool $explode = true, + bool $required = true + ): array { + if ( + empty($value) + && ($value !== false || $openApiType !== 'boolean') // if $value === false and $openApiType ==='boolean' it isn't empty + ) { + if ($required) { + return ["{$paramName}" => '']; + } else { + return []; + } + } + + $query = []; + $value = (in_array($openApiType, ['object', 'array'], true)) ? (array)$value : $value; + + // since \GuzzleHttp\Psr7\Query::build fails with nested arrays + // need to flatten array first + $flattenArray = function ($arr, $name, &$result = []) use (&$flattenArray, $style, $explode) { + if (!is_array($arr)) return $arr; + + foreach ($arr as $k => $v) { + $prop = ($style === 'deepObject') ? $prop = "{$name}[{$k}]" : $k; + + if (is_array($v)) { + $flattenArray($v, $prop, $result); + } else { + if ($style !== 'deepObject' && !$explode) { + // push key itself + $result[] = $prop; + } + $result[$prop] = $v; + } + } + return $result; + }; + + $value = $flattenArray($value, $paramName); + + if ($openApiType === 'object' && ($style === 'deepObject' || $explode)) { + return $value; + } + + if ('boolean' === $openApiType && is_bool($value)) { + $value = self::convertBoolToQueryStringFormat($value); + } + + // handle style in serializeCollection + $query[$paramName] = ($explode) ? $value : self::serializeCollection((array)$value, $style); + + return $query; + } + + /** + * Convert boolean value to format for query string. + * + * @param bool $value Boolean value + * + * @return int|string Boolean value in format + */ + public static function convertBoolToQueryStringFormat(bool $value) + { + if (Configuration::BOOLEAN_FORMAT_STRING == Configuration::getDefaultConfiguration()->getBooleanFormatForQueryString()) { + return $value ? 'true' : 'false'; + } + + return (int) $value; + } + + /** + * 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) + { + $callable = [$value, 'toHeaderValue']; + if (is_callable($callable)) { + return $callable(); + } + + 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 + * If it's a boolean, convert it to "true" or "false". + * + * @param string|bool|\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(self::$dateTimeFormat); + } elseif (is_bool($value)) { + return $value ? 'true' : 'false'; + } else { + return (string) $value; + } + } + + /** + * Serialize an array to a string. + * + * @param array $collection collection to serialize to a string + * @param string $style 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, $style, $allowCollectionFormatMulti = false) + { + if ($allowCollectionFormatMulti && ('multi' === $style)) { + // 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 ($style) { + case 'pipeDelimited': + case 'pipes': + return implode('|', $collection); + + case 'tsv': + return implode("\t", $collection); + + case 'spaceDelimited': + case 'ssv': + return implode(' ', $collection); + + case 'simple': + case 'csv': + // Deliberate fall through. CSV is default format. + default: + return implode(',', $collection); + } + } + + /** + * Deserialize a JSON string into an object + * + * @param mixed $data object or primitive to be deserialized + * @param string $class class name is passed as a string + * @param string[] $httpHeaders HTTP headers + * @param string $discriminator discriminator if polymorphism is used + * + * @return object|array|null a single or an array of $class instances + */ + public static function deserialize($data, $class, $httpHeaders = null) + { + if (null === $data) { + return null; + } + + if (strcasecmp(substr($class, -2), '[]') === 0) { + $data = is_string($data) ? json_decode($data) : $data; + + if (!is_array($data)) { + throw new \InvalidArgumentException("Invalid array '$class'"); + } + + $subClass = substr($class, 0, -2); + $values = []; + foreach ($data as $key => $value) { + $values[] = self::deserialize($value, $subClass, null); + } + return $values; + } + + if (preg_match('/^(array<|map\[)/', $class)) { // for associative array e.g. array + $data = is_string($data) ? json_decode($data) : $data; + settype($data, 'array'); + $inner = substr($class, 4, -1); + $deserialized = []; + if (strrpos($inner, ",") !== false) { + $subClass_array = explode(',', $inner, 2); + $subClass = $subClass_array[1]; + foreach ($data as $key => $value) { + $deserialized[$key] = self::deserialize($value, $subClass, null); + } + } + return $deserialized; + } + + if ($class === 'object') { + settype($data, 'array'); + return $data; + } elseif ($class === 'mixed') { + settype($data, gettype($data)); + return $data; + } + + if ($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)) { + try { + return new \DateTime($data); + } catch (\Exception $exception) { + // Some API's return a date-time with too high nanosecond + // precision for php's DateTime to handle. + // With provided regexp 6 digits of microseconds saved + return new \DateTime(self::sanitizeTimestamp($data)); + } + } else { + return null; + } + } + + if ($class === '\SplFileObject') { + $data = Utils::streamFor($data); + + /** @var \Psr\Http\Message\StreamInterface $data */ + + // determine file name + if ( + is_array($httpHeaders) + && array_key_exists('Content-Disposition', $httpHeaders) + && preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeaders['Content-Disposition'], $match) + ) { + $filename = Configuration::getDefaultConfiguration()->getTempFolderPath() . DIRECTORY_SEPARATOR . self::sanitizeFilename($match[1]); + } else { + $filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), ''); + } + + $file = fopen($filename, 'w'); + while ($chunk = $data->read(200)) { + fwrite($file, $chunk); + } + fclose($file); + + return new \SplFileObject($filename, 'r'); + } + + /** @psalm-suppress ParadoxicalCondition */ + if (in_array($class, ['\DateTime', '\SplFileObject', 'array', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) { + settype($data, $class); + return $data; + } + + + if (method_exists($class, 'getAllowableEnumValues')) { + if (!in_array($data, $class::getAllowableEnumValues(), true)) { + $imploded = implode("', '", $class::getAllowableEnumValues()); + throw new \InvalidArgumentException("Invalid value for enum '$class', must be one of: '$imploded'"); + } + return $data; + } else { + $data = is_string($data) ? json_decode($data) : $data; + // If a discriminator is defined and points to a valid subclass, use it. + $discriminator = $class::DISCRIMINATOR; + if (!empty($discriminator) && isset($data->{$discriminator}) && is_string($data->{$discriminator})) { + $subclass = '\Gr4vy\Model\\' . $data->{$discriminator}; + if (is_subclass_of($subclass, $class)) { + $class = $subclass; + } + } + + /** @var ModelInterface $instance */ + $instance = new $class(); + foreach ($instance::openAPITypes() as $property => $type) { + $propertySetter = $instance::setters()[$property]; + + if (!isset($propertySetter) || !isset($data->{$instance::attributeMap()[$property]})) { + continue; + } + + if (isset($data->{$instance::attributeMap()[$property]})) { + $propertyValue = $data->{$instance::attributeMap()[$property]}; + $instance->$propertySetter(self::deserialize($propertyValue, $type, null)); + } + } + return $instance; + } + } + + /** + * Native `http_build_query` wrapper. + * @see https://www.php.net/manual/en/function.http-build-query + * + * @param array|object $data May be an array or object containing properties. + * @param string $numeric_prefix If numeric indices are used in the base array and this parameter is provided, it will be prepended to the numeric index for elements in the base array only. + * @param string|null $arg_separator arg_separator.output is used to separate arguments but may be overridden by specifying this parameter. + * @param int $encoding_type Encoding type. By default, PHP_QUERY_RFC1738. + * + * @return string + */ + public static function buildQuery( + $data, + string $numeric_prefix = '', + ?string $arg_separator = null, + int $encoding_type = \PHP_QUERY_RFC3986 + ): string { + return \GuzzleHttp\Psr7\Query::build($data, $encoding_type); + } +} diff --git a/lib/api/AntiFraudServicesApi.php b/lib/api/AntiFraudServicesApi.php new file mode 100644 index 0000000..6838fdf --- /dev/null +++ b/lib/api/AntiFraudServicesApi.php @@ -0,0 +1,1422 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation addAntiFraudService + * + * New anti-fraud service + * + * @param \Gr4vy\model\AntiFraudServiceCreate $anti_fraud_service_create anti_fraud_service_create (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\AntiFraudService|\Gr4vy\model\ErrorGeneric|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error409DuplicateRecord + */ + public function addAntiFraudService($anti_fraud_service_create = null) + { + list($response) = $this->addAntiFraudServiceWithHttpInfo($anti_fraud_service_create); + return $response; + } + + /** + * Operation addAntiFraudServiceWithHttpInfo + * + * New anti-fraud service + * + * @param \Gr4vy\model\AntiFraudServiceCreate $anti_fraud_service_create (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\AntiFraudService|\Gr4vy\model\ErrorGeneric|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error409DuplicateRecord, HTTP status code, HTTP response headers (array of strings) + */ + public function addAntiFraudServiceWithHttpInfo($anti_fraud_service_create = null) + { + $request = $this->addAntiFraudServiceRequest($anti_fraud_service_create); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 201: + if ('\Gr4vy\model\AntiFraudService' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\AntiFraudService' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\AntiFraudService', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\Gr4vy\model\ErrorGeneric' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\ErrorGeneric' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\ErrorGeneric', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 409: + if ('\Gr4vy\model\Error409DuplicateRecord' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error409DuplicateRecord' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error409DuplicateRecord', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\AntiFraudService'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 201: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\AntiFraudService', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\ErrorGeneric', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 409: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error409DuplicateRecord', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation addAntiFraudServiceAsync + * + * New anti-fraud service + * + * @param \Gr4vy\model\AntiFraudServiceCreate $anti_fraud_service_create (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addAntiFraudServiceAsync($anti_fraud_service_create = null) + { + return $this->addAntiFraudServiceAsyncWithHttpInfo($anti_fraud_service_create) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation addAntiFraudServiceAsyncWithHttpInfo + * + * New anti-fraud service + * + * @param \Gr4vy\model\AntiFraudServiceCreate $anti_fraud_service_create (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addAntiFraudServiceAsyncWithHttpInfo($anti_fraud_service_create = null) + { + $returnType = '\Gr4vy\model\AntiFraudService'; + $request = $this->addAntiFraudServiceRequest($anti_fraud_service_create); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'addAntiFraudService' + * + * @param \Gr4vy\model\AntiFraudServiceCreate $anti_fraud_service_create (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function addAntiFraudServiceRequest($anti_fraud_service_create = null) + { + + $resourcePath = '/anti-fraud-services'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($anti_fraud_service_create)) { + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($anti_fraud_service_create)); + } else { + $httpBody = $anti_fraud_service_create; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deleteAntiFraudService + * + * Delete anti-fraud service + * + * @param string $anti_fraud_service_id The unique ID for an anti-fraud service. (required) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function deleteAntiFraudService($anti_fraud_service_id) + { + $this->deleteAntiFraudServiceWithHttpInfo($anti_fraud_service_id); + } + + /** + * Operation deleteAntiFraudServiceWithHttpInfo + * + * Delete anti-fraud service + * + * @param string $anti_fraud_service_id The unique ID for an anti-fraud service. (required) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of null, HTTP status code, HTTP response headers (array of strings) + */ + public function deleteAntiFraudServiceWithHttpInfo($anti_fraud_service_id) + { + $request = $this->deleteAntiFraudServiceRequest($anti_fraud_service_id); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error404NotFound', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deleteAntiFraudServiceAsync + * + * Delete anti-fraud service + * + * @param string $anti_fraud_service_id The unique ID for an anti-fraud service. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteAntiFraudServiceAsync($anti_fraud_service_id) + { + return $this->deleteAntiFraudServiceAsyncWithHttpInfo($anti_fraud_service_id) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteAntiFraudServiceAsyncWithHttpInfo + * + * Delete anti-fraud service + * + * @param string $anti_fraud_service_id The unique ID for an anti-fraud service. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteAntiFraudServiceAsyncWithHttpInfo($anti_fraud_service_id) + { + $returnType = ''; + $request = $this->deleteAntiFraudServiceRequest($anti_fraud_service_id); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteAntiFraudService' + * + * @param string $anti_fraud_service_id The unique ID for an anti-fraud service. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deleteAntiFraudServiceRequest($anti_fraud_service_id) + { + // verify the required parameter 'anti_fraud_service_id' is set + if ($anti_fraud_service_id === null || (is_array($anti_fraud_service_id) && count($anti_fraud_service_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $anti_fraud_service_id when calling deleteAntiFraudService' + ); + } + + $resourcePath = '/anti-fraud-services/{anti_fraud_service_id}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($anti_fraud_service_id !== null) { + $resourcePath = str_replace( + '{' . 'anti_fraud_service_id' . '}', + ObjectSerializer::toPathValue($anti_fraud_service_id), + $resourcePath + ); + } + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'DELETE', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getAntiFraudService + * + * Get anti-fraud service + * + * @param string $anti_fraud_service_id The unique ID for an anti-fraud service. (required) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\AntiFraudService|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error404NotFound|\Gr4vy\model\ErrorGeneric + */ + public function getAntiFraudService($anti_fraud_service_id) + { + list($response) = $this->getAntiFraudServiceWithHttpInfo($anti_fraud_service_id); + return $response; + } + + /** + * Operation getAntiFraudServiceWithHttpInfo + * + * Get anti-fraud service + * + * @param string $anti_fraud_service_id The unique ID for an anti-fraud service. (required) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\AntiFraudService|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error404NotFound|\Gr4vy\model\ErrorGeneric, HTTP status code, HTTP response headers (array of strings) + */ + public function getAntiFraudServiceWithHttpInfo($anti_fraud_service_id) + { + $request = $this->getAntiFraudServiceRequest($anti_fraud_service_id); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\Gr4vy\model\AntiFraudService' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\AntiFraudService' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\AntiFraudService', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\Gr4vy\model\Error404NotFound' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error404NotFound' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error404NotFound', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + default: + if ('\Gr4vy\model\ErrorGeneric' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\ErrorGeneric' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\ErrorGeneric', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\AntiFraudService'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + '\Gr4vy\model\AntiFraudService', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error404NotFound', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\ErrorGeneric', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getAntiFraudServiceAsync + * + * Get anti-fraud service + * + * @param string $anti_fraud_service_id The unique ID for an anti-fraud service. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getAntiFraudServiceAsync($anti_fraud_service_id) + { + return $this->getAntiFraudServiceAsyncWithHttpInfo($anti_fraud_service_id) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getAntiFraudServiceAsyncWithHttpInfo + * + * Get anti-fraud service + * + * @param string $anti_fraud_service_id The unique ID for an anti-fraud service. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getAntiFraudServiceAsyncWithHttpInfo($anti_fraud_service_id) + { + $returnType = '\Gr4vy\model\AntiFraudService'; + $request = $this->getAntiFraudServiceRequest($anti_fraud_service_id); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getAntiFraudService' + * + * @param string $anti_fraud_service_id The unique ID for an anti-fraud service. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getAntiFraudServiceRequest($anti_fraud_service_id) + { + // verify the required parameter 'anti_fraud_service_id' is set + if ($anti_fraud_service_id === null || (is_array($anti_fraud_service_id) && count($anti_fraud_service_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $anti_fraud_service_id when calling getAntiFraudService' + ); + } + + $resourcePath = '/anti-fraud-services/{anti_fraud_service_id}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($anti_fraud_service_id !== null) { + $resourcePath = str_replace( + '{' . 'anti_fraud_service_id' . '}', + ObjectSerializer::toPathValue($anti_fraud_service_id), + $resourcePath + ); + } + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateAntiFraudService + * + * Update anti-fraud service + * + * @param string $anti_fraud_service_id The unique ID for an anti-fraud service. (required) + * @param \Gr4vy\model\AntiFraudServiceUpdate $anti_fraud_service_update anti_fraud_service_update (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\AntiFraudService|\Gr4vy\model\ErrorGeneric|\Gr4vy\model\Error401Unauthorized + */ + public function updateAntiFraudService($anti_fraud_service_id, $anti_fraud_service_update = null) + { + list($response) = $this->updateAntiFraudServiceWithHttpInfo($anti_fraud_service_id, $anti_fraud_service_update); + return $response; + } + + /** + * Operation updateAntiFraudServiceWithHttpInfo + * + * Update anti-fraud service + * + * @param string $anti_fraud_service_id The unique ID for an anti-fraud service. (required) + * @param \Gr4vy\model\AntiFraudServiceUpdate $anti_fraud_service_update (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\AntiFraudService|\Gr4vy\model\ErrorGeneric|\Gr4vy\model\Error401Unauthorized, HTTP status code, HTTP response headers (array of strings) + */ + public function updateAntiFraudServiceWithHttpInfo($anti_fraud_service_id, $anti_fraud_service_update = null) + { + $request = $this->updateAntiFraudServiceRequest($anti_fraud_service_id, $anti_fraud_service_update); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 201: + if ('\Gr4vy\model\AntiFraudService' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\AntiFraudService' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\AntiFraudService', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\Gr4vy\model\ErrorGeneric' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\ErrorGeneric' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\ErrorGeneric', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\AntiFraudService'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 201: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\AntiFraudService', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\ErrorGeneric', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateAntiFraudServiceAsync + * + * Update anti-fraud service + * + * @param string $anti_fraud_service_id The unique ID for an anti-fraud service. (required) + * @param \Gr4vy\model\AntiFraudServiceUpdate $anti_fraud_service_update (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateAntiFraudServiceAsync($anti_fraud_service_id, $anti_fraud_service_update = null) + { + return $this->updateAntiFraudServiceAsyncWithHttpInfo($anti_fraud_service_id, $anti_fraud_service_update) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateAntiFraudServiceAsyncWithHttpInfo + * + * Update anti-fraud service + * + * @param string $anti_fraud_service_id The unique ID for an anti-fraud service. (required) + * @param \Gr4vy\model\AntiFraudServiceUpdate $anti_fraud_service_update (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateAntiFraudServiceAsyncWithHttpInfo($anti_fraud_service_id, $anti_fraud_service_update = null) + { + $returnType = '\Gr4vy\model\AntiFraudService'; + $request = $this->updateAntiFraudServiceRequest($anti_fraud_service_id, $anti_fraud_service_update); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateAntiFraudService' + * + * @param string $anti_fraud_service_id The unique ID for an anti-fraud service. (required) + * @param \Gr4vy\model\AntiFraudServiceUpdate $anti_fraud_service_update (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateAntiFraudServiceRequest($anti_fraud_service_id, $anti_fraud_service_update = null) + { + // verify the required parameter 'anti_fraud_service_id' is set + if ($anti_fraud_service_id === null || (is_array($anti_fraud_service_id) && count($anti_fraud_service_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $anti_fraud_service_id when calling updateAntiFraudService' + ); + } + + $resourcePath = '/anti-fraud-services/{anti_fraud_service_id}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($anti_fraud_service_id !== null) { + $resourcePath = str_replace( + '{' . 'anti_fraud_service_id' . '}', + ObjectSerializer::toPathValue($anti_fraud_service_id), + $resourcePath + ); + } + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($anti_fraud_service_update)) { + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($anti_fraud_service_update)); + } else { + $httpBody = $anti_fraud_service_update; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/lib/api/AuditLogsApi.php b/lib/api/AuditLogsApi.php new file mode 100644 index 0000000..a1ef6f4 --- /dev/null +++ b/lib/api/AuditLogsApi.php @@ -0,0 +1,460 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation listAuditLogs + * + * List Audit Logs + * + * @param int $limit Defines the maximum number of items to return for this request. (optional, default to 20) + * @param string $cursor A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\AuditLogs|\Gr4vy\model\Error401Unauthorized + */ + public function listAuditLogs($limit = 20, $cursor = null) + { + list($response) = $this->listAuditLogsWithHttpInfo($limit, $cursor); + return $response; + } + + /** + * Operation listAuditLogsWithHttpInfo + * + * List Audit Logs + * + * @param int $limit Defines the maximum number of items to return for this request. (optional, default to 20) + * @param string $cursor A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\AuditLogs|\Gr4vy\model\Error401Unauthorized, HTTP status code, HTTP response headers (array of strings) + */ + public function listAuditLogsWithHttpInfo($limit = 20, $cursor = null) + { + $request = $this->listAuditLogsRequest($limit, $cursor); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\Gr4vy\model\AuditLogs' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\AuditLogs' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\AuditLogs', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\AuditLogs'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + '\Gr4vy\model\AuditLogs', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation listAuditLogsAsync + * + * List Audit Logs + * + * @param int $limit Defines the maximum number of items to return for this request. (optional, default to 20) + * @param string $cursor A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function listAuditLogsAsync($limit = 20, $cursor = null) + { + return $this->listAuditLogsAsyncWithHttpInfo($limit, $cursor) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation listAuditLogsAsyncWithHttpInfo + * + * List Audit Logs + * + * @param int $limit Defines the maximum number of items to return for this request. (optional, default to 20) + * @param string $cursor A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function listAuditLogsAsyncWithHttpInfo($limit = 20, $cursor = null) + { + $returnType = '\Gr4vy\model\AuditLogs'; + $request = $this->listAuditLogsRequest($limit, $cursor); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'listAuditLogs' + * + * @param int $limit Defines the maximum number of items to return for this request. (optional, default to 20) + * @param string $cursor A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function listAuditLogsRequest($limit = 20, $cursor = null) + { + if ($limit !== null && $limit > 100) { + throw new \InvalidArgumentException('invalid value for "$limit" when calling AuditLogsApi.listAuditLogs, must be smaller than or equal to 100.'); + } + if ($limit !== null && $limit < 1) { + throw new \InvalidArgumentException('invalid value for "$limit" when calling AuditLogsApi.listAuditLogs, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/audit-logs'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $cursor, + 'cursor', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + + + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/lib/api/BuyersApi.php b/lib/api/BuyersApi.php new file mode 100644 index 0000000..94129df --- /dev/null +++ b/lib/api/BuyersApi.php @@ -0,0 +1,1782 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation addBuyer + * + * New buyer + * + * @param \Gr4vy\model\BuyerRequest $buyer_request buyer_request (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\Buyer|\Gr4vy\model\ErrorGeneric|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error409DuplicateRecord + */ + public function addBuyer($buyer_request = null) + { + list($response) = $this->addBuyerWithHttpInfo($buyer_request); + return $response; + } + + /** + * Operation addBuyerWithHttpInfo + * + * New buyer + * + * @param \Gr4vy\model\BuyerRequest $buyer_request (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\Buyer|\Gr4vy\model\ErrorGeneric|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error409DuplicateRecord, HTTP status code, HTTP response headers (array of strings) + */ + public function addBuyerWithHttpInfo($buyer_request = null) + { + $request = $this->addBuyerRequest($buyer_request); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 201: + if ('\Gr4vy\model\Buyer' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Buyer' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Buyer', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\Gr4vy\model\ErrorGeneric' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\ErrorGeneric' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\ErrorGeneric', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 409: + if ('\Gr4vy\model\Error409DuplicateRecord' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error409DuplicateRecord' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error409DuplicateRecord', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\Buyer'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 201: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Buyer', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\ErrorGeneric', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 409: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error409DuplicateRecord', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation addBuyerAsync + * + * New buyer + * + * @param \Gr4vy\model\BuyerRequest $buyer_request (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addBuyerAsync($buyer_request = null) + { + return $this->addBuyerAsyncWithHttpInfo($buyer_request) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation addBuyerAsyncWithHttpInfo + * + * New buyer + * + * @param \Gr4vy\model\BuyerRequest $buyer_request (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addBuyerAsyncWithHttpInfo($buyer_request = null) + { + $returnType = '\Gr4vy\model\Buyer'; + $request = $this->addBuyerRequest($buyer_request); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'addBuyer' + * + * @param \Gr4vy\model\BuyerRequest $buyer_request (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function addBuyerRequest($buyer_request = null) + { + + $resourcePath = '/buyers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($buyer_request)) { + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($buyer_request)); + } else { + $httpBody = $buyer_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deleteBuyer + * + * Delete buyer + * + * @param string $buyer_id The unique ID for a buyer. (required) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function deleteBuyer($buyer_id) + { + $this->deleteBuyerWithHttpInfo($buyer_id); + } + + /** + * Operation deleteBuyerWithHttpInfo + * + * Delete buyer + * + * @param string $buyer_id The unique ID for a buyer. (required) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of null, HTTP status code, HTTP response headers (array of strings) + */ + public function deleteBuyerWithHttpInfo($buyer_id) + { + $request = $this->deleteBuyerRequest($buyer_id); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error404NotFound', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deleteBuyerAsync + * + * Delete buyer + * + * @param string $buyer_id The unique ID for a buyer. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteBuyerAsync($buyer_id) + { + return $this->deleteBuyerAsyncWithHttpInfo($buyer_id) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteBuyerAsyncWithHttpInfo + * + * Delete buyer + * + * @param string $buyer_id The unique ID for a buyer. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteBuyerAsyncWithHttpInfo($buyer_id) + { + $returnType = ''; + $request = $this->deleteBuyerRequest($buyer_id); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteBuyer' + * + * @param string $buyer_id The unique ID for a buyer. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deleteBuyerRequest($buyer_id) + { + // verify the required parameter 'buyer_id' is set + if ($buyer_id === null || (is_array($buyer_id) && count($buyer_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $buyer_id when calling deleteBuyer' + ); + } + + $resourcePath = '/buyers/{buyer_id}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($buyer_id !== null) { + $resourcePath = str_replace( + '{' . 'buyer_id' . '}', + ObjectSerializer::toPathValue($buyer_id), + $resourcePath + ); + } + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'DELETE', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getBuyer + * + * Get buyer + * + * @param string $buyer_id The unique ID for a buyer. (required) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\Buyer|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error404NotFound|\Gr4vy\model\ErrorGeneric + */ + public function getBuyer($buyer_id) + { + list($response) = $this->getBuyerWithHttpInfo($buyer_id); + return $response; + } + + /** + * Operation getBuyerWithHttpInfo + * + * Get buyer + * + * @param string $buyer_id The unique ID for a buyer. (required) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\Buyer|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error404NotFound|\Gr4vy\model\ErrorGeneric, HTTP status code, HTTP response headers (array of strings) + */ + public function getBuyerWithHttpInfo($buyer_id) + { + $request = $this->getBuyerRequest($buyer_id); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\Gr4vy\model\Buyer' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Buyer' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Buyer', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\Gr4vy\model\Error404NotFound' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error404NotFound' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error404NotFound', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + default: + if ('\Gr4vy\model\ErrorGeneric' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\ErrorGeneric' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\ErrorGeneric', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\Buyer'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + '\Gr4vy\model\Buyer', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error404NotFound', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\ErrorGeneric', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getBuyerAsync + * + * Get buyer + * + * @param string $buyer_id The unique ID for a buyer. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBuyerAsync($buyer_id) + { + return $this->getBuyerAsyncWithHttpInfo($buyer_id) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getBuyerAsyncWithHttpInfo + * + * Get buyer + * + * @param string $buyer_id The unique ID for a buyer. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBuyerAsyncWithHttpInfo($buyer_id) + { + $returnType = '\Gr4vy\model\Buyer'; + $request = $this->getBuyerRequest($buyer_id); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getBuyer' + * + * @param string $buyer_id The unique ID for a buyer. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getBuyerRequest($buyer_id) + { + // verify the required parameter 'buyer_id' is set + if ($buyer_id === null || (is_array($buyer_id) && count($buyer_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $buyer_id when calling getBuyer' + ); + } + + $resourcePath = '/buyers/{buyer_id}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($buyer_id !== null) { + $resourcePath = str_replace( + '{' . 'buyer_id' . '}', + ObjectSerializer::toPathValue($buyer_id), + $resourcePath + ); + } + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation listBuyers + * + * List buyers + * + * @param string $search Filters the results to only the buyers for which the `display_name` or `external_identifier` matches this value. This field allows for a partial match, matching any buyer for which either of the fields partially or completely matches. (optional) + * @param int $limit Defines the maximum number of items to return for this request. (optional, default to 20) + * @param string $cursor A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\Buyers|\Gr4vy\model\Error401Unauthorized + */ + public function listBuyers($search = null, $limit = 20, $cursor = null) + { + list($response) = $this->listBuyersWithHttpInfo($search, $limit, $cursor); + return $response; + } + + /** + * Operation listBuyersWithHttpInfo + * + * List buyers + * + * @param string $search Filters the results to only the buyers for which the `display_name` or `external_identifier` matches this value. This field allows for a partial match, matching any buyer for which either of the fields partially or completely matches. (optional) + * @param int $limit Defines the maximum number of items to return for this request. (optional, default to 20) + * @param string $cursor A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\Buyers|\Gr4vy\model\Error401Unauthorized, HTTP status code, HTTP response headers (array of strings) + */ + public function listBuyersWithHttpInfo($search = null, $limit = 20, $cursor = null) + { + $request = $this->listBuyersRequest($search, $limit, $cursor); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\Gr4vy\model\Buyers' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Buyers' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Buyers', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\Buyers'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + '\Gr4vy\model\Buyers', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation listBuyersAsync + * + * List buyers + * + * @param string $search Filters the results to only the buyers for which the `display_name` or `external_identifier` matches this value. This field allows for a partial match, matching any buyer for which either of the fields partially or completely matches. (optional) + * @param int $limit Defines the maximum number of items to return for this request. (optional, default to 20) + * @param string $cursor A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function listBuyersAsync($search = null, $limit = 20, $cursor = null) + { + return $this->listBuyersAsyncWithHttpInfo($search, $limit, $cursor) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation listBuyersAsyncWithHttpInfo + * + * List buyers + * + * @param string $search Filters the results to only the buyers for which the `display_name` or `external_identifier` matches this value. This field allows for a partial match, matching any buyer for which either of the fields partially or completely matches. (optional) + * @param int $limit Defines the maximum number of items to return for this request. (optional, default to 20) + * @param string $cursor A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function listBuyersAsyncWithHttpInfo($search = null, $limit = 20, $cursor = null) + { + $returnType = '\Gr4vy\model\Buyers'; + $request = $this->listBuyersRequest($search, $limit, $cursor); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'listBuyers' + * + * @param string $search Filters the results to only the buyers for which the `display_name` or `external_identifier` matches this value. This field allows for a partial match, matching any buyer for which either of the fields partially or completely matches. (optional) + * @param int $limit Defines the maximum number of items to return for this request. (optional, default to 20) + * @param string $cursor A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function listBuyersRequest($search = null, $limit = 20, $cursor = null) + { + if ($limit !== null && $limit > 100) { + throw new \InvalidArgumentException('invalid value for "$limit" when calling BuyersApi.listBuyers, must be smaller than or equal to 100.'); + } + if ($limit !== null && $limit < 1) { + throw new \InvalidArgumentException('invalid value for "$limit" when calling BuyersApi.listBuyers, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/buyers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $search, + 'search', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $cursor, + 'cursor', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + + + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateBuyer + * + * Update buyer + * + * @param string $buyer_id The unique ID for a buyer. (required) + * @param \Gr4vy\model\BuyerUpdate $buyer_update buyer_update (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\Buyer|\Gr4vy\model\ErrorGeneric|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error404NotFound + */ + public function updateBuyer($buyer_id, $buyer_update = null) + { + list($response) = $this->updateBuyerWithHttpInfo($buyer_id, $buyer_update); + return $response; + } + + /** + * Operation updateBuyerWithHttpInfo + * + * Update buyer + * + * @param string $buyer_id The unique ID for a buyer. (required) + * @param \Gr4vy\model\BuyerUpdate $buyer_update (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\Buyer|\Gr4vy\model\ErrorGeneric|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error404NotFound, HTTP status code, HTTP response headers (array of strings) + */ + public function updateBuyerWithHttpInfo($buyer_id, $buyer_update = null) + { + $request = $this->updateBuyerRequest($buyer_id, $buyer_update); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\Gr4vy\model\Buyer' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Buyer' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Buyer', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\Gr4vy\model\ErrorGeneric' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\ErrorGeneric' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\ErrorGeneric', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\Gr4vy\model\Error404NotFound' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error404NotFound' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error404NotFound', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\Buyer'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + '\Gr4vy\model\Buyer', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\ErrorGeneric', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error404NotFound', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateBuyerAsync + * + * Update buyer + * + * @param string $buyer_id The unique ID for a buyer. (required) + * @param \Gr4vy\model\BuyerUpdate $buyer_update (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateBuyerAsync($buyer_id, $buyer_update = null) + { + return $this->updateBuyerAsyncWithHttpInfo($buyer_id, $buyer_update) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateBuyerAsyncWithHttpInfo + * + * Update buyer + * + * @param string $buyer_id The unique ID for a buyer. (required) + * @param \Gr4vy\model\BuyerUpdate $buyer_update (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateBuyerAsyncWithHttpInfo($buyer_id, $buyer_update = null) + { + $returnType = '\Gr4vy\model\Buyer'; + $request = $this->updateBuyerRequest($buyer_id, $buyer_update); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateBuyer' + * + * @param string $buyer_id The unique ID for a buyer. (required) + * @param \Gr4vy\model\BuyerUpdate $buyer_update (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateBuyerRequest($buyer_id, $buyer_update = null) + { + // verify the required parameter 'buyer_id' is set + if ($buyer_id === null || (is_array($buyer_id) && count($buyer_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $buyer_id when calling updateBuyer' + ); + } + + $resourcePath = '/buyers/{buyer_id}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($buyer_id !== null) { + $resourcePath = str_replace( + '{' . 'buyer_id' . '}', + ObjectSerializer::toPathValue($buyer_id), + $resourcePath + ); + } + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($buyer_update)) { + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($buyer_update)); + } else { + $httpBody = $buyer_update; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/lib/api/CardSchemeDefinitionsApi.php b/lib/api/CardSchemeDefinitionsApi.php new file mode 100644 index 0000000..f076c2f --- /dev/null +++ b/lib/api/CardSchemeDefinitionsApi.php @@ -0,0 +1,425 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation listCardSchemeDefinitions + * + * List card scheme definitions + * + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\CardSchemeDefinitions|\Gr4vy\model\Error401Unauthorized + */ + public function listCardSchemeDefinitions() + { + list($response) = $this->listCardSchemeDefinitionsWithHttpInfo(); + return $response; + } + + /** + * Operation listCardSchemeDefinitionsWithHttpInfo + * + * List card scheme definitions + * + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\CardSchemeDefinitions|\Gr4vy\model\Error401Unauthorized, HTTP status code, HTTP response headers (array of strings) + */ + public function listCardSchemeDefinitionsWithHttpInfo() + { + $request = $this->listCardSchemeDefinitionsRequest(); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\Gr4vy\model\CardSchemeDefinitions' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\CardSchemeDefinitions' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\CardSchemeDefinitions', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\CardSchemeDefinitions'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + '\Gr4vy\model\CardSchemeDefinitions', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation listCardSchemeDefinitionsAsync + * + * List card scheme definitions + * + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function listCardSchemeDefinitionsAsync() + { + return $this->listCardSchemeDefinitionsAsyncWithHttpInfo() + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation listCardSchemeDefinitionsAsyncWithHttpInfo + * + * List card scheme definitions + * + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function listCardSchemeDefinitionsAsyncWithHttpInfo() + { + $returnType = '\Gr4vy\model\CardSchemeDefinitions'; + $request = $this->listCardSchemeDefinitionsRequest(); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'listCardSchemeDefinitions' + * + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function listCardSchemeDefinitionsRequest() + { + + $resourcePath = '/card-scheme-definitions'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/lib/api/CheckoutSessionsApi.php b/lib/api/CheckoutSessionsApi.php new file mode 100644 index 0000000..1c4bea4 --- /dev/null +++ b/lib/api/CheckoutSessionsApi.php @@ -0,0 +1,1320 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation addCheckoutSession + * + * Create a new Checkout Session + * + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\CheckoutSession|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\ErrorGeneric + */ + public function addCheckoutSession() + { + list($response) = $this->addCheckoutSessionWithHttpInfo(); + return $response; + } + + /** + * Operation addCheckoutSessionWithHttpInfo + * + * Create a new Checkout Session + * + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\CheckoutSession|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\ErrorGeneric, HTTP status code, HTTP response headers (array of strings) + */ + public function addCheckoutSessionWithHttpInfo() + { + $request = $this->addCheckoutSessionRequest(); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 201: + if ('\Gr4vy\model\CheckoutSession' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\CheckoutSession' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\CheckoutSession', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + default: + if ('\Gr4vy\model\ErrorGeneric' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\ErrorGeneric' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\ErrorGeneric', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\CheckoutSession'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 201: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\CheckoutSession', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\ErrorGeneric', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation addCheckoutSessionAsync + * + * Create a new Checkout Session + * + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addCheckoutSessionAsync() + { + return $this->addCheckoutSessionAsyncWithHttpInfo() + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation addCheckoutSessionAsyncWithHttpInfo + * + * Create a new Checkout Session + * + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addCheckoutSessionAsyncWithHttpInfo() + { + $returnType = '\Gr4vy\model\CheckoutSession'; + $request = $this->addCheckoutSessionRequest(); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'addCheckoutSession' + * + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function addCheckoutSessionRequest() + { + + $resourcePath = '/checkout/sessions'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deleteCheckoutSession + * + * Delete a Checkout Session + * + * @param string $checkout_session_id The unique ID for a Checkout Session. (required) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function deleteCheckoutSession($checkout_session_id) + { + $this->deleteCheckoutSessionWithHttpInfo($checkout_session_id); + } + + /** + * Operation deleteCheckoutSessionWithHttpInfo + * + * Delete a Checkout Session + * + * @param string $checkout_session_id The unique ID for a Checkout Session. (required) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of null, HTTP status code, HTTP response headers (array of strings) + */ + public function deleteCheckoutSessionWithHttpInfo($checkout_session_id) + { + $request = $this->deleteCheckoutSessionRequest($checkout_session_id); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error404NotFound', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\ErrorGeneric', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deleteCheckoutSessionAsync + * + * Delete a Checkout Session + * + * @param string $checkout_session_id The unique ID for a Checkout Session. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteCheckoutSessionAsync($checkout_session_id) + { + return $this->deleteCheckoutSessionAsyncWithHttpInfo($checkout_session_id) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteCheckoutSessionAsyncWithHttpInfo + * + * Delete a Checkout Session + * + * @param string $checkout_session_id The unique ID for a Checkout Session. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteCheckoutSessionAsyncWithHttpInfo($checkout_session_id) + { + $returnType = ''; + $request = $this->deleteCheckoutSessionRequest($checkout_session_id); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteCheckoutSession' + * + * @param string $checkout_session_id The unique ID for a Checkout Session. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deleteCheckoutSessionRequest($checkout_session_id) + { + // verify the required parameter 'checkout_session_id' is set + if ($checkout_session_id === null || (is_array($checkout_session_id) && count($checkout_session_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $checkout_session_id when calling deleteCheckoutSession' + ); + } + + $resourcePath = '/checkout/sessions/{checkout_session_id}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($checkout_session_id !== null) { + $resourcePath = str_replace( + '{' . 'checkout_session_id' . '}', + ObjectSerializer::toPathValue($checkout_session_id), + $resourcePath + ); + } + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'DELETE', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCheckoutSession + * + * Get a Checkout Session + * + * @param string $checkout_session_id The unique ID for a Checkout Session. (required) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\CheckoutSession|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error404NotFound|\Gr4vy\model\ErrorGeneric + */ + public function getCheckoutSession($checkout_session_id) + { + list($response) = $this->getCheckoutSessionWithHttpInfo($checkout_session_id); + return $response; + } + + /** + * Operation getCheckoutSessionWithHttpInfo + * + * Get a Checkout Session + * + * @param string $checkout_session_id The unique ID for a Checkout Session. (required) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\CheckoutSession|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error404NotFound|\Gr4vy\model\ErrorGeneric, HTTP status code, HTTP response headers (array of strings) + */ + public function getCheckoutSessionWithHttpInfo($checkout_session_id) + { + $request = $this->getCheckoutSessionRequest($checkout_session_id); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\Gr4vy\model\CheckoutSession' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\CheckoutSession' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\CheckoutSession', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\Gr4vy\model\Error404NotFound' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error404NotFound' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error404NotFound', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + default: + if ('\Gr4vy\model\ErrorGeneric' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\ErrorGeneric' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\ErrorGeneric', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\CheckoutSession'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + '\Gr4vy\model\CheckoutSession', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error404NotFound', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\ErrorGeneric', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCheckoutSessionAsync + * + * Get a Checkout Session + * + * @param string $checkout_session_id The unique ID for a Checkout Session. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCheckoutSessionAsync($checkout_session_id) + { + return $this->getCheckoutSessionAsyncWithHttpInfo($checkout_session_id) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCheckoutSessionAsyncWithHttpInfo + * + * Get a Checkout Session + * + * @param string $checkout_session_id The unique ID for a Checkout Session. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCheckoutSessionAsyncWithHttpInfo($checkout_session_id) + { + $returnType = '\Gr4vy\model\CheckoutSession'; + $request = $this->getCheckoutSessionRequest($checkout_session_id); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCheckoutSession' + * + * @param string $checkout_session_id The unique ID for a Checkout Session. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCheckoutSessionRequest($checkout_session_id) + { + // verify the required parameter 'checkout_session_id' is set + if ($checkout_session_id === null || (is_array($checkout_session_id) && count($checkout_session_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $checkout_session_id when calling getCheckoutSession' + ); + } + + $resourcePath = '/checkout/sessions/{checkout_session_id}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($checkout_session_id !== null) { + $resourcePath = str_replace( + '{' . 'checkout_session_id' . '}', + ObjectSerializer::toPathValue($checkout_session_id), + $resourcePath + ); + } + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateCheckoutSessionFields + * + * Update a Checkout Session's Secure Fields + * + * @param string $checkout_session_id The unique ID for a Checkout Session. (required) + * @param \Gr4vy\model\CheckoutSessionSecureFieldsUpdate $checkout_session_secure_fields_update checkout_session_secure_fields_update (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function updateCheckoutSessionFields($checkout_session_id, $checkout_session_secure_fields_update = null) + { + $this->updateCheckoutSessionFieldsWithHttpInfo($checkout_session_id, $checkout_session_secure_fields_update); + } + + /** + * Operation updateCheckoutSessionFieldsWithHttpInfo + * + * Update a Checkout Session's Secure Fields + * + * @param string $checkout_session_id The unique ID for a Checkout Session. (required) + * @param \Gr4vy\model\CheckoutSessionSecureFieldsUpdate $checkout_session_secure_fields_update (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of null, HTTP status code, HTTP response headers (array of strings) + */ + public function updateCheckoutSessionFieldsWithHttpInfo($checkout_session_id, $checkout_session_secure_fields_update = null) + { + $request = $this->updateCheckoutSessionFieldsRequest($checkout_session_id, $checkout_session_secure_fields_update); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error404NotFound', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\ErrorGeneric', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateCheckoutSessionFieldsAsync + * + * Update a Checkout Session's Secure Fields + * + * @param string $checkout_session_id The unique ID for a Checkout Session. (required) + * @param \Gr4vy\model\CheckoutSessionSecureFieldsUpdate $checkout_session_secure_fields_update (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateCheckoutSessionFieldsAsync($checkout_session_id, $checkout_session_secure_fields_update = null) + { + return $this->updateCheckoutSessionFieldsAsyncWithHttpInfo($checkout_session_id, $checkout_session_secure_fields_update) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateCheckoutSessionFieldsAsyncWithHttpInfo + * + * Update a Checkout Session's Secure Fields + * + * @param string $checkout_session_id The unique ID for a Checkout Session. (required) + * @param \Gr4vy\model\CheckoutSessionSecureFieldsUpdate $checkout_session_secure_fields_update (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateCheckoutSessionFieldsAsyncWithHttpInfo($checkout_session_id, $checkout_session_secure_fields_update = null) + { + $returnType = ''; + $request = $this->updateCheckoutSessionFieldsRequest($checkout_session_id, $checkout_session_secure_fields_update); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateCheckoutSessionFields' + * + * @param string $checkout_session_id The unique ID for a Checkout Session. (required) + * @param \Gr4vy\model\CheckoutSessionSecureFieldsUpdate $checkout_session_secure_fields_update (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateCheckoutSessionFieldsRequest($checkout_session_id, $checkout_session_secure_fields_update = null) + { + // verify the required parameter 'checkout_session_id' is set + if ($checkout_session_id === null || (is_array($checkout_session_id) && count($checkout_session_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $checkout_session_id when calling updateCheckoutSessionFields' + ); + } + + $resourcePath = '/checkout/sessions/{checkout_session_id}/fields'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($checkout_session_id !== null) { + $resourcePath = str_replace( + '{' . 'checkout_session_id' . '}', + ObjectSerializer::toPathValue($checkout_session_id), + $resourcePath + ); + } + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($checkout_session_secure_fields_update)) { + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($checkout_session_secure_fields_update)); + } else { + $httpBody = $checkout_session_secure_fields_update; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/lib/api/DigitalWalletsApi.php b/lib/api/DigitalWalletsApi.php new file mode 100644 index 0000000..8e014e8 --- /dev/null +++ b/lib/api/DigitalWalletsApi.php @@ -0,0 +1,1687 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation deregisterDigitalWallet + * + * De-register digital wallet + * + * @param string $digital_wallet_id The ID of the registered digital wallet. (required) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function deregisterDigitalWallet($digital_wallet_id) + { + $this->deregisterDigitalWalletWithHttpInfo($digital_wallet_id); + } + + /** + * Operation deregisterDigitalWalletWithHttpInfo + * + * De-register digital wallet + * + * @param string $digital_wallet_id The ID of the registered digital wallet. (required) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of null, HTTP status code, HTTP response headers (array of strings) + */ + public function deregisterDigitalWalletWithHttpInfo($digital_wallet_id) + { + $request = $this->deregisterDigitalWalletRequest($digital_wallet_id); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error404NotFound', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deregisterDigitalWalletAsync + * + * De-register digital wallet + * + * @param string $digital_wallet_id The ID of the registered digital wallet. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deregisterDigitalWalletAsync($digital_wallet_id) + { + return $this->deregisterDigitalWalletAsyncWithHttpInfo($digital_wallet_id) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deregisterDigitalWalletAsyncWithHttpInfo + * + * De-register digital wallet + * + * @param string $digital_wallet_id The ID of the registered digital wallet. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deregisterDigitalWalletAsyncWithHttpInfo($digital_wallet_id) + { + $returnType = ''; + $request = $this->deregisterDigitalWalletRequest($digital_wallet_id); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deregisterDigitalWallet' + * + * @param string $digital_wallet_id The ID of the registered digital wallet. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deregisterDigitalWalletRequest($digital_wallet_id) + { + // verify the required parameter 'digital_wallet_id' is set + if ($digital_wallet_id === null || (is_array($digital_wallet_id) && count($digital_wallet_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $digital_wallet_id when calling deregisterDigitalWallet' + ); + } + + $resourcePath = '/digital-wallets/{digital_wallet_id}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($digital_wallet_id !== null) { + $resourcePath = str_replace( + '{' . 'digital_wallet_id' . '}', + ObjectSerializer::toPathValue($digital_wallet_id), + $resourcePath + ); + } + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'DELETE', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getDigitalWallet + * + * Get digital wallet + * + * @param string $digital_wallet_id The ID of the registered digital wallet. (required) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\DigitalWallet|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error404NotFound + */ + public function getDigitalWallet($digital_wallet_id) + { + list($response) = $this->getDigitalWalletWithHttpInfo($digital_wallet_id); + return $response; + } + + /** + * Operation getDigitalWalletWithHttpInfo + * + * Get digital wallet + * + * @param string $digital_wallet_id The ID of the registered digital wallet. (required) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\DigitalWallet|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error404NotFound, HTTP status code, HTTP response headers (array of strings) + */ + public function getDigitalWalletWithHttpInfo($digital_wallet_id) + { + $request = $this->getDigitalWalletRequest($digital_wallet_id); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\Gr4vy\model\DigitalWallet' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\DigitalWallet' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\DigitalWallet', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\Gr4vy\model\Error404NotFound' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error404NotFound' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error404NotFound', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\DigitalWallet'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + '\Gr4vy\model\DigitalWallet', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error404NotFound', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getDigitalWalletAsync + * + * Get digital wallet + * + * @param string $digital_wallet_id The ID of the registered digital wallet. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getDigitalWalletAsync($digital_wallet_id) + { + return $this->getDigitalWalletAsyncWithHttpInfo($digital_wallet_id) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getDigitalWalletAsyncWithHttpInfo + * + * Get digital wallet + * + * @param string $digital_wallet_id The ID of the registered digital wallet. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getDigitalWalletAsyncWithHttpInfo($digital_wallet_id) + { + $returnType = '\Gr4vy\model\DigitalWallet'; + $request = $this->getDigitalWalletRequest($digital_wallet_id); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getDigitalWallet' + * + * @param string $digital_wallet_id The ID of the registered digital wallet. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getDigitalWalletRequest($digital_wallet_id) + { + // verify the required parameter 'digital_wallet_id' is set + if ($digital_wallet_id === null || (is_array($digital_wallet_id) && count($digital_wallet_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $digital_wallet_id when calling getDigitalWallet' + ); + } + + $resourcePath = '/digital-wallets/{digital_wallet_id}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($digital_wallet_id !== null) { + $resourcePath = str_replace( + '{' . 'digital_wallet_id' . '}', + ObjectSerializer::toPathValue($digital_wallet_id), + $resourcePath + ); + } + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation listDigitalWallets + * + * List digital wallets + * + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\DigitalWallets|\Gr4vy\model\Error401Unauthorized + */ + public function listDigitalWallets() + { + list($response) = $this->listDigitalWalletsWithHttpInfo(); + return $response; + } + + /** + * Operation listDigitalWalletsWithHttpInfo + * + * List digital wallets + * + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\DigitalWallets|\Gr4vy\model\Error401Unauthorized, HTTP status code, HTTP response headers (array of strings) + */ + public function listDigitalWalletsWithHttpInfo() + { + $request = $this->listDigitalWalletsRequest(); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\Gr4vy\model\DigitalWallets' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\DigitalWallets' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\DigitalWallets', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\DigitalWallets'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + '\Gr4vy\model\DigitalWallets', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation listDigitalWalletsAsync + * + * List digital wallets + * + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function listDigitalWalletsAsync() + { + return $this->listDigitalWalletsAsyncWithHttpInfo() + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation listDigitalWalletsAsyncWithHttpInfo + * + * List digital wallets + * + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function listDigitalWalletsAsyncWithHttpInfo() + { + $returnType = '\Gr4vy\model\DigitalWallets'; + $request = $this->listDigitalWalletsRequest(); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'listDigitalWallets' + * + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function listDigitalWalletsRequest() + { + + $resourcePath = '/digital-wallets'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation registerDigitalWallet + * + * Register digital wallet + * + * @param \Gr4vy\model\DigitalWalletRequest $digital_wallet_request digital_wallet_request (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\DigitalWallet|\Gr4vy\model\ErrorGeneric|\Gr4vy\model\Error401Unauthorized + */ + public function registerDigitalWallet($digital_wallet_request = null) + { + list($response) = $this->registerDigitalWalletWithHttpInfo($digital_wallet_request); + return $response; + } + + /** + * Operation registerDigitalWalletWithHttpInfo + * + * Register digital wallet + * + * @param \Gr4vy\model\DigitalWalletRequest $digital_wallet_request (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\DigitalWallet|\Gr4vy\model\ErrorGeneric|\Gr4vy\model\Error401Unauthorized, HTTP status code, HTTP response headers (array of strings) + */ + public function registerDigitalWalletWithHttpInfo($digital_wallet_request = null) + { + $request = $this->registerDigitalWalletRequest($digital_wallet_request); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 201: + if ('\Gr4vy\model\DigitalWallet' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\DigitalWallet' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\DigitalWallet', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\Gr4vy\model\ErrorGeneric' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\ErrorGeneric' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\ErrorGeneric', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\DigitalWallet'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 201: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\DigitalWallet', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\ErrorGeneric', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation registerDigitalWalletAsync + * + * Register digital wallet + * + * @param \Gr4vy\model\DigitalWalletRequest $digital_wallet_request (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function registerDigitalWalletAsync($digital_wallet_request = null) + { + return $this->registerDigitalWalletAsyncWithHttpInfo($digital_wallet_request) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation registerDigitalWalletAsyncWithHttpInfo + * + * Register digital wallet + * + * @param \Gr4vy\model\DigitalWalletRequest $digital_wallet_request (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function registerDigitalWalletAsyncWithHttpInfo($digital_wallet_request = null) + { + $returnType = '\Gr4vy\model\DigitalWallet'; + $request = $this->registerDigitalWalletRequest($digital_wallet_request); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'registerDigitalWallet' + * + * @param \Gr4vy\model\DigitalWalletRequest $digital_wallet_request (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function registerDigitalWalletRequest($digital_wallet_request = null) + { + + $resourcePath = '/digital-wallets'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($digital_wallet_request)) { + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($digital_wallet_request)); + } else { + $httpBody = $digital_wallet_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateDigitalWallet + * + * Update digital wallet + * + * @param string $digital_wallet_id The ID of the registered digital wallet. (required) + * @param \Gr4vy\model\DigitalWalletUpdate $digital_wallet_update digital_wallet_update (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\DigitalWallet|\Gr4vy\model\ErrorGeneric|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error404NotFound + */ + public function updateDigitalWallet($digital_wallet_id, $digital_wallet_update = null) + { + list($response) = $this->updateDigitalWalletWithHttpInfo($digital_wallet_id, $digital_wallet_update); + return $response; + } + + /** + * Operation updateDigitalWalletWithHttpInfo + * + * Update digital wallet + * + * @param string $digital_wallet_id The ID of the registered digital wallet. (required) + * @param \Gr4vy\model\DigitalWalletUpdate $digital_wallet_update (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\DigitalWallet|\Gr4vy\model\ErrorGeneric|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error404NotFound, HTTP status code, HTTP response headers (array of strings) + */ + public function updateDigitalWalletWithHttpInfo($digital_wallet_id, $digital_wallet_update = null) + { + $request = $this->updateDigitalWalletRequest($digital_wallet_id, $digital_wallet_update); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\Gr4vy\model\DigitalWallet' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\DigitalWallet' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\DigitalWallet', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\Gr4vy\model\ErrorGeneric' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\ErrorGeneric' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\ErrorGeneric', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\Gr4vy\model\Error404NotFound' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error404NotFound' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error404NotFound', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\DigitalWallet'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + '\Gr4vy\model\DigitalWallet', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\ErrorGeneric', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error404NotFound', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateDigitalWalletAsync + * + * Update digital wallet + * + * @param string $digital_wallet_id The ID of the registered digital wallet. (required) + * @param \Gr4vy\model\DigitalWalletUpdate $digital_wallet_update (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateDigitalWalletAsync($digital_wallet_id, $digital_wallet_update = null) + { + return $this->updateDigitalWalletAsyncWithHttpInfo($digital_wallet_id, $digital_wallet_update) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateDigitalWalletAsyncWithHttpInfo + * + * Update digital wallet + * + * @param string $digital_wallet_id The ID of the registered digital wallet. (required) + * @param \Gr4vy\model\DigitalWalletUpdate $digital_wallet_update (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateDigitalWalletAsyncWithHttpInfo($digital_wallet_id, $digital_wallet_update = null) + { + $returnType = '\Gr4vy\model\DigitalWallet'; + $request = $this->updateDigitalWalletRequest($digital_wallet_id, $digital_wallet_update); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateDigitalWallet' + * + * @param string $digital_wallet_id The ID of the registered digital wallet. (required) + * @param \Gr4vy\model\DigitalWalletUpdate $digital_wallet_update (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateDigitalWalletRequest($digital_wallet_id, $digital_wallet_update = null) + { + // verify the required parameter 'digital_wallet_id' is set + if ($digital_wallet_id === null || (is_array($digital_wallet_id) && count($digital_wallet_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $digital_wallet_id when calling updateDigitalWallet' + ); + } + + $resourcePath = '/digital-wallets/{digital_wallet_id}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($digital_wallet_id !== null) { + $resourcePath = str_replace( + '{' . 'digital_wallet_id' . '}', + ObjectSerializer::toPathValue($digital_wallet_id), + $resourcePath + ); + } + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($digital_wallet_update)) { + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($digital_wallet_update)); + } else { + $httpBody = $digital_wallet_update; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/lib/api/PaymentMethodDefinitionsApi.php b/lib/api/PaymentMethodDefinitionsApi.php new file mode 100644 index 0000000..799af4c --- /dev/null +++ b/lib/api/PaymentMethodDefinitionsApi.php @@ -0,0 +1,425 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation listPaymentMethodDefinitions + * + * List payment method definitions + * + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\PaymentMethodDefinitions|\Gr4vy\model\Error401Unauthorized + */ + public function listPaymentMethodDefinitions() + { + list($response) = $this->listPaymentMethodDefinitionsWithHttpInfo(); + return $response; + } + + /** + * Operation listPaymentMethodDefinitionsWithHttpInfo + * + * List payment method definitions + * + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\PaymentMethodDefinitions|\Gr4vy\model\Error401Unauthorized, HTTP status code, HTTP response headers (array of strings) + */ + public function listPaymentMethodDefinitionsWithHttpInfo() + { + $request = $this->listPaymentMethodDefinitionsRequest(); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\Gr4vy\model\PaymentMethodDefinitions' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\PaymentMethodDefinitions' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\PaymentMethodDefinitions', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\PaymentMethodDefinitions'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + '\Gr4vy\model\PaymentMethodDefinitions', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation listPaymentMethodDefinitionsAsync + * + * List payment method definitions + * + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function listPaymentMethodDefinitionsAsync() + { + return $this->listPaymentMethodDefinitionsAsyncWithHttpInfo() + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation listPaymentMethodDefinitionsAsyncWithHttpInfo + * + * List payment method definitions + * + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function listPaymentMethodDefinitionsAsyncWithHttpInfo() + { + $returnType = '\Gr4vy\model\PaymentMethodDefinitions'; + $request = $this->listPaymentMethodDefinitionsRequest(); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'listPaymentMethodDefinitions' + * + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function listPaymentMethodDefinitionsRequest() + { + + $resourcePath = '/payment-method-definitions'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/lib/api/PaymentMethodTokensApi.php b/lib/api/PaymentMethodTokensApi.php new file mode 100644 index 0000000..2eb5e64 --- /dev/null +++ b/lib/api/PaymentMethodTokensApi.php @@ -0,0 +1,467 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation listPaymentMethodTokens + * + * List payment method tokens + * + * @param string $payment_method_id The ID of the payment method. (required) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\PaymentMethodTokens|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error404NotFound + */ + public function listPaymentMethodTokens($payment_method_id) + { + list($response) = $this->listPaymentMethodTokensWithHttpInfo($payment_method_id); + return $response; + } + + /** + * Operation listPaymentMethodTokensWithHttpInfo + * + * List payment method tokens + * + * @param string $payment_method_id The ID of the payment method. (required) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\PaymentMethodTokens|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error404NotFound, HTTP status code, HTTP response headers (array of strings) + */ + public function listPaymentMethodTokensWithHttpInfo($payment_method_id) + { + $request = $this->listPaymentMethodTokensRequest($payment_method_id); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\Gr4vy\model\PaymentMethodTokens' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\PaymentMethodTokens' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\PaymentMethodTokens', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\Gr4vy\model\Error404NotFound' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error404NotFound' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error404NotFound', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\PaymentMethodTokens'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + '\Gr4vy\model\PaymentMethodTokens', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error404NotFound', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation listPaymentMethodTokensAsync + * + * List payment method tokens + * + * @param string $payment_method_id The ID of the payment method. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function listPaymentMethodTokensAsync($payment_method_id) + { + return $this->listPaymentMethodTokensAsyncWithHttpInfo($payment_method_id) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation listPaymentMethodTokensAsyncWithHttpInfo + * + * List payment method tokens + * + * @param string $payment_method_id The ID of the payment method. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function listPaymentMethodTokensAsyncWithHttpInfo($payment_method_id) + { + $returnType = '\Gr4vy\model\PaymentMethodTokens'; + $request = $this->listPaymentMethodTokensRequest($payment_method_id); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'listPaymentMethodTokens' + * + * @param string $payment_method_id The ID of the payment method. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function listPaymentMethodTokensRequest($payment_method_id) + { + // verify the required parameter 'payment_method_id' is set + if ($payment_method_id === null || (is_array($payment_method_id) && count($payment_method_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $payment_method_id when calling listPaymentMethodTokens' + ); + } + + $resourcePath = '/payment-methods/{payment_method_id}/tokens'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($payment_method_id !== null) { + $resourcePath = str_replace( + '{' . 'payment_method_id' . '}', + ObjectSerializer::toPathValue($payment_method_id), + $resourcePath + ); + } + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/lib/api/PaymentMethodsApi.php b/lib/api/PaymentMethodsApi.php new file mode 100644 index 0000000..c333b75 --- /dev/null +++ b/lib/api/PaymentMethodsApi.php @@ -0,0 +1,1767 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation deletePaymentMethod + * + * Delete payment method + * + * @param string $payment_method_id The ID of the payment method. (required) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function deletePaymentMethod($payment_method_id) + { + $this->deletePaymentMethodWithHttpInfo($payment_method_id); + } + + /** + * Operation deletePaymentMethodWithHttpInfo + * + * Delete payment method + * + * @param string $payment_method_id The ID of the payment method. (required) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of null, HTTP status code, HTTP response headers (array of strings) + */ + public function deletePaymentMethodWithHttpInfo($payment_method_id) + { + $request = $this->deletePaymentMethodRequest($payment_method_id); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error404NotFound', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deletePaymentMethodAsync + * + * Delete payment method + * + * @param string $payment_method_id The ID of the payment method. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deletePaymentMethodAsync($payment_method_id) + { + return $this->deletePaymentMethodAsyncWithHttpInfo($payment_method_id) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deletePaymentMethodAsyncWithHttpInfo + * + * Delete payment method + * + * @param string $payment_method_id The ID of the payment method. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deletePaymentMethodAsyncWithHttpInfo($payment_method_id) + { + $returnType = ''; + $request = $this->deletePaymentMethodRequest($payment_method_id); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deletePaymentMethod' + * + * @param string $payment_method_id The ID of the payment method. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deletePaymentMethodRequest($payment_method_id) + { + // verify the required parameter 'payment_method_id' is set + if ($payment_method_id === null || (is_array($payment_method_id) && count($payment_method_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $payment_method_id when calling deletePaymentMethod' + ); + } + + $resourcePath = '/payment-methods/{payment_method_id}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($payment_method_id !== null) { + $resourcePath = str_replace( + '{' . 'payment_method_id' . '}', + ObjectSerializer::toPathValue($payment_method_id), + $resourcePath + ); + } + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'DELETE', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getPaymentMethod + * + * Get stored payment method + * + * @param string $payment_method_id The ID of the payment method. (required) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\PaymentMethod|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error404NotFound + */ + public function getPaymentMethod($payment_method_id) + { + list($response) = $this->getPaymentMethodWithHttpInfo($payment_method_id); + return $response; + } + + /** + * Operation getPaymentMethodWithHttpInfo + * + * Get stored payment method + * + * @param string $payment_method_id The ID of the payment method. (required) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\PaymentMethod|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error404NotFound, HTTP status code, HTTP response headers (array of strings) + */ + public function getPaymentMethodWithHttpInfo($payment_method_id) + { + $request = $this->getPaymentMethodRequest($payment_method_id); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\Gr4vy\model\PaymentMethod' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\PaymentMethod' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\PaymentMethod', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\Gr4vy\model\Error404NotFound' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error404NotFound' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error404NotFound', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\PaymentMethod'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + '\Gr4vy\model\PaymentMethod', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error404NotFound', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getPaymentMethodAsync + * + * Get stored payment method + * + * @param string $payment_method_id The ID of the payment method. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPaymentMethodAsync($payment_method_id) + { + return $this->getPaymentMethodAsyncWithHttpInfo($payment_method_id) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getPaymentMethodAsyncWithHttpInfo + * + * Get stored payment method + * + * @param string $payment_method_id The ID of the payment method. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPaymentMethodAsyncWithHttpInfo($payment_method_id) + { + $returnType = '\Gr4vy\model\PaymentMethod'; + $request = $this->getPaymentMethodRequest($payment_method_id); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getPaymentMethod' + * + * @param string $payment_method_id The ID of the payment method. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getPaymentMethodRequest($payment_method_id) + { + // verify the required parameter 'payment_method_id' is set + if ($payment_method_id === null || (is_array($payment_method_id) && count($payment_method_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $payment_method_id when calling getPaymentMethod' + ); + } + + $resourcePath = '/payment-methods/{payment_method_id}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($payment_method_id !== null) { + $resourcePath = str_replace( + '{' . 'payment_method_id' . '}', + ObjectSerializer::toPathValue($payment_method_id), + $resourcePath + ); + } + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation listBuyerPaymentMethods + * + * List stored payment methods for a buyer + * + * @param string $buyer_id Filters the results to only the items for which the `buyer` has an `id` that matches this value. (optional) + * @param string $buyer_external_identifier Filters the results to only the items for which the `buyer` has an `external_identifier` that matches this value. (optional) + * @param string $country Filters the results to only the items which support this country code. A country is formatted as 2-letter ISO country code. (optional) + * @param string $currency Filters the results to only the items which support this currency code. A currency is formatted as 3-letter ISO currency code. (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\PaymentMethodsTokenized|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error404NotFound + */ + public function listBuyerPaymentMethods($buyer_id = null, $buyer_external_identifier = null, $country = null, $currency = null) + { + list($response) = $this->listBuyerPaymentMethodsWithHttpInfo($buyer_id, $buyer_external_identifier, $country, $currency); + return $response; + } + + /** + * Operation listBuyerPaymentMethodsWithHttpInfo + * + * List stored payment methods for a buyer + * + * @param string $buyer_id Filters the results to only the items for which the `buyer` has an `id` that matches this value. (optional) + * @param string $buyer_external_identifier Filters the results to only the items for which the `buyer` has an `external_identifier` that matches this value. (optional) + * @param string $country Filters the results to only the items which support this country code. A country is formatted as 2-letter ISO country code. (optional) + * @param string $currency Filters the results to only the items which support this currency code. A currency is formatted as 3-letter ISO currency code. (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\PaymentMethodsTokenized|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error404NotFound, HTTP status code, HTTP response headers (array of strings) + */ + public function listBuyerPaymentMethodsWithHttpInfo($buyer_id = null, $buyer_external_identifier = null, $country = null, $currency = null) + { + $request = $this->listBuyerPaymentMethodsRequest($buyer_id, $buyer_external_identifier, $country, $currency); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\Gr4vy\model\PaymentMethodsTokenized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\PaymentMethodsTokenized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\PaymentMethodsTokenized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\Gr4vy\model\Error404NotFound' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error404NotFound' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error404NotFound', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\PaymentMethodsTokenized'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + '\Gr4vy\model\PaymentMethodsTokenized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error404NotFound', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation listBuyerPaymentMethodsAsync + * + * List stored payment methods for a buyer + * + * @param string $buyer_id Filters the results to only the items for which the `buyer` has an `id` that matches this value. (optional) + * @param string $buyer_external_identifier Filters the results to only the items for which the `buyer` has an `external_identifier` that matches this value. (optional) + * @param string $country Filters the results to only the items which support this country code. A country is formatted as 2-letter ISO country code. (optional) + * @param string $currency Filters the results to only the items which support this currency code. A currency is formatted as 3-letter ISO currency code. (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function listBuyerPaymentMethodsAsync($buyer_id = null, $buyer_external_identifier = null, $country = null, $currency = null) + { + return $this->listBuyerPaymentMethodsAsyncWithHttpInfo($buyer_id, $buyer_external_identifier, $country, $currency) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation listBuyerPaymentMethodsAsyncWithHttpInfo + * + * List stored payment methods for a buyer + * + * @param string $buyer_id Filters the results to only the items for which the `buyer` has an `id` that matches this value. (optional) + * @param string $buyer_external_identifier Filters the results to only the items for which the `buyer` has an `external_identifier` that matches this value. (optional) + * @param string $country Filters the results to only the items which support this country code. A country is formatted as 2-letter ISO country code. (optional) + * @param string $currency Filters the results to only the items which support this currency code. A currency is formatted as 3-letter ISO currency code. (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function listBuyerPaymentMethodsAsyncWithHttpInfo($buyer_id = null, $buyer_external_identifier = null, $country = null, $currency = null) + { + $returnType = '\Gr4vy\model\PaymentMethodsTokenized'; + $request = $this->listBuyerPaymentMethodsRequest($buyer_id, $buyer_external_identifier, $country, $currency); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'listBuyerPaymentMethods' + * + * @param string $buyer_id Filters the results to only the items for which the `buyer` has an `id` that matches this value. (optional) + * @param string $buyer_external_identifier Filters the results to only the items for which the `buyer` has an `external_identifier` that matches this value. (optional) + * @param string $country Filters the results to only the items which support this country code. A country is formatted as 2-letter ISO country code. (optional) + * @param string $currency Filters the results to only the items which support this currency code. A currency is formatted as 3-letter ISO currency code. (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function listBuyerPaymentMethodsRequest($buyer_id = null, $buyer_external_identifier = null, $country = null, $currency = null) + { + + $resourcePath = '/buyers/payment-methods'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $buyer_id, + 'buyer_id', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $buyer_external_identifier, + 'buyer_external_identifier', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $country, + 'country', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $currency, + 'currency', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + + + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation listPaymentMethods + * + * List payment methods + * + * @param string $buyer_id Filters the results to only the items for which the `buyer` has an `id` that matches this value. (optional) + * @param string $buyer_external_identifier Filters the results to only the items for which the `buyer` has an `external_identifier` that matches this value. (optional) + * @param string $status Filters the results to only the payment methods for which the `status` matches this value. (optional) + * @param int $limit Defines the maximum number of items to return for this request. (optional, default to 20) + * @param string $cursor A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\PaymentMethods|\Gr4vy\model\Error401Unauthorized + */ + public function listPaymentMethods($buyer_id = null, $buyer_external_identifier = null, $status = null, $limit = 20, $cursor = null) + { + list($response) = $this->listPaymentMethodsWithHttpInfo($buyer_id, $buyer_external_identifier, $status, $limit, $cursor); + return $response; + } + + /** + * Operation listPaymentMethodsWithHttpInfo + * + * List payment methods + * + * @param string $buyer_id Filters the results to only the items for which the `buyer` has an `id` that matches this value. (optional) + * @param string $buyer_external_identifier Filters the results to only the items for which the `buyer` has an `external_identifier` that matches this value. (optional) + * @param string $status Filters the results to only the payment methods for which the `status` matches this value. (optional) + * @param int $limit Defines the maximum number of items to return for this request. (optional, default to 20) + * @param string $cursor A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\PaymentMethods|\Gr4vy\model\Error401Unauthorized, HTTP status code, HTTP response headers (array of strings) + */ + public function listPaymentMethodsWithHttpInfo($buyer_id = null, $buyer_external_identifier = null, $status = null, $limit = 20, $cursor = null) + { + $request = $this->listPaymentMethodsRequest($buyer_id, $buyer_external_identifier, $status, $limit, $cursor); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\Gr4vy\model\PaymentMethods' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\PaymentMethods' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\PaymentMethods', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\PaymentMethods'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + '\Gr4vy\model\PaymentMethods', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation listPaymentMethodsAsync + * + * List payment methods + * + * @param string $buyer_id Filters the results to only the items for which the `buyer` has an `id` that matches this value. (optional) + * @param string $buyer_external_identifier Filters the results to only the items for which the `buyer` has an `external_identifier` that matches this value. (optional) + * @param string $status Filters the results to only the payment methods for which the `status` matches this value. (optional) + * @param int $limit Defines the maximum number of items to return for this request. (optional, default to 20) + * @param string $cursor A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function listPaymentMethodsAsync($buyer_id = null, $buyer_external_identifier = null, $status = null, $limit = 20, $cursor = null) + { + return $this->listPaymentMethodsAsyncWithHttpInfo($buyer_id, $buyer_external_identifier, $status, $limit, $cursor) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation listPaymentMethodsAsyncWithHttpInfo + * + * List payment methods + * + * @param string $buyer_id Filters the results to only the items for which the `buyer` has an `id` that matches this value. (optional) + * @param string $buyer_external_identifier Filters the results to only the items for which the `buyer` has an `external_identifier` that matches this value. (optional) + * @param string $status Filters the results to only the payment methods for which the `status` matches this value. (optional) + * @param int $limit Defines the maximum number of items to return for this request. (optional, default to 20) + * @param string $cursor A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function listPaymentMethodsAsyncWithHttpInfo($buyer_id = null, $buyer_external_identifier = null, $status = null, $limit = 20, $cursor = null) + { + $returnType = '\Gr4vy\model\PaymentMethods'; + $request = $this->listPaymentMethodsRequest($buyer_id, $buyer_external_identifier, $status, $limit, $cursor); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'listPaymentMethods' + * + * @param string $buyer_id Filters the results to only the items for which the `buyer` has an `id` that matches this value. (optional) + * @param string $buyer_external_identifier Filters the results to only the items for which the `buyer` has an `external_identifier` that matches this value. (optional) + * @param string $status Filters the results to only the payment methods for which the `status` matches this value. (optional) + * @param int $limit Defines the maximum number of items to return for this request. (optional, default to 20) + * @param string $cursor A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function listPaymentMethodsRequest($buyer_id = null, $buyer_external_identifier = null, $status = null, $limit = 20, $cursor = null) + { + if ($limit !== null && $limit > 100) { + throw new \InvalidArgumentException('invalid value for "$limit" when calling PaymentMethodsApi.listPaymentMethods, must be smaller than or equal to 100.'); + } + if ($limit !== null && $limit < 1) { + throw new \InvalidArgumentException('invalid value for "$limit" when calling PaymentMethodsApi.listPaymentMethods, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/payment-methods'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $buyer_id, + 'buyer_id', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $buyer_external_identifier, + 'buyer_external_identifier', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $status, + 'status', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $cursor, + 'cursor', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + + + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation storePaymentMethod + * + * New payment method + * + * @param \Gr4vy\model\PaymentMethodRequest $payment_method_request payment_method_request (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\PaymentMethod|\Gr4vy\model\ErrorGeneric|\Gr4vy\model\Error401Unauthorized + */ + public function storePaymentMethod($payment_method_request = null) + { + list($response) = $this->storePaymentMethodWithHttpInfo($payment_method_request); + return $response; + } + + /** + * Operation storePaymentMethodWithHttpInfo + * + * New payment method + * + * @param \Gr4vy\model\PaymentMethodRequest $payment_method_request (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\PaymentMethod|\Gr4vy\model\ErrorGeneric|\Gr4vy\model\Error401Unauthorized, HTTP status code, HTTP response headers (array of strings) + */ + public function storePaymentMethodWithHttpInfo($payment_method_request = null) + { + $request = $this->storePaymentMethodRequest($payment_method_request); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 201: + if ('\Gr4vy\model\PaymentMethod' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\PaymentMethod' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\PaymentMethod', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\Gr4vy\model\ErrorGeneric' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\ErrorGeneric' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\ErrorGeneric', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\PaymentMethod'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 201: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\PaymentMethod', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\ErrorGeneric', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation storePaymentMethodAsync + * + * New payment method + * + * @param \Gr4vy\model\PaymentMethodRequest $payment_method_request (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function storePaymentMethodAsync($payment_method_request = null) + { + return $this->storePaymentMethodAsyncWithHttpInfo($payment_method_request) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation storePaymentMethodAsyncWithHttpInfo + * + * New payment method + * + * @param \Gr4vy\model\PaymentMethodRequest $payment_method_request (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function storePaymentMethodAsyncWithHttpInfo($payment_method_request = null) + { + $returnType = '\Gr4vy\model\PaymentMethod'; + $request = $this->storePaymentMethodRequest($payment_method_request); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'storePaymentMethod' + * + * @param \Gr4vy\model\PaymentMethodRequest $payment_method_request (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function storePaymentMethodRequest($payment_method_request = null) + { + + $resourcePath = '/payment-methods'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($payment_method_request)) { + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($payment_method_request)); + } else { + $httpBody = $payment_method_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($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/PaymentOptionsApi.php b/lib/api/PaymentOptionsApi.php new file mode 100644 index 0000000..7e7c130 --- /dev/null +++ b/lib/api/PaymentOptionsApi.php @@ -0,0 +1,522 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation listPaymentOptions + * + * List payment options + * + * @param string $country Filters the results to only the items which support this country code. A country is formatted as 2-letter ISO country code. (optional) + * @param string $currency Filters the results to only the items which support this currency code. A currency is formatted as 3-letter ISO currency code. (optional) + * @param int $amount Used by the Flow engine to filter the results based on the transaction amount. (optional) + * @param string $metadata Used by the Flow engine to filter available options based on various client-defined parameters. If present, this must be a string representing a valid JSON dictionary. (optional) + * @param string $locale An ISO 639-1 Language Code and optional ISO 3166 Country Code. This locale determines the language for the labels returned for every payment option. (optional, default to 'en-US') + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\PaymentOptions|\Gr4vy\model\Error400BadRequest|\Gr4vy\model\Error401Unauthorized + */ + public function listPaymentOptions($country = null, $currency = null, $amount = null, $metadata = null, $locale = 'en-US') + { + list($response) = $this->listPaymentOptionsWithHttpInfo($country, $currency, $amount, $metadata, $locale); + return $response; + } + + /** + * Operation listPaymentOptionsWithHttpInfo + * + * List payment options + * + * @param string $country Filters the results to only the items which support this country code. A country is formatted as 2-letter ISO country code. (optional) + * @param string $currency Filters the results to only the items which support this currency code. A currency is formatted as 3-letter ISO currency code. (optional) + * @param int $amount Used by the Flow engine to filter the results based on the transaction amount. (optional) + * @param string $metadata Used by the Flow engine to filter available options based on various client-defined parameters. If present, this must be a string representing a valid JSON dictionary. (optional) + * @param string $locale An ISO 639-1 Language Code and optional ISO 3166 Country Code. This locale determines the language for the labels returned for every payment option. (optional, default to 'en-US') + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\PaymentOptions|\Gr4vy\model\Error400BadRequest|\Gr4vy\model\Error401Unauthorized, HTTP status code, HTTP response headers (array of strings) + */ + public function listPaymentOptionsWithHttpInfo($country = null, $currency = null, $amount = null, $metadata = null, $locale = 'en-US') + { + $request = $this->listPaymentOptionsRequest($country, $currency, $amount, $metadata, $locale); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\Gr4vy\model\PaymentOptions' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\PaymentOptions' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\PaymentOptions', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\Gr4vy\model\Error400BadRequest' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error400BadRequest' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error400BadRequest', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\PaymentOptions'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + '\Gr4vy\model\PaymentOptions', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error400BadRequest', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation listPaymentOptionsAsync + * + * List payment options + * + * @param string $country Filters the results to only the items which support this country code. A country is formatted as 2-letter ISO country code. (optional) + * @param string $currency Filters the results to only the items which support this currency code. A currency is formatted as 3-letter ISO currency code. (optional) + * @param int $amount Used by the Flow engine to filter the results based on the transaction amount. (optional) + * @param string $metadata Used by the Flow engine to filter available options based on various client-defined parameters. If present, this must be a string representing a valid JSON dictionary. (optional) + * @param string $locale An ISO 639-1 Language Code and optional ISO 3166 Country Code. This locale determines the language for the labels returned for every payment option. (optional, default to 'en-US') + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function listPaymentOptionsAsync($country = null, $currency = null, $amount = null, $metadata = null, $locale = 'en-US') + { + return $this->listPaymentOptionsAsyncWithHttpInfo($country, $currency, $amount, $metadata, $locale) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation listPaymentOptionsAsyncWithHttpInfo + * + * List payment options + * + * @param string $country Filters the results to only the items which support this country code. A country is formatted as 2-letter ISO country code. (optional) + * @param string $currency Filters the results to only the items which support this currency code. A currency is formatted as 3-letter ISO currency code. (optional) + * @param int $amount Used by the Flow engine to filter the results based on the transaction amount. (optional) + * @param string $metadata Used by the Flow engine to filter available options based on various client-defined parameters. If present, this must be a string representing a valid JSON dictionary. (optional) + * @param string $locale An ISO 639-1 Language Code and optional ISO 3166 Country Code. This locale determines the language for the labels returned for every payment option. (optional, default to 'en-US') + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function listPaymentOptionsAsyncWithHttpInfo($country = null, $currency = null, $amount = null, $metadata = null, $locale = 'en-US') + { + $returnType = '\Gr4vy\model\PaymentOptions'; + $request = $this->listPaymentOptionsRequest($country, $currency, $amount, $metadata, $locale); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'listPaymentOptions' + * + * @param string $country Filters the results to only the items which support this country code. A country is formatted as 2-letter ISO country code. (optional) + * @param string $currency Filters the results to only the items which support this currency code. A currency is formatted as 3-letter ISO currency code. (optional) + * @param int $amount Used by the Flow engine to filter the results based on the transaction amount. (optional) + * @param string $metadata Used by the Flow engine to filter available options based on various client-defined parameters. If present, this must be a string representing a valid JSON dictionary. (optional) + * @param string $locale An ISO 639-1 Language Code and optional ISO 3166 Country Code. This locale determines the language for the labels returned for every payment option. (optional, default to 'en-US') + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function listPaymentOptionsRequest($country = null, $currency = null, $amount = null, $metadata = null, $locale = 'en-US') + { + if ($locale !== null && !preg_match("/^[a-z]{2}(?:-[A-Z]{2})?$/", $locale)) { + throw new \InvalidArgumentException("invalid value for \"locale\" when calling PaymentOptionsApi.listPaymentOptions, must conform to the pattern /^[a-z]{2}(?:-[A-Z]{2})?$/."); + } + + + $resourcePath = '/payment-options'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $country, + 'country', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $currency, + 'currency', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $amount, + 'amount', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $metadata, + 'metadata', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $locale, + 'locale', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + + + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/lib/api/PaymentServiceDefinitionsApi.php b/lib/api/PaymentServiceDefinitionsApi.php new file mode 100644 index 0000000..af7167f --- /dev/null +++ b/lib/api/PaymentServiceDefinitionsApi.php @@ -0,0 +1,790 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation getPaymentServiceDefinition + * + * Get payment service definition + * + * @param string $payment_service_definition_id The unique ID of the payment service definition. (required) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\PaymentServiceDefinition|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error404NotFound + */ + public function getPaymentServiceDefinition($payment_service_definition_id) + { + list($response) = $this->getPaymentServiceDefinitionWithHttpInfo($payment_service_definition_id); + return $response; + } + + /** + * Operation getPaymentServiceDefinitionWithHttpInfo + * + * Get payment service definition + * + * @param string $payment_service_definition_id The unique ID of the payment service definition. (required) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\PaymentServiceDefinition|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error404NotFound, HTTP status code, HTTP response headers (array of strings) + */ + public function getPaymentServiceDefinitionWithHttpInfo($payment_service_definition_id) + { + $request = $this->getPaymentServiceDefinitionRequest($payment_service_definition_id); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\Gr4vy\model\PaymentServiceDefinition' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\PaymentServiceDefinition' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\PaymentServiceDefinition', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\Gr4vy\model\Error404NotFound' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error404NotFound' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error404NotFound', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\PaymentServiceDefinition'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + '\Gr4vy\model\PaymentServiceDefinition', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error404NotFound', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getPaymentServiceDefinitionAsync + * + * Get payment service definition + * + * @param string $payment_service_definition_id The unique ID of the payment service definition. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPaymentServiceDefinitionAsync($payment_service_definition_id) + { + return $this->getPaymentServiceDefinitionAsyncWithHttpInfo($payment_service_definition_id) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getPaymentServiceDefinitionAsyncWithHttpInfo + * + * Get payment service definition + * + * @param string $payment_service_definition_id The unique ID of the payment service definition. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPaymentServiceDefinitionAsyncWithHttpInfo($payment_service_definition_id) + { + $returnType = '\Gr4vy\model\PaymentServiceDefinition'; + $request = $this->getPaymentServiceDefinitionRequest($payment_service_definition_id); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getPaymentServiceDefinition' + * + * @param string $payment_service_definition_id The unique ID of the payment service definition. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getPaymentServiceDefinitionRequest($payment_service_definition_id) + { + // verify the required parameter 'payment_service_definition_id' is set + if ($payment_service_definition_id === null || (is_array($payment_service_definition_id) && count($payment_service_definition_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $payment_service_definition_id when calling getPaymentServiceDefinition' + ); + } + + $resourcePath = '/payment-service-definitions/{payment_service_definition_id}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($payment_service_definition_id !== null) { + $resourcePath = str_replace( + '{' . 'payment_service_definition_id' . '}', + ObjectSerializer::toPathValue($payment_service_definition_id), + $resourcePath + ); + } + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation listPaymentServiceDefinitions + * + * List payment service definitions + * + * @param int $limit Defines the maximum number of items to return for this request. (optional, default to 20) + * @param string $cursor A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\PaymentServiceDefinitions|\Gr4vy\model\Error401Unauthorized + */ + public function listPaymentServiceDefinitions($limit = 20, $cursor = null) + { + list($response) = $this->listPaymentServiceDefinitionsWithHttpInfo($limit, $cursor); + return $response; + } + + /** + * Operation listPaymentServiceDefinitionsWithHttpInfo + * + * List payment service definitions + * + * @param int $limit Defines the maximum number of items to return for this request. (optional, default to 20) + * @param string $cursor A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\PaymentServiceDefinitions|\Gr4vy\model\Error401Unauthorized, HTTP status code, HTTP response headers (array of strings) + */ + public function listPaymentServiceDefinitionsWithHttpInfo($limit = 20, $cursor = null) + { + $request = $this->listPaymentServiceDefinitionsRequest($limit, $cursor); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\Gr4vy\model\PaymentServiceDefinitions' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\PaymentServiceDefinitions' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\PaymentServiceDefinitions', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\PaymentServiceDefinitions'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + '\Gr4vy\model\PaymentServiceDefinitions', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation listPaymentServiceDefinitionsAsync + * + * List payment service definitions + * + * @param int $limit Defines the maximum number of items to return for this request. (optional, default to 20) + * @param string $cursor A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function listPaymentServiceDefinitionsAsync($limit = 20, $cursor = null) + { + return $this->listPaymentServiceDefinitionsAsyncWithHttpInfo($limit, $cursor) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation listPaymentServiceDefinitionsAsyncWithHttpInfo + * + * List payment service definitions + * + * @param int $limit Defines the maximum number of items to return for this request. (optional, default to 20) + * @param string $cursor A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function listPaymentServiceDefinitionsAsyncWithHttpInfo($limit = 20, $cursor = null) + { + $returnType = '\Gr4vy\model\PaymentServiceDefinitions'; + $request = $this->listPaymentServiceDefinitionsRequest($limit, $cursor); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'listPaymentServiceDefinitions' + * + * @param int $limit Defines the maximum number of items to return for this request. (optional, default to 20) + * @param string $cursor A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function listPaymentServiceDefinitionsRequest($limit = 20, $cursor = null) + { + if ($limit !== null && $limit > 100) { + throw new \InvalidArgumentException('invalid value for "$limit" when calling PaymentServiceDefinitionsApi.listPaymentServiceDefinitions, must be smaller than or equal to 100.'); + } + if ($limit !== null && $limit < 1) { + throw new \InvalidArgumentException('invalid value for "$limit" when calling PaymentServiceDefinitionsApi.listPaymentServiceDefinitions, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/payment-service-definitions'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $cursor, + 'cursor', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + + + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/lib/api/PaymentServicesApi.php b/lib/api/PaymentServicesApi.php new file mode 100644 index 0000000..2ec404f --- /dev/null +++ b/lib/api/PaymentServicesApi.php @@ -0,0 +1,1750 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation addPaymentService + * + * New payment service + * + * @param \Gr4vy\model\PaymentServiceRequest $payment_service_request payment_service_request (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\PaymentService|\Gr4vy\model\ErrorGeneric|\Gr4vy\model\Error401Unauthorized + */ + public function addPaymentService($payment_service_request = null) + { + list($response) = $this->addPaymentServiceWithHttpInfo($payment_service_request); + return $response; + } + + /** + * Operation addPaymentServiceWithHttpInfo + * + * New payment service + * + * @param \Gr4vy\model\PaymentServiceRequest $payment_service_request (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\PaymentService|\Gr4vy\model\ErrorGeneric|\Gr4vy\model\Error401Unauthorized, HTTP status code, HTTP response headers (array of strings) + */ + public function addPaymentServiceWithHttpInfo($payment_service_request = null) + { + $request = $this->addPaymentServiceRequest($payment_service_request); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 201: + if ('\Gr4vy\model\PaymentService' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\PaymentService' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\PaymentService', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\Gr4vy\model\ErrorGeneric' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\ErrorGeneric' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\ErrorGeneric', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\PaymentService'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 201: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\PaymentService', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\ErrorGeneric', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation addPaymentServiceAsync + * + * New payment service + * + * @param \Gr4vy\model\PaymentServiceRequest $payment_service_request (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addPaymentServiceAsync($payment_service_request = null) + { + return $this->addPaymentServiceAsyncWithHttpInfo($payment_service_request) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation addPaymentServiceAsyncWithHttpInfo + * + * New payment service + * + * @param \Gr4vy\model\PaymentServiceRequest $payment_service_request (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addPaymentServiceAsyncWithHttpInfo($payment_service_request = null) + { + $returnType = '\Gr4vy\model\PaymentService'; + $request = $this->addPaymentServiceRequest($payment_service_request); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'addPaymentService' + * + * @param \Gr4vy\model\PaymentServiceRequest $payment_service_request (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function addPaymentServiceRequest($payment_service_request = null) + { + + $resourcePath = '/payment-services'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($payment_service_request)) { + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($payment_service_request)); + } else { + $httpBody = $payment_service_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deletePaymentService + * + * Delete payment service + * + * @param string $payment_service_id The ID of the payment service. (required) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function deletePaymentService($payment_service_id) + { + $this->deletePaymentServiceWithHttpInfo($payment_service_id); + } + + /** + * Operation deletePaymentServiceWithHttpInfo + * + * Delete payment service + * + * @param string $payment_service_id The ID of the payment service. (required) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of null, HTTP status code, HTTP response headers (array of strings) + */ + public function deletePaymentServiceWithHttpInfo($payment_service_id) + { + $request = $this->deletePaymentServiceRequest($payment_service_id); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error404NotFound', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deletePaymentServiceAsync + * + * Delete payment service + * + * @param string $payment_service_id The ID of the payment service. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deletePaymentServiceAsync($payment_service_id) + { + return $this->deletePaymentServiceAsyncWithHttpInfo($payment_service_id) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deletePaymentServiceAsyncWithHttpInfo + * + * Delete payment service + * + * @param string $payment_service_id The ID of the payment service. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deletePaymentServiceAsyncWithHttpInfo($payment_service_id) + { + $returnType = ''; + $request = $this->deletePaymentServiceRequest($payment_service_id); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deletePaymentService' + * + * @param string $payment_service_id The ID of the payment service. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deletePaymentServiceRequest($payment_service_id) + { + // verify the required parameter 'payment_service_id' is set + if ($payment_service_id === null || (is_array($payment_service_id) && count($payment_service_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $payment_service_id when calling deletePaymentService' + ); + } + + $resourcePath = '/payment-services/{payment_service_id}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($payment_service_id !== null) { + $resourcePath = str_replace( + '{' . 'payment_service_id' . '}', + ObjectSerializer::toPathValue($payment_service_id), + $resourcePath + ); + } + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'DELETE', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getPaymentService + * + * Get payment service + * + * @param string $payment_service_id The ID of the payment service. (required) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\PaymentService|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error404NotFound + */ + public function getPaymentService($payment_service_id) + { + list($response) = $this->getPaymentServiceWithHttpInfo($payment_service_id); + return $response; + } + + /** + * Operation getPaymentServiceWithHttpInfo + * + * Get payment service + * + * @param string $payment_service_id The ID of the payment service. (required) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\PaymentService|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error404NotFound, HTTP status code, HTTP response headers (array of strings) + */ + public function getPaymentServiceWithHttpInfo($payment_service_id) + { + $request = $this->getPaymentServiceRequest($payment_service_id); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\Gr4vy\model\PaymentService' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\PaymentService' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\PaymentService', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\Gr4vy\model\Error404NotFound' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error404NotFound' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error404NotFound', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\PaymentService'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + '\Gr4vy\model\PaymentService', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error404NotFound', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getPaymentServiceAsync + * + * Get payment service + * + * @param string $payment_service_id The ID of the payment service. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPaymentServiceAsync($payment_service_id) + { + return $this->getPaymentServiceAsyncWithHttpInfo($payment_service_id) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getPaymentServiceAsyncWithHttpInfo + * + * Get payment service + * + * @param string $payment_service_id The ID of the payment service. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPaymentServiceAsyncWithHttpInfo($payment_service_id) + { + $returnType = '\Gr4vy\model\PaymentService'; + $request = $this->getPaymentServiceRequest($payment_service_id); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getPaymentService' + * + * @param string $payment_service_id The ID of the payment service. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getPaymentServiceRequest($payment_service_id) + { + // verify the required parameter 'payment_service_id' is set + if ($payment_service_id === null || (is_array($payment_service_id) && count($payment_service_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $payment_service_id when calling getPaymentService' + ); + } + + $resourcePath = '/payment-services/{payment_service_id}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($payment_service_id !== null) { + $resourcePath = str_replace( + '{' . 'payment_service_id' . '}', + ObjectSerializer::toPathValue($payment_service_id), + $resourcePath + ); + } + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation listPaymentServices + * + * List payment services + * + * @param int $limit Defines the maximum number of items to return for this request. (optional, default to 20) + * @param string $cursor A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. (optional) + * @param string $method Filters the results to only the items for which the `method` has been set to this value. (optional) + * @param bool $deleted Filters the results to only show items which have been deleted. By default, deleted items will not be returned. (optional, default to false) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\PaymentServices|\Gr4vy\model\Error401Unauthorized + */ + public function listPaymentServices($limit = 20, $cursor = null, $method = null, $deleted = false) + { + list($response) = $this->listPaymentServicesWithHttpInfo($limit, $cursor, $method, $deleted); + return $response; + } + + /** + * Operation listPaymentServicesWithHttpInfo + * + * List payment services + * + * @param int $limit Defines the maximum number of items to return for this request. (optional, default to 20) + * @param string $cursor A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. (optional) + * @param string $method Filters the results to only the items for which the `method` has been set to this value. (optional) + * @param bool $deleted Filters the results to only show items which have been deleted. By default, deleted items will not be returned. (optional, default to false) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\PaymentServices|\Gr4vy\model\Error401Unauthorized, HTTP status code, HTTP response headers (array of strings) + */ + public function listPaymentServicesWithHttpInfo($limit = 20, $cursor = null, $method = null, $deleted = false) + { + $request = $this->listPaymentServicesRequest($limit, $cursor, $method, $deleted); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\Gr4vy\model\PaymentServices' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\PaymentServices' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\PaymentServices', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\PaymentServices'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + '\Gr4vy\model\PaymentServices', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation listPaymentServicesAsync + * + * List payment services + * + * @param int $limit Defines the maximum number of items to return for this request. (optional, default to 20) + * @param string $cursor A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. (optional) + * @param string $method Filters the results to only the items for which the `method` has been set to this value. (optional) + * @param bool $deleted Filters the results to only show items which have been deleted. By default, deleted items will not be returned. (optional, default to false) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function listPaymentServicesAsync($limit = 20, $cursor = null, $method = null, $deleted = false) + { + return $this->listPaymentServicesAsyncWithHttpInfo($limit, $cursor, $method, $deleted) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation listPaymentServicesAsyncWithHttpInfo + * + * List payment services + * + * @param int $limit Defines the maximum number of items to return for this request. (optional, default to 20) + * @param string $cursor A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. (optional) + * @param string $method Filters the results to only the items for which the `method` has been set to this value. (optional) + * @param bool $deleted Filters the results to only show items which have been deleted. By default, deleted items will not be returned. (optional, default to false) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function listPaymentServicesAsyncWithHttpInfo($limit = 20, $cursor = null, $method = null, $deleted = false) + { + $returnType = '\Gr4vy\model\PaymentServices'; + $request = $this->listPaymentServicesRequest($limit, $cursor, $method, $deleted); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'listPaymentServices' + * + * @param int $limit Defines the maximum number of items to return for this request. (optional, default to 20) + * @param string $cursor A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. (optional) + * @param string $method Filters the results to only the items for which the `method` has been set to this value. (optional) + * @param bool $deleted Filters the results to only show items which have been deleted. By default, deleted items will not be returned. (optional, default to false) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function listPaymentServicesRequest($limit = 20, $cursor = null, $method = null, $deleted = false) + { + if ($limit !== null && $limit > 100) { + throw new \InvalidArgumentException('invalid value for "$limit" when calling PaymentServicesApi.listPaymentServices, must be smaller than or equal to 100.'); + } + if ($limit !== null && $limit < 1) { + throw new \InvalidArgumentException('invalid value for "$limit" when calling PaymentServicesApi.listPaymentServices, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/payment-services'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $cursor, + 'cursor', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $method, + 'method', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $deleted, + 'deleted', // param base name + 'boolean', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + + + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updatePaymentService + * + * Update payment service + * + * @param string $payment_service_id The ID of the payment service. (required) + * @param \Gr4vy\model\PaymentServiceUpdate $payment_service_update payment_service_update (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\PaymentService|\Gr4vy\model\ErrorGeneric|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error404NotFound + */ + public function updatePaymentService($payment_service_id, $payment_service_update = null) + { + list($response) = $this->updatePaymentServiceWithHttpInfo($payment_service_id, $payment_service_update); + return $response; + } + + /** + * Operation updatePaymentServiceWithHttpInfo + * + * Update payment service + * + * @param string $payment_service_id The ID of the payment service. (required) + * @param \Gr4vy\model\PaymentServiceUpdate $payment_service_update (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\PaymentService|\Gr4vy\model\ErrorGeneric|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error404NotFound, HTTP status code, HTTP response headers (array of strings) + */ + public function updatePaymentServiceWithHttpInfo($payment_service_id, $payment_service_update = null) + { + $request = $this->updatePaymentServiceRequest($payment_service_id, $payment_service_update); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 201: + if ('\Gr4vy\model\PaymentService' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\PaymentService' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\PaymentService', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\Gr4vy\model\ErrorGeneric' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\ErrorGeneric' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\ErrorGeneric', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\Gr4vy\model\Error404NotFound' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error404NotFound' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error404NotFound', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\PaymentService'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 201: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\PaymentService', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\ErrorGeneric', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error404NotFound', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updatePaymentServiceAsync + * + * Update payment service + * + * @param string $payment_service_id The ID of the payment service. (required) + * @param \Gr4vy\model\PaymentServiceUpdate $payment_service_update (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updatePaymentServiceAsync($payment_service_id, $payment_service_update = null) + { + return $this->updatePaymentServiceAsyncWithHttpInfo($payment_service_id, $payment_service_update) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updatePaymentServiceAsyncWithHttpInfo + * + * Update payment service + * + * @param string $payment_service_id The ID of the payment service. (required) + * @param \Gr4vy\model\PaymentServiceUpdate $payment_service_update (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updatePaymentServiceAsyncWithHttpInfo($payment_service_id, $payment_service_update = null) + { + $returnType = '\Gr4vy\model\PaymentService'; + $request = $this->updatePaymentServiceRequest($payment_service_id, $payment_service_update); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updatePaymentService' + * + * @param string $payment_service_id The ID of the payment service. (required) + * @param \Gr4vy\model\PaymentServiceUpdate $payment_service_update (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updatePaymentServiceRequest($payment_service_id, $payment_service_update = null) + { + // verify the required parameter 'payment_service_id' is set + if ($payment_service_id === null || (is_array($payment_service_id) && count($payment_service_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $payment_service_id when calling updatePaymentService' + ); + } + + $resourcePath = '/payment-services/{payment_service_id}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($payment_service_id !== null) { + $resourcePath = str_replace( + '{' . 'payment_service_id' . '}', + ObjectSerializer::toPathValue($payment_service_id), + $resourcePath + ); + } + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($payment_service_update)) { + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($payment_service_update)); + } else { + $httpBody = $payment_service_update; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/lib/api/TransactionsApi.php b/lib/api/TransactionsApi.php new file mode 100644 index 0000000..df56c53 --- /dev/null +++ b/lib/api/TransactionsApi.php @@ -0,0 +1,3243 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation authorizeNewTransaction + * + * New transaction + * + * @param \Gr4vy\model\TransactionRequest $transaction_request transaction_request (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\Transaction|\Gr4vy\model\ErrorGeneric|\Gr4vy\model\Error401Unauthorized + */ + public function authorizeNewTransaction($transaction_request = null) + { + list($response) = $this->authorizeNewTransactionWithHttpInfo($transaction_request); + return $response; + } + + /** + * Operation authorizeNewTransactionWithHttpInfo + * + * New transaction + * + * @param \Gr4vy\model\TransactionRequest $transaction_request (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\Transaction|\Gr4vy\model\ErrorGeneric|\Gr4vy\model\Error401Unauthorized, HTTP status code, HTTP response headers (array of strings) + */ + public function authorizeNewTransactionWithHttpInfo($transaction_request = null) + { + $request = $this->authorizeNewTransactionRequest($transaction_request); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 201: + if ('\Gr4vy\model\Transaction' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Transaction' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Transaction', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\Gr4vy\model\ErrorGeneric' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\ErrorGeneric' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\ErrorGeneric', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\Transaction'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 201: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Transaction', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\ErrorGeneric', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation authorizeNewTransactionAsync + * + * New transaction + * + * @param \Gr4vy\model\TransactionRequest $transaction_request (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function authorizeNewTransactionAsync($transaction_request = null) + { + return $this->authorizeNewTransactionAsyncWithHttpInfo($transaction_request) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation authorizeNewTransactionAsyncWithHttpInfo + * + * New transaction + * + * @param \Gr4vy\model\TransactionRequest $transaction_request (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function authorizeNewTransactionAsyncWithHttpInfo($transaction_request = null) + { + $returnType = '\Gr4vy\model\Transaction'; + $request = $this->authorizeNewTransactionRequest($transaction_request); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'authorizeNewTransaction' + * + * @param \Gr4vy\model\TransactionRequest $transaction_request (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function authorizeNewTransactionRequest($transaction_request = null) + { + + $resourcePath = '/transactions'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($transaction_request)) { + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($transaction_request)); + } else { + $httpBody = $transaction_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation captureTransaction + * + * Capture transaction + * + * @param string $transaction_id The ID for the transaction to get the information for. (required) + * @param \Gr4vy\model\TransactionCaptureRequest $transaction_capture_request transaction_capture_request (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\Transaction|\Gr4vy\model\ErrorGeneric|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\ErrorGeneric + */ + public function captureTransaction($transaction_id, $transaction_capture_request = null) + { + list($response) = $this->captureTransactionWithHttpInfo($transaction_id, $transaction_capture_request); + return $response; + } + + /** + * Operation captureTransactionWithHttpInfo + * + * Capture transaction + * + * @param string $transaction_id The ID for the transaction to get the information for. (required) + * @param \Gr4vy\model\TransactionCaptureRequest $transaction_capture_request (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\Transaction|\Gr4vy\model\ErrorGeneric|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\ErrorGeneric, HTTP status code, HTTP response headers (array of strings) + */ + public function captureTransactionWithHttpInfo($transaction_id, $transaction_capture_request = null) + { + $request = $this->captureTransactionRequest($transaction_id, $transaction_capture_request); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\Gr4vy\model\Transaction' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Transaction' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Transaction', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\Gr4vy\model\ErrorGeneric' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\ErrorGeneric' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\ErrorGeneric', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\Gr4vy\model\ErrorGeneric' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\ErrorGeneric' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\ErrorGeneric', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\Transaction'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + '\Gr4vy\model\Transaction', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\ErrorGeneric', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\ErrorGeneric', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation captureTransactionAsync + * + * Capture transaction + * + * @param string $transaction_id The ID for the transaction to get the information for. (required) + * @param \Gr4vy\model\TransactionCaptureRequest $transaction_capture_request (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function captureTransactionAsync($transaction_id, $transaction_capture_request = null) + { + return $this->captureTransactionAsyncWithHttpInfo($transaction_id, $transaction_capture_request) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation captureTransactionAsyncWithHttpInfo + * + * Capture transaction + * + * @param string $transaction_id The ID for the transaction to get the information for. (required) + * @param \Gr4vy\model\TransactionCaptureRequest $transaction_capture_request (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function captureTransactionAsyncWithHttpInfo($transaction_id, $transaction_capture_request = null) + { + $returnType = '\Gr4vy\model\Transaction'; + $request = $this->captureTransactionRequest($transaction_id, $transaction_capture_request); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'captureTransaction' + * + * @param string $transaction_id The ID for the transaction to get the information for. (required) + * @param \Gr4vy\model\TransactionCaptureRequest $transaction_capture_request (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function captureTransactionRequest($transaction_id, $transaction_capture_request = null) + { + // verify the required parameter 'transaction_id' is set + if ($transaction_id === null || (is_array($transaction_id) && count($transaction_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $transaction_id when calling captureTransaction' + ); + } + + $resourcePath = '/transactions/{transaction_id}/capture'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($transaction_id !== null) { + $resourcePath = str_replace( + '{' . 'transaction_id' . '}', + ObjectSerializer::toPathValue($transaction_id), + $resourcePath + ); + } + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($transaction_capture_request)) { + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($transaction_capture_request)); + } else { + $httpBody = $transaction_capture_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getTransaction + * + * Get transaction + * + * @param string $transaction_id The ID for the transaction to get the information for. (required) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\Transaction|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\ErrorGeneric + */ + public function getTransaction($transaction_id) + { + list($response) = $this->getTransactionWithHttpInfo($transaction_id); + return $response; + } + + /** + * Operation getTransactionWithHttpInfo + * + * Get transaction + * + * @param string $transaction_id The ID for the transaction to get the information for. (required) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\Transaction|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\ErrorGeneric, HTTP status code, HTTP response headers (array of strings) + */ + public function getTransactionWithHttpInfo($transaction_id) + { + $request = $this->getTransactionRequest($transaction_id); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\Gr4vy\model\Transaction' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Transaction' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Transaction', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\Gr4vy\model\ErrorGeneric' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\ErrorGeneric' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\ErrorGeneric', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\Transaction'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + '\Gr4vy\model\Transaction', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\ErrorGeneric', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getTransactionAsync + * + * Get transaction + * + * @param string $transaction_id The ID for the transaction to get the information for. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getTransactionAsync($transaction_id) + { + return $this->getTransactionAsyncWithHttpInfo($transaction_id) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getTransactionAsyncWithHttpInfo + * + * Get transaction + * + * @param string $transaction_id The ID for the transaction to get the information for. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getTransactionAsyncWithHttpInfo($transaction_id) + { + $returnType = '\Gr4vy\model\Transaction'; + $request = $this->getTransactionRequest($transaction_id); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getTransaction' + * + * @param string $transaction_id The ID for the transaction to get the information for. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getTransactionRequest($transaction_id) + { + // verify the required parameter 'transaction_id' is set + if ($transaction_id === null || (is_array($transaction_id) && count($transaction_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $transaction_id when calling getTransaction' + ); + } + + $resourcePath = '/transactions/{transaction_id}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($transaction_id !== null) { + $resourcePath = str_replace( + '{' . 'transaction_id' . '}', + ObjectSerializer::toPathValue($transaction_id), + $resourcePath + ); + } + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getTransactionRefund + * + * Get transaction refund + * + * @param string $transaction_id The ID for the transaction to get the information for. (required) + * @param string $refund_id The unique ID of the refund. (required) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\Refund|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error404NotFound + */ + public function getTransactionRefund($transaction_id, $refund_id) + { + list($response) = $this->getTransactionRefundWithHttpInfo($transaction_id, $refund_id); + return $response; + } + + /** + * Operation getTransactionRefundWithHttpInfo + * + * Get transaction refund + * + * @param string $transaction_id The ID for the transaction to get the information for. (required) + * @param string $refund_id The unique ID of the refund. (required) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\Refund|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error404NotFound, HTTP status code, HTTP response headers (array of strings) + */ + public function getTransactionRefundWithHttpInfo($transaction_id, $refund_id) + { + $request = $this->getTransactionRefundRequest($transaction_id, $refund_id); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\Gr4vy\model\Refund' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Refund' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Refund', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\Gr4vy\model\Error404NotFound' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error404NotFound' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error404NotFound', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\Refund'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + '\Gr4vy\model\Refund', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error404NotFound', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getTransactionRefundAsync + * + * Get transaction refund + * + * @param string $transaction_id The ID for the transaction to get the information for. (required) + * @param string $refund_id The unique ID of the refund. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getTransactionRefundAsync($transaction_id, $refund_id) + { + return $this->getTransactionRefundAsyncWithHttpInfo($transaction_id, $refund_id) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getTransactionRefundAsyncWithHttpInfo + * + * Get transaction refund + * + * @param string $transaction_id The ID for the transaction to get the information for. (required) + * @param string $refund_id The unique ID of the refund. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getTransactionRefundAsyncWithHttpInfo($transaction_id, $refund_id) + { + $returnType = '\Gr4vy\model\Refund'; + $request = $this->getTransactionRefundRequest($transaction_id, $refund_id); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getTransactionRefund' + * + * @param string $transaction_id The ID for the transaction to get the information for. (required) + * @param string $refund_id The unique ID of the refund. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getTransactionRefundRequest($transaction_id, $refund_id) + { + // verify the required parameter 'transaction_id' is set + if ($transaction_id === null || (is_array($transaction_id) && count($transaction_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $transaction_id when calling getTransactionRefund' + ); + } + // verify the required parameter 'refund_id' is set + if ($refund_id === null || (is_array($refund_id) && count($refund_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $refund_id when calling getTransactionRefund' + ); + } + + $resourcePath = '/transactions/{transaction_id}/refunds/{refund_id}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($transaction_id !== null) { + $resourcePath = str_replace( + '{' . 'transaction_id' . '}', + ObjectSerializer::toPathValue($transaction_id), + $resourcePath + ); + } + // path params + if ($refund_id !== null) { + $resourcePath = str_replace( + '{' . 'refund_id' . '}', + ObjectSerializer::toPathValue($refund_id), + $resourcePath + ); + } + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation listTransactionRefunds + * + * List transaction refunds + * + * @param string $transaction_id The ID for the transaction to get the information for. (required) + * @param int $limit Defines the maximum number of items to return for this request. (optional, default to 20) + * @param string $cursor A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\Refunds|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error404NotFound + */ + public function listTransactionRefunds($transaction_id, $limit = 20, $cursor = null) + { + list($response) = $this->listTransactionRefundsWithHttpInfo($transaction_id, $limit, $cursor); + return $response; + } + + /** + * Operation listTransactionRefundsWithHttpInfo + * + * List transaction refunds + * + * @param string $transaction_id The ID for the transaction to get the information for. (required) + * @param int $limit Defines the maximum number of items to return for this request. (optional, default to 20) + * @param string $cursor A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\Refunds|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error404NotFound, HTTP status code, HTTP response headers (array of strings) + */ + public function listTransactionRefundsWithHttpInfo($transaction_id, $limit = 20, $cursor = null) + { + $request = $this->listTransactionRefundsRequest($transaction_id, $limit, $cursor); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\Gr4vy\model\Refunds' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Refunds' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Refunds', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\Gr4vy\model\Error404NotFound' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error404NotFound' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error404NotFound', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\Refunds'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + '\Gr4vy\model\Refunds', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error404NotFound', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation listTransactionRefundsAsync + * + * List transaction refunds + * + * @param string $transaction_id The ID for the transaction to get the information for. (required) + * @param int $limit Defines the maximum number of items to return for this request. (optional, default to 20) + * @param string $cursor A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function listTransactionRefundsAsync($transaction_id, $limit = 20, $cursor = null) + { + return $this->listTransactionRefundsAsyncWithHttpInfo($transaction_id, $limit, $cursor) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation listTransactionRefundsAsyncWithHttpInfo + * + * List transaction refunds + * + * @param string $transaction_id The ID for the transaction to get the information for. (required) + * @param int $limit Defines the maximum number of items to return for this request. (optional, default to 20) + * @param string $cursor A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function listTransactionRefundsAsyncWithHttpInfo($transaction_id, $limit = 20, $cursor = null) + { + $returnType = '\Gr4vy\model\Refunds'; + $request = $this->listTransactionRefundsRequest($transaction_id, $limit, $cursor); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'listTransactionRefunds' + * + * @param string $transaction_id The ID for the transaction to get the information for. (required) + * @param int $limit Defines the maximum number of items to return for this request. (optional, default to 20) + * @param string $cursor A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function listTransactionRefundsRequest($transaction_id, $limit = 20, $cursor = null) + { + // verify the required parameter 'transaction_id' is set + if ($transaction_id === null || (is_array($transaction_id) && count($transaction_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $transaction_id when calling listTransactionRefunds' + ); + } + if ($limit !== null && $limit > 100) { + throw new \InvalidArgumentException('invalid value for "$limit" when calling TransactionsApi.listTransactionRefunds, must be smaller than or equal to 100.'); + } + if ($limit !== null && $limit < 1) { + throw new \InvalidArgumentException('invalid value for "$limit" when calling TransactionsApi.listTransactionRefunds, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/transactions/{transaction_id}/refunds'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $cursor, + 'cursor', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + + + // path params + if ($transaction_id !== null) { + $resourcePath = str_replace( + '{' . 'transaction_id' . '}', + ObjectSerializer::toPathValue($transaction_id), + $resourcePath + ); + } + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation listTransactions + * + * List transactions + * + * @param string $buyer_external_identifier Filters the results to only the items for which the `buyer` has an `external_identifier` that matches this value. (optional) + * @param string $buyer_id Filters the results to only the items for which the `buyer` has an `id` that matches this value. (optional) + * @param string $cursor A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. (optional) + * @param int $limit Defines the maximum number of items to return for this request. (optional, default to 20) + * @param int $amount_eq Filters for transactions that have an `amount` that is equal to the provided `amount_eq` value. (optional) + * @param int $amount_gte Filters for transactions that have an `amount` that is greater than or equal to the `amount_gte` value. (optional) + * @param int $amount_lte Filters for transactions that have an `amount` that is less than or equal to the `amount_lte` value. (optional) + * @param \DateTime $created_at_gte Filters the results to only transactions created after this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. (optional) + * @param \DateTime $created_at_lte Filters the results to only transactions created before this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. (optional) + * @param string[] $currency Filters for transactions that have matching `currency` values. The `currency` values provided must be formatted as 3-letter ISO currency code. (optional) + * @param string $external_identifier Filters the results to only the items for which the `external_identifier` matches this value. (optional) + * @param bool $has_refunds When set to `true`, filter for transactions that have at least one refund in any state associated with it. When set to `false`, filter for transactions that have no refunds. (optional) + * @param string $id Filters for the transaction that has a matching `id` value. (optional) + * @param string[] $metadata Filters for transactions where their `metadata` values contain all of the provided `metadata` keys. The value sent for `metadata` must be formatted as a JSON string, and all keys and values must be strings. This value should also be URL encoded. Duplicate keys are not supported. If a key is duplicated, only the last appearing value will be used. (optional) + * @param string[] $method Filters the results to only the items for which the `method` has been set to this value. (optional) + * @param string[] $payment_service_id Filters for transactions that were processed by the provided `payment_service_id` values. (optional) + * @param string $payment_service_transaction_id Filters for transactions that have a matching `payment_service_transaction_id` value. The `payment_service_transaction_id` is the identifier of the transaction given by the payment service. (optional) + * @param string $search Filters for transactions that have one of the following fields match exactly with the provided `search` value: * `buyer_external_identifier` * `buyer_id` * `external_identifier` * `id` * `payment_service_transaction_id` (optional) + * @param string[] $status Filters the results to only the transactions that have a `status` that matches with any of the provided status values. (optional) + * @param \DateTime $updated_at_gte Filters the results to only transactions last updated after this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. (optional) + * @param \DateTime $updated_at_lte Filters the results to only transactions last updated before this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. (optional) + * @param \DateTime $before_created_at Filters the results to only transactions created before this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. **WARNING** This filter is deprecated and may be removed eventually, use `created_at_lte` instead. (optional) (deprecated) + * @param \DateTime $after_created_at Filters the results to only transactions created after this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. **WARNING** This filter is deprecated and may be removed eventually, use `created_at_gte` instead. (optional) (deprecated) + * @param \DateTime $before_updated_at Filters the results to only transactions last updated before this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. **WARNING** This filter is deprecated and may be removed eventually, use `updated_at_lte` instead. (optional) (deprecated) + * @param \DateTime $after_updated_at Filters the results to only transactions last updated after this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. **WARNING** This filter is deprecated and may be removed eventually, use `updated_at_gte` instead. (optional) (deprecated) + * @param string $transaction_status Filters the results to only the transactions for which the `status` matches this value. **WARNING** This filter is deprecated and may be removed eventually, use `status` instead. (optional) (deprecated) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\Transactions|\Gr4vy\model\Error401Unauthorized + */ + public function listTransactions($buyer_external_identifier = null, $buyer_id = null, $cursor = null, $limit = 20, $amount_eq = null, $amount_gte = null, $amount_lte = null, $created_at_gte = null, $created_at_lte = null, $currency = null, $external_identifier = null, $has_refunds = null, $id = null, $metadata = null, $method = null, $payment_service_id = null, $payment_service_transaction_id = null, $search = null, $status = null, $updated_at_gte = null, $updated_at_lte = null, $before_created_at = null, $after_created_at = null, $before_updated_at = null, $after_updated_at = null, $transaction_status = null) + { + list($response) = $this->listTransactionsWithHttpInfo($buyer_external_identifier, $buyer_id, $cursor, $limit, $amount_eq, $amount_gte, $amount_lte, $created_at_gte, $created_at_lte, $currency, $external_identifier, $has_refunds, $id, $metadata, $method, $payment_service_id, $payment_service_transaction_id, $search, $status, $updated_at_gte, $updated_at_lte, $before_created_at, $after_created_at, $before_updated_at, $after_updated_at, $transaction_status); + return $response; + } + + /** + * Operation listTransactionsWithHttpInfo + * + * List transactions + * + * @param string $buyer_external_identifier Filters the results to only the items for which the `buyer` has an `external_identifier` that matches this value. (optional) + * @param string $buyer_id Filters the results to only the items for which the `buyer` has an `id` that matches this value. (optional) + * @param string $cursor A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. (optional) + * @param int $limit Defines the maximum number of items to return for this request. (optional, default to 20) + * @param int $amount_eq Filters for transactions that have an `amount` that is equal to the provided `amount_eq` value. (optional) + * @param int $amount_gte Filters for transactions that have an `amount` that is greater than or equal to the `amount_gte` value. (optional) + * @param int $amount_lte Filters for transactions that have an `amount` that is less than or equal to the `amount_lte` value. (optional) + * @param \DateTime $created_at_gte Filters the results to only transactions created after this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. (optional) + * @param \DateTime $created_at_lte Filters the results to only transactions created before this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. (optional) + * @param string[] $currency Filters for transactions that have matching `currency` values. The `currency` values provided must be formatted as 3-letter ISO currency code. (optional) + * @param string $external_identifier Filters the results to only the items for which the `external_identifier` matches this value. (optional) + * @param bool $has_refunds When set to `true`, filter for transactions that have at least one refund in any state associated with it. When set to `false`, filter for transactions that have no refunds. (optional) + * @param string $id Filters for the transaction that has a matching `id` value. (optional) + * @param string[] $metadata Filters for transactions where their `metadata` values contain all of the provided `metadata` keys. The value sent for `metadata` must be formatted as a JSON string, and all keys and values must be strings. This value should also be URL encoded. Duplicate keys are not supported. If a key is duplicated, only the last appearing value will be used. (optional) + * @param string[] $method Filters the results to only the items for which the `method` has been set to this value. (optional) + * @param string[] $payment_service_id Filters for transactions that were processed by the provided `payment_service_id` values. (optional) + * @param string $payment_service_transaction_id Filters for transactions that have a matching `payment_service_transaction_id` value. The `payment_service_transaction_id` is the identifier of the transaction given by the payment service. (optional) + * @param string $search Filters for transactions that have one of the following fields match exactly with the provided `search` value: * `buyer_external_identifier` * `buyer_id` * `external_identifier` * `id` * `payment_service_transaction_id` (optional) + * @param string[] $status Filters the results to only the transactions that have a `status` that matches with any of the provided status values. (optional) + * @param \DateTime $updated_at_gte Filters the results to only transactions last updated after this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. (optional) + * @param \DateTime $updated_at_lte Filters the results to only transactions last updated before this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. (optional) + * @param \DateTime $before_created_at Filters the results to only transactions created before this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. **WARNING** This filter is deprecated and may be removed eventually, use `created_at_lte` instead. (optional) (deprecated) + * @param \DateTime $after_created_at Filters the results to only transactions created after this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. **WARNING** This filter is deprecated and may be removed eventually, use `created_at_gte` instead. (optional) (deprecated) + * @param \DateTime $before_updated_at Filters the results to only transactions last updated before this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. **WARNING** This filter is deprecated and may be removed eventually, use `updated_at_lte` instead. (optional) (deprecated) + * @param \DateTime $after_updated_at Filters the results to only transactions last updated after this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. **WARNING** This filter is deprecated and may be removed eventually, use `updated_at_gte` instead. (optional) (deprecated) + * @param string $transaction_status Filters the results to only the transactions for which the `status` matches this value. **WARNING** This filter is deprecated and may be removed eventually, use `status` instead. (optional) (deprecated) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\Transactions|\Gr4vy\model\Error401Unauthorized, HTTP status code, HTTP response headers (array of strings) + */ + public function listTransactionsWithHttpInfo($buyer_external_identifier = null, $buyer_id = null, $cursor = null, $limit = 20, $amount_eq = null, $amount_gte = null, $amount_lte = null, $created_at_gte = null, $created_at_lte = null, $currency = null, $external_identifier = null, $has_refunds = null, $id = null, $metadata = null, $method = null, $payment_service_id = null, $payment_service_transaction_id = null, $search = null, $status = null, $updated_at_gte = null, $updated_at_lte = null, $before_created_at = null, $after_created_at = null, $before_updated_at = null, $after_updated_at = null, $transaction_status = null) + { + $request = $this->listTransactionsRequest($buyer_external_identifier, $buyer_id, $cursor, $limit, $amount_eq, $amount_gte, $amount_lte, $created_at_gte, $created_at_lte, $currency, $external_identifier, $has_refunds, $id, $metadata, $method, $payment_service_id, $payment_service_transaction_id, $search, $status, $updated_at_gte, $updated_at_lte, $before_created_at, $after_created_at, $before_updated_at, $after_updated_at, $transaction_status); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\Gr4vy\model\Transactions' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Transactions' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Transactions', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\Transactions'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + '\Gr4vy\model\Transactions', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation listTransactionsAsync + * + * List transactions + * + * @param string $buyer_external_identifier Filters the results to only the items for which the `buyer` has an `external_identifier` that matches this value. (optional) + * @param string $buyer_id Filters the results to only the items for which the `buyer` has an `id` that matches this value. (optional) + * @param string $cursor A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. (optional) + * @param int $limit Defines the maximum number of items to return for this request. (optional, default to 20) + * @param int $amount_eq Filters for transactions that have an `amount` that is equal to the provided `amount_eq` value. (optional) + * @param int $amount_gte Filters for transactions that have an `amount` that is greater than or equal to the `amount_gte` value. (optional) + * @param int $amount_lte Filters for transactions that have an `amount` that is less than or equal to the `amount_lte` value. (optional) + * @param \DateTime $created_at_gte Filters the results to only transactions created after this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. (optional) + * @param \DateTime $created_at_lte Filters the results to only transactions created before this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. (optional) + * @param string[] $currency Filters for transactions that have matching `currency` values. The `currency` values provided must be formatted as 3-letter ISO currency code. (optional) + * @param string $external_identifier Filters the results to only the items for which the `external_identifier` matches this value. (optional) + * @param bool $has_refunds When set to `true`, filter for transactions that have at least one refund in any state associated with it. When set to `false`, filter for transactions that have no refunds. (optional) + * @param string $id Filters for the transaction that has a matching `id` value. (optional) + * @param string[] $metadata Filters for transactions where their `metadata` values contain all of the provided `metadata` keys. The value sent for `metadata` must be formatted as a JSON string, and all keys and values must be strings. This value should also be URL encoded. Duplicate keys are not supported. If a key is duplicated, only the last appearing value will be used. (optional) + * @param string[] $method Filters the results to only the items for which the `method` has been set to this value. (optional) + * @param string[] $payment_service_id Filters for transactions that were processed by the provided `payment_service_id` values. (optional) + * @param string $payment_service_transaction_id Filters for transactions that have a matching `payment_service_transaction_id` value. The `payment_service_transaction_id` is the identifier of the transaction given by the payment service. (optional) + * @param string $search Filters for transactions that have one of the following fields match exactly with the provided `search` value: * `buyer_external_identifier` * `buyer_id` * `external_identifier` * `id` * `payment_service_transaction_id` (optional) + * @param string[] $status Filters the results to only the transactions that have a `status` that matches with any of the provided status values. (optional) + * @param \DateTime $updated_at_gte Filters the results to only transactions last updated after this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. (optional) + * @param \DateTime $updated_at_lte Filters the results to only transactions last updated before this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. (optional) + * @param \DateTime $before_created_at Filters the results to only transactions created before this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. **WARNING** This filter is deprecated and may be removed eventually, use `created_at_lte` instead. (optional) (deprecated) + * @param \DateTime $after_created_at Filters the results to only transactions created after this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. **WARNING** This filter is deprecated and may be removed eventually, use `created_at_gte` instead. (optional) (deprecated) + * @param \DateTime $before_updated_at Filters the results to only transactions last updated before this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. **WARNING** This filter is deprecated and may be removed eventually, use `updated_at_lte` instead. (optional) (deprecated) + * @param \DateTime $after_updated_at Filters the results to only transactions last updated after this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. **WARNING** This filter is deprecated and may be removed eventually, use `updated_at_gte` instead. (optional) (deprecated) + * @param string $transaction_status Filters the results to only the transactions for which the `status` matches this value. **WARNING** This filter is deprecated and may be removed eventually, use `status` instead. (optional) (deprecated) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function listTransactionsAsync($buyer_external_identifier = null, $buyer_id = null, $cursor = null, $limit = 20, $amount_eq = null, $amount_gte = null, $amount_lte = null, $created_at_gte = null, $created_at_lte = null, $currency = null, $external_identifier = null, $has_refunds = null, $id = null, $metadata = null, $method = null, $payment_service_id = null, $payment_service_transaction_id = null, $search = null, $status = null, $updated_at_gte = null, $updated_at_lte = null, $before_created_at = null, $after_created_at = null, $before_updated_at = null, $after_updated_at = null, $transaction_status = null) + { + return $this->listTransactionsAsyncWithHttpInfo($buyer_external_identifier, $buyer_id, $cursor, $limit, $amount_eq, $amount_gte, $amount_lte, $created_at_gte, $created_at_lte, $currency, $external_identifier, $has_refunds, $id, $metadata, $method, $payment_service_id, $payment_service_transaction_id, $search, $status, $updated_at_gte, $updated_at_lte, $before_created_at, $after_created_at, $before_updated_at, $after_updated_at, $transaction_status) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation listTransactionsAsyncWithHttpInfo + * + * List transactions + * + * @param string $buyer_external_identifier Filters the results to only the items for which the `buyer` has an `external_identifier` that matches this value. (optional) + * @param string $buyer_id Filters the results to only the items for which the `buyer` has an `id` that matches this value. (optional) + * @param string $cursor A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. (optional) + * @param int $limit Defines the maximum number of items to return for this request. (optional, default to 20) + * @param int $amount_eq Filters for transactions that have an `amount` that is equal to the provided `amount_eq` value. (optional) + * @param int $amount_gte Filters for transactions that have an `amount` that is greater than or equal to the `amount_gte` value. (optional) + * @param int $amount_lte Filters for transactions that have an `amount` that is less than or equal to the `amount_lte` value. (optional) + * @param \DateTime $created_at_gte Filters the results to only transactions created after this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. (optional) + * @param \DateTime $created_at_lte Filters the results to only transactions created before this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. (optional) + * @param string[] $currency Filters for transactions that have matching `currency` values. The `currency` values provided must be formatted as 3-letter ISO currency code. (optional) + * @param string $external_identifier Filters the results to only the items for which the `external_identifier` matches this value. (optional) + * @param bool $has_refunds When set to `true`, filter for transactions that have at least one refund in any state associated with it. When set to `false`, filter for transactions that have no refunds. (optional) + * @param string $id Filters for the transaction that has a matching `id` value. (optional) + * @param string[] $metadata Filters for transactions where their `metadata` values contain all of the provided `metadata` keys. The value sent for `metadata` must be formatted as a JSON string, and all keys and values must be strings. This value should also be URL encoded. Duplicate keys are not supported. If a key is duplicated, only the last appearing value will be used. (optional) + * @param string[] $method Filters the results to only the items for which the `method` has been set to this value. (optional) + * @param string[] $payment_service_id Filters for transactions that were processed by the provided `payment_service_id` values. (optional) + * @param string $payment_service_transaction_id Filters for transactions that have a matching `payment_service_transaction_id` value. The `payment_service_transaction_id` is the identifier of the transaction given by the payment service. (optional) + * @param string $search Filters for transactions that have one of the following fields match exactly with the provided `search` value: * `buyer_external_identifier` * `buyer_id` * `external_identifier` * `id` * `payment_service_transaction_id` (optional) + * @param string[] $status Filters the results to only the transactions that have a `status` that matches with any of the provided status values. (optional) + * @param \DateTime $updated_at_gte Filters the results to only transactions last updated after this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. (optional) + * @param \DateTime $updated_at_lte Filters the results to only transactions last updated before this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. (optional) + * @param \DateTime $before_created_at Filters the results to only transactions created before this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. **WARNING** This filter is deprecated and may be removed eventually, use `created_at_lte` instead. (optional) (deprecated) + * @param \DateTime $after_created_at Filters the results to only transactions created after this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. **WARNING** This filter is deprecated and may be removed eventually, use `created_at_gte` instead. (optional) (deprecated) + * @param \DateTime $before_updated_at Filters the results to only transactions last updated before this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. **WARNING** This filter is deprecated and may be removed eventually, use `updated_at_lte` instead. (optional) (deprecated) + * @param \DateTime $after_updated_at Filters the results to only transactions last updated after this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. **WARNING** This filter is deprecated and may be removed eventually, use `updated_at_gte` instead. (optional) (deprecated) + * @param string $transaction_status Filters the results to only the transactions for which the `status` matches this value. **WARNING** This filter is deprecated and may be removed eventually, use `status` instead. (optional) (deprecated) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function listTransactionsAsyncWithHttpInfo($buyer_external_identifier = null, $buyer_id = null, $cursor = null, $limit = 20, $amount_eq = null, $amount_gte = null, $amount_lte = null, $created_at_gte = null, $created_at_lte = null, $currency = null, $external_identifier = null, $has_refunds = null, $id = null, $metadata = null, $method = null, $payment_service_id = null, $payment_service_transaction_id = null, $search = null, $status = null, $updated_at_gte = null, $updated_at_lte = null, $before_created_at = null, $after_created_at = null, $before_updated_at = null, $after_updated_at = null, $transaction_status = null) + { + $returnType = '\Gr4vy\model\Transactions'; + $request = $this->listTransactionsRequest($buyer_external_identifier, $buyer_id, $cursor, $limit, $amount_eq, $amount_gte, $amount_lte, $created_at_gte, $created_at_lte, $currency, $external_identifier, $has_refunds, $id, $metadata, $method, $payment_service_id, $payment_service_transaction_id, $search, $status, $updated_at_gte, $updated_at_lte, $before_created_at, $after_created_at, $before_updated_at, $after_updated_at, $transaction_status); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'listTransactions' + * + * @param string $buyer_external_identifier Filters the results to only the items for which the `buyer` has an `external_identifier` that matches this value. (optional) + * @param string $buyer_id Filters the results to only the items for which the `buyer` has an `id` that matches this value. (optional) + * @param string $cursor A cursor that identifies the page of results to return. This is used to paginate the results of this API. For the first page of results, this parameter can be left out. For additional pages, use the value returned by the API in the `next_cursor` field. Similarly the `previous_cursor` can be used to reverse backwards in the list. (optional) + * @param int $limit Defines the maximum number of items to return for this request. (optional, default to 20) + * @param int $amount_eq Filters for transactions that have an `amount` that is equal to the provided `amount_eq` value. (optional) + * @param int $amount_gte Filters for transactions that have an `amount` that is greater than or equal to the `amount_gte` value. (optional) + * @param int $amount_lte Filters for transactions that have an `amount` that is less than or equal to the `amount_lte` value. (optional) + * @param \DateTime $created_at_gte Filters the results to only transactions created after this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. (optional) + * @param \DateTime $created_at_lte Filters the results to only transactions created before this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. (optional) + * @param string[] $currency Filters for transactions that have matching `currency` values. The `currency` values provided must be formatted as 3-letter ISO currency code. (optional) + * @param string $external_identifier Filters the results to only the items for which the `external_identifier` matches this value. (optional) + * @param bool $has_refunds When set to `true`, filter for transactions that have at least one refund in any state associated with it. When set to `false`, filter for transactions that have no refunds. (optional) + * @param string $id Filters for the transaction that has a matching `id` value. (optional) + * @param string[] $metadata Filters for transactions where their `metadata` values contain all of the provided `metadata` keys. The value sent for `metadata` must be formatted as a JSON string, and all keys and values must be strings. This value should also be URL encoded. Duplicate keys are not supported. If a key is duplicated, only the last appearing value will be used. (optional) + * @param string[] $method Filters the results to only the items for which the `method` has been set to this value. (optional) + * @param string[] $payment_service_id Filters for transactions that were processed by the provided `payment_service_id` values. (optional) + * @param string $payment_service_transaction_id Filters for transactions that have a matching `payment_service_transaction_id` value. The `payment_service_transaction_id` is the identifier of the transaction given by the payment service. (optional) + * @param string $search Filters for transactions that have one of the following fields match exactly with the provided `search` value: * `buyer_external_identifier` * `buyer_id` * `external_identifier` * `id` * `payment_service_transaction_id` (optional) + * @param string[] $status Filters the results to only the transactions that have a `status` that matches with any of the provided status values. (optional) + * @param \DateTime $updated_at_gte Filters the results to only transactions last updated after this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. (optional) + * @param \DateTime $updated_at_lte Filters the results to only transactions last updated before this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. (optional) + * @param \DateTime $before_created_at Filters the results to only transactions created before this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. **WARNING** This filter is deprecated and may be removed eventually, use `created_at_lte` instead. (optional) (deprecated) + * @param \DateTime $after_created_at Filters the results to only transactions created after this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. **WARNING** This filter is deprecated and may be removed eventually, use `created_at_gte` instead. (optional) (deprecated) + * @param \DateTime $before_updated_at Filters the results to only transactions last updated before this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. **WARNING** This filter is deprecated and may be removed eventually, use `updated_at_lte` instead. (optional) (deprecated) + * @param \DateTime $after_updated_at Filters the results to only transactions last updated after this ISO date-time string. The time zone must be included. Ensure that the date-time string is URL encoded, e.g. `2022-01-01T12:00:00+08:00` must be encoded as `2022-01-01T12%3A00%3A00%2B08%3A00`. **WARNING** This filter is deprecated and may be removed eventually, use `updated_at_gte` instead. (optional) (deprecated) + * @param string $transaction_status Filters the results to only the transactions for which the `status` matches this value. **WARNING** This filter is deprecated and may be removed eventually, use `status` instead. (optional) (deprecated) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function listTransactionsRequest($buyer_external_identifier = null, $buyer_id = null, $cursor = null, $limit = 20, $amount_eq = null, $amount_gte = null, $amount_lte = null, $created_at_gte = null, $created_at_lte = null, $currency = null, $external_identifier = null, $has_refunds = null, $id = null, $metadata = null, $method = null, $payment_service_id = null, $payment_service_transaction_id = null, $search = null, $status = null, $updated_at_gte = null, $updated_at_lte = null, $before_created_at = null, $after_created_at = null, $before_updated_at = null, $after_updated_at = null, $transaction_status = null) + { + if ($limit !== null && $limit > 500) { + throw new \InvalidArgumentException('invalid value for "$limit" when calling TransactionsApi.listTransactions, must be smaller than or equal to 500.'); + } + if ($limit !== null && $limit < 1) { + throw new \InvalidArgumentException('invalid value for "$limit" when calling TransactionsApi.listTransactions, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/transactions'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $buyer_external_identifier, + 'buyer_external_identifier', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $buyer_id, + 'buyer_id', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $cursor, + 'cursor', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $amount_eq, + 'amount_eq', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $amount_gte, + 'amount_gte', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $amount_lte, + 'amount_lte', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $created_at_gte, + 'created_at_gte', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $created_at_lte, + 'created_at_lte', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $currency, + 'currency', // param base name + 'array', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $external_identifier, + 'external_identifier', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $has_refunds, + 'has_refunds', // param base name + 'boolean', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $id, + 'id', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $metadata, + 'metadata', // param base name + 'array', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $method, + 'method', // param base name + 'array', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $payment_service_id, + 'payment_service_id', // param base name + 'array', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $payment_service_transaction_id, + 'payment_service_transaction_id', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $search, + 'search', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $status, + 'status', // param base name + 'array', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $updated_at_gte, + 'updated_at_gte', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $updated_at_lte, + 'updated_at_lte', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $before_created_at, + 'before_created_at', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $after_created_at, + 'after_created_at', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $before_updated_at, + 'before_updated_at', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $after_updated_at, + 'after_updated_at', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $transaction_status, + 'transaction_status', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + + + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation refundTransaction + * + * Refund transaction + * + * @param string $transaction_id The ID for the transaction to get the information for. (required) + * @param \Gr4vy\model\TransactionRefundRequest $transaction_refund_request transaction_refund_request (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\Refund|\Gr4vy\model\ErrorGeneric|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error404NotFound + */ + public function refundTransaction($transaction_id, $transaction_refund_request = null) + { + list($response) = $this->refundTransactionWithHttpInfo($transaction_id, $transaction_refund_request); + return $response; + } + + /** + * Operation refundTransactionWithHttpInfo + * + * Refund transaction + * + * @param string $transaction_id The ID for the transaction to get the information for. (required) + * @param \Gr4vy\model\TransactionRefundRequest $transaction_refund_request (optional) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\Refund|\Gr4vy\model\ErrorGeneric|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error404NotFound, HTTP status code, HTTP response headers (array of strings) + */ + public function refundTransactionWithHttpInfo($transaction_id, $transaction_refund_request = null) + { + $request = $this->refundTransactionRequest($transaction_id, $transaction_refund_request); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 201: + if ('\Gr4vy\model\Refund' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Refund' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Refund', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\Gr4vy\model\ErrorGeneric' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\ErrorGeneric' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\ErrorGeneric', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\Gr4vy\model\Error404NotFound' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error404NotFound' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error404NotFound', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\Refund'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 201: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Refund', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\ErrorGeneric', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error404NotFound', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation refundTransactionAsync + * + * Refund transaction + * + * @param string $transaction_id The ID for the transaction to get the information for. (required) + * @param \Gr4vy\model\TransactionRefundRequest $transaction_refund_request (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function refundTransactionAsync($transaction_id, $transaction_refund_request = null) + { + return $this->refundTransactionAsyncWithHttpInfo($transaction_id, $transaction_refund_request) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation refundTransactionAsyncWithHttpInfo + * + * Refund transaction + * + * @param string $transaction_id The ID for the transaction to get the information for. (required) + * @param \Gr4vy\model\TransactionRefundRequest $transaction_refund_request (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function refundTransactionAsyncWithHttpInfo($transaction_id, $transaction_refund_request = null) + { + $returnType = '\Gr4vy\model\Refund'; + $request = $this->refundTransactionRequest($transaction_id, $transaction_refund_request); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'refundTransaction' + * + * @param string $transaction_id The ID for the transaction to get the information for. (required) + * @param \Gr4vy\model\TransactionRefundRequest $transaction_refund_request (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function refundTransactionRequest($transaction_id, $transaction_refund_request = null) + { + // verify the required parameter 'transaction_id' is set + if ($transaction_id === null || (is_array($transaction_id) && count($transaction_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $transaction_id when calling refundTransaction' + ); + } + + $resourcePath = '/transactions/{transaction_id}/refunds'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = '{}'; + $multipart = false; + + + + // path params + if ($transaction_id !== null) { + $resourcePath = str_replace( + '{' . 'transaction_id' . '}', + ObjectSerializer::toPathValue($transaction_id), + $resourcePath + ); + } + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($transaction_refund_request)) { + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($transaction_refund_request)); + } else { + $httpBody = $transaction_refund_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation voidTransaction + * + * Void transaction + * + * @param string $transaction_id The ID for the transaction to get the information for. (required) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Gr4vy\model\Transaction|\Gr4vy\model\ErrorGeneric|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error404NotFound + */ + public function voidTransaction($transaction_id) + { + list($response) = $this->voidTransactionWithHttpInfo($transaction_id); + return $response; + } + + /** + * Operation voidTransactionWithHttpInfo + * + * Void transaction + * + * @param string $transaction_id The ID for the transaction to get the information for. (required) + * + * @throws \Gr4vy\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Gr4vy\model\Transaction|\Gr4vy\model\ErrorGeneric|\Gr4vy\model\Error401Unauthorized|\Gr4vy\model\Error404NotFound, HTTP status code, HTTP response headers (array of strings) + */ + public function voidTransactionWithHttpInfo($transaction_id) + { + $request = $this->voidTransactionRequest($transaction_id); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\Gr4vy\model\Transaction' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Transaction' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Transaction', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\Gr4vy\model\ErrorGeneric' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\ErrorGeneric' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\ErrorGeneric', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Gr4vy\model\Error401Unauthorized' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error401Unauthorized' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error401Unauthorized', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\Gr4vy\model\Error404NotFound' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Gr4vy\model\Error404NotFound' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\Gr4vy\model\Error404NotFound', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Gr4vy\model\Transaction'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + '\Gr4vy\model\Transaction', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\ErrorGeneric', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error401Unauthorized', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Gr4vy\model\Error404NotFound', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation voidTransactionAsync + * + * Void transaction + * + * @param string $transaction_id The ID for the transaction to get the information for. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function voidTransactionAsync($transaction_id) + { + return $this->voidTransactionAsyncWithHttpInfo($transaction_id) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation voidTransactionAsyncWithHttpInfo + * + * Void transaction + * + * @param string $transaction_id The ID for the transaction to get the information for. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function voidTransactionAsyncWithHttpInfo($transaction_id) + { + $returnType = '\Gr4vy\model\Transaction'; + $request = $this->voidTransactionRequest($transaction_id); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'voidTransaction' + * + * @param string $transaction_id The ID for the transaction to get the information for. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function voidTransactionRequest($transaction_id) + { + // verify the required parameter 'transaction_id' is set + if ($transaction_id === null || (is_array($transaction_id) && count($transaction_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $transaction_id when calling voidTransaction' + ); + } + + $resourcePath = '/transactions/{transaction_id}/void'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($transaction_id !== null) { + $resourcePath = str_replace( + '{' . 'transaction_id' . '}', + ObjectSerializer::toPathValue($transaction_id), + $resourcePath + ); + } + + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // 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 = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer (JWT) authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($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/model/Address.php b/lib/model/Address.php new file mode 100644 index 0000000..4b68d48 --- /dev/null +++ b/lib/model/Address.php @@ -0,0 +1,699 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class Address implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'Address'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'city' => 'string', + 'country' => 'string', + 'postal_code' => 'string', + 'state' => 'string', + 'state_code' => 'string', + 'house_number_or_name' => 'string', + 'line1' => 'string', + 'line2' => 'string', + 'organization' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'city' => null, + 'country' => null, + 'postal_code' => null, + 'state' => null, + 'state_code' => null, + 'house_number_or_name' => null, + 'line1' => null, + 'line2' => null, + 'organization' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'city' => 'city', + 'country' => 'country', + 'postal_code' => 'postal_code', + 'state' => 'state', + 'state_code' => 'state_code', + 'house_number_or_name' => 'house_number_or_name', + 'line1' => 'line1', + 'line2' => 'line2', + 'organization' => 'organization' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'city' => 'setCity', + 'country' => 'setCountry', + 'postal_code' => 'setPostalCode', + 'state' => 'setState', + 'state_code' => 'setStateCode', + 'house_number_or_name' => 'setHouseNumberOrName', + 'line1' => 'setLine1', + 'line2' => 'setLine2', + 'organization' => 'setOrganization' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'city' => 'getCity', + 'country' => 'getCountry', + 'postal_code' => 'getPostalCode', + 'state' => 'getState', + 'state_code' => 'getStateCode', + 'house_number_or_name' => 'getHouseNumberOrName', + 'line1' => 'getLine1', + 'line2' => 'getLine2', + 'organization' => 'getOrganization' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['city'] = $data['city'] ?? null; + $this->container['country'] = $data['country'] ?? null; + $this->container['postal_code'] = $data['postal_code'] ?? null; + $this->container['state'] = $data['state'] ?? null; + $this->container['state_code'] = $data['state_code'] ?? null; + $this->container['house_number_or_name'] = $data['house_number_or_name'] ?? null; + $this->container['line1'] = $data['line1'] ?? null; + $this->container['line2'] = $data['line2'] ?? null; + $this->container['organization'] = $data['organization'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['city']) && (mb_strlen($this->container['city']) > 100)) { + $invalidProperties[] = "invalid value for 'city', the character length must be smaller than or equal to 100."; + } + + if (!is_null($this->container['city']) && (mb_strlen($this->container['city']) < 1)) { + $invalidProperties[] = "invalid value for 'city', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['country']) && (mb_strlen($this->container['country']) > 2)) { + $invalidProperties[] = "invalid value for 'country', the character length must be smaller than or equal to 2."; + } + + if (!is_null($this->container['country']) && (mb_strlen($this->container['country']) < 1)) { + $invalidProperties[] = "invalid value for 'country', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['postal_code']) && (mb_strlen($this->container['postal_code']) > 50)) { + $invalidProperties[] = "invalid value for 'postal_code', the character length must be smaller than or equal to 50."; + } + + if (!is_null($this->container['postal_code']) && (mb_strlen($this->container['postal_code']) < 1)) { + $invalidProperties[] = "invalid value for 'postal_code', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['state']) && (mb_strlen($this->container['state']) > 255)) { + $invalidProperties[] = "invalid value for 'state', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['state']) && (mb_strlen($this->container['state']) < 1)) { + $invalidProperties[] = "invalid value for 'state', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['state_code']) && (mb_strlen($this->container['state_code']) > 6)) { + $invalidProperties[] = "invalid value for 'state_code', the character length must be smaller than or equal to 6."; + } + + if (!is_null($this->container['state_code']) && (mb_strlen($this->container['state_code']) < 4)) { + $invalidProperties[] = "invalid value for 'state_code', the character length must be bigger than or equal to 4."; + } + + if (!is_null($this->container['house_number_or_name']) && (mb_strlen($this->container['house_number_or_name']) > 255)) { + $invalidProperties[] = "invalid value for 'house_number_or_name', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['house_number_or_name']) && (mb_strlen($this->container['house_number_or_name']) < 1)) { + $invalidProperties[] = "invalid value for 'house_number_or_name', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['line1']) && (mb_strlen($this->container['line1']) > 255)) { + $invalidProperties[] = "invalid value for 'line1', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['line1']) && (mb_strlen($this->container['line1']) < 1)) { + $invalidProperties[] = "invalid value for 'line1', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['line2']) && (mb_strlen($this->container['line2']) > 255)) { + $invalidProperties[] = "invalid value for 'line2', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['line2']) && (mb_strlen($this->container['line2']) < 1)) { + $invalidProperties[] = "invalid value for 'line2', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['organization']) && (mb_strlen($this->container['organization']) > 255)) { + $invalidProperties[] = "invalid value for 'organization', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['organization']) && (mb_strlen($this->container['organization']) < 1)) { + $invalidProperties[] = "invalid value for 'organization', the character length must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets city + * + * @return string|null + */ + public function getCity() + { + return $this->container['city']; + } + + /** + * Sets city + * + * @param string|null $city The city for the billing address. + * + * @return self + */ + public function setCity($city) + { + if (!is_null($city) && (mb_strlen($city) > 100)) { + throw new \InvalidArgumentException('invalid length for $city when calling Address., must be smaller than or equal to 100.'); + } + if (!is_null($city) && (mb_strlen($city) < 1)) { + throw new \InvalidArgumentException('invalid length for $city when calling Address., must be bigger than or equal to 1.'); + } + + $this->container['city'] = $city; + + return $this; + } + + /** + * Gets country + * + * @return string|null + */ + public function getCountry() + { + return $this->container['country']; + } + + /** + * Sets country + * + * @param string|null $country The country for the billing address. + * + * @return self + */ + public function setCountry($country) + { + if (!is_null($country) && (mb_strlen($country) > 2)) { + throw new \InvalidArgumentException('invalid length for $country when calling Address., must be smaller than or equal to 2.'); + } + if (!is_null($country) && (mb_strlen($country) < 1)) { + throw new \InvalidArgumentException('invalid length for $country when calling Address., must be bigger than or equal to 1.'); + } + + $this->container['country'] = $country; + + return $this; + } + + /** + * Gets postal_code + * + * @return string|null + */ + public function getPostalCode() + { + return $this->container['postal_code']; + } + + /** + * Sets postal_code + * + * @param string|null $postal_code The postal code or zip code for the billing address. + * + * @return self + */ + public function setPostalCode($postal_code) + { + if (!is_null($postal_code) && (mb_strlen($postal_code) > 50)) { + throw new \InvalidArgumentException('invalid length for $postal_code when calling Address., must be smaller than or equal to 50.'); + } + if (!is_null($postal_code) && (mb_strlen($postal_code) < 1)) { + throw new \InvalidArgumentException('invalid length for $postal_code when calling Address., must be bigger than or equal to 1.'); + } + + $this->container['postal_code'] = $postal_code; + + return $this; + } + + /** + * Gets state + * + * @return string|null + */ + public function getState() + { + return $this->container['state']; + } + + /** + * Sets state + * + * @param string|null $state The state, county, or province for the billing address. + * + * @return self + */ + public function setState($state) + { + if (!is_null($state) && (mb_strlen($state) > 255)) { + throw new \InvalidArgumentException('invalid length for $state when calling Address., must be smaller than or equal to 255.'); + } + if (!is_null($state) && (mb_strlen($state) < 1)) { + throw new \InvalidArgumentException('invalid length for $state when calling Address., must be bigger than or equal to 1.'); + } + + $this->container['state'] = $state; + + return $this; + } + + /** + * Gets state_code + * + * @return string|null + */ + public function getStateCode() + { + return $this->container['state_code']; + } + + /** + * Sets state_code + * + * @param string|null $state_code The code of state, county, or province for the billing address in ISO 3166-2 format. + * + * @return self + */ + public function setStateCode($state_code) + { + if (!is_null($state_code) && (mb_strlen($state_code) > 6)) { + throw new \InvalidArgumentException('invalid length for $state_code when calling Address., must be smaller than or equal to 6.'); + } + if (!is_null($state_code) && (mb_strlen($state_code) < 4)) { + throw new \InvalidArgumentException('invalid length for $state_code when calling Address., must be bigger than or equal to 4.'); + } + + $this->container['state_code'] = $state_code; + + return $this; + } + + /** + * Gets house_number_or_name + * + * @return string|null + */ + public function getHouseNumberOrName() + { + return $this->container['house_number_or_name']; + } + + /** + * Sets house_number_or_name + * + * @param string|null $house_number_or_name The house number or name for the billing address. Not all payment services use this field but some do. + * + * @return self + */ + public function setHouseNumberOrName($house_number_or_name) + { + if (!is_null($house_number_or_name) && (mb_strlen($house_number_or_name) > 255)) { + throw new \InvalidArgumentException('invalid length for $house_number_or_name when calling Address., must be smaller than or equal to 255.'); + } + if (!is_null($house_number_or_name) && (mb_strlen($house_number_or_name) < 1)) { + throw new \InvalidArgumentException('invalid length for $house_number_or_name when calling Address., must be bigger than or equal to 1.'); + } + + $this->container['house_number_or_name'] = $house_number_or_name; + + return $this; + } + + /** + * Gets line1 + * + * @return string|null + */ + public function getLine1() + { + return $this->container['line1']; + } + + /** + * Sets line1 + * + * @param string|null $line1 The first line of the billing address. + * + * @return self + */ + public function setLine1($line1) + { + if (!is_null($line1) && (mb_strlen($line1) > 255)) { + throw new \InvalidArgumentException('invalid length for $line1 when calling Address., must be smaller than or equal to 255.'); + } + if (!is_null($line1) && (mb_strlen($line1) < 1)) { + throw new \InvalidArgumentException('invalid length for $line1 when calling Address., must be bigger than or equal to 1.'); + } + + $this->container['line1'] = $line1; + + return $this; + } + + /** + * Gets line2 + * + * @return string|null + */ + public function getLine2() + { + return $this->container['line2']; + } + + /** + * Sets line2 + * + * @param string|null $line2 The second line of the billing address. + * + * @return self + */ + public function setLine2($line2) + { + if (!is_null($line2) && (mb_strlen($line2) > 255)) { + throw new \InvalidArgumentException('invalid length for $line2 when calling Address., must be smaller than or equal to 255.'); + } + if (!is_null($line2) && (mb_strlen($line2) < 1)) { + throw new \InvalidArgumentException('invalid length for $line2 when calling Address., must be bigger than or equal to 1.'); + } + + $this->container['line2'] = $line2; + + return $this; + } + + /** + * Gets organization + * + * @return string|null + */ + public function getOrganization() + { + return $this->container['organization']; + } + + /** + * Sets organization + * + * @param string|null $organization The optional name of the company or organisation to add to the billing address. + * + * @return self + */ + public function setOrganization($organization) + { + if (!is_null($organization) && (mb_strlen($organization) > 255)) { + throw new \InvalidArgumentException('invalid length for $organization when calling Address., must be smaller than or equal to 255.'); + } + if (!is_null($organization) && (mb_strlen($organization) < 1)) { + throw new \InvalidArgumentException('invalid length for $organization when calling Address., must be bigger than or equal to 1.'); + } + + $this->container['organization'] = $organization; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/AntiFraudService.php b/lib/model/AntiFraudService.php new file mode 100644 index 0000000..65ea5e8 --- /dev/null +++ b/lib/model/AntiFraudService.php @@ -0,0 +1,614 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class AntiFraudService implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'AntiFraudService'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'id' => 'string', + 'anti_fraud_service_definition_id' => 'string', + 'display_name' => 'string', + 'active' => 'bool', + 'fields' => '\Gr4vy\model\AntiFraudServiceFieldsInner[]', + 'created_at' => '\DateTime', + 'updated_at' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'id' => 'uuid', + 'anti_fraud_service_definition_id' => null, + 'display_name' => null, + 'active' => null, + 'fields' => null, + 'created_at' => 'date-time', + 'updated_at' => 'date-time' + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'id' => 'id', + 'anti_fraud_service_definition_id' => 'anti_fraud_service_definition_id', + 'display_name' => 'display_name', + 'active' => 'active', + 'fields' => 'fields', + 'created_at' => 'created_at', + 'updated_at' => 'updated_at' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'id' => 'setId', + 'anti_fraud_service_definition_id' => 'setAntiFraudServiceDefinitionId', + 'display_name' => 'setDisplayName', + 'active' => 'setActive', + 'fields' => 'setFields', + 'created_at' => 'setCreatedAt', + 'updated_at' => 'setUpdatedAt' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'id' => 'getId', + 'anti_fraud_service_definition_id' => 'getAntiFraudServiceDefinitionId', + 'display_name' => 'getDisplayName', + 'active' => 'getActive', + 'fields' => 'getFields', + 'created_at' => 'getCreatedAt', + 'updated_at' => 'getUpdatedAt' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_ANTI_FRAUD_SERVICE = 'anti-fraud-service'; + public const ANTI_FRAUD_SERVICE_DEFINITION_ID_SIFT = 'sift'; + public const ANTI_FRAUD_SERVICE_DEFINITION_ID_CYBERSOURCE = 'cybersource'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_ANTI_FRAUD_SERVICE, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getAntiFraudServiceDefinitionIdAllowableValues() + { + return [ + self::ANTI_FRAUD_SERVICE_DEFINITION_ID_SIFT, + self::ANTI_FRAUD_SERVICE_DEFINITION_ID_CYBERSOURCE, + ]; + } + + /** + * 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['type'] = $data['type'] ?? null; + $this->container['id'] = $data['id'] ?? null; + $this->container['anti_fraud_service_definition_id'] = $data['anti_fraud_service_definition_id'] ?? null; + $this->container['display_name'] = $data['display_name'] ?? null; + $this->container['active'] = $data['active'] ?? true; + $this->container['fields'] = $data['fields'] ?? null; + $this->container['created_at'] = $data['created_at'] ?? null; + $this->container['updated_at'] = $data['updated_at'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getAntiFraudServiceDefinitionIdAllowableValues(); + if (!is_null($this->container['anti_fraud_service_definition_id']) && !in_array($this->container['anti_fraud_service_definition_id'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'anti_fraud_service_definition_id', must be one of '%s'", + $this->container['anti_fraud_service_definition_id'], + implode("', '", $allowedValues) + ); + } + + if (!is_null($this->container['display_name']) && (mb_strlen($this->container['display_name']) > 200)) { + $invalidProperties[] = "invalid value for 'display_name', the character length must be smaller than or equal to 200."; + } + + if (!is_null($this->container['display_name']) && (mb_strlen($this->container['display_name']) < 1)) { + $invalidProperties[] = "invalid value for 'display_name', the character length must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type The type of this resource. Is always `anti-fraud-service`. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id The unique Gr4vy ID for this anti-fraud service. + * + * @return self + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets anti_fraud_service_definition_id + * + * @return string|null + */ + public function getAntiFraudServiceDefinitionId() + { + return $this->container['anti_fraud_service_definition_id']; + } + + /** + * Sets anti_fraud_service_definition_id + * + * @param string|null $anti_fraud_service_definition_id The name of the Anti-Fraud service provider. During update request, this value is used for validation only but the underlying service can not be changed for an existing service. + * + * @return self + */ + public function setAntiFraudServiceDefinitionId($anti_fraud_service_definition_id) + { + $allowedValues = $this->getAntiFraudServiceDefinitionIdAllowableValues(); + if (!is_null($anti_fraud_service_definition_id) && !in_array($anti_fraud_service_definition_id, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'anti_fraud_service_definition_id', must be one of '%s'", + $anti_fraud_service_definition_id, + implode("', '", $allowedValues) + ) + ); + } + $this->container['anti_fraud_service_definition_id'] = $anti_fraud_service_definition_id; + + return $this; + } + + /** + * Gets display_name + * + * @return string|null + */ + public function getDisplayName() + { + return $this->container['display_name']; + } + + /** + * Sets display_name + * + * @param string|null $display_name A unique name for this anti-fraud service which is used in the Gr4vy admin panel to give a anti-fraud service a human readable name. + * + * @return self + */ + public function setDisplayName($display_name) + { + if (!is_null($display_name) && (mb_strlen($display_name) > 200)) { + throw new \InvalidArgumentException('invalid length for $display_name when calling AntiFraudService., must be smaller than or equal to 200.'); + } + if (!is_null($display_name) && (mb_strlen($display_name) < 1)) { + throw new \InvalidArgumentException('invalid length for $display_name when calling AntiFraudService., must be bigger than or equal to 1.'); + } + + $this->container['display_name'] = $display_name; + + return $this; + } + + /** + * Gets active + * + * @return bool|null + */ + public function getActive() + { + return $this->container['active']; + } + + /** + * Sets active + * + * @param bool|null $active Defines if this service is currently active or not. + * + * @return self + */ + public function setActive($active) + { + $this->container['active'] = $active; + + return $this; + } + + /** + * Gets fields + * + * @return \Gr4vy\model\AntiFraudServiceFieldsInner[]|null + */ + public function getFields() + { + return $this->container['fields']; + } + + /** + * Sets fields + * + * @param \Gr4vy\model\AntiFraudServiceFieldsInner[]|null $fields A list of fields, each containing a key-value pair for anti-fraud service decision mapping e.g. for sift `approve_decision` will be in the response. + * + * @return self + */ + public function setFields($fields) + { + $this->container['fields'] = $fields; + + return $this; + } + + /** + * Gets created_at + * + * @return \DateTime|null + */ + public function getCreatedAt() + { + return $this->container['created_at']; + } + + /** + * Sets created_at + * + * @param \DateTime|null $created_at The date and time when this anti-fraud service was created in our system. + * + * @return self + */ + public function setCreatedAt($created_at) + { + $this->container['created_at'] = $created_at; + + return $this; + } + + /** + * Gets updated_at + * + * @return \DateTime|null + */ + public function getUpdatedAt() + { + return $this->container['updated_at']; + } + + /** + * Sets updated_at + * + * @param \DateTime|null $updated_at The date and time when this anti-fraud service was last updated in our system. + * + * @return self + */ + public function setUpdatedAt($updated_at) + { + $this->container['updated_at'] = $updated_at; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/AntiFraudServiceCreate.php b/lib/model/AntiFraudServiceCreate.php new file mode 100644 index 0000000..7edefb8 --- /dev/null +++ b/lib/model/AntiFraudServiceCreate.php @@ -0,0 +1,472 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class AntiFraudServiceCreate implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'AntiFraudServiceCreate'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'anti_fraud_service_definition_id' => 'string', + 'display_name' => 'string', + 'active' => 'bool', + 'fields' => '\Gr4vy\model\AntiFraudServiceUpdateFieldsInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'anti_fraud_service_definition_id' => null, + 'display_name' => null, + 'active' => null, + 'fields' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'anti_fraud_service_definition_id' => 'anti_fraud_service_definition_id', + 'display_name' => 'display_name', + 'active' => 'active', + 'fields' => 'fields' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'anti_fraud_service_definition_id' => 'setAntiFraudServiceDefinitionId', + 'display_name' => 'setDisplayName', + 'active' => 'setActive', + 'fields' => 'setFields' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'anti_fraud_service_definition_id' => 'getAntiFraudServiceDefinitionId', + 'display_name' => 'getDisplayName', + 'active' => 'getActive', + 'fields' => 'getFields' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const ANTI_FRAUD_SERVICE_DEFINITION_ID_SIFT = 'sift'; + public const ANTI_FRAUD_SERVICE_DEFINITION_ID_CYBERSOURCE = 'cybersource'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getAntiFraudServiceDefinitionIdAllowableValues() + { + return [ + self::ANTI_FRAUD_SERVICE_DEFINITION_ID_SIFT, + self::ANTI_FRAUD_SERVICE_DEFINITION_ID_CYBERSOURCE, + ]; + } + + /** + * 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['anti_fraud_service_definition_id'] = $data['anti_fraud_service_definition_id'] ?? null; + $this->container['display_name'] = $data['display_name'] ?? null; + $this->container['active'] = $data['active'] ?? true; + $this->container['fields'] = $data['fields'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['anti_fraud_service_definition_id'] === null) { + $invalidProperties[] = "'anti_fraud_service_definition_id' can't be null"; + } + $allowedValues = $this->getAntiFraudServiceDefinitionIdAllowableValues(); + if (!is_null($this->container['anti_fraud_service_definition_id']) && !in_array($this->container['anti_fraud_service_definition_id'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'anti_fraud_service_definition_id', must be one of '%s'", + $this->container['anti_fraud_service_definition_id'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['display_name'] === null) { + $invalidProperties[] = "'display_name' can't be null"; + } + if ((mb_strlen($this->container['display_name']) > 200)) { + $invalidProperties[] = "invalid value for 'display_name', the character length must be smaller than or equal to 200."; + } + + if ((mb_strlen($this->container['display_name']) < 1)) { + $invalidProperties[] = "invalid value for 'display_name', the character length must be bigger than or equal to 1."; + } + + if ($this->container['fields'] === null) { + $invalidProperties[] = "'fields' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets anti_fraud_service_definition_id + * + * @return string + */ + public function getAntiFraudServiceDefinitionId() + { + return $this->container['anti_fraud_service_definition_id']; + } + + /** + * Sets anti_fraud_service_definition_id + * + * @param string $anti_fraud_service_definition_id The name of the Anti-Fraud service provider. During update request, this value is used for validation only but the underlying service can not be changed for an existing service. + * + * @return self + */ + public function setAntiFraudServiceDefinitionId($anti_fraud_service_definition_id) + { + $allowedValues = $this->getAntiFraudServiceDefinitionIdAllowableValues(); + if (!in_array($anti_fraud_service_definition_id, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'anti_fraud_service_definition_id', must be one of '%s'", + $anti_fraud_service_definition_id, + implode("', '", $allowedValues) + ) + ); + } + $this->container['anti_fraud_service_definition_id'] = $anti_fraud_service_definition_id; + + return $this; + } + + /** + * Gets display_name + * + * @return string + */ + public function getDisplayName() + { + return $this->container['display_name']; + } + + /** + * Sets display_name + * + * @param string $display_name A unique name for this anti-fraud service which is used in the Gr4vy admin panel to give a anti-fraud Service a human readable name. + * + * @return self + */ + public function setDisplayName($display_name) + { + if ((mb_strlen($display_name) > 200)) { + throw new \InvalidArgumentException('invalid length for $display_name when calling AntiFraudServiceCreate., must be smaller than or equal to 200.'); + } + if ((mb_strlen($display_name) < 1)) { + throw new \InvalidArgumentException('invalid length for $display_name when calling AntiFraudServiceCreate., must be bigger than or equal to 1.'); + } + + $this->container['display_name'] = $display_name; + + return $this; + } + + /** + * Gets active + * + * @return bool|null + */ + public function getActive() + { + return $this->container['active']; + } + + /** + * Sets active + * + * @param bool|null $active Defines if this service is currently active or not. + * + * @return self + */ + public function setActive($active) + { + $this->container['active'] = $active; + + return $this; + } + + /** + * Gets fields + * + * @return \Gr4vy\model\AntiFraudServiceUpdateFieldsInner[] + */ + public function getFields() + { + return $this->container['fields']; + } + + /** + * Sets fields + * + * @param \Gr4vy\model\AntiFraudServiceUpdateFieldsInner[] $fields A list of fields, each containing a key-value pair for each field defined by the definition for this anti-fraud service e.g. for sift `api_key` must be sent within this field when creating the service. For updates, only the fields sent here will be updated, existing ones will not be affected if not present. + * + * @return self + */ + public function setFields($fields) + { + $this->container['fields'] = $fields; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/AntiFraudServiceFieldsInner.php b/lib/model/AntiFraudServiceFieldsInner.php new file mode 100644 index 0000000..281d5ee --- /dev/null +++ b/lib/model/AntiFraudServiceFieldsInner.php @@ -0,0 +1,390 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class AntiFraudServiceFieldsInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'AntiFraudService_fields_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'key' => 'string', + 'value' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'key' => null, + 'value' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'key' => 'key', + 'value' => 'value' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'key' => 'setKey', + 'value' => 'setValue' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'key' => 'getKey', + 'value' => 'getValue' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['key'] = $data['key'] ?? null; + $this->container['value'] = $data['value'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['key'] === null) { + $invalidProperties[] = "'key' can't be null"; + } + if ((mb_strlen($this->container['key']) > 50)) { + $invalidProperties[] = "invalid value for 'key', the character length must be smaller than or equal to 50."; + } + + if ((mb_strlen($this->container['key']) < 1)) { + $invalidProperties[] = "invalid value for 'key', the character length must be bigger than or equal to 1."; + } + + if ($this->container['value'] === null) { + $invalidProperties[] = "'value' can't be null"; + } + if ((mb_strlen($this->container['value']) > 5000)) { + $invalidProperties[] = "invalid value for 'value', the character length must be smaller than or equal to 5000."; + } + + if ((mb_strlen($this->container['value']) < 1)) { + $invalidProperties[] = "invalid value for 'value', the character length must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets key + * + * @return string + */ + public function getKey() + { + return $this->container['key']; + } + + /** + * Sets key + * + * @param string $key The key of the field to set a value for. + * + * @return self + */ + public function setKey($key) + { + if ((mb_strlen($key) > 50)) { + throw new \InvalidArgumentException('invalid length for $key when calling AntiFraudServiceFieldsInner., must be smaller than or equal to 50.'); + } + if ((mb_strlen($key) < 1)) { + throw new \InvalidArgumentException('invalid length for $key when calling AntiFraudServiceFieldsInner., must be bigger than or equal to 1.'); + } + + $this->container['key'] = $key; + + return $this; + } + + /** + * Gets value + * + * @return string + */ + public function getValue() + { + return $this->container['value']; + } + + /** + * Sets value + * + * @param string $value The value of a field to set. + * + * @return self + */ + public function setValue($value) + { + if ((mb_strlen($value) > 5000)) { + throw new \InvalidArgumentException('invalid length for $value when calling AntiFraudServiceFieldsInner., must be smaller than or equal to 5000.'); + } + if ((mb_strlen($value) < 1)) { + throw new \InvalidArgumentException('invalid length for $value when calling AntiFraudServiceFieldsInner., must be bigger than or equal to 1.'); + } + + $this->container['value'] = $value; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/AntiFraudServiceUpdate.php b/lib/model/AntiFraudServiceUpdate.php new file mode 100644 index 0000000..e398cb9 --- /dev/null +++ b/lib/model/AntiFraudServiceUpdate.php @@ -0,0 +1,466 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class AntiFraudServiceUpdate implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'AntiFraudServiceUpdate'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'anti_fraud_service_definition_id' => 'string', + 'display_name' => 'string', + 'active' => 'bool', + 'fields' => '\Gr4vy\model\AntiFraudServiceUpdateFieldsInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'anti_fraud_service_definition_id' => null, + 'display_name' => null, + 'active' => null, + 'fields' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'anti_fraud_service_definition_id' => 'anti_fraud_service_definition_id', + 'display_name' => 'display_name', + 'active' => 'active', + 'fields' => 'fields' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'anti_fraud_service_definition_id' => 'setAntiFraudServiceDefinitionId', + 'display_name' => 'setDisplayName', + 'active' => 'setActive', + 'fields' => 'setFields' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'anti_fraud_service_definition_id' => 'getAntiFraudServiceDefinitionId', + 'display_name' => 'getDisplayName', + 'active' => 'getActive', + 'fields' => 'getFields' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const ANTI_FRAUD_SERVICE_DEFINITION_ID_SIFT = 'sift'; + public const ANTI_FRAUD_SERVICE_DEFINITION_ID_CYBERSOURCE = 'cybersource'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getAntiFraudServiceDefinitionIdAllowableValues() + { + return [ + self::ANTI_FRAUD_SERVICE_DEFINITION_ID_SIFT, + self::ANTI_FRAUD_SERVICE_DEFINITION_ID_CYBERSOURCE, + ]; + } + + /** + * 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['anti_fraud_service_definition_id'] = $data['anti_fraud_service_definition_id'] ?? null; + $this->container['display_name'] = $data['display_name'] ?? null; + $this->container['active'] = $data['active'] ?? true; + $this->container['fields'] = $data['fields'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['anti_fraud_service_definition_id'] === null) { + $invalidProperties[] = "'anti_fraud_service_definition_id' can't be null"; + } + $allowedValues = $this->getAntiFraudServiceDefinitionIdAllowableValues(); + if (!is_null($this->container['anti_fraud_service_definition_id']) && !in_array($this->container['anti_fraud_service_definition_id'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'anti_fraud_service_definition_id', must be one of '%s'", + $this->container['anti_fraud_service_definition_id'], + implode("', '", $allowedValues) + ); + } + + if (!is_null($this->container['display_name']) && (mb_strlen($this->container['display_name']) > 200)) { + $invalidProperties[] = "invalid value for 'display_name', the character length must be smaller than or equal to 200."; + } + + if (!is_null($this->container['display_name']) && (mb_strlen($this->container['display_name']) < 1)) { + $invalidProperties[] = "invalid value for 'display_name', the character length must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets anti_fraud_service_definition_id + * + * @return string + */ + public function getAntiFraudServiceDefinitionId() + { + return $this->container['anti_fraud_service_definition_id']; + } + + /** + * Sets anti_fraud_service_definition_id + * + * @param string $anti_fraud_service_definition_id The name of the Anti-Fraud service provider. During update request, this value is used for validation only but the underlying service can not be changed for an existing service. + * + * @return self + */ + public function setAntiFraudServiceDefinitionId($anti_fraud_service_definition_id) + { + $allowedValues = $this->getAntiFraudServiceDefinitionIdAllowableValues(); + if (!in_array($anti_fraud_service_definition_id, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'anti_fraud_service_definition_id', must be one of '%s'", + $anti_fraud_service_definition_id, + implode("', '", $allowedValues) + ) + ); + } + $this->container['anti_fraud_service_definition_id'] = $anti_fraud_service_definition_id; + + return $this; + } + + /** + * Gets display_name + * + * @return string|null + */ + public function getDisplayName() + { + return $this->container['display_name']; + } + + /** + * Sets display_name + * + * @param string|null $display_name A unique name for this anti-fraud service which is used in the Gr4vy admin panel to give a anti-fraud Service a human readable name. + * + * @return self + */ + public function setDisplayName($display_name) + { + if (!is_null($display_name) && (mb_strlen($display_name) > 200)) { + throw new \InvalidArgumentException('invalid length for $display_name when calling AntiFraudServiceUpdate., must be smaller than or equal to 200.'); + } + if (!is_null($display_name) && (mb_strlen($display_name) < 1)) { + throw new \InvalidArgumentException('invalid length for $display_name when calling AntiFraudServiceUpdate., must be bigger than or equal to 1.'); + } + + $this->container['display_name'] = $display_name; + + return $this; + } + + /** + * Gets active + * + * @return bool|null + */ + public function getActive() + { + return $this->container['active']; + } + + /** + * Sets active + * + * @param bool|null $active Defines if this service is currently active or not. + * + * @return self + */ + public function setActive($active) + { + $this->container['active'] = $active; + + return $this; + } + + /** + * Gets fields + * + * @return \Gr4vy\model\AntiFraudServiceUpdateFieldsInner[]|null + */ + public function getFields() + { + return $this->container['fields']; + } + + /** + * Sets fields + * + * @param \Gr4vy\model\AntiFraudServiceUpdateFieldsInner[]|null $fields A list of fields, each containing a key-value pair for each field defined by the definition for this anti-fraud service e.g. for sift `api_key` must be sent within this field when creating the service. For updates, only the fields sent here will be updated, existing ones will not be affected if not present. + * + * @return self + */ + public function setFields($fields) + { + $this->container['fields'] = $fields; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/AntiFraudServiceUpdateFieldsInner.php b/lib/model/AntiFraudServiceUpdateFieldsInner.php new file mode 100644 index 0000000..1282e11 --- /dev/null +++ b/lib/model/AntiFraudServiceUpdateFieldsInner.php @@ -0,0 +1,390 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class AntiFraudServiceUpdateFieldsInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'AntiFraudServiceUpdate_fields_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'key' => 'string', + 'value' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'key' => null, + 'value' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'key' => 'key', + 'value' => 'value' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'key' => 'setKey', + 'value' => 'setValue' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'key' => 'getKey', + 'value' => 'getValue' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['key'] = $data['key'] ?? null; + $this->container['value'] = $data['value'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['key'] === null) { + $invalidProperties[] = "'key' can't be null"; + } + if ((mb_strlen($this->container['key']) > 50)) { + $invalidProperties[] = "invalid value for 'key', the character length must be smaller than or equal to 50."; + } + + if ((mb_strlen($this->container['key']) < 1)) { + $invalidProperties[] = "invalid value for 'key', the character length must be bigger than or equal to 1."; + } + + if ($this->container['value'] === null) { + $invalidProperties[] = "'value' can't be null"; + } + if ((mb_strlen($this->container['value']) > 5000)) { + $invalidProperties[] = "invalid value for 'value', the character length must be smaller than or equal to 5000."; + } + + if ((mb_strlen($this->container['value']) < 1)) { + $invalidProperties[] = "invalid value for 'value', the character length must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets key + * + * @return string + */ + public function getKey() + { + return $this->container['key']; + } + + /** + * Sets key + * + * @param string $key The key of the field to set a value for. + * + * @return self + */ + public function setKey($key) + { + if ((mb_strlen($key) > 50)) { + throw new \InvalidArgumentException('invalid length for $key when calling AntiFraudServiceUpdateFieldsInner., must be smaller than or equal to 50.'); + } + if ((mb_strlen($key) < 1)) { + throw new \InvalidArgumentException('invalid length for $key when calling AntiFraudServiceUpdateFieldsInner., must be bigger than or equal to 1.'); + } + + $this->container['key'] = $key; + + return $this; + } + + /** + * Gets value + * + * @return string + */ + public function getValue() + { + return $this->container['value']; + } + + /** + * Sets value + * + * @param string $value The value of a field to set. + * + * @return self + */ + public function setValue($value) + { + if ((mb_strlen($value) > 5000)) { + throw new \InvalidArgumentException('invalid length for $value when calling AntiFraudServiceUpdateFieldsInner., must be smaller than or equal to 5000.'); + } + if ((mb_strlen($value) < 1)) { + throw new \InvalidArgumentException('invalid length for $value when calling AntiFraudServiceUpdateFieldsInner., must be bigger than or equal to 1.'); + } + + $this->container['value'] = $value; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/ApplePayRequest.php b/lib/model/ApplePayRequest.php new file mode 100644 index 0000000..c6ef27f --- /dev/null +++ b/lib/model/ApplePayRequest.php @@ -0,0 +1,392 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class ApplePayRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ApplePayRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'method' => 'string', + 'token' => 'object' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'method' => null, + 'token' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'method' => 'method', + 'token' => 'token' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'method' => 'setMethod', + 'token' => 'setToken' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'method' => 'getMethod', + 'token' => 'getToken' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const METHOD_APPLEPAY = 'applepay'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getMethodAllowableValues() + { + return [ + self::METHOD_APPLEPAY, + ]; + } + + /** + * 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['method'] = $data['method'] ?? null; + $this->container['token'] = $data['token'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['method'] === null) { + $invalidProperties[] = "'method' can't be null"; + } + $allowedValues = $this->getMethodAllowableValues(); + if (!is_null($this->container['method']) && !in_array($this->container['method'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'method', must be one of '%s'", + $this->container['method'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['token'] === null) { + $invalidProperties[] = "'token' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets method + * + * @return string + */ + public function getMethod() + { + return $this->container['method']; + } + + /** + * Sets method + * + * @param string $method `applepay`. + * + * @return self + */ + public function setMethod($method) + { + $allowedValues = $this->getMethodAllowableValues(); + if (!in_array($method, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'method', must be one of '%s'", + $method, + implode("', '", $allowedValues) + ) + ); + } + $this->container['method'] = $method; + + return $this; + } + + /** + * Gets token + * + * @return object + */ + public function getToken() + { + return $this->container['token']; + } + + /** + * Sets token + * + * @param object $token The encrypted (opaque) token that was passed to the `onpaymentauthorized` callback by the Apple Pay integration. + * + * @return self + */ + public function setToken($token) + { + $this->container['token'] = $token; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/ApplePaySessionRequest.php b/lib/model/ApplePaySessionRequest.php new file mode 100644 index 0000000..59325c1 --- /dev/null +++ b/lib/model/ApplePaySessionRequest.php @@ -0,0 +1,360 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class ApplePaySessionRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ApplePaySessionRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'validation_url' => 'string', + 'domain_name' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'validation_url' => null, + 'domain_name' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'validation_url' => 'validation_url', + 'domain_name' => 'domain_name' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'validation_url' => 'setValidationUrl', + 'domain_name' => 'setDomainName' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'validation_url' => 'getValidationUrl', + 'domain_name' => 'getDomainName' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['validation_url'] = $data['validation_url'] ?? null; + $this->container['domain_name'] = $data['domain_name'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['validation_url'] === null) { + $invalidProperties[] = "'validation_url' can't be null"; + } + if ($this->container['domain_name'] === null) { + $invalidProperties[] = "'domain_name' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets validation_url + * + * @return string + */ + public function getValidationUrl() + { + return $this->container['validation_url']; + } + + /** + * Sets validation_url + * + * @param string $validation_url Validation URL obtained from the event passed to a `onvalidatemerchant` callback. + * + * @return self + */ + public function setValidationUrl($validation_url) + { + $this->container['validation_url'] = $validation_url; + + return $this; + } + + /** + * Gets domain_name + * + * @return string + */ + public function getDomainName() + { + return $this->container['domain_name']; + } + + /** + * Sets domain_name + * + * @param string $domain_name Fully qualified domain name of the merchant. + * + * @return self + */ + public function setDomainName($domain_name) + { + $this->container['domain_name'] = $domain_name; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/AuditLog.php b/lib/model/AuditLog.php new file mode 100644 index 0000000..b1376ab --- /dev/null +++ b/lib/model/AuditLog.php @@ -0,0 +1,542 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class AuditLog implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'AuditLog'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'id' => 'string', + 'timestamp' => 'string', + 'action' => 'string', + 'user' => '\Gr4vy\model\AuditLogUser', + 'resource' => '\Gr4vy\model\AuditLogResource' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'id' => 'uuid', + 'timestamp' => 'datetime', + 'action' => null, + 'user' => null, + 'resource' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'id' => 'id', + 'timestamp' => 'timestamp', + 'action' => 'action', + 'user' => 'user', + 'resource' => 'resource' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'id' => 'setId', + 'timestamp' => 'setTimestamp', + 'action' => 'setAction', + 'user' => 'setUser', + 'resource' => 'setResource' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'id' => 'getId', + 'timestamp' => 'getTimestamp', + 'action' => 'getAction', + 'user' => 'getUser', + 'resource' => 'getResource' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_AUDIT_LOG = 'audit-log'; + public const ACTION_CREATED = 'created'; + public const ACTION_UPDATED = 'updated'; + public const ACTION_DELETED = 'deleted'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_AUDIT_LOG, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getActionAllowableValues() + { + return [ + self::ACTION_CREATED, + self::ACTION_UPDATED, + self::ACTION_DELETED, + ]; + } + + /** + * 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['type'] = $data['type'] ?? null; + $this->container['id'] = $data['id'] ?? null; + $this->container['timestamp'] = $data['timestamp'] ?? null; + $this->container['action'] = $data['action'] ?? null; + $this->container['user'] = $data['user'] ?? null; + $this->container['resource'] = $data['resource'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getActionAllowableValues(); + if (!is_null($this->container['action']) && !in_array($this->container['action'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'action', must be one of '%s'", + $this->container['action'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type `audit-log`. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id The ID of the audit log entry. + * + * @return self + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets timestamp + * + * @return string|null + */ + public function getTimestamp() + { + return $this->container['timestamp']; + } + + /** + * Sets timestamp + * + * @param string|null $timestamp The date and time that the action was performed. + * + * @return self + */ + public function setTimestamp($timestamp) + { + $this->container['timestamp'] = $timestamp; + + return $this; + } + + /** + * Gets action + * + * @return string|null + */ + public function getAction() + { + return $this->container['action']; + } + + /** + * Sets action + * + * @param string|null $action The action that was performed. + * + * @return self + */ + public function setAction($action) + { + $allowedValues = $this->getActionAllowableValues(); + if (!is_null($action) && !in_array($action, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'action', must be one of '%s'", + $action, + implode("', '", $allowedValues) + ) + ); + } + $this->container['action'] = $action; + + return $this; + } + + /** + * Gets user + * + * @return \Gr4vy\model\AuditLogUser|null + */ + public function getUser() + { + return $this->container['user']; + } + + /** + * Sets user + * + * @param \Gr4vy\model\AuditLogUser|null $user user + * + * @return self + */ + public function setUser($user) + { + $this->container['user'] = $user; + + return $this; + } + + /** + * Gets resource + * + * @return \Gr4vy\model\AuditLogResource|null + */ + public function getResource() + { + return $this->container['resource']; + } + + /** + * Sets resource + * + * @param \Gr4vy\model\AuditLogResource|null $resource resource + * + * @return self + */ + public function setResource($resource) + { + $this->container['resource'] = $resource; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/AuditLogResource.php b/lib/model/AuditLogResource.php new file mode 100644 index 0000000..34cbed8 --- /dev/null +++ b/lib/model/AuditLogResource.php @@ -0,0 +1,384 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class AuditLogResource implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'AuditLog_resource'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'id' => 'string', + 'name' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'id' => 'uuid', + 'name' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'id' => 'id', + 'name' => 'name' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'id' => 'setId', + 'name' => 'setName' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'id' => 'getId', + 'name' => 'getName' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['type'] = $data['type'] ?? null; + $this->container['id'] = $data['id'] ?? null; + $this->container['name'] = $data['name'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type The type of the resource. + * + * @return self + */ + public function setType($type) + { + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id The ID of the resource. + * + * @return self + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name The descriptive name of the resource. + * + * @return self + */ + public function setName($name) + { + $this->container['name'] = $name; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/AuditLogUser.php b/lib/model/AuditLogUser.php new file mode 100644 index 0000000..eaf480a --- /dev/null +++ b/lib/model/AuditLogUser.php @@ -0,0 +1,384 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class AuditLogUser implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'AuditLog_user'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'name' => 'string', + 'staff' => 'bool' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'uuid', + 'name' => null, + 'staff' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'name' => 'name', + 'staff' => 'staff' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'name' => 'setName', + 'staff' => 'setStaff' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'name' => 'getName', + 'staff' => 'getStaff' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['id'] = $data['id'] ?? null; + $this->container['name'] = $data['name'] ?? null; + $this->container['staff'] = $data['staff'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id The ID of the user. + * + * @return self + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name The name of the user. + * + * @return self + */ + public function setName($name) + { + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets staff + * + * @return bool|null + */ + public function getStaff() + { + return $this->container['staff']; + } + + /** + * Sets staff + * + * @param bool|null $staff Whether the user is Gr4vy staff. + * + * @return self + */ + public function setStaff($staff) + { + $this->container['staff'] = $staff; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/AuditLogs.php b/lib/model/AuditLogs.php new file mode 100644 index 0000000..71c893b --- /dev/null +++ b/lib/model/AuditLogs.php @@ -0,0 +1,460 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class AuditLogs implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'AuditLogs'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'items' => '\Gr4vy\model\AuditLog[]', + 'limit' => 'int', + 'next_cursor' => 'string', + 'previous_cursor' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'items' => null, + 'limit' => 'int32', + 'next_cursor' => null, + 'previous_cursor' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'items' => 'items', + 'limit' => 'limit', + 'next_cursor' => 'next_cursor', + 'previous_cursor' => 'previous_cursor' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'items' => 'setItems', + 'limit' => 'setLimit', + 'next_cursor' => 'setNextCursor', + 'previous_cursor' => 'setPreviousCursor' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'items' => 'getItems', + 'limit' => 'getLimit', + 'next_cursor' => 'getNextCursor', + 'previous_cursor' => 'getPreviousCursor' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['items'] = $data['items'] ?? null; + $this->container['limit'] = $data['limit'] ?? 20; + $this->container['next_cursor'] = $data['next_cursor'] ?? null; + $this->container['previous_cursor'] = $data['previous_cursor'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['limit']) && ($this->container['limit'] > 100)) { + $invalidProperties[] = "invalid value for 'limit', must be smaller than or equal to 100."; + } + + if (!is_null($this->container['limit']) && ($this->container['limit'] < 1)) { + $invalidProperties[] = "invalid value for 'limit', must be bigger than or equal to 1."; + } + + if (!is_null($this->container['next_cursor']) && (mb_strlen($this->container['next_cursor']) > 1000)) { + $invalidProperties[] = "invalid value for 'next_cursor', the character length must be smaller than or equal to 1000."; + } + + if (!is_null($this->container['next_cursor']) && (mb_strlen($this->container['next_cursor']) < 1)) { + $invalidProperties[] = "invalid value for 'next_cursor', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['previous_cursor']) && (mb_strlen($this->container['previous_cursor']) > 1000)) { + $invalidProperties[] = "invalid value for 'previous_cursor', the character length must be smaller than or equal to 1000."; + } + + if (!is_null($this->container['previous_cursor']) && (mb_strlen($this->container['previous_cursor']) < 1)) { + $invalidProperties[] = "invalid value for 'previous_cursor', the character length must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets items + * + * @return \Gr4vy\model\AuditLog[]|null + */ + public function getItems() + { + return $this->container['items']; + } + + /** + * Sets items + * + * @param \Gr4vy\model\AuditLog[]|null $items A list of audit log entries. + * + * @return self + */ + public function setItems($items) + { + $this->container['items'] = $items; + + return $this; + } + + /** + * Gets limit + * + * @return int|null + */ + public function getLimit() + { + return $this->container['limit']; + } + + /** + * Sets limit + * + * @param int|null $limit The limit applied to request. This represents the number of items that are at maximum returned by this request. + * + * @return self + */ + public function setLimit($limit) + { + + if (!is_null($limit) && ($limit > 100)) { + throw new \InvalidArgumentException('invalid value for $limit when calling AuditLogs., must be smaller than or equal to 100.'); + } + if (!is_null($limit) && ($limit < 1)) { + throw new \InvalidArgumentException('invalid value for $limit when calling AuditLogs., must be bigger than or equal to 1.'); + } + + $this->container['limit'] = $limit; + + return $this; + } + + /** + * Gets next_cursor + * + * @return string|null + */ + public function getNextCursor() + { + return $this->container['next_cursor']; + } + + /** + * Sets next_cursor + * + * @param string|null $next_cursor The cursor that represents the next page of results. Use the `cursor` query parameter to fetch this page of items. + * + * @return self + */ + public function setNextCursor($next_cursor) + { + if (!is_null($next_cursor) && (mb_strlen($next_cursor) > 1000)) { + throw new \InvalidArgumentException('invalid length for $next_cursor when calling AuditLogs., must be smaller than or equal to 1000.'); + } + if (!is_null($next_cursor) && (mb_strlen($next_cursor) < 1)) { + throw new \InvalidArgumentException('invalid length for $next_cursor when calling AuditLogs., must be bigger than or equal to 1.'); + } + + $this->container['next_cursor'] = $next_cursor; + + return $this; + } + + /** + * Gets previous_cursor + * + * @return string|null + */ + public function getPreviousCursor() + { + return $this->container['previous_cursor']; + } + + /** + * Sets previous_cursor + * + * @param string|null $previous_cursor The cursor that represents the next page of results. Use the `cursor` query parameter to fetch this page of items. + * + * @return self + */ + public function setPreviousCursor($previous_cursor) + { + if (!is_null($previous_cursor) && (mb_strlen($previous_cursor) > 1000)) { + throw new \InvalidArgumentException('invalid length for $previous_cursor when calling AuditLogs., must be smaller than or equal to 1000.'); + } + if (!is_null($previous_cursor) && (mb_strlen($previous_cursor) < 1)) { + throw new \InvalidArgumentException('invalid length for $previous_cursor when calling AuditLogs., must be bigger than or equal to 1.'); + } + + $this->container['previous_cursor'] = $previous_cursor; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/BillingDetails.php b/lib/model/BillingDetails.php new file mode 100644 index 0000000..e057c5a --- /dev/null +++ b/lib/model/BillingDetails.php @@ -0,0 +1,603 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class BillingDetails implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'BillingDetails'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'first_name' => 'string', + 'last_name' => 'string', + 'email_address' => 'string', + 'phone_number' => 'string', + 'address' => '\Gr4vy\model\BillingDetailsAddress', + 'tax_id' => '\Gr4vy\model\BillingDetailsTaxId' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'first_name' => null, + 'last_name' => null, + 'email_address' => null, + 'phone_number' => null, + 'address' => null, + 'tax_id' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'first_name' => 'first_name', + 'last_name' => 'last_name', + 'email_address' => 'email_address', + 'phone_number' => 'phone_number', + 'address' => 'address', + 'tax_id' => 'tax_id' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'first_name' => 'setFirstName', + 'last_name' => 'setLastName', + 'email_address' => 'setEmailAddress', + 'phone_number' => 'setPhoneNumber', + 'address' => 'setAddress', + 'tax_id' => 'setTaxId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'first_name' => 'getFirstName', + 'last_name' => 'getLastName', + 'email_address' => 'getEmailAddress', + 'phone_number' => 'getPhoneNumber', + 'address' => 'getAddress', + 'tax_id' => 'getTaxId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_BILLING_DETAILS = 'billing-details'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_BILLING_DETAILS, + ]; + } + + /** + * 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['type'] = $data['type'] ?? null; + $this->container['first_name'] = $data['first_name'] ?? null; + $this->container['last_name'] = $data['last_name'] ?? null; + $this->container['email_address'] = $data['email_address'] ?? null; + $this->container['phone_number'] = $data['phone_number'] ?? null; + $this->container['address'] = $data['address'] ?? null; + $this->container['tax_id'] = $data['tax_id'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + if (!is_null($this->container['first_name']) && (mb_strlen($this->container['first_name']) > 255)) { + $invalidProperties[] = "invalid value for 'first_name', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['first_name']) && (mb_strlen($this->container['first_name']) < 1)) { + $invalidProperties[] = "invalid value for 'first_name', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['last_name']) && (mb_strlen($this->container['last_name']) > 255)) { + $invalidProperties[] = "invalid value for 'last_name', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['last_name']) && (mb_strlen($this->container['last_name']) < 1)) { + $invalidProperties[] = "invalid value for 'last_name', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['email_address']) && (mb_strlen($this->container['email_address']) > 320)) { + $invalidProperties[] = "invalid value for 'email_address', the character length must be smaller than or equal to 320."; + } + + if (!is_null($this->container['email_address']) && (mb_strlen($this->container['email_address']) < 1)) { + $invalidProperties[] = "invalid value for 'email_address', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['phone_number']) && (mb_strlen($this->container['phone_number']) > 50)) { + $invalidProperties[] = "invalid value for 'phone_number', the character length must be smaller than or equal to 50."; + } + + if (!is_null($this->container['phone_number']) && (mb_strlen($this->container['phone_number']) < 1)) { + $invalidProperties[] = "invalid value for 'phone_number', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['phone_number']) && !preg_match("/^\\+[1-9]\\d{1,14}$/", $this->container['phone_number'])) { + $invalidProperties[] = "invalid value for 'phone_number', must be conform to the pattern /^\\+[1-9]\\d{1,14}$/."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type The type of this resource. Is always `billing-details`. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets first_name + * + * @return string|null + */ + public function getFirstName() + { + return $this->container['first_name']; + } + + /** + * Sets first_name + * + * @param string|null $first_name The first name(s) or given name of the buyer. + * + * @return self + */ + public function setFirstName($first_name) + { + if (!is_null($first_name) && (mb_strlen($first_name) > 255)) { + throw new \InvalidArgumentException('invalid length for $first_name when calling BillingDetails., must be smaller than or equal to 255.'); + } + if (!is_null($first_name) && (mb_strlen($first_name) < 1)) { + throw new \InvalidArgumentException('invalid length for $first_name when calling BillingDetails., must be bigger than or equal to 1.'); + } + + $this->container['first_name'] = $first_name; + + return $this; + } + + /** + * Gets last_name + * + * @return string|null + */ + public function getLastName() + { + return $this->container['last_name']; + } + + /** + * Sets last_name + * + * @param string|null $last_name The last name, or family name, of the buyer. + * + * @return self + */ + public function setLastName($last_name) + { + if (!is_null($last_name) && (mb_strlen($last_name) > 255)) { + throw new \InvalidArgumentException('invalid length for $last_name when calling BillingDetails., must be smaller than or equal to 255.'); + } + if (!is_null($last_name) && (mb_strlen($last_name) < 1)) { + throw new \InvalidArgumentException('invalid length for $last_name when calling BillingDetails., must be bigger than or equal to 1.'); + } + + $this->container['last_name'] = $last_name; + + return $this; + } + + /** + * Gets email_address + * + * @return string|null + */ + public function getEmailAddress() + { + return $this->container['email_address']; + } + + /** + * Sets email_address + * + * @param string|null $email_address The email address of the buyer. + * + * @return self + */ + public function setEmailAddress($email_address) + { + if (!is_null($email_address) && (mb_strlen($email_address) > 320)) { + throw new \InvalidArgumentException('invalid length for $email_address when calling BillingDetails., must be smaller than or equal to 320.'); + } + if (!is_null($email_address) && (mb_strlen($email_address) < 1)) { + throw new \InvalidArgumentException('invalid length for $email_address when calling BillingDetails., must be bigger than or equal to 1.'); + } + + $this->container['email_address'] = $email_address; + + return $this; + } + + /** + * Gets phone_number + * + * @return string|null + */ + public function getPhoneNumber() + { + return $this->container['phone_number']; + } + + /** + * Sets phone_number + * + * @param string|null $phone_number The phone number of the buyer. This number is formatted according to the [E164 number standard](https://www.twilio.com/docs/glossary/what-e164). + * + * @return self + */ + public function setPhoneNumber($phone_number) + { + if (!is_null($phone_number) && (mb_strlen($phone_number) > 50)) { + throw new \InvalidArgumentException('invalid length for $phone_number when calling BillingDetails., must be smaller than or equal to 50.'); + } + if (!is_null($phone_number) && (mb_strlen($phone_number) < 1)) { + throw new \InvalidArgumentException('invalid length for $phone_number when calling BillingDetails., must be bigger than or equal to 1.'); + } + if (!is_null($phone_number) && (!preg_match("/^\\+[1-9]\\d{1,14}$/", $phone_number))) { + throw new \InvalidArgumentException("invalid value for $phone_number when calling BillingDetails., must conform to the pattern /^\\+[1-9]\\d{1,14}$/."); + } + + $this->container['phone_number'] = $phone_number; + + return $this; + } + + /** + * Gets address + * + * @return \Gr4vy\model\BillingDetailsAddress|null + */ + public function getAddress() + { + return $this->container['address']; + } + + /** + * Sets address + * + * @param \Gr4vy\model\BillingDetailsAddress|null $address address + * + * @return self + */ + public function setAddress($address) + { + $this->container['address'] = $address; + + return $this; + } + + /** + * Gets tax_id + * + * @return \Gr4vy\model\BillingDetailsTaxId|null + */ + public function getTaxId() + { + return $this->container['tax_id']; + } + + /** + * Sets tax_id + * + * @param \Gr4vy\model\BillingDetailsTaxId|null $tax_id tax_id + * + * @return self + */ + public function setTaxId($tax_id) + { + $this->container['tax_id'] = $tax_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/BillingDetailsAddress.php b/lib/model/BillingDetailsAddress.php new file mode 100644 index 0000000..2e84b8f --- /dev/null +++ b/lib/model/BillingDetailsAddress.php @@ -0,0 +1,698 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class BillingDetailsAddress implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'BillingDetails_address'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'city' => 'string', + 'country' => 'string', + 'postal_code' => 'string', + 'state' => 'string', + 'state_code' => 'string', + 'house_number_or_name' => 'string', + 'line1' => 'string', + 'line2' => 'string', + 'organization' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'city' => null, + 'country' => null, + 'postal_code' => null, + 'state' => null, + 'state_code' => null, + 'house_number_or_name' => null, + 'line1' => null, + 'line2' => null, + 'organization' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'city' => 'city', + 'country' => 'country', + 'postal_code' => 'postal_code', + 'state' => 'state', + 'state_code' => 'state_code', + 'house_number_or_name' => 'house_number_or_name', + 'line1' => 'line1', + 'line2' => 'line2', + 'organization' => 'organization' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'city' => 'setCity', + 'country' => 'setCountry', + 'postal_code' => 'setPostalCode', + 'state' => 'setState', + 'state_code' => 'setStateCode', + 'house_number_or_name' => 'setHouseNumberOrName', + 'line1' => 'setLine1', + 'line2' => 'setLine2', + 'organization' => 'setOrganization' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'city' => 'getCity', + 'country' => 'getCountry', + 'postal_code' => 'getPostalCode', + 'state' => 'getState', + 'state_code' => 'getStateCode', + 'house_number_or_name' => 'getHouseNumberOrName', + 'line1' => 'getLine1', + 'line2' => 'getLine2', + 'organization' => 'getOrganization' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['city'] = $data['city'] ?? null; + $this->container['country'] = $data['country'] ?? null; + $this->container['postal_code'] = $data['postal_code'] ?? null; + $this->container['state'] = $data['state'] ?? null; + $this->container['state_code'] = $data['state_code'] ?? null; + $this->container['house_number_or_name'] = $data['house_number_or_name'] ?? null; + $this->container['line1'] = $data['line1'] ?? null; + $this->container['line2'] = $data['line2'] ?? null; + $this->container['organization'] = $data['organization'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['city']) && (mb_strlen($this->container['city']) > 100)) { + $invalidProperties[] = "invalid value for 'city', the character length must be smaller than or equal to 100."; + } + + if (!is_null($this->container['city']) && (mb_strlen($this->container['city']) < 1)) { + $invalidProperties[] = "invalid value for 'city', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['country']) && (mb_strlen($this->container['country']) > 2)) { + $invalidProperties[] = "invalid value for 'country', the character length must be smaller than or equal to 2."; + } + + if (!is_null($this->container['country']) && (mb_strlen($this->container['country']) < 1)) { + $invalidProperties[] = "invalid value for 'country', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['postal_code']) && (mb_strlen($this->container['postal_code']) > 50)) { + $invalidProperties[] = "invalid value for 'postal_code', the character length must be smaller than or equal to 50."; + } + + if (!is_null($this->container['postal_code']) && (mb_strlen($this->container['postal_code']) < 1)) { + $invalidProperties[] = "invalid value for 'postal_code', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['state']) && (mb_strlen($this->container['state']) > 255)) { + $invalidProperties[] = "invalid value for 'state', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['state']) && (mb_strlen($this->container['state']) < 1)) { + $invalidProperties[] = "invalid value for 'state', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['state_code']) && (mb_strlen($this->container['state_code']) > 6)) { + $invalidProperties[] = "invalid value for 'state_code', the character length must be smaller than or equal to 6."; + } + + if (!is_null($this->container['state_code']) && (mb_strlen($this->container['state_code']) < 4)) { + $invalidProperties[] = "invalid value for 'state_code', the character length must be bigger than or equal to 4."; + } + + if (!is_null($this->container['house_number_or_name']) && (mb_strlen($this->container['house_number_or_name']) > 255)) { + $invalidProperties[] = "invalid value for 'house_number_or_name', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['house_number_or_name']) && (mb_strlen($this->container['house_number_or_name']) < 1)) { + $invalidProperties[] = "invalid value for 'house_number_or_name', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['line1']) && (mb_strlen($this->container['line1']) > 255)) { + $invalidProperties[] = "invalid value for 'line1', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['line1']) && (mb_strlen($this->container['line1']) < 1)) { + $invalidProperties[] = "invalid value for 'line1', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['line2']) && (mb_strlen($this->container['line2']) > 255)) { + $invalidProperties[] = "invalid value for 'line2', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['line2']) && (mb_strlen($this->container['line2']) < 1)) { + $invalidProperties[] = "invalid value for 'line2', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['organization']) && (mb_strlen($this->container['organization']) > 255)) { + $invalidProperties[] = "invalid value for 'organization', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['organization']) && (mb_strlen($this->container['organization']) < 1)) { + $invalidProperties[] = "invalid value for 'organization', the character length must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets city + * + * @return string|null + */ + public function getCity() + { + return $this->container['city']; + } + + /** + * Sets city + * + * @param string|null $city The city for the billing address. + * + * @return self + */ + public function setCity($city) + { + if (!is_null($city) && (mb_strlen($city) > 100)) { + throw new \InvalidArgumentException('invalid length for $city when calling BillingDetailsAddress., must be smaller than or equal to 100.'); + } + if (!is_null($city) && (mb_strlen($city) < 1)) { + throw new \InvalidArgumentException('invalid length for $city when calling BillingDetailsAddress., must be bigger than or equal to 1.'); + } + + $this->container['city'] = $city; + + return $this; + } + + /** + * Gets country + * + * @return string|null + */ + public function getCountry() + { + return $this->container['country']; + } + + /** + * Sets country + * + * @param string|null $country The country for the billing address. + * + * @return self + */ + public function setCountry($country) + { + if (!is_null($country) && (mb_strlen($country) > 2)) { + throw new \InvalidArgumentException('invalid length for $country when calling BillingDetailsAddress., must be smaller than or equal to 2.'); + } + if (!is_null($country) && (mb_strlen($country) < 1)) { + throw new \InvalidArgumentException('invalid length for $country when calling BillingDetailsAddress., must be bigger than or equal to 1.'); + } + + $this->container['country'] = $country; + + return $this; + } + + /** + * Gets postal_code + * + * @return string|null + */ + public function getPostalCode() + { + return $this->container['postal_code']; + } + + /** + * Sets postal_code + * + * @param string|null $postal_code The postal code or zip code for the billing address. + * + * @return self + */ + public function setPostalCode($postal_code) + { + if (!is_null($postal_code) && (mb_strlen($postal_code) > 50)) { + throw new \InvalidArgumentException('invalid length for $postal_code when calling BillingDetailsAddress., must be smaller than or equal to 50.'); + } + if (!is_null($postal_code) && (mb_strlen($postal_code) < 1)) { + throw new \InvalidArgumentException('invalid length for $postal_code when calling BillingDetailsAddress., must be bigger than or equal to 1.'); + } + + $this->container['postal_code'] = $postal_code; + + return $this; + } + + /** + * Gets state + * + * @return string|null + */ + public function getState() + { + return $this->container['state']; + } + + /** + * Sets state + * + * @param string|null $state The state, county, or province for the billing address. + * + * @return self + */ + public function setState($state) + { + if (!is_null($state) && (mb_strlen($state) > 255)) { + throw new \InvalidArgumentException('invalid length for $state when calling BillingDetailsAddress., must be smaller than or equal to 255.'); + } + if (!is_null($state) && (mb_strlen($state) < 1)) { + throw new \InvalidArgumentException('invalid length for $state when calling BillingDetailsAddress., must be bigger than or equal to 1.'); + } + + $this->container['state'] = $state; + + return $this; + } + + /** + * Gets state_code + * + * @return string|null + */ + public function getStateCode() + { + return $this->container['state_code']; + } + + /** + * Sets state_code + * + * @param string|null $state_code The code of state, county, or province for the billing address in ISO 3166-2 format. + * + * @return self + */ + public function setStateCode($state_code) + { + if (!is_null($state_code) && (mb_strlen($state_code) > 6)) { + throw new \InvalidArgumentException('invalid length for $state_code when calling BillingDetailsAddress., must be smaller than or equal to 6.'); + } + if (!is_null($state_code) && (mb_strlen($state_code) < 4)) { + throw new \InvalidArgumentException('invalid length for $state_code when calling BillingDetailsAddress., must be bigger than or equal to 4.'); + } + + $this->container['state_code'] = $state_code; + + return $this; + } + + /** + * Gets house_number_or_name + * + * @return string|null + */ + public function getHouseNumberOrName() + { + return $this->container['house_number_or_name']; + } + + /** + * Sets house_number_or_name + * + * @param string|null $house_number_or_name The house number or name for the billing address. Not all payment services use this field but some do. + * + * @return self + */ + public function setHouseNumberOrName($house_number_or_name) + { + if (!is_null($house_number_or_name) && (mb_strlen($house_number_or_name) > 255)) { + throw new \InvalidArgumentException('invalid length for $house_number_or_name when calling BillingDetailsAddress., must be smaller than or equal to 255.'); + } + if (!is_null($house_number_or_name) && (mb_strlen($house_number_or_name) < 1)) { + throw new \InvalidArgumentException('invalid length for $house_number_or_name when calling BillingDetailsAddress., must be bigger than or equal to 1.'); + } + + $this->container['house_number_or_name'] = $house_number_or_name; + + return $this; + } + + /** + * Gets line1 + * + * @return string|null + */ + public function getLine1() + { + return $this->container['line1']; + } + + /** + * Sets line1 + * + * @param string|null $line1 The first line of the billing address. + * + * @return self + */ + public function setLine1($line1) + { + if (!is_null($line1) && (mb_strlen($line1) > 255)) { + throw new \InvalidArgumentException('invalid length for $line1 when calling BillingDetailsAddress., must be smaller than or equal to 255.'); + } + if (!is_null($line1) && (mb_strlen($line1) < 1)) { + throw new \InvalidArgumentException('invalid length for $line1 when calling BillingDetailsAddress., must be bigger than or equal to 1.'); + } + + $this->container['line1'] = $line1; + + return $this; + } + + /** + * Gets line2 + * + * @return string|null + */ + public function getLine2() + { + return $this->container['line2']; + } + + /** + * Sets line2 + * + * @param string|null $line2 The second line of the billing address. + * + * @return self + */ + public function setLine2($line2) + { + if (!is_null($line2) && (mb_strlen($line2) > 255)) { + throw new \InvalidArgumentException('invalid length for $line2 when calling BillingDetailsAddress., must be smaller than or equal to 255.'); + } + if (!is_null($line2) && (mb_strlen($line2) < 1)) { + throw new \InvalidArgumentException('invalid length for $line2 when calling BillingDetailsAddress., must be bigger than or equal to 1.'); + } + + $this->container['line2'] = $line2; + + return $this; + } + + /** + * Gets organization + * + * @return string|null + */ + public function getOrganization() + { + return $this->container['organization']; + } + + /** + * Sets organization + * + * @param string|null $organization The optional name of the company or organisation to add to the billing address. + * + * @return self + */ + public function setOrganization($organization) + { + if (!is_null($organization) && (mb_strlen($organization) > 255)) { + throw new \InvalidArgumentException('invalid length for $organization when calling BillingDetailsAddress., must be smaller than or equal to 255.'); + } + if (!is_null($organization) && (mb_strlen($organization) < 1)) { + throw new \InvalidArgumentException('invalid length for $organization when calling BillingDetailsAddress., must be bigger than or equal to 1.'); + } + + $this->container['organization'] = $organization; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/BillingDetailsRequest.php b/lib/model/BillingDetailsRequest.php new file mode 100644 index 0000000..8c472fb --- /dev/null +++ b/lib/model/BillingDetailsRequest.php @@ -0,0 +1,541 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class BillingDetailsRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'BillingDetailsRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'first_name' => 'string', + 'last_name' => 'string', + 'email_address' => 'string', + 'phone_number' => 'string', + 'address' => '\Gr4vy\model\BillingDetailsRequestAddress', + 'tax_id' => '\Gr4vy\model\BillingDetailsTaxId' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'first_name' => null, + 'last_name' => null, + 'email_address' => null, + 'phone_number' => null, + 'address' => null, + 'tax_id' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'first_name' => 'first_name', + 'last_name' => 'last_name', + 'email_address' => 'email_address', + 'phone_number' => 'phone_number', + 'address' => 'address', + 'tax_id' => 'tax_id' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'first_name' => 'setFirstName', + 'last_name' => 'setLastName', + 'email_address' => 'setEmailAddress', + 'phone_number' => 'setPhoneNumber', + 'address' => 'setAddress', + 'tax_id' => 'setTaxId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'first_name' => 'getFirstName', + 'last_name' => 'getLastName', + 'email_address' => 'getEmailAddress', + 'phone_number' => 'getPhoneNumber', + 'address' => 'getAddress', + 'tax_id' => 'getTaxId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['first_name'] = $data['first_name'] ?? null; + $this->container['last_name'] = $data['last_name'] ?? null; + $this->container['email_address'] = $data['email_address'] ?? null; + $this->container['phone_number'] = $data['phone_number'] ?? null; + $this->container['address'] = $data['address'] ?? null; + $this->container['tax_id'] = $data['tax_id'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['first_name']) && (mb_strlen($this->container['first_name']) > 255)) { + $invalidProperties[] = "invalid value for 'first_name', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['first_name']) && (mb_strlen($this->container['first_name']) < 1)) { + $invalidProperties[] = "invalid value for 'first_name', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['last_name']) && (mb_strlen($this->container['last_name']) > 255)) { + $invalidProperties[] = "invalid value for 'last_name', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['last_name']) && (mb_strlen($this->container['last_name']) < 1)) { + $invalidProperties[] = "invalid value for 'last_name', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['email_address']) && (mb_strlen($this->container['email_address']) > 320)) { + $invalidProperties[] = "invalid value for 'email_address', the character length must be smaller than or equal to 320."; + } + + if (!is_null($this->container['email_address']) && (mb_strlen($this->container['email_address']) < 1)) { + $invalidProperties[] = "invalid value for 'email_address', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['phone_number']) && (mb_strlen($this->container['phone_number']) > 50)) { + $invalidProperties[] = "invalid value for 'phone_number', the character length must be smaller than or equal to 50."; + } + + if (!is_null($this->container['phone_number']) && (mb_strlen($this->container['phone_number']) < 1)) { + $invalidProperties[] = "invalid value for 'phone_number', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['phone_number']) && !preg_match("/^\\+[1-9]\\d{1,14}$/", $this->container['phone_number'])) { + $invalidProperties[] = "invalid value for 'phone_number', must be conform to the pattern /^\\+[1-9]\\d{1,14}$/."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets first_name + * + * @return string|null + */ + public function getFirstName() + { + return $this->container['first_name']; + } + + /** + * Sets first_name + * + * @param string|null $first_name The first name(s) or given name for the buyer. + * + * @return self + */ + public function setFirstName($first_name) + { + if (!is_null($first_name) && (mb_strlen($first_name) > 255)) { + throw new \InvalidArgumentException('invalid length for $first_name when calling BillingDetailsRequest., must be smaller than or equal to 255.'); + } + if (!is_null($first_name) && (mb_strlen($first_name) < 1)) { + throw new \InvalidArgumentException('invalid length for $first_name when calling BillingDetailsRequest., must be bigger than or equal to 1.'); + } + + $this->container['first_name'] = $first_name; + + return $this; + } + + /** + * Gets last_name + * + * @return string|null + */ + public function getLastName() + { + return $this->container['last_name']; + } + + /** + * Sets last_name + * + * @param string|null $last_name The last name, or family name, of the buyer. + * + * @return self + */ + public function setLastName($last_name) + { + if (!is_null($last_name) && (mb_strlen($last_name) > 255)) { + throw new \InvalidArgumentException('invalid length for $last_name when calling BillingDetailsRequest., must be smaller than or equal to 255.'); + } + if (!is_null($last_name) && (mb_strlen($last_name) < 1)) { + throw new \InvalidArgumentException('invalid length for $last_name when calling BillingDetailsRequest., must be bigger than or equal to 1.'); + } + + $this->container['last_name'] = $last_name; + + return $this; + } + + /** + * Gets email_address + * + * @return string|null + */ + public function getEmailAddress() + { + return $this->container['email_address']; + } + + /** + * Sets email_address + * + * @param string|null $email_address The email address for the buyer. + * + * @return self + */ + public function setEmailAddress($email_address) + { + if (!is_null($email_address) && (mb_strlen($email_address) > 320)) { + throw new \InvalidArgumentException('invalid length for $email_address when calling BillingDetailsRequest., must be smaller than or equal to 320.'); + } + if (!is_null($email_address) && (mb_strlen($email_address) < 1)) { + throw new \InvalidArgumentException('invalid length for $email_address when calling BillingDetailsRequest., must be bigger than or equal to 1.'); + } + + $this->container['email_address'] = $email_address; + + return $this; + } + + /** + * Gets phone_number + * + * @return string|null + */ + public function getPhoneNumber() + { + return $this->container['phone_number']; + } + + /** + * Sets phone_number + * + * @param string|null $phone_number The phone number for the buyer which should be formatted according to the [E164 number standard](https://www.twilio.com/docs/glossary/what-e164). + * + * @return self + */ + public function setPhoneNumber($phone_number) + { + if (!is_null($phone_number) && (mb_strlen($phone_number) > 50)) { + throw new \InvalidArgumentException('invalid length for $phone_number when calling BillingDetailsRequest., must be smaller than or equal to 50.'); + } + if (!is_null($phone_number) && (mb_strlen($phone_number) < 1)) { + throw new \InvalidArgumentException('invalid length for $phone_number when calling BillingDetailsRequest., must be bigger than or equal to 1.'); + } + if (!is_null($phone_number) && (!preg_match("/^\\+[1-9]\\d{1,14}$/", $phone_number))) { + throw new \InvalidArgumentException("invalid value for $phone_number when calling BillingDetailsRequest., must conform to the pattern /^\\+[1-9]\\d{1,14}$/."); + } + + $this->container['phone_number'] = $phone_number; + + return $this; + } + + /** + * Gets address + * + * @return \Gr4vy\model\BillingDetailsRequestAddress|null + */ + public function getAddress() + { + return $this->container['address']; + } + + /** + * Sets address + * + * @param \Gr4vy\model\BillingDetailsRequestAddress|null $address address + * + * @return self + */ + public function setAddress($address) + { + $this->container['address'] = $address; + + return $this; + } + + /** + * Gets tax_id + * + * @return \Gr4vy\model\BillingDetailsTaxId|null + */ + public function getTaxId() + { + return $this->container['tax_id']; + } + + /** + * Sets tax_id + * + * @param \Gr4vy\model\BillingDetailsTaxId|null $tax_id tax_id + * + * @return self + */ + public function setTaxId($tax_id) + { + $this->container['tax_id'] = $tax_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/BillingDetailsRequestAddress.php b/lib/model/BillingDetailsRequestAddress.php new file mode 100644 index 0000000..89ae222 --- /dev/null +++ b/lib/model/BillingDetailsRequestAddress.php @@ -0,0 +1,714 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class BillingDetailsRequestAddress implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'BillingDetailsRequest_address'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'city' => 'string', + 'country' => 'string', + 'postal_code' => 'string', + 'state' => 'string', + 'state_code' => 'string', + 'house_number_or_name' => 'string', + 'line1' => 'string', + 'line2' => 'string', + 'organization' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'city' => null, + 'country' => null, + 'postal_code' => null, + 'state' => null, + 'state_code' => null, + 'house_number_or_name' => null, + 'line1' => null, + 'line2' => null, + 'organization' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'city' => 'city', + 'country' => 'country', + 'postal_code' => 'postal_code', + 'state' => 'state', + 'state_code' => 'state_code', + 'house_number_or_name' => 'house_number_or_name', + 'line1' => 'line1', + 'line2' => 'line2', + 'organization' => 'organization' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'city' => 'setCity', + 'country' => 'setCountry', + 'postal_code' => 'setPostalCode', + 'state' => 'setState', + 'state_code' => 'setStateCode', + 'house_number_or_name' => 'setHouseNumberOrName', + 'line1' => 'setLine1', + 'line2' => 'setLine2', + 'organization' => 'setOrganization' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'city' => 'getCity', + 'country' => 'getCountry', + 'postal_code' => 'getPostalCode', + 'state' => 'getState', + 'state_code' => 'getStateCode', + 'house_number_or_name' => 'getHouseNumberOrName', + 'line1' => 'getLine1', + 'line2' => 'getLine2', + 'organization' => 'getOrganization' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['city'] = $data['city'] ?? null; + $this->container['country'] = $data['country'] ?? null; + $this->container['postal_code'] = $data['postal_code'] ?? null; + $this->container['state'] = $data['state'] ?? null; + $this->container['state_code'] = $data['state_code'] ?? null; + $this->container['house_number_or_name'] = $data['house_number_or_name'] ?? null; + $this->container['line1'] = $data['line1'] ?? null; + $this->container['line2'] = $data['line2'] ?? null; + $this->container['organization'] = $data['organization'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['city'] === null) { + $invalidProperties[] = "'city' can't be null"; + } + if ((mb_strlen($this->container['city']) > 100)) { + $invalidProperties[] = "invalid value for 'city', the character length must be smaller than or equal to 100."; + } + + if ((mb_strlen($this->container['city']) < 1)) { + $invalidProperties[] = "invalid value for 'city', the character length must be bigger than or equal to 1."; + } + + if ($this->container['country'] === null) { + $invalidProperties[] = "'country' can't be null"; + } + if ((mb_strlen($this->container['country']) > 2)) { + $invalidProperties[] = "invalid value for 'country', the character length must be smaller than or equal to 2."; + } + + if ((mb_strlen($this->container['country']) < 1)) { + $invalidProperties[] = "invalid value for 'country', the character length must be bigger than or equal to 1."; + } + + if ($this->container['postal_code'] === null) { + $invalidProperties[] = "'postal_code' can't be null"; + } + if ((mb_strlen($this->container['postal_code']) > 50)) { + $invalidProperties[] = "invalid value for 'postal_code', the character length must be smaller than or equal to 50."; + } + + if ((mb_strlen($this->container['postal_code']) < 1)) { + $invalidProperties[] = "invalid value for 'postal_code', the character length must be bigger than or equal to 1."; + } + + if ($this->container['state'] === null) { + $invalidProperties[] = "'state' can't be null"; + } + if ((mb_strlen($this->container['state']) > 255)) { + $invalidProperties[] = "invalid value for 'state', the character length must be smaller than or equal to 255."; + } + + if ((mb_strlen($this->container['state']) < 1)) { + $invalidProperties[] = "invalid value for 'state', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['state_code']) && (mb_strlen($this->container['state_code']) > 6)) { + $invalidProperties[] = "invalid value for 'state_code', the character length must be smaller than or equal to 6."; + } + + if (!is_null($this->container['state_code']) && (mb_strlen($this->container['state_code']) < 4)) { + $invalidProperties[] = "invalid value for 'state_code', the character length must be bigger than or equal to 4."; + } + + if (!is_null($this->container['house_number_or_name']) && (mb_strlen($this->container['house_number_or_name']) > 255)) { + $invalidProperties[] = "invalid value for 'house_number_or_name', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['house_number_or_name']) && (mb_strlen($this->container['house_number_or_name']) < 1)) { + $invalidProperties[] = "invalid value for 'house_number_or_name', the character length must be bigger than or equal to 1."; + } + + if ($this->container['line1'] === null) { + $invalidProperties[] = "'line1' can't be null"; + } + if ((mb_strlen($this->container['line1']) > 255)) { + $invalidProperties[] = "invalid value for 'line1', the character length must be smaller than or equal to 255."; + } + + if ((mb_strlen($this->container['line1']) < 1)) { + $invalidProperties[] = "invalid value for 'line1', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['line2']) && (mb_strlen($this->container['line2']) > 255)) { + $invalidProperties[] = "invalid value for 'line2', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['line2']) && (mb_strlen($this->container['line2']) < 1)) { + $invalidProperties[] = "invalid value for 'line2', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['organization']) && (mb_strlen($this->container['organization']) > 255)) { + $invalidProperties[] = "invalid value for 'organization', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['organization']) && (mb_strlen($this->container['organization']) < 1)) { + $invalidProperties[] = "invalid value for 'organization', the character length must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets city + * + * @return string + */ + public function getCity() + { + return $this->container['city']; + } + + /** + * Sets city + * + * @param string $city The city for the billing address. + * + * @return self + */ + public function setCity($city) + { + if ((mb_strlen($city) > 100)) { + throw new \InvalidArgumentException('invalid length for $city when calling BillingDetailsRequestAddress., must be smaller than or equal to 100.'); + } + if ((mb_strlen($city) < 1)) { + throw new \InvalidArgumentException('invalid length for $city when calling BillingDetailsRequestAddress., must be bigger than or equal to 1.'); + } + + $this->container['city'] = $city; + + return $this; + } + + /** + * Gets country + * + * @return string + */ + public function getCountry() + { + return $this->container['country']; + } + + /** + * Sets country + * + * @param string $country The country for the billing address. + * + * @return self + */ + public function setCountry($country) + { + if ((mb_strlen($country) > 2)) { + throw new \InvalidArgumentException('invalid length for $country when calling BillingDetailsRequestAddress., must be smaller than or equal to 2.'); + } + if ((mb_strlen($country) < 1)) { + throw new \InvalidArgumentException('invalid length for $country when calling BillingDetailsRequestAddress., must be bigger than or equal to 1.'); + } + + $this->container['country'] = $country; + + return $this; + } + + /** + * Gets postal_code + * + * @return string + */ + public function getPostalCode() + { + return $this->container['postal_code']; + } + + /** + * Sets postal_code + * + * @param string $postal_code The postal code or zip code for the billing address. + * + * @return self + */ + public function setPostalCode($postal_code) + { + if ((mb_strlen($postal_code) > 50)) { + throw new \InvalidArgumentException('invalid length for $postal_code when calling BillingDetailsRequestAddress., must be smaller than or equal to 50.'); + } + if ((mb_strlen($postal_code) < 1)) { + throw new \InvalidArgumentException('invalid length for $postal_code when calling BillingDetailsRequestAddress., must be bigger than or equal to 1.'); + } + + $this->container['postal_code'] = $postal_code; + + return $this; + } + + /** + * Gets state + * + * @return string + */ + public function getState() + { + return $this->container['state']; + } + + /** + * Sets state + * + * @param string $state The state, county, or province for the billing address. + * + * @return self + */ + public function setState($state) + { + if ((mb_strlen($state) > 255)) { + throw new \InvalidArgumentException('invalid length for $state when calling BillingDetailsRequestAddress., must be smaller than or equal to 255.'); + } + if ((mb_strlen($state) < 1)) { + throw new \InvalidArgumentException('invalid length for $state when calling BillingDetailsRequestAddress., must be bigger than or equal to 1.'); + } + + $this->container['state'] = $state; + + return $this; + } + + /** + * Gets state_code + * + * @return string|null + */ + public function getStateCode() + { + return $this->container['state_code']; + } + + /** + * Sets state_code + * + * @param string|null $state_code The code of state, county, or province for the billing address in ISO 3166-2 format. + * + * @return self + */ + public function setStateCode($state_code) + { + if (!is_null($state_code) && (mb_strlen($state_code) > 6)) { + throw new \InvalidArgumentException('invalid length for $state_code when calling BillingDetailsRequestAddress., must be smaller than or equal to 6.'); + } + if (!is_null($state_code) && (mb_strlen($state_code) < 4)) { + throw new \InvalidArgumentException('invalid length for $state_code when calling BillingDetailsRequestAddress., must be bigger than or equal to 4.'); + } + + $this->container['state_code'] = $state_code; + + return $this; + } + + /** + * Gets house_number_or_name + * + * @return string|null + */ + public function getHouseNumberOrName() + { + return $this->container['house_number_or_name']; + } + + /** + * Sets house_number_or_name + * + * @param string|null $house_number_or_name The house number or name for the billing address. Not all payment services use this field but some do. + * + * @return self + */ + public function setHouseNumberOrName($house_number_or_name) + { + if (!is_null($house_number_or_name) && (mb_strlen($house_number_or_name) > 255)) { + throw new \InvalidArgumentException('invalid length for $house_number_or_name when calling BillingDetailsRequestAddress., must be smaller than or equal to 255.'); + } + if (!is_null($house_number_or_name) && (mb_strlen($house_number_or_name) < 1)) { + throw new \InvalidArgumentException('invalid length for $house_number_or_name when calling BillingDetailsRequestAddress., must be bigger than or equal to 1.'); + } + + $this->container['house_number_or_name'] = $house_number_or_name; + + return $this; + } + + /** + * Gets line1 + * + * @return string + */ + public function getLine1() + { + return $this->container['line1']; + } + + /** + * Sets line1 + * + * @param string $line1 The first line of the billing address. + * + * @return self + */ + public function setLine1($line1) + { + if ((mb_strlen($line1) > 255)) { + throw new \InvalidArgumentException('invalid length for $line1 when calling BillingDetailsRequestAddress., must be smaller than or equal to 255.'); + } + if ((mb_strlen($line1) < 1)) { + throw new \InvalidArgumentException('invalid length for $line1 when calling BillingDetailsRequestAddress., must be bigger than or equal to 1.'); + } + + $this->container['line1'] = $line1; + + return $this; + } + + /** + * Gets line2 + * + * @return string|null + */ + public function getLine2() + { + return $this->container['line2']; + } + + /** + * Sets line2 + * + * @param string|null $line2 The second line of the billing address. + * + * @return self + */ + public function setLine2($line2) + { + if (!is_null($line2) && (mb_strlen($line2) > 255)) { + throw new \InvalidArgumentException('invalid length for $line2 when calling BillingDetailsRequestAddress., must be smaller than or equal to 255.'); + } + if (!is_null($line2) && (mb_strlen($line2) < 1)) { + throw new \InvalidArgumentException('invalid length for $line2 when calling BillingDetailsRequestAddress., must be bigger than or equal to 1.'); + } + + $this->container['line2'] = $line2; + + return $this; + } + + /** + * Gets organization + * + * @return string|null + */ + public function getOrganization() + { + return $this->container['organization']; + } + + /** + * Sets organization + * + * @param string|null $organization The optional name of the company or organisation to add to the billing address. + * + * @return self + */ + public function setOrganization($organization) + { + if (!is_null($organization) && (mb_strlen($organization) > 255)) { + throw new \InvalidArgumentException('invalid length for $organization when calling BillingDetailsRequestAddress., must be smaller than or equal to 255.'); + } + if (!is_null($organization) && (mb_strlen($organization) < 1)) { + throw new \InvalidArgumentException('invalid length for $organization when calling BillingDetailsRequestAddress., must be bigger than or equal to 1.'); + } + + $this->container['organization'] = $organization; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/BillingDetailsTaxId.php b/lib/model/BillingDetailsTaxId.php new file mode 100644 index 0000000..dedbcd5 --- /dev/null +++ b/lib/model/BillingDetailsTaxId.php @@ -0,0 +1,488 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class BillingDetailsTaxId implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'BillingDetails_tax_id'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'value' => 'string', + 'kind' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'value' => null, + 'kind' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'value' => 'value', + 'kind' => 'kind' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'value' => 'setValue', + 'kind' => 'setKind' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'value' => 'getValue', + 'kind' => 'getKind' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const KIND_AE_TRN = 'ae.trn'; + public const KIND_AU_ABN = 'au.abn'; + public const KIND_AR_CUIT = 'ar.cuit'; + public const KIND_BR_CNPJ = 'br.cnpj'; + public const KIND_BR_CPF = 'br.cpf'; + public const KIND_CA_BN = 'ca.bn'; + public const KIND_CA_GST_HST = 'ca.gst_hst'; + public const KIND_CA_PST_BC = 'ca.pst_bc'; + public const KIND_CA_PST_MB = 'ca.pst_mb'; + public const KIND_CA_PST_SK = 'ca.pst_sk'; + public const KIND_CA_QST = 'ca.qst'; + public const KIND_CH_VAT = 'ch.vat'; + public const KIND_CL_TIN = 'cl.tin'; + public const KIND_ES_CIF = 'es.cif'; + public const KIND_EU_VAT = 'eu.vat'; + public const KIND_GB_VAT = 'gb.vat'; + public const KIND_HK_BR = 'hk.br'; + public const KIND_ID_NIK = 'id.nik'; + public const KIND_ID_NPWP = 'id.npwp'; + public const KIND_IN_GST = 'in.gst'; + public const KIND_JP_CN = 'jp.cn'; + public const KIND_JP_RN = 'jp.rn'; + public const KIND_KR_BRN = 'kr.brn'; + public const KIND_LI_UID = 'li.uid'; + public const KIND_MX_RFC = 'mx.rfc'; + public const KIND_MY_FRP = 'my.frp'; + public const KIND_MY_ITN = 'my.itn'; + public const KIND_MY_NRIC = 'my.nric'; + public const KIND_MY_SST = 'my.sst'; + public const KIND_NO_VAT = 'no.vat'; + public const KIND_NZ_GST = 'nz.gst'; + public const KIND_PH_TIN = 'ph.tin'; + public const KIND_RU_INN = 'ru.inn'; + public const KIND_RU_KPP = 'ru.kpp'; + public const KIND_SA_VAT = 'sa.vat'; + public const KIND_SG_GST = 'sg.gst'; + public const KIND_SG_UEN = 'sg.uen'; + public const KIND_TH_ID = 'th.id'; + public const KIND_TH_VAT = 'th.vat'; + public const KIND_TW_VAT = 'tw.vat'; + public const KIND_US_EIN = 'us.ein'; + public const KIND_ZA_VAT = 'za.vat'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getKindAllowableValues() + { + return [ + self::KIND_AE_TRN, + self::KIND_AU_ABN, + self::KIND_AR_CUIT, + self::KIND_BR_CNPJ, + self::KIND_BR_CPF, + self::KIND_CA_BN, + self::KIND_CA_GST_HST, + self::KIND_CA_PST_BC, + self::KIND_CA_PST_MB, + self::KIND_CA_PST_SK, + self::KIND_CA_QST, + self::KIND_CH_VAT, + self::KIND_CL_TIN, + self::KIND_ES_CIF, + self::KIND_EU_VAT, + self::KIND_GB_VAT, + self::KIND_HK_BR, + self::KIND_ID_NIK, + self::KIND_ID_NPWP, + self::KIND_IN_GST, + self::KIND_JP_CN, + self::KIND_JP_RN, + self::KIND_KR_BRN, + self::KIND_LI_UID, + self::KIND_MX_RFC, + self::KIND_MY_FRP, + self::KIND_MY_ITN, + self::KIND_MY_NRIC, + self::KIND_MY_SST, + self::KIND_NO_VAT, + self::KIND_NZ_GST, + self::KIND_PH_TIN, + self::KIND_RU_INN, + self::KIND_RU_KPP, + self::KIND_SA_VAT, + self::KIND_SG_GST, + self::KIND_SG_UEN, + self::KIND_TH_ID, + self::KIND_TH_VAT, + self::KIND_TW_VAT, + self::KIND_US_EIN, + self::KIND_ZA_VAT, + ]; + } + + /** + * 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['value'] = $data['value'] ?? null; + $this->container['kind'] = $data['kind'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['value'] === null) { + $invalidProperties[] = "'value' can't be null"; + } + if ((mb_strlen($this->container['value']) > 50)) { + $invalidProperties[] = "invalid value for 'value', the character length must be smaller than or equal to 50."; + } + + if ((mb_strlen($this->container['value']) < 1)) { + $invalidProperties[] = "invalid value for 'value', the character length must be bigger than or equal to 1."; + } + + if ($this->container['kind'] === null) { + $invalidProperties[] = "'kind' can't be null"; + } + $allowedValues = $this->getKindAllowableValues(); + if (!is_null($this->container['kind']) && !in_array($this->container['kind'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'kind', must be one of '%s'", + $this->container['kind'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets value + * + * @return string + */ + public function getValue() + { + return $this->container['value']; + } + + /** + * Sets value + * + * @param string $value The tax ID for the buyer. + * + * @return self + */ + public function setValue($value) + { + if ((mb_strlen($value) > 50)) { + throw new \InvalidArgumentException('invalid length for $value when calling BillingDetailsTaxId., must be smaller than or equal to 50.'); + } + if ((mb_strlen($value) < 1)) { + throw new \InvalidArgumentException('invalid length for $value when calling BillingDetailsTaxId., must be bigger than or equal to 1.'); + } + + $this->container['value'] = $value; + + return $this; + } + + /** + * Gets kind + * + * @return string + */ + public function getKind() + { + return $this->container['kind']; + } + + /** + * Sets kind + * + * @param string $kind The kind of tax ID. + * + * @return self + */ + public function setKind($kind) + { + $allowedValues = $this->getKindAllowableValues(); + if (!in_array($kind, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'kind', must be one of '%s'", + $kind, + implode("', '", $allowedValues) + ) + ); + } + $this->container['kind'] = $kind; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/BillingDetailsUpdateRequest.php b/lib/model/BillingDetailsUpdateRequest.php new file mode 100644 index 0000000..b61a994 --- /dev/null +++ b/lib/model/BillingDetailsUpdateRequest.php @@ -0,0 +1,540 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class BillingDetailsUpdateRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'BillingDetailsUpdateRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'first_name' => 'string', + 'last_name' => 'string', + 'email_address' => 'string', + 'phone_number' => 'string', + 'address' => '\Gr4vy\model\BillingDetailsUpdateRequestAddress', + 'tax_id' => '\Gr4vy\model\BillingDetailsTaxId' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'first_name' => null, + 'last_name' => null, + 'email_address' => null, + 'phone_number' => null, + 'address' => null, + 'tax_id' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'first_name' => 'first_name', + 'last_name' => 'last_name', + 'email_address' => 'email_address', + 'phone_number' => 'phone_number', + 'address' => 'address', + 'tax_id' => 'tax_id' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'first_name' => 'setFirstName', + 'last_name' => 'setLastName', + 'email_address' => 'setEmailAddress', + 'phone_number' => 'setPhoneNumber', + 'address' => 'setAddress', + 'tax_id' => 'setTaxId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'first_name' => 'getFirstName', + 'last_name' => 'getLastName', + 'email_address' => 'getEmailAddress', + 'phone_number' => 'getPhoneNumber', + 'address' => 'getAddress', + 'tax_id' => 'getTaxId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['first_name'] = $data['first_name'] ?? null; + $this->container['last_name'] = $data['last_name'] ?? null; + $this->container['email_address'] = $data['email_address'] ?? null; + $this->container['phone_number'] = $data['phone_number'] ?? null; + $this->container['address'] = $data['address'] ?? null; + $this->container['tax_id'] = $data['tax_id'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['first_name']) && (mb_strlen($this->container['first_name']) > 255)) { + $invalidProperties[] = "invalid value for 'first_name', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['first_name']) && (mb_strlen($this->container['first_name']) < 1)) { + $invalidProperties[] = "invalid value for 'first_name', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['last_name']) && (mb_strlen($this->container['last_name']) > 255)) { + $invalidProperties[] = "invalid value for 'last_name', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['last_name']) && (mb_strlen($this->container['last_name']) < 1)) { + $invalidProperties[] = "invalid value for 'last_name', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['email_address']) && (mb_strlen($this->container['email_address']) > 320)) { + $invalidProperties[] = "invalid value for 'email_address', the character length must be smaller than or equal to 320."; + } + + if (!is_null($this->container['email_address']) && (mb_strlen($this->container['email_address']) < 1)) { + $invalidProperties[] = "invalid value for 'email_address', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['phone_number']) && (mb_strlen($this->container['phone_number']) > 50)) { + $invalidProperties[] = "invalid value for 'phone_number', the character length must be smaller than or equal to 50."; + } + + if (!is_null($this->container['phone_number']) && (mb_strlen($this->container['phone_number']) < 1)) { + $invalidProperties[] = "invalid value for 'phone_number', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['phone_number']) && !preg_match("/^\\+[1-9]\\d{1,14}$/", $this->container['phone_number'])) { + $invalidProperties[] = "invalid value for 'phone_number', must be conform to the pattern /^\\+[1-9]\\d{1,14}$/."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets first_name + * + * @return string|null + */ + public function getFirstName() + { + return $this->container['first_name']; + } + + /** + * Sets first_name + * + * @param string|null $first_name The first name(s) or given name for the buyer. + * + * @return self + */ + public function setFirstName($first_name) + { + if (!is_null($first_name) && (mb_strlen($first_name) > 255)) { + throw new \InvalidArgumentException('invalid length for $first_name when calling BillingDetailsUpdateRequest., must be smaller than or equal to 255.'); + } + if (!is_null($first_name) && (mb_strlen($first_name) < 1)) { + throw new \InvalidArgumentException('invalid length for $first_name when calling BillingDetailsUpdateRequest., must be bigger than or equal to 1.'); + } + + $this->container['first_name'] = $first_name; + + return $this; + } + + /** + * Gets last_name + * + * @return string|null + */ + public function getLastName() + { + return $this->container['last_name']; + } + + /** + * Sets last_name + * + * @param string|null $last_name The last name, or family name, of the buyer. + * + * @return self + */ + public function setLastName($last_name) + { + if (!is_null($last_name) && (mb_strlen($last_name) > 255)) { + throw new \InvalidArgumentException('invalid length for $last_name when calling BillingDetailsUpdateRequest., must be smaller than or equal to 255.'); + } + if (!is_null($last_name) && (mb_strlen($last_name) < 1)) { + throw new \InvalidArgumentException('invalid length for $last_name when calling BillingDetailsUpdateRequest., must be bigger than or equal to 1.'); + } + + $this->container['last_name'] = $last_name; + + return $this; + } + + /** + * Gets email_address + * + * @return string|null + */ + public function getEmailAddress() + { + return $this->container['email_address']; + } + + /** + * Sets email_address + * + * @param string|null $email_address The email address for the buyer. + * + * @return self + */ + public function setEmailAddress($email_address) + { + if (!is_null($email_address) && (mb_strlen($email_address) > 320)) { + throw new \InvalidArgumentException('invalid length for $email_address when calling BillingDetailsUpdateRequest., must be smaller than or equal to 320.'); + } + if (!is_null($email_address) && (mb_strlen($email_address) < 1)) { + throw new \InvalidArgumentException('invalid length for $email_address when calling BillingDetailsUpdateRequest., must be bigger than or equal to 1.'); + } + + $this->container['email_address'] = $email_address; + + return $this; + } + + /** + * Gets phone_number + * + * @return string|null + */ + public function getPhoneNumber() + { + return $this->container['phone_number']; + } + + /** + * Sets phone_number + * + * @param string|null $phone_number The phone number for the buyer which should be formatted according to the [E164 number standard](https://www.twilio.com/docs/glossary/what-e164). + * + * @return self + */ + public function setPhoneNumber($phone_number) + { + if (!is_null($phone_number) && (mb_strlen($phone_number) > 50)) { + throw new \InvalidArgumentException('invalid length for $phone_number when calling BillingDetailsUpdateRequest., must be smaller than or equal to 50.'); + } + if (!is_null($phone_number) && (mb_strlen($phone_number) < 1)) { + throw new \InvalidArgumentException('invalid length for $phone_number when calling BillingDetailsUpdateRequest., must be bigger than or equal to 1.'); + } + if (!is_null($phone_number) && (!preg_match("/^\\+[1-9]\\d{1,14}$/", $phone_number))) { + throw new \InvalidArgumentException("invalid value for $phone_number when calling BillingDetailsUpdateRequest., must conform to the pattern /^\\+[1-9]\\d{1,14}$/."); + } + + $this->container['phone_number'] = $phone_number; + + return $this; + } + + /** + * Gets address + * + * @return \Gr4vy\model\BillingDetailsUpdateRequestAddress|null + */ + public function getAddress() + { + return $this->container['address']; + } + + /** + * Sets address + * + * @param \Gr4vy\model\BillingDetailsUpdateRequestAddress|null $address address + * + * @return self + */ + public function setAddress($address) + { + $this->container['address'] = $address; + + return $this; + } + + /** + * Gets tax_id + * + * @return \Gr4vy\model\BillingDetailsTaxId|null + */ + public function getTaxId() + { + return $this->container['tax_id']; + } + + /** + * Sets tax_id + * + * @param \Gr4vy\model\BillingDetailsTaxId|null $tax_id tax_id + * + * @return self + */ + public function setTaxId($tax_id) + { + $this->container['tax_id'] = $tax_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/BillingDetailsUpdateRequestAddress.php b/lib/model/BillingDetailsUpdateRequestAddress.php new file mode 100644 index 0000000..8217f2f --- /dev/null +++ b/lib/model/BillingDetailsUpdateRequestAddress.php @@ -0,0 +1,699 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class BillingDetailsUpdateRequestAddress implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'BillingDetailsUpdateRequest_address'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'city' => 'string', + 'country' => 'string', + 'postal_code' => 'string', + 'state' => 'string', + 'state_code' => 'string', + 'house_number_or_name' => 'string', + 'line1' => 'string', + 'line2' => 'string', + 'organization' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'city' => null, + 'country' => null, + 'postal_code' => null, + 'state' => null, + 'state_code' => null, + 'house_number_or_name' => null, + 'line1' => null, + 'line2' => null, + 'organization' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'city' => 'city', + 'country' => 'country', + 'postal_code' => 'postal_code', + 'state' => 'state', + 'state_code' => 'state_code', + 'house_number_or_name' => 'house_number_or_name', + 'line1' => 'line1', + 'line2' => 'line2', + 'organization' => 'organization' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'city' => 'setCity', + 'country' => 'setCountry', + 'postal_code' => 'setPostalCode', + 'state' => 'setState', + 'state_code' => 'setStateCode', + 'house_number_or_name' => 'setHouseNumberOrName', + 'line1' => 'setLine1', + 'line2' => 'setLine2', + 'organization' => 'setOrganization' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'city' => 'getCity', + 'country' => 'getCountry', + 'postal_code' => 'getPostalCode', + 'state' => 'getState', + 'state_code' => 'getStateCode', + 'house_number_or_name' => 'getHouseNumberOrName', + 'line1' => 'getLine1', + 'line2' => 'getLine2', + 'organization' => 'getOrganization' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['city'] = $data['city'] ?? null; + $this->container['country'] = $data['country'] ?? null; + $this->container['postal_code'] = $data['postal_code'] ?? null; + $this->container['state'] = $data['state'] ?? null; + $this->container['state_code'] = $data['state_code'] ?? null; + $this->container['house_number_or_name'] = $data['house_number_or_name'] ?? null; + $this->container['line1'] = $data['line1'] ?? null; + $this->container['line2'] = $data['line2'] ?? null; + $this->container['organization'] = $data['organization'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['city']) && (mb_strlen($this->container['city']) > 100)) { + $invalidProperties[] = "invalid value for 'city', the character length must be smaller than or equal to 100."; + } + + if (!is_null($this->container['city']) && (mb_strlen($this->container['city']) < 1)) { + $invalidProperties[] = "invalid value for 'city', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['country']) && (mb_strlen($this->container['country']) > 2)) { + $invalidProperties[] = "invalid value for 'country', the character length must be smaller than or equal to 2."; + } + + if (!is_null($this->container['country']) && (mb_strlen($this->container['country']) < 1)) { + $invalidProperties[] = "invalid value for 'country', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['postal_code']) && (mb_strlen($this->container['postal_code']) > 50)) { + $invalidProperties[] = "invalid value for 'postal_code', the character length must be smaller than or equal to 50."; + } + + if (!is_null($this->container['postal_code']) && (mb_strlen($this->container['postal_code']) < 1)) { + $invalidProperties[] = "invalid value for 'postal_code', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['state']) && (mb_strlen($this->container['state']) > 255)) { + $invalidProperties[] = "invalid value for 'state', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['state']) && (mb_strlen($this->container['state']) < 1)) { + $invalidProperties[] = "invalid value for 'state', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['state_code']) && (mb_strlen($this->container['state_code']) > 6)) { + $invalidProperties[] = "invalid value for 'state_code', the character length must be smaller than or equal to 6."; + } + + if (!is_null($this->container['state_code']) && (mb_strlen($this->container['state_code']) < 4)) { + $invalidProperties[] = "invalid value for 'state_code', the character length must be bigger than or equal to 4."; + } + + if (!is_null($this->container['house_number_or_name']) && (mb_strlen($this->container['house_number_or_name']) > 255)) { + $invalidProperties[] = "invalid value for 'house_number_or_name', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['house_number_or_name']) && (mb_strlen($this->container['house_number_or_name']) < 1)) { + $invalidProperties[] = "invalid value for 'house_number_or_name', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['line1']) && (mb_strlen($this->container['line1']) > 255)) { + $invalidProperties[] = "invalid value for 'line1', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['line1']) && (mb_strlen($this->container['line1']) < 1)) { + $invalidProperties[] = "invalid value for 'line1', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['line2']) && (mb_strlen($this->container['line2']) > 255)) { + $invalidProperties[] = "invalid value for 'line2', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['line2']) && (mb_strlen($this->container['line2']) < 1)) { + $invalidProperties[] = "invalid value for 'line2', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['organization']) && (mb_strlen($this->container['organization']) > 255)) { + $invalidProperties[] = "invalid value for 'organization', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['organization']) && (mb_strlen($this->container['organization']) < 1)) { + $invalidProperties[] = "invalid value for 'organization', the character length must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets city + * + * @return string|null + */ + public function getCity() + { + return $this->container['city']; + } + + /** + * Sets city + * + * @param string|null $city The city for the billing address. + * + * @return self + */ + public function setCity($city) + { + if (!is_null($city) && (mb_strlen($city) > 100)) { + throw new \InvalidArgumentException('invalid length for $city when calling BillingDetailsUpdateRequestAddress., must be smaller than or equal to 100.'); + } + if (!is_null($city) && (mb_strlen($city) < 1)) { + throw new \InvalidArgumentException('invalid length for $city when calling BillingDetailsUpdateRequestAddress., must be bigger than or equal to 1.'); + } + + $this->container['city'] = $city; + + return $this; + } + + /** + * Gets country + * + * @return string|null + */ + public function getCountry() + { + return $this->container['country']; + } + + /** + * Sets country + * + * @param string|null $country The country for the billing address. + * + * @return self + */ + public function setCountry($country) + { + if (!is_null($country) && (mb_strlen($country) > 2)) { + throw new \InvalidArgumentException('invalid length for $country when calling BillingDetailsUpdateRequestAddress., must be smaller than or equal to 2.'); + } + if (!is_null($country) && (mb_strlen($country) < 1)) { + throw new \InvalidArgumentException('invalid length for $country when calling BillingDetailsUpdateRequestAddress., must be bigger than or equal to 1.'); + } + + $this->container['country'] = $country; + + return $this; + } + + /** + * Gets postal_code + * + * @return string|null + */ + public function getPostalCode() + { + return $this->container['postal_code']; + } + + /** + * Sets postal_code + * + * @param string|null $postal_code The postal code or zip code for the billing address. + * + * @return self + */ + public function setPostalCode($postal_code) + { + if (!is_null($postal_code) && (mb_strlen($postal_code) > 50)) { + throw new \InvalidArgumentException('invalid length for $postal_code when calling BillingDetailsUpdateRequestAddress., must be smaller than or equal to 50.'); + } + if (!is_null($postal_code) && (mb_strlen($postal_code) < 1)) { + throw new \InvalidArgumentException('invalid length for $postal_code when calling BillingDetailsUpdateRequestAddress., must be bigger than or equal to 1.'); + } + + $this->container['postal_code'] = $postal_code; + + return $this; + } + + /** + * Gets state + * + * @return string|null + */ + public function getState() + { + return $this->container['state']; + } + + /** + * Sets state + * + * @param string|null $state The state, county, or province for the billing address. + * + * @return self + */ + public function setState($state) + { + if (!is_null($state) && (mb_strlen($state) > 255)) { + throw new \InvalidArgumentException('invalid length for $state when calling BillingDetailsUpdateRequestAddress., must be smaller than or equal to 255.'); + } + if (!is_null($state) && (mb_strlen($state) < 1)) { + throw new \InvalidArgumentException('invalid length for $state when calling BillingDetailsUpdateRequestAddress., must be bigger than or equal to 1.'); + } + + $this->container['state'] = $state; + + return $this; + } + + /** + * Gets state_code + * + * @return string|null + */ + public function getStateCode() + { + return $this->container['state_code']; + } + + /** + * Sets state_code + * + * @param string|null $state_code The code of state, county, or province for the billing address in ISO 3166-2 format. + * + * @return self + */ + public function setStateCode($state_code) + { + if (!is_null($state_code) && (mb_strlen($state_code) > 6)) { + throw new \InvalidArgumentException('invalid length for $state_code when calling BillingDetailsUpdateRequestAddress., must be smaller than or equal to 6.'); + } + if (!is_null($state_code) && (mb_strlen($state_code) < 4)) { + throw new \InvalidArgumentException('invalid length for $state_code when calling BillingDetailsUpdateRequestAddress., must be bigger than or equal to 4.'); + } + + $this->container['state_code'] = $state_code; + + return $this; + } + + /** + * Gets house_number_or_name + * + * @return string|null + */ + public function getHouseNumberOrName() + { + return $this->container['house_number_or_name']; + } + + /** + * Sets house_number_or_name + * + * @param string|null $house_number_or_name The house number or name for the billing address. Not all payment services use this field but some do. + * + * @return self + */ + public function setHouseNumberOrName($house_number_or_name) + { + if (!is_null($house_number_or_name) && (mb_strlen($house_number_or_name) > 255)) { + throw new \InvalidArgumentException('invalid length for $house_number_or_name when calling BillingDetailsUpdateRequestAddress., must be smaller than or equal to 255.'); + } + if (!is_null($house_number_or_name) && (mb_strlen($house_number_or_name) < 1)) { + throw new \InvalidArgumentException('invalid length for $house_number_or_name when calling BillingDetailsUpdateRequestAddress., must be bigger than or equal to 1.'); + } + + $this->container['house_number_or_name'] = $house_number_or_name; + + return $this; + } + + /** + * Gets line1 + * + * @return string|null + */ + public function getLine1() + { + return $this->container['line1']; + } + + /** + * Sets line1 + * + * @param string|null $line1 The first line of the billing address. + * + * @return self + */ + public function setLine1($line1) + { + if (!is_null($line1) && (mb_strlen($line1) > 255)) { + throw new \InvalidArgumentException('invalid length for $line1 when calling BillingDetailsUpdateRequestAddress., must be smaller than or equal to 255.'); + } + if (!is_null($line1) && (mb_strlen($line1) < 1)) { + throw new \InvalidArgumentException('invalid length for $line1 when calling BillingDetailsUpdateRequestAddress., must be bigger than or equal to 1.'); + } + + $this->container['line1'] = $line1; + + return $this; + } + + /** + * Gets line2 + * + * @return string|null + */ + public function getLine2() + { + return $this->container['line2']; + } + + /** + * Sets line2 + * + * @param string|null $line2 The second line of the billing address. + * + * @return self + */ + public function setLine2($line2) + { + if (!is_null($line2) && (mb_strlen($line2) > 255)) { + throw new \InvalidArgumentException('invalid length for $line2 when calling BillingDetailsUpdateRequestAddress., must be smaller than or equal to 255.'); + } + if (!is_null($line2) && (mb_strlen($line2) < 1)) { + throw new \InvalidArgumentException('invalid length for $line2 when calling BillingDetailsUpdateRequestAddress., must be bigger than or equal to 1.'); + } + + $this->container['line2'] = $line2; + + return $this; + } + + /** + * Gets organization + * + * @return string|null + */ + public function getOrganization() + { + return $this->container['organization']; + } + + /** + * Sets organization + * + * @param string|null $organization The optional name of the company or organisation to add to the billing address. + * + * @return self + */ + public function setOrganization($organization) + { + if (!is_null($organization) && (mb_strlen($organization) > 255)) { + throw new \InvalidArgumentException('invalid length for $organization when calling BillingDetailsUpdateRequestAddress., must be smaller than or equal to 255.'); + } + if (!is_null($organization) && (mb_strlen($organization) < 1)) { + throw new \InvalidArgumentException('invalid length for $organization when calling BillingDetailsUpdateRequestAddress., must be bigger than or equal to 1.'); + } + + $this->container['organization'] = $organization; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/BrowserInfo.php b/lib/model/BrowserInfo.php new file mode 100644 index 0000000..fff6163 --- /dev/null +++ b/lib/model/BrowserInfo.php @@ -0,0 +1,654 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class BrowserInfo implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'BrowserInfo'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'java_enabled' => 'bool', + 'javascript_enabled' => 'bool', + 'language' => 'string', + 'color_depth' => 'float', + 'screen_height' => 'float', + 'screen_width' => 'float', + 'time_zone_offset' => 'float', + 'user_device' => 'string', + 'user_agent' => 'string', + 'accept_header' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'java_enabled' => null, + 'javascript_enabled' => null, + 'language' => null, + 'color_depth' => null, + 'screen_height' => null, + 'screen_width' => null, + 'time_zone_offset' => null, + 'user_device' => null, + 'user_agent' => null, + 'accept_header' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'java_enabled' => 'java_enabled', + 'javascript_enabled' => 'javascript_enabled', + 'language' => 'language', + 'color_depth' => 'color_depth', + 'screen_height' => 'screen_height', + 'screen_width' => 'screen_width', + 'time_zone_offset' => 'time_zone_offset', + 'user_device' => 'user_device', + 'user_agent' => 'user_agent', + 'accept_header' => 'accept_header' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'java_enabled' => 'setJavaEnabled', + 'javascript_enabled' => 'setJavascriptEnabled', + 'language' => 'setLanguage', + 'color_depth' => 'setColorDepth', + 'screen_height' => 'setScreenHeight', + 'screen_width' => 'setScreenWidth', + 'time_zone_offset' => 'setTimeZoneOffset', + 'user_device' => 'setUserDevice', + 'user_agent' => 'setUserAgent', + 'accept_header' => 'setAcceptHeader' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'java_enabled' => 'getJavaEnabled', + 'javascript_enabled' => 'getJavascriptEnabled', + 'language' => 'getLanguage', + 'color_depth' => 'getColorDepth', + 'screen_height' => 'getScreenHeight', + 'screen_width' => 'getScreenWidth', + 'time_zone_offset' => 'getTimeZoneOffset', + 'user_device' => 'getUserDevice', + 'user_agent' => 'getUserAgent', + 'accept_header' => 'getAcceptHeader' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const USER_DEVICE_DESKTOP = 'desktop'; + public const USER_DEVICE_MOBILE = 'mobile'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getUserDeviceAllowableValues() + { + return [ + self::USER_DEVICE_DESKTOP, + self::USER_DEVICE_MOBILE, + ]; + } + + /** + * 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['java_enabled'] = $data['java_enabled'] ?? null; + $this->container['javascript_enabled'] = $data['javascript_enabled'] ?? null; + $this->container['language'] = $data['language'] ?? null; + $this->container['color_depth'] = $data['color_depth'] ?? null; + $this->container['screen_height'] = $data['screen_height'] ?? null; + $this->container['screen_width'] = $data['screen_width'] ?? null; + $this->container['time_zone_offset'] = $data['time_zone_offset'] ?? null; + $this->container['user_device'] = $data['user_device'] ?? null; + $this->container['user_agent'] = $data['user_agent'] ?? null; + $this->container['accept_header'] = $data['accept_header'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['java_enabled'] === null) { + $invalidProperties[] = "'java_enabled' can't be null"; + } + if ($this->container['javascript_enabled'] === null) { + $invalidProperties[] = "'javascript_enabled' can't be null"; + } + if ($this->container['language'] === null) { + $invalidProperties[] = "'language' can't be null"; + } + if ($this->container['color_depth'] === null) { + $invalidProperties[] = "'color_depth' can't be null"; + } + if ($this->container['screen_height'] === null) { + $invalidProperties[] = "'screen_height' can't be null"; + } + if ($this->container['screen_width'] === null) { + $invalidProperties[] = "'screen_width' can't be null"; + } + if ($this->container['time_zone_offset'] === null) { + $invalidProperties[] = "'time_zone_offset' can't be null"; + } + if ($this->container['user_device'] === null) { + $invalidProperties[] = "'user_device' can't be null"; + } + $allowedValues = $this->getUserDeviceAllowableValues(); + if (!is_null($this->container['user_device']) && !in_array($this->container['user_device'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'user_device', must be one of '%s'", + $this->container['user_device'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['user_agent'] === null) { + $invalidProperties[] = "'user_agent' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets java_enabled + * + * @return bool + */ + public function getJavaEnabled() + { + return $this->container['java_enabled']; + } + + /** + * Sets java_enabled + * + * @param bool $java_enabled Indicates whether the client browser supports Java. + * + * @return self + */ + public function setJavaEnabled($java_enabled) + { + $this->container['java_enabled'] = $java_enabled; + + return $this; + } + + /** + * Gets javascript_enabled + * + * @return bool + */ + public function getJavascriptEnabled() + { + return $this->container['javascript_enabled']; + } + + /** + * Sets javascript_enabled + * + * @param bool $javascript_enabled Indicates whether the client browser supports JavaScript. + * + * @return self + */ + public function setJavascriptEnabled($javascript_enabled) + { + $this->container['javascript_enabled'] = $javascript_enabled; + + return $this; + } + + /** + * Gets language + * + * @return string + */ + public function getLanguage() + { + return $this->container['language']; + } + + /** + * Sets language + * + * @param string $language The preferred language of the buyer, usually the language of the browser UI. + * + * @return self + */ + public function setLanguage($language) + { + $this->container['language'] = $language; + + return $this; + } + + /** + * Gets color_depth + * + * @return float + */ + public function getColorDepth() + { + return $this->container['color_depth']; + } + + /** + * Sets color_depth + * + * @param float $color_depth The color depth of the screen. + * + * @return self + */ + public function setColorDepth($color_depth) + { + $this->container['color_depth'] = $color_depth; + + return $this; + } + + /** + * Gets screen_height + * + * @return float + */ + public function getScreenHeight() + { + return $this->container['screen_height']; + } + + /** + * Sets screen_height + * + * @param float $screen_height The height of the screen in pixels. + * + * @return self + */ + public function setScreenHeight($screen_height) + { + $this->container['screen_height'] = $screen_height; + + return $this; + } + + /** + * Gets screen_width + * + * @return float + */ + public function getScreenWidth() + { + return $this->container['screen_width']; + } + + /** + * Sets screen_width + * + * @param float $screen_width The width of the screen in pixels. + * + * @return self + */ + public function setScreenWidth($screen_width) + { + $this->container['screen_width'] = $screen_width; + + return $this; + } + + /** + * Gets time_zone_offset + * + * @return float + */ + public function getTimeZoneOffset() + { + return $this->container['time_zone_offset']; + } + + /** + * Sets time_zone_offset + * + * @param float $time_zone_offset Time-zone offset in minutes between UTC and buyer location. + * + * @return self + */ + public function setTimeZoneOffset($time_zone_offset) + { + $this->container['time_zone_offset'] = $time_zone_offset; + + return $this; + } + + /** + * Gets user_device + * + * @return string + */ + public function getUserDevice() + { + return $this->container['user_device']; + } + + /** + * Sets user_device + * + * @param string $user_device The platform that is being used to access the website. + * + * @return self + */ + public function setUserDevice($user_device) + { + $allowedValues = $this->getUserDeviceAllowableValues(); + if (!in_array($user_device, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'user_device', must be one of '%s'", + $user_device, + implode("', '", $allowedValues) + ) + ); + } + $this->container['user_device'] = $user_device; + + return $this; + } + + /** + * Gets user_agent + * + * @return string + */ + public function getUserAgent() + { + return $this->container['user_agent']; + } + + /** + * Sets user_agent + * + * @param string $user_agent The user agent string for the current browser. + * + * @return self + */ + public function setUserAgent($user_agent) + { + $this->container['user_agent'] = $user_agent; + + return $this; + } + + /** + * Gets accept_header + * + * @return string|null + */ + public function getAcceptHeader() + { + return $this->container['accept_header']; + } + + /** + * Sets accept_header + * + * @param string|null $accept_header The `Accept` header of the request from the buyer's browser. + * + * @return self + */ + public function setAcceptHeader($accept_header) + { + $this->container['accept_header'] = $accept_header; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/Buyer.php b/lib/model/Buyer.php new file mode 100644 index 0000000..6cf7cc7 --- /dev/null +++ b/lib/model/Buyer.php @@ -0,0 +1,565 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class Buyer implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'Buyer'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'id' => 'string', + 'external_identifier' => 'string', + 'display_name' => 'string', + 'billing_details' => '\Gr4vy\model\BuyerBillingDetails', + 'created_at' => '\DateTime', + 'updated_at' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'id' => 'uuid', + 'external_identifier' => null, + 'display_name' => null, + 'billing_details' => null, + 'created_at' => 'date-time', + 'updated_at' => 'date-time' + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'id' => 'id', + 'external_identifier' => 'external_identifier', + 'display_name' => 'display_name', + 'billing_details' => 'billing_details', + 'created_at' => 'created_at', + 'updated_at' => 'updated_at' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'id' => 'setId', + 'external_identifier' => 'setExternalIdentifier', + 'display_name' => 'setDisplayName', + 'billing_details' => 'setBillingDetails', + 'created_at' => 'setCreatedAt', + 'updated_at' => 'setUpdatedAt' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'id' => 'getId', + 'external_identifier' => 'getExternalIdentifier', + 'display_name' => 'getDisplayName', + 'billing_details' => 'getBillingDetails', + 'created_at' => 'getCreatedAt', + 'updated_at' => 'getUpdatedAt' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_BUYER = 'buyer'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_BUYER, + ]; + } + + /** + * 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['type'] = $data['type'] ?? null; + $this->container['id'] = $data['id'] ?? null; + $this->container['external_identifier'] = $data['external_identifier'] ?? null; + $this->container['display_name'] = $data['display_name'] ?? null; + $this->container['billing_details'] = $data['billing_details'] ?? null; + $this->container['created_at'] = $data['created_at'] ?? null; + $this->container['updated_at'] = $data['updated_at'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + if (!is_null($this->container['external_identifier']) && (mb_strlen($this->container['external_identifier']) > 200)) { + $invalidProperties[] = "invalid value for 'external_identifier', the character length must be smaller than or equal to 200."; + } + + if (!is_null($this->container['external_identifier']) && (mb_strlen($this->container['external_identifier']) < 1)) { + $invalidProperties[] = "invalid value for 'external_identifier', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['display_name']) && (mb_strlen($this->container['display_name']) > 200)) { + $invalidProperties[] = "invalid value for 'display_name', the character length must be smaller than or equal to 200."; + } + + if (!is_null($this->container['display_name']) && (mb_strlen($this->container['display_name']) < 1)) { + $invalidProperties[] = "invalid value for 'display_name', the character length must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type The type of this resource. Is always `buyer`. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id The unique Gr4vy ID for this buyer. + * + * @return self + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets external_identifier + * + * @return string|null + */ + public function getExternalIdentifier() + { + return $this->container['external_identifier']; + } + + /** + * Sets external_identifier + * + * @param string|null $external_identifier An external identifier that can be used to match the buyer against your own records. + * + * @return self + */ + public function setExternalIdentifier($external_identifier) + { + if (!is_null($external_identifier) && (mb_strlen($external_identifier) > 200)) { + throw new \InvalidArgumentException('invalid length for $external_identifier when calling Buyer., must be smaller than or equal to 200.'); + } + if (!is_null($external_identifier) && (mb_strlen($external_identifier) < 1)) { + throw new \InvalidArgumentException('invalid length for $external_identifier when calling Buyer., must be bigger than or equal to 1.'); + } + + $this->container['external_identifier'] = $external_identifier; + + return $this; + } + + /** + * Gets display_name + * + * @return string|null + */ + public function getDisplayName() + { + return $this->container['display_name']; + } + + /** + * Sets display_name + * + * @param string|null $display_name A unique name for this buyer which is used in the Gr4vy admin panel to give a buyer a human readable name. + * + * @return self + */ + public function setDisplayName($display_name) + { + if (!is_null($display_name) && (mb_strlen($display_name) > 200)) { + throw new \InvalidArgumentException('invalid length for $display_name when calling Buyer., must be smaller than or equal to 200.'); + } + if (!is_null($display_name) && (mb_strlen($display_name) < 1)) { + throw new \InvalidArgumentException('invalid length for $display_name when calling Buyer., must be bigger than or equal to 1.'); + } + + $this->container['display_name'] = $display_name; + + return $this; + } + + /** + * Gets billing_details + * + * @return \Gr4vy\model\BuyerBillingDetails|null + */ + public function getBillingDetails() + { + return $this->container['billing_details']; + } + + /** + * Sets billing_details + * + * @param \Gr4vy\model\BuyerBillingDetails|null $billing_details billing_details + * + * @return self + */ + public function setBillingDetails($billing_details) + { + $this->container['billing_details'] = $billing_details; + + return $this; + } + + /** + * Gets created_at + * + * @return \DateTime|null + */ + public function getCreatedAt() + { + return $this->container['created_at']; + } + + /** + * Sets created_at + * + * @param \DateTime|null $created_at The date and time when this buyer was created in our system. + * + * @return self + */ + public function setCreatedAt($created_at) + { + $this->container['created_at'] = $created_at; + + return $this; + } + + /** + * Gets updated_at + * + * @return \DateTime|null + */ + public function getUpdatedAt() + { + return $this->container['updated_at']; + } + + /** + * Sets updated_at + * + * @param \DateTime|null $updated_at The date and time when this buyer was last updated in our system. + * + * @return self + */ + public function setUpdatedAt($updated_at) + { + $this->container['updated_at'] = $updated_at; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/BuyerBillingDetails.php b/lib/model/BuyerBillingDetails.php new file mode 100644 index 0000000..8fb0237 --- /dev/null +++ b/lib/model/BuyerBillingDetails.php @@ -0,0 +1,602 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class BuyerBillingDetails implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'Buyer_billing_details'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'first_name' => 'string', + 'last_name' => 'string', + 'email_address' => 'string', + 'phone_number' => 'string', + 'address' => '\Gr4vy\model\BillingDetailsAddress', + 'tax_id' => '\Gr4vy\model\BillingDetailsTaxId' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'first_name' => null, + 'last_name' => null, + 'email_address' => null, + 'phone_number' => null, + 'address' => null, + 'tax_id' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'first_name' => 'first_name', + 'last_name' => 'last_name', + 'email_address' => 'email_address', + 'phone_number' => 'phone_number', + 'address' => 'address', + 'tax_id' => 'tax_id' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'first_name' => 'setFirstName', + 'last_name' => 'setLastName', + 'email_address' => 'setEmailAddress', + 'phone_number' => 'setPhoneNumber', + 'address' => 'setAddress', + 'tax_id' => 'setTaxId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'first_name' => 'getFirstName', + 'last_name' => 'getLastName', + 'email_address' => 'getEmailAddress', + 'phone_number' => 'getPhoneNumber', + 'address' => 'getAddress', + 'tax_id' => 'getTaxId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_BILLING_DETAILS = 'billing-details'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_BILLING_DETAILS, + ]; + } + + /** + * 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['type'] = $data['type'] ?? null; + $this->container['first_name'] = $data['first_name'] ?? null; + $this->container['last_name'] = $data['last_name'] ?? null; + $this->container['email_address'] = $data['email_address'] ?? null; + $this->container['phone_number'] = $data['phone_number'] ?? null; + $this->container['address'] = $data['address'] ?? null; + $this->container['tax_id'] = $data['tax_id'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + if (!is_null($this->container['first_name']) && (mb_strlen($this->container['first_name']) > 255)) { + $invalidProperties[] = "invalid value for 'first_name', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['first_name']) && (mb_strlen($this->container['first_name']) < 1)) { + $invalidProperties[] = "invalid value for 'first_name', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['last_name']) && (mb_strlen($this->container['last_name']) > 255)) { + $invalidProperties[] = "invalid value for 'last_name', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['last_name']) && (mb_strlen($this->container['last_name']) < 1)) { + $invalidProperties[] = "invalid value for 'last_name', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['email_address']) && (mb_strlen($this->container['email_address']) > 320)) { + $invalidProperties[] = "invalid value for 'email_address', the character length must be smaller than or equal to 320."; + } + + if (!is_null($this->container['email_address']) && (mb_strlen($this->container['email_address']) < 1)) { + $invalidProperties[] = "invalid value for 'email_address', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['phone_number']) && (mb_strlen($this->container['phone_number']) > 50)) { + $invalidProperties[] = "invalid value for 'phone_number', the character length must be smaller than or equal to 50."; + } + + if (!is_null($this->container['phone_number']) && (mb_strlen($this->container['phone_number']) < 1)) { + $invalidProperties[] = "invalid value for 'phone_number', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['phone_number']) && !preg_match("/^\\+[1-9]\\d{1,14}$/", $this->container['phone_number'])) { + $invalidProperties[] = "invalid value for 'phone_number', must be conform to the pattern /^\\+[1-9]\\d{1,14}$/."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type The type of this resource. Is always `billing-details`. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets first_name + * + * @return string|null + */ + public function getFirstName() + { + return $this->container['first_name']; + } + + /** + * Sets first_name + * + * @param string|null $first_name The first name(s) or given name of the buyer. + * + * @return self + */ + public function setFirstName($first_name) + { + if (!is_null($first_name) && (mb_strlen($first_name) > 255)) { + throw new \InvalidArgumentException('invalid length for $first_name when calling BuyerBillingDetails., must be smaller than or equal to 255.'); + } + if (!is_null($first_name) && (mb_strlen($first_name) < 1)) { + throw new \InvalidArgumentException('invalid length for $first_name when calling BuyerBillingDetails., must be bigger than or equal to 1.'); + } + + $this->container['first_name'] = $first_name; + + return $this; + } + + /** + * Gets last_name + * + * @return string|null + */ + public function getLastName() + { + return $this->container['last_name']; + } + + /** + * Sets last_name + * + * @param string|null $last_name The last name, or family name, of the buyer. + * + * @return self + */ + public function setLastName($last_name) + { + if (!is_null($last_name) && (mb_strlen($last_name) > 255)) { + throw new \InvalidArgumentException('invalid length for $last_name when calling BuyerBillingDetails., must be smaller than or equal to 255.'); + } + if (!is_null($last_name) && (mb_strlen($last_name) < 1)) { + throw new \InvalidArgumentException('invalid length for $last_name when calling BuyerBillingDetails., must be bigger than or equal to 1.'); + } + + $this->container['last_name'] = $last_name; + + return $this; + } + + /** + * Gets email_address + * + * @return string|null + */ + public function getEmailAddress() + { + return $this->container['email_address']; + } + + /** + * Sets email_address + * + * @param string|null $email_address The email address of the buyer. + * + * @return self + */ + public function setEmailAddress($email_address) + { + if (!is_null($email_address) && (mb_strlen($email_address) > 320)) { + throw new \InvalidArgumentException('invalid length for $email_address when calling BuyerBillingDetails., must be smaller than or equal to 320.'); + } + if (!is_null($email_address) && (mb_strlen($email_address) < 1)) { + throw new \InvalidArgumentException('invalid length for $email_address when calling BuyerBillingDetails., must be bigger than or equal to 1.'); + } + + $this->container['email_address'] = $email_address; + + return $this; + } + + /** + * Gets phone_number + * + * @return string|null + */ + public function getPhoneNumber() + { + return $this->container['phone_number']; + } + + /** + * Sets phone_number + * + * @param string|null $phone_number The phone number of the buyer. This number is formatted according to the [E164 number standard](https://www.twilio.com/docs/glossary/what-e164). + * + * @return self + */ + public function setPhoneNumber($phone_number) + { + if (!is_null($phone_number) && (mb_strlen($phone_number) > 50)) { + throw new \InvalidArgumentException('invalid length for $phone_number when calling BuyerBillingDetails., must be smaller than or equal to 50.'); + } + if (!is_null($phone_number) && (mb_strlen($phone_number) < 1)) { + throw new \InvalidArgumentException('invalid length for $phone_number when calling BuyerBillingDetails., must be bigger than or equal to 1.'); + } + if (!is_null($phone_number) && (!preg_match("/^\\+[1-9]\\d{1,14}$/", $phone_number))) { + throw new \InvalidArgumentException("invalid value for $phone_number when calling BuyerBillingDetails., must conform to the pattern /^\\+[1-9]\\d{1,14}$/."); + } + + $this->container['phone_number'] = $phone_number; + + return $this; + } + + /** + * Gets address + * + * @return \Gr4vy\model\BillingDetailsAddress|null + */ + public function getAddress() + { + return $this->container['address']; + } + + /** + * Sets address + * + * @param \Gr4vy\model\BillingDetailsAddress|null $address address + * + * @return self + */ + public function setAddress($address) + { + $this->container['address'] = $address; + + return $this; + } + + /** + * Gets tax_id + * + * @return \Gr4vy\model\BillingDetailsTaxId|null + */ + public function getTaxId() + { + return $this->container['tax_id']; + } + + /** + * Sets tax_id + * + * @param \Gr4vy\model\BillingDetailsTaxId|null $tax_id tax_id + * + * @return self + */ + public function setTaxId($tax_id) + { + $this->container['tax_id'] = $tax_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/BuyerRequest.php b/lib/model/BuyerRequest.php new file mode 100644 index 0000000..afa0177 --- /dev/null +++ b/lib/model/BuyerRequest.php @@ -0,0 +1,414 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class BuyerRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'BuyerRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'external_identifier' => 'string', + 'display_name' => 'string', + 'billing_details' => '\Gr4vy\model\BuyerRequestBillingDetails' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'external_identifier' => null, + 'display_name' => null, + 'billing_details' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'external_identifier' => 'external_identifier', + 'display_name' => 'display_name', + 'billing_details' => 'billing_details' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'external_identifier' => 'setExternalIdentifier', + 'display_name' => 'setDisplayName', + 'billing_details' => 'setBillingDetails' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'external_identifier' => 'getExternalIdentifier', + 'display_name' => 'getDisplayName', + 'billing_details' => 'getBillingDetails' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['external_identifier'] = $data['external_identifier'] ?? null; + $this->container['display_name'] = $data['display_name'] ?? null; + $this->container['billing_details'] = $data['billing_details'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['external_identifier']) && (mb_strlen($this->container['external_identifier']) > 200)) { + $invalidProperties[] = "invalid value for 'external_identifier', the character length must be smaller than or equal to 200."; + } + + if (!is_null($this->container['external_identifier']) && (mb_strlen($this->container['external_identifier']) < 1)) { + $invalidProperties[] = "invalid value for 'external_identifier', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['display_name']) && (mb_strlen($this->container['display_name']) > 200)) { + $invalidProperties[] = "invalid value for 'display_name', the character length must be smaller than or equal to 200."; + } + + if (!is_null($this->container['display_name']) && (mb_strlen($this->container['display_name']) < 1)) { + $invalidProperties[] = "invalid value for 'display_name', the character length must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets external_identifier + * + * @return string|null + */ + public function getExternalIdentifier() + { + return $this->container['external_identifier']; + } + + /** + * Sets external_identifier + * + * @param string|null $external_identifier An external identifier that can be used to match the buyer against your own records. This value needs to be unique for all buyers. + * + * @return self + */ + public function setExternalIdentifier($external_identifier) + { + if (!is_null($external_identifier) && (mb_strlen($external_identifier) > 200)) { + throw new \InvalidArgumentException('invalid length for $external_identifier when calling BuyerRequest., must be smaller than or equal to 200.'); + } + if (!is_null($external_identifier) && (mb_strlen($external_identifier) < 1)) { + throw new \InvalidArgumentException('invalid length for $external_identifier when calling BuyerRequest., must be bigger than or equal to 1.'); + } + + $this->container['external_identifier'] = $external_identifier; + + return $this; + } + + /** + * Gets display_name + * + * @return string|null + */ + public function getDisplayName() + { + return $this->container['display_name']; + } + + /** + * Sets display_name + * + * @param string|null $display_name A unique name for this buyer which is used in the Gr4vy admin panel to give a buyer a human readable name. + * + * @return self + */ + public function setDisplayName($display_name) + { + if (!is_null($display_name) && (mb_strlen($display_name) > 200)) { + throw new \InvalidArgumentException('invalid length for $display_name when calling BuyerRequest., must be smaller than or equal to 200.'); + } + if (!is_null($display_name) && (mb_strlen($display_name) < 1)) { + throw new \InvalidArgumentException('invalid length for $display_name when calling BuyerRequest., must be bigger than or equal to 1.'); + } + + $this->container['display_name'] = $display_name; + + return $this; + } + + /** + * Gets billing_details + * + * @return \Gr4vy\model\BuyerRequestBillingDetails|null + */ + public function getBillingDetails() + { + return $this->container['billing_details']; + } + + /** + * Sets billing_details + * + * @param \Gr4vy\model\BuyerRequestBillingDetails|null $billing_details billing_details + * + * @return self + */ + public function setBillingDetails($billing_details) + { + $this->container['billing_details'] = $billing_details; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/BuyerRequestBillingDetails.php b/lib/model/BuyerRequestBillingDetails.php new file mode 100644 index 0000000..9b6445b --- /dev/null +++ b/lib/model/BuyerRequestBillingDetails.php @@ -0,0 +1,540 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class BuyerRequestBillingDetails implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'BuyerRequest_billing_details'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'first_name' => 'string', + 'last_name' => 'string', + 'email_address' => 'string', + 'phone_number' => 'string', + 'address' => '\Gr4vy\model\BillingDetailsRequestAddress', + 'tax_id' => '\Gr4vy\model\BillingDetailsTaxId' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'first_name' => null, + 'last_name' => null, + 'email_address' => null, + 'phone_number' => null, + 'address' => null, + 'tax_id' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'first_name' => 'first_name', + 'last_name' => 'last_name', + 'email_address' => 'email_address', + 'phone_number' => 'phone_number', + 'address' => 'address', + 'tax_id' => 'tax_id' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'first_name' => 'setFirstName', + 'last_name' => 'setLastName', + 'email_address' => 'setEmailAddress', + 'phone_number' => 'setPhoneNumber', + 'address' => 'setAddress', + 'tax_id' => 'setTaxId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'first_name' => 'getFirstName', + 'last_name' => 'getLastName', + 'email_address' => 'getEmailAddress', + 'phone_number' => 'getPhoneNumber', + 'address' => 'getAddress', + 'tax_id' => 'getTaxId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['first_name'] = $data['first_name'] ?? null; + $this->container['last_name'] = $data['last_name'] ?? null; + $this->container['email_address'] = $data['email_address'] ?? null; + $this->container['phone_number'] = $data['phone_number'] ?? null; + $this->container['address'] = $data['address'] ?? null; + $this->container['tax_id'] = $data['tax_id'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['first_name']) && (mb_strlen($this->container['first_name']) > 255)) { + $invalidProperties[] = "invalid value for 'first_name', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['first_name']) && (mb_strlen($this->container['first_name']) < 1)) { + $invalidProperties[] = "invalid value for 'first_name', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['last_name']) && (mb_strlen($this->container['last_name']) > 255)) { + $invalidProperties[] = "invalid value for 'last_name', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['last_name']) && (mb_strlen($this->container['last_name']) < 1)) { + $invalidProperties[] = "invalid value for 'last_name', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['email_address']) && (mb_strlen($this->container['email_address']) > 320)) { + $invalidProperties[] = "invalid value for 'email_address', the character length must be smaller than or equal to 320."; + } + + if (!is_null($this->container['email_address']) && (mb_strlen($this->container['email_address']) < 1)) { + $invalidProperties[] = "invalid value for 'email_address', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['phone_number']) && (mb_strlen($this->container['phone_number']) > 50)) { + $invalidProperties[] = "invalid value for 'phone_number', the character length must be smaller than or equal to 50."; + } + + if (!is_null($this->container['phone_number']) && (mb_strlen($this->container['phone_number']) < 1)) { + $invalidProperties[] = "invalid value for 'phone_number', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['phone_number']) && !preg_match("/^\\+[1-9]\\d{1,14}$/", $this->container['phone_number'])) { + $invalidProperties[] = "invalid value for 'phone_number', must be conform to the pattern /^\\+[1-9]\\d{1,14}$/."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets first_name + * + * @return string|null + */ + public function getFirstName() + { + return $this->container['first_name']; + } + + /** + * Sets first_name + * + * @param string|null $first_name The first name(s) or given name for the buyer. + * + * @return self + */ + public function setFirstName($first_name) + { + if (!is_null($first_name) && (mb_strlen($first_name) > 255)) { + throw new \InvalidArgumentException('invalid length for $first_name when calling BuyerRequestBillingDetails., must be smaller than or equal to 255.'); + } + if (!is_null($first_name) && (mb_strlen($first_name) < 1)) { + throw new \InvalidArgumentException('invalid length for $first_name when calling BuyerRequestBillingDetails., must be bigger than or equal to 1.'); + } + + $this->container['first_name'] = $first_name; + + return $this; + } + + /** + * Gets last_name + * + * @return string|null + */ + public function getLastName() + { + return $this->container['last_name']; + } + + /** + * Sets last_name + * + * @param string|null $last_name The last name, or family name, of the buyer. + * + * @return self + */ + public function setLastName($last_name) + { + if (!is_null($last_name) && (mb_strlen($last_name) > 255)) { + throw new \InvalidArgumentException('invalid length for $last_name when calling BuyerRequestBillingDetails., must be smaller than or equal to 255.'); + } + if (!is_null($last_name) && (mb_strlen($last_name) < 1)) { + throw new \InvalidArgumentException('invalid length for $last_name when calling BuyerRequestBillingDetails., must be bigger than or equal to 1.'); + } + + $this->container['last_name'] = $last_name; + + return $this; + } + + /** + * Gets email_address + * + * @return string|null + */ + public function getEmailAddress() + { + return $this->container['email_address']; + } + + /** + * Sets email_address + * + * @param string|null $email_address The email address for the buyer. + * + * @return self + */ + public function setEmailAddress($email_address) + { + if (!is_null($email_address) && (mb_strlen($email_address) > 320)) { + throw new \InvalidArgumentException('invalid length for $email_address when calling BuyerRequestBillingDetails., must be smaller than or equal to 320.'); + } + if (!is_null($email_address) && (mb_strlen($email_address) < 1)) { + throw new \InvalidArgumentException('invalid length for $email_address when calling BuyerRequestBillingDetails., must be bigger than or equal to 1.'); + } + + $this->container['email_address'] = $email_address; + + return $this; + } + + /** + * Gets phone_number + * + * @return string|null + */ + public function getPhoneNumber() + { + return $this->container['phone_number']; + } + + /** + * Sets phone_number + * + * @param string|null $phone_number The phone number for the buyer which should be formatted according to the [E164 number standard](https://www.twilio.com/docs/glossary/what-e164). + * + * @return self + */ + public function setPhoneNumber($phone_number) + { + if (!is_null($phone_number) && (mb_strlen($phone_number) > 50)) { + throw new \InvalidArgumentException('invalid length for $phone_number when calling BuyerRequestBillingDetails., must be smaller than or equal to 50.'); + } + if (!is_null($phone_number) && (mb_strlen($phone_number) < 1)) { + throw new \InvalidArgumentException('invalid length for $phone_number when calling BuyerRequestBillingDetails., must be bigger than or equal to 1.'); + } + if (!is_null($phone_number) && (!preg_match("/^\\+[1-9]\\d{1,14}$/", $phone_number))) { + throw new \InvalidArgumentException("invalid value for $phone_number when calling BuyerRequestBillingDetails., must conform to the pattern /^\\+[1-9]\\d{1,14}$/."); + } + + $this->container['phone_number'] = $phone_number; + + return $this; + } + + /** + * Gets address + * + * @return \Gr4vy\model\BillingDetailsRequestAddress|null + */ + public function getAddress() + { + return $this->container['address']; + } + + /** + * Sets address + * + * @param \Gr4vy\model\BillingDetailsRequestAddress|null $address address + * + * @return self + */ + public function setAddress($address) + { + $this->container['address'] = $address; + + return $this; + } + + /** + * Gets tax_id + * + * @return \Gr4vy\model\BillingDetailsTaxId|null + */ + public function getTaxId() + { + return $this->container['tax_id']; + } + + /** + * Sets tax_id + * + * @param \Gr4vy\model\BillingDetailsTaxId|null $tax_id tax_id + * + * @return self + */ + public function setTaxId($tax_id) + { + $this->container['tax_id'] = $tax_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/BuyerSnapshot.php b/lib/model/BuyerSnapshot.php new file mode 100644 index 0000000..85608bc --- /dev/null +++ b/lib/model/BuyerSnapshot.php @@ -0,0 +1,506 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class BuyerSnapshot implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'Buyer--Snapshot'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'id' => 'string', + 'external_identifier' => 'string', + 'display_name' => 'string', + 'billing_details' => '\Gr4vy\model\BuyerSnapshotBillingDetails' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'id' => 'uuid', + 'external_identifier' => null, + 'display_name' => null, + 'billing_details' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'id' => 'id', + 'external_identifier' => 'external_identifier', + 'display_name' => 'display_name', + 'billing_details' => 'billing_details' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'id' => 'setId', + 'external_identifier' => 'setExternalIdentifier', + 'display_name' => 'setDisplayName', + 'billing_details' => 'setBillingDetails' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'id' => 'getId', + 'external_identifier' => 'getExternalIdentifier', + 'display_name' => 'getDisplayName', + 'billing_details' => 'getBillingDetails' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_BUYER = 'buyer'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_BUYER, + ]; + } + + /** + * 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['type'] = $data['type'] ?? null; + $this->container['id'] = $data['id'] ?? null; + $this->container['external_identifier'] = $data['external_identifier'] ?? null; + $this->container['display_name'] = $data['display_name'] ?? null; + $this->container['billing_details'] = $data['billing_details'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + if (!is_null($this->container['external_identifier']) && (mb_strlen($this->container['external_identifier']) > 200)) { + $invalidProperties[] = "invalid value for 'external_identifier', the character length must be smaller than or equal to 200."; + } + + if (!is_null($this->container['external_identifier']) && (mb_strlen($this->container['external_identifier']) < 1)) { + $invalidProperties[] = "invalid value for 'external_identifier', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['display_name']) && (mb_strlen($this->container['display_name']) > 200)) { + $invalidProperties[] = "invalid value for 'display_name', the character length must be smaller than or equal to 200."; + } + + if (!is_null($this->container['display_name']) && (mb_strlen($this->container['display_name']) < 1)) { + $invalidProperties[] = "invalid value for 'display_name', the character length must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type The type of this resource. Is always `buyer`. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id The unique Gr4vy ID for this buyer. + * + * @return self + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets external_identifier + * + * @return string|null + */ + public function getExternalIdentifier() + { + return $this->container['external_identifier']; + } + + /** + * Sets external_identifier + * + * @param string|null $external_identifier An external identifier that can be used to match the buyer against your own records. + * + * @return self + */ + public function setExternalIdentifier($external_identifier) + { + if (!is_null($external_identifier) && (mb_strlen($external_identifier) > 200)) { + throw new \InvalidArgumentException('invalid length for $external_identifier when calling BuyerSnapshot., must be smaller than or equal to 200.'); + } + if (!is_null($external_identifier) && (mb_strlen($external_identifier) < 1)) { + throw new \InvalidArgumentException('invalid length for $external_identifier when calling BuyerSnapshot., must be bigger than or equal to 1.'); + } + + $this->container['external_identifier'] = $external_identifier; + + return $this; + } + + /** + * Gets display_name + * + * @return string|null + */ + public function getDisplayName() + { + return $this->container['display_name']; + } + + /** + * Sets display_name + * + * @param string|null $display_name A unique name for this buyer which is used in the Gr4vy admin panel to give a buyer a human readable name. + * + * @return self + */ + public function setDisplayName($display_name) + { + if (!is_null($display_name) && (mb_strlen($display_name) > 200)) { + throw new \InvalidArgumentException('invalid length for $display_name when calling BuyerSnapshot., must be smaller than or equal to 200.'); + } + if (!is_null($display_name) && (mb_strlen($display_name) < 1)) { + throw new \InvalidArgumentException('invalid length for $display_name when calling BuyerSnapshot., must be bigger than or equal to 1.'); + } + + $this->container['display_name'] = $display_name; + + return $this; + } + + /** + * Gets billing_details + * + * @return \Gr4vy\model\BuyerSnapshotBillingDetails|null + */ + public function getBillingDetails() + { + return $this->container['billing_details']; + } + + /** + * Sets billing_details + * + * @param \Gr4vy\model\BuyerSnapshotBillingDetails|null $billing_details billing_details + * + * @return self + */ + public function setBillingDetails($billing_details) + { + $this->container['billing_details'] = $billing_details; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/BuyerSnapshotBillingDetails.php b/lib/model/BuyerSnapshotBillingDetails.php new file mode 100644 index 0000000..febac32 --- /dev/null +++ b/lib/model/BuyerSnapshotBillingDetails.php @@ -0,0 +1,602 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class BuyerSnapshotBillingDetails implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'Buyer__Snapshot_billing_details'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'first_name' => 'string', + 'last_name' => 'string', + 'email_address' => 'string', + 'phone_number' => 'string', + 'address' => '\Gr4vy\model\BillingDetailsAddress', + 'tax_id' => '\Gr4vy\model\BillingDetailsTaxId' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'first_name' => null, + 'last_name' => null, + 'email_address' => null, + 'phone_number' => null, + 'address' => null, + 'tax_id' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'first_name' => 'first_name', + 'last_name' => 'last_name', + 'email_address' => 'email_address', + 'phone_number' => 'phone_number', + 'address' => 'address', + 'tax_id' => 'tax_id' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'first_name' => 'setFirstName', + 'last_name' => 'setLastName', + 'email_address' => 'setEmailAddress', + 'phone_number' => 'setPhoneNumber', + 'address' => 'setAddress', + 'tax_id' => 'setTaxId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'first_name' => 'getFirstName', + 'last_name' => 'getLastName', + 'email_address' => 'getEmailAddress', + 'phone_number' => 'getPhoneNumber', + 'address' => 'getAddress', + 'tax_id' => 'getTaxId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_BILLING_DETAILS = 'billing-details'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_BILLING_DETAILS, + ]; + } + + /** + * 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['type'] = $data['type'] ?? null; + $this->container['first_name'] = $data['first_name'] ?? null; + $this->container['last_name'] = $data['last_name'] ?? null; + $this->container['email_address'] = $data['email_address'] ?? null; + $this->container['phone_number'] = $data['phone_number'] ?? null; + $this->container['address'] = $data['address'] ?? null; + $this->container['tax_id'] = $data['tax_id'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + if (!is_null($this->container['first_name']) && (mb_strlen($this->container['first_name']) > 255)) { + $invalidProperties[] = "invalid value for 'first_name', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['first_name']) && (mb_strlen($this->container['first_name']) < 1)) { + $invalidProperties[] = "invalid value for 'first_name', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['last_name']) && (mb_strlen($this->container['last_name']) > 255)) { + $invalidProperties[] = "invalid value for 'last_name', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['last_name']) && (mb_strlen($this->container['last_name']) < 1)) { + $invalidProperties[] = "invalid value for 'last_name', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['email_address']) && (mb_strlen($this->container['email_address']) > 320)) { + $invalidProperties[] = "invalid value for 'email_address', the character length must be smaller than or equal to 320."; + } + + if (!is_null($this->container['email_address']) && (mb_strlen($this->container['email_address']) < 1)) { + $invalidProperties[] = "invalid value for 'email_address', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['phone_number']) && (mb_strlen($this->container['phone_number']) > 50)) { + $invalidProperties[] = "invalid value for 'phone_number', the character length must be smaller than or equal to 50."; + } + + if (!is_null($this->container['phone_number']) && (mb_strlen($this->container['phone_number']) < 1)) { + $invalidProperties[] = "invalid value for 'phone_number', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['phone_number']) && !preg_match("/^\\+[1-9]\\d{1,14}$/", $this->container['phone_number'])) { + $invalidProperties[] = "invalid value for 'phone_number', must be conform to the pattern /^\\+[1-9]\\d{1,14}$/."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type The type of this resource. Is always `billing-details`. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets first_name + * + * @return string|null + */ + public function getFirstName() + { + return $this->container['first_name']; + } + + /** + * Sets first_name + * + * @param string|null $first_name The first name(s) or given name of the buyer. + * + * @return self + */ + public function setFirstName($first_name) + { + if (!is_null($first_name) && (mb_strlen($first_name) > 255)) { + throw new \InvalidArgumentException('invalid length for $first_name when calling BuyerSnapshotBillingDetails., must be smaller than or equal to 255.'); + } + if (!is_null($first_name) && (mb_strlen($first_name) < 1)) { + throw new \InvalidArgumentException('invalid length for $first_name when calling BuyerSnapshotBillingDetails., must be bigger than or equal to 1.'); + } + + $this->container['first_name'] = $first_name; + + return $this; + } + + /** + * Gets last_name + * + * @return string|null + */ + public function getLastName() + { + return $this->container['last_name']; + } + + /** + * Sets last_name + * + * @param string|null $last_name The last name, or family name, of the buyer. + * + * @return self + */ + public function setLastName($last_name) + { + if (!is_null($last_name) && (mb_strlen($last_name) > 255)) { + throw new \InvalidArgumentException('invalid length for $last_name when calling BuyerSnapshotBillingDetails., must be smaller than or equal to 255.'); + } + if (!is_null($last_name) && (mb_strlen($last_name) < 1)) { + throw new \InvalidArgumentException('invalid length for $last_name when calling BuyerSnapshotBillingDetails., must be bigger than or equal to 1.'); + } + + $this->container['last_name'] = $last_name; + + return $this; + } + + /** + * Gets email_address + * + * @return string|null + */ + public function getEmailAddress() + { + return $this->container['email_address']; + } + + /** + * Sets email_address + * + * @param string|null $email_address The email address of the buyer. + * + * @return self + */ + public function setEmailAddress($email_address) + { + if (!is_null($email_address) && (mb_strlen($email_address) > 320)) { + throw new \InvalidArgumentException('invalid length for $email_address when calling BuyerSnapshotBillingDetails., must be smaller than or equal to 320.'); + } + if (!is_null($email_address) && (mb_strlen($email_address) < 1)) { + throw new \InvalidArgumentException('invalid length for $email_address when calling BuyerSnapshotBillingDetails., must be bigger than or equal to 1.'); + } + + $this->container['email_address'] = $email_address; + + return $this; + } + + /** + * Gets phone_number + * + * @return string|null + */ + public function getPhoneNumber() + { + return $this->container['phone_number']; + } + + /** + * Sets phone_number + * + * @param string|null $phone_number The phone number of the buyer. This number is formatted according to the [E164 number standard](https://www.twilio.com/docs/glossary/what-e164). + * + * @return self + */ + public function setPhoneNumber($phone_number) + { + if (!is_null($phone_number) && (mb_strlen($phone_number) > 50)) { + throw new \InvalidArgumentException('invalid length for $phone_number when calling BuyerSnapshotBillingDetails., must be smaller than or equal to 50.'); + } + if (!is_null($phone_number) && (mb_strlen($phone_number) < 1)) { + throw new \InvalidArgumentException('invalid length for $phone_number when calling BuyerSnapshotBillingDetails., must be bigger than or equal to 1.'); + } + if (!is_null($phone_number) && (!preg_match("/^\\+[1-9]\\d{1,14}$/", $phone_number))) { + throw new \InvalidArgumentException("invalid value for $phone_number when calling BuyerSnapshotBillingDetails., must conform to the pattern /^\\+[1-9]\\d{1,14}$/."); + } + + $this->container['phone_number'] = $phone_number; + + return $this; + } + + /** + * Gets address + * + * @return \Gr4vy\model\BillingDetailsAddress|null + */ + public function getAddress() + { + return $this->container['address']; + } + + /** + * Sets address + * + * @param \Gr4vy\model\BillingDetailsAddress|null $address address + * + * @return self + */ + public function setAddress($address) + { + $this->container['address'] = $address; + + return $this; + } + + /** + * Gets tax_id + * + * @return \Gr4vy\model\BillingDetailsTaxId|null + */ + public function getTaxId() + { + return $this->container['tax_id']; + } + + /** + * Sets tax_id + * + * @param \Gr4vy\model\BillingDetailsTaxId|null $tax_id tax_id + * + * @return self + */ + public function setTaxId($tax_id) + { + $this->container['tax_id'] = $tax_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/BuyerUpdate.php b/lib/model/BuyerUpdate.php new file mode 100644 index 0000000..5d9e0f5 --- /dev/null +++ b/lib/model/BuyerUpdate.php @@ -0,0 +1,414 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class BuyerUpdate implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'BuyerUpdate'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'external_identifier' => 'string', + 'display_name' => 'string', + 'billing_details' => '\Gr4vy\model\BuyerUpdateBillingDetails' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'external_identifier' => null, + 'display_name' => null, + 'billing_details' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'external_identifier' => 'external_identifier', + 'display_name' => 'display_name', + 'billing_details' => 'billing_details' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'external_identifier' => 'setExternalIdentifier', + 'display_name' => 'setDisplayName', + 'billing_details' => 'setBillingDetails' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'external_identifier' => 'getExternalIdentifier', + 'display_name' => 'getDisplayName', + 'billing_details' => 'getBillingDetails' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['external_identifier'] = $data['external_identifier'] ?? null; + $this->container['display_name'] = $data['display_name'] ?? null; + $this->container['billing_details'] = $data['billing_details'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['external_identifier']) && (mb_strlen($this->container['external_identifier']) > 200)) { + $invalidProperties[] = "invalid value for 'external_identifier', the character length must be smaller than or equal to 200."; + } + + if (!is_null($this->container['external_identifier']) && (mb_strlen($this->container['external_identifier']) < 1)) { + $invalidProperties[] = "invalid value for 'external_identifier', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['display_name']) && (mb_strlen($this->container['display_name']) > 200)) { + $invalidProperties[] = "invalid value for 'display_name', the character length must be smaller than or equal to 200."; + } + + if (!is_null($this->container['display_name']) && (mb_strlen($this->container['display_name']) < 1)) { + $invalidProperties[] = "invalid value for 'display_name', the character length must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets external_identifier + * + * @return string|null + */ + public function getExternalIdentifier() + { + return $this->container['external_identifier']; + } + + /** + * Sets external_identifier + * + * @param string|null $external_identifier An external identifier that can be used to match the buyer against your own records. This value needs to be unique for all buyers. + * + * @return self + */ + public function setExternalIdentifier($external_identifier) + { + if (!is_null($external_identifier) && (mb_strlen($external_identifier) > 200)) { + throw new \InvalidArgumentException('invalid length for $external_identifier when calling BuyerUpdate., must be smaller than or equal to 200.'); + } + if (!is_null($external_identifier) && (mb_strlen($external_identifier) < 1)) { + throw new \InvalidArgumentException('invalid length for $external_identifier when calling BuyerUpdate., must be bigger than or equal to 1.'); + } + + $this->container['external_identifier'] = $external_identifier; + + return $this; + } + + /** + * Gets display_name + * + * @return string|null + */ + public function getDisplayName() + { + return $this->container['display_name']; + } + + /** + * Sets display_name + * + * @param string|null $display_name A unique name for this buyer which is used in the Gr4vy admin panel to give a buyer a human readable name. + * + * @return self + */ + public function setDisplayName($display_name) + { + if (!is_null($display_name) && (mb_strlen($display_name) > 200)) { + throw new \InvalidArgumentException('invalid length for $display_name when calling BuyerUpdate., must be smaller than or equal to 200.'); + } + if (!is_null($display_name) && (mb_strlen($display_name) < 1)) { + throw new \InvalidArgumentException('invalid length for $display_name when calling BuyerUpdate., must be bigger than or equal to 1.'); + } + + $this->container['display_name'] = $display_name; + + return $this; + } + + /** + * Gets billing_details + * + * @return \Gr4vy\model\BuyerUpdateBillingDetails|null + */ + public function getBillingDetails() + { + return $this->container['billing_details']; + } + + /** + * Sets billing_details + * + * @param \Gr4vy\model\BuyerUpdateBillingDetails|null $billing_details billing_details + * + * @return self + */ + public function setBillingDetails($billing_details) + { + $this->container['billing_details'] = $billing_details; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/BuyerUpdateBillingDetails.php b/lib/model/BuyerUpdateBillingDetails.php new file mode 100644 index 0000000..cc0b4f3 --- /dev/null +++ b/lib/model/BuyerUpdateBillingDetails.php @@ -0,0 +1,540 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class BuyerUpdateBillingDetails implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'BuyerUpdate_billing_details'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'first_name' => 'string', + 'last_name' => 'string', + 'email_address' => 'string', + 'phone_number' => 'string', + 'address' => '\Gr4vy\model\BillingDetailsUpdateRequestAddress', + 'tax_id' => '\Gr4vy\model\BillingDetailsTaxId' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'first_name' => null, + 'last_name' => null, + 'email_address' => null, + 'phone_number' => null, + 'address' => null, + 'tax_id' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'first_name' => 'first_name', + 'last_name' => 'last_name', + 'email_address' => 'email_address', + 'phone_number' => 'phone_number', + 'address' => 'address', + 'tax_id' => 'tax_id' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'first_name' => 'setFirstName', + 'last_name' => 'setLastName', + 'email_address' => 'setEmailAddress', + 'phone_number' => 'setPhoneNumber', + 'address' => 'setAddress', + 'tax_id' => 'setTaxId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'first_name' => 'getFirstName', + 'last_name' => 'getLastName', + 'email_address' => 'getEmailAddress', + 'phone_number' => 'getPhoneNumber', + 'address' => 'getAddress', + 'tax_id' => 'getTaxId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['first_name'] = $data['first_name'] ?? null; + $this->container['last_name'] = $data['last_name'] ?? null; + $this->container['email_address'] = $data['email_address'] ?? null; + $this->container['phone_number'] = $data['phone_number'] ?? null; + $this->container['address'] = $data['address'] ?? null; + $this->container['tax_id'] = $data['tax_id'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['first_name']) && (mb_strlen($this->container['first_name']) > 255)) { + $invalidProperties[] = "invalid value for 'first_name', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['first_name']) && (mb_strlen($this->container['first_name']) < 1)) { + $invalidProperties[] = "invalid value for 'first_name', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['last_name']) && (mb_strlen($this->container['last_name']) > 255)) { + $invalidProperties[] = "invalid value for 'last_name', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['last_name']) && (mb_strlen($this->container['last_name']) < 1)) { + $invalidProperties[] = "invalid value for 'last_name', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['email_address']) && (mb_strlen($this->container['email_address']) > 320)) { + $invalidProperties[] = "invalid value for 'email_address', the character length must be smaller than or equal to 320."; + } + + if (!is_null($this->container['email_address']) && (mb_strlen($this->container['email_address']) < 1)) { + $invalidProperties[] = "invalid value for 'email_address', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['phone_number']) && (mb_strlen($this->container['phone_number']) > 50)) { + $invalidProperties[] = "invalid value for 'phone_number', the character length must be smaller than or equal to 50."; + } + + if (!is_null($this->container['phone_number']) && (mb_strlen($this->container['phone_number']) < 1)) { + $invalidProperties[] = "invalid value for 'phone_number', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['phone_number']) && !preg_match("/^\\+[1-9]\\d{1,14}$/", $this->container['phone_number'])) { + $invalidProperties[] = "invalid value for 'phone_number', must be conform to the pattern /^\\+[1-9]\\d{1,14}$/."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets first_name + * + * @return string|null + */ + public function getFirstName() + { + return $this->container['first_name']; + } + + /** + * Sets first_name + * + * @param string|null $first_name The first name(s) or given name for the buyer. + * + * @return self + */ + public function setFirstName($first_name) + { + if (!is_null($first_name) && (mb_strlen($first_name) > 255)) { + throw new \InvalidArgumentException('invalid length for $first_name when calling BuyerUpdateBillingDetails., must be smaller than or equal to 255.'); + } + if (!is_null($first_name) && (mb_strlen($first_name) < 1)) { + throw new \InvalidArgumentException('invalid length for $first_name when calling BuyerUpdateBillingDetails., must be bigger than or equal to 1.'); + } + + $this->container['first_name'] = $first_name; + + return $this; + } + + /** + * Gets last_name + * + * @return string|null + */ + public function getLastName() + { + return $this->container['last_name']; + } + + /** + * Sets last_name + * + * @param string|null $last_name The last name, or family name, of the buyer. + * + * @return self + */ + public function setLastName($last_name) + { + if (!is_null($last_name) && (mb_strlen($last_name) > 255)) { + throw new \InvalidArgumentException('invalid length for $last_name when calling BuyerUpdateBillingDetails., must be smaller than or equal to 255.'); + } + if (!is_null($last_name) && (mb_strlen($last_name) < 1)) { + throw new \InvalidArgumentException('invalid length for $last_name when calling BuyerUpdateBillingDetails., must be bigger than or equal to 1.'); + } + + $this->container['last_name'] = $last_name; + + return $this; + } + + /** + * Gets email_address + * + * @return string|null + */ + public function getEmailAddress() + { + return $this->container['email_address']; + } + + /** + * Sets email_address + * + * @param string|null $email_address The email address for the buyer. + * + * @return self + */ + public function setEmailAddress($email_address) + { + if (!is_null($email_address) && (mb_strlen($email_address) > 320)) { + throw new \InvalidArgumentException('invalid length for $email_address when calling BuyerUpdateBillingDetails., must be smaller than or equal to 320.'); + } + if (!is_null($email_address) && (mb_strlen($email_address) < 1)) { + throw new \InvalidArgumentException('invalid length for $email_address when calling BuyerUpdateBillingDetails., must be bigger than or equal to 1.'); + } + + $this->container['email_address'] = $email_address; + + return $this; + } + + /** + * Gets phone_number + * + * @return string|null + */ + public function getPhoneNumber() + { + return $this->container['phone_number']; + } + + /** + * Sets phone_number + * + * @param string|null $phone_number The phone number for the buyer which should be formatted according to the [E164 number standard](https://www.twilio.com/docs/glossary/what-e164). + * + * @return self + */ + public function setPhoneNumber($phone_number) + { + if (!is_null($phone_number) && (mb_strlen($phone_number) > 50)) { + throw new \InvalidArgumentException('invalid length for $phone_number when calling BuyerUpdateBillingDetails., must be smaller than or equal to 50.'); + } + if (!is_null($phone_number) && (mb_strlen($phone_number) < 1)) { + throw new \InvalidArgumentException('invalid length for $phone_number when calling BuyerUpdateBillingDetails., must be bigger than or equal to 1.'); + } + if (!is_null($phone_number) && (!preg_match("/^\\+[1-9]\\d{1,14}$/", $phone_number))) { + throw new \InvalidArgumentException("invalid value for $phone_number when calling BuyerUpdateBillingDetails., must conform to the pattern /^\\+[1-9]\\d{1,14}$/."); + } + + $this->container['phone_number'] = $phone_number; + + return $this; + } + + /** + * Gets address + * + * @return \Gr4vy\model\BillingDetailsUpdateRequestAddress|null + */ + public function getAddress() + { + return $this->container['address']; + } + + /** + * Sets address + * + * @param \Gr4vy\model\BillingDetailsUpdateRequestAddress|null $address address + * + * @return self + */ + public function setAddress($address) + { + $this->container['address'] = $address; + + return $this; + } + + /** + * Gets tax_id + * + * @return \Gr4vy\model\BillingDetailsTaxId|null + */ + public function getTaxId() + { + return $this->container['tax_id']; + } + + /** + * Sets tax_id + * + * @param \Gr4vy\model\BillingDetailsTaxId|null $tax_id tax_id + * + * @return self + */ + public function setTaxId($tax_id) + { + $this->container['tax_id'] = $tax_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/Buyers.php b/lib/model/Buyers.php new file mode 100644 index 0000000..b87e652 --- /dev/null +++ b/lib/model/Buyers.php @@ -0,0 +1,460 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class Buyers implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'Buyers'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'items' => '\Gr4vy\model\Buyer[]', + 'limit' => 'int', + 'next_cursor' => 'string', + 'previous_cursor' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'items' => null, + 'limit' => 'int32', + 'next_cursor' => null, + 'previous_cursor' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'items' => 'items', + 'limit' => 'limit', + 'next_cursor' => 'next_cursor', + 'previous_cursor' => 'previous_cursor' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'items' => 'setItems', + 'limit' => 'setLimit', + 'next_cursor' => 'setNextCursor', + 'previous_cursor' => 'setPreviousCursor' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'items' => 'getItems', + 'limit' => 'getLimit', + 'next_cursor' => 'getNextCursor', + 'previous_cursor' => 'getPreviousCursor' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['items'] = $data['items'] ?? null; + $this->container['limit'] = $data['limit'] ?? 20; + $this->container['next_cursor'] = $data['next_cursor'] ?? null; + $this->container['previous_cursor'] = $data['previous_cursor'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['limit']) && ($this->container['limit'] > 100)) { + $invalidProperties[] = "invalid value for 'limit', must be smaller than or equal to 100."; + } + + if (!is_null($this->container['limit']) && ($this->container['limit'] < 1)) { + $invalidProperties[] = "invalid value for 'limit', must be bigger than or equal to 1."; + } + + if (!is_null($this->container['next_cursor']) && (mb_strlen($this->container['next_cursor']) > 1000)) { + $invalidProperties[] = "invalid value for 'next_cursor', the character length must be smaller than or equal to 1000."; + } + + if (!is_null($this->container['next_cursor']) && (mb_strlen($this->container['next_cursor']) < 1)) { + $invalidProperties[] = "invalid value for 'next_cursor', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['previous_cursor']) && (mb_strlen($this->container['previous_cursor']) > 1000)) { + $invalidProperties[] = "invalid value for 'previous_cursor', the character length must be smaller than or equal to 1000."; + } + + if (!is_null($this->container['previous_cursor']) && (mb_strlen($this->container['previous_cursor']) < 1)) { + $invalidProperties[] = "invalid value for 'previous_cursor', the character length must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets items + * + * @return \Gr4vy\model\Buyer[]|null + */ + public function getItems() + { + return $this->container['items']; + } + + /** + * Sets items + * + * @param \Gr4vy\model\Buyer[]|null $items A list of buyers. + * + * @return self + */ + public function setItems($items) + { + $this->container['items'] = $items; + + return $this; + } + + /** + * Gets limit + * + * @return int|null + */ + public function getLimit() + { + return $this->container['limit']; + } + + /** + * Sets limit + * + * @param int|null $limit The limit applied to request. This represents the number of items that are at maximum returned by this request. + * + * @return self + */ + public function setLimit($limit) + { + + if (!is_null($limit) && ($limit > 100)) { + throw new \InvalidArgumentException('invalid value for $limit when calling Buyers., must be smaller than or equal to 100.'); + } + if (!is_null($limit) && ($limit < 1)) { + throw new \InvalidArgumentException('invalid value for $limit when calling Buyers., must be bigger than or equal to 1.'); + } + + $this->container['limit'] = $limit; + + return $this; + } + + /** + * Gets next_cursor + * + * @return string|null + */ + public function getNextCursor() + { + return $this->container['next_cursor']; + } + + /** + * Sets next_cursor + * + * @param string|null $next_cursor The cursor that represents the next page of results. Use the `cursor` query parameter to fetch this page of items. + * + * @return self + */ + public function setNextCursor($next_cursor) + { + if (!is_null($next_cursor) && (mb_strlen($next_cursor) > 1000)) { + throw new \InvalidArgumentException('invalid length for $next_cursor when calling Buyers., must be smaller than or equal to 1000.'); + } + if (!is_null($next_cursor) && (mb_strlen($next_cursor) < 1)) { + throw new \InvalidArgumentException('invalid length for $next_cursor when calling Buyers., must be bigger than or equal to 1.'); + } + + $this->container['next_cursor'] = $next_cursor; + + return $this; + } + + /** + * Gets previous_cursor + * + * @return string|null + */ + public function getPreviousCursor() + { + return $this->container['previous_cursor']; + } + + /** + * Sets previous_cursor + * + * @param string|null $previous_cursor The cursor that represents the next page of results. Use the `cursor` query parameter to fetch this page of items. + * + * @return self + */ + public function setPreviousCursor($previous_cursor) + { + if (!is_null($previous_cursor) && (mb_strlen($previous_cursor) > 1000)) { + throw new \InvalidArgumentException('invalid length for $previous_cursor when calling Buyers., must be smaller than or equal to 1000.'); + } + if (!is_null($previous_cursor) && (mb_strlen($previous_cursor) < 1)) { + throw new \InvalidArgumentException('invalid length for $previous_cursor when calling Buyers., must be bigger than or equal to 1.'); + } + + $this->container['previous_cursor'] = $previous_cursor; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/CardDetails.php b/lib/model/CardDetails.php new file mode 100644 index 0000000..6809869 --- /dev/null +++ b/lib/model/CardDetails.php @@ -0,0 +1,555 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class CardDetails implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CardDetails'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'id' => 'string', + 'card_type' => 'string', + 'scheme' => 'string', + 'country' => 'string', + 'required_fields' => '\Gr4vy\model\RequiredFields' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'id' => 'bin', + 'card_type' => null, + 'scheme' => null, + 'country' => null, + 'required_fields' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'id' => 'id', + 'card_type' => 'card_type', + 'scheme' => 'scheme', + 'country' => 'country', + 'required_fields' => 'required_fields' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'id' => 'setId', + 'card_type' => 'setCardType', + 'scheme' => 'setScheme', + 'country' => 'setCountry', + 'required_fields' => 'setRequiredFields' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'id' => 'getId', + 'card_type' => 'getCardType', + 'scheme' => 'getScheme', + 'country' => 'getCountry', + 'required_fields' => 'getRequiredFields' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_CARD_DETAIL = 'card-detail'; + public const CARD_TYPE_CREDIT = 'credit'; + public const CARD_TYPE_DEBIT = 'debit'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_CARD_DETAIL, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getCardTypeAllowableValues() + { + return [ + self::CARD_TYPE_CREDIT, + self::CARD_TYPE_DEBIT, + ]; + } + + /** + * 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['type'] = $data['type'] ?? null; + $this->container['id'] = $data['id'] ?? null; + $this->container['card_type'] = $data['card_type'] ?? null; + $this->container['scheme'] = $data['scheme'] ?? null; + $this->container['country'] = $data['country'] ?? null; + $this->container['required_fields'] = $data['required_fields'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + if (!is_null($this->container['id']) && (mb_strlen($this->container['id']) > 8)) { + $invalidProperties[] = "invalid value for 'id', the character length must be smaller than or equal to 8."; + } + + if (!is_null($this->container['id']) && (mb_strlen($this->container['id']) < 8)) { + $invalidProperties[] = "invalid value for 'id', the character length must be bigger than or equal to 8."; + } + + $allowedValues = $this->getCardTypeAllowableValues(); + if (!is_null($this->container['card_type']) && !in_array($this->container['card_type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'card_type', must be one of '%s'", + $this->container['card_type'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type `card-detail`. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id The 8 digit BIN of the card. When looking up card details using a `payment_method_id` this value will be `null`. + * + * @return self + */ + public function setId($id) + { + if (!is_null($id) && (mb_strlen($id) > 8)) { + throw new \InvalidArgumentException('invalid length for $id when calling CardDetails., must be smaller than or equal to 8.'); + } + if (!is_null($id) && (mb_strlen($id) < 8)) { + throw new \InvalidArgumentException('invalid length for $id when calling CardDetails., must be bigger than or equal to 8.'); + } + + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets card_type + * + * @return string|null + */ + public function getCardType() + { + return $this->container['card_type']; + } + + /** + * Sets card_type + * + * @param string|null $card_type The type of card. + * + * @return self + */ + public function setCardType($card_type) + { + $allowedValues = $this->getCardTypeAllowableValues(); + if (!is_null($card_type) && !in_array($card_type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'card_type', must be one of '%s'", + $card_type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['card_type'] = $card_type; + + return $this; + } + + /** + * Gets scheme + * + * @return string|null + */ + public function getScheme() + { + return $this->container['scheme']; + } + + /** + * Sets scheme + * + * @param string|null $scheme The scheme/brand of the card. + * + * @return self + */ + public function setScheme($scheme) + { + $this->container['scheme'] = $scheme; + + return $this; + } + + /** + * Gets country + * + * @return string|null + */ + public function getCountry() + { + return $this->container['country']; + } + + /** + * Sets country + * + * @param string|null $country The 2-letter ISO code of the issuing country of the card. + * + * @return self + */ + public function setCountry($country) + { + $this->container['country'] = $country; + + return $this; + } + + /** + * Gets required_fields + * + * @return \Gr4vy\model\RequiredFields|null + */ + public function getRequiredFields() + { + return $this->container['required_fields']; + } + + /** + * Sets required_fields + * + * @param \Gr4vy\model\RequiredFields|null $required_fields required_fields + * + * @return self + */ + public function setRequiredFields($required_fields) + { + $this->container['required_fields'] = $required_fields; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/CardRequest.php b/lib/model/CardRequest.php new file mode 100644 index 0000000..76d8cc5 --- /dev/null +++ b/lib/model/CardRequest.php @@ -0,0 +1,614 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class CardRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CardRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'method' => 'string', + 'number' => 'string', + 'expiration_date' => 'string', + 'security_code' => 'string', + 'external_identifier' => 'string', + 'buyer_id' => 'string', + 'buyer_external_identifier' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'method' => null, + 'number' => null, + 'expiration_date' => null, + 'security_code' => null, + 'external_identifier' => null, + 'buyer_id' => 'uuid', + 'buyer_external_identifier' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'method' => 'method', + 'number' => 'number', + 'expiration_date' => 'expiration_date', + 'security_code' => 'security_code', + 'external_identifier' => 'external_identifier', + 'buyer_id' => 'buyer_id', + 'buyer_external_identifier' => 'buyer_external_identifier' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'method' => 'setMethod', + 'number' => 'setNumber', + 'expiration_date' => 'setExpirationDate', + 'security_code' => 'setSecurityCode', + 'external_identifier' => 'setExternalIdentifier', + 'buyer_id' => 'setBuyerId', + 'buyer_external_identifier' => 'setBuyerExternalIdentifier' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'method' => 'getMethod', + 'number' => 'getNumber', + 'expiration_date' => 'getExpirationDate', + 'security_code' => 'getSecurityCode', + 'external_identifier' => 'getExternalIdentifier', + 'buyer_id' => 'getBuyerId', + 'buyer_external_identifier' => 'getBuyerExternalIdentifier' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const METHOD_CARD = 'card'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getMethodAllowableValues() + { + return [ + self::METHOD_CARD, + ]; + } + + /** + * 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['method'] = $data['method'] ?? null; + $this->container['number'] = $data['number'] ?? null; + $this->container['expiration_date'] = $data['expiration_date'] ?? null; + $this->container['security_code'] = $data['security_code'] ?? null; + $this->container['external_identifier'] = $data['external_identifier'] ?? null; + $this->container['buyer_id'] = $data['buyer_id'] ?? null; + $this->container['buyer_external_identifier'] = $data['buyer_external_identifier'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['method'] === null) { + $invalidProperties[] = "'method' can't be null"; + } + $allowedValues = $this->getMethodAllowableValues(); + if (!is_null($this->container['method']) && !in_array($this->container['method'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'method', must be one of '%s'", + $this->container['method'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['number'] === null) { + $invalidProperties[] = "'number' can't be null"; + } + if ((mb_strlen($this->container['number']) > 19)) { + $invalidProperties[] = "invalid value for 'number', the character length must be smaller than or equal to 19."; + } + + if ((mb_strlen($this->container['number']) < 13)) { + $invalidProperties[] = "invalid value for 'number', the character length must be bigger than or equal to 13."; + } + + if (!preg_match("/^[0-9]{13,19}$/", $this->container['number'])) { + $invalidProperties[] = "invalid value for 'number', must be conform to the pattern /^[0-9]{13,19}$/."; + } + + if ($this->container['expiration_date'] === null) { + $invalidProperties[] = "'expiration_date' can't be null"; + } + if ((mb_strlen($this->container['expiration_date']) > 5)) { + $invalidProperties[] = "invalid value for 'expiration_date', the character length must be smaller than or equal to 5."; + } + + if ((mb_strlen($this->container['expiration_date']) < 5)) { + $invalidProperties[] = "invalid value for 'expiration_date', the character length must be bigger than or equal to 5."; + } + + if (!preg_match("/^\\d{2}\/\\d{2}$/", $this->container['expiration_date'])) { + $invalidProperties[] = "invalid value for 'expiration_date', must be conform to the pattern /^\\d{2}\/\\d{2}$/."; + } + + if ($this->container['security_code'] === null) { + $invalidProperties[] = "'security_code' can't be null"; + } + if ((mb_strlen($this->container['security_code']) > 4)) { + $invalidProperties[] = "invalid value for 'security_code', the character length must be smaller than or equal to 4."; + } + + if ((mb_strlen($this->container['security_code']) < 3)) { + $invalidProperties[] = "invalid value for 'security_code', the character length must be bigger than or equal to 3."; + } + + if (!preg_match("/^\\d{3,4}$/", $this->container['security_code'])) { + $invalidProperties[] = "invalid value for 'security_code', must be conform to the pattern /^\\d{3,4}$/."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets method + * + * @return string + */ + public function getMethod() + { + return $this->container['method']; + } + + /** + * Sets method + * + * @param string $method `card`. + * + * @return self + */ + public function setMethod($method) + { + $allowedValues = $this->getMethodAllowableValues(); + if (!in_array($method, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'method', must be one of '%s'", + $method, + implode("', '", $allowedValues) + ) + ); + } + $this->container['method'] = $method; + + return $this; + } + + /** + * Gets number + * + * @return string + */ + public function getNumber() + { + return $this->container['number']; + } + + /** + * Sets number + * + * @param string $number The 13-19 digit number for this card as it can be found on the front of the card. + * + * @return self + */ + public function setNumber($number) + { + if ((mb_strlen($number) > 19)) { + throw new \InvalidArgumentException('invalid length for $number when calling CardRequest., must be smaller than or equal to 19.'); + } + if ((mb_strlen($number) < 13)) { + throw new \InvalidArgumentException('invalid length for $number when calling CardRequest., must be bigger than or equal to 13.'); + } + if ((!preg_match("/^[0-9]{13,19}$/", $number))) { + throw new \InvalidArgumentException("invalid value for $number when calling CardRequest., must conform to the pattern /^[0-9]{13,19}$/."); + } + + $this->container['number'] = $number; + + return $this; + } + + /** + * Gets expiration_date + * + * @return string + */ + public function getExpirationDate() + { + return $this->container['expiration_date']; + } + + /** + * Sets expiration_date + * + * @param string $expiration_date The expiration date of the card, formatted `MM/YY`. + * + * @return self + */ + public function setExpirationDate($expiration_date) + { + if ((mb_strlen($expiration_date) > 5)) { + throw new \InvalidArgumentException('invalid length for $expiration_date when calling CardRequest., must be smaller than or equal to 5.'); + } + if ((mb_strlen($expiration_date) < 5)) { + throw new \InvalidArgumentException('invalid length for $expiration_date when calling CardRequest., must be bigger than or equal to 5.'); + } + if ((!preg_match("/^\\d{2}\/\\d{2}$/", $expiration_date))) { + throw new \InvalidArgumentException("invalid value for $expiration_date when calling CardRequest., must conform to the pattern /^\\d{2}\/\\d{2}$/."); + } + + $this->container['expiration_date'] = $expiration_date; + + return $this; + } + + /** + * Gets security_code + * + * @return string + */ + public function getSecurityCode() + { + return $this->container['security_code']; + } + + /** + * Sets security_code + * + * @param string $security_code The 3 or 4 digit security code often found on the card. This often referred to as the CVV or CVD. + * + * @return self + */ + public function setSecurityCode($security_code) + { + if ((mb_strlen($security_code) > 4)) { + throw new \InvalidArgumentException('invalid length for $security_code when calling CardRequest., must be smaller than or equal to 4.'); + } + if ((mb_strlen($security_code) < 3)) { + throw new \InvalidArgumentException('invalid length for $security_code when calling CardRequest., must be bigger than or equal to 3.'); + } + if ((!preg_match("/^\\d{3,4}$/", $security_code))) { + throw new \InvalidArgumentException("invalid value for $security_code when calling CardRequest., must conform to the pattern /^\\d{3,4}$/."); + } + + $this->container['security_code'] = $security_code; + + return $this; + } + + /** + * Gets external_identifier + * + * @return string|null + */ + public function getExternalIdentifier() + { + return $this->container['external_identifier']; + } + + /** + * Sets external_identifier + * + * @param string|null $external_identifier An external identifier that can be used to match the card against your own records. + * + * @return self + */ + public function setExternalIdentifier($external_identifier) + { + $this->container['external_identifier'] = $external_identifier; + + return $this; + } + + /** + * Gets buyer_id + * + * @return string|null + */ + public function getBuyerId() + { + return $this->container['buyer_id']; + } + + /** + * Sets buyer_id + * + * @param string|null $buyer_id The ID of the buyer to associate this payment method to. If this field is provided then the `buyer_external_identifier` field needs to be unset. + * + * @return self + */ + public function setBuyerId($buyer_id) + { + $this->container['buyer_id'] = $buyer_id; + + return $this; + } + + /** + * Gets buyer_external_identifier + * + * @return string|null + */ + public function getBuyerExternalIdentifier() + { + return $this->container['buyer_external_identifier']; + } + + /** + * Sets buyer_external_identifier + * + * @param string|null $buyer_external_identifier The `external_identifier` of the buyer to associate this payment method to. If this field is provided then the `buyer_id` field needs to be unset. + * + * @return self + */ + public function setBuyerExternalIdentifier($buyer_external_identifier) + { + $this->container['buyer_external_identifier'] = $buyer_external_identifier; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/CardSchemeDefinition.php b/lib/model/CardSchemeDefinition.php new file mode 100644 index 0000000..fbfa265 --- /dev/null +++ b/lib/model/CardSchemeDefinition.php @@ -0,0 +1,446 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class CardSchemeDefinition implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CardSchemeDefinition'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'id' => 'string', + 'icon_url' => 'string', + 'display_name' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'id' => null, + 'icon_url' => null, + 'display_name' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'id' => 'id', + 'icon_url' => 'icon_url', + 'display_name' => 'display_name' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'id' => 'setId', + 'icon_url' => 'setIconUrl', + 'display_name' => 'setDisplayName' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'id' => 'getId', + 'icon_url' => 'getIconUrl', + 'display_name' => 'getDisplayName' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_CARD_SCHEME_DEFINITION = 'card-scheme-definition'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_CARD_SCHEME_DEFINITION, + ]; + } + + /** + * 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['type'] = $data['type'] ?? null; + $this->container['id'] = $data['id'] ?? null; + $this->container['icon_url'] = $data['icon_url'] ?? null; + $this->container['display_name'] = $data['display_name'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type `card-scheme-definition`. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id The name of this card scheme. + * + * @return self + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets icon_url + * + * @return string|null + */ + public function getIconUrl() + { + return $this->container['icon_url']; + } + + /** + * Sets icon_url + * + * @param string|null $icon_url The icon for this card scheme. + * + * @return self + */ + public function setIconUrl($icon_url) + { + $this->container['icon_url'] = $icon_url; + + return $this; + } + + /** + * Gets display_name + * + * @return string|null + */ + public function getDisplayName() + { + return $this->container['display_name']; + } + + /** + * Sets display_name + * + * @param string|null $display_name The display name of this card scheme. + * + * @return self + */ + public function setDisplayName($display_name) + { + $this->container['display_name'] = $display_name; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/CardSchemeDefinitions.php b/lib/model/CardSchemeDefinitions.php new file mode 100644 index 0000000..a52af4e --- /dev/null +++ b/lib/model/CardSchemeDefinitions.php @@ -0,0 +1,324 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class CardSchemeDefinitions implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CardSchemeDefinitions'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'items' => '\Gr4vy\model\CardSchemeDefinition[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'items' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'items' => 'items' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'items' => 'setItems' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'items' => 'getItems' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['items'] = $data['items'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets items + * + * @return \Gr4vy\model\CardSchemeDefinition[]|null + */ + public function getItems() + { + return $this->container['items']; + } + + /** + * Sets items + * + * @param \Gr4vy\model\CardSchemeDefinition[]|null $items items + * + * @return self + */ + public function setItems($items) + { + $this->container['items'] = $items; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/CartItem.php b/lib/model/CartItem.php new file mode 100644 index 0000000..6ed7365 --- /dev/null +++ b/lib/model/CartItem.php @@ -0,0 +1,791 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class CartItem implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CartItem'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'name' => 'string', + 'quantity' => 'int', + 'unit_amount' => 'int', + 'discount_amount' => 'int', + 'tax_amount' => 'int', + 'external_identifier' => 'string', + 'sku' => 'string', + 'product_url' => 'string', + 'image_url' => 'string', + 'categories' => 'string[]', + 'product_type' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'name' => null, + 'quantity' => null, + 'unit_amount' => null, + 'discount_amount' => null, + 'tax_amount' => null, + 'external_identifier' => null, + 'sku' => null, + 'product_url' => 'url', + 'image_url' => 'url', + 'categories' => null, + 'product_type' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'name' => 'name', + 'quantity' => 'quantity', + 'unit_amount' => 'unit_amount', + 'discount_amount' => 'discount_amount', + 'tax_amount' => 'tax_amount', + 'external_identifier' => 'external_identifier', + 'sku' => 'sku', + 'product_url' => 'product_url', + 'image_url' => 'image_url', + 'categories' => 'categories', + 'product_type' => 'product_type' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'name' => 'setName', + 'quantity' => 'setQuantity', + 'unit_amount' => 'setUnitAmount', + 'discount_amount' => 'setDiscountAmount', + 'tax_amount' => 'setTaxAmount', + 'external_identifier' => 'setExternalIdentifier', + 'sku' => 'setSku', + 'product_url' => 'setProductUrl', + 'image_url' => 'setImageUrl', + 'categories' => 'setCategories', + 'product_type' => 'setProductType' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'name' => 'getName', + 'quantity' => 'getQuantity', + 'unit_amount' => 'getUnitAmount', + 'discount_amount' => 'getDiscountAmount', + 'tax_amount' => 'getTaxAmount', + 'external_identifier' => 'getExternalIdentifier', + 'sku' => 'getSku', + 'product_url' => 'getProductUrl', + 'image_url' => 'getImageUrl', + 'categories' => 'getCategories', + 'product_type' => 'getProductType' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const PRODUCT_TYPE_PHYSICAL = 'physical'; + public const PRODUCT_TYPE_DISCOUNT = 'discount'; + public const PRODUCT_TYPE_SHIPPING_FEE = 'shipping_fee'; + public const PRODUCT_TYPE_SALES_TAX = 'sales_tax'; + public const PRODUCT_TYPE_DIGITAL = 'digital'; + public const PRODUCT_TYPE_GIFT_CARD = 'gift_card'; + public const PRODUCT_TYPE_STORE_CREDIT = 'store_credit'; + public const PRODUCT_TYPE_SURCHARGE = 'surcharge'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getProductTypeAllowableValues() + { + return [ + self::PRODUCT_TYPE_PHYSICAL, + self::PRODUCT_TYPE_DISCOUNT, + self::PRODUCT_TYPE_SHIPPING_FEE, + self::PRODUCT_TYPE_SALES_TAX, + self::PRODUCT_TYPE_DIGITAL, + self::PRODUCT_TYPE_GIFT_CARD, + self::PRODUCT_TYPE_STORE_CREDIT, + self::PRODUCT_TYPE_SURCHARGE, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['name'] = $data['name'] ?? null; + $this->container['quantity'] = $data['quantity'] ?? null; + $this->container['unit_amount'] = $data['unit_amount'] ?? null; + $this->container['discount_amount'] = $data['discount_amount'] ?? 0; + $this->container['tax_amount'] = $data['tax_amount'] ?? 0; + $this->container['external_identifier'] = $data['external_identifier'] ?? null; + $this->container['sku'] = $data['sku'] ?? null; + $this->container['product_url'] = $data['product_url'] ?? null; + $this->container['image_url'] = $data['image_url'] ?? null; + $this->container['categories'] = $data['categories'] ?? null; + $this->container['product_type'] = $data['product_type'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['name'] === null) { + $invalidProperties[] = "'name' can't be null"; + } + if ((mb_strlen($this->container['name']) > 255)) { + $invalidProperties[] = "invalid value for 'name', the character length must be smaller than or equal to 255."; + } + + if ($this->container['quantity'] === null) { + $invalidProperties[] = "'quantity' can't be null"; + } + if (($this->container['quantity'] > 99999999)) { + $invalidProperties[] = "invalid value for 'quantity', must be smaller than or equal to 99999999."; + } + + if (($this->container['quantity'] < 1)) { + $invalidProperties[] = "invalid value for 'quantity', must be bigger than or equal to 1."; + } + + if ($this->container['unit_amount'] === null) { + $invalidProperties[] = "'unit_amount' can't be null"; + } + if (($this->container['unit_amount'] > 99999999)) { + $invalidProperties[] = "invalid value for 'unit_amount', must be smaller than or equal to 99999999."; + } + + if (($this->container['unit_amount'] < 0)) { + $invalidProperties[] = "invalid value for 'unit_amount', must be bigger than or equal to 0."; + } + + if (!is_null($this->container['discount_amount']) && ($this->container['discount_amount'] > 99999999)) { + $invalidProperties[] = "invalid value for 'discount_amount', must be smaller than or equal to 99999999."; + } + + if (!is_null($this->container['discount_amount']) && ($this->container['discount_amount'] < 0)) { + $invalidProperties[] = "invalid value for 'discount_amount', must be bigger than or equal to 0."; + } + + if (!is_null($this->container['tax_amount']) && ($this->container['tax_amount'] > 99999999)) { + $invalidProperties[] = "invalid value for 'tax_amount', must be smaller than or equal to 99999999."; + } + + if (!is_null($this->container['tax_amount']) && ($this->container['tax_amount'] < 0)) { + $invalidProperties[] = "invalid value for 'tax_amount', must be bigger than or equal to 0."; + } + + if (!is_null($this->container['external_identifier']) && (mb_strlen($this->container['external_identifier']) > 200)) { + $invalidProperties[] = "invalid value for 'external_identifier', the character length must be smaller than or equal to 200."; + } + + if (!is_null($this->container['sku']) && (mb_strlen($this->container['sku']) > 200)) { + $invalidProperties[] = "invalid value for 'sku', the character length must be smaller than or equal to 200."; + } + + if (!is_null($this->container['product_url']) && (mb_strlen($this->container['product_url']) > 2083)) { + $invalidProperties[] = "invalid value for 'product_url', the character length must be smaller than or equal to 2083."; + } + + if (!is_null($this->container['image_url']) && (mb_strlen($this->container['image_url']) > 2083)) { + $invalidProperties[] = "invalid value for 'image_url', the character length must be smaller than or equal to 2083."; + } + + if (!is_null($this->container['categories']) && (count($this->container['categories']) > 500)) { + $invalidProperties[] = "invalid value for 'categories', number of items must be less than or equal to 100."; + } + + $allowedValues = $this->getProductTypeAllowableValues(); + if (!is_null($this->container['product_type']) && !in_array($this->container['product_type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'product_type', must be one of '%s'", + $this->container['product_type'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets name + * + * @return string + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string $name The name of the cart item. The value you set for this property may be truncated if the maximum length accepted by a payment service provider is less than 255 characters. + * + * @return self + */ + public function setName($name) + { + if ((mb_strlen($name) > 255)) { + throw new \InvalidArgumentException('invalid length for $name when calling CartItem., must be smaller than or equal to 255.'); + } + + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets quantity + * + * @return int + */ + public function getQuantity() + { + return $this->container['quantity']; + } + + /** + * Sets quantity + * + * @param int $quantity The quantity of this item in the cart. This value cannot be negative or zero. + * + * @return self + */ + public function setQuantity($quantity) + { + + if (($quantity > 99999999)) { + throw new \InvalidArgumentException('invalid value for $quantity when calling CartItem., must be smaller than or equal to 99999999.'); + } + if (($quantity < 1)) { + throw new \InvalidArgumentException('invalid value for $quantity when calling CartItem., must be bigger than or equal to 1.'); + } + + $this->container['quantity'] = $quantity; + + return $this; + } + + /** + * Gets unit_amount + * + * @return int + */ + public function getUnitAmount() + { + return $this->container['unit_amount']; + } + + /** + * Sets unit_amount + * + * @param int $unit_amount The amount for an individual item represented as a monetary amount in the smallest currency unit for the given currency, for example `1299` USD cents represents `$12.99`. + * + * @return self + */ + public function setUnitAmount($unit_amount) + { + + if (($unit_amount > 99999999)) { + throw new \InvalidArgumentException('invalid value for $unit_amount when calling CartItem., must be smaller than or equal to 99999999.'); + } + if (($unit_amount < 0)) { + throw new \InvalidArgumentException('invalid value for $unit_amount when calling CartItem., must be bigger than or equal to 0.'); + } + + $this->container['unit_amount'] = $unit_amount; + + return $this; + } + + /** + * Gets discount_amount + * + * @return int|null + */ + public function getDiscountAmount() + { + return $this->container['discount_amount']; + } + + /** + * Sets discount_amount + * + * @param int|null $discount_amount The amount discounted for this item represented as a monetary amount in the smallest currency unit for the given currency, for example `1299` USD cents represents `$12.99`. Please note that this amount is for the total of the cart item and not for an individual item. For example, if the quantity is 5, this value should be the total discount amount for 5 of the cart item. You might see unexpected failed transactions if the `discount_amount` can not be equally divided by the `quantity` value. This is due to the fact that some payment services require this amount to be specified per unit. In this situation we recommend splitting this item into separate items, each with their own specific discount. + * + * @return self + */ + public function setDiscountAmount($discount_amount) + { + + if (!is_null($discount_amount) && ($discount_amount > 99999999)) { + throw new \InvalidArgumentException('invalid value for $discount_amount when calling CartItem., must be smaller than or equal to 99999999.'); + } + if (!is_null($discount_amount) && ($discount_amount < 0)) { + throw new \InvalidArgumentException('invalid value for $discount_amount when calling CartItem., must be bigger than or equal to 0.'); + } + + $this->container['discount_amount'] = $discount_amount; + + return $this; + } + + /** + * Gets tax_amount + * + * @return int|null + */ + public function getTaxAmount() + { + return $this->container['tax_amount']; + } + + /** + * Sets tax_amount + * + * @param int|null $tax_amount The tax amount for this item represented as a monetary amount in the smallest currency unit for the given currency, for example `1299` USD cents represents `$12.99`. Please not that this amount is for the total of the cart item and not for an individual item. For example, if the quantity is 5, this value should be the total tax amount for 5 of the cart item. You might see unexpected failed transactions if the `tax_amount` can not be equally divided by the `quantity` value. This is due to the fact that some payment services require this amount to be specified per unit. In this situation we recommend splitting this item into separate items, each with their own specific tax amount. + * + * @return self + */ + public function setTaxAmount($tax_amount) + { + + if (!is_null($tax_amount) && ($tax_amount > 99999999)) { + throw new \InvalidArgumentException('invalid value for $tax_amount when calling CartItem., must be smaller than or equal to 99999999.'); + } + if (!is_null($tax_amount) && ($tax_amount < 0)) { + throw new \InvalidArgumentException('invalid value for $tax_amount when calling CartItem., must be bigger than or equal to 0.'); + } + + $this->container['tax_amount'] = $tax_amount; + + return $this; + } + + /** + * Gets external_identifier + * + * @return string|null + */ + public function getExternalIdentifier() + { + return $this->container['external_identifier']; + } + + /** + * Sets external_identifier + * + * @param string|null $external_identifier An external identifier for the cart item. This can be set to any value and is not sent to the payment service. + * + * @return self + */ + public function setExternalIdentifier($external_identifier) + { + if (!is_null($external_identifier) && (mb_strlen($external_identifier) > 200)) { + throw new \InvalidArgumentException('invalid length for $external_identifier when calling CartItem., must be smaller than or equal to 200.'); + } + + $this->container['external_identifier'] = $external_identifier; + + return $this; + } + + /** + * Gets sku + * + * @return string|null + */ + public function getSku() + { + return $this->container['sku']; + } + + /** + * Sets sku + * + * @param string|null $sku The SKU for the item. + * + * @return self + */ + public function setSku($sku) + { + if (!is_null($sku) && (mb_strlen($sku) > 200)) { + throw new \InvalidArgumentException('invalid length for $sku when calling CartItem., must be smaller than or equal to 200.'); + } + + $this->container['sku'] = $sku; + + return $this; + } + + /** + * Gets product_url + * + * @return string|null + */ + public function getProductUrl() + { + return $this->container['product_url']; + } + + /** + * Sets product_url + * + * @param string|null $product_url The product URL for the item. + * + * @return self + */ + public function setProductUrl($product_url) + { + if (!is_null($product_url) && (mb_strlen($product_url) > 2083)) { + throw new \InvalidArgumentException('invalid length for $product_url when calling CartItem., must be smaller than or equal to 2083.'); + } + + $this->container['product_url'] = $product_url; + + return $this; + } + + /** + * Gets image_url + * + * @return string|null + */ + public function getImageUrl() + { + return $this->container['image_url']; + } + + /** + * Sets image_url + * + * @param string|null $image_url The URL for the image of the item. + * + * @return self + */ + public function setImageUrl($image_url) + { + if (!is_null($image_url) && (mb_strlen($image_url) > 2083)) { + throw new \InvalidArgumentException('invalid length for $image_url when calling CartItem., must be smaller than or equal to 2083.'); + } + + $this->container['image_url'] = $image_url; + + return $this; + } + + /** + * Gets categories + * + * @return string[]|null + */ + public function getCategories() + { + return $this->container['categories']; + } + + /** + * Sets categories + * + * @param string[]|null $categories A list of strings containing product categories for the item. Max length per item: 50. + * + * @return self + */ + public function setCategories($categories) + { + + if (!is_null($categories) && (count($categories) > 100)) { + throw new \InvalidArgumentException('invalid value for $categories when calling CartItem., number of items must be less than or equal to 100.'); + } + $this->container['categories'] = $categories; + + return $this; + } + + /** + * Gets product_type + * + * @return string|null + */ + public function getProductType() + { + return $this->container['product_type']; + } + + /** + * Sets product_type + * + * @param string|null $product_type The product type of the cart item. + * + * @return self + */ + public function setProductType($product_type) + { + $allowedValues = $this->getProductTypeAllowableValues(); + if (!is_null($product_type) && !in_array($product_type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'product_type', must be one of '%s'", + $product_type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['product_type'] = $product_type; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/CheckoutSession.php b/lib/model/CheckoutSession.php new file mode 100644 index 0000000..b66e1cd --- /dev/null +++ b/lib/model/CheckoutSession.php @@ -0,0 +1,416 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class CheckoutSession implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CheckoutSession'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'id' => 'string', + 'expires_at' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'id' => 'uuid', + 'expires_at' => 'datetime' + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'id' => 'id', + 'expires_at' => 'expires_at' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'id' => 'setId', + 'expires_at' => 'setExpiresAt' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'id' => 'getId', + 'expires_at' => 'getExpiresAt' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_CHECKOUT_SESSION = 'checkout-session'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_CHECKOUT_SESSION, + ]; + } + + /** + * 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['type'] = $data['type'] ?? null; + $this->container['id'] = $data['id'] ?? null; + $this->container['expires_at'] = $data['expires_at'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type `checkout-session`. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id The ID of the Checkout Session. + * + * @return self + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets expires_at + * + * @return string|null + */ + public function getExpiresAt() + { + return $this->container['expires_at']; + } + + /** + * Sets expires_at + * + * @param string|null $expires_at The date and time when the Checkout Session will expire. By default this will be set to 1 hour from the date of creation. + * + * @return self + */ + public function setExpiresAt($expires_at) + { + $this->container['expires_at'] = $expires_at; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/CheckoutSessionRequest.php b/lib/model/CheckoutSessionRequest.php new file mode 100644 index 0000000..e8f203a --- /dev/null +++ b/lib/model/CheckoutSessionRequest.php @@ -0,0 +1,392 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class CheckoutSessionRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CheckoutSessionRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'method' => 'string', + 'id' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'method' => null, + 'id' => 'uuid' + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'method' => 'method', + 'id' => 'id' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'method' => 'setMethod', + 'id' => 'setId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'method' => 'getMethod', + 'id' => 'getId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const METHOD_CHECKOUT_SESSION = 'checkout-session'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getMethodAllowableValues() + { + return [ + self::METHOD_CHECKOUT_SESSION, + ]; + } + + /** + * 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['method'] = $data['method'] ?? null; + $this->container['id'] = $data['id'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['method'] === null) { + $invalidProperties[] = "'method' can't be null"; + } + $allowedValues = $this->getMethodAllowableValues(); + if (!is_null($this->container['method']) && !in_array($this->container['method'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'method', must be one of '%s'", + $this->container['method'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['id'] === null) { + $invalidProperties[] = "'id' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets method + * + * @return string + */ + public function getMethod() + { + return $this->container['method']; + } + + /** + * Sets method + * + * @param string $method `checkout-session`. + * + * @return self + */ + public function setMethod($method) + { + $allowedValues = $this->getMethodAllowableValues(); + if (!in_array($method, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'method', must be one of '%s'", + $method, + implode("', '", $allowedValues) + ) + ); + } + $this->container['method'] = $method; + + return $this; + } + + /** + * Gets id + * + * @return string + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string $id The ID of the Checkout Session. + * + * @return self + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/CheckoutSessionSecureFieldsUpdate.php b/lib/model/CheckoutSessionSecureFieldsUpdate.php new file mode 100644 index 0000000..5421c46 --- /dev/null +++ b/lib/model/CheckoutSessionSecureFieldsUpdate.php @@ -0,0 +1,324 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class CheckoutSessionSecureFieldsUpdate implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CheckoutSessionSecureFieldsUpdate'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'payment_method' => '\Gr4vy\model\CardRequest' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'payment_method' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'payment_method' => 'payment_method' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'payment_method' => 'setPaymentMethod' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'payment_method' => 'getPaymentMethod' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['payment_method'] = $data['payment_method'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets payment_method + * + * @return \Gr4vy\model\CardRequest|null + */ + public function getPaymentMethod() + { + return $this->container['payment_method']; + } + + /** + * Sets payment_method + * + * @param \Gr4vy\model\CardRequest|null $payment_method payment_method + * + * @return self + */ + public function setPaymentMethod($payment_method) + { + $this->container['payment_method'] = $payment_method; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/Connection.php b/lib/model/Connection.php new file mode 100644 index 0000000..b453404 --- /dev/null +++ b/lib/model/Connection.php @@ -0,0 +1,444 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class Connection implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'Connection'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'type' => 'string', + 'name' => 'string', + 'active' => 'bool', + 'definition' => '\Gr4vy\model\ConnectionDefinition' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'type' => null, + 'name' => null, + 'active' => null, + 'definition' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'type' => 'type', + 'name' => 'name', + 'active' => 'active', + 'definition' => 'definition' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'type' => 'setType', + 'name' => 'setName', + 'active' => 'setActive', + 'definition' => 'setDefinition' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'type' => 'getType', + 'name' => 'getName', + 'active' => 'getActive', + 'definition' => 'getDefinition' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['id'] = $data['id'] ?? null; + $this->container['type'] = $data['type'] ?? 'connection'; + $this->container['name'] = $data['name'] ?? null; + $this->container['active'] = $data['active'] ?? null; + $this->container['definition'] = $data['definition'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id The ID of the connection. + * + * @return self + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type `connection`. + * + * @return self + */ + public function setType($type) + { + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name The name of this connection. + * + * @return self + */ + public function setName($name) + { + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets active + * + * @return bool|null + */ + public function getActive() + { + return $this->container['active']; + } + + /** + * Sets active + * + * @param bool|null $active Whether this connection is currently in use. Connections can be deactivated to allow for them to be kept around and re-activated at a later date. + * + * @return self + */ + public function setActive($active) + { + $this->container['active'] = $active; + + return $this; + } + + /** + * Gets definition + * + * @return \Gr4vy\model\ConnectionDefinition|null + */ + public function getDefinition() + { + return $this->container['definition']; + } + + /** + * Sets definition + * + * @param \Gr4vy\model\ConnectionDefinition|null $definition definition + * + * @return self + */ + public function setDefinition($definition) + { + $this->container['definition'] = $definition; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/ConnectionDefinition.php b/lib/model/ConnectionDefinition.php new file mode 100644 index 0000000..1bb6f4a --- /dev/null +++ b/lib/model/ConnectionDefinition.php @@ -0,0 +1,612 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class ConnectionDefinition implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ConnectionDefinition'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'type' => 'string', + 'name' => 'string', + 'count' => 'float', + 'group' => 'string', + 'category' => 'string', + 'icon_url' => 'string', + 'provider' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'type' => null, + 'name' => null, + 'count' => null, + 'group' => null, + 'category' => null, + 'icon_url' => null, + 'provider' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'type' => 'type', + 'name' => 'name', + 'count' => 'count', + 'group' => 'group', + 'category' => 'category', + 'icon_url' => 'icon_url', + 'provider' => 'provider' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'type' => 'setType', + 'name' => 'setName', + 'count' => 'setCount', + 'group' => 'setGroup', + 'category' => 'setCategory', + 'icon_url' => 'setIconUrl', + 'provider' => 'setProvider' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'type' => 'getType', + 'name' => 'getName', + 'count' => 'getCount', + 'group' => 'getGroup', + 'category' => 'getCategory', + 'icon_url' => 'getIconUrl', + 'provider' => 'getProvider' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const GROUP_ANTI_FRAUD_SERVICE = 'anti-fraud-service'; + public const GROUP_PAYMENT_SERVICE = 'payment-service'; + public const GROUP_DIGITAL_WALLET = 'digital-wallet'; + public const CATEGORY_ANTI_FRAUD = 'anti-fraud'; + public const CATEGORY_BANK = 'bank'; + public const CATEGORY_BNPL = 'bnpl'; + public const CATEGORY_CARD = 'card'; + public const CATEGORY_CASH = 'cash'; + public const CATEGORY_WALLET = 'wallet'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getGroupAllowableValues() + { + return [ + self::GROUP_ANTI_FRAUD_SERVICE, + self::GROUP_PAYMENT_SERVICE, + self::GROUP_DIGITAL_WALLET, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getCategoryAllowableValues() + { + return [ + self::CATEGORY_ANTI_FRAUD, + self::CATEGORY_BANK, + self::CATEGORY_BNPL, + self::CATEGORY_CARD, + self::CATEGORY_CASH, + self::CATEGORY_WALLET, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['id'] = $data['id'] ?? null; + $this->container['type'] = $data['type'] ?? 'connection-definition'; + $this->container['name'] = $data['name'] ?? null; + $this->container['count'] = $data['count'] ?? null; + $this->container['group'] = $data['group'] ?? null; + $this->container['category'] = $data['category'] ?? null; + $this->container['icon_url'] = $data['icon_url'] ?? null; + $this->container['provider'] = $data['provider'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getGroupAllowableValues(); + if (!is_null($this->container['group']) && !in_array($this->container['group'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'group', must be one of '%s'", + $this->container['group'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getCategoryAllowableValues(); + if (!is_null($this->container['category']) && !in_array($this->container['category'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'category', must be one of '%s'", + $this->container['category'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id The ID of the connection. + * + * @return self + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type `connection-definition`. + * + * @return self + */ + public function setType($type) + { + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name The name of this connection. + * + * @return self + */ + public function setName($name) + { + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets count + * + * @return float|null + */ + public function getCount() + { + return $this->container['count']; + } + + /** + * Sets count + * + * @param float|null $count The number of configured connections. + * + * @return self + */ + public function setCount($count) + { + $this->container['count'] = $count; + + return $this; + } + + /** + * Gets group + * + * @return string|null + */ + public function getGroup() + { + return $this->container['group']; + } + + /** + * Sets group + * + * @param string|null $group group + * + * @return self + */ + public function setGroup($group) + { + $allowedValues = $this->getGroupAllowableValues(); + if (!is_null($group) && !in_array($group, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'group', must be one of '%s'", + $group, + implode("', '", $allowedValues) + ) + ); + } + $this->container['group'] = $group; + + return $this; + } + + /** + * Gets category + * + * @return string|null + */ + public function getCategory() + { + return $this->container['category']; + } + + /** + * Sets category + * + * @param string|null $category category + * + * @return self + */ + public function setCategory($category) + { + $allowedValues = $this->getCategoryAllowableValues(); + if (!is_null($category) && !in_array($category, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'category', must be one of '%s'", + $category, + implode("', '", $allowedValues) + ) + ); + } + $this->container['category'] = $category; + + return $this; + } + + /** + * Gets icon_url + * + * @return string|null + */ + public function getIconUrl() + { + return $this->container['icon_url']; + } + + /** + * Sets icon_url + * + * @param string|null $icon_url An icon to display for the connection. + * + * @return self + */ + public function setIconUrl($icon_url) + { + $this->container['icon_url'] = $icon_url; + + return $this; + } + + /** + * Gets provider + * + * @return string|null + */ + public function getProvider() + { + return $this->container['provider']; + } + + /** + * Sets provider + * + * @param string|null $provider The provider for this connection. + * + * @return self + */ + public function setProvider($provider) + { + $this->container['provider'] = $provider; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/ConnectionDefinitions.php b/lib/model/ConnectionDefinitions.php new file mode 100644 index 0000000..5d11eea --- /dev/null +++ b/lib/model/ConnectionDefinitions.php @@ -0,0 +1,324 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class ConnectionDefinitions implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ConnectionDefinitions'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'items' => '\Gr4vy\model\ConnectionDefinition[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'items' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'items' => 'items' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'items' => 'setItems' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'items' => 'getItems' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['items'] = $data['items'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets items + * + * @return \Gr4vy\model\ConnectionDefinition[]|null + */ + public function getItems() + { + return $this->container['items']; + } + + /** + * Sets items + * + * @param \Gr4vy\model\ConnectionDefinition[]|null $items items + * + * @return self + */ + public function setItems($items) + { + $this->container['items'] = $items; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/Connections.php b/lib/model/Connections.php new file mode 100644 index 0000000..79f6eb6 --- /dev/null +++ b/lib/model/Connections.php @@ -0,0 +1,324 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class Connections implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'Connections'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'items' => '\Gr4vy\model\Connection[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'items' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'items' => 'items' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'items' => 'setItems' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'items' => 'getItems' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['items'] = $data['items'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets items + * + * @return \Gr4vy\model\Connection[]|null + */ + public function getItems() + { + return $this->container['items']; + } + + /** + * Sets items + * + * @param \Gr4vy\model\Connection[]|null $items items + * + * @return self + */ + public function setItems($items) + { + $this->container['items'] = $items; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/DigitalWallet.php b/lib/model/DigitalWallet.php new file mode 100644 index 0000000..15f2df3 --- /dev/null +++ b/lib/model/DigitalWallet.php @@ -0,0 +1,615 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class DigitalWallet implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'DigitalWallet'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'provider' => 'string', + 'id' => 'string', + 'merchant_name' => 'string', + 'merchant_url' => 'string', + 'domain_names' => 'string[]', + 'created_at' => '\DateTime', + 'updated_at' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'provider' => null, + 'id' => 'uuid', + 'merchant_name' => null, + 'merchant_url' => 'url', + 'domain_names' => null, + 'created_at' => 'date-time', + 'updated_at' => 'date-time' + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'provider' => 'provider', + 'id' => 'id', + 'merchant_name' => 'merchant_name', + 'merchant_url' => 'merchant_url', + 'domain_names' => 'domain_names', + 'created_at' => 'created_at', + 'updated_at' => 'updated_at' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'provider' => 'setProvider', + 'id' => 'setId', + 'merchant_name' => 'setMerchantName', + 'merchant_url' => 'setMerchantUrl', + 'domain_names' => 'setDomainNames', + 'created_at' => 'setCreatedAt', + 'updated_at' => 'setUpdatedAt' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'provider' => 'getProvider', + 'id' => 'getId', + 'merchant_name' => 'getMerchantName', + 'merchant_url' => 'getMerchantUrl', + 'domain_names' => 'getDomainNames', + 'created_at' => 'getCreatedAt', + 'updated_at' => 'getUpdatedAt' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_DIGITAL_WALLET = 'digital-wallet'; + public const PROVIDER_APPLE = 'apple'; + public const PROVIDER_GOOGLE = 'google'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_DIGITAL_WALLET, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getProviderAllowableValues() + { + return [ + self::PROVIDER_APPLE, + self::PROVIDER_GOOGLE, + ]; + } + + /** + * 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['type'] = $data['type'] ?? null; + $this->container['provider'] = $data['provider'] ?? null; + $this->container['id'] = $data['id'] ?? null; + $this->container['merchant_name'] = $data['merchant_name'] ?? null; + $this->container['merchant_url'] = $data['merchant_url'] ?? null; + $this->container['domain_names'] = $data['domain_names'] ?? null; + $this->container['created_at'] = $data['created_at'] ?? null; + $this->container['updated_at'] = $data['updated_at'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getProviderAllowableValues(); + if (!is_null($this->container['provider']) && !in_array($this->container['provider'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'provider', must be one of '%s'", + $this->container['provider'], + implode("', '", $allowedValues) + ); + } + + if (!is_null($this->container['domain_names']) && (count($this->container['domain_names']) > 99)) { + $invalidProperties[] = "invalid value for 'domain_names', number of items must be less than or equal to 99."; + } + + if (!is_null($this->container['domain_names']) && (count($this->container['domain_names']) < 1)) { + $invalidProperties[] = "invalid value for 'domain_names', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type `digital-wallet`. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets provider + * + * @return string|null + */ + public function getProvider() + { + return $this->container['provider']; + } + + /** + * Sets provider + * + * @param string|null $provider The name of the digital wallet provider. + * + * @return self + */ + public function setProvider($provider) + { + $allowedValues = $this->getProviderAllowableValues(); + if (!is_null($provider) && !in_array($provider, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'provider', must be one of '%s'", + $provider, + implode("', '", $allowedValues) + ) + ); + } + $this->container['provider'] = $provider; + + return $this; + } + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id The ID of the registered digital wallet. + * + * @return self + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets merchant_name + * + * @return string|null + */ + public function getMerchantName() + { + return $this->container['merchant_name']; + } + + /** + * Sets merchant_name + * + * @param string|null $merchant_name The name of the merchant the digital wallet is registered to. + * + * @return self + */ + public function setMerchantName($merchant_name) + { + $this->container['merchant_name'] = $merchant_name; + + return $this; + } + + /** + * Gets merchant_url + * + * @return string|null + */ + public function getMerchantUrl() + { + return $this->container['merchant_url']; + } + + /** + * Sets merchant_url + * + * @param string|null $merchant_url The main URL of the merchant. + * + * @return self + */ + public function setMerchantUrl($merchant_url) + { + $this->container['merchant_url'] = $merchant_url; + + return $this; + } + + /** + * Gets domain_names + * + * @return string[]|null + */ + public function getDomainNames() + { + return $this->container['domain_names']; + } + + /** + * Sets domain_names + * + * @param string[]|null $domain_names The list of domain names that a digital wallet can be used on. To use a digital wallet on a website, the domain of the site is required to be in this list. + * + * @return self + */ + public function setDomainNames($domain_names) + { + + if (!is_null($domain_names) && (count($domain_names) > 99)) { + throw new \InvalidArgumentException('invalid value for $domain_names when calling DigitalWallet., number of items must be less than or equal to 99.'); + } + if (!is_null($domain_names) && (count($domain_names) < 1)) { + throw new \InvalidArgumentException('invalid length for $domain_names when calling DigitalWallet., number of items must be greater than or equal to 1.'); + } + $this->container['domain_names'] = $domain_names; + + return $this; + } + + /** + * Gets created_at + * + * @return \DateTime|null + */ + public function getCreatedAt() + { + return $this->container['created_at']; + } + + /** + * Sets created_at + * + * @param \DateTime|null $created_at The date and time when this digital wallet was registered. + * + * @return self + */ + public function setCreatedAt($created_at) + { + $this->container['created_at'] = $created_at; + + return $this; + } + + /** + * Gets updated_at + * + * @return \DateTime|null + */ + public function getUpdatedAt() + { + return $this->container['updated_at']; + } + + /** + * Sets updated_at + * + * @param \DateTime|null $updated_at The date and time when this digital wallet was last updated. + * + * @return self + */ + public function setUpdatedAt($updated_at) + { + $this->container['updated_at'] = $updated_at; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/DigitalWalletRequest.php b/lib/model/DigitalWalletRequest.php new file mode 100644 index 0000000..98e91a7 --- /dev/null +++ b/lib/model/DigitalWalletRequest.php @@ -0,0 +1,505 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class DigitalWalletRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'DigitalWalletRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'provider' => 'string', + 'merchant_name' => 'string', + 'merchant_url' => 'string', + 'domain_names' => 'string[]', + 'accept_terms_and_conditions' => 'bool' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'provider' => null, + 'merchant_name' => null, + 'merchant_url' => 'url', + 'domain_names' => null, + 'accept_terms_and_conditions' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'provider' => 'provider', + 'merchant_name' => 'merchant_name', + 'merchant_url' => 'merchant_url', + 'domain_names' => 'domain_names', + 'accept_terms_and_conditions' => 'accept_terms_and_conditions' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'provider' => 'setProvider', + 'merchant_name' => 'setMerchantName', + 'merchant_url' => 'setMerchantUrl', + 'domain_names' => 'setDomainNames', + 'accept_terms_and_conditions' => 'setAcceptTermsAndConditions' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'provider' => 'getProvider', + 'merchant_name' => 'getMerchantName', + 'merchant_url' => 'getMerchantUrl', + 'domain_names' => 'getDomainNames', + 'accept_terms_and_conditions' => 'getAcceptTermsAndConditions' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const PROVIDER_APPLE = 'apple'; + public const PROVIDER_GOOGLE = 'google'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getProviderAllowableValues() + { + return [ + self::PROVIDER_APPLE, + self::PROVIDER_GOOGLE, + ]; + } + + /** + * 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['provider'] = $data['provider'] ?? null; + $this->container['merchant_name'] = $data['merchant_name'] ?? null; + $this->container['merchant_url'] = $data['merchant_url'] ?? null; + $this->container['domain_names'] = $data['domain_names'] ?? null; + $this->container['accept_terms_and_conditions'] = $data['accept_terms_and_conditions'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['provider'] === null) { + $invalidProperties[] = "'provider' can't be null"; + } + $allowedValues = $this->getProviderAllowableValues(); + if (!is_null($this->container['provider']) && !in_array($this->container['provider'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'provider', must be one of '%s'", + $this->container['provider'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['merchant_name'] === null) { + $invalidProperties[] = "'merchant_name' can't be null"; + } + if ($this->container['domain_names'] === null) { + $invalidProperties[] = "'domain_names' can't be null"; + } + if ((count($this->container['domain_names']) > 99)) { + $invalidProperties[] = "invalid value for 'domain_names', number of items must be less than or equal to 99."; + } + + if ((count($this->container['domain_names']) < 1)) { + $invalidProperties[] = "invalid value for 'domain_names', number of items must be greater than or equal to 1."; + } + + if ($this->container['accept_terms_and_conditions'] === null) { + $invalidProperties[] = "'accept_terms_and_conditions' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets provider + * + * @return string + */ + public function getProvider() + { + return $this->container['provider']; + } + + /** + * Sets provider + * + * @param string $provider The name of the digital wallet provider. + * + * @return self + */ + public function setProvider($provider) + { + $allowedValues = $this->getProviderAllowableValues(); + if (!in_array($provider, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'provider', must be one of '%s'", + $provider, + implode("', '", $allowedValues) + ) + ); + } + $this->container['provider'] = $provider; + + return $this; + } + + /** + * Gets merchant_name + * + * @return string + */ + public function getMerchantName() + { + return $this->container['merchant_name']; + } + + /** + * Sets merchant_name + * + * @param string $merchant_name The name of the merchant. This is used to register the merchant with a digital wallet provider and this name is not displayed to the buyer. + * + * @return self + */ + public function setMerchantName($merchant_name) + { + $this->container['merchant_name'] = $merchant_name; + + return $this; + } + + /** + * Gets merchant_url + * + * @return string|null + */ + public function getMerchantUrl() + { + return $this->container['merchant_url']; + } + + /** + * Sets merchant_url + * + * @param string|null $merchant_url The main URL of the merchant. This is used to register the merchant with a digital wallet provider and this URL is not displayed to the buyer. + * + * @return self + */ + public function setMerchantUrl($merchant_url) + { + $this->container['merchant_url'] = $merchant_url; + + return $this; + } + + /** + * Gets domain_names + * + * @return string[] + */ + public function getDomainNames() + { + return $this->container['domain_names']; + } + + /** + * Sets domain_names + * + * @param string[] $domain_names The list of domain names that a digital wallet can be used on. To use a digital wallet on a website, the domain of the site is required to be in this list. + * + * @return self + */ + public function setDomainNames($domain_names) + { + + if ((count($domain_names) > 99)) { + throw new \InvalidArgumentException('invalid value for $domain_names when calling DigitalWalletRequest., number of items must be less than or equal to 99.'); + } + if ((count($domain_names) < 1)) { + throw new \InvalidArgumentException('invalid length for $domain_names when calling DigitalWalletRequest., number of items must be greater than or equal to 1.'); + } + $this->container['domain_names'] = $domain_names; + + return $this; + } + + /** + * Gets accept_terms_and_conditions + * + * @return bool + */ + public function getAcceptTermsAndConditions() + { + return $this->container['accept_terms_and_conditions']; + } + + /** + * Sets accept_terms_and_conditions + * + * @param bool $accept_terms_and_conditions The explicit acceptance of the digital wallet provider's terms and conditions by the merchant. Needs to be `true` to register a new digital wallet. + * + * @return self + */ + public function setAcceptTermsAndConditions($accept_terms_and_conditions) + { + $this->container['accept_terms_and_conditions'] = $accept_terms_and_conditions; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/DigitalWalletUpdate.php b/lib/model/DigitalWalletUpdate.php new file mode 100644 index 0000000..ac519fe --- /dev/null +++ b/lib/model/DigitalWalletUpdate.php @@ -0,0 +1,369 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class DigitalWalletUpdate implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'DigitalWalletUpdate'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'merchant_name' => 'string', + 'domain_names' => 'string[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'merchant_name' => null, + 'domain_names' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'merchant_name' => 'merchant_name', + 'domain_names' => 'domain_names' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'merchant_name' => 'setMerchantName', + 'domain_names' => 'setDomainNames' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'merchant_name' => 'getMerchantName', + 'domain_names' => 'getDomainNames' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['merchant_name'] = $data['merchant_name'] ?? null; + $this->container['domain_names'] = $data['domain_names'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['domain_names']) && (count($this->container['domain_names']) > 99)) { + $invalidProperties[] = "invalid value for 'domain_names', number of items must be less than or equal to 99."; + } + + if (!is_null($this->container['domain_names']) && (count($this->container['domain_names']) < 1)) { + $invalidProperties[] = "invalid value for 'domain_names', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets merchant_name + * + * @return string|null + */ + public function getMerchantName() + { + return $this->container['merchant_name']; + } + + /** + * Sets merchant_name + * + * @param string|null $merchant_name The name of the merchant. This is used to update the value initially used to register with a digital wallet provider and this name is not displayed to the buyer. + * + * @return self + */ + public function setMerchantName($merchant_name) + { + $this->container['merchant_name'] = $merchant_name; + + return $this; + } + + /** + * Gets domain_names + * + * @return string[]|null + */ + public function getDomainNames() + { + return $this->container['domain_names']; + } + + /** + * Sets domain_names + * + * @param string[]|null $domain_names The list of domain names that a digital wallet can be used on. To use a digital wallet on a website, the domain of the site is required to be in this list. + * + * @return self + */ + public function setDomainNames($domain_names) + { + + if (!is_null($domain_names) && (count($domain_names) > 99)) { + throw new \InvalidArgumentException('invalid value for $domain_names when calling DigitalWalletUpdate., number of items must be less than or equal to 99.'); + } + if (!is_null($domain_names) && (count($domain_names) < 1)) { + throw new \InvalidArgumentException('invalid length for $domain_names when calling DigitalWalletUpdate., number of items must be greater than or equal to 1.'); + } + $this->container['domain_names'] = $domain_names; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/DigitalWallets.php b/lib/model/DigitalWallets.php new file mode 100644 index 0000000..0737c38 --- /dev/null +++ b/lib/model/DigitalWallets.php @@ -0,0 +1,324 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class DigitalWallets implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'DigitalWallets'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'items' => '\Gr4vy\model\DigitalWallet[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'items' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'items' => 'items' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'items' => 'setItems' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'items' => 'getItems' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['items'] = $data['items'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets items + * + * @return \Gr4vy\model\DigitalWallet[]|null + */ + public function getItems() + { + return $this->container['items']; + } + + /** + * Sets items + * + * @param \Gr4vy\model\DigitalWallet[]|null $items A list of registered digital wallets. + * + * @return self + */ + public function setItems($items) + { + $this->container['items'] = $items; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/Error400BadRequest.php b/lib/model/Error400BadRequest.php new file mode 100644 index 0000000..94a3fbd --- /dev/null +++ b/lib/model/Error400BadRequest.php @@ -0,0 +1,540 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class Error400BadRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'Error400BadRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'code' => 'string', + 'status' => 'int', + 'message' => 'string', + 'details' => '\Gr4vy\model\ErrorDetail[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'code' => null, + 'status' => null, + 'message' => null, + 'details' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'code' => 'code', + 'status' => 'status', + 'message' => 'message', + 'details' => 'details' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'code' => 'setCode', + 'status' => 'setStatus', + 'message' => 'setMessage', + 'details' => 'setDetails' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'code' => 'getCode', + 'status' => 'getStatus', + 'message' => 'getMessage', + 'details' => 'getDetails' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_ERROR = 'error'; + public const CODE_BAD_REQUEST = 'bad_request'; + public const STATUS_400 = 400; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_ERROR, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getCodeAllowableValues() + { + return [ + self::CODE_BAD_REQUEST, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStatusAllowableValues() + { + return [ + self::STATUS_400, + ]; + } + + /** + * 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['type'] = $data['type'] ?? null; + $this->container['code'] = $data['code'] ?? null; + $this->container['status'] = $data['status'] ?? null; + $this->container['message'] = $data['message'] ?? null; + $this->container['details'] = $data['details'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getCodeAllowableValues(); + if (!is_null($this->container['code']) && !in_array($this->container['code'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'code', must be one of '%s'", + $this->container['code'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($this->container['status']) && !in_array($this->container['status'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'status', must be one of '%s'", + $this->container['status'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type `error`. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets code + * + * @return string|null + */ + public function getCode() + { + return $this->container['code']; + } + + /** + * Sets code + * + * @param string|null $code `bad_request`. + * + * @return self + */ + public function setCode($code) + { + $allowedValues = $this->getCodeAllowableValues(); + if (!is_null($code) && !in_array($code, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'code', must be one of '%s'", + $code, + implode("', '", $allowedValues) + ) + ); + } + $this->container['code'] = $code; + + return $this; + } + + /** + * Gets status + * + * @return int|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param int|null $status `400`. + * + * @return self + */ + public function setStatus($status) + { + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($status) && !in_array($status, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'status', must be one of '%s'", + $status, + implode("', '", $allowedValues) + ) + ); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets message + * + * @return string|null + */ + public function getMessage() + { + return $this->container['message']; + } + + /** + * Sets message + * + * @param string|null $message Describes the fields that are missing or incorrectly formatted in the API request. + * + * @return self + */ + public function setMessage($message) + { + $this->container['message'] = $message; + + return $this; + } + + /** + * Gets details + * + * @return \Gr4vy\model\ErrorDetail[]|null + */ + public function getDetails() + { + return $this->container['details']; + } + + /** + * Sets details + * + * @param \Gr4vy\model\ErrorDetail[]|null $details A list of detail objects that further clarify the reason for the error. + * + * @return self + */ + public function setDetails($details) + { + $this->container['details'] = $details; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/Error400IncorrectJson.php b/lib/model/Error400IncorrectJson.php new file mode 100644 index 0000000..cae3474 --- /dev/null +++ b/lib/model/Error400IncorrectJson.php @@ -0,0 +1,540 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class Error400IncorrectJson implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'Error400IncorrectJson'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'code' => 'string', + 'status' => 'int', + 'message' => 'string', + 'details' => '\Gr4vy\model\ErrorDetail[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'code' => null, + 'status' => null, + 'message' => null, + 'details' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'code' => 'code', + 'status' => 'status', + 'message' => 'message', + 'details' => 'details' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'code' => 'setCode', + 'status' => 'setStatus', + 'message' => 'setMessage', + 'details' => 'setDetails' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'code' => 'getCode', + 'status' => 'getStatus', + 'message' => 'getMessage', + 'details' => 'getDetails' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_ERROR = 'error'; + public const CODE_INCORRECT_JSON = 'incorrect_json'; + public const STATUS_400 = 400; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_ERROR, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getCodeAllowableValues() + { + return [ + self::CODE_INCORRECT_JSON, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStatusAllowableValues() + { + return [ + self::STATUS_400, + ]; + } + + /** + * 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['type'] = $data['type'] ?? null; + $this->container['code'] = $data['code'] ?? null; + $this->container['status'] = $data['status'] ?? null; + $this->container['message'] = $data['message'] ?? null; + $this->container['details'] = $data['details'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getCodeAllowableValues(); + if (!is_null($this->container['code']) && !in_array($this->container['code'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'code', must be one of '%s'", + $this->container['code'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($this->container['status']) && !in_array($this->container['status'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'status', must be one of '%s'", + $this->container['status'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type `error`. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets code + * + * @return string|null + */ + public function getCode() + { + return $this->container['code']; + } + + /** + * Sets code + * + * @param string|null $code `incorrect_json`. + * + * @return self + */ + public function setCode($code) + { + $allowedValues = $this->getCodeAllowableValues(); + if (!is_null($code) && !in_array($code, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'code', must be one of '%s'", + $code, + implode("', '", $allowedValues) + ) + ); + } + $this->container['code'] = $code; + + return $this; + } + + /** + * Gets status + * + * @return int|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param int|null $status `400`. + * + * @return self + */ + public function setStatus($status) + { + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($status) && !in_array($status, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'status', must be one of '%s'", + $status, + implode("', '", $allowedValues) + ) + ); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets message + * + * @return string|null + */ + public function getMessage() + { + return $this->container['message']; + } + + /** + * Sets message + * + * @param string|null $message Incorrect JSON. The request body could not be parsed as valid JSON. + * + * @return self + */ + public function setMessage($message) + { + $this->container['message'] = $message; + + return $this; + } + + /** + * Gets details + * + * @return \Gr4vy\model\ErrorDetail[]|null + */ + public function getDetails() + { + return $this->container['details']; + } + + /** + * Sets details + * + * @param \Gr4vy\model\ErrorDetail[]|null $details A list of detail objects that further clarify the reason for the error. Not every error supports more detail. + * + * @return self + */ + public function setDetails($details) + { + $this->container['details'] = $details; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/Error400InvalidCredentials.php b/lib/model/Error400InvalidCredentials.php new file mode 100644 index 0000000..3ee1def --- /dev/null +++ b/lib/model/Error400InvalidCredentials.php @@ -0,0 +1,510 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class Error400InvalidCredentials implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'Error400InvalidCredentials'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'code' => 'string', + 'status' => 'int', + 'message' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'code' => null, + 'status' => null, + 'message' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'code' => 'code', + 'status' => 'status', + 'message' => 'message' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'code' => 'setCode', + 'status' => 'setStatus', + 'message' => 'setMessage' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'code' => 'getCode', + 'status' => 'getStatus', + 'message' => 'getMessage' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_ERROR = 'error'; + public const CODE_INVALID_CREDENTIALS = 'invalid_credentials'; + public const STATUS_400 = 400; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_ERROR, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getCodeAllowableValues() + { + return [ + self::CODE_INVALID_CREDENTIALS, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStatusAllowableValues() + { + return [ + self::STATUS_400, + ]; + } + + /** + * 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['type'] = $data['type'] ?? null; + $this->container['code'] = $data['code'] ?? null; + $this->container['status'] = $data['status'] ?? null; + $this->container['message'] = $data['message'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getCodeAllowableValues(); + if (!is_null($this->container['code']) && !in_array($this->container['code'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'code', must be one of '%s'", + $this->container['code'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($this->container['status']) && !in_array($this->container['status'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'status', must be one of '%s'", + $this->container['status'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type `error`. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets code + * + * @return string|null + */ + public function getCode() + { + return $this->container['code']; + } + + /** + * Sets code + * + * @param string|null $code `invalid_credentials`. + * + * @return self + */ + public function setCode($code) + { + $allowedValues = $this->getCodeAllowableValues(); + if (!is_null($code) && !in_array($code, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'code', must be one of '%s'", + $code, + implode("', '", $allowedValues) + ) + ); + } + $this->container['code'] = $code; + + return $this; + } + + /** + * Gets status + * + * @return int|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param int|null $status `400`. + * + * @return self + */ + public function setStatus($status) + { + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($status) && !in_array($status, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'status', must be one of '%s'", + $status, + implode("', '", $allowedValues) + ) + ); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets message + * + * @return string|null + */ + public function getMessage() + { + return $this->container['message']; + } + + /** + * Sets message + * + * @param string|null $message The provided credentials are invalid. + * + * @return self + */ + public function setMessage($message) + { + $this->container['message'] = $message; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/Error401Unauthorized.php b/lib/model/Error401Unauthorized.php new file mode 100644 index 0000000..1176282 --- /dev/null +++ b/lib/model/Error401Unauthorized.php @@ -0,0 +1,572 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class Error401Unauthorized implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'Error401Unauthorized'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'code' => 'string', + 'status' => 'int', + 'message' => 'string', + 'details' => '\Gr4vy\model\ErrorDetail[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'code' => null, + 'status' => null, + 'message' => null, + 'details' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'code' => 'code', + 'status' => 'status', + 'message' => 'message', + 'details' => 'details' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'code' => 'setCode', + 'status' => 'setStatus', + 'message' => 'setMessage', + 'details' => 'setDetails' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'code' => 'getCode', + 'status' => 'getStatus', + 'message' => 'getMessage', + 'details' => 'getDetails' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_ERROR = 'error'; + public const CODE_UNAUTHORIZED = 'unauthorized'; + public const STATUS_401 = 401; + public const MESSAGE_NO_VALID_API_AUTHENTICATION_FOUND = 'No valid API authentication found'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_ERROR, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getCodeAllowableValues() + { + return [ + self::CODE_UNAUTHORIZED, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStatusAllowableValues() + { + return [ + self::STATUS_401, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getMessageAllowableValues() + { + return [ + self::MESSAGE_NO_VALID_API_AUTHENTICATION_FOUND, + ]; + } + + /** + * 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['type'] = $data['type'] ?? null; + $this->container['code'] = $data['code'] ?? null; + $this->container['status'] = $data['status'] ?? null; + $this->container['message'] = $data['message'] ?? null; + $this->container['details'] = $data['details'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getCodeAllowableValues(); + if (!is_null($this->container['code']) && !in_array($this->container['code'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'code', must be one of '%s'", + $this->container['code'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($this->container['status']) && !in_array($this->container['status'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'status', must be one of '%s'", + $this->container['status'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getMessageAllowableValues(); + if (!is_null($this->container['message']) && !in_array($this->container['message'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'message', must be one of '%s'", + $this->container['message'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type `error`. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets code + * + * @return string|null + */ + public function getCode() + { + return $this->container['code']; + } + + /** + * Sets code + * + * @param string|null $code `unauthorized`. + * + * @return self + */ + public function setCode($code) + { + $allowedValues = $this->getCodeAllowableValues(); + if (!is_null($code) && !in_array($code, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'code', must be one of '%s'", + $code, + implode("', '", $allowedValues) + ) + ); + } + $this->container['code'] = $code; + + return $this; + } + + /** + * Gets status + * + * @return int|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param int|null $status `401`. + * + * @return self + */ + public function setStatus($status) + { + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($status) && !in_array($status, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'status', must be one of '%s'", + $status, + implode("', '", $allowedValues) + ) + ); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets message + * + * @return string|null + */ + public function getMessage() + { + return $this->container['message']; + } + + /** + * Sets message + * + * @param string|null $message No valid API authentication found. + * + * @return self + */ + public function setMessage($message) + { + $allowedValues = $this->getMessageAllowableValues(); + if (!is_null($message) && !in_array($message, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'message', must be one of '%s'", + $message, + implode("', '", $allowedValues) + ) + ); + } + $this->container['message'] = $message; + + return $this; + } + + /** + * Gets details + * + * @return \Gr4vy\model\ErrorDetail[]|null + */ + public function getDetails() + { + return $this->container['details']; + } + + /** + * Sets details + * + * @param \Gr4vy\model\ErrorDetail[]|null $details A list of detail objects that further clarify the reason for the error. Not every error supports more detail. + * + * @return self + */ + public function setDetails($details) + { + $this->container['details'] = $details; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/Error403Forbidden.php b/lib/model/Error403Forbidden.php new file mode 100644 index 0000000..eb58dba --- /dev/null +++ b/lib/model/Error403Forbidden.php @@ -0,0 +1,572 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class Error403Forbidden implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'Error403Forbidden'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'code' => 'string', + 'status' => 'int', + 'message' => 'string', + 'details' => '\Gr4vy\model\ErrorDetail[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'code' => null, + 'status' => null, + 'message' => null, + 'details' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'code' => 'code', + 'status' => 'status', + 'message' => 'message', + 'details' => 'details' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'code' => 'setCode', + 'status' => 'setStatus', + 'message' => 'setMessage', + 'details' => 'setDetails' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'code' => 'getCode', + 'status' => 'getStatus', + 'message' => 'getMessage', + 'details' => 'getDetails' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_ERROR = 'error'; + public const CODE_FORBIDDEN = 'forbidden'; + public const STATUS_403 = 403; + public const MESSAGE_INVALID_CREDENTIALS = 'Invalid credentials'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_ERROR, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getCodeAllowableValues() + { + return [ + self::CODE_FORBIDDEN, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStatusAllowableValues() + { + return [ + self::STATUS_403, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getMessageAllowableValues() + { + return [ + self::MESSAGE_INVALID_CREDENTIALS, + ]; + } + + /** + * 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['type'] = $data['type'] ?? null; + $this->container['code'] = $data['code'] ?? null; + $this->container['status'] = $data['status'] ?? null; + $this->container['message'] = $data['message'] ?? null; + $this->container['details'] = $data['details'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getCodeAllowableValues(); + if (!is_null($this->container['code']) && !in_array($this->container['code'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'code', must be one of '%s'", + $this->container['code'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($this->container['status']) && !in_array($this->container['status'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'status', must be one of '%s'", + $this->container['status'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getMessageAllowableValues(); + if (!is_null($this->container['message']) && !in_array($this->container['message'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'message', must be one of '%s'", + $this->container['message'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type `error`. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets code + * + * @return string|null + */ + public function getCode() + { + return $this->container['code']; + } + + /** + * Sets code + * + * @param string|null $code `forbidden`. + * + * @return self + */ + public function setCode($code) + { + $allowedValues = $this->getCodeAllowableValues(); + if (!is_null($code) && !in_array($code, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'code', must be one of '%s'", + $code, + implode("', '", $allowedValues) + ) + ); + } + $this->container['code'] = $code; + + return $this; + } + + /** + * Gets status + * + * @return int|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param int|null $status `403`. + * + * @return self + */ + public function setStatus($status) + { + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($status) && !in_array($status, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'status', must be one of '%s'", + $status, + implode("', '", $allowedValues) + ) + ); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets message + * + * @return string|null + */ + public function getMessage() + { + return $this->container['message']; + } + + /** + * Sets message + * + * @param string|null $message Invalid credentials. + * + * @return self + */ + public function setMessage($message) + { + $allowedValues = $this->getMessageAllowableValues(); + if (!is_null($message) && !in_array($message, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'message', must be one of '%s'", + $message, + implode("', '", $allowedValues) + ) + ); + } + $this->container['message'] = $message; + + return $this; + } + + /** + * Gets details + * + * @return \Gr4vy\model\ErrorDetail[]|null + */ + public function getDetails() + { + return $this->container['details']; + } + + /** + * Sets details + * + * @param \Gr4vy\model\ErrorDetail[]|null $details A list of detail objects that further clarify the reason for the error. Not every error supports more detail. + * + * @return self + */ + public function setDetails($details) + { + $this->container['details'] = $details; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/Error404NotFound.php b/lib/model/Error404NotFound.php new file mode 100644 index 0000000..d98963c --- /dev/null +++ b/lib/model/Error404NotFound.php @@ -0,0 +1,572 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class Error404NotFound implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'Error404NotFound'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'code' => 'string', + 'status' => 'int', + 'message' => 'string', + 'details' => '\Gr4vy\model\ErrorDetail[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'code' => null, + 'status' => null, + 'message' => null, + 'details' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'code' => 'code', + 'status' => 'status', + 'message' => 'message', + 'details' => 'details' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'code' => 'setCode', + 'status' => 'setStatus', + 'message' => 'setMessage', + 'details' => 'setDetails' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'code' => 'getCode', + 'status' => 'getStatus', + 'message' => 'getMessage', + 'details' => 'getDetails' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_ERROR = 'error'; + public const CODE_NOT_FOUND = 'not_found'; + public const STATUS_404 = 404; + public const MESSAGE_THE_RESOURCE_COULD_NOT_BE_FOUND = 'The resource could not be found'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_ERROR, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getCodeAllowableValues() + { + return [ + self::CODE_NOT_FOUND, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStatusAllowableValues() + { + return [ + self::STATUS_404, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getMessageAllowableValues() + { + return [ + self::MESSAGE_THE_RESOURCE_COULD_NOT_BE_FOUND, + ]; + } + + /** + * 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['type'] = $data['type'] ?? null; + $this->container['code'] = $data['code'] ?? null; + $this->container['status'] = $data['status'] ?? null; + $this->container['message'] = $data['message'] ?? null; + $this->container['details'] = $data['details'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getCodeAllowableValues(); + if (!is_null($this->container['code']) && !in_array($this->container['code'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'code', must be one of '%s'", + $this->container['code'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($this->container['status']) && !in_array($this->container['status'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'status', must be one of '%s'", + $this->container['status'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getMessageAllowableValues(); + if (!is_null($this->container['message']) && !in_array($this->container['message'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'message', must be one of '%s'", + $this->container['message'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type `error`. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets code + * + * @return string|null + */ + public function getCode() + { + return $this->container['code']; + } + + /** + * Sets code + * + * @param string|null $code `not_found`. + * + * @return self + */ + public function setCode($code) + { + $allowedValues = $this->getCodeAllowableValues(); + if (!is_null($code) && !in_array($code, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'code', must be one of '%s'", + $code, + implode("', '", $allowedValues) + ) + ); + } + $this->container['code'] = $code; + + return $this; + } + + /** + * Gets status + * + * @return int|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param int|null $status `404`. + * + * @return self + */ + public function setStatus($status) + { + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($status) && !in_array($status, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'status', must be one of '%s'", + $status, + implode("', '", $allowedValues) + ) + ); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets message + * + * @return string|null + */ + public function getMessage() + { + return $this->container['message']; + } + + /** + * Sets message + * + * @param string|null $message The resource could not be found. + * + * @return self + */ + public function setMessage($message) + { + $allowedValues = $this->getMessageAllowableValues(); + if (!is_null($message) && !in_array($message, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'message', must be one of '%s'", + $message, + implode("', '", $allowedValues) + ) + ); + } + $this->container['message'] = $message; + + return $this; + } + + /** + * Gets details + * + * @return \Gr4vy\model\ErrorDetail[]|null + */ + public function getDetails() + { + return $this->container['details']; + } + + /** + * Sets details + * + * @param \Gr4vy\model\ErrorDetail[]|null $details A list of detail objects that further clarify the reason for the error. Not every error supports more detail. + * + * @return self + */ + public function setDetails($details) + { + $this->container['details'] = $details; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/Error404PendingCreation.php b/lib/model/Error404PendingCreation.php new file mode 100644 index 0000000..ab62f0d --- /dev/null +++ b/lib/model/Error404PendingCreation.php @@ -0,0 +1,572 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class Error404PendingCreation implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'Error404PendingCreation'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'code' => 'string', + 'status' => 'int', + 'message' => 'string', + 'details' => '\Gr4vy\model\ErrorDetail[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'code' => null, + 'status' => null, + 'message' => null, + 'details' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'code' => 'code', + 'status' => 'status', + 'message' => 'message', + 'details' => 'details' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'code' => 'setCode', + 'status' => 'setStatus', + 'message' => 'setMessage', + 'details' => 'setDetails' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'code' => 'getCode', + 'status' => 'getStatus', + 'message' => 'getMessage', + 'details' => 'getDetails' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_ERROR = 'error'; + public const CODE_PENDING_CREATION = 'pending_creation'; + public const STATUS_404 = 404; + public const MESSAGE_THE_RESOURCE_IS_STILL_PENDING = 'The resource is still pending'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_ERROR, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getCodeAllowableValues() + { + return [ + self::CODE_PENDING_CREATION, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStatusAllowableValues() + { + return [ + self::STATUS_404, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getMessageAllowableValues() + { + return [ + self::MESSAGE_THE_RESOURCE_IS_STILL_PENDING, + ]; + } + + /** + * 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['type'] = $data['type'] ?? null; + $this->container['code'] = $data['code'] ?? null; + $this->container['status'] = $data['status'] ?? null; + $this->container['message'] = $data['message'] ?? null; + $this->container['details'] = $data['details'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getCodeAllowableValues(); + if (!is_null($this->container['code']) && !in_array($this->container['code'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'code', must be one of '%s'", + $this->container['code'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($this->container['status']) && !in_array($this->container['status'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'status', must be one of '%s'", + $this->container['status'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getMessageAllowableValues(); + if (!is_null($this->container['message']) && !in_array($this->container['message'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'message', must be one of '%s'", + $this->container['message'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type `error`. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets code + * + * @return string|null + */ + public function getCode() + { + return $this->container['code']; + } + + /** + * Sets code + * + * @param string|null $code `pending_creation`. + * + * @return self + */ + public function setCode($code) + { + $allowedValues = $this->getCodeAllowableValues(); + if (!is_null($code) && !in_array($code, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'code', must be one of '%s'", + $code, + implode("', '", $allowedValues) + ) + ); + } + $this->container['code'] = $code; + + return $this; + } + + /** + * Gets status + * + * @return int|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param int|null $status `404`. + * + * @return self + */ + public function setStatus($status) + { + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($status) && !in_array($status, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'status', must be one of '%s'", + $status, + implode("', '", $allowedValues) + ) + ); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets message + * + * @return string|null + */ + public function getMessage() + { + return $this->container['message']; + } + + /** + * Sets message + * + * @param string|null $message The resource is still pending. + * + * @return self + */ + public function setMessage($message) + { + $allowedValues = $this->getMessageAllowableValues(); + if (!is_null($message) && !in_array($message, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'message', must be one of '%s'", + $message, + implode("', '", $allowedValues) + ) + ); + } + $this->container['message'] = $message; + + return $this; + } + + /** + * Gets details + * + * @return \Gr4vy\model\ErrorDetail[]|null + */ + public function getDetails() + { + return $this->container['details']; + } + + /** + * Sets details + * + * @param \Gr4vy\model\ErrorDetail[]|null $details A list of detail objects that further clarify the reason for the error. Not every error supports more detail. + * + * @return self + */ + public function setDetails($details) + { + $this->container['details'] = $details; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/Error409DuplicateRecord.php b/lib/model/Error409DuplicateRecord.php new file mode 100644 index 0000000..c2c29b7 --- /dev/null +++ b/lib/model/Error409DuplicateRecord.php @@ -0,0 +1,540 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class Error409DuplicateRecord implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'Error409DuplicateRecord'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'code' => 'string', + 'status' => 'int', + 'message' => 'string', + 'details' => '\Gr4vy\model\ErrorDetail[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'code' => null, + 'status' => null, + 'message' => null, + 'details' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'code' => 'code', + 'status' => 'status', + 'message' => 'message', + 'details' => 'details' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'code' => 'setCode', + 'status' => 'setStatus', + 'message' => 'setMessage', + 'details' => 'setDetails' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'code' => 'getCode', + 'status' => 'getStatus', + 'message' => 'getMessage', + 'details' => 'getDetails' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_ERROR = 'error'; + public const CODE_DUPLICATE_RECORD = 'duplicate_record'; + public const STATUS_409 = 409; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_ERROR, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getCodeAllowableValues() + { + return [ + self::CODE_DUPLICATE_RECORD, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStatusAllowableValues() + { + return [ + self::STATUS_409, + ]; + } + + /** + * 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['type'] = $data['type'] ?? null; + $this->container['code'] = $data['code'] ?? null; + $this->container['status'] = $data['status'] ?? null; + $this->container['message'] = $data['message'] ?? null; + $this->container['details'] = $data['details'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getCodeAllowableValues(); + if (!is_null($this->container['code']) && !in_array($this->container['code'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'code', must be one of '%s'", + $this->container['code'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($this->container['status']) && !in_array($this->container['status'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'status', must be one of '%s'", + $this->container['status'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type `error`. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets code + * + * @return string|null + */ + public function getCode() + { + return $this->container['code']; + } + + /** + * Sets code + * + * @param string|null $code `duplicate_record`. + * + * @return self + */ + public function setCode($code) + { + $allowedValues = $this->getCodeAllowableValues(); + if (!is_null($code) && !in_array($code, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'code', must be one of '%s'", + $code, + implode("', '", $allowedValues) + ) + ); + } + $this->container['code'] = $code; + + return $this; + } + + /** + * Gets status + * + * @return int|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param int|null $status `409`. + * + * @return self + */ + public function setStatus($status) + { + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($status) && !in_array($status, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'status', must be one of '%s'", + $status, + implode("', '", $allowedValues) + ) + ); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets message + * + * @return string|null + */ + public function getMessage() + { + return $this->container['message']; + } + + /** + * Sets message + * + * @param string|null $message Further details on the field that triggered the error. + * + * @return self + */ + public function setMessage($message) + { + $this->container['message'] = $message; + + return $this; + } + + /** + * Gets details + * + * @return \Gr4vy\model\ErrorDetail[]|null + */ + public function getDetails() + { + return $this->container['details']; + } + + /** + * Sets details + * + * @param \Gr4vy\model\ErrorDetail[]|null $details A list of detail objects that further clarify the reason for the error. Not every error supports more detail. + * + * @return self + */ + public function setDetails($details) + { + $this->container['details'] = $details; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/ErrorDetail.php b/lib/model/ErrorDetail.php new file mode 100644 index 0000000..dbe5075 --- /dev/null +++ b/lib/model/ErrorDetail.php @@ -0,0 +1,452 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class ErrorDetail implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ErrorDetail'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'location' => 'string', + 'type' => 'string', + 'pointer' => 'string', + 'message' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'location' => null, + 'type' => null, + 'pointer' => null, + 'message' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'location' => 'location', + 'type' => 'type', + 'pointer' => 'pointer', + 'message' => 'message' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'location' => 'setLocation', + 'type' => 'setType', + 'pointer' => 'setPointer', + 'message' => 'setMessage' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'location' => 'getLocation', + 'type' => 'getType', + 'pointer' => 'getPointer', + 'message' => 'getMessage' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const LOCATION_QUERY = 'query'; + public const LOCATION_BODY = 'body'; + public const LOCATION_PATH = 'path'; + public const LOCATION_HEADER = 'header'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getLocationAllowableValues() + { + return [ + self::LOCATION_QUERY, + self::LOCATION_BODY, + self::LOCATION_PATH, + self::LOCATION_HEADER, + ]; + } + + /** + * 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['location'] = $data['location'] ?? null; + $this->container['type'] = $data['type'] ?? null; + $this->container['pointer'] = $data['pointer'] ?? null; + $this->container['message'] = $data['message'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getLocationAllowableValues(); + if (!is_null($this->container['location']) && !in_array($this->container['location'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'location', must be one of '%s'", + $this->container['location'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets location + * + * @return string|null + */ + public function getLocation() + { + return $this->container['location']; + } + + /** + * Sets location + * + * @param string|null $location The location where the error caused an issue. + * + * @return self + */ + public function setLocation($location) + { + $allowedValues = $this->getLocationAllowableValues(); + if (!is_null($location) && !in_array($location, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'location', must be one of '%s'", + $location, + implode("', '", $allowedValues) + ) + ); + } + $this->container['location'] = $location; + + return $this; + } + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type A unique identifier for the type of error that occurred. + * + * @return self + */ + public function setType($type) + { + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets pointer + * + * @return string|null + */ + public function getPointer() + { + return $this->container['pointer']; + } + + /** + * Sets pointer + * + * @param string|null $pointer The exact item for which the validation did not succeed. This is a JSON pointer for request bodies, while for query, path, and header parameters it is the name of the parameter. + * + * @return self + */ + public function setPointer($pointer) + { + $this->container['pointer'] = $pointer; + + return $this; + } + + /** + * Gets message + * + * @return string|null + */ + public function getMessage() + { + return $this->container['message']; + } + + /** + * Sets message + * + * @param string|null $message A human readable message for this error detail. + * + * @return self + */ + public function setMessage($message) + { + $this->container['message'] = $message; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/ErrorGeneric.php b/lib/model/ErrorGeneric.php new file mode 100644 index 0000000..86cfeeb --- /dev/null +++ b/lib/model/ErrorGeneric.php @@ -0,0 +1,492 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class ErrorGeneric implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ErrorGeneric'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'code' => 'string', + 'status' => 'int', + 'message' => 'string', + 'details' => '\Gr4vy\model\ErrorDetail[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'code' => null, + 'status' => 'int32', + 'message' => null, + 'details' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'code' => 'code', + 'status' => 'status', + 'message' => 'message', + 'details' => 'details' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'code' => 'setCode', + 'status' => 'setStatus', + 'message' => 'setMessage', + 'details' => 'setDetails' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'code' => 'getCode', + 'status' => 'getStatus', + 'message' => 'getMessage', + 'details' => 'getDetails' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_ERROR = 'error'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_ERROR, + ]; + } + + /** + * 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['type'] = $data['type'] ?? 'error'; + $this->container['code'] = $data['code'] ?? null; + $this->container['status'] = $data['status'] ?? null; + $this->container['message'] = $data['message'] ?? null; + $this->container['details'] = $data['details'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + if (!is_null($this->container['status']) && ($this->container['status'] >= 600)) { + $invalidProperties[] = "invalid value for 'status', must be smaller than 600."; + } + + if (!is_null($this->container['status']) && ($this->container['status'] < 200)) { + $invalidProperties[] = "invalid value for 'status', must be bigger than or equal to 200."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type The type of this object. This is always `error`. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets code + * + * @return string|null + */ + public function getCode() + { + return $this->container['code']; + } + + /** + * Sets code + * + * @param string|null $code A custom code to further describe the type of error being returned. This code provides further specification within the HTTP `status` code and can be used by a program to define logic based on the error. + * + * @return self + */ + public function setCode($code) + { + $this->container['code'] = $code; + + return $this; + } + + /** + * Gets status + * + * @return int|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param int|null $status The HTTP status code of this error. + * + * @return self + */ + public function setStatus($status) + { + + if (!is_null($status) && ($status >= 600)) { + throw new \InvalidArgumentException('invalid value for $status when calling ErrorGeneric., must be smaller than 600.'); + } + if (!is_null($status) && ($status < 200)) { + throw new \InvalidArgumentException('invalid value for $status when calling ErrorGeneric., must be bigger than or equal to 200.'); + } + + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets message + * + * @return string|null + */ + public function getMessage() + { + return $this->container['message']; + } + + /** + * Sets message + * + * @param string|null $message A human readable message that describes the error. The content of this field should not be used to determine any business logic. + * + * @return self + */ + public function setMessage($message) + { + $this->container['message'] = $message; + + return $this; + } + + /** + * Gets details + * + * @return \Gr4vy\model\ErrorDetail[]|null + */ + public function getDetails() + { + return $this->container['details']; + } + + /** + * Sets details + * + * @param \Gr4vy\model\ErrorDetail[]|null $details A list of detail objects that further clarify the reason for the error. Not every error supports more detail. + * + * @return self + */ + public function setDetails($details) + { + $this->container['details'] = $details; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/FlowPaymentOptionOutcome.php b/lib/model/FlowPaymentOptionOutcome.php new file mode 100644 index 0000000..5d04075 --- /dev/null +++ b/lib/model/FlowPaymentOptionOutcome.php @@ -0,0 +1,506 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class FlowPaymentOptionOutcome implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'FlowPaymentOptionOutcome'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'id' => 'string', + 'label' => 'string', + 'active' => 'bool', + 'group' => 'string', + 'icon_url' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'id' => null, + 'label' => null, + 'active' => null, + 'group' => null, + 'icon_url' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'id' => 'id', + 'label' => 'label', + 'active' => 'active', + 'group' => 'group', + 'icon_url' => 'icon_url' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'id' => 'setId', + 'label' => 'setLabel', + 'active' => 'setActive', + 'group' => 'setGroup', + 'icon_url' => 'setIconUrl' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'id' => 'getId', + 'label' => 'getLabel', + 'active' => 'getActive', + 'group' => 'getGroup', + 'icon_url' => 'getIconUrl' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_ACTION = 'action'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_ACTION, + ]; + } + + /** + * 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['type'] = $data['type'] ?? null; + $this->container['id'] = $data['id'] ?? null; + $this->container['label'] = $data['label'] ?? null; + $this->container['active'] = $data['active'] ?? null; + $this->container['group'] = $data['group'] ?? null; + $this->container['icon_url'] = $data['icon_url'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type The type of this resource. Is always `action`. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Payment option identifier. + * + * @return self + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets label + * + * @return string|null + */ + public function getLabel() + { + return $this->container['label']; + } + + /** + * Sets label + * + * @param string|null $label Verbose payment option name. + * + * @return self + */ + public function setLabel($label) + { + $this->container['label'] = $label; + + return $this; + } + + /** + * Gets active + * + * @return bool|null + */ + public function getActive() + { + return $this->container['active']; + } + + /** + * Sets active + * + * @param bool|null $active The status of the payment option, true if at least one underlying connection is active, otherwise false. + * + * @return self + */ + public function setActive($active) + { + $this->container['active'] = $active; + + return $this; + } + + /** + * Gets group + * + * @return string|null + */ + public function getGroup() + { + return $this->container['group']; + } + + /** + * Sets group + * + * @param string|null $group Optional group label for a given payment option, e.g. `Bank`. + * + * @return self + */ + public function setGroup($group) + { + $this->container['group'] = $group; + + return $this; + } + + /** + * Gets icon_url + * + * @return string|null + */ + public function getIconUrl() + { + return $this->container['icon_url']; + } + + /** + * Sets icon_url + * + * @param string|null $icon_url Payment option icon URL. + * + * @return self + */ + public function setIconUrl($icon_url) + { + $this->container['icon_url'] = $icon_url; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/FlowRuleBooleanOutcome.php b/lib/model/FlowRuleBooleanOutcome.php new file mode 100644 index 0000000..38e6255 --- /dev/null +++ b/lib/model/FlowRuleBooleanOutcome.php @@ -0,0 +1,424 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class FlowRuleBooleanOutcome implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'FlowRuleBooleanOutcome'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'result' => 'bool' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'result' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_BOOLEAN = 'boolean'; + public const RESULT_TRUE = 'true'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_BOOLEAN, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getResultAllowableValues() + { + return [ + self::RESULT_TRUE, + ]; + } + + /** + * 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['type'] = $data['type'] ?? null; + $this->container['result'] = $data['result'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['type'] === null) { + $invalidProperties[] = "'type' can't be null"; + } + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['result'] === null) { + $invalidProperties[] = "'result' can't be null"; + } + $allowedValues = $this->getResultAllowableValues(); + if (!is_null($this->container['result']) && !in_array($this->container['result'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'result', must be one of '%s'", + $this->container['result'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string $type The type of action outcome for the given rule. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets result + * + * @return bool + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param bool $result Results for a given flow action. + * + * @return self + */ + public function setResult($result) + { + $allowedValues = $this->getResultAllowableValues(); + if (!in_array($result, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'result', must be one of '%s'", + $result, + implode("', '", $allowedValues) + ) + ); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/FlowRuleMethodOutcome.php b/lib/model/FlowRuleMethodOutcome.php new file mode 100644 index 0000000..b52f161 --- /dev/null +++ b/lib/model/FlowRuleMethodOutcome.php @@ -0,0 +1,462 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class FlowRuleMethodOutcome implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'FlowRuleMethodOutcome'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'result' => 'string[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'result' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE__LIST = 'list'; + public const RESULT_AFTERPAY = 'afterpay'; + public const RESULT_APPLEPAY = 'applepay'; + public const RESULT_BANKED = 'banked'; + public const RESULT_BITPAY = 'bitpay'; + public const RESULT_BOLETO = 'boleto'; + public const RESULT_CARD = 'card'; + public const RESULT_CLEARPAY = 'clearpay'; + public const RESULT_DANA = 'dana'; + public const RESULT_FORTUMO = 'fortumo'; + public const RESULT_GCASH = 'gcash'; + public const RESULT_GOCARDLESS = 'gocardless'; + public const RESULT_GOOGLEPAY = 'googlepay'; + public const RESULT_GRABPAY = 'grabpay'; + public const RESULT_KLARNA = 'klarna'; + public const RESULT_OVO = 'ovo'; + public const RESULT_PAYMAYA = 'paymaya'; + public const RESULT_PAYPAL = 'paypal'; + public const RESULT_PIX = 'pix'; + public const RESULT_RABBITLINEPAY = 'rabbitlinepay'; + public const RESULT_SCALAPAY = 'scalapay'; + public const RESULT_SHOPEEPAY = 'shopeepay'; + public const RESULT_STRIPEDD = 'stripedd'; + public const RESULT_TRUEMONEY = 'truemoney'; + public const RESULT_TRUSTLY = 'trustly'; + public const RESULT_ZIPPAY = 'zippay'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE__LIST, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getResultAllowableValues() + { + return [ + self::RESULT_AFTERPAY, + self::RESULT_APPLEPAY, + self::RESULT_BANKED, + self::RESULT_BITPAY, + self::RESULT_BOLETO, + self::RESULT_CARD, + self::RESULT_CLEARPAY, + self::RESULT_DANA, + self::RESULT_FORTUMO, + self::RESULT_GCASH, + self::RESULT_GOCARDLESS, + self::RESULT_GOOGLEPAY, + self::RESULT_GRABPAY, + self::RESULT_KLARNA, + self::RESULT_OVO, + self::RESULT_PAYMAYA, + self::RESULT_PAYPAL, + self::RESULT_PIX, + self::RESULT_RABBITLINEPAY, + self::RESULT_SCALAPAY, + self::RESULT_SHOPEEPAY, + self::RESULT_STRIPEDD, + self::RESULT_TRUEMONEY, + self::RESULT_TRUSTLY, + self::RESULT_ZIPPAY, + ]; + } + + /** + * 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['type'] = $data['type'] ?? null; + $this->container['result'] = $data['result'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['type'] === null) { + $invalidProperties[] = "'type' can't be null"; + } + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['result'] === null) { + $invalidProperties[] = "'result' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string $type The type of action outcome for the given rule. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets result + * + * @return string[] + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param string[] $result Results for a given flow action. + * + * @return self + */ + public function setResult($result) + { + $allowedValues = $this->getResultAllowableValues(); + if (array_diff($result, $allowedValues)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for 'result', must be one of '%s'", + implode("', '", $allowedValues) + ) + ); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/FlowRuleServiceOutcome.php b/lib/model/FlowRuleServiceOutcome.php new file mode 100644 index 0000000..dcc5dbd --- /dev/null +++ b/lib/model/FlowRuleServiceOutcome.php @@ -0,0 +1,392 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class FlowRuleServiceOutcome implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'FlowRuleServiceOutcome'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'result' => 'string[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'result' => 'uuid' + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE__LIST = 'list'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE__LIST, + ]; + } + + /** + * 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['type'] = $data['type'] ?? null; + $this->container['result'] = $data['result'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['type'] === null) { + $invalidProperties[] = "'type' can't be null"; + } + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['result'] === null) { + $invalidProperties[] = "'result' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string $type The type of action outcome for the given rule. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets result + * + * @return string[] + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param string[] $result Results for a given flow action. + * + * @return self + */ + public function setResult($result) + { + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/GooglePayRequest.php b/lib/model/GooglePayRequest.php new file mode 100644 index 0000000..6441454 --- /dev/null +++ b/lib/model/GooglePayRequest.php @@ -0,0 +1,392 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class GooglePayRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GooglePayRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'method' => 'string', + 'token' => 'object' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'method' => null, + 'token' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'method' => 'method', + 'token' => 'token' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'method' => 'setMethod', + 'token' => 'setToken' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'method' => 'getMethod', + 'token' => 'getToken' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const METHOD_GOOGLEPAY = 'googlepay'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getMethodAllowableValues() + { + return [ + self::METHOD_GOOGLEPAY, + ]; + } + + /** + * 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['method'] = $data['method'] ?? null; + $this->container['token'] = $data['token'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['method'] === null) { + $invalidProperties[] = "'method' can't be null"; + } + $allowedValues = $this->getMethodAllowableValues(); + if (!is_null($this->container['method']) && !in_array($this->container['method'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'method', must be one of '%s'", + $this->container['method'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['token'] === null) { + $invalidProperties[] = "'token' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets method + * + * @return string + */ + public function getMethod() + { + return $this->container['method']; + } + + /** + * Sets method + * + * @param string $method `googlepay`. + * + * @return self + */ + public function setMethod($method) + { + $allowedValues = $this->getMethodAllowableValues(); + if (!in_array($method, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'method', must be one of '%s'", + $method, + implode("', '", $allowedValues) + ) + ); + } + $this->container['method'] = $method; + + return $this; + } + + /** + * Gets token + * + * @return object + */ + public function getToken() + { + return $this->container['token']; + } + + /** + * Sets token + * + * @param object $token The encrypted (opaque) token returned by the Google Pay API that represents a payment method. + * + * @return self + */ + public function setToken($token) + { + $this->container['token'] = $token; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/GooglePaySessionRequest.php b/lib/model/GooglePaySessionRequest.php new file mode 100644 index 0000000..c828a8c --- /dev/null +++ b/lib/model/GooglePaySessionRequest.php @@ -0,0 +1,327 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class GooglePaySessionRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GooglePaySessionRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'origin_domain' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'origin_domain' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'origin_domain' => 'origin_domain' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'origin_domain' => 'setOriginDomain' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'origin_domain' => 'getOriginDomain' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['origin_domain'] = $data['origin_domain'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['origin_domain'] === null) { + $invalidProperties[] = "'origin_domain' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets origin_domain + * + * @return string + */ + public function getOriginDomain() + { + return $this->container['origin_domain']; + } + + /** + * Sets origin_domain + * + * @param string $origin_domain Fully qualified domain name of the merchant. + * + * @return self + */ + public function setOriginDomain($origin_domain) + { + $this->container['origin_domain'] = $origin_domain; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/ModelInterface.php b/lib/model/ModelInterface.php new file mode 100644 index 0000000..d96e3df --- /dev/null +++ b/lib/model/ModelInterface.php @@ -0,0 +1,96 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class PaymentMethod implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PaymentMethod'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'id' => 'string', + 'status' => 'string', + 'method' => 'string', + 'mode' => 'string', + 'created_at' => '\DateTime', + 'updated_at' => '\DateTime', + 'external_identifier' => 'string', + 'buyer' => '\Gr4vy\model\PaymentMethodBuyer', + 'label' => 'string', + 'scheme' => 'string', + 'expiration_date' => 'string', + 'approval_target' => 'string', + 'approval_url' => 'string', + 'currency' => 'string', + 'country' => 'string', + 'details' => '\Gr4vy\model\PaymentMethodDetailsCard' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'id' => 'uuid', + 'status' => null, + 'method' => null, + 'mode' => null, + 'created_at' => 'date-time', + 'updated_at' => 'date-time', + 'external_identifier' => null, + 'buyer' => null, + 'label' => null, + 'scheme' => null, + 'expiration_date' => null, + 'approval_target' => null, + 'approval_url' => null, + 'currency' => null, + 'country' => null, + 'details' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'id' => 'id', + 'status' => 'status', + 'method' => 'method', + 'mode' => 'mode', + 'created_at' => 'created_at', + 'updated_at' => 'updated_at', + 'external_identifier' => 'external_identifier', + 'buyer' => 'buyer', + 'label' => 'label', + 'scheme' => 'scheme', + 'expiration_date' => 'expiration_date', + 'approval_target' => 'approval_target', + 'approval_url' => 'approval_url', + 'currency' => 'currency', + 'country' => 'country', + 'details' => 'details' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'id' => 'setId', + 'status' => 'setStatus', + 'method' => 'setMethod', + 'mode' => 'setMode', + 'created_at' => 'setCreatedAt', + 'updated_at' => 'setUpdatedAt', + 'external_identifier' => 'setExternalIdentifier', + 'buyer' => 'setBuyer', + 'label' => 'setLabel', + 'scheme' => 'setScheme', + 'expiration_date' => 'setExpirationDate', + 'approval_target' => 'setApprovalTarget', + 'approval_url' => 'setApprovalUrl', + 'currency' => 'setCurrency', + 'country' => 'setCountry', + 'details' => 'setDetails' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'id' => 'getId', + 'status' => 'getStatus', + 'method' => 'getMethod', + 'mode' => 'getMode', + 'created_at' => 'getCreatedAt', + 'updated_at' => 'getUpdatedAt', + 'external_identifier' => 'getExternalIdentifier', + 'buyer' => 'getBuyer', + 'label' => 'getLabel', + 'scheme' => 'getScheme', + 'expiration_date' => 'getExpirationDate', + 'approval_target' => 'getApprovalTarget', + 'approval_url' => 'getApprovalUrl', + 'currency' => 'getCurrency', + 'country' => 'getCountry', + 'details' => 'getDetails' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_PAYMENT_METHOD = 'payment-method'; + public const STATUS_PROCESSING = 'processing'; + public const STATUS_BUYER_APPROVAL_REQUIRED = 'buyer_approval_required'; + public const STATUS_SUCCEEDED = 'succeeded'; + public const STATUS_FAILED = 'failed'; + public const APPROVAL_TARGET_ANY = 'any'; + public const APPROVAL_TARGET_NEW_WINDOW = 'new_window'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_PAYMENT_METHOD, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStatusAllowableValues() + { + return [ + self::STATUS_PROCESSING, + self::STATUS_BUYER_APPROVAL_REQUIRED, + self::STATUS_SUCCEEDED, + self::STATUS_FAILED, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getApprovalTargetAllowableValues() + { + return [ + self::APPROVAL_TARGET_ANY, + self::APPROVAL_TARGET_NEW_WINDOW, + ]; + } + + /** + * 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['type'] = $data['type'] ?? null; + $this->container['id'] = $data['id'] ?? null; + $this->container['status'] = $data['status'] ?? null; + $this->container['method'] = $data['method'] ?? null; + $this->container['mode'] = $data['mode'] ?? null; + $this->container['created_at'] = $data['created_at'] ?? null; + $this->container['updated_at'] = $data['updated_at'] ?? null; + $this->container['external_identifier'] = $data['external_identifier'] ?? null; + $this->container['buyer'] = $data['buyer'] ?? null; + $this->container['label'] = $data['label'] ?? null; + $this->container['scheme'] = $data['scheme'] ?? null; + $this->container['expiration_date'] = $data['expiration_date'] ?? null; + $this->container['approval_target'] = $data['approval_target'] ?? null; + $this->container['approval_url'] = $data['approval_url'] ?? null; + $this->container['currency'] = $data['currency'] ?? null; + $this->container['country'] = $data['country'] ?? null; + $this->container['details'] = $data['details'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($this->container['status']) && !in_array($this->container['status'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'status', must be one of '%s'", + $this->container['status'], + implode("', '", $allowedValues) + ); + } + + if (!is_null($this->container['expiration_date']) && (mb_strlen($this->container['expiration_date']) > 5)) { + $invalidProperties[] = "invalid value for 'expiration_date', the character length must be smaller than or equal to 5."; + } + + if (!is_null($this->container['expiration_date']) && (mb_strlen($this->container['expiration_date']) < 5)) { + $invalidProperties[] = "invalid value for 'expiration_date', the character length must be bigger than or equal to 5."; + } + + if (!is_null($this->container['expiration_date']) && !preg_match("/^\\d{2}\/\\d{2}$/", $this->container['expiration_date'])) { + $invalidProperties[] = "invalid value for 'expiration_date', must be conform to the pattern /^\\d{2}\/\\d{2}$/."; + } + + $allowedValues = $this->getApprovalTargetAllowableValues(); + if (!is_null($this->container['approval_target']) && !in_array($this->container['approval_target'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'approval_target', must be one of '%s'", + $this->container['approval_target'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type `payment-method`. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id The unique ID of the payment method. + * + * @return self + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets status + * + * @return string|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param string|null $status The state of the payment method. - `processing` - The payment method is still being stored. - `buyer_approval_required` - Storing the payment method requires the buyer to provide approval. Follow the `approval_url` for next steps. - `succeeded` - The payment method is approved and stored with all relevant payment services. - `failed` - Storing the payment method did not succeed. + * + * @return self + */ + public function setStatus($status) + { + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($status) && !in_array($status, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'status', must be one of '%s'", + $status, + implode("', '", $allowedValues) + ) + ); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets method + * + * @return string|null + */ + public function getMethod() + { + return $this->container['method']; + } + + /** + * Sets method + * + * @param string|null $method method + * + * @return self + */ + public function setMethod($method) + { + $this->container['method'] = $method; + + return $this; + } + + /** + * Gets mode + * + * @return string|null + */ + public function getMode() + { + return $this->container['mode']; + } + + /** + * Sets mode + * + * @param string|null $mode mode + * + * @return self + */ + public function setMode($mode) + { + $this->container['mode'] = $mode; + + return $this; + } + + /** + * Gets created_at + * + * @return \DateTime|null + */ + public function getCreatedAt() + { + return $this->container['created_at']; + } + + /** + * Sets created_at + * + * @param \DateTime|null $created_at The date and time when this payment method was first created in our system. + * + * @return self + */ + public function setCreatedAt($created_at) + { + $this->container['created_at'] = $created_at; + + return $this; + } + + /** + * Gets updated_at + * + * @return \DateTime|null + */ + public function getUpdatedAt() + { + return $this->container['updated_at']; + } + + /** + * Sets updated_at + * + * @param \DateTime|null $updated_at The date and time when this payment method was last updated in our system. + * + * @return self + */ + public function setUpdatedAt($updated_at) + { + $this->container['updated_at'] = $updated_at; + + return $this; + } + + /** + * Gets external_identifier + * + * @return string|null + */ + public function getExternalIdentifier() + { + return $this->container['external_identifier']; + } + + /** + * Sets external_identifier + * + * @param string|null $external_identifier An external identifier that can be used to match the payment method against your own records. + * + * @return self + */ + public function setExternalIdentifier($external_identifier) + { + $this->container['external_identifier'] = $external_identifier; + + return $this; + } + + /** + * Gets buyer + * + * @return \Gr4vy\model\PaymentMethodBuyer|null + */ + public function getBuyer() + { + return $this->container['buyer']; + } + + /** + * Sets buyer + * + * @param \Gr4vy\model\PaymentMethodBuyer|null $buyer buyer + * + * @return self + */ + public function setBuyer($buyer) + { + $this->container['buyer'] = $buyer; + + return $this; + } + + /** + * Gets label + * + * @return string|null + */ + public function getLabel() + { + return $this->container['label']; + } + + /** + * Sets label + * + * @param string|null $label A label for the card or the account. For a `paypal` payment method this is the user's email address. For a card it is the last 4 digits of the card. + * + * @return self + */ + public function setLabel($label) + { + $this->container['label'] = $label; + + return $this; + } + + /** + * Gets scheme + * + * @return string|null + */ + public function getScheme() + { + return $this->container['scheme']; + } + + /** + * Sets scheme + * + * @param string|null $scheme The scheme of the card. Only applies to card payments. + * + * @return self + */ + public function setScheme($scheme) + { + $this->container['scheme'] = $scheme; + + return $this; + } + + /** + * Gets expiration_date + * + * @return string|null + */ + public function getExpirationDate() + { + return $this->container['expiration_date']; + } + + /** + * Sets expiration_date + * + * @param string|null $expiration_date The expiration date for the payment method. + * + * @return self + */ + public function setExpirationDate($expiration_date) + { + if (!is_null($expiration_date) && (mb_strlen($expiration_date) > 5)) { + throw new \InvalidArgumentException('invalid length for $expiration_date when calling PaymentMethod., must be smaller than or equal to 5.'); + } + if (!is_null($expiration_date) && (mb_strlen($expiration_date) < 5)) { + throw new \InvalidArgumentException('invalid length for $expiration_date when calling PaymentMethod., must be bigger than or equal to 5.'); + } + if (!is_null($expiration_date) && (!preg_match("/^\\d{2}\/\\d{2}$/", $expiration_date))) { + throw new \InvalidArgumentException("invalid value for $expiration_date when calling PaymentMethod., must conform to the pattern /^\\d{2}\/\\d{2}$/."); + } + + $this->container['expiration_date'] = $expiration_date; + + return $this; + } + + /** + * Gets approval_target + * + * @return string|null + */ + public function getApprovalTarget() + { + return $this->container['approval_target']; + } + + /** + * Sets approval_target + * + * @param string|null $approval_target The browser target that an approval URL must be opened in. If `any` or `null`, then there is no specific requirement. + * + * @return self + */ + public function setApprovalTarget($approval_target) + { + $allowedValues = $this->getApprovalTargetAllowableValues(); + if (!is_null($approval_target) && !in_array($approval_target, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'approval_target', must be one of '%s'", + $approval_target, + implode("', '", $allowedValues) + ) + ); + } + $this->container['approval_target'] = $approval_target; + + return $this; + } + + /** + * Gets approval_url + * + * @return string|null + */ + public function getApprovalUrl() + { + return $this->container['approval_url']; + } + + /** + * Sets approval_url + * + * @param string|null $approval_url The optional URL that the buyer needs to be redirected to to further authorize their payment. + * + * @return self + */ + public function setApprovalUrl($approval_url) + { + $this->container['approval_url'] = $approval_url; + + return $this; + } + + /** + * Gets currency + * + * @return string|null + */ + public function getCurrency() + { + return $this->container['currency']; + } + + /** + * Sets currency + * + * @param string|null $currency The ISO-4217 currency code that this payment method can be used for. If this value is `null` the payment method may be used for multiple currencies. + * + * @return self + */ + public function setCurrency($currency) + { + $this->container['currency'] = $currency; + + return $this; + } + + /** + * Gets country + * + * @return string|null + */ + public function getCountry() + { + return $this->container['country']; + } + + /** + * Sets country + * + * @param string|null $country The 2-letter ISO code of the country this payment method can be used for. If this value is `null` the payment method may be used in multiple countries. + * + * @return self + */ + public function setCountry($country) + { + $this->container['country'] = $country; + + return $this; + } + + /** + * Gets details + * + * @return \Gr4vy\model\PaymentMethodDetailsCard|null + */ + public function getDetails() + { + return $this->container['details']; + } + + /** + * Sets details + * + * @param \Gr4vy\model\PaymentMethodDetailsCard|null $details details + * + * @return self + */ + public function setDetails($details) + { + $this->container['details'] = $details; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/PaymentMethodBuyer.php b/lib/model/PaymentMethodBuyer.php new file mode 100644 index 0000000..85f2373 --- /dev/null +++ b/lib/model/PaymentMethodBuyer.php @@ -0,0 +1,565 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class PaymentMethodBuyer implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PaymentMethod_buyer'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'id' => 'string', + 'external_identifier' => 'string', + 'display_name' => 'string', + 'billing_details' => '\Gr4vy\model\BuyerBillingDetails', + 'created_at' => '\DateTime', + 'updated_at' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'id' => 'uuid', + 'external_identifier' => null, + 'display_name' => null, + 'billing_details' => null, + 'created_at' => 'date-time', + 'updated_at' => 'date-time' + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'id' => 'id', + 'external_identifier' => 'external_identifier', + 'display_name' => 'display_name', + 'billing_details' => 'billing_details', + 'created_at' => 'created_at', + 'updated_at' => 'updated_at' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'id' => 'setId', + 'external_identifier' => 'setExternalIdentifier', + 'display_name' => 'setDisplayName', + 'billing_details' => 'setBillingDetails', + 'created_at' => 'setCreatedAt', + 'updated_at' => 'setUpdatedAt' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'id' => 'getId', + 'external_identifier' => 'getExternalIdentifier', + 'display_name' => 'getDisplayName', + 'billing_details' => 'getBillingDetails', + 'created_at' => 'getCreatedAt', + 'updated_at' => 'getUpdatedAt' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_BUYER = 'buyer'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_BUYER, + ]; + } + + /** + * 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['type'] = $data['type'] ?? null; + $this->container['id'] = $data['id'] ?? null; + $this->container['external_identifier'] = $data['external_identifier'] ?? null; + $this->container['display_name'] = $data['display_name'] ?? null; + $this->container['billing_details'] = $data['billing_details'] ?? null; + $this->container['created_at'] = $data['created_at'] ?? null; + $this->container['updated_at'] = $data['updated_at'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + if (!is_null($this->container['external_identifier']) && (mb_strlen($this->container['external_identifier']) > 200)) { + $invalidProperties[] = "invalid value for 'external_identifier', the character length must be smaller than or equal to 200."; + } + + if (!is_null($this->container['external_identifier']) && (mb_strlen($this->container['external_identifier']) < 1)) { + $invalidProperties[] = "invalid value for 'external_identifier', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['display_name']) && (mb_strlen($this->container['display_name']) > 200)) { + $invalidProperties[] = "invalid value for 'display_name', the character length must be smaller than or equal to 200."; + } + + if (!is_null($this->container['display_name']) && (mb_strlen($this->container['display_name']) < 1)) { + $invalidProperties[] = "invalid value for 'display_name', the character length must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type The type of this resource. Is always `buyer`. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id The unique Gr4vy ID for this buyer. + * + * @return self + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets external_identifier + * + * @return string|null + */ + public function getExternalIdentifier() + { + return $this->container['external_identifier']; + } + + /** + * Sets external_identifier + * + * @param string|null $external_identifier An external identifier that can be used to match the buyer against your own records. + * + * @return self + */ + public function setExternalIdentifier($external_identifier) + { + if (!is_null($external_identifier) && (mb_strlen($external_identifier) > 200)) { + throw new \InvalidArgumentException('invalid length for $external_identifier when calling PaymentMethodBuyer., must be smaller than or equal to 200.'); + } + if (!is_null($external_identifier) && (mb_strlen($external_identifier) < 1)) { + throw new \InvalidArgumentException('invalid length for $external_identifier when calling PaymentMethodBuyer., must be bigger than or equal to 1.'); + } + + $this->container['external_identifier'] = $external_identifier; + + return $this; + } + + /** + * Gets display_name + * + * @return string|null + */ + public function getDisplayName() + { + return $this->container['display_name']; + } + + /** + * Sets display_name + * + * @param string|null $display_name A unique name for this buyer which is used in the Gr4vy admin panel to give a buyer a human readable name. + * + * @return self + */ + public function setDisplayName($display_name) + { + if (!is_null($display_name) && (mb_strlen($display_name) > 200)) { + throw new \InvalidArgumentException('invalid length for $display_name when calling PaymentMethodBuyer., must be smaller than or equal to 200.'); + } + if (!is_null($display_name) && (mb_strlen($display_name) < 1)) { + throw new \InvalidArgumentException('invalid length for $display_name when calling PaymentMethodBuyer., must be bigger than or equal to 1.'); + } + + $this->container['display_name'] = $display_name; + + return $this; + } + + /** + * Gets billing_details + * + * @return \Gr4vy\model\BuyerBillingDetails|null + */ + public function getBillingDetails() + { + return $this->container['billing_details']; + } + + /** + * Sets billing_details + * + * @param \Gr4vy\model\BuyerBillingDetails|null $billing_details billing_details + * + * @return self + */ + public function setBillingDetails($billing_details) + { + $this->container['billing_details'] = $billing_details; + + return $this; + } + + /** + * Gets created_at + * + * @return \DateTime|null + */ + public function getCreatedAt() + { + return $this->container['created_at']; + } + + /** + * Sets created_at + * + * @param \DateTime|null $created_at The date and time when this buyer was created in our system. + * + * @return self + */ + public function setCreatedAt($created_at) + { + $this->container['created_at'] = $created_at; + + return $this; + } + + /** + * Gets updated_at + * + * @return \DateTime|null + */ + public function getUpdatedAt() + { + return $this->container['updated_at']; + } + + /** + * Sets updated_at + * + * @param \DateTime|null $updated_at The date and time when this buyer was last updated in our system. + * + * @return self + */ + public function setUpdatedAt($updated_at) + { + $this->container['updated_at'] = $updated_at; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/PaymentMethodDefinition.php b/lib/model/PaymentMethodDefinition.php new file mode 100644 index 0000000..eba8975 --- /dev/null +++ b/lib/model/PaymentMethodDefinition.php @@ -0,0 +1,444 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class PaymentMethodDefinition implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PaymentMethodDefinition'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'icon_url' => 'string', + 'display_name' => 'string', + 'long_display_name' => 'string', + 'method' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'icon_url' => null, + 'display_name' => null, + 'long_display_name' => null, + 'method' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'icon_url' => 'icon_url', + 'display_name' => 'display_name', + 'long_display_name' => 'long_display_name', + 'method' => 'method' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'icon_url' => 'setIconUrl', + 'display_name' => 'setDisplayName', + 'long_display_name' => 'setLongDisplayName', + 'method' => 'setMethod' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'icon_url' => 'getIconUrl', + 'display_name' => 'getDisplayName', + 'long_display_name' => 'getLongDisplayName', + 'method' => 'getMethod' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['id'] = $data['id'] ?? null; + $this->container['icon_url'] = $data['icon_url'] ?? null; + $this->container['display_name'] = $data['display_name'] ?? null; + $this->container['long_display_name'] = $data['long_display_name'] ?? null; + $this->container['method'] = $data['method'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id The mode of this payment method. + * + * @return self + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets icon_url + * + * @return string|null + */ + public function getIconUrl() + { + return $this->container['icon_url']; + } + + /** + * Sets icon_url + * + * @param string|null $icon_url The icon for this payment method. + * + * @return self + */ + public function setIconUrl($icon_url) + { + $this->container['icon_url'] = $icon_url; + + return $this; + } + + /** + * Gets display_name + * + * @return string|null + */ + public function getDisplayName() + { + return $this->container['display_name']; + } + + /** + * Sets display_name + * + * @param string|null $display_name The display name of this payment method. + * + * @return self + */ + public function setDisplayName($display_name) + { + $this->container['display_name'] = $display_name; + + return $this; + } + + /** + * Gets long_display_name + * + * @return string|null + */ + public function getLongDisplayName() + { + return $this->container['long_display_name']; + } + + /** + * Sets long_display_name + * + * @param string|null $long_display_name The long display name of this payment method. + * + * @return self + */ + public function setLongDisplayName($long_display_name) + { + $this->container['long_display_name'] = $long_display_name; + + return $this; + } + + /** + * Gets method + * + * @return string|null + */ + public function getMethod() + { + return $this->container['method']; + } + + /** + * Sets method + * + * @param string|null $method The method, or type, for this payment method. + * + * @return self + */ + public function setMethod($method) + { + $this->container['method'] = $method; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/PaymentMethodDefinitions.php b/lib/model/PaymentMethodDefinitions.php new file mode 100644 index 0000000..83d6a6d --- /dev/null +++ b/lib/model/PaymentMethodDefinitions.php @@ -0,0 +1,324 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class PaymentMethodDefinitions implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PaymentMethodDefinitions'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'items' => '\Gr4vy\model\PaymentMethodDefinition[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'items' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'items' => 'items' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'items' => 'setItems' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'items' => 'getItems' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['items'] = $data['items'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets items + * + * @return \Gr4vy\model\PaymentMethodDefinition[]|null + */ + public function getItems() + { + return $this->container['items']; + } + + /** + * Sets items + * + * @param \Gr4vy\model\PaymentMethodDefinition[]|null $items items + * + * @return self + */ + public function setItems($items) + { + $this->container['items'] = $items; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/PaymentMethodDetailsCard.php b/lib/model/PaymentMethodDetailsCard.php new file mode 100644 index 0000000..85fa578 --- /dev/null +++ b/lib/model/PaymentMethodDetailsCard.php @@ -0,0 +1,390 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class PaymentMethodDetailsCard implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PaymentMethodDetailsCard'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'card_type' => 'string', + 'bin' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'card_type' => null, + 'bin' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'card_type' => 'card_type', + 'bin' => 'bin' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'card_type' => 'setCardType', + 'bin' => 'setBin' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'card_type' => 'getCardType', + 'bin' => 'getBin' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const CARD_TYPE_CREDIT = 'credit'; + public const CARD_TYPE_DEBIT = 'debit'; + public const CARD_TYPE_PREPAID = 'prepaid'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getCardTypeAllowableValues() + { + return [ + self::CARD_TYPE_CREDIT, + self::CARD_TYPE_DEBIT, + self::CARD_TYPE_PREPAID, + ]; + } + + /** + * 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['card_type'] = $data['card_type'] ?? null; + $this->container['bin'] = $data['bin'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getCardTypeAllowableValues(); + if (!is_null($this->container['card_type']) && !in_array($this->container['card_type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'card_type', must be one of '%s'", + $this->container['card_type'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets card_type + * + * @return string|null + */ + public function getCardType() + { + return $this->container['card_type']; + } + + /** + * Sets card_type + * + * @param string|null $card_type The type of card, one of `credit`, `debit` or `prepaid`. + * + * @return self + */ + public function setCardType($card_type) + { + $allowedValues = $this->getCardTypeAllowableValues(); + if (!is_null($card_type) && !in_array($card_type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'card_type', must be one of '%s'", + $card_type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['card_type'] = $card_type; + + return $this; + } + + /** + * Gets bin + * + * @return string|null + */ + public function getBin() + { + return $this->container['bin']; + } + + /** + * Sets bin + * + * @param string|null $bin The first 6 digits of the full card number (the BIN). + * + * @return self + */ + public function setBin($bin) + { + $this->container['bin'] = $bin; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/PaymentMethodRequest.php b/lib/model/PaymentMethodRequest.php new file mode 100644 index 0000000..85ae6d4 --- /dev/null +++ b/lib/model/PaymentMethodRequest.php @@ -0,0 +1,663 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class PaymentMethodRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PaymentMethodRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'method' => 'string', + 'number' => 'string', + 'expiration_date' => 'string', + 'security_code' => 'string', + 'external_identifier' => 'string', + 'buyer_id' => 'string', + 'buyer_external_identifier' => 'string', + 'redirect_url' => 'string', + 'currency' => 'string', + 'country' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'method' => null, + 'number' => null, + 'expiration_date' => null, + 'security_code' => null, + 'external_identifier' => null, + 'buyer_id' => 'uuid', + 'buyer_external_identifier' => null, + 'redirect_url' => null, + 'currency' => null, + 'country' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'method' => 'method', + 'number' => 'number', + 'expiration_date' => 'expiration_date', + 'security_code' => 'security_code', + 'external_identifier' => 'external_identifier', + 'buyer_id' => 'buyer_id', + 'buyer_external_identifier' => 'buyer_external_identifier', + 'redirect_url' => 'redirect_url', + 'currency' => 'currency', + 'country' => 'country' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'method' => 'setMethod', + 'number' => 'setNumber', + 'expiration_date' => 'setExpirationDate', + 'security_code' => 'setSecurityCode', + 'external_identifier' => 'setExternalIdentifier', + 'buyer_id' => 'setBuyerId', + 'buyer_external_identifier' => 'setBuyerExternalIdentifier', + 'redirect_url' => 'setRedirectUrl', + 'currency' => 'setCurrency', + 'country' => 'setCountry' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'method' => 'getMethod', + 'number' => 'getNumber', + 'expiration_date' => 'getExpirationDate', + 'security_code' => 'getSecurityCode', + 'external_identifier' => 'getExternalIdentifier', + 'buyer_id' => 'getBuyerId', + 'buyer_external_identifier' => 'getBuyerExternalIdentifier', + 'redirect_url' => 'getRedirectUrl', + 'currency' => 'getCurrency', + 'country' => 'getCountry' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['method'] = $data['method'] ?? null; + $this->container['number'] = $data['number'] ?? null; + $this->container['expiration_date'] = $data['expiration_date'] ?? null; + $this->container['security_code'] = $data['security_code'] ?? null; + $this->container['external_identifier'] = $data['external_identifier'] ?? null; + $this->container['buyer_id'] = $data['buyer_id'] ?? null; + $this->container['buyer_external_identifier'] = $data['buyer_external_identifier'] ?? null; + $this->container['redirect_url'] = $data['redirect_url'] ?? null; + $this->container['currency'] = $data['currency'] ?? null; + $this->container['country'] = $data['country'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['method'] === null) { + $invalidProperties[] = "'method' can't be null"; + } + if (!is_null($this->container['number']) && (mb_strlen($this->container['number']) > 19)) { + $invalidProperties[] = "invalid value for 'number', the character length must be smaller than or equal to 19."; + } + + if (!is_null($this->container['number']) && (mb_strlen($this->container['number']) < 13)) { + $invalidProperties[] = "invalid value for 'number', the character length must be bigger than or equal to 13."; + } + + if (!is_null($this->container['number']) && !preg_match("/^[0-9]{13,19}$/", $this->container['number'])) { + $invalidProperties[] = "invalid value for 'number', must be conform to the pattern /^[0-9]{13,19}$/."; + } + + if (!is_null($this->container['expiration_date']) && (mb_strlen($this->container['expiration_date']) > 5)) { + $invalidProperties[] = "invalid value for 'expiration_date', the character length must be smaller than or equal to 5."; + } + + if (!is_null($this->container['expiration_date']) && (mb_strlen($this->container['expiration_date']) < 5)) { + $invalidProperties[] = "invalid value for 'expiration_date', the character length must be bigger than or equal to 5."; + } + + if (!is_null($this->container['expiration_date']) && !preg_match("/^\\d\\d\/\\d\\d$/", $this->container['expiration_date'])) { + $invalidProperties[] = "invalid value for 'expiration_date', must be conform to the pattern /^\\d\\d\/\\d\\d$/."; + } + + if (!is_null($this->container['security_code']) && (mb_strlen($this->container['security_code']) > 4)) { + $invalidProperties[] = "invalid value for 'security_code', the character length must be smaller than or equal to 4."; + } + + if (!is_null($this->container['security_code']) && (mb_strlen($this->container['security_code']) < 3)) { + $invalidProperties[] = "invalid value for 'security_code', the character length must be bigger than or equal to 3."; + } + + if (!is_null($this->container['security_code']) && !preg_match("/^\\d{3,4}$/", $this->container['security_code'])) { + $invalidProperties[] = "invalid value for 'security_code', must be conform to the pattern /^\\d{3,4}$/."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets method + * + * @return string + */ + public function getMethod() + { + return $this->container['method']; + } + + /** + * Sets method + * + * @param string $method method + * + * @return self + */ + public function setMethod($method) + { + $this->container['method'] = $method; + + return $this; + } + + /** + * Gets number + * + * @return string|null + */ + public function getNumber() + { + return $this->container['number']; + } + + /** + * Sets number + * + * @param string|null $number The 13-19 digit number for this credit card as it can be found on the front of the card. If a card has been stored with us previously, this number will represent the unique tokenized card ID provided via our API. + * + * @return self + */ + public function setNumber($number) + { + if (!is_null($number) && (mb_strlen($number) > 19)) { + throw new \InvalidArgumentException('invalid length for $number when calling PaymentMethodRequest., must be smaller than or equal to 19.'); + } + if (!is_null($number) && (mb_strlen($number) < 13)) { + throw new \InvalidArgumentException('invalid length for $number when calling PaymentMethodRequest., must be bigger than or equal to 13.'); + } + if (!is_null($number) && (!preg_match("/^[0-9]{13,19}$/", $number))) { + throw new \InvalidArgumentException("invalid value for $number when calling PaymentMethodRequest., must conform to the pattern /^[0-9]{13,19}$/."); + } + + $this->container['number'] = $number; + + return $this; + } + + /** + * Gets expiration_date + * + * @return string|null + */ + public function getExpirationDate() + { + return $this->container['expiration_date']; + } + + /** + * Sets expiration_date + * + * @param string|null $expiration_date The expiration date of the card, formatted `MM/YY`. If a card has been previously stored with us this value is optional. If the `number` of this card represents a tokenized card, then this value is ignored. + * + * @return self + */ + public function setExpirationDate($expiration_date) + { + if (!is_null($expiration_date) && (mb_strlen($expiration_date) > 5)) { + throw new \InvalidArgumentException('invalid length for $expiration_date when calling PaymentMethodRequest., must be smaller than or equal to 5.'); + } + if (!is_null($expiration_date) && (mb_strlen($expiration_date) < 5)) { + throw new \InvalidArgumentException('invalid length for $expiration_date when calling PaymentMethodRequest., must be bigger than or equal to 5.'); + } + if (!is_null($expiration_date) && (!preg_match("/^\\d\\d\/\\d\\d$/", $expiration_date))) { + throw new \InvalidArgumentException("invalid value for $expiration_date when calling PaymentMethodRequest., must conform to the pattern /^\\d\\d\/\\d\\d$/."); + } + + $this->container['expiration_date'] = $expiration_date; + + return $this; + } + + /** + * Gets security_code + * + * @return string|null + */ + public function getSecurityCode() + { + return $this->container['security_code']; + } + + /** + * Sets security_code + * + * @param string|null $security_code The 3 or 4 digit security code often found on the card. This often referred to as the CVV or CVD. If the `number` of this card represents a tokenized card, then this value is ignored. + * + * @return self + */ + public function setSecurityCode($security_code) + { + if (!is_null($security_code) && (mb_strlen($security_code) > 4)) { + throw new \InvalidArgumentException('invalid length for $security_code when calling PaymentMethodRequest., must be smaller than or equal to 4.'); + } + if (!is_null($security_code) && (mb_strlen($security_code) < 3)) { + throw new \InvalidArgumentException('invalid length for $security_code when calling PaymentMethodRequest., must be bigger than or equal to 3.'); + } + if (!is_null($security_code) && (!preg_match("/^\\d{3,4}$/", $security_code))) { + throw new \InvalidArgumentException("invalid value for $security_code when calling PaymentMethodRequest., must conform to the pattern /^\\d{3,4}$/."); + } + + $this->container['security_code'] = $security_code; + + return $this; + } + + /** + * Gets external_identifier + * + * @return string|null + */ + public function getExternalIdentifier() + { + return $this->container['external_identifier']; + } + + /** + * Sets external_identifier + * + * @param string|null $external_identifier An external identifier that can be used to match the card against your own records. + * + * @return self + */ + public function setExternalIdentifier($external_identifier) + { + $this->container['external_identifier'] = $external_identifier; + + return $this; + } + + /** + * Gets buyer_id + * + * @return string|null + */ + public function getBuyerId() + { + return $this->container['buyer_id']; + } + + /** + * Sets buyer_id + * + * @param string|null $buyer_id The ID of the buyer to associate this payment method to. If this field is provided then the `buyer_external_identifier` field needs to be unset. + * + * @return self + */ + public function setBuyerId($buyer_id) + { + $this->container['buyer_id'] = $buyer_id; + + return $this; + } + + /** + * Gets buyer_external_identifier + * + * @return string|null + */ + public function getBuyerExternalIdentifier() + { + return $this->container['buyer_external_identifier']; + } + + /** + * Sets buyer_external_identifier + * + * @param string|null $buyer_external_identifier The `external_identifier` of the buyer to associate this payment method to. If this field is provided then the `buyer_id` field needs to be unset. + * + * @return self + */ + public function setBuyerExternalIdentifier($buyer_external_identifier) + { + $this->container['buyer_external_identifier'] = $buyer_external_identifier; + + return $this; + } + + /** + * Gets redirect_url + * + * @return string|null + */ + public function getRedirectUrl() + { + return $this->container['redirect_url']; + } + + /** + * Sets redirect_url + * + * @param string|null $redirect_url The redirect URL to redirect a buyer to after they have authorized their transaction or payment method. This only applies to payment methods that require buyer approval. + * + * @return self + */ + public function setRedirectUrl($redirect_url) + { + $this->container['redirect_url'] = $redirect_url; + + return $this; + } + + /** + * Gets currency + * + * @return string|null + */ + public function getCurrency() + { + return $this->container['currency']; + } + + /** + * Sets currency + * + * @param string|null $currency The ISO-4217 currency code to store this payment method for. This is used to select the payment service to use. This only applies to `redirect` mode payment methods like `gocardless`. + * + * @return self + */ + public function setCurrency($currency) + { + $this->container['currency'] = $currency; + + return $this; + } + + /** + * Gets country + * + * @return string|null + */ + public function getCountry() + { + return $this->container['country']; + } + + /** + * Sets country + * + * @param string|null $country The 2-letter ISO code of the country to store this payment method for. This is used to select the payment service to use. This only applies to `redirect` mode payment methods like `gocardless`. + * + * @return self + */ + public function setCountry($country) + { + $this->container['country'] = $country; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/PaymentMethodSnapshot.php b/lib/model/PaymentMethodSnapshot.php new file mode 100644 index 0000000..148be1b --- /dev/null +++ b/lib/model/PaymentMethodSnapshot.php @@ -0,0 +1,742 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class PaymentMethodSnapshot implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PaymentMethod--Snapshot'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'id' => 'string', + 'method' => 'string', + 'external_identifier' => 'string', + 'label' => 'string', + 'scheme' => 'string', + 'expiration_date' => 'string', + 'approval_target' => 'string', + 'approval_url' => 'string', + 'currency' => 'string', + 'country' => 'string', + 'details' => '\Gr4vy\model\PaymentMethodDetailsCard' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'id' => 'uuid', + 'method' => null, + 'external_identifier' => null, + 'label' => null, + 'scheme' => null, + 'expiration_date' => null, + 'approval_target' => null, + 'approval_url' => null, + 'currency' => null, + 'country' => null, + 'details' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'id' => 'id', + 'method' => 'method', + 'external_identifier' => 'external_identifier', + 'label' => 'label', + 'scheme' => 'scheme', + 'expiration_date' => 'expiration_date', + 'approval_target' => 'approval_target', + 'approval_url' => 'approval_url', + 'currency' => 'currency', + 'country' => 'country', + 'details' => 'details' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'id' => 'setId', + 'method' => 'setMethod', + 'external_identifier' => 'setExternalIdentifier', + 'label' => 'setLabel', + 'scheme' => 'setScheme', + 'expiration_date' => 'setExpirationDate', + 'approval_target' => 'setApprovalTarget', + 'approval_url' => 'setApprovalUrl', + 'currency' => 'setCurrency', + 'country' => 'setCountry', + 'details' => 'setDetails' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'id' => 'getId', + 'method' => 'getMethod', + 'external_identifier' => 'getExternalIdentifier', + 'label' => 'getLabel', + 'scheme' => 'getScheme', + 'expiration_date' => 'getExpirationDate', + 'approval_target' => 'getApprovalTarget', + 'approval_url' => 'getApprovalUrl', + 'currency' => 'getCurrency', + 'country' => 'getCountry', + 'details' => 'getDetails' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_PAYMENT_METHOD = 'payment-method'; + public const APPROVAL_TARGET_ANY = 'any'; + public const APPROVAL_TARGET_NEW_WINDOW = 'new_window'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_PAYMENT_METHOD, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getApprovalTargetAllowableValues() + { + return [ + self::APPROVAL_TARGET_ANY, + self::APPROVAL_TARGET_NEW_WINDOW, + ]; + } + + /** + * 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['type'] = $data['type'] ?? null; + $this->container['id'] = $data['id'] ?? null; + $this->container['method'] = $data['method'] ?? null; + $this->container['external_identifier'] = $data['external_identifier'] ?? null; + $this->container['label'] = $data['label'] ?? null; + $this->container['scheme'] = $data['scheme'] ?? null; + $this->container['expiration_date'] = $data['expiration_date'] ?? null; + $this->container['approval_target'] = $data['approval_target'] ?? null; + $this->container['approval_url'] = $data['approval_url'] ?? null; + $this->container['currency'] = $data['currency'] ?? null; + $this->container['country'] = $data['country'] ?? null; + $this->container['details'] = $data['details'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + if (!is_null($this->container['expiration_date']) && (mb_strlen($this->container['expiration_date']) > 5)) { + $invalidProperties[] = "invalid value for 'expiration_date', the character length must be smaller than or equal to 5."; + } + + if (!is_null($this->container['expiration_date']) && (mb_strlen($this->container['expiration_date']) < 5)) { + $invalidProperties[] = "invalid value for 'expiration_date', the character length must be bigger than or equal to 5."; + } + + if (!is_null($this->container['expiration_date']) && !preg_match("/^\\d{2}\/\\d{2}$/", $this->container['expiration_date'])) { + $invalidProperties[] = "invalid value for 'expiration_date', must be conform to the pattern /^\\d{2}\/\\d{2}$/."; + } + + $allowedValues = $this->getApprovalTargetAllowableValues(); + if (!is_null($this->container['approval_target']) && !in_array($this->container['approval_target'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'approval_target', must be one of '%s'", + $this->container['approval_target'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type `payment-method`. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id The unique ID of the payment method. + * + * @return self + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets method + * + * @return string|null + */ + public function getMethod() + { + return $this->container['method']; + } + + /** + * Sets method + * + * @param string|null $method method + * + * @return self + */ + public function setMethod($method) + { + $this->container['method'] = $method; + + return $this; + } + + /** + * Gets external_identifier + * + * @return string|null + */ + public function getExternalIdentifier() + { + return $this->container['external_identifier']; + } + + /** + * Sets external_identifier + * + * @param string|null $external_identifier An external identifier that can be used to match the payment method against your own records. + * + * @return self + */ + public function setExternalIdentifier($external_identifier) + { + $this->container['external_identifier'] = $external_identifier; + + return $this; + } + + /** + * Gets label + * + * @return string|null + */ + public function getLabel() + { + return $this->container['label']; + } + + /** + * Sets label + * + * @param string|null $label A label for the payment method. This can be the last 4 digits for a card, or the email address for an alternative payment method. + * + * @return self + */ + public function setLabel($label) + { + $this->container['label'] = $label; + + return $this; + } + + /** + * Gets scheme + * + * @return string|null + */ + public function getScheme() + { + return $this->container['scheme']; + } + + /** + * Sets scheme + * + * @param string|null $scheme An additional label used to differentiate different sub-types of a payment method. Most notably this can include the type of card used in a transaction. + * + * @return self + */ + public function setScheme($scheme) + { + $this->container['scheme'] = $scheme; + + return $this; + } + + /** + * Gets expiration_date + * + * @return string|null + */ + public function getExpirationDate() + { + return $this->container['expiration_date']; + } + + /** + * Sets expiration_date + * + * @param string|null $expiration_date The expiration date for this payment method. This is mostly used by cards where the card might have an expiration date. + * + * @return self + */ + public function setExpirationDate($expiration_date) + { + if (!is_null($expiration_date) && (mb_strlen($expiration_date) > 5)) { + throw new \InvalidArgumentException('invalid length for $expiration_date when calling PaymentMethodSnapshot., must be smaller than or equal to 5.'); + } + if (!is_null($expiration_date) && (mb_strlen($expiration_date) < 5)) { + throw new \InvalidArgumentException('invalid length for $expiration_date when calling PaymentMethodSnapshot., must be bigger than or equal to 5.'); + } + if (!is_null($expiration_date) && (!preg_match("/^\\d{2}\/\\d{2}$/", $expiration_date))) { + throw new \InvalidArgumentException("invalid value for $expiration_date when calling PaymentMethodSnapshot., must conform to the pattern /^\\d{2}\/\\d{2}$/."); + } + + $this->container['expiration_date'] = $expiration_date; + + return $this; + } + + /** + * Gets approval_target + * + * @return string|null + */ + public function getApprovalTarget() + { + return $this->container['approval_target']; + } + + /** + * Sets approval_target + * + * @param string|null $approval_target The browser target that an approval URL must be opened in. If `any` or `null`, then there is no specific requirement. + * + * @return self + */ + public function setApprovalTarget($approval_target) + { + $allowedValues = $this->getApprovalTargetAllowableValues(); + if (!is_null($approval_target) && !in_array($approval_target, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'approval_target', must be one of '%s'", + $approval_target, + implode("', '", $allowedValues) + ) + ); + } + $this->container['approval_target'] = $approval_target; + + return $this; + } + + /** + * Gets approval_url + * + * @return string|null + */ + public function getApprovalUrl() + { + return $this->container['approval_url']; + } + + /** + * Sets approval_url + * + * @param string|null $approval_url The optional URL that the buyer needs to be redirected to to further authorize their payment. + * + * @return self + */ + public function setApprovalUrl($approval_url) + { + $this->container['approval_url'] = $approval_url; + + return $this; + } + + /** + * Gets currency + * + * @return string|null + */ + public function getCurrency() + { + return $this->container['currency']; + } + + /** + * Sets currency + * + * @param string|null $currency The ISO-4217 currency code that this payment method can be used for. If this value is `null` the payment method may be used for multiple currencies. + * + * @return self + */ + public function setCurrency($currency) + { + $this->container['currency'] = $currency; + + return $this; + } + + /** + * Gets country + * + * @return string|null + */ + public function getCountry() + { + return $this->container['country']; + } + + /** + * Sets country + * + * @param string|null $country The 2-letter ISO code of the country this payment method can be used for. If this value is `null` the payment method may be used in multiple countries. + * + * @return self + */ + public function setCountry($country) + { + $this->container['country'] = $country; + + return $this; + } + + /** + * Gets details + * + * @return \Gr4vy\model\PaymentMethodDetailsCard|null + */ + public function getDetails() + { + return $this->container['details']; + } + + /** + * Sets details + * + * @param \Gr4vy\model\PaymentMethodDetailsCard|null $details details + * + * @return self + */ + public function setDetails($details) + { + $this->container['details'] = $details; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/PaymentMethodToken.php b/lib/model/PaymentMethodToken.php new file mode 100644 index 0000000..fa12db9 --- /dev/null +++ b/lib/model/PaymentMethodToken.php @@ -0,0 +1,514 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class PaymentMethodToken implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PaymentMethodToken'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'id' => 'string', + 'token' => 'string', + 'status' => 'string', + 'payment_service' => '\Gr4vy\model\PaymentMethodTokenPaymentService' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'id' => null, + 'token' => null, + 'status' => null, + 'payment_service' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'id' => 'id', + 'token' => 'token', + 'status' => 'status', + 'payment_service' => 'payment_service' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'id' => 'setId', + 'token' => 'setToken', + 'status' => 'setStatus', + 'payment_service' => 'setPaymentService' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'id' => 'getId', + 'token' => 'getToken', + 'status' => 'getStatus', + 'payment_service' => 'getPaymentService' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_PAYMENT_METHOD_TOKEN = 'payment-method-token'; + public const STATUS_PROCESSING = 'processing'; + public const STATUS_BUYER_APPROVAL_REQUIRED = 'buyer_approval_required'; + public const STATUS_SUCCEEDED = 'succeeded'; + public const STATUS_FAILED = 'failed'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_PAYMENT_METHOD_TOKEN, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStatusAllowableValues() + { + return [ + self::STATUS_PROCESSING, + self::STATUS_BUYER_APPROVAL_REQUIRED, + self::STATUS_SUCCEEDED, + self::STATUS_FAILED, + ]; + } + + /** + * 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['type'] = $data['type'] ?? null; + $this->container['id'] = $data['id'] ?? null; + $this->container['token'] = $data['token'] ?? null; + $this->container['status'] = $data['status'] ?? null; + $this->container['payment_service'] = $data['payment_service'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($this->container['status']) && !in_array($this->container['status'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'status', must be one of '%s'", + $this->container['status'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type `payment-method-token`. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id The external ID of this payment method as it has been registered with the payment service, which can be used directly in combination with the `token` without the need to go through Gr4vy for a transaction. In some cases this is a different value to the `token` while in others this value is identical. Please see the documentation for the payment service for more details. + * + * @return self + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets token + * + * @return string|null + */ + public function getToken() + { + return $this->container['token']; + } + + /** + * Sets token + * + * @param string|null $token The token of this payment method as it has been registered with the payment service, which can be used directly in combination with the `id` without the need to go through Gr4vy for a transaction. In some cases this is a different value to the `id` while in others this value is identical. Please see the documentation for the payment service for more details. + * + * @return self + */ + public function setToken($token) + { + $this->container['token'] = $token; + + return $this; + } + + /** + * Gets status + * + * @return string|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param string|null $status The state of the payment method. - `processing` - The payment method is still being stored. - `buyer_approval_required` - The buyer still needs to provide approval before the payment method can be stored. - `succeeded` - The payment method is approved and stored with all relevant payment services. - `failed` - Storing the payment method did not succeed. + * + * @return self + */ + public function setStatus($status) + { + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($status) && !in_array($status, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'status', must be one of '%s'", + $status, + implode("', '", $allowedValues) + ) + ); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets payment_service + * + * @return \Gr4vy\model\PaymentMethodTokenPaymentService|null + */ + public function getPaymentService() + { + return $this->container['payment_service']; + } + + /** + * Sets payment_service + * + * @param \Gr4vy\model\PaymentMethodTokenPaymentService|null $payment_service payment_service + * + * @return self + */ + public function setPaymentService($payment_service) + { + $this->container['payment_service'] = $payment_service; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/PaymentMethodTokenPaymentService.php b/lib/model/PaymentMethodTokenPaymentService.php new file mode 100644 index 0000000..fdb3d0d --- /dev/null +++ b/lib/model/PaymentMethodTokenPaymentService.php @@ -0,0 +1,520 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class PaymentMethodTokenPaymentService implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PaymentMethodToken_payment_service'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'type' => 'string', + 'payment_service_definition_id' => 'string', + 'method' => 'string', + 'display_name' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'type' => null, + 'payment_service_definition_id' => null, + 'method' => null, + 'display_name' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'type' => 'type', + 'payment_service_definition_id' => 'payment_service_definition_id', + 'method' => 'method', + 'display_name' => 'display_name' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'type' => 'setType', + 'payment_service_definition_id' => 'setPaymentServiceDefinitionId', + 'method' => 'setMethod', + 'display_name' => 'setDisplayName' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'type' => 'getType', + 'payment_service_definition_id' => 'getPaymentServiceDefinitionId', + 'method' => 'getMethod', + 'display_name' => 'getDisplayName' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_PAYMENT_SERVICE = 'payment-service'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_PAYMENT_SERVICE, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['id'] = $data['id'] ?? null; + $this->container['type'] = $data['type'] ?? null; + $this->container['payment_service_definition_id'] = $data['payment_service_definition_id'] ?? null; + $this->container['method'] = $data['method'] ?? null; + $this->container['display_name'] = $data['display_name'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['id']) && (mb_strlen($this->container['id']) > 200)) { + $invalidProperties[] = "invalid value for 'id', the character length must be smaller than or equal to 200."; + } + + if (!is_null($this->container['id']) && (mb_strlen($this->container['id']) < 1)) { + $invalidProperties[] = "invalid value for 'id', the character length must be bigger than or equal to 1."; + } + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + if (!is_null($this->container['payment_service_definition_id']) && (mb_strlen($this->container['payment_service_definition_id']) > 50)) { + $invalidProperties[] = "invalid value for 'payment_service_definition_id', the character length must be smaller than or equal to 50."; + } + + if (!is_null($this->container['payment_service_definition_id']) && (mb_strlen($this->container['payment_service_definition_id']) < 1)) { + $invalidProperties[] = "invalid value for 'payment_service_definition_id', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['display_name']) && (mb_strlen($this->container['display_name']) > 50)) { + $invalidProperties[] = "invalid value for 'display_name', the character length must be smaller than or equal to 50."; + } + + if (!is_null($this->container['display_name']) && (mb_strlen($this->container['display_name']) < 1)) { + $invalidProperties[] = "invalid value for 'display_name', the character length must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id The ID of this payment service. + * + * @return self + */ + public function setId($id) + { + if (!is_null($id) && (mb_strlen($id) > 200)) { + throw new \InvalidArgumentException('invalid length for $id when calling PaymentMethodTokenPaymentService., must be smaller than or equal to 200.'); + } + if (!is_null($id) && (mb_strlen($id) < 1)) { + throw new \InvalidArgumentException('invalid length for $id when calling PaymentMethodTokenPaymentService., must be bigger than or equal to 1.'); + } + + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type The type of this resource. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets payment_service_definition_id + * + * @return string|null + */ + public function getPaymentServiceDefinitionId() + { + return $this->container['payment_service_definition_id']; + } + + /** + * Sets payment_service_definition_id + * + * @param string|null $payment_service_definition_id The ID of the payment service definition used to create this service. + * + * @return self + */ + public function setPaymentServiceDefinitionId($payment_service_definition_id) + { + if (!is_null($payment_service_definition_id) && (mb_strlen($payment_service_definition_id) > 50)) { + throw new \InvalidArgumentException('invalid length for $payment_service_definition_id when calling PaymentMethodTokenPaymentService., must be smaller than or equal to 50.'); + } + if (!is_null($payment_service_definition_id) && (mb_strlen($payment_service_definition_id) < 1)) { + throw new \InvalidArgumentException('invalid length for $payment_service_definition_id when calling PaymentMethodTokenPaymentService., must be bigger than or equal to 1.'); + } + + $this->container['payment_service_definition_id'] = $payment_service_definition_id; + + return $this; + } + + /** + * Gets method + * + * @return string|null + */ + public function getMethod() + { + return $this->container['method']; + } + + /** + * Sets method + * + * @param string|null $method method + * + * @return self + */ + public function setMethod($method) + { + $this->container['method'] = $method; + + return $this; + } + + /** + * Gets display_name + * + * @return string|null + */ + public function getDisplayName() + { + return $this->container['display_name']; + } + + /** + * Sets display_name + * + * @param string|null $display_name The custom name set for this service. + * + * @return self + */ + public function setDisplayName($display_name) + { + if (!is_null($display_name) && (mb_strlen($display_name) > 50)) { + throw new \InvalidArgumentException('invalid length for $display_name when calling PaymentMethodTokenPaymentService., must be smaller than or equal to 50.'); + } + if (!is_null($display_name) && (mb_strlen($display_name) < 1)) { + throw new \InvalidArgumentException('invalid length for $display_name when calling PaymentMethodTokenPaymentService., must be bigger than or equal to 1.'); + } + + $this->container['display_name'] = $display_name; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/PaymentMethodTokenized.php b/lib/model/PaymentMethodTokenized.php new file mode 100644 index 0000000..0ed4bf6 --- /dev/null +++ b/lib/model/PaymentMethodTokenized.php @@ -0,0 +1,738 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class PaymentMethodTokenized implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PaymentMethod--Tokenized'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'id' => 'string', + 'method' => 'string', + 'label' => 'string', + 'scheme' => 'string', + 'expiration_date' => 'string', + 'approval_target' => 'string', + 'approval_url' => 'string', + 'currency' => 'string', + 'country' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'id' => 'uuid', + 'method' => null, + 'label' => null, + 'scheme' => null, + 'expiration_date' => null, + 'approval_target' => null, + 'approval_url' => null, + 'currency' => null, + 'country' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'id' => 'id', + 'method' => 'method', + 'label' => 'label', + 'scheme' => 'scheme', + 'expiration_date' => 'expiration_date', + 'approval_target' => 'approval_target', + 'approval_url' => 'approval_url', + 'currency' => 'currency', + 'country' => 'country' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'id' => 'setId', + 'method' => 'setMethod', + 'label' => 'setLabel', + 'scheme' => 'setScheme', + 'expiration_date' => 'setExpirationDate', + 'approval_target' => 'setApprovalTarget', + 'approval_url' => 'setApprovalUrl', + 'currency' => 'setCurrency', + 'country' => 'setCountry' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'id' => 'getId', + 'method' => 'getMethod', + 'label' => 'getLabel', + 'scheme' => 'getScheme', + 'expiration_date' => 'getExpirationDate', + 'approval_target' => 'getApprovalTarget', + 'approval_url' => 'getApprovalUrl', + 'currency' => 'getCurrency', + 'country' => 'getCountry' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_PAYMENT_METHOD = 'payment-method'; + public const SCHEME_AMEX = 'amex'; + public const SCHEME_DANKORT = 'dankort'; + public const SCHEME_DINERS_CLUB = 'diners-club'; + public const SCHEME_DISCOVER = 'discover'; + public const SCHEME_EFTPOS_AUSTRALIA = 'eftpos-australia'; + public const SCHEME_ELO = 'elo'; + public const SCHEME_JCB = 'jcb'; + public const SCHEME_MAESTRO = 'maestro'; + public const SCHEME_MASTERCARD = 'mastercard'; + public const SCHEME_OTHER = 'other'; + public const SCHEME_RUPAY = 'rupay'; + public const SCHEME_UNIONPAY = 'unionpay'; + public const SCHEME_VISA = 'visa'; + public const APPROVAL_TARGET_ANY = 'any'; + public const APPROVAL_TARGET_NEW_WINDOW = 'new_window'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_PAYMENT_METHOD, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getSchemeAllowableValues() + { + return [ + self::SCHEME_AMEX, + self::SCHEME_DANKORT, + self::SCHEME_DINERS_CLUB, + self::SCHEME_DISCOVER, + self::SCHEME_EFTPOS_AUSTRALIA, + self::SCHEME_ELO, + self::SCHEME_JCB, + self::SCHEME_MAESTRO, + self::SCHEME_MASTERCARD, + self::SCHEME_OTHER, + self::SCHEME_RUPAY, + self::SCHEME_UNIONPAY, + self::SCHEME_VISA, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getApprovalTargetAllowableValues() + { + return [ + self::APPROVAL_TARGET_ANY, + self::APPROVAL_TARGET_NEW_WINDOW, + ]; + } + + /** + * 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['type'] = $data['type'] ?? null; + $this->container['id'] = $data['id'] ?? null; + $this->container['method'] = $data['method'] ?? null; + $this->container['label'] = $data['label'] ?? null; + $this->container['scheme'] = $data['scheme'] ?? null; + $this->container['expiration_date'] = $data['expiration_date'] ?? null; + $this->container['approval_target'] = $data['approval_target'] ?? null; + $this->container['approval_url'] = $data['approval_url'] ?? null; + $this->container['currency'] = $data['currency'] ?? null; + $this->container['country'] = $data['country'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getSchemeAllowableValues(); + if (!is_null($this->container['scheme']) && !in_array($this->container['scheme'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'scheme', must be one of '%s'", + $this->container['scheme'], + implode("', '", $allowedValues) + ); + } + + if (!is_null($this->container['expiration_date']) && (mb_strlen($this->container['expiration_date']) > 5)) { + $invalidProperties[] = "invalid value for 'expiration_date', the character length must be smaller than or equal to 5."; + } + + if (!is_null($this->container['expiration_date']) && (mb_strlen($this->container['expiration_date']) < 5)) { + $invalidProperties[] = "invalid value for 'expiration_date', the character length must be bigger than or equal to 5."; + } + + if (!is_null($this->container['expiration_date']) && !preg_match("/^\\d{2}\/\\d{2}$/", $this->container['expiration_date'])) { + $invalidProperties[] = "invalid value for 'expiration_date', must be conform to the pattern /^\\d{2}\/\\d{2}$/."; + } + + $allowedValues = $this->getApprovalTargetAllowableValues(); + if (!is_null($this->container['approval_target']) && !in_array($this->container['approval_target'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'approval_target', must be one of '%s'", + $this->container['approval_target'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type `payment-method`. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id The unique ID of the payment method. + * + * @return self + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets method + * + * @return string|null + */ + public function getMethod() + { + return $this->container['method']; + } + + /** + * Sets method + * + * @param string|null $method method + * + * @return self + */ + public function setMethod($method) + { + $this->container['method'] = $method; + + return $this; + } + + /** + * Gets label + * + * @return string|null + */ + public function getLabel() + { + return $this->container['label']; + } + + /** + * Sets label + * + * @param string|null $label A label for the payment method. For a `card` payment method this is the last 4 digits on the card. For others it would be the email address. + * + * @return self + */ + public function setLabel($label) + { + $this->container['label'] = $label; + + return $this; + } + + /** + * Gets scheme + * + * @return string|null + */ + public function getScheme() + { + return $this->container['scheme']; + } + + /** + * Sets scheme + * + * @param string|null $scheme The type of the card, if the payment method is a card. + * + * @return self + */ + public function setScheme($scheme) + { + $allowedValues = $this->getSchemeAllowableValues(); + if (!is_null($scheme) && !in_array($scheme, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'scheme', must be one of '%s'", + $scheme, + implode("', '", $allowedValues) + ) + ); + } + $this->container['scheme'] = $scheme; + + return $this; + } + + /** + * Gets expiration_date + * + * @return string|null + */ + public function getExpirationDate() + { + return $this->container['expiration_date']; + } + + /** + * Sets expiration_date + * + * @param string|null $expiration_date The expiration date for the payment method. + * + * @return self + */ + public function setExpirationDate($expiration_date) + { + if (!is_null($expiration_date) && (mb_strlen($expiration_date) > 5)) { + throw new \InvalidArgumentException('invalid length for $expiration_date when calling PaymentMethodTokenized., must be smaller than or equal to 5.'); + } + if (!is_null($expiration_date) && (mb_strlen($expiration_date) < 5)) { + throw new \InvalidArgumentException('invalid length for $expiration_date when calling PaymentMethodTokenized., must be bigger than or equal to 5.'); + } + if (!is_null($expiration_date) && (!preg_match("/^\\d{2}\/\\d{2}$/", $expiration_date))) { + throw new \InvalidArgumentException("invalid value for $expiration_date when calling PaymentMethodTokenized., must conform to the pattern /^\\d{2}\/\\d{2}$/."); + } + + $this->container['expiration_date'] = $expiration_date; + + return $this; + } + + /** + * Gets approval_target + * + * @return string|null + */ + public function getApprovalTarget() + { + return $this->container['approval_target']; + } + + /** + * Sets approval_target + * + * @param string|null $approval_target The browser target that an approval URL must be opened in. If `any` or `null`, then there is no specific requirement. + * + * @return self + */ + public function setApprovalTarget($approval_target) + { + $allowedValues = $this->getApprovalTargetAllowableValues(); + if (!is_null($approval_target) && !in_array($approval_target, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'approval_target', must be one of '%s'", + $approval_target, + implode("', '", $allowedValues) + ) + ); + } + $this->container['approval_target'] = $approval_target; + + return $this; + } + + /** + * Gets approval_url + * + * @return string|null + */ + public function getApprovalUrl() + { + return $this->container['approval_url']; + } + + /** + * Sets approval_url + * + * @param string|null $approval_url The optional URL that the buyer needs to be redirected to to further authorize their payment. + * + * @return self + */ + public function setApprovalUrl($approval_url) + { + $this->container['approval_url'] = $approval_url; + + return $this; + } + + /** + * Gets currency + * + * @return string|null + */ + public function getCurrency() + { + return $this->container['currency']; + } + + /** + * Sets currency + * + * @param string|null $currency The ISO-4217 currency code that this payment method can be used for. If this value is `null` the payment method may be used for multiple currencies. + * + * @return self + */ + public function setCurrency($currency) + { + $this->container['currency'] = $currency; + + return $this; + } + + /** + * Gets country + * + * @return string|null + */ + public function getCountry() + { + return $this->container['country']; + } + + /** + * Sets country + * + * @param string|null $country The 2-letter ISO code of the country this payment method can be used for. If this value is `null` the payment method may be used in multiple countries. + * + * @return self + */ + public function setCountry($country) + { + $this->container['country'] = $country; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/PaymentMethodTokens.php b/lib/model/PaymentMethodTokens.php new file mode 100644 index 0000000..296dc3d --- /dev/null +++ b/lib/model/PaymentMethodTokens.php @@ -0,0 +1,324 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class PaymentMethodTokens implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PaymentMethodTokens'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'items' => '\Gr4vy\model\PaymentMethodToken[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'items' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'items' => 'items' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'items' => 'setItems' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'items' => 'getItems' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['items'] = $data['items'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets items + * + * @return \Gr4vy\model\PaymentMethodToken[]|null + */ + public function getItems() + { + return $this->container['items']; + } + + /** + * Sets items + * + * @param \Gr4vy\model\PaymentMethodToken[]|null $items A list of stored tokens for payment methods. + * + * @return self + */ + public function setItems($items) + { + $this->container['items'] = $items; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/PaymentMethods.php b/lib/model/PaymentMethods.php new file mode 100644 index 0000000..538b47b --- /dev/null +++ b/lib/model/PaymentMethods.php @@ -0,0 +1,460 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class PaymentMethods implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PaymentMethods'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'items' => '\Gr4vy\model\PaymentMethod[]', + 'limit' => 'int', + 'next_cursor' => 'string', + 'previous_cursor' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'items' => null, + 'limit' => 'int32', + 'next_cursor' => null, + 'previous_cursor' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'items' => 'items', + 'limit' => 'limit', + 'next_cursor' => 'next_cursor', + 'previous_cursor' => 'previous_cursor' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'items' => 'setItems', + 'limit' => 'setLimit', + 'next_cursor' => 'setNextCursor', + 'previous_cursor' => 'setPreviousCursor' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'items' => 'getItems', + 'limit' => 'getLimit', + 'next_cursor' => 'getNextCursor', + 'previous_cursor' => 'getPreviousCursor' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['items'] = $data['items'] ?? null; + $this->container['limit'] = $data['limit'] ?? 20; + $this->container['next_cursor'] = $data['next_cursor'] ?? null; + $this->container['previous_cursor'] = $data['previous_cursor'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['limit']) && ($this->container['limit'] > 100)) { + $invalidProperties[] = "invalid value for 'limit', must be smaller than or equal to 100."; + } + + if (!is_null($this->container['limit']) && ($this->container['limit'] < 1)) { + $invalidProperties[] = "invalid value for 'limit', must be bigger than or equal to 1."; + } + + if (!is_null($this->container['next_cursor']) && (mb_strlen($this->container['next_cursor']) > 1000)) { + $invalidProperties[] = "invalid value for 'next_cursor', the character length must be smaller than or equal to 1000."; + } + + if (!is_null($this->container['next_cursor']) && (mb_strlen($this->container['next_cursor']) < 1)) { + $invalidProperties[] = "invalid value for 'next_cursor', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['previous_cursor']) && (mb_strlen($this->container['previous_cursor']) > 1000)) { + $invalidProperties[] = "invalid value for 'previous_cursor', the character length must be smaller than or equal to 1000."; + } + + if (!is_null($this->container['previous_cursor']) && (mb_strlen($this->container['previous_cursor']) < 1)) { + $invalidProperties[] = "invalid value for 'previous_cursor', the character length must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets items + * + * @return \Gr4vy\model\PaymentMethod[]|null + */ + public function getItems() + { + return $this->container['items']; + } + + /** + * Sets items + * + * @param \Gr4vy\model\PaymentMethod[]|null $items A list of stored payment methods. + * + * @return self + */ + public function setItems($items) + { + $this->container['items'] = $items; + + return $this; + } + + /** + * Gets limit + * + * @return int|null + */ + public function getLimit() + { + return $this->container['limit']; + } + + /** + * Sets limit + * + * @param int|null $limit The limit applied to request. This represents the number of items that are at maximum returned by this request. + * + * @return self + */ + public function setLimit($limit) + { + + if (!is_null($limit) && ($limit > 100)) { + throw new \InvalidArgumentException('invalid value for $limit when calling PaymentMethods., must be smaller than or equal to 100.'); + } + if (!is_null($limit) && ($limit < 1)) { + throw new \InvalidArgumentException('invalid value for $limit when calling PaymentMethods., must be bigger than or equal to 1.'); + } + + $this->container['limit'] = $limit; + + return $this; + } + + /** + * Gets next_cursor + * + * @return string|null + */ + public function getNextCursor() + { + return $this->container['next_cursor']; + } + + /** + * Sets next_cursor + * + * @param string|null $next_cursor The cursor that represents the next page of results. Use the `cursor` query parameter to fetch this page of items. + * + * @return self + */ + public function setNextCursor($next_cursor) + { + if (!is_null($next_cursor) && (mb_strlen($next_cursor) > 1000)) { + throw new \InvalidArgumentException('invalid length for $next_cursor when calling PaymentMethods., must be smaller than or equal to 1000.'); + } + if (!is_null($next_cursor) && (mb_strlen($next_cursor) < 1)) { + throw new \InvalidArgumentException('invalid length for $next_cursor when calling PaymentMethods., must be bigger than or equal to 1.'); + } + + $this->container['next_cursor'] = $next_cursor; + + return $this; + } + + /** + * Gets previous_cursor + * + * @return string|null + */ + public function getPreviousCursor() + { + return $this->container['previous_cursor']; + } + + /** + * Sets previous_cursor + * + * @param string|null $previous_cursor The cursor that represents the next page of results. Use the `cursor` query parameter to fetch this page of items. + * + * @return self + */ + public function setPreviousCursor($previous_cursor) + { + if (!is_null($previous_cursor) && (mb_strlen($previous_cursor) > 1000)) { + throw new \InvalidArgumentException('invalid length for $previous_cursor when calling PaymentMethods., must be smaller than or equal to 1000.'); + } + if (!is_null($previous_cursor) && (mb_strlen($previous_cursor) < 1)) { + throw new \InvalidArgumentException('invalid length for $previous_cursor when calling PaymentMethods., must be bigger than or equal to 1.'); + } + + $this->container['previous_cursor'] = $previous_cursor; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/PaymentMethodsTokenized.php b/lib/model/PaymentMethodsTokenized.php new file mode 100644 index 0000000..4164506 --- /dev/null +++ b/lib/model/PaymentMethodsTokenized.php @@ -0,0 +1,324 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class PaymentMethodsTokenized implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PaymentMethods--Tokenized'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'items' => '\Gr4vy\model\PaymentMethodTokenized[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'items' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'items' => 'items' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'items' => 'setItems' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'items' => 'getItems' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['items'] = $data['items'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets items + * + * @return \Gr4vy\model\PaymentMethodTokenized[]|null + */ + public function getItems() + { + return $this->container['items']; + } + + /** + * Sets items + * + * @param \Gr4vy\model\PaymentMethodTokenized[]|null $items A list of stored payment methods in token format. + * + * @return self + */ + public function setItems($items) + { + $this->container['items'] = $items; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/PaymentOption.php b/lib/model/PaymentOption.php new file mode 100644 index 0000000..f46d303 --- /dev/null +++ b/lib/model/PaymentOption.php @@ -0,0 +1,536 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class PaymentOption implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PaymentOption'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'method' => 'string', + 'icon_url' => 'string', + 'mode' => 'string', + 'label' => 'string', + 'can_store_payment_method' => 'bool', + 'context' => '\Gr4vy\model\PaymentOptionContext' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'method' => null, + 'icon_url' => null, + 'mode' => null, + 'label' => null, + 'can_store_payment_method' => null, + 'context' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'method' => 'method', + 'icon_url' => 'icon_url', + 'mode' => 'mode', + 'label' => 'label', + 'can_store_payment_method' => 'can_store_payment_method', + 'context' => 'context' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'method' => 'setMethod', + 'icon_url' => 'setIconUrl', + 'mode' => 'setMode', + 'label' => 'setLabel', + 'can_store_payment_method' => 'setCanStorePaymentMethod', + 'context' => 'setContext' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'method' => 'getMethod', + 'icon_url' => 'getIconUrl', + 'mode' => 'getMode', + 'label' => 'getLabel', + 'can_store_payment_method' => 'getCanStorePaymentMethod', + 'context' => 'getContext' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_PAYMENT_OPTION = 'payment-option'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_PAYMENT_OPTION, + ]; + } + + /** + * 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['type'] = $data['type'] ?? null; + $this->container['method'] = $data['method'] ?? null; + $this->container['icon_url'] = $data['icon_url'] ?? null; + $this->container['mode'] = $data['mode'] ?? null; + $this->container['label'] = $data['label'] ?? null; + $this->container['can_store_payment_method'] = $data['can_store_payment_method'] ?? null; + $this->container['context'] = $data['context'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type `payment-option`. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets method + * + * @return string|null + */ + public function getMethod() + { + return $this->container['method']; + } + + /** + * Sets method + * + * @param string|null $method method + * + * @return self + */ + public function setMethod($method) + { + $this->container['method'] = $method; + + return $this; + } + + /** + * Gets icon_url + * + * @return string|null + */ + public function getIconUrl() + { + return $this->container['icon_url']; + } + + /** + * Sets icon_url + * + * @param string|null $icon_url An icon to display for the payment option. + * + * @return self + */ + public function setIconUrl($icon_url) + { + $this->container['icon_url'] = $icon_url; + + return $this; + } + + /** + * Gets mode + * + * @return string|null + */ + public function getMode() + { + return $this->container['mode']; + } + + /** + * Sets mode + * + * @param string|null $mode mode + * + * @return self + */ + public function setMode($mode) + { + $this->container['mode'] = $mode; + + return $this; + } + + /** + * Gets label + * + * @return string|null + */ + public function getLabel() + { + return $this->container['label']; + } + + /** + * Sets label + * + * @param string|null $label A label that describes this payment option. This label is returned in the language defined by the `locale` query parameter. The label can be used to display a list of payment options to the buyer in their language. + * + * @return self + */ + public function setLabel($label) + { + $this->container['label'] = $label; + + return $this; + } + + /** + * Gets can_store_payment_method + * + * @return bool|null + */ + public function getCanStorePaymentMethod() + { + return $this->container['can_store_payment_method']; + } + + /** + * Sets can_store_payment_method + * + * @param bool|null $can_store_payment_method A flag to indicate if storing the payment method is supported. + * + * @return self + */ + public function setCanStorePaymentMethod($can_store_payment_method) + { + $this->container['can_store_payment_method'] = $can_store_payment_method; + + return $this; + } + + /** + * Gets context + * + * @return \Gr4vy\model\PaymentOptionContext|null + */ + public function getContext() + { + return $this->container['context']; + } + + /** + * Sets context + * + * @param \Gr4vy\model\PaymentOptionContext|null $context context + * + * @return self + */ + public function setContext($context) + { + $this->container['context'] = $context; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/PaymentOptionApprovalUI.php b/lib/model/PaymentOptionApprovalUI.php new file mode 100644 index 0000000..f2212fc --- /dev/null +++ b/lib/model/PaymentOptionApprovalUI.php @@ -0,0 +1,354 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class PaymentOptionApprovalUI implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PaymentOptionApprovalUI'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'height' => 'string', + 'width' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'height' => null, + 'width' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'height' => 'height', + 'width' => 'width' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'height' => 'setHeight', + 'width' => 'setWidth' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'height' => 'getHeight', + 'width' => 'getWidth' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['height'] = $data['height'] ?? null; + $this->container['width'] = $data['width'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets height + * + * @return string|null + */ + public function getHeight() + { + return $this->container['height']; + } + + /** + * Sets height + * + * @param string|null $height Height of the approval interface in either pixels or view height (vh). + * + * @return self + */ + public function setHeight($height) + { + $this->container['height'] = $height; + + return $this; + } + + /** + * Gets width + * + * @return string|null + */ + public function getWidth() + { + return $this->container['width']; + } + + /** + * Sets width + * + * @param string|null $width Width of the approval interface in either pixels or view width (vw). + * + * @return self + */ + public function setWidth($width) + { + $this->container['width'] = $width; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/PaymentOptionCardSchemeApplePay.php b/lib/model/PaymentOptionCardSchemeApplePay.php new file mode 100644 index 0000000..cd2fb24 --- /dev/null +++ b/lib/model/PaymentOptionCardSchemeApplePay.php @@ -0,0 +1,99 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class PaymentOptionContext implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PaymentOption_context'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'merchant_name' => 'string', + 'supported_schemes' => 'string[]', + 'approval_ui' => '\Gr4vy\model\PaymentOptionApprovalUI', + 'required_fields' => '\Gr4vy\model\RequiredFields' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'merchant_name' => null, + 'supported_schemes' => null, + 'approval_ui' => null, + 'required_fields' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'merchant_name' => 'merchant_name', + 'supported_schemes' => 'supported_schemes', + 'approval_ui' => 'approval_ui', + 'required_fields' => 'required_fields' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'merchant_name' => 'setMerchantName', + 'supported_schemes' => 'setSupportedSchemes', + 'approval_ui' => 'setApprovalUi', + 'required_fields' => 'setRequiredFields' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'merchant_name' => 'getMerchantName', + 'supported_schemes' => 'getSupportedSchemes', + 'approval_ui' => 'getApprovalUi', + 'required_fields' => 'getRequiredFields' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['merchant_name'] = $data['merchant_name'] ?? null; + $this->container['supported_schemes'] = $data['supported_schemes'] ?? null; + $this->container['approval_ui'] = $data['approval_ui'] ?? null; + $this->container['required_fields'] = $data['required_fields'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets merchant_name + * + * @return string|null + */ + public function getMerchantName() + { + return $this->container['merchant_name']; + } + + /** + * Sets merchant_name + * + * @param string|null $merchant_name Display name of the merchant as registered with the digital wallet provider. + * + * @return self + */ + public function setMerchantName($merchant_name) + { + $this->container['merchant_name'] = $merchant_name; + + return $this; + } + + /** + * Gets supported_schemes + * + * @return string[]|null + */ + public function getSupportedSchemes() + { + return $this->container['supported_schemes']; + } + + /** + * Sets supported_schemes + * + * @param string[]|null $supported_schemes Card schemes supported by the digital wallet provider. + * + * @return self + */ + public function setSupportedSchemes($supported_schemes) + { + $this->container['supported_schemes'] = $supported_schemes; + + return $this; + } + + /** + * Gets approval_ui + * + * @return \Gr4vy\model\PaymentOptionApprovalUI|null + */ + public function getApprovalUi() + { + return $this->container['approval_ui']; + } + + /** + * Sets approval_ui + * + * @param \Gr4vy\model\PaymentOptionApprovalUI|null $approval_ui approval_ui + * + * @return self + */ + public function setApprovalUi($approval_ui) + { + $this->container['approval_ui'] = $approval_ui; + + return $this; + } + + /** + * Gets required_fields + * + * @return \Gr4vy\model\RequiredFields|null + */ + public function getRequiredFields() + { + return $this->container['required_fields']; + } + + /** + * Sets required_fields + * + * @param \Gr4vy\model\RequiredFields|null $required_fields required_fields + * + * @return self + */ + public function setRequiredFields($required_fields) + { + $this->container['required_fields'] = $required_fields; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/PaymentOptions.php b/lib/model/PaymentOptions.php new file mode 100644 index 0000000..7a64d28 --- /dev/null +++ b/lib/model/PaymentOptions.php @@ -0,0 +1,324 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class PaymentOptions implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PaymentOptions'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'items' => '\Gr4vy\model\PaymentOption[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'items' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'items' => 'items' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'items' => 'setItems' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'items' => 'getItems' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['items'] = $data['items'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets items + * + * @return \Gr4vy\model\PaymentOption[]|null + */ + public function getItems() + { + return $this->container['items']; + } + + /** + * Sets items + * + * @param \Gr4vy\model\PaymentOption[]|null $items items + * + * @return self + */ + public function setItems($items) + { + $this->container['items'] = $items; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/PaymentService.php b/lib/model/PaymentService.php new file mode 100644 index 0000000..d2672b1 --- /dev/null +++ b/lib/model/PaymentService.php @@ -0,0 +1,1255 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class PaymentService implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PaymentService'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'type' => 'string', + 'payment_service_definition_id' => 'string', + 'method' => 'string', + 'display_name' => 'string', + 'status' => 'string', + 'accepted_currencies' => 'string[]', + 'accepted_countries' => 'string[]', + 'three_d_secure_enabled' => 'bool', + 'acquirer_bin_visa' => 'string', + 'acquirer_bin_mastercard' => 'string', + 'acquirer_bin_amex' => 'string', + 'acquirer_bin_discover' => 'string', + 'acquirer_merchant_id' => 'string', + 'merchant_name' => 'string', + 'merchant_country_code' => 'string', + 'merchant_category_code' => 'string', + 'merchant_url' => 'string', + 'active' => 'bool', + 'position' => 'float', + 'payment_method_tokenization_enabled' => 'bool', + 'created_at' => '\DateTime', + 'updated_at' => '\DateTime', + 'webhook_url' => 'string', + 'fields' => '\Gr4vy\model\PaymentServiceFieldsInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'uuid', + 'type' => null, + 'payment_service_definition_id' => null, + 'method' => null, + 'display_name' => null, + 'status' => null, + 'accepted_currencies' => null, + 'accepted_countries' => null, + 'three_d_secure_enabled' => null, + 'acquirer_bin_visa' => null, + 'acquirer_bin_mastercard' => null, + 'acquirer_bin_amex' => null, + 'acquirer_bin_discover' => null, + 'acquirer_merchant_id' => null, + 'merchant_name' => null, + 'merchant_country_code' => null, + 'merchant_category_code' => null, + 'merchant_url' => 'url', + 'active' => null, + 'position' => null, + 'payment_method_tokenization_enabled' => null, + 'created_at' => 'date-time', + 'updated_at' => 'date-time', + 'webhook_url' => 'url', + 'fields' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'type' => 'type', + 'payment_service_definition_id' => 'payment_service_definition_id', + 'method' => 'method', + 'display_name' => 'display_name', + 'status' => 'status', + 'accepted_currencies' => 'accepted_currencies', + 'accepted_countries' => 'accepted_countries', + 'three_d_secure_enabled' => 'three_d_secure_enabled', + 'acquirer_bin_visa' => 'acquirer_bin_visa', + 'acquirer_bin_mastercard' => 'acquirer_bin_mastercard', + 'acquirer_bin_amex' => 'acquirer_bin_amex', + 'acquirer_bin_discover' => 'acquirer_bin_discover', + 'acquirer_merchant_id' => 'acquirer_merchant_id', + 'merchant_name' => 'merchant_name', + 'merchant_country_code' => 'merchant_country_code', + 'merchant_category_code' => 'merchant_category_code', + 'merchant_url' => 'merchant_url', + 'active' => 'active', + 'position' => 'position', + 'payment_method_tokenization_enabled' => 'payment_method_tokenization_enabled', + 'created_at' => 'created_at', + 'updated_at' => 'updated_at', + 'webhook_url' => 'webhook_url', + 'fields' => 'fields' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'type' => 'setType', + 'payment_service_definition_id' => 'setPaymentServiceDefinitionId', + 'method' => 'setMethod', + 'display_name' => 'setDisplayName', + 'status' => 'setStatus', + 'accepted_currencies' => 'setAcceptedCurrencies', + 'accepted_countries' => 'setAcceptedCountries', + 'three_d_secure_enabled' => 'setThreeDSecureEnabled', + 'acquirer_bin_visa' => 'setAcquirerBinVisa', + 'acquirer_bin_mastercard' => 'setAcquirerBinMastercard', + 'acquirer_bin_amex' => 'setAcquirerBinAmex', + 'acquirer_bin_discover' => 'setAcquirerBinDiscover', + 'acquirer_merchant_id' => 'setAcquirerMerchantId', + 'merchant_name' => 'setMerchantName', + 'merchant_country_code' => 'setMerchantCountryCode', + 'merchant_category_code' => 'setMerchantCategoryCode', + 'merchant_url' => 'setMerchantUrl', + 'active' => 'setActive', + 'position' => 'setPosition', + 'payment_method_tokenization_enabled' => 'setPaymentMethodTokenizationEnabled', + 'created_at' => 'setCreatedAt', + 'updated_at' => 'setUpdatedAt', + 'webhook_url' => 'setWebhookUrl', + 'fields' => 'setFields' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'type' => 'getType', + 'payment_service_definition_id' => 'getPaymentServiceDefinitionId', + 'method' => 'getMethod', + 'display_name' => 'getDisplayName', + 'status' => 'getStatus', + 'accepted_currencies' => 'getAcceptedCurrencies', + 'accepted_countries' => 'getAcceptedCountries', + 'three_d_secure_enabled' => 'getThreeDSecureEnabled', + 'acquirer_bin_visa' => 'getAcquirerBinVisa', + 'acquirer_bin_mastercard' => 'getAcquirerBinMastercard', + 'acquirer_bin_amex' => 'getAcquirerBinAmex', + 'acquirer_bin_discover' => 'getAcquirerBinDiscover', + 'acquirer_merchant_id' => 'getAcquirerMerchantId', + 'merchant_name' => 'getMerchantName', + 'merchant_country_code' => 'getMerchantCountryCode', + 'merchant_category_code' => 'getMerchantCategoryCode', + 'merchant_url' => 'getMerchantUrl', + 'active' => 'getActive', + 'position' => 'getPosition', + 'payment_method_tokenization_enabled' => 'getPaymentMethodTokenizationEnabled', + 'created_at' => 'getCreatedAt', + 'updated_at' => 'getUpdatedAt', + 'webhook_url' => 'getWebhookUrl', + 'fields' => 'getFields' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_PAYMENT_SERVICE = 'payment-service'; + public const STATUS_PENDING = 'pending'; + public const STATUS_CREATED = 'created'; + public const STATUS_FAILED = 'failed'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_PAYMENT_SERVICE, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStatusAllowableValues() + { + return [ + self::STATUS_PENDING, + self::STATUS_CREATED, + self::STATUS_FAILED, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['id'] = $data['id'] ?? null; + $this->container['type'] = $data['type'] ?? null; + $this->container['payment_service_definition_id'] = $data['payment_service_definition_id'] ?? null; + $this->container['method'] = $data['method'] ?? null; + $this->container['display_name'] = $data['display_name'] ?? null; + $this->container['status'] = $data['status'] ?? null; + $this->container['accepted_currencies'] = $data['accepted_currencies'] ?? null; + $this->container['accepted_countries'] = $data['accepted_countries'] ?? null; + $this->container['three_d_secure_enabled'] = $data['three_d_secure_enabled'] ?? false; + $this->container['acquirer_bin_visa'] = $data['acquirer_bin_visa'] ?? null; + $this->container['acquirer_bin_mastercard'] = $data['acquirer_bin_mastercard'] ?? null; + $this->container['acquirer_bin_amex'] = $data['acquirer_bin_amex'] ?? null; + $this->container['acquirer_bin_discover'] = $data['acquirer_bin_discover'] ?? null; + $this->container['acquirer_merchant_id'] = $data['acquirer_merchant_id'] ?? null; + $this->container['merchant_name'] = $data['merchant_name'] ?? null; + $this->container['merchant_country_code'] = $data['merchant_country_code'] ?? null; + $this->container['merchant_category_code'] = $data['merchant_category_code'] ?? null; + $this->container['merchant_url'] = $data['merchant_url'] ?? null; + $this->container['active'] = $data['active'] ?? true; + $this->container['position'] = $data['position'] ?? null; + $this->container['payment_method_tokenization_enabled'] = $data['payment_method_tokenization_enabled'] ?? false; + $this->container['created_at'] = $data['created_at'] ?? null; + $this->container['updated_at'] = $data['updated_at'] ?? null; + $this->container['webhook_url'] = $data['webhook_url'] ?? null; + $this->container['fields'] = $data['fields'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['id']) && (mb_strlen($this->container['id']) > 200)) { + $invalidProperties[] = "invalid value for 'id', the character length must be smaller than or equal to 200."; + } + + if (!is_null($this->container['id']) && (mb_strlen($this->container['id']) < 1)) { + $invalidProperties[] = "invalid value for 'id', the character length must be bigger than or equal to 1."; + } + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + if (!is_null($this->container['payment_service_definition_id']) && (mb_strlen($this->container['payment_service_definition_id']) > 50)) { + $invalidProperties[] = "invalid value for 'payment_service_definition_id', the character length must be smaller than or equal to 50."; + } + + if (!is_null($this->container['payment_service_definition_id']) && (mb_strlen($this->container['payment_service_definition_id']) < 1)) { + $invalidProperties[] = "invalid value for 'payment_service_definition_id', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['display_name']) && (mb_strlen($this->container['display_name']) > 200)) { + $invalidProperties[] = "invalid value for 'display_name', the character length must be smaller than or equal to 200."; + } + + if (!is_null($this->container['display_name']) && (mb_strlen($this->container['display_name']) < 1)) { + $invalidProperties[] = "invalid value for 'display_name', the character length must be bigger than or equal to 1."; + } + + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($this->container['status']) && !in_array($this->container['status'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'status', must be one of '%s'", + $this->container['status'], + implode("', '", $allowedValues) + ); + } + + if (!is_null($this->container['accepted_currencies']) && (count($this->container['accepted_currencies']) < 1)) { + $invalidProperties[] = "invalid value for 'accepted_currencies', number of items must be greater than or equal to 1."; + } + + if (!is_null($this->container['accepted_countries']) && (count($this->container['accepted_countries']) < 1)) { + $invalidProperties[] = "invalid value for 'accepted_countries', number of items must be greater than or equal to 1."; + } + + if (!is_null($this->container['acquirer_bin_visa']) && (mb_strlen($this->container['acquirer_bin_visa']) > 11)) { + $invalidProperties[] = "invalid value for 'acquirer_bin_visa', the character length must be smaller than or equal to 11."; + } + + if (!is_null($this->container['acquirer_bin_mastercard']) && (mb_strlen($this->container['acquirer_bin_mastercard']) > 11)) { + $invalidProperties[] = "invalid value for 'acquirer_bin_mastercard', the character length must be smaller than or equal to 11."; + } + + if (!is_null($this->container['acquirer_bin_amex']) && (mb_strlen($this->container['acquirer_bin_amex']) > 11)) { + $invalidProperties[] = "invalid value for 'acquirer_bin_amex', the character length must be smaller than or equal to 11."; + } + + if (!is_null($this->container['acquirer_bin_discover']) && (mb_strlen($this->container['acquirer_bin_discover']) > 11)) { + $invalidProperties[] = "invalid value for 'acquirer_bin_discover', the character length must be smaller than or equal to 11."; + } + + if (!is_null($this->container['acquirer_merchant_id']) && (mb_strlen($this->container['acquirer_merchant_id']) > 35)) { + $invalidProperties[] = "invalid value for 'acquirer_merchant_id', the character length must be smaller than or equal to 35."; + } + + if (!is_null($this->container['merchant_name']) && (mb_strlen($this->container['merchant_name']) > 40)) { + $invalidProperties[] = "invalid value for 'merchant_name', the character length must be smaller than or equal to 40."; + } + + if (!is_null($this->container['merchant_country_code']) && !preg_match("/^\\d{3}$/", $this->container['merchant_country_code'])) { + $invalidProperties[] = "invalid value for 'merchant_country_code', must be conform to the pattern /^\\d{3}$/."; + } + + if (!is_null($this->container['merchant_category_code']) && (mb_strlen($this->container['merchant_category_code']) > 4)) { + $invalidProperties[] = "invalid value for 'merchant_category_code', the character length must be smaller than or equal to 4."; + } + + if (!is_null($this->container['merchant_category_code']) && (mb_strlen($this->container['merchant_category_code']) < 4)) { + $invalidProperties[] = "invalid value for 'merchant_category_code', the character length must be bigger than or equal to 4."; + } + + if (!is_null($this->container['merchant_url']) && (mb_strlen($this->container['merchant_url']) > 2048)) { + $invalidProperties[] = "invalid value for 'merchant_url', the character length must be smaller than or equal to 2048."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id The ID of this payment service. + * + * @return self + */ + public function setId($id) + { + if (!is_null($id) && (mb_strlen($id) > 200)) { + throw new \InvalidArgumentException('invalid length for $id when calling PaymentService., must be smaller than or equal to 200.'); + } + if (!is_null($id) && (mb_strlen($id) < 1)) { + throw new \InvalidArgumentException('invalid length for $id when calling PaymentService., must be bigger than or equal to 1.'); + } + + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type The type of this resource. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets payment_service_definition_id + * + * @return string|null + */ + public function getPaymentServiceDefinitionId() + { + return $this->container['payment_service_definition_id']; + } + + /** + * Sets payment_service_definition_id + * + * @param string|null $payment_service_definition_id The ID of the payment service definition used to create this service. + * + * @return self + */ + public function setPaymentServiceDefinitionId($payment_service_definition_id) + { + if (!is_null($payment_service_definition_id) && (mb_strlen($payment_service_definition_id) > 50)) { + throw new \InvalidArgumentException('invalid length for $payment_service_definition_id when calling PaymentService., must be smaller than or equal to 50.'); + } + if (!is_null($payment_service_definition_id) && (mb_strlen($payment_service_definition_id) < 1)) { + throw new \InvalidArgumentException('invalid length for $payment_service_definition_id when calling PaymentService., must be bigger than or equal to 1.'); + } + + $this->container['payment_service_definition_id'] = $payment_service_definition_id; + + return $this; + } + + /** + * Gets method + * + * @return string|null + */ + public function getMethod() + { + return $this->container['method']; + } + + /** + * Sets method + * + * @param string|null $method method + * + * @return self + */ + public function setMethod($method) + { + $this->container['method'] = $method; + + return $this; + } + + /** + * Gets display_name + * + * @return string|null + */ + public function getDisplayName() + { + return $this->container['display_name']; + } + + /** + * Sets display_name + * + * @param string|null $display_name The custom name set for this service. + * + * @return self + */ + public function setDisplayName($display_name) + { + if (!is_null($display_name) && (mb_strlen($display_name) > 200)) { + throw new \InvalidArgumentException('invalid length for $display_name when calling PaymentService., must be smaller than or equal to 200.'); + } + if (!is_null($display_name) && (mb_strlen($display_name) < 1)) { + throw new \InvalidArgumentException('invalid length for $display_name when calling PaymentService., must be bigger than or equal to 1.'); + } + + $this->container['display_name'] = $display_name; + + return $this; + } + + /** + * Gets status + * + * @return string|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param string|null $status The current status of this service. This will start off as pending, move to created, and might eventually move to an error status if and when the credentials are no longer valid. + * + * @return self + */ + public function setStatus($status) + { + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($status) && !in_array($status, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'status', must be one of '%s'", + $status, + implode("', '", $allowedValues) + ) + ); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets accepted_currencies + * + * @return string[]|null + */ + public function getAcceptedCurrencies() + { + return $this->container['accepted_currencies']; + } + + /** + * Sets accepted_currencies + * + * @param string[]|null $accepted_currencies A list of currencies for which this service is enabled, in ISO 4217 three-letter code format. + * + * @return self + */ + public function setAcceptedCurrencies($accepted_currencies) + { + + + if (!is_null($accepted_currencies) && (count($accepted_currencies) < 1)) { + throw new \InvalidArgumentException('invalid length for $accepted_currencies when calling PaymentService., number of items must be greater than or equal to 1.'); + } + $this->container['accepted_currencies'] = $accepted_currencies; + + return $this; + } + + /** + * Gets accepted_countries + * + * @return string[]|null + */ + public function getAcceptedCountries() + { + return $this->container['accepted_countries']; + } + + /** + * Sets accepted_countries + * + * @param string[]|null $accepted_countries A list of countries for which this service is enabled, in ISO two-letter code format. + * + * @return self + */ + public function setAcceptedCountries($accepted_countries) + { + + + if (!is_null($accepted_countries) && (count($accepted_countries) < 1)) { + throw new \InvalidArgumentException('invalid length for $accepted_countries when calling PaymentService., number of items must be greater than or equal to 1.'); + } + $this->container['accepted_countries'] = $accepted_countries; + + return $this; + } + + /** + * Gets three_d_secure_enabled + * + * @return bool|null + */ + public function getThreeDSecureEnabled() + { + return $this->container['three_d_secure_enabled']; + } + + /** + * Sets three_d_secure_enabled + * + * @param bool|null $three_d_secure_enabled Defines if 3-D Secure is enabled for the service (can only be enabled if the payment service definition supports the `three_d_secure_hosted` feature). This does not affect pass through 3-D Secure data. + * + * @return self + */ + public function setThreeDSecureEnabled($three_d_secure_enabled) + { + $this->container['three_d_secure_enabled'] = $three_d_secure_enabled; + + return $this; + } + + /** + * Gets acquirer_bin_visa + * + * @return string|null + */ + public function getAcquirerBinVisa() + { + return $this->container['acquirer_bin_visa']; + } + + /** + * Sets acquirer_bin_visa + * + * @param string|null $acquirer_bin_visa Acquiring institution identification code for VISA. + * + * @return self + */ + public function setAcquirerBinVisa($acquirer_bin_visa) + { + if (!is_null($acquirer_bin_visa) && (mb_strlen($acquirer_bin_visa) > 11)) { + throw new \InvalidArgumentException('invalid length for $acquirer_bin_visa when calling PaymentService., must be smaller than or equal to 11.'); + } + + $this->container['acquirer_bin_visa'] = $acquirer_bin_visa; + + return $this; + } + + /** + * Gets acquirer_bin_mastercard + * + * @return string|null + */ + public function getAcquirerBinMastercard() + { + return $this->container['acquirer_bin_mastercard']; + } + + /** + * Sets acquirer_bin_mastercard + * + * @param string|null $acquirer_bin_mastercard Acquiring institution identification code for Mastercard. + * + * @return self + */ + public function setAcquirerBinMastercard($acquirer_bin_mastercard) + { + if (!is_null($acquirer_bin_mastercard) && (mb_strlen($acquirer_bin_mastercard) > 11)) { + throw new \InvalidArgumentException('invalid length for $acquirer_bin_mastercard when calling PaymentService., must be smaller than or equal to 11.'); + } + + $this->container['acquirer_bin_mastercard'] = $acquirer_bin_mastercard; + + return $this; + } + + /** + * Gets acquirer_bin_amex + * + * @return string|null + */ + public function getAcquirerBinAmex() + { + return $this->container['acquirer_bin_amex']; + } + + /** + * Sets acquirer_bin_amex + * + * @param string|null $acquirer_bin_amex Acquiring institution identification code for Amex. + * + * @return self + */ + public function setAcquirerBinAmex($acquirer_bin_amex) + { + if (!is_null($acquirer_bin_amex) && (mb_strlen($acquirer_bin_amex) > 11)) { + throw new \InvalidArgumentException('invalid length for $acquirer_bin_amex when calling PaymentService., must be smaller than or equal to 11.'); + } + + $this->container['acquirer_bin_amex'] = $acquirer_bin_amex; + + return $this; + } + + /** + * Gets acquirer_bin_discover + * + * @return string|null + */ + public function getAcquirerBinDiscover() + { + return $this->container['acquirer_bin_discover']; + } + + /** + * Sets acquirer_bin_discover + * + * @param string|null $acquirer_bin_discover Acquiring institution identification code for Discover. + * + * @return self + */ + public function setAcquirerBinDiscover($acquirer_bin_discover) + { + if (!is_null($acquirer_bin_discover) && (mb_strlen($acquirer_bin_discover) > 11)) { + throw new \InvalidArgumentException('invalid length for $acquirer_bin_discover when calling PaymentService., must be smaller than or equal to 11.'); + } + + $this->container['acquirer_bin_discover'] = $acquirer_bin_discover; + + return $this; + } + + /** + * Gets acquirer_merchant_id + * + * @return string|null + */ + public function getAcquirerMerchantId() + { + return $this->container['acquirer_merchant_id']; + } + + /** + * Sets acquirer_merchant_id + * + * @param string|null $acquirer_merchant_id Merchant identifier used in authorisation requests (assigned by the acquirer). + * + * @return self + */ + public function setAcquirerMerchantId($acquirer_merchant_id) + { + if (!is_null($acquirer_merchant_id) && (mb_strlen($acquirer_merchant_id) > 35)) { + throw new \InvalidArgumentException('invalid length for $acquirer_merchant_id when calling PaymentService., must be smaller than or equal to 35.'); + } + + $this->container['acquirer_merchant_id'] = $acquirer_merchant_id; + + return $this; + } + + /** + * Gets merchant_name + * + * @return string|null + */ + public function getMerchantName() + { + return $this->container['merchant_name']; + } + + /** + * Sets merchant_name + * + * @param string|null $merchant_name Merchant name (assigned by the acquirer). + * + * @return self + */ + public function setMerchantName($merchant_name) + { + if (!is_null($merchant_name) && (mb_strlen($merchant_name) > 40)) { + throw new \InvalidArgumentException('invalid length for $merchant_name when calling PaymentService., must be smaller than or equal to 40.'); + } + + $this->container['merchant_name'] = $merchant_name; + + return $this; + } + + /** + * Gets merchant_country_code + * + * @return string|null + */ + public function getMerchantCountryCode() + { + return $this->container['merchant_country_code']; + } + + /** + * Sets merchant_country_code + * + * @param string|null $merchant_country_code ISO 3166-1 numeric three-digit country code. + * + * @return self + */ + public function setMerchantCountryCode($merchant_country_code) + { + + if (!is_null($merchant_country_code) && (!preg_match("/^\\d{3}$/", $merchant_country_code))) { + throw new \InvalidArgumentException("invalid value for $merchant_country_code when calling PaymentService., must conform to the pattern /^\\d{3}$/."); + } + + $this->container['merchant_country_code'] = $merchant_country_code; + + return $this; + } + + /** + * Gets merchant_category_code + * + * @return string|null + */ + public function getMerchantCategoryCode() + { + return $this->container['merchant_category_code']; + } + + /** + * Sets merchant_category_code + * + * @param string|null $merchant_category_code Merchant category code that describes the business. + * + * @return self + */ + public function setMerchantCategoryCode($merchant_category_code) + { + if (!is_null($merchant_category_code) && (mb_strlen($merchant_category_code) > 4)) { + throw new \InvalidArgumentException('invalid length for $merchant_category_code when calling PaymentService., must be smaller than or equal to 4.'); + } + if (!is_null($merchant_category_code) && (mb_strlen($merchant_category_code) < 4)) { + throw new \InvalidArgumentException('invalid length for $merchant_category_code when calling PaymentService., must be bigger than or equal to 4.'); + } + + $this->container['merchant_category_code'] = $merchant_category_code; + + return $this; + } + + /** + * Gets merchant_url + * + * @return string|null + */ + public function getMerchantUrl() + { + return $this->container['merchant_url']; + } + + /** + * Sets merchant_url + * + * @param string|null $merchant_url Fully qualified URL of 3-D Secure requestor website or customer care site. + * + * @return self + */ + public function setMerchantUrl($merchant_url) + { + if (!is_null($merchant_url) && (mb_strlen($merchant_url) > 2048)) { + throw new \InvalidArgumentException('invalid length for $merchant_url when calling PaymentService., must be smaller than or equal to 2048.'); + } + + $this->container['merchant_url'] = $merchant_url; + + return $this; + } + + /** + * Gets active + * + * @return bool|null + */ + public function getActive() + { + return $this->container['active']; + } + + /** + * Sets active + * + * @param bool|null $active Defines if this service is currently active or not. + * + * @return self + */ + public function setActive($active) + { + $this->container['active'] = $active; + + return $this; + } + + /** + * Gets position + * + * @return float|null + */ + public function getPosition() + { + return $this->container['position']; + } + + /** + * Sets position + * + * @param float|null $position The numeric rank of a payment service. Payment services with a lower position value are processed first. + * + * @return self + */ + public function setPosition($position) + { + $this->container['position'] = $position; + + return $this; + } + + /** + * Gets payment_method_tokenization_enabled + * + * @return bool|null + */ + public function getPaymentMethodTokenizationEnabled() + { + return $this->container['payment_method_tokenization_enabled']; + } + + /** + * Sets payment_method_tokenization_enabled + * + * @param bool|null $payment_method_tokenization_enabled Defines if tokenization is enabled for the service (can only be enabled if the payment service definition supports it). + * + * @return self + */ + public function setPaymentMethodTokenizationEnabled($payment_method_tokenization_enabled) + { + $this->container['payment_method_tokenization_enabled'] = $payment_method_tokenization_enabled; + + return $this; + } + + /** + * Gets created_at + * + * @return \DateTime|null + */ + public function getCreatedAt() + { + return $this->container['created_at']; + } + + /** + * Sets created_at + * + * @param \DateTime|null $created_at The date and time when this service was created. + * + * @return self + */ + public function setCreatedAt($created_at) + { + $this->container['created_at'] = $created_at; + + return $this; + } + + /** + * Gets updated_at + * + * @return \DateTime|null + */ + public function getUpdatedAt() + { + return $this->container['updated_at']; + } + + /** + * Sets updated_at + * + * @param \DateTime|null $updated_at The date and time when this service was last updated. + * + * @return self + */ + public function setUpdatedAt($updated_at) + { + $this->container['updated_at'] = $updated_at; + + return $this; + } + + /** + * Gets webhook_url + * + * @return string|null + */ + public function getWebhookUrl() + { + return $this->container['webhook_url']; + } + + /** + * Sets webhook_url + * + * @param string|null $webhook_url The URL that needs to be configured with this payment service as the receiving endpoint for webhooks from the service to Gr4vy. Currently, Gr4vy does not yet automatically register webhooks on setup, and therefore webhooks need to be registered manually by the merchant. + * + * @return self + */ + public function setWebhookUrl($webhook_url) + { + $this->container['webhook_url'] = $webhook_url; + + return $this; + } + + /** + * Gets fields + * + * @return \Gr4vy\model\PaymentServiceFieldsInner[]|null + */ + public function getFields() + { + return $this->container['fields']; + } + + /** + * Sets fields + * + * @param \Gr4vy\model\PaymentServiceFieldsInner[]|null $fields A list of fields, each containing a key-value pair for each field configured for this payment service. Fields marked as `secret` (see Payment Service Definition) are not returned. + * + * @return self + */ + public function setFields($fields) + { + $this->container['fields'] = $fields; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/PaymentServiceDefinition.php b/lib/model/PaymentServiceDefinition.php new file mode 100644 index 0000000..bebcaee --- /dev/null +++ b/lib/model/PaymentServiceDefinition.php @@ -0,0 +1,651 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class PaymentServiceDefinition implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PaymentServiceDefinition'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'type' => 'string', + 'display_name' => 'string', + 'method' => 'string', + 'fields' => '\Gr4vy\model\PaymentServiceDefinitionFieldsInner[]', + 'supported_currencies' => 'string[]', + 'supported_countries' => 'string[]', + 'mode' => 'string', + 'supported_features' => '\Gr4vy\model\PaymentServiceDefinitionSupportedFeatures', + 'icon_url' => 'string', + 'configuration' => '\Gr4vy\model\PaymentServiceDefinitionConfiguration' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'type' => null, + 'display_name' => null, + 'method' => null, + 'fields' => null, + 'supported_currencies' => null, + 'supported_countries' => null, + 'mode' => null, + 'supported_features' => null, + 'icon_url' => null, + 'configuration' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'type' => 'type', + 'display_name' => 'display_name', + 'method' => 'method', + 'fields' => 'fields', + 'supported_currencies' => 'supported_currencies', + 'supported_countries' => 'supported_countries', + 'mode' => 'mode', + 'supported_features' => 'supported_features', + 'icon_url' => 'icon_url', + 'configuration' => 'configuration' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'type' => 'setType', + 'display_name' => 'setDisplayName', + 'method' => 'setMethod', + 'fields' => 'setFields', + 'supported_currencies' => 'setSupportedCurrencies', + 'supported_countries' => 'setSupportedCountries', + 'mode' => 'setMode', + 'supported_features' => 'setSupportedFeatures', + 'icon_url' => 'setIconUrl', + 'configuration' => 'setConfiguration' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'type' => 'getType', + 'display_name' => 'getDisplayName', + 'method' => 'getMethod', + 'fields' => 'getFields', + 'supported_currencies' => 'getSupportedCurrencies', + 'supported_countries' => 'getSupportedCountries', + 'mode' => 'getMode', + 'supported_features' => 'getSupportedFeatures', + 'icon_url' => 'getIconUrl', + 'configuration' => 'getConfiguration' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['id'] = $data['id'] ?? null; + $this->container['type'] = $data['type'] ?? 'payment-service-definition'; + $this->container['display_name'] = $data['display_name'] ?? null; + $this->container['method'] = $data['method'] ?? null; + $this->container['fields'] = $data['fields'] ?? null; + $this->container['supported_currencies'] = $data['supported_currencies'] ?? null; + $this->container['supported_countries'] = $data['supported_countries'] ?? null; + $this->container['mode'] = $data['mode'] ?? null; + $this->container['supported_features'] = $data['supported_features'] ?? null; + $this->container['icon_url'] = $data['icon_url'] ?? null; + $this->container['configuration'] = $data['configuration'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['fields']) && (count($this->container['fields']) < 1)) { + $invalidProperties[] = "invalid value for 'fields', number of items must be greater than or equal to 1."; + } + + if (!is_null($this->container['supported_currencies']) && (count($this->container['supported_currencies']) < 1)) { + $invalidProperties[] = "invalid value for 'supported_currencies', number of items must be greater than or equal to 1."; + } + + if (!is_null($this->container['supported_countries']) && (count($this->container['supported_countries']) < 1)) { + $invalidProperties[] = "invalid value for 'supported_countries', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id The ID of the payment service. This is the underlying provider followed by a dash followed by the payment method ID. + * + * @return self + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type `payment-service-definition`. + * + * @return self + */ + public function setType($type) + { + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets display_name + * + * @return string|null + */ + public function getDisplayName() + { + return $this->container['display_name']; + } + + /** + * Sets display_name + * + * @param string|null $display_name The display name of this service. + * + * @return self + */ + public function setDisplayName($display_name) + { + $this->container['display_name'] = $display_name; + + return $this; + } + + /** + * Gets method + * + * @return string|null + */ + public function getMethod() + { + return $this->container['method']; + } + + /** + * Sets method + * + * @param string|null $method method + * + * @return self + */ + public function setMethod($method) + { + $this->container['method'] = $method; + + return $this; + } + + /** + * Gets fields + * + * @return \Gr4vy\model\PaymentServiceDefinitionFieldsInner[]|null + */ + public function getFields() + { + return $this->container['fields']; + } + + /** + * Sets fields + * + * @param \Gr4vy\model\PaymentServiceDefinitionFieldsInner[]|null $fields A list of fields that need to be submitted when activating the payment. service. + * + * @return self + */ + public function setFields($fields) + { + + + if (!is_null($fields) && (count($fields) < 1)) { + throw new \InvalidArgumentException('invalid length for $fields when calling PaymentServiceDefinition., number of items must be greater than or equal to 1.'); + } + $this->container['fields'] = $fields; + + return $this; + } + + /** + * Gets supported_currencies + * + * @return string[]|null + */ + public function getSupportedCurrencies() + { + return $this->container['supported_currencies']; + } + + /** + * Sets supported_currencies + * + * @param string[]|null $supported_currencies A list of three-letter ISO currency codes that this service supports. + * + * @return self + */ + public function setSupportedCurrencies($supported_currencies) + { + + + if (!is_null($supported_currencies) && (count($supported_currencies) < 1)) { + throw new \InvalidArgumentException('invalid length for $supported_currencies when calling PaymentServiceDefinition., number of items must be greater than or equal to 1.'); + } + $this->container['supported_currencies'] = $supported_currencies; + + return $this; + } + + /** + * Gets supported_countries + * + * @return string[]|null + */ + public function getSupportedCountries() + { + return $this->container['supported_countries']; + } + + /** + * Sets supported_countries + * + * @param string[]|null $supported_countries A list of two-letter ISO country codes that this service supports. + * + * @return self + */ + public function setSupportedCountries($supported_countries) + { + + + if (!is_null($supported_countries) && (count($supported_countries) < 1)) { + throw new \InvalidArgumentException('invalid length for $supported_countries when calling PaymentServiceDefinition., number of items must be greater than or equal to 1.'); + } + $this->container['supported_countries'] = $supported_countries; + + return $this; + } + + /** + * Gets mode + * + * @return string|null + */ + public function getMode() + { + return $this->container['mode']; + } + + /** + * Sets mode + * + * @param string|null $mode mode + * + * @return self + */ + public function setMode($mode) + { + $this->container['mode'] = $mode; + + return $this; + } + + /** + * Gets supported_features + * + * @return \Gr4vy\model\PaymentServiceDefinitionSupportedFeatures|null + */ + public function getSupportedFeatures() + { + return $this->container['supported_features']; + } + + /** + * Sets supported_features + * + * @param \Gr4vy\model\PaymentServiceDefinitionSupportedFeatures|null $supported_features supported_features + * + * @return self + */ + public function setSupportedFeatures($supported_features) + { + $this->container['supported_features'] = $supported_features; + + return $this; + } + + /** + * Gets icon_url + * + * @return string|null + */ + public function getIconUrl() + { + return $this->container['icon_url']; + } + + /** + * Sets icon_url + * + * @param string|null $icon_url An icon to display for the payment service. + * + * @return self + */ + public function setIconUrl($icon_url) + { + $this->container['icon_url'] = $icon_url; + + return $this; + } + + /** + * Gets configuration + * + * @return \Gr4vy\model\PaymentServiceDefinitionConfiguration|null + */ + public function getConfiguration() + { + return $this->container['configuration']; + } + + /** + * Sets configuration + * + * @param \Gr4vy\model\PaymentServiceDefinitionConfiguration|null $configuration configuration + * + * @return self + */ + public function setConfiguration($configuration) + { + $this->container['configuration'] = $configuration; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/PaymentServiceDefinitionConfiguration.php b/lib/model/PaymentServiceDefinitionConfiguration.php new file mode 100644 index 0000000..6086dad --- /dev/null +++ b/lib/model/PaymentServiceDefinitionConfiguration.php @@ -0,0 +1,418 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class PaymentServiceDefinitionConfiguration implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PaymentServiceDefinitionConfiguration'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'approval_ui_height' => 'string', + 'approval_ui_width' => 'string', + 'approval_ui_target' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'approval_ui_height' => null, + 'approval_ui_width' => null, + 'approval_ui_target' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'approval_ui_height' => 'approval_ui_height', + 'approval_ui_width' => 'approval_ui_width', + 'approval_ui_target' => 'approval_ui_target' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'approval_ui_height' => 'setApprovalUiHeight', + 'approval_ui_width' => 'setApprovalUiWidth', + 'approval_ui_target' => 'setApprovalUiTarget' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'approval_ui_height' => 'getApprovalUiHeight', + 'approval_ui_width' => 'getApprovalUiWidth', + 'approval_ui_target' => 'getApprovalUiTarget' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const APPROVAL_UI_TARGET_ANY = 'any'; + public const APPROVAL_UI_TARGET_NEW_WINDOW = 'new_window'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getApprovalUiTargetAllowableValues() + { + return [ + self::APPROVAL_UI_TARGET_ANY, + self::APPROVAL_UI_TARGET_NEW_WINDOW, + ]; + } + + /** + * 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['approval_ui_height'] = $data['approval_ui_height'] ?? null; + $this->container['approval_ui_width'] = $data['approval_ui_width'] ?? null; + $this->container['approval_ui_target'] = $data['approval_ui_target'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getApprovalUiTargetAllowableValues(); + if (!is_null($this->container['approval_ui_target']) && !in_array($this->container['approval_ui_target'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'approval_ui_target', must be one of '%s'", + $this->container['approval_ui_target'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets approval_ui_height + * + * @return string|null + */ + public function getApprovalUiHeight() + { + return $this->container['approval_ui_height']; + } + + /** + * Sets approval_ui_height + * + * @param string|null $approval_ui_height Height of the approval interface in either pixels or view height (vh). + * + * @return self + */ + public function setApprovalUiHeight($approval_ui_height) + { + $this->container['approval_ui_height'] = $approval_ui_height; + + return $this; + } + + /** + * Gets approval_ui_width + * + * @return string|null + */ + public function getApprovalUiWidth() + { + return $this->container['approval_ui_width']; + } + + /** + * Sets approval_ui_width + * + * @param string|null $approval_ui_width Width of the approval interface in either pixels or view width (vw). + * + * @return self + */ + public function setApprovalUiWidth($approval_ui_width) + { + $this->container['approval_ui_width'] = $approval_ui_width; + + return $this; + } + + /** + * Gets approval_ui_target + * + * @return string|null + */ + public function getApprovalUiTarget() + { + return $this->container['approval_ui_target']; + } + + /** + * Sets approval_ui_target + * + * @param string|null $approval_ui_target The browser target that an approval URL must be opened in. If `any` or `null`, then there is no specific requirement. + * + * @return self + */ + public function setApprovalUiTarget($approval_ui_target) + { + $allowedValues = $this->getApprovalUiTargetAllowableValues(); + if (!is_null($approval_ui_target) && !in_array($approval_ui_target, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'approval_ui_target', must be one of '%s'", + $approval_ui_target, + implode("', '", $allowedValues) + ) + ); + } + $this->container['approval_ui_target'] = $approval_ui_target; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/PaymentServiceDefinitionFieldsInner.php b/lib/model/PaymentServiceDefinitionFieldsInner.php new file mode 100644 index 0000000..efcc8e2 --- /dev/null +++ b/lib/model/PaymentServiceDefinitionFieldsInner.php @@ -0,0 +1,480 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class PaymentServiceDefinitionFieldsInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PaymentServiceDefinition_fields_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'key' => 'string', + 'display_name' => 'string', + 'required' => 'bool', + 'format' => 'string', + 'secret' => 'bool' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'key' => null, + 'display_name' => null, + 'required' => null, + 'format' => null, + 'secret' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'key' => 'key', + 'display_name' => 'display_name', + 'required' => 'required', + 'format' => 'format', + 'secret' => 'secret' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'key' => 'setKey', + 'display_name' => 'setDisplayName', + 'required' => 'setRequired', + 'format' => 'setFormat', + 'secret' => 'setSecret' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'key' => 'getKey', + 'display_name' => 'getDisplayName', + 'required' => 'getRequired', + 'format' => 'getFormat', + 'secret' => 'getSecret' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const FORMAT_TEXT = 'text'; + public const FORMAT_MULTILINE = 'multiline'; + public const FORMAT_NUMBER = 'number'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getFormatAllowableValues() + { + return [ + self::FORMAT_TEXT, + self::FORMAT_MULTILINE, + self::FORMAT_NUMBER, + ]; + } + + /** + * 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['key'] = $data['key'] ?? null; + $this->container['display_name'] = $data['display_name'] ?? null; + $this->container['required'] = $data['required'] ?? null; + $this->container['format'] = $data['format'] ?? null; + $this->container['secret'] = $data['secret'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getFormatAllowableValues(); + if (!is_null($this->container['format']) && !in_array($this->container['format'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'format', must be one of '%s'", + $this->container['format'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets key + * + * @return string|null + */ + public function getKey() + { + return $this->container['key']; + } + + /** + * Sets key + * + * @param string|null $key The key of a field that needs to be submitted. + * + * @return self + */ + public function setKey($key) + { + $this->container['key'] = $key; + + return $this; + } + + /** + * Gets display_name + * + * @return string|null + */ + public function getDisplayName() + { + return $this->container['display_name']; + } + + /** + * Sets display_name + * + * @param string|null $display_name The name to display for a field in the dashboard. + * + * @return self + */ + public function setDisplayName($display_name) + { + $this->container['display_name'] = $display_name; + + return $this; + } + + /** + * Gets required + * + * @return bool|null + */ + public function getRequired() + { + return $this->container['required']; + } + + /** + * Sets required + * + * @param bool|null $required Defines if this field is required when the service is created. + * + * @return self + */ + public function setRequired($required) + { + $this->container['required'] = $required; + + return $this; + } + + /** + * Gets format + * + * @return string|null + */ + public function getFormat() + { + return $this->container['format']; + } + + /** + * Sets format + * + * @param string|null $format Defines the type of input that needs to be rendered for this field. + * + * @return self + */ + public function setFormat($format) + { + $allowedValues = $this->getFormatAllowableValues(); + if (!is_null($format) && !in_array($format, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'format', must be one of '%s'", + $format, + implode("', '", $allowedValues) + ) + ); + } + $this->container['format'] = $format; + + return $this; + } + + /** + * Gets secret + * + * @return bool|null + */ + public function getSecret() + { + return $this->container['secret']; + } + + /** + * Sets secret + * + * @param bool|null $secret Defines if this field is secret. When `true` the field is not returned when querying the payment service. + * + * @return self + */ + public function setSecret($secret) + { + $this->container['secret'] = $secret; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/PaymentServiceDefinitionSupportedFeatures.php b/lib/model/PaymentServiceDefinitionSupportedFeatures.php new file mode 100644 index 0000000..ac518c2 --- /dev/null +++ b/lib/model/PaymentServiceDefinitionSupportedFeatures.php @@ -0,0 +1,594 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class PaymentServiceDefinitionSupportedFeatures implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PaymentServiceDefinition_supported_features'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'delayed_capture' => 'bool', + 'network_tokens' => 'bool', + 'partial_refunds' => 'bool', + 'payment_method_tokenization' => 'bool', + 'payment_method_tokenization_toggle' => 'bool', + 'refunds' => 'bool', + 'three_d_secure_hosted' => 'bool', + 'three_d_secure_pass_through' => 'bool', + 'verify_credentials' => 'bool', + 'void' => 'bool' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'delayed_capture' => null, + 'network_tokens' => null, + 'partial_refunds' => null, + 'payment_method_tokenization' => null, + 'payment_method_tokenization_toggle' => null, + 'refunds' => null, + 'three_d_secure_hosted' => null, + 'three_d_secure_pass_through' => null, + 'verify_credentials' => null, + 'void' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'delayed_capture' => 'delayed_capture', + 'network_tokens' => 'network_tokens', + 'partial_refunds' => 'partial_refunds', + 'payment_method_tokenization' => 'payment_method_tokenization', + 'payment_method_tokenization_toggle' => 'payment_method_tokenization_toggle', + 'refunds' => 'refunds', + 'three_d_secure_hosted' => 'three_d_secure_hosted', + 'three_d_secure_pass_through' => 'three_d_secure_pass_through', + 'verify_credentials' => 'verify_credentials', + 'void' => 'void' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'delayed_capture' => 'setDelayedCapture', + 'network_tokens' => 'setNetworkTokens', + 'partial_refunds' => 'setPartialRefunds', + 'payment_method_tokenization' => 'setPaymentMethodTokenization', + 'payment_method_tokenization_toggle' => 'setPaymentMethodTokenizationToggle', + 'refunds' => 'setRefunds', + 'three_d_secure_hosted' => 'setThreeDSecureHosted', + 'three_d_secure_pass_through' => 'setThreeDSecurePassThrough', + 'verify_credentials' => 'setVerifyCredentials', + 'void' => 'setVoid' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'delayed_capture' => 'getDelayedCapture', + 'network_tokens' => 'getNetworkTokens', + 'partial_refunds' => 'getPartialRefunds', + 'payment_method_tokenization' => 'getPaymentMethodTokenization', + 'payment_method_tokenization_toggle' => 'getPaymentMethodTokenizationToggle', + 'refunds' => 'getRefunds', + 'three_d_secure_hosted' => 'getThreeDSecureHosted', + 'three_d_secure_pass_through' => 'getThreeDSecurePassThrough', + 'verify_credentials' => 'getVerifyCredentials', + 'void' => 'getVoid' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['delayed_capture'] = $data['delayed_capture'] ?? null; + $this->container['network_tokens'] = $data['network_tokens'] ?? null; + $this->container['partial_refunds'] = $data['partial_refunds'] ?? null; + $this->container['payment_method_tokenization'] = $data['payment_method_tokenization'] ?? null; + $this->container['payment_method_tokenization_toggle'] = $data['payment_method_tokenization_toggle'] ?? null; + $this->container['refunds'] = $data['refunds'] ?? null; + $this->container['three_d_secure_hosted'] = $data['three_d_secure_hosted'] ?? null; + $this->container['three_d_secure_pass_through'] = $data['three_d_secure_pass_through'] ?? null; + $this->container['verify_credentials'] = $data['verify_credentials'] ?? null; + $this->container['void'] = $data['void'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets delayed_capture + * + * @return bool|null + */ + public function getDelayedCapture() + { + return $this->container['delayed_capture']; + } + + /** + * Sets delayed_capture + * + * @param bool|null $delayed_capture Supports [capturing](#operation/capture-transaction) authorized transactions. + * + * @return self + */ + public function setDelayedCapture($delayed_capture) + { + $this->container['delayed_capture'] = $delayed_capture; + + return $this; + } + + /** + * Gets network_tokens + * + * @return bool|null + */ + public function getNetworkTokens() + { + return $this->container['network_tokens']; + } + + /** + * Sets network_tokens + * + * @param bool|null $network_tokens Supports passing decrypted digital wallet (e.g. Apple Pay) tokens to the underlying processor. + * + * @return self + */ + public function setNetworkTokens($network_tokens) + { + $this->container['network_tokens'] = $network_tokens; + + return $this; + } + + /** + * Gets partial_refunds + * + * @return bool|null + */ + public function getPartialRefunds() + { + return $this->container['partial_refunds']; + } + + /** + * Sets partial_refunds + * + * @param bool|null $partial_refunds Supports [partially refunding](#operation/refund-transaction) captured transactions. + * + * @return self + */ + public function setPartialRefunds($partial_refunds) + { + $this->container['partial_refunds'] = $partial_refunds; + + return $this; + } + + /** + * Gets payment_method_tokenization + * + * @return bool|null + */ + public function getPaymentMethodTokenization() + { + return $this->container['payment_method_tokenization']; + } + + /** + * Sets payment_method_tokenization + * + * @param bool|null $payment_method_tokenization Supports storing a payment method via tokenization. + * + * @return self + */ + public function setPaymentMethodTokenization($payment_method_tokenization) + { + $this->container['payment_method_tokenization'] = $payment_method_tokenization; + + return $this; + } + + /** + * Gets payment_method_tokenization_toggle + * + * @return bool|null + */ + public function getPaymentMethodTokenizationToggle() + { + return $this->container['payment_method_tokenization_toggle']; + } + + /** + * Sets payment_method_tokenization_toggle + * + * @param bool|null $payment_method_tokenization_toggle Supports toggling tokenization for a payment method on or off from the dashboard. + * + * @return self + */ + public function setPaymentMethodTokenizationToggle($payment_method_tokenization_toggle) + { + $this->container['payment_method_tokenization_toggle'] = $payment_method_tokenization_toggle; + + return $this; + } + + /** + * Gets refunds + * + * @return bool|null + */ + public function getRefunds() + { + return $this->container['refunds']; + } + + /** + * Sets refunds + * + * @param bool|null $refunds Supports [refunding](#operation/refund-transaction) captured transactions. + * + * @return self + */ + public function setRefunds($refunds) + { + $this->container['refunds'] = $refunds; + + return $this; + } + + /** + * Gets three_d_secure_hosted + * + * @return bool|null + */ + public function getThreeDSecureHosted() + { + return $this->container['three_d_secure_hosted']; + } + + /** + * Sets three_d_secure_hosted + * + * @param bool|null $three_d_secure_hosted Supports hosted 3-D Secure with a redirect. + * + * @return self + */ + public function setThreeDSecureHosted($three_d_secure_hosted) + { + $this->container['three_d_secure_hosted'] = $three_d_secure_hosted; + + return $this; + } + + /** + * Gets three_d_secure_pass_through + * + * @return bool|null + */ + public function getThreeDSecurePassThrough() + { + return $this->container['three_d_secure_pass_through']; + } + + /** + * Sets three_d_secure_pass_through + * + * @param bool|null $three_d_secure_pass_through Supports passing 3-D Secure data to the underlying processor. + * + * @return self + */ + public function setThreeDSecurePassThrough($three_d_secure_pass_through) + { + $this->container['three_d_secure_pass_through'] = $three_d_secure_pass_through; + + return $this; + } + + /** + * Gets verify_credentials + * + * @return bool|null + */ + public function getVerifyCredentials() + { + return $this->container['verify_credentials']; + } + + /** + * Sets verify_credentials + * + * @param bool|null $verify_credentials Supports verifying the credentials entered while setting up the underlying processor. This is for internal use only. + * + * @return self + */ + public function setVerifyCredentials($verify_credentials) + { + $this->container['verify_credentials'] = $verify_credentials; + + return $this; + } + + /** + * Gets void + * + * @return bool|null + */ + public function getVoid() + { + return $this->container['void']; + } + + /** + * Sets void + * + * @param bool|null $void Supports [voiding](#operation/void-transaction) authorized transactions. + * + * @return self + */ + public function setVoid($void) + { + $this->container['void'] = $void; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/PaymentServiceDefinitions.php b/lib/model/PaymentServiceDefinitions.php new file mode 100644 index 0000000..65106bd --- /dev/null +++ b/lib/model/PaymentServiceDefinitions.php @@ -0,0 +1,460 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class PaymentServiceDefinitions implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PaymentServiceDefinitions'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'items' => '\Gr4vy\model\PaymentServiceDefinition[]', + 'limit' => 'int', + 'next_cursor' => 'string', + 'previous_cursor' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'items' => null, + 'limit' => 'int32', + 'next_cursor' => null, + 'previous_cursor' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'items' => 'items', + 'limit' => 'limit', + 'next_cursor' => 'next_cursor', + 'previous_cursor' => 'previous_cursor' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'items' => 'setItems', + 'limit' => 'setLimit', + 'next_cursor' => 'setNextCursor', + 'previous_cursor' => 'setPreviousCursor' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'items' => 'getItems', + 'limit' => 'getLimit', + 'next_cursor' => 'getNextCursor', + 'previous_cursor' => 'getPreviousCursor' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['items'] = $data['items'] ?? null; + $this->container['limit'] = $data['limit'] ?? 20; + $this->container['next_cursor'] = $data['next_cursor'] ?? null; + $this->container['previous_cursor'] = $data['previous_cursor'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['limit']) && ($this->container['limit'] > 100)) { + $invalidProperties[] = "invalid value for 'limit', must be smaller than or equal to 100."; + } + + if (!is_null($this->container['limit']) && ($this->container['limit'] < 1)) { + $invalidProperties[] = "invalid value for 'limit', must be bigger than or equal to 1."; + } + + if (!is_null($this->container['next_cursor']) && (mb_strlen($this->container['next_cursor']) > 1000)) { + $invalidProperties[] = "invalid value for 'next_cursor', the character length must be smaller than or equal to 1000."; + } + + if (!is_null($this->container['next_cursor']) && (mb_strlen($this->container['next_cursor']) < 1)) { + $invalidProperties[] = "invalid value for 'next_cursor', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['previous_cursor']) && (mb_strlen($this->container['previous_cursor']) > 1000)) { + $invalidProperties[] = "invalid value for 'previous_cursor', the character length must be smaller than or equal to 1000."; + } + + if (!is_null($this->container['previous_cursor']) && (mb_strlen($this->container['previous_cursor']) < 1)) { + $invalidProperties[] = "invalid value for 'previous_cursor', the character length must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets items + * + * @return \Gr4vy\model\PaymentServiceDefinition[]|null + */ + public function getItems() + { + return $this->container['items']; + } + + /** + * Sets items + * + * @param \Gr4vy\model\PaymentServiceDefinition[]|null $items items + * + * @return self + */ + public function setItems($items) + { + $this->container['items'] = $items; + + return $this; + } + + /** + * Gets limit + * + * @return int|null + */ + public function getLimit() + { + return $this->container['limit']; + } + + /** + * Sets limit + * + * @param int|null $limit The limit applied to request. This represents the number of items that are at maximum returned by this request. + * + * @return self + */ + public function setLimit($limit) + { + + if (!is_null($limit) && ($limit > 100)) { + throw new \InvalidArgumentException('invalid value for $limit when calling PaymentServiceDefinitions., must be smaller than or equal to 100.'); + } + if (!is_null($limit) && ($limit < 1)) { + throw new \InvalidArgumentException('invalid value for $limit when calling PaymentServiceDefinitions., must be bigger than or equal to 1.'); + } + + $this->container['limit'] = $limit; + + return $this; + } + + /** + * Gets next_cursor + * + * @return string|null + */ + public function getNextCursor() + { + return $this->container['next_cursor']; + } + + /** + * Sets next_cursor + * + * @param string|null $next_cursor The cursor that represents the next page of results. Use the `cursor` query parameter to fetch this page of items. + * + * @return self + */ + public function setNextCursor($next_cursor) + { + if (!is_null($next_cursor) && (mb_strlen($next_cursor) > 1000)) { + throw new \InvalidArgumentException('invalid length for $next_cursor when calling PaymentServiceDefinitions., must be smaller than or equal to 1000.'); + } + if (!is_null($next_cursor) && (mb_strlen($next_cursor) < 1)) { + throw new \InvalidArgumentException('invalid length for $next_cursor when calling PaymentServiceDefinitions., must be bigger than or equal to 1.'); + } + + $this->container['next_cursor'] = $next_cursor; + + return $this; + } + + /** + * Gets previous_cursor + * + * @return string|null + */ + public function getPreviousCursor() + { + return $this->container['previous_cursor']; + } + + /** + * Sets previous_cursor + * + * @param string|null $previous_cursor The cursor that represents the next page of results. Use the `cursor` query parameter to fetch this page of items. + * + * @return self + */ + public function setPreviousCursor($previous_cursor) + { + if (!is_null($previous_cursor) && (mb_strlen($previous_cursor) > 1000)) { + throw new \InvalidArgumentException('invalid length for $previous_cursor when calling PaymentServiceDefinitions., must be smaller than or equal to 1000.'); + } + if (!is_null($previous_cursor) && (mb_strlen($previous_cursor) < 1)) { + throw new \InvalidArgumentException('invalid length for $previous_cursor when calling PaymentServiceDefinitions., must be bigger than or equal to 1.'); + } + + $this->container['previous_cursor'] = $previous_cursor; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/PaymentServiceFieldsInner.php b/lib/model/PaymentServiceFieldsInner.php new file mode 100644 index 0000000..fdf3733 --- /dev/null +++ b/lib/model/PaymentServiceFieldsInner.php @@ -0,0 +1,383 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class PaymentServiceFieldsInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PaymentService_fields_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'key' => 'string', + 'value' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'key' => null, + 'value' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'key' => 'key', + 'value' => 'value' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'key' => 'setKey', + 'value' => 'setValue' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'key' => 'getKey', + 'value' => 'getValue' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['key'] = $data['key'] ?? null; + $this->container['value'] = $data['value'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['key']) && (mb_strlen($this->container['key']) > 50)) { + $invalidProperties[] = "invalid value for 'key', the character length must be smaller than or equal to 50."; + } + + if (!is_null($this->container['key']) && (mb_strlen($this->container['key']) < 1)) { + $invalidProperties[] = "invalid value for 'key', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['value']) && (mb_strlen($this->container['value']) > 5000)) { + $invalidProperties[] = "invalid value for 'value', the character length must be smaller than or equal to 5000."; + } + + if (!is_null($this->container['value']) && (mb_strlen($this->container['value']) < 0)) { + $invalidProperties[] = "invalid value for 'value', the character length must be bigger than or equal to 0."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets key + * + * @return string|null + */ + public function getKey() + { + return $this->container['key']; + } + + /** + * Sets key + * + * @param string|null $key The key of the field. + * + * @return self + */ + public function setKey($key) + { + if (!is_null($key) && (mb_strlen($key) > 50)) { + throw new \InvalidArgumentException('invalid length for $key when calling PaymentServiceFieldsInner., must be smaller than or equal to 50.'); + } + if (!is_null($key) && (mb_strlen($key) < 1)) { + throw new \InvalidArgumentException('invalid length for $key when calling PaymentServiceFieldsInner., must be bigger than or equal to 1.'); + } + + $this->container['key'] = $key; + + return $this; + } + + /** + * Gets value + * + * @return string|null + */ + public function getValue() + { + return $this->container['value']; + } + + /** + * Sets value + * + * @param string|null $value The value of the field. + * + * @return self + */ + public function setValue($value) + { + if (!is_null($value) && (mb_strlen($value) > 5000)) { + throw new \InvalidArgumentException('invalid length for $value when calling PaymentServiceFieldsInner., must be smaller than or equal to 5000.'); + } + if (!is_null($value) && (mb_strlen($value) < 0)) { + throw new \InvalidArgumentException('invalid length for $value when calling PaymentServiceFieldsInner., must be bigger than or equal to 0.'); + } + + $this->container['value'] = $value; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/PaymentServiceRequest.php b/lib/model/PaymentServiceRequest.php new file mode 100644 index 0000000..fb54204 --- /dev/null +++ b/lib/model/PaymentServiceRequest.php @@ -0,0 +1,977 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class PaymentServiceRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PaymentServiceRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'display_name' => 'string', + 'fields' => '\Gr4vy\model\PaymentServiceUpdateFieldsInner[]', + 'accepted_countries' => 'string[]', + 'accepted_currencies' => 'string[]', + 'three_d_secure_enabled' => 'bool', + 'acquirer_bin_visa' => 'string', + 'acquirer_bin_mastercard' => 'string', + 'acquirer_bin_amex' => 'string', + 'acquirer_bin_discover' => 'string', + 'acquirer_merchant_id' => 'string', + 'merchant_name' => 'string', + 'merchant_country_code' => 'string', + 'merchant_category_code' => 'string', + 'merchant_url' => 'string', + 'active' => 'bool', + 'position' => 'float', + 'payment_method_tokenization_enabled' => 'bool', + 'payment_service_definition_id' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'display_name' => null, + 'fields' => null, + 'accepted_countries' => null, + 'accepted_currencies' => null, + 'three_d_secure_enabled' => null, + 'acquirer_bin_visa' => null, + 'acquirer_bin_mastercard' => null, + 'acquirer_bin_amex' => null, + 'acquirer_bin_discover' => null, + 'acquirer_merchant_id' => null, + 'merchant_name' => null, + 'merchant_country_code' => null, + 'merchant_category_code' => null, + 'merchant_url' => 'url', + 'active' => null, + 'position' => null, + 'payment_method_tokenization_enabled' => null, + 'payment_service_definition_id' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'display_name' => 'display_name', + 'fields' => 'fields', + 'accepted_countries' => 'accepted_countries', + 'accepted_currencies' => 'accepted_currencies', + 'three_d_secure_enabled' => 'three_d_secure_enabled', + 'acquirer_bin_visa' => 'acquirer_bin_visa', + 'acquirer_bin_mastercard' => 'acquirer_bin_mastercard', + 'acquirer_bin_amex' => 'acquirer_bin_amex', + 'acquirer_bin_discover' => 'acquirer_bin_discover', + 'acquirer_merchant_id' => 'acquirer_merchant_id', + 'merchant_name' => 'merchant_name', + 'merchant_country_code' => 'merchant_country_code', + 'merchant_category_code' => 'merchant_category_code', + 'merchant_url' => 'merchant_url', + 'active' => 'active', + 'position' => 'position', + 'payment_method_tokenization_enabled' => 'payment_method_tokenization_enabled', + 'payment_service_definition_id' => 'payment_service_definition_id' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'display_name' => 'setDisplayName', + 'fields' => 'setFields', + 'accepted_countries' => 'setAcceptedCountries', + 'accepted_currencies' => 'setAcceptedCurrencies', + 'three_d_secure_enabled' => 'setThreeDSecureEnabled', + 'acquirer_bin_visa' => 'setAcquirerBinVisa', + 'acquirer_bin_mastercard' => 'setAcquirerBinMastercard', + 'acquirer_bin_amex' => 'setAcquirerBinAmex', + 'acquirer_bin_discover' => 'setAcquirerBinDiscover', + 'acquirer_merchant_id' => 'setAcquirerMerchantId', + 'merchant_name' => 'setMerchantName', + 'merchant_country_code' => 'setMerchantCountryCode', + 'merchant_category_code' => 'setMerchantCategoryCode', + 'merchant_url' => 'setMerchantUrl', + 'active' => 'setActive', + 'position' => 'setPosition', + 'payment_method_tokenization_enabled' => 'setPaymentMethodTokenizationEnabled', + 'payment_service_definition_id' => 'setPaymentServiceDefinitionId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'display_name' => 'getDisplayName', + 'fields' => 'getFields', + 'accepted_countries' => 'getAcceptedCountries', + 'accepted_currencies' => 'getAcceptedCurrencies', + 'three_d_secure_enabled' => 'getThreeDSecureEnabled', + 'acquirer_bin_visa' => 'getAcquirerBinVisa', + 'acquirer_bin_mastercard' => 'getAcquirerBinMastercard', + 'acquirer_bin_amex' => 'getAcquirerBinAmex', + 'acquirer_bin_discover' => 'getAcquirerBinDiscover', + 'acquirer_merchant_id' => 'getAcquirerMerchantId', + 'merchant_name' => 'getMerchantName', + 'merchant_country_code' => 'getMerchantCountryCode', + 'merchant_category_code' => 'getMerchantCategoryCode', + 'merchant_url' => 'getMerchantUrl', + 'active' => 'getActive', + 'position' => 'getPosition', + 'payment_method_tokenization_enabled' => 'getPaymentMethodTokenizationEnabled', + 'payment_service_definition_id' => 'getPaymentServiceDefinitionId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['display_name'] = $data['display_name'] ?? null; + $this->container['fields'] = $data['fields'] ?? null; + $this->container['accepted_countries'] = $data['accepted_countries'] ?? null; + $this->container['accepted_currencies'] = $data['accepted_currencies'] ?? null; + $this->container['three_d_secure_enabled'] = $data['three_d_secure_enabled'] ?? false; + $this->container['acquirer_bin_visa'] = $data['acquirer_bin_visa'] ?? null; + $this->container['acquirer_bin_mastercard'] = $data['acquirer_bin_mastercard'] ?? null; + $this->container['acquirer_bin_amex'] = $data['acquirer_bin_amex'] ?? null; + $this->container['acquirer_bin_discover'] = $data['acquirer_bin_discover'] ?? null; + $this->container['acquirer_merchant_id'] = $data['acquirer_merchant_id'] ?? null; + $this->container['merchant_name'] = $data['merchant_name'] ?? null; + $this->container['merchant_country_code'] = $data['merchant_country_code'] ?? null; + $this->container['merchant_category_code'] = $data['merchant_category_code'] ?? null; + $this->container['merchant_url'] = $data['merchant_url'] ?? null; + $this->container['active'] = $data['active'] ?? true; + $this->container['position'] = $data['position'] ?? null; + $this->container['payment_method_tokenization_enabled'] = $data['payment_method_tokenization_enabled'] ?? false; + $this->container['payment_service_definition_id'] = $data['payment_service_definition_id'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['display_name'] === null) { + $invalidProperties[] = "'display_name' can't be null"; + } + if ((mb_strlen($this->container['display_name']) > 50)) { + $invalidProperties[] = "invalid value for 'display_name', the character length must be smaller than or equal to 50."; + } + + if ((mb_strlen($this->container['display_name']) < 1)) { + $invalidProperties[] = "invalid value for 'display_name', the character length must be bigger than or equal to 1."; + } + + if ($this->container['fields'] === null) { + $invalidProperties[] = "'fields' can't be null"; + } + if ($this->container['accepted_countries'] === null) { + $invalidProperties[] = "'accepted_countries' can't be null"; + } + if ((count($this->container['accepted_countries']) < 1)) { + $invalidProperties[] = "invalid value for 'accepted_countries', number of items must be greater than or equal to 1."; + } + + if ($this->container['accepted_currencies'] === null) { + $invalidProperties[] = "'accepted_currencies' can't be null"; + } + if ((count($this->container['accepted_currencies']) < 1)) { + $invalidProperties[] = "invalid value for 'accepted_currencies', number of items must be greater than or equal to 1."; + } + + if (!is_null($this->container['acquirer_bin_visa']) && (mb_strlen($this->container['acquirer_bin_visa']) > 11)) { + $invalidProperties[] = "invalid value for 'acquirer_bin_visa', the character length must be smaller than or equal to 11."; + } + + if (!is_null($this->container['acquirer_bin_mastercard']) && (mb_strlen($this->container['acquirer_bin_mastercard']) > 11)) { + $invalidProperties[] = "invalid value for 'acquirer_bin_mastercard', the character length must be smaller than or equal to 11."; + } + + if (!is_null($this->container['acquirer_bin_amex']) && (mb_strlen($this->container['acquirer_bin_amex']) > 11)) { + $invalidProperties[] = "invalid value for 'acquirer_bin_amex', the character length must be smaller than or equal to 11."; + } + + if (!is_null($this->container['acquirer_bin_discover']) && (mb_strlen($this->container['acquirer_bin_discover']) > 11)) { + $invalidProperties[] = "invalid value for 'acquirer_bin_discover', the character length must be smaller than or equal to 11."; + } + + if (!is_null($this->container['acquirer_merchant_id']) && (mb_strlen($this->container['acquirer_merchant_id']) > 35)) { + $invalidProperties[] = "invalid value for 'acquirer_merchant_id', the character length must be smaller than or equal to 35."; + } + + if (!is_null($this->container['merchant_name']) && (mb_strlen($this->container['merchant_name']) > 40)) { + $invalidProperties[] = "invalid value for 'merchant_name', the character length must be smaller than or equal to 40."; + } + + if (!is_null($this->container['merchant_country_code']) && !preg_match("/^\\d{3}$/", $this->container['merchant_country_code'])) { + $invalidProperties[] = "invalid value for 'merchant_country_code', must be conform to the pattern /^\\d{3}$/."; + } + + if (!is_null($this->container['merchant_category_code']) && (mb_strlen($this->container['merchant_category_code']) > 4)) { + $invalidProperties[] = "invalid value for 'merchant_category_code', the character length must be smaller than or equal to 4."; + } + + if (!is_null($this->container['merchant_category_code']) && (mb_strlen($this->container['merchant_category_code']) < 4)) { + $invalidProperties[] = "invalid value for 'merchant_category_code', the character length must be bigger than or equal to 4."; + } + + if (!is_null($this->container['merchant_url']) && (mb_strlen($this->container['merchant_url']) > 2048)) { + $invalidProperties[] = "invalid value for 'merchant_url', the character length must be smaller than or equal to 2048."; + } + + if ($this->container['payment_service_definition_id'] === null) { + $invalidProperties[] = "'payment_service_definition_id' can't be null"; + } + if ((mb_strlen($this->container['payment_service_definition_id']) > 50)) { + $invalidProperties[] = "invalid value for 'payment_service_definition_id', the character length must be smaller than or equal to 50."; + } + + if ((mb_strlen($this->container['payment_service_definition_id']) < 1)) { + $invalidProperties[] = "invalid value for 'payment_service_definition_id', the character length must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets display_name + * + * @return string + */ + public function getDisplayName() + { + return $this->container['display_name']; + } + + /** + * Sets display_name + * + * @param string $display_name A custom name for the payment service. This will be shown in the Admin UI. + * + * @return self + */ + public function setDisplayName($display_name) + { + if ((mb_strlen($display_name) > 50)) { + throw new \InvalidArgumentException('invalid length for $display_name when calling PaymentServiceRequest., must be smaller than or equal to 50.'); + } + if ((mb_strlen($display_name) < 1)) { + throw new \InvalidArgumentException('invalid length for $display_name when calling PaymentServiceRequest., must be bigger than or equal to 1.'); + } + + $this->container['display_name'] = $display_name; + + return $this; + } + + /** + * Gets fields + * + * @return \Gr4vy\model\PaymentServiceUpdateFieldsInner[] + */ + public function getFields() + { + return $this->container['fields']; + } + + /** + * Sets fields + * + * @param \Gr4vy\model\PaymentServiceUpdateFieldsInner[] $fields A list of fields, each containing a key-value pair for each field defined by the definition for this payment service e.g. for stripe-card `secret_key` is required and so must be sent within this field. + * + * @return self + */ + public function setFields($fields) + { + $this->container['fields'] = $fields; + + return $this; + } + + /** + * Gets accepted_countries + * + * @return string[] + */ + public function getAcceptedCountries() + { + return $this->container['accepted_countries']; + } + + /** + * Sets accepted_countries + * + * @param string[] $accepted_countries A list of countries that this payment service needs to support in ISO two-letter code format. + * + * @return self + */ + public function setAcceptedCountries($accepted_countries) + { + + + if ((count($accepted_countries) < 1)) { + throw new \InvalidArgumentException('invalid length for $accepted_countries when calling PaymentServiceRequest., number of items must be greater than or equal to 1.'); + } + $this->container['accepted_countries'] = $accepted_countries; + + return $this; + } + + /** + * Gets accepted_currencies + * + * @return string[] + */ + public function getAcceptedCurrencies() + { + return $this->container['accepted_currencies']; + } + + /** + * Sets accepted_currencies + * + * @param string[] $accepted_currencies A list of currencies that this payment service needs to support in ISO 4217 three-letter code format. + * + * @return self + */ + public function setAcceptedCurrencies($accepted_currencies) + { + + + if ((count($accepted_currencies) < 1)) { + throw new \InvalidArgumentException('invalid length for $accepted_currencies when calling PaymentServiceRequest., number of items must be greater than or equal to 1.'); + } + $this->container['accepted_currencies'] = $accepted_currencies; + + return $this; + } + + /** + * Gets three_d_secure_enabled + * + * @return bool|null + */ + public function getThreeDSecureEnabled() + { + return $this->container['three_d_secure_enabled']; + } + + /** + * Sets three_d_secure_enabled + * + * @param bool|null $three_d_secure_enabled Defines if 3-D Secure is enabled for the service (can only be enabled if the payment service definition supports the `three_d_secure_hosted` feature). This does not affect pass through 3-D Secure data. + * + * @return self + */ + public function setThreeDSecureEnabled($three_d_secure_enabled) + { + $this->container['three_d_secure_enabled'] = $three_d_secure_enabled; + + return $this; + } + + /** + * Gets acquirer_bin_visa + * + * @return string|null + */ + public function getAcquirerBinVisa() + { + return $this->container['acquirer_bin_visa']; + } + + /** + * Sets acquirer_bin_visa + * + * @param string|null $acquirer_bin_visa Acquiring institution identification code for VISA. + * + * @return self + */ + public function setAcquirerBinVisa($acquirer_bin_visa) + { + if (!is_null($acquirer_bin_visa) && (mb_strlen($acquirer_bin_visa) > 11)) { + throw new \InvalidArgumentException('invalid length for $acquirer_bin_visa when calling PaymentServiceRequest., must be smaller than or equal to 11.'); + } + + $this->container['acquirer_bin_visa'] = $acquirer_bin_visa; + + return $this; + } + + /** + * Gets acquirer_bin_mastercard + * + * @return string|null + */ + public function getAcquirerBinMastercard() + { + return $this->container['acquirer_bin_mastercard']; + } + + /** + * Sets acquirer_bin_mastercard + * + * @param string|null $acquirer_bin_mastercard Acquiring institution identification code for Mastercard. + * + * @return self + */ + public function setAcquirerBinMastercard($acquirer_bin_mastercard) + { + if (!is_null($acquirer_bin_mastercard) && (mb_strlen($acquirer_bin_mastercard) > 11)) { + throw new \InvalidArgumentException('invalid length for $acquirer_bin_mastercard when calling PaymentServiceRequest., must be smaller than or equal to 11.'); + } + + $this->container['acquirer_bin_mastercard'] = $acquirer_bin_mastercard; + + return $this; + } + + /** + * Gets acquirer_bin_amex + * + * @return string|null + */ + public function getAcquirerBinAmex() + { + return $this->container['acquirer_bin_amex']; + } + + /** + * Sets acquirer_bin_amex + * + * @param string|null $acquirer_bin_amex Acquiring institution identification code for Amex. + * + * @return self + */ + public function setAcquirerBinAmex($acquirer_bin_amex) + { + if (!is_null($acquirer_bin_amex) && (mb_strlen($acquirer_bin_amex) > 11)) { + throw new \InvalidArgumentException('invalid length for $acquirer_bin_amex when calling PaymentServiceRequest., must be smaller than or equal to 11.'); + } + + $this->container['acquirer_bin_amex'] = $acquirer_bin_amex; + + return $this; + } + + /** + * Gets acquirer_bin_discover + * + * @return string|null + */ + public function getAcquirerBinDiscover() + { + return $this->container['acquirer_bin_discover']; + } + + /** + * Sets acquirer_bin_discover + * + * @param string|null $acquirer_bin_discover Acquiring institution identification code for Discover. + * + * @return self + */ + public function setAcquirerBinDiscover($acquirer_bin_discover) + { + if (!is_null($acquirer_bin_discover) && (mb_strlen($acquirer_bin_discover) > 11)) { + throw new \InvalidArgumentException('invalid length for $acquirer_bin_discover when calling PaymentServiceRequest., must be smaller than or equal to 11.'); + } + + $this->container['acquirer_bin_discover'] = $acquirer_bin_discover; + + return $this; + } + + /** + * Gets acquirer_merchant_id + * + * @return string|null + */ + public function getAcquirerMerchantId() + { + return $this->container['acquirer_merchant_id']; + } + + /** + * Sets acquirer_merchant_id + * + * @param string|null $acquirer_merchant_id Merchant identifier used in authorisation requests (assigned by the acquirer). + * + * @return self + */ + public function setAcquirerMerchantId($acquirer_merchant_id) + { + if (!is_null($acquirer_merchant_id) && (mb_strlen($acquirer_merchant_id) > 35)) { + throw new \InvalidArgumentException('invalid length for $acquirer_merchant_id when calling PaymentServiceRequest., must be smaller than or equal to 35.'); + } + + $this->container['acquirer_merchant_id'] = $acquirer_merchant_id; + + return $this; + } + + /** + * Gets merchant_name + * + * @return string|null + */ + public function getMerchantName() + { + return $this->container['merchant_name']; + } + + /** + * Sets merchant_name + * + * @param string|null $merchant_name Merchant name (assigned by the acquirer). + * + * @return self + */ + public function setMerchantName($merchant_name) + { + if (!is_null($merchant_name) && (mb_strlen($merchant_name) > 40)) { + throw new \InvalidArgumentException('invalid length for $merchant_name when calling PaymentServiceRequest., must be smaller than or equal to 40.'); + } + + $this->container['merchant_name'] = $merchant_name; + + return $this; + } + + /** + * Gets merchant_country_code + * + * @return string|null + */ + public function getMerchantCountryCode() + { + return $this->container['merchant_country_code']; + } + + /** + * Sets merchant_country_code + * + * @param string|null $merchant_country_code ISO 3166-1 numeric three-digit country code. + * + * @return self + */ + public function setMerchantCountryCode($merchant_country_code) + { + + if (!is_null($merchant_country_code) && (!preg_match("/^\\d{3}$/", $merchant_country_code))) { + throw new \InvalidArgumentException("invalid value for $merchant_country_code when calling PaymentServiceRequest., must conform to the pattern /^\\d{3}$/."); + } + + $this->container['merchant_country_code'] = $merchant_country_code; + + return $this; + } + + /** + * Gets merchant_category_code + * + * @return string|null + */ + public function getMerchantCategoryCode() + { + return $this->container['merchant_category_code']; + } + + /** + * Sets merchant_category_code + * + * @param string|null $merchant_category_code Merchant category code that describes the business. + * + * @return self + */ + public function setMerchantCategoryCode($merchant_category_code) + { + if (!is_null($merchant_category_code) && (mb_strlen($merchant_category_code) > 4)) { + throw new \InvalidArgumentException('invalid length for $merchant_category_code when calling PaymentServiceRequest., must be smaller than or equal to 4.'); + } + if (!is_null($merchant_category_code) && (mb_strlen($merchant_category_code) < 4)) { + throw new \InvalidArgumentException('invalid length for $merchant_category_code when calling PaymentServiceRequest., must be bigger than or equal to 4.'); + } + + $this->container['merchant_category_code'] = $merchant_category_code; + + return $this; + } + + /** + * Gets merchant_url + * + * @return string|null + */ + public function getMerchantUrl() + { + return $this->container['merchant_url']; + } + + /** + * Sets merchant_url + * + * @param string|null $merchant_url Fully qualified URL of 3-D Secure requestor website or customer care site. + * + * @return self + */ + public function setMerchantUrl($merchant_url) + { + if (!is_null($merchant_url) && (mb_strlen($merchant_url) > 2048)) { + throw new \InvalidArgumentException('invalid length for $merchant_url when calling PaymentServiceRequest., must be smaller than or equal to 2048.'); + } + + $this->container['merchant_url'] = $merchant_url; + + return $this; + } + + /** + * Gets active + * + * @return bool|null + */ + public function getActive() + { + return $this->container['active']; + } + + /** + * Sets active + * + * @param bool|null $active Defines if this service is currently active or not. + * + * @return self + */ + public function setActive($active) + { + $this->container['active'] = $active; + + return $this; + } + + /** + * Gets position + * + * @return float|null + */ + public function getPosition() + { + return $this->container['position']; + } + + /** + * Sets position + * + * @param float|null $position The numeric rank of a payment service. Payment services with a lower position value are processed first. When a payment services is inserted at a position, any payment services with the the same value or higher are shifted down a position accordingly. When left out, the payment service is inserted at the end of the list. + * + * @return self + */ + public function setPosition($position) + { + $this->container['position'] = $position; + + return $this; + } + + /** + * Gets payment_method_tokenization_enabled + * + * @return bool|null + */ + public function getPaymentMethodTokenizationEnabled() + { + return $this->container['payment_method_tokenization_enabled']; + } + + /** + * Sets payment_method_tokenization_enabled + * + * @param bool|null $payment_method_tokenization_enabled Defines if tokenization is enabled for the service (can only be enabled if the payment service definition supports it). + * + * @return self + */ + public function setPaymentMethodTokenizationEnabled($payment_method_tokenization_enabled) + { + $this->container['payment_method_tokenization_enabled'] = $payment_method_tokenization_enabled; + + return $this; + } + + /** + * Gets payment_service_definition_id + * + * @return string + */ + public function getPaymentServiceDefinitionId() + { + return $this->container['payment_service_definition_id']; + } + + /** + * Sets payment_service_definition_id + * + * @param string $payment_service_definition_id The ID of the payment service to use. + * + * @return self + */ + public function setPaymentServiceDefinitionId($payment_service_definition_id) + { + if ((mb_strlen($payment_service_definition_id) > 50)) { + throw new \InvalidArgumentException('invalid length for $payment_service_definition_id when calling PaymentServiceRequest., must be smaller than or equal to 50.'); + } + if ((mb_strlen($payment_service_definition_id) < 1)) { + throw new \InvalidArgumentException('invalid length for $payment_service_definition_id when calling PaymentServiceRequest., must be bigger than or equal to 1.'); + } + + $this->container['payment_service_definition_id'] = $payment_service_definition_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/PaymentServiceRequestAllOf.php b/lib/model/PaymentServiceRequestAllOf.php new file mode 100644 index 0000000..3b049d3 --- /dev/null +++ b/lib/model/PaymentServiceRequestAllOf.php @@ -0,0 +1,338 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class PaymentServiceRequestAllOf implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PaymentServiceRequest_allOf'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'payment_service_definition_id' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'payment_service_definition_id' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'payment_service_definition_id' => 'payment_service_definition_id' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'payment_service_definition_id' => 'setPaymentServiceDefinitionId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'payment_service_definition_id' => 'getPaymentServiceDefinitionId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['payment_service_definition_id'] = $data['payment_service_definition_id'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['payment_service_definition_id']) && (mb_strlen($this->container['payment_service_definition_id']) > 50)) { + $invalidProperties[] = "invalid value for 'payment_service_definition_id', the character length must be smaller than or equal to 50."; + } + + if (!is_null($this->container['payment_service_definition_id']) && (mb_strlen($this->container['payment_service_definition_id']) < 1)) { + $invalidProperties[] = "invalid value for 'payment_service_definition_id', the character length must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets payment_service_definition_id + * + * @return string|null + */ + public function getPaymentServiceDefinitionId() + { + return $this->container['payment_service_definition_id']; + } + + /** + * Sets payment_service_definition_id + * + * @param string|null $payment_service_definition_id The ID of the payment service to use. + * + * @return self + */ + public function setPaymentServiceDefinitionId($payment_service_definition_id) + { + if (!is_null($payment_service_definition_id) && (mb_strlen($payment_service_definition_id) > 50)) { + throw new \InvalidArgumentException('invalid length for $payment_service_definition_id when calling PaymentServiceRequestAllOf., must be smaller than or equal to 50.'); + } + if (!is_null($payment_service_definition_id) && (mb_strlen($payment_service_definition_id) < 1)) { + throw new \InvalidArgumentException('invalid length for $payment_service_definition_id when calling PaymentServiceRequestAllOf., must be bigger than or equal to 1.'); + } + + $this->container['payment_service_definition_id'] = $payment_service_definition_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/PaymentServiceSnapshot.php b/lib/model/PaymentServiceSnapshot.php new file mode 100644 index 0000000..e174908 --- /dev/null +++ b/lib/model/PaymentServiceSnapshot.php @@ -0,0 +1,521 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class PaymentServiceSnapshot implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PaymentService--Snapshot'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'type' => 'string', + 'payment_service_definition_id' => 'string', + 'method' => 'string', + 'display_name' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'type' => null, + 'payment_service_definition_id' => null, + 'method' => null, + 'display_name' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'type' => 'type', + 'payment_service_definition_id' => 'payment_service_definition_id', + 'method' => 'method', + 'display_name' => 'display_name' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'type' => 'setType', + 'payment_service_definition_id' => 'setPaymentServiceDefinitionId', + 'method' => 'setMethod', + 'display_name' => 'setDisplayName' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'type' => 'getType', + 'payment_service_definition_id' => 'getPaymentServiceDefinitionId', + 'method' => 'getMethod', + 'display_name' => 'getDisplayName' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_PAYMENT_SERVICE = 'payment-service'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_PAYMENT_SERVICE, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['id'] = $data['id'] ?? null; + $this->container['type'] = $data['type'] ?? null; + $this->container['payment_service_definition_id'] = $data['payment_service_definition_id'] ?? null; + $this->container['method'] = $data['method'] ?? null; + $this->container['display_name'] = $data['display_name'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['id']) && (mb_strlen($this->container['id']) > 200)) { + $invalidProperties[] = "invalid value for 'id', the character length must be smaller than or equal to 200."; + } + + if (!is_null($this->container['id']) && (mb_strlen($this->container['id']) < 1)) { + $invalidProperties[] = "invalid value for 'id', the character length must be bigger than or equal to 1."; + } + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + if (!is_null($this->container['payment_service_definition_id']) && (mb_strlen($this->container['payment_service_definition_id']) > 50)) { + $invalidProperties[] = "invalid value for 'payment_service_definition_id', the character length must be smaller than or equal to 50."; + } + + if (!is_null($this->container['payment_service_definition_id']) && (mb_strlen($this->container['payment_service_definition_id']) < 1)) { + $invalidProperties[] = "invalid value for 'payment_service_definition_id', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['display_name']) && (mb_strlen($this->container['display_name']) > 50)) { + $invalidProperties[] = "invalid value for 'display_name', the character length must be smaller than or equal to 50."; + } + + if (!is_null($this->container['display_name']) && (mb_strlen($this->container['display_name']) < 1)) { + $invalidProperties[] = "invalid value for 'display_name', the character length must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id The ID of this payment service. + * + * @return self + */ + public function setId($id) + { + if (!is_null($id) && (mb_strlen($id) > 200)) { + throw new \InvalidArgumentException('invalid length for $id when calling PaymentServiceSnapshot., must be smaller than or equal to 200.'); + } + if (!is_null($id) && (mb_strlen($id) < 1)) { + throw new \InvalidArgumentException('invalid length for $id when calling PaymentServiceSnapshot., must be bigger than or equal to 1.'); + } + + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type The type of this resource. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets payment_service_definition_id + * + * @return string|null + */ + public function getPaymentServiceDefinitionId() + { + return $this->container['payment_service_definition_id']; + } + + /** + * Sets payment_service_definition_id + * + * @param string|null $payment_service_definition_id The ID of the payment service definition used to create this service. + * + * @return self + */ + public function setPaymentServiceDefinitionId($payment_service_definition_id) + { + if (!is_null($payment_service_definition_id) && (mb_strlen($payment_service_definition_id) > 50)) { + throw new \InvalidArgumentException('invalid length for $payment_service_definition_id when calling PaymentServiceSnapshot., must be smaller than or equal to 50.'); + } + if (!is_null($payment_service_definition_id) && (mb_strlen($payment_service_definition_id) < 1)) { + throw new \InvalidArgumentException('invalid length for $payment_service_definition_id when calling PaymentServiceSnapshot., must be bigger than or equal to 1.'); + } + + $this->container['payment_service_definition_id'] = $payment_service_definition_id; + + return $this; + } + + /** + * Gets method + * + * @return string|null + */ + public function getMethod() + { + return $this->container['method']; + } + + /** + * Sets method + * + * @param string|null $method method + * + * @return self + */ + public function setMethod($method) + { + $this->container['method'] = $method; + + return $this; + } + + /** + * Gets display_name + * + * @return string|null + */ + public function getDisplayName() + { + return $this->container['display_name']; + } + + /** + * Sets display_name + * + * @param string|null $display_name The custom name set for this service. + * + * @return self + */ + public function setDisplayName($display_name) + { + if (!is_null($display_name) && (mb_strlen($display_name) > 50)) { + throw new \InvalidArgumentException('invalid length for $display_name when calling PaymentServiceSnapshot., must be smaller than or equal to 50.'); + } + if (!is_null($display_name) && (mb_strlen($display_name) < 1)) { + throw new \InvalidArgumentException('invalid length for $display_name when calling PaymentServiceSnapshot., must be bigger than or equal to 1.'); + } + + $this->container['display_name'] = $display_name; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/PaymentServiceUpdate.php b/lib/model/PaymentServiceUpdate.php new file mode 100644 index 0000000..113e2c9 --- /dev/null +++ b/lib/model/PaymentServiceUpdate.php @@ -0,0 +1,917 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class PaymentServiceUpdate implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PaymentServiceUpdate'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'display_name' => 'string', + 'fields' => '\Gr4vy\model\PaymentServiceUpdateFieldsInner[]', + 'accepted_countries' => 'string[]', + 'accepted_currencies' => 'string[]', + 'three_d_secure_enabled' => 'bool', + 'acquirer_bin_visa' => 'string', + 'acquirer_bin_mastercard' => 'string', + 'acquirer_bin_amex' => 'string', + 'acquirer_bin_discover' => 'string', + 'acquirer_merchant_id' => 'string', + 'merchant_name' => 'string', + 'merchant_country_code' => 'string', + 'merchant_category_code' => 'string', + 'merchant_url' => 'string', + 'active' => 'bool', + 'position' => 'float', + 'payment_method_tokenization_enabled' => 'bool' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'display_name' => null, + 'fields' => null, + 'accepted_countries' => null, + 'accepted_currencies' => null, + 'three_d_secure_enabled' => null, + 'acquirer_bin_visa' => null, + 'acquirer_bin_mastercard' => null, + 'acquirer_bin_amex' => null, + 'acquirer_bin_discover' => null, + 'acquirer_merchant_id' => null, + 'merchant_name' => null, + 'merchant_country_code' => null, + 'merchant_category_code' => null, + 'merchant_url' => 'url', + 'active' => null, + 'position' => null, + 'payment_method_tokenization_enabled' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'display_name' => 'display_name', + 'fields' => 'fields', + 'accepted_countries' => 'accepted_countries', + 'accepted_currencies' => 'accepted_currencies', + 'three_d_secure_enabled' => 'three_d_secure_enabled', + 'acquirer_bin_visa' => 'acquirer_bin_visa', + 'acquirer_bin_mastercard' => 'acquirer_bin_mastercard', + 'acquirer_bin_amex' => 'acquirer_bin_amex', + 'acquirer_bin_discover' => 'acquirer_bin_discover', + 'acquirer_merchant_id' => 'acquirer_merchant_id', + 'merchant_name' => 'merchant_name', + 'merchant_country_code' => 'merchant_country_code', + 'merchant_category_code' => 'merchant_category_code', + 'merchant_url' => 'merchant_url', + 'active' => 'active', + 'position' => 'position', + 'payment_method_tokenization_enabled' => 'payment_method_tokenization_enabled' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'display_name' => 'setDisplayName', + 'fields' => 'setFields', + 'accepted_countries' => 'setAcceptedCountries', + 'accepted_currencies' => 'setAcceptedCurrencies', + 'three_d_secure_enabled' => 'setThreeDSecureEnabled', + 'acquirer_bin_visa' => 'setAcquirerBinVisa', + 'acquirer_bin_mastercard' => 'setAcquirerBinMastercard', + 'acquirer_bin_amex' => 'setAcquirerBinAmex', + 'acquirer_bin_discover' => 'setAcquirerBinDiscover', + 'acquirer_merchant_id' => 'setAcquirerMerchantId', + 'merchant_name' => 'setMerchantName', + 'merchant_country_code' => 'setMerchantCountryCode', + 'merchant_category_code' => 'setMerchantCategoryCode', + 'merchant_url' => 'setMerchantUrl', + 'active' => 'setActive', + 'position' => 'setPosition', + 'payment_method_tokenization_enabled' => 'setPaymentMethodTokenizationEnabled' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'display_name' => 'getDisplayName', + 'fields' => 'getFields', + 'accepted_countries' => 'getAcceptedCountries', + 'accepted_currencies' => 'getAcceptedCurrencies', + 'three_d_secure_enabled' => 'getThreeDSecureEnabled', + 'acquirer_bin_visa' => 'getAcquirerBinVisa', + 'acquirer_bin_mastercard' => 'getAcquirerBinMastercard', + 'acquirer_bin_amex' => 'getAcquirerBinAmex', + 'acquirer_bin_discover' => 'getAcquirerBinDiscover', + 'acquirer_merchant_id' => 'getAcquirerMerchantId', + 'merchant_name' => 'getMerchantName', + 'merchant_country_code' => 'getMerchantCountryCode', + 'merchant_category_code' => 'getMerchantCategoryCode', + 'merchant_url' => 'getMerchantUrl', + 'active' => 'getActive', + 'position' => 'getPosition', + 'payment_method_tokenization_enabled' => 'getPaymentMethodTokenizationEnabled' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['display_name'] = $data['display_name'] ?? null; + $this->container['fields'] = $data['fields'] ?? null; + $this->container['accepted_countries'] = $data['accepted_countries'] ?? null; + $this->container['accepted_currencies'] = $data['accepted_currencies'] ?? null; + $this->container['three_d_secure_enabled'] = $data['three_d_secure_enabled'] ?? false; + $this->container['acquirer_bin_visa'] = $data['acquirer_bin_visa'] ?? null; + $this->container['acquirer_bin_mastercard'] = $data['acquirer_bin_mastercard'] ?? null; + $this->container['acquirer_bin_amex'] = $data['acquirer_bin_amex'] ?? null; + $this->container['acquirer_bin_discover'] = $data['acquirer_bin_discover'] ?? null; + $this->container['acquirer_merchant_id'] = $data['acquirer_merchant_id'] ?? null; + $this->container['merchant_name'] = $data['merchant_name'] ?? null; + $this->container['merchant_country_code'] = $data['merchant_country_code'] ?? null; + $this->container['merchant_category_code'] = $data['merchant_category_code'] ?? null; + $this->container['merchant_url'] = $data['merchant_url'] ?? null; + $this->container['active'] = $data['active'] ?? true; + $this->container['position'] = $data['position'] ?? null; + $this->container['payment_method_tokenization_enabled'] = $data['payment_method_tokenization_enabled'] ?? false; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['display_name']) && (mb_strlen($this->container['display_name']) > 50)) { + $invalidProperties[] = "invalid value for 'display_name', the character length must be smaller than or equal to 50."; + } + + if (!is_null($this->container['display_name']) && (mb_strlen($this->container['display_name']) < 1)) { + $invalidProperties[] = "invalid value for 'display_name', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['accepted_countries']) && (count($this->container['accepted_countries']) < 1)) { + $invalidProperties[] = "invalid value for 'accepted_countries', number of items must be greater than or equal to 1."; + } + + if (!is_null($this->container['accepted_currencies']) && (count($this->container['accepted_currencies']) < 1)) { + $invalidProperties[] = "invalid value for 'accepted_currencies', number of items must be greater than or equal to 1."; + } + + if (!is_null($this->container['acquirer_bin_visa']) && (mb_strlen($this->container['acquirer_bin_visa']) > 11)) { + $invalidProperties[] = "invalid value for 'acquirer_bin_visa', the character length must be smaller than or equal to 11."; + } + + if (!is_null($this->container['acquirer_bin_mastercard']) && (mb_strlen($this->container['acquirer_bin_mastercard']) > 11)) { + $invalidProperties[] = "invalid value for 'acquirer_bin_mastercard', the character length must be smaller than or equal to 11."; + } + + if (!is_null($this->container['acquirer_bin_amex']) && (mb_strlen($this->container['acquirer_bin_amex']) > 11)) { + $invalidProperties[] = "invalid value for 'acquirer_bin_amex', the character length must be smaller than or equal to 11."; + } + + if (!is_null($this->container['acquirer_bin_discover']) && (mb_strlen($this->container['acquirer_bin_discover']) > 11)) { + $invalidProperties[] = "invalid value for 'acquirer_bin_discover', the character length must be smaller than or equal to 11."; + } + + if (!is_null($this->container['acquirer_merchant_id']) && (mb_strlen($this->container['acquirer_merchant_id']) > 35)) { + $invalidProperties[] = "invalid value for 'acquirer_merchant_id', the character length must be smaller than or equal to 35."; + } + + if (!is_null($this->container['merchant_name']) && (mb_strlen($this->container['merchant_name']) > 40)) { + $invalidProperties[] = "invalid value for 'merchant_name', the character length must be smaller than or equal to 40."; + } + + if (!is_null($this->container['merchant_country_code']) && !preg_match("/^\\d{3}$/", $this->container['merchant_country_code'])) { + $invalidProperties[] = "invalid value for 'merchant_country_code', must be conform to the pattern /^\\d{3}$/."; + } + + if (!is_null($this->container['merchant_category_code']) && (mb_strlen($this->container['merchant_category_code']) > 4)) { + $invalidProperties[] = "invalid value for 'merchant_category_code', the character length must be smaller than or equal to 4."; + } + + if (!is_null($this->container['merchant_category_code']) && (mb_strlen($this->container['merchant_category_code']) < 4)) { + $invalidProperties[] = "invalid value for 'merchant_category_code', the character length must be bigger than or equal to 4."; + } + + if (!is_null($this->container['merchant_url']) && (mb_strlen($this->container['merchant_url']) > 2048)) { + $invalidProperties[] = "invalid value for 'merchant_url', the character length must be smaller than or equal to 2048."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets display_name + * + * @return string|null + */ + public function getDisplayName() + { + return $this->container['display_name']; + } + + /** + * Sets display_name + * + * @param string|null $display_name A custom name for the payment service. This will be shown in the Admin UI. + * + * @return self + */ + public function setDisplayName($display_name) + { + if (!is_null($display_name) && (mb_strlen($display_name) > 50)) { + throw new \InvalidArgumentException('invalid length for $display_name when calling PaymentServiceUpdate., must be smaller than or equal to 50.'); + } + if (!is_null($display_name) && (mb_strlen($display_name) < 1)) { + throw new \InvalidArgumentException('invalid length for $display_name when calling PaymentServiceUpdate., must be bigger than or equal to 1.'); + } + + $this->container['display_name'] = $display_name; + + return $this; + } + + /** + * Gets fields + * + * @return \Gr4vy\model\PaymentServiceUpdateFieldsInner[]|null + */ + public function getFields() + { + return $this->container['fields']; + } + + /** + * Sets fields + * + * @param \Gr4vy\model\PaymentServiceUpdateFieldsInner[]|null $fields A list of fields, each containing a key-value pair for each field defined by the definition for this payment service e.g. for stripe-card `secret_key` is required and so must be sent within this field. + * + * @return self + */ + public function setFields($fields) + { + $this->container['fields'] = $fields; + + return $this; + } + + /** + * Gets accepted_countries + * + * @return string[]|null + */ + public function getAcceptedCountries() + { + return $this->container['accepted_countries']; + } + + /** + * Sets accepted_countries + * + * @param string[]|null $accepted_countries A list of countries that this payment service needs to support in ISO two-letter code format. + * + * @return self + */ + public function setAcceptedCountries($accepted_countries) + { + + + if (!is_null($accepted_countries) && (count($accepted_countries) < 1)) { + throw new \InvalidArgumentException('invalid length for $accepted_countries when calling PaymentServiceUpdate., number of items must be greater than or equal to 1.'); + } + $this->container['accepted_countries'] = $accepted_countries; + + return $this; + } + + /** + * Gets accepted_currencies + * + * @return string[]|null + */ + public function getAcceptedCurrencies() + { + return $this->container['accepted_currencies']; + } + + /** + * Sets accepted_currencies + * + * @param string[]|null $accepted_currencies A list of currencies that this payment service needs to support in ISO 4217 three-letter code format. + * + * @return self + */ + public function setAcceptedCurrencies($accepted_currencies) + { + + + if (!is_null($accepted_currencies) && (count($accepted_currencies) < 1)) { + throw new \InvalidArgumentException('invalid length for $accepted_currencies when calling PaymentServiceUpdate., number of items must be greater than or equal to 1.'); + } + $this->container['accepted_currencies'] = $accepted_currencies; + + return $this; + } + + /** + * Gets three_d_secure_enabled + * + * @return bool|null + */ + public function getThreeDSecureEnabled() + { + return $this->container['three_d_secure_enabled']; + } + + /** + * Sets three_d_secure_enabled + * + * @param bool|null $three_d_secure_enabled Defines if 3-D Secure is enabled for the service (can only be enabled if the payment service definition supports the `three_d_secure_hosted` feature). This does not affect pass through 3-D Secure data. + * + * @return self + */ + public function setThreeDSecureEnabled($three_d_secure_enabled) + { + $this->container['three_d_secure_enabled'] = $three_d_secure_enabled; + + return $this; + } + + /** + * Gets acquirer_bin_visa + * + * @return string|null + */ + public function getAcquirerBinVisa() + { + return $this->container['acquirer_bin_visa']; + } + + /** + * Sets acquirer_bin_visa + * + * @param string|null $acquirer_bin_visa Acquiring institution identification code for VISA. + * + * @return self + */ + public function setAcquirerBinVisa($acquirer_bin_visa) + { + if (!is_null($acquirer_bin_visa) && (mb_strlen($acquirer_bin_visa) > 11)) { + throw new \InvalidArgumentException('invalid length for $acquirer_bin_visa when calling PaymentServiceUpdate., must be smaller than or equal to 11.'); + } + + $this->container['acquirer_bin_visa'] = $acquirer_bin_visa; + + return $this; + } + + /** + * Gets acquirer_bin_mastercard + * + * @return string|null + */ + public function getAcquirerBinMastercard() + { + return $this->container['acquirer_bin_mastercard']; + } + + /** + * Sets acquirer_bin_mastercard + * + * @param string|null $acquirer_bin_mastercard Acquiring institution identification code for Mastercard. + * + * @return self + */ + public function setAcquirerBinMastercard($acquirer_bin_mastercard) + { + if (!is_null($acquirer_bin_mastercard) && (mb_strlen($acquirer_bin_mastercard) > 11)) { + throw new \InvalidArgumentException('invalid length for $acquirer_bin_mastercard when calling PaymentServiceUpdate., must be smaller than or equal to 11.'); + } + + $this->container['acquirer_bin_mastercard'] = $acquirer_bin_mastercard; + + return $this; + } + + /** + * Gets acquirer_bin_amex + * + * @return string|null + */ + public function getAcquirerBinAmex() + { + return $this->container['acquirer_bin_amex']; + } + + /** + * Sets acquirer_bin_amex + * + * @param string|null $acquirer_bin_amex Acquiring institution identification code for Amex. + * + * @return self + */ + public function setAcquirerBinAmex($acquirer_bin_amex) + { + if (!is_null($acquirer_bin_amex) && (mb_strlen($acquirer_bin_amex) > 11)) { + throw new \InvalidArgumentException('invalid length for $acquirer_bin_amex when calling PaymentServiceUpdate., must be smaller than or equal to 11.'); + } + + $this->container['acquirer_bin_amex'] = $acquirer_bin_amex; + + return $this; + } + + /** + * Gets acquirer_bin_discover + * + * @return string|null + */ + public function getAcquirerBinDiscover() + { + return $this->container['acquirer_bin_discover']; + } + + /** + * Sets acquirer_bin_discover + * + * @param string|null $acquirer_bin_discover Acquiring institution identification code for Discover. + * + * @return self + */ + public function setAcquirerBinDiscover($acquirer_bin_discover) + { + if (!is_null($acquirer_bin_discover) && (mb_strlen($acquirer_bin_discover) > 11)) { + throw new \InvalidArgumentException('invalid length for $acquirer_bin_discover when calling PaymentServiceUpdate., must be smaller than or equal to 11.'); + } + + $this->container['acquirer_bin_discover'] = $acquirer_bin_discover; + + return $this; + } + + /** + * Gets acquirer_merchant_id + * + * @return string|null + */ + public function getAcquirerMerchantId() + { + return $this->container['acquirer_merchant_id']; + } + + /** + * Sets acquirer_merchant_id + * + * @param string|null $acquirer_merchant_id Merchant identifier used in authorisation requests (assigned by the acquirer). + * + * @return self + */ + public function setAcquirerMerchantId($acquirer_merchant_id) + { + if (!is_null($acquirer_merchant_id) && (mb_strlen($acquirer_merchant_id) > 35)) { + throw new \InvalidArgumentException('invalid length for $acquirer_merchant_id when calling PaymentServiceUpdate., must be smaller than or equal to 35.'); + } + + $this->container['acquirer_merchant_id'] = $acquirer_merchant_id; + + return $this; + } + + /** + * Gets merchant_name + * + * @return string|null + */ + public function getMerchantName() + { + return $this->container['merchant_name']; + } + + /** + * Sets merchant_name + * + * @param string|null $merchant_name Merchant name (assigned by the acquirer). + * + * @return self + */ + public function setMerchantName($merchant_name) + { + if (!is_null($merchant_name) && (mb_strlen($merchant_name) > 40)) { + throw new \InvalidArgumentException('invalid length for $merchant_name when calling PaymentServiceUpdate., must be smaller than or equal to 40.'); + } + + $this->container['merchant_name'] = $merchant_name; + + return $this; + } + + /** + * Gets merchant_country_code + * + * @return string|null + */ + public function getMerchantCountryCode() + { + return $this->container['merchant_country_code']; + } + + /** + * Sets merchant_country_code + * + * @param string|null $merchant_country_code ISO 3166-1 numeric three-digit country code. + * + * @return self + */ + public function setMerchantCountryCode($merchant_country_code) + { + + if (!is_null($merchant_country_code) && (!preg_match("/^\\d{3}$/", $merchant_country_code))) { + throw new \InvalidArgumentException("invalid value for $merchant_country_code when calling PaymentServiceUpdate., must conform to the pattern /^\\d{3}$/."); + } + + $this->container['merchant_country_code'] = $merchant_country_code; + + return $this; + } + + /** + * Gets merchant_category_code + * + * @return string|null + */ + public function getMerchantCategoryCode() + { + return $this->container['merchant_category_code']; + } + + /** + * Sets merchant_category_code + * + * @param string|null $merchant_category_code Merchant category code that describes the business. + * + * @return self + */ + public function setMerchantCategoryCode($merchant_category_code) + { + if (!is_null($merchant_category_code) && (mb_strlen($merchant_category_code) > 4)) { + throw new \InvalidArgumentException('invalid length for $merchant_category_code when calling PaymentServiceUpdate., must be smaller than or equal to 4.'); + } + if (!is_null($merchant_category_code) && (mb_strlen($merchant_category_code) < 4)) { + throw new \InvalidArgumentException('invalid length for $merchant_category_code when calling PaymentServiceUpdate., must be bigger than or equal to 4.'); + } + + $this->container['merchant_category_code'] = $merchant_category_code; + + return $this; + } + + /** + * Gets merchant_url + * + * @return string|null + */ + public function getMerchantUrl() + { + return $this->container['merchant_url']; + } + + /** + * Sets merchant_url + * + * @param string|null $merchant_url Fully qualified URL of 3-D Secure requestor website or customer care site. + * + * @return self + */ + public function setMerchantUrl($merchant_url) + { + if (!is_null($merchant_url) && (mb_strlen($merchant_url) > 2048)) { + throw new \InvalidArgumentException('invalid length for $merchant_url when calling PaymentServiceUpdate., must be smaller than or equal to 2048.'); + } + + $this->container['merchant_url'] = $merchant_url; + + return $this; + } + + /** + * Gets active + * + * @return bool|null + */ + public function getActive() + { + return $this->container['active']; + } + + /** + * Sets active + * + * @param bool|null $active Defines if this service is currently active or not. + * + * @return self + */ + public function setActive($active) + { + $this->container['active'] = $active; + + return $this; + } + + /** + * Gets position + * + * @return float|null + */ + public function getPosition() + { + return $this->container['position']; + } + + /** + * Sets position + * + * @param float|null $position The numeric rank of a payment service. Payment services with a lower position value are processed first. When a payment services is inserted at a position, any payment services with the the same value or higher are shifted down a position accordingly. When left out, the payment service is inserted at the end of the list. + * + * @return self + */ + public function setPosition($position) + { + $this->container['position'] = $position; + + return $this; + } + + /** + * Gets payment_method_tokenization_enabled + * + * @return bool|null + */ + public function getPaymentMethodTokenizationEnabled() + { + return $this->container['payment_method_tokenization_enabled']; + } + + /** + * Sets payment_method_tokenization_enabled + * + * @param bool|null $payment_method_tokenization_enabled Defines if tokenization is enabled for the service (can only be enabled if the payment service definition supports it). + * + * @return self + */ + public function setPaymentMethodTokenizationEnabled($payment_method_tokenization_enabled) + { + $this->container['payment_method_tokenization_enabled'] = $payment_method_tokenization_enabled; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/PaymentServiceUpdateFieldsInner.php b/lib/model/PaymentServiceUpdateFieldsInner.php new file mode 100644 index 0000000..8202d44 --- /dev/null +++ b/lib/model/PaymentServiceUpdateFieldsInner.php @@ -0,0 +1,390 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class PaymentServiceUpdateFieldsInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PaymentServiceUpdate_fields_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'key' => 'string', + 'value' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'key' => null, + 'value' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'key' => 'key', + 'value' => 'value' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'key' => 'setKey', + 'value' => 'setValue' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'key' => 'getKey', + 'value' => 'getValue' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['key'] = $data['key'] ?? null; + $this->container['value'] = $data['value'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['key'] === null) { + $invalidProperties[] = "'key' can't be null"; + } + if ((mb_strlen($this->container['key']) > 50)) { + $invalidProperties[] = "invalid value for 'key', the character length must be smaller than or equal to 50."; + } + + if ((mb_strlen($this->container['key']) < 1)) { + $invalidProperties[] = "invalid value for 'key', the character length must be bigger than or equal to 1."; + } + + if ($this->container['value'] === null) { + $invalidProperties[] = "'value' can't be null"; + } + if ((mb_strlen($this->container['value']) > 5000)) { + $invalidProperties[] = "invalid value for 'value', the character length must be smaller than or equal to 5000."; + } + + if ((mb_strlen($this->container['value']) < 1)) { + $invalidProperties[] = "invalid value for 'value', the character length must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets key + * + * @return string + */ + public function getKey() + { + return $this->container['key']; + } + + /** + * Sets key + * + * @param string $key The key of the field to set a value for. + * + * @return self + */ + public function setKey($key) + { + if ((mb_strlen($key) > 50)) { + throw new \InvalidArgumentException('invalid length for $key when calling PaymentServiceUpdateFieldsInner., must be smaller than or equal to 50.'); + } + if ((mb_strlen($key) < 1)) { + throw new \InvalidArgumentException('invalid length for $key when calling PaymentServiceUpdateFieldsInner., must be bigger than or equal to 1.'); + } + + $this->container['key'] = $key; + + return $this; + } + + /** + * Gets value + * + * @return string + */ + public function getValue() + { + return $this->container['value']; + } + + /** + * Sets value + * + * @param string $value The value of a field to set. + * + * @return self + */ + public function setValue($value) + { + if ((mb_strlen($value) > 5000)) { + throw new \InvalidArgumentException('invalid length for $value when calling PaymentServiceUpdateFieldsInner., must be smaller than or equal to 5000.'); + } + if ((mb_strlen($value) < 1)) { + throw new \InvalidArgumentException('invalid length for $value when calling PaymentServiceUpdateFieldsInner., must be bigger than or equal to 1.'); + } + + $this->container['value'] = $value; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/PaymentServices.php b/lib/model/PaymentServices.php new file mode 100644 index 0000000..4cd2c9b --- /dev/null +++ b/lib/model/PaymentServices.php @@ -0,0 +1,460 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class PaymentServices implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PaymentServices'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'items' => '\Gr4vy\model\PaymentService[]', + 'limit' => 'int', + 'next_cursor' => 'string', + 'previous_cursor' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'items' => null, + 'limit' => 'int32', + 'next_cursor' => null, + 'previous_cursor' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'items' => 'items', + 'limit' => 'limit', + 'next_cursor' => 'next_cursor', + 'previous_cursor' => 'previous_cursor' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'items' => 'setItems', + 'limit' => 'setLimit', + 'next_cursor' => 'setNextCursor', + 'previous_cursor' => 'setPreviousCursor' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'items' => 'getItems', + 'limit' => 'getLimit', + 'next_cursor' => 'getNextCursor', + 'previous_cursor' => 'getPreviousCursor' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['items'] = $data['items'] ?? null; + $this->container['limit'] = $data['limit'] ?? 20; + $this->container['next_cursor'] = $data['next_cursor'] ?? null; + $this->container['previous_cursor'] = $data['previous_cursor'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['limit']) && ($this->container['limit'] > 100)) { + $invalidProperties[] = "invalid value for 'limit', must be smaller than or equal to 100."; + } + + if (!is_null($this->container['limit']) && ($this->container['limit'] < 1)) { + $invalidProperties[] = "invalid value for 'limit', must be bigger than or equal to 1."; + } + + if (!is_null($this->container['next_cursor']) && (mb_strlen($this->container['next_cursor']) > 1000)) { + $invalidProperties[] = "invalid value for 'next_cursor', the character length must be smaller than or equal to 1000."; + } + + if (!is_null($this->container['next_cursor']) && (mb_strlen($this->container['next_cursor']) < 1)) { + $invalidProperties[] = "invalid value for 'next_cursor', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['previous_cursor']) && (mb_strlen($this->container['previous_cursor']) > 1000)) { + $invalidProperties[] = "invalid value for 'previous_cursor', the character length must be smaller than or equal to 1000."; + } + + if (!is_null($this->container['previous_cursor']) && (mb_strlen($this->container['previous_cursor']) < 1)) { + $invalidProperties[] = "invalid value for 'previous_cursor', the character length must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets items + * + * @return \Gr4vy\model\PaymentService[]|null + */ + public function getItems() + { + return $this->container['items']; + } + + /** + * Sets items + * + * @param \Gr4vy\model\PaymentService[]|null $items items + * + * @return self + */ + public function setItems($items) + { + $this->container['items'] = $items; + + return $this; + } + + /** + * Gets limit + * + * @return int|null + */ + public function getLimit() + { + return $this->container['limit']; + } + + /** + * Sets limit + * + * @param int|null $limit The limit applied to request. This represents the number of items that are at maximum returned by this request. + * + * @return self + */ + public function setLimit($limit) + { + + if (!is_null($limit) && ($limit > 100)) { + throw new \InvalidArgumentException('invalid value for $limit when calling PaymentServices., must be smaller than or equal to 100.'); + } + if (!is_null($limit) && ($limit < 1)) { + throw new \InvalidArgumentException('invalid value for $limit when calling PaymentServices., must be bigger than or equal to 1.'); + } + + $this->container['limit'] = $limit; + + return $this; + } + + /** + * Gets next_cursor + * + * @return string|null + */ + public function getNextCursor() + { + return $this->container['next_cursor']; + } + + /** + * Sets next_cursor + * + * @param string|null $next_cursor The cursor that represents the next page of results. Use the `cursor` query parameter to fetch this page of items. + * + * @return self + */ + public function setNextCursor($next_cursor) + { + if (!is_null($next_cursor) && (mb_strlen($next_cursor) > 1000)) { + throw new \InvalidArgumentException('invalid length for $next_cursor when calling PaymentServices., must be smaller than or equal to 1000.'); + } + if (!is_null($next_cursor) && (mb_strlen($next_cursor) < 1)) { + throw new \InvalidArgumentException('invalid length for $next_cursor when calling PaymentServices., must be bigger than or equal to 1.'); + } + + $this->container['next_cursor'] = $next_cursor; + + return $this; + } + + /** + * Gets previous_cursor + * + * @return string|null + */ + public function getPreviousCursor() + { + return $this->container['previous_cursor']; + } + + /** + * Sets previous_cursor + * + * @param string|null $previous_cursor The cursor that represents the next page of results. Use the `cursor` query parameter to fetch this page of items. + * + * @return self + */ + public function setPreviousCursor($previous_cursor) + { + if (!is_null($previous_cursor) && (mb_strlen($previous_cursor) > 1000)) { + throw new \InvalidArgumentException('invalid length for $previous_cursor when calling PaymentServices., must be smaller than or equal to 1000.'); + } + if (!is_null($previous_cursor) && (mb_strlen($previous_cursor) < 1)) { + throw new \InvalidArgumentException('invalid length for $previous_cursor when calling PaymentServices., must be bigger than or equal to 1.'); + } + + $this->container['previous_cursor'] = $previous_cursor; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/RedirectRequest.php b/lib/model/RedirectRequest.php new file mode 100644 index 0000000..00e6c52 --- /dev/null +++ b/lib/model/RedirectRequest.php @@ -0,0 +1,516 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class RedirectRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'RedirectRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'method' => 'string', + 'redirect_url' => 'string', + 'currency' => 'string', + 'country' => 'string', + 'external_identifier' => 'string', + 'buyer_id' => 'string', + 'buyer_external_identifier' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'method' => null, + 'redirect_url' => null, + 'currency' => null, + 'country' => null, + 'external_identifier' => null, + 'buyer_id' => 'uuid', + 'buyer_external_identifier' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'method' => 'method', + 'redirect_url' => 'redirect_url', + 'currency' => 'currency', + 'country' => 'country', + 'external_identifier' => 'external_identifier', + 'buyer_id' => 'buyer_id', + 'buyer_external_identifier' => 'buyer_external_identifier' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'method' => 'setMethod', + 'redirect_url' => 'setRedirectUrl', + 'currency' => 'setCurrency', + 'country' => 'setCountry', + 'external_identifier' => 'setExternalIdentifier', + 'buyer_id' => 'setBuyerId', + 'buyer_external_identifier' => 'setBuyerExternalIdentifier' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'method' => 'getMethod', + 'redirect_url' => 'getRedirectUrl', + 'currency' => 'getCurrency', + 'country' => 'getCountry', + 'external_identifier' => 'getExternalIdentifier', + 'buyer_id' => 'getBuyerId', + 'buyer_external_identifier' => 'getBuyerExternalIdentifier' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['method'] = $data['method'] ?? null; + $this->container['redirect_url'] = $data['redirect_url'] ?? null; + $this->container['currency'] = $data['currency'] ?? null; + $this->container['country'] = $data['country'] ?? null; + $this->container['external_identifier'] = $data['external_identifier'] ?? null; + $this->container['buyer_id'] = $data['buyer_id'] ?? null; + $this->container['buyer_external_identifier'] = $data['buyer_external_identifier'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['method'] === null) { + $invalidProperties[] = "'method' can't be null"; + } + if ($this->container['redirect_url'] === null) { + $invalidProperties[] = "'redirect_url' can't be null"; + } + if ($this->container['currency'] === null) { + $invalidProperties[] = "'currency' can't be null"; + } + if ($this->container['country'] === null) { + $invalidProperties[] = "'country' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets method + * + * @return string + */ + public function getMethod() + { + return $this->container['method']; + } + + /** + * Sets method + * + * @param string $method method + * + * @return self + */ + public function setMethod($method) + { + $this->container['method'] = $method; + + return $this; + } + + /** + * Gets redirect_url + * + * @return string + */ + public function getRedirectUrl() + { + return $this->container['redirect_url']; + } + + /** + * Sets redirect_url + * + * @param string $redirect_url The redirect URL to redirect a buyer to after they have authorized their transaction. + * + * @return self + */ + public function setRedirectUrl($redirect_url) + { + $this->container['redirect_url'] = $redirect_url; + + return $this; + } + + /** + * Gets currency + * + * @return string + */ + public function getCurrency() + { + return $this->container['currency']; + } + + /** + * Sets currency + * + * @param string $currency The ISO-4217 currency code to use this payment method for. This is used to select the payment service to use. + * + * @return self + */ + public function setCurrency($currency) + { + $this->container['currency'] = $currency; + + return $this; + } + + /** + * Gets country + * + * @return string + */ + public function getCountry() + { + return $this->container['country']; + } + + /** + * Sets country + * + * @param string $country The 2-letter ISO code of the country to use this payment method for. This is used to select the payment service to use. + * + * @return self + */ + public function setCountry($country) + { + $this->container['country'] = $country; + + return $this; + } + + /** + * Gets external_identifier + * + * @return string|null + */ + public function getExternalIdentifier() + { + return $this->container['external_identifier']; + } + + /** + * Sets external_identifier + * + * @param string|null $external_identifier An external identifier that can be used to match the account against your own records. + * + * @return self + */ + public function setExternalIdentifier($external_identifier) + { + $this->container['external_identifier'] = $external_identifier; + + return $this; + } + + /** + * Gets buyer_id + * + * @return string|null + */ + public function getBuyerId() + { + return $this->container['buyer_id']; + } + + /** + * Sets buyer_id + * + * @param string|null $buyer_id The ID of the buyer to associate this payment method to. If this field is provided then the `buyer_external_identifier` field needs to be unset. + * + * @return self + */ + public function setBuyerId($buyer_id) + { + $this->container['buyer_id'] = $buyer_id; + + return $this; + } + + /** + * Gets buyer_external_identifier + * + * @return string|null + */ + public function getBuyerExternalIdentifier() + { + return $this->container['buyer_external_identifier']; + } + + /** + * Sets buyer_external_identifier + * + * @param string|null $buyer_external_identifier The `external_identifier` of the buyer to associate this payment method to. If this field is provided then the `buyer_id` field needs to be unset. + * + * @return self + */ + public function setBuyerExternalIdentifier($buyer_external_identifier) + { + $this->container['buyer_external_identifier'] = $buyer_external_identifier; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/Refund.php b/lib/model/Refund.php new file mode 100644 index 0000000..1d80056 --- /dev/null +++ b/lib/model/Refund.php @@ -0,0 +1,622 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class Refund implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'Refund'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'id' => 'string', + 'transaction_id' => 'string', + 'status' => 'string', + 'currency' => 'string', + 'amount' => 'int', + 'created_at' => '\DateTime', + 'updated_at' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'id' => 'uuid', + 'transaction_id' => 'uuid', + 'status' => null, + 'currency' => null, + 'amount' => null, + 'created_at' => 'date-time', + 'updated_at' => 'date-time' + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'id' => 'id', + 'transaction_id' => 'transaction_id', + 'status' => 'status', + 'currency' => 'currency', + 'amount' => 'amount', + 'created_at' => 'created_at', + 'updated_at' => 'updated_at' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'id' => 'setId', + 'transaction_id' => 'setTransactionId', + 'status' => 'setStatus', + 'currency' => 'setCurrency', + 'amount' => 'setAmount', + 'created_at' => 'setCreatedAt', + 'updated_at' => 'setUpdatedAt' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'id' => 'getId', + 'transaction_id' => 'getTransactionId', + 'status' => 'getStatus', + 'currency' => 'getCurrency', + 'amount' => 'getAmount', + 'created_at' => 'getCreatedAt', + 'updated_at' => 'getUpdatedAt' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_REFUND = 'refund'; + public const STATUS_PROCESSING = 'processing'; + public const STATUS_SUCCEEDED = 'succeeded'; + public const STATUS_DECLINED = 'declined'; + public const STATUS_FAILED = 'failed'; + public const STATUS_VOIDED = 'voided'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_REFUND, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStatusAllowableValues() + { + return [ + self::STATUS_PROCESSING, + self::STATUS_SUCCEEDED, + self::STATUS_DECLINED, + self::STATUS_FAILED, + self::STATUS_VOIDED, + ]; + } + + /** + * 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['type'] = $data['type'] ?? null; + $this->container['id'] = $data['id'] ?? null; + $this->container['transaction_id'] = $data['transaction_id'] ?? null; + $this->container['status'] = $data['status'] ?? null; + $this->container['currency'] = $data['currency'] ?? null; + $this->container['amount'] = $data['amount'] ?? null; + $this->container['created_at'] = $data['created_at'] ?? null; + $this->container['updated_at'] = $data['updated_at'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($this->container['status']) && !in_array($this->container['status'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'status', must be one of '%s'", + $this->container['status'], + implode("', '", $allowedValues) + ); + } + + if (!is_null($this->container['amount']) && ($this->container['amount'] > 99999999)) { + $invalidProperties[] = "invalid value for 'amount', must be smaller than or equal to 99999999."; + } + + if (!is_null($this->container['amount']) && ($this->container['amount'] < 0)) { + $invalidProperties[] = "invalid value for 'amount', must be bigger than or equal to 0."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type The type of this resource. Is always `refund`. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id The unique ID of the refund. + * + * @return self + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets transaction_id + * + * @return string|null + */ + public function getTransactionId() + { + return $this->container['transaction_id']; + } + + /** + * Sets transaction_id + * + * @param string|null $transaction_id The ID of the transaction associated with this refund. + * + * @return self + */ + public function setTransactionId($transaction_id) + { + $this->container['transaction_id'] = $transaction_id; + + return $this; + } + + /** + * Gets status + * + * @return string|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param string|null $status The status of the refund. It may change over time as asynchronous processing events occur. - `processing` - The refund is being processed. - `succeeded` - The refund was successful. - `declined` - The refund was declined by the underlying PSP. - `failed` - The refund could not proceed due to a technical issue. - `voided` - The refund was voided and will not proceed. + * + * @return self + */ + public function setStatus($status) + { + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($status) && !in_array($status, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'status', must be one of '%s'", + $status, + implode("', '", $allowedValues) + ) + ); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets currency + * + * @return string|null + */ + public function getCurrency() + { + return $this->container['currency']; + } + + /** + * Sets currency + * + * @param string|null $currency The currency code for this refund. Will always match that of the associated transaction. + * + * @return self + */ + public function setCurrency($currency) + { + $this->container['currency'] = $currency; + + return $this; + } + + /** + * Gets amount + * + * @return int|null + */ + public function getAmount() + { + return $this->container['amount']; + } + + /** + * Sets amount + * + * @param int|null $amount The amount requested for this refund. + * + * @return self + */ + public function setAmount($amount) + { + + if (!is_null($amount) && ($amount > 99999999)) { + throw new \InvalidArgumentException('invalid value for $amount when calling Refund., must be smaller than or equal to 99999999.'); + } + if (!is_null($amount) && ($amount < 0)) { + throw new \InvalidArgumentException('invalid value for $amount when calling Refund., must be bigger than or equal to 0.'); + } + + $this->container['amount'] = $amount; + + return $this; + } + + /** + * Gets created_at + * + * @return \DateTime|null + */ + public function getCreatedAt() + { + return $this->container['created_at']; + } + + /** + * Sets created_at + * + * @param \DateTime|null $created_at The date and time when this refund was created. + * + * @return self + */ + public function setCreatedAt($created_at) + { + $this->container['created_at'] = $created_at; + + return $this; + } + + /** + * Gets updated_at + * + * @return \DateTime|null + */ + public function getUpdatedAt() + { + return $this->container['updated_at']; + } + + /** + * Sets updated_at + * + * @param \DateTime|null $updated_at The date and time when this refund was last updated. + * + * @return self + */ + public function setUpdatedAt($updated_at) + { + $this->container['updated_at'] = $updated_at; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/Refunds.php b/lib/model/Refunds.php new file mode 100644 index 0000000..ffee741 --- /dev/null +++ b/lib/model/Refunds.php @@ -0,0 +1,460 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class Refunds implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'Refunds'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'items' => '\Gr4vy\model\Refund[]', + 'limit' => 'int', + 'next_cursor' => 'string', + 'previous_cursor' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'items' => null, + 'limit' => 'int32', + 'next_cursor' => null, + 'previous_cursor' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'items' => 'items', + 'limit' => 'limit', + 'next_cursor' => 'next_cursor', + 'previous_cursor' => 'previous_cursor' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'items' => 'setItems', + 'limit' => 'setLimit', + 'next_cursor' => 'setNextCursor', + 'previous_cursor' => 'setPreviousCursor' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'items' => 'getItems', + 'limit' => 'getLimit', + 'next_cursor' => 'getNextCursor', + 'previous_cursor' => 'getPreviousCursor' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['items'] = $data['items'] ?? null; + $this->container['limit'] = $data['limit'] ?? 20; + $this->container['next_cursor'] = $data['next_cursor'] ?? null; + $this->container['previous_cursor'] = $data['previous_cursor'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['limit']) && ($this->container['limit'] > 100)) { + $invalidProperties[] = "invalid value for 'limit', must be smaller than or equal to 100."; + } + + if (!is_null($this->container['limit']) && ($this->container['limit'] < 1)) { + $invalidProperties[] = "invalid value for 'limit', must be bigger than or equal to 1."; + } + + if (!is_null($this->container['next_cursor']) && (mb_strlen($this->container['next_cursor']) > 1000)) { + $invalidProperties[] = "invalid value for 'next_cursor', the character length must be smaller than or equal to 1000."; + } + + if (!is_null($this->container['next_cursor']) && (mb_strlen($this->container['next_cursor']) < 1)) { + $invalidProperties[] = "invalid value for 'next_cursor', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['previous_cursor']) && (mb_strlen($this->container['previous_cursor']) > 1000)) { + $invalidProperties[] = "invalid value for 'previous_cursor', the character length must be smaller than or equal to 1000."; + } + + if (!is_null($this->container['previous_cursor']) && (mb_strlen($this->container['previous_cursor']) < 1)) { + $invalidProperties[] = "invalid value for 'previous_cursor', the character length must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets items + * + * @return \Gr4vy\model\Refund[]|null + */ + public function getItems() + { + return $this->container['items']; + } + + /** + * Sets items + * + * @param \Gr4vy\model\Refund[]|null $items A list of refunds. + * + * @return self + */ + public function setItems($items) + { + $this->container['items'] = $items; + + return $this; + } + + /** + * Gets limit + * + * @return int|null + */ + public function getLimit() + { + return $this->container['limit']; + } + + /** + * Sets limit + * + * @param int|null $limit The limit applied to request. This represents the number of items that are at maximum returned by this request. + * + * @return self + */ + public function setLimit($limit) + { + + if (!is_null($limit) && ($limit > 100)) { + throw new \InvalidArgumentException('invalid value for $limit when calling Refunds., must be smaller than or equal to 100.'); + } + if (!is_null($limit) && ($limit < 1)) { + throw new \InvalidArgumentException('invalid value for $limit when calling Refunds., must be bigger than or equal to 1.'); + } + + $this->container['limit'] = $limit; + + return $this; + } + + /** + * Gets next_cursor + * + * @return string|null + */ + public function getNextCursor() + { + return $this->container['next_cursor']; + } + + /** + * Sets next_cursor + * + * @param string|null $next_cursor The cursor that represents the next page of results. Use the `cursor` query parameter to fetch this page of items. + * + * @return self + */ + public function setNextCursor($next_cursor) + { + if (!is_null($next_cursor) && (mb_strlen($next_cursor) > 1000)) { + throw new \InvalidArgumentException('invalid length for $next_cursor when calling Refunds., must be smaller than or equal to 1000.'); + } + if (!is_null($next_cursor) && (mb_strlen($next_cursor) < 1)) { + throw new \InvalidArgumentException('invalid length for $next_cursor when calling Refunds., must be bigger than or equal to 1.'); + } + + $this->container['next_cursor'] = $next_cursor; + + return $this; + } + + /** + * Gets previous_cursor + * + * @return string|null + */ + public function getPreviousCursor() + { + return $this->container['previous_cursor']; + } + + /** + * Sets previous_cursor + * + * @param string|null $previous_cursor The cursor that represents the next page of results. Use the `cursor` query parameter to fetch this page of items. + * + * @return self + */ + public function setPreviousCursor($previous_cursor) + { + if (!is_null($previous_cursor) && (mb_strlen($previous_cursor) > 1000)) { + throw new \InvalidArgumentException('invalid length for $previous_cursor when calling Refunds., must be smaller than or equal to 1000.'); + } + if (!is_null($previous_cursor) && (mb_strlen($previous_cursor) < 1)) { + throw new \InvalidArgumentException('invalid length for $previous_cursor when calling Refunds., must be bigger than or equal to 1.'); + } + + $this->container['previous_cursor'] = $previous_cursor; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/RequiredFields.php b/lib/model/RequiredFields.php new file mode 100644 index 0000000..15af003 --- /dev/null +++ b/lib/model/RequiredFields.php @@ -0,0 +1,474 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class RequiredFields implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'RequiredFields'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'first_name' => 'bool', + 'last_name' => 'bool', + 'email_address' => 'bool', + 'phone_number' => 'bool', + 'address' => '\Gr4vy\model\RequiredFieldsAddress', + 'tax_id' => 'bool' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'first_name' => null, + 'last_name' => null, + 'email_address' => null, + 'phone_number' => null, + 'address' => null, + 'tax_id' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'first_name' => 'first_name', + 'last_name' => 'last_name', + 'email_address' => 'email_address', + 'phone_number' => 'phone_number', + 'address' => 'address', + 'tax_id' => 'tax_id' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'first_name' => 'setFirstName', + 'last_name' => 'setLastName', + 'email_address' => 'setEmailAddress', + 'phone_number' => 'setPhoneNumber', + 'address' => 'setAddress', + 'tax_id' => 'setTaxId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'first_name' => 'getFirstName', + 'last_name' => 'getLastName', + 'email_address' => 'getEmailAddress', + 'phone_number' => 'getPhoneNumber', + 'address' => 'getAddress', + 'tax_id' => 'getTaxId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['first_name'] = $data['first_name'] ?? null; + $this->container['last_name'] = $data['last_name'] ?? null; + $this->container['email_address'] = $data['email_address'] ?? null; + $this->container['phone_number'] = $data['phone_number'] ?? null; + $this->container['address'] = $data['address'] ?? null; + $this->container['tax_id'] = $data['tax_id'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets first_name + * + * @return bool|null + */ + public function getFirstName() + { + return $this->container['first_name']; + } + + /** + * Sets first_name + * + * @param bool|null $first_name The first (given) name of the buyer. + * + * @return self + */ + public function setFirstName($first_name) + { + $this->container['first_name'] = $first_name; + + return $this; + } + + /** + * Gets last_name + * + * @return bool|null + */ + public function getLastName() + { + return $this->container['last_name']; + } + + /** + * Sets last_name + * + * @param bool|null $last_name The last (family) name of the buyer. + * + * @return self + */ + public function setLastName($last_name) + { + $this->container['last_name'] = $last_name; + + return $this; + } + + /** + * Gets email_address + * + * @return bool|null + */ + public function getEmailAddress() + { + return $this->container['email_address']; + } + + /** + * Sets email_address + * + * @param bool|null $email_address The email address of the buyer. + * + * @return self + */ + public function setEmailAddress($email_address) + { + $this->container['email_address'] = $email_address; + + return $this; + } + + /** + * Gets phone_number + * + * @return bool|null + */ + public function getPhoneNumber() + { + return $this->container['phone_number']; + } + + /** + * Sets phone_number + * + * @param bool|null $phone_number The phone number of the buyer. + * + * @return self + */ + public function setPhoneNumber($phone_number) + { + $this->container['phone_number'] = $phone_number; + + return $this; + } + + /** + * Gets address + * + * @return \Gr4vy\model\RequiredFieldsAddress|null + */ + public function getAddress() + { + return $this->container['address']; + } + + /** + * Sets address + * + * @param \Gr4vy\model\RequiredFieldsAddress|null $address address + * + * @return self + */ + public function setAddress($address) + { + $this->container['address'] = $address; + + return $this; + } + + /** + * Gets tax_id + * + * @return bool|null + */ + public function getTaxId() + { + return $this->container['tax_id']; + } + + /** + * Sets tax_id + * + * @param bool|null $tax_id The tax id code associated with the billing details. + * + * @return self + */ + public function setTaxId($tax_id) + { + $this->container['tax_id'] = $tax_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/RequiredFieldsAddress.php b/lib/model/RequiredFieldsAddress.php new file mode 100644 index 0000000..cf35952 --- /dev/null +++ b/lib/model/RequiredFieldsAddress.php @@ -0,0 +1,474 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class RequiredFieldsAddress implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'RequiredFields_address'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'city' => 'bool', + 'country' => 'bool', + 'postal_code' => 'bool', + 'state' => 'bool', + 'house_number_or_name' => 'bool', + 'line1' => 'bool' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'city' => null, + 'country' => null, + 'postal_code' => null, + 'state' => null, + 'house_number_or_name' => null, + 'line1' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'city' => 'city', + 'country' => 'country', + 'postal_code' => 'postal_code', + 'state' => 'state', + 'house_number_or_name' => 'house_number_or_name', + 'line1' => 'line1' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'city' => 'setCity', + 'country' => 'setCountry', + 'postal_code' => 'setPostalCode', + 'state' => 'setState', + 'house_number_or_name' => 'setHouseNumberOrName', + 'line1' => 'setLine1' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'city' => 'getCity', + 'country' => 'getCountry', + 'postal_code' => 'getPostalCode', + 'state' => 'getState', + 'house_number_or_name' => 'getHouseNumberOrName', + 'line1' => 'getLine1' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['city'] = $data['city'] ?? null; + $this->container['country'] = $data['country'] ?? null; + $this->container['postal_code'] = $data['postal_code'] ?? null; + $this->container['state'] = $data['state'] ?? null; + $this->container['house_number_or_name'] = $data['house_number_or_name'] ?? null; + $this->container['line1'] = $data['line1'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets city + * + * @return bool|null + */ + public function getCity() + { + return $this->container['city']; + } + + /** + * Sets city + * + * @param bool|null $city The city for the billing address. + * + * @return self + */ + public function setCity($city) + { + $this->container['city'] = $city; + + return $this; + } + + /** + * Gets country + * + * @return bool|null + */ + public function getCountry() + { + return $this->container['country']; + } + + /** + * Sets country + * + * @param bool|null $country The country for the billing address. + * + * @return self + */ + public function setCountry($country) + { + $this->container['country'] = $country; + + return $this; + } + + /** + * Gets postal_code + * + * @return bool|null + */ + public function getPostalCode() + { + return $this->container['postal_code']; + } + + /** + * Sets postal_code + * + * @param bool|null $postal_code The postal code or zip code for the billing address. + * + * @return self + */ + public function setPostalCode($postal_code) + { + $this->container['postal_code'] = $postal_code; + + return $this; + } + + /** + * Gets state + * + * @return bool|null + */ + public function getState() + { + return $this->container['state']; + } + + /** + * Sets state + * + * @param bool|null $state The state, county, or province for the billing address. + * + * @return self + */ + public function setState($state) + { + $this->container['state'] = $state; + + return $this; + } + + /** + * Gets house_number_or_name + * + * @return bool|null + */ + public function getHouseNumberOrName() + { + return $this->container['house_number_or_name']; + } + + /** + * Sets house_number_or_name + * + * @param bool|null $house_number_or_name The house number or name for the billing address. Not all payment services use this field but some do. + * + * @return self + */ + public function setHouseNumberOrName($house_number_or_name) + { + $this->container['house_number_or_name'] = $house_number_or_name; + + return $this; + } + + /** + * Gets line1 + * + * @return bool|null + */ + public function getLine1() + { + return $this->container['line1']; + } + + /** + * Sets line1 + * + * @param bool|null $line1 The first line of the billing address. + * + * @return self + */ + public function setLine1($line1) + { + $this->container['line1'] = $line1; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/ResetPasswordRequest.php b/lib/model/ResetPasswordRequest.php new file mode 100644 index 0000000..6c94caa --- /dev/null +++ b/lib/model/ResetPasswordRequest.php @@ -0,0 +1,324 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class ResetPasswordRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ResetPasswordRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'email_address' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'email_address' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'email_address' => 'email_address' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'email_address' => 'setEmailAddress' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'email_address' => 'getEmailAddress' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['email_address'] = $data['email_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 count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets email_address + * + * @return string|null + */ + public function getEmailAddress() + { + return $this->container['email_address']; + } + + /** + * Sets email_address + * + * @param string|null $email_address The email address of the user account to reset. + * + * @return self + */ + public function setEmailAddress($email_address) + { + $this->container['email_address'] = $email_address; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/SetPasswordRequest.php b/lib/model/SetPasswordRequest.php new file mode 100644 index 0000000..2edfe25 --- /dev/null +++ b/lib/model/SetPasswordRequest.php @@ -0,0 +1,369 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class SetPasswordRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'SetPasswordRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'reset_token' => 'string', + 'password' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'reset_token' => null, + 'password' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'reset_token' => 'reset_token', + 'password' => 'password' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'reset_token' => 'setResetToken', + 'password' => 'setPassword' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'reset_token' => 'getResetToken', + 'password' => 'getPassword' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['reset_token'] = $data['reset_token'] ?? null; + $this->container['password'] = $data['password'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['reset_token']) && (mb_strlen($this->container['reset_token']) > 100)) { + $invalidProperties[] = "invalid value for 'reset_token', the character length must be smaller than or equal to 100."; + } + + if (!is_null($this->container['reset_token']) && (mb_strlen($this->container['reset_token']) < 100)) { + $invalidProperties[] = "invalid value for 'reset_token', the character length must be bigger than or equal to 100."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets reset_token + * + * @return string|null + */ + public function getResetToken() + { + return $this->container['reset_token']; + } + + /** + * Sets reset_token + * + * @param string|null $reset_token Unique reset token valid for 7 days. + * + * @return self + */ + public function setResetToken($reset_token) + { + if (!is_null($reset_token) && (mb_strlen($reset_token) > 100)) { + throw new \InvalidArgumentException('invalid length for $reset_token when calling SetPasswordRequest., must be smaller than or equal to 100.'); + } + if (!is_null($reset_token) && (mb_strlen($reset_token) < 100)) { + throw new \InvalidArgumentException('invalid length for $reset_token when calling SetPasswordRequest., must be bigger than or equal to 100.'); + } + + $this->container['reset_token'] = $reset_token; + + return $this; + } + + /** + * Gets password + * + * @return string|null + */ + public function getPassword() + { + return $this->container['password']; + } + + /** + * Sets password + * + * @param string|null $password The password the user to log in with. + * + * @return self + */ + public function setPassword($password) + { + $this->container['password'] = $password; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/StatementDescriptor.php b/lib/model/StatementDescriptor.php new file mode 100644 index 0000000..84f0a5b --- /dev/null +++ b/lib/model/StatementDescriptor.php @@ -0,0 +1,526 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class StatementDescriptor implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'StatementDescriptor'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'name' => 'string', + 'description' => 'string', + 'city' => 'string', + 'phone_number' => 'string', + 'url' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'name' => null, + 'description' => null, + 'city' => null, + 'phone_number' => null, + 'url' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'name' => 'name', + 'description' => 'description', + 'city' => 'city', + 'phone_number' => 'phone_number', + 'url' => 'url' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'name' => 'setName', + 'description' => 'setDescription', + 'city' => 'setCity', + 'phone_number' => 'setPhoneNumber', + 'url' => 'setUrl' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'name' => 'getName', + 'description' => 'getDescription', + 'city' => 'getCity', + 'phone_number' => 'getPhoneNumber', + 'url' => 'getUrl' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['name'] = $data['name'] ?? null; + $this->container['description'] = $data['description'] ?? null; + $this->container['city'] = $data['city'] ?? null; + $this->container['phone_number'] = $data['phone_number'] ?? null; + $this->container['url'] = $data['url'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['name']) && (mb_strlen($this->container['name']) > 22)) { + $invalidProperties[] = "invalid value for 'name', the character length must be smaller than or equal to 22."; + } + + if (!is_null($this->container['name']) && (mb_strlen($this->container['name']) < 5)) { + $invalidProperties[] = "invalid value for 'name', the character length must be bigger than or equal to 5."; + } + + if (!is_null($this->container['description']) && (mb_strlen($this->container['description']) > 22)) { + $invalidProperties[] = "invalid value for 'description', the character length must be smaller than or equal to 22."; + } + + if (!is_null($this->container['description']) && (mb_strlen($this->container['description']) < 5)) { + $invalidProperties[] = "invalid value for 'description', the character length must be bigger than or equal to 5."; + } + + if (!is_null($this->container['city']) && (mb_strlen($this->container['city']) > 13)) { + $invalidProperties[] = "invalid value for 'city', the character length must be smaller than or equal to 13."; + } + + if (!is_null($this->container['city']) && (mb_strlen($this->container['city']) < 1)) { + $invalidProperties[] = "invalid value for 'city', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['phone_number']) && (mb_strlen($this->container['phone_number']) > 20)) { + $invalidProperties[] = "invalid value for 'phone_number', the character length must be smaller than or equal to 20."; + } + + if (!is_null($this->container['phone_number']) && (mb_strlen($this->container['phone_number']) < 5)) { + $invalidProperties[] = "invalid value for 'phone_number', the character length must be bigger than or equal to 5."; + } + + if (!is_null($this->container['phone_number']) && !preg_match("/^\\+[1-9]\\d{1,14}$/", $this->container['phone_number'])) { + $invalidProperties[] = "invalid value for 'phone_number', must be conform to the pattern /^\\+[1-9]\\d{1,14}$/."; + } + + if (!is_null($this->container['url']) && (mb_strlen($this->container['url']) > 13)) { + $invalidProperties[] = "invalid value for 'url', the character length must be smaller than or equal to 13."; + } + + if (!is_null($this->container['url']) && (mb_strlen($this->container['url']) < 1)) { + $invalidProperties[] = "invalid value for 'url', the character length must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name Reflects your doing business as (DBA) name. Other validations: 1. Contains only Latin characters. 2. Contain at least one letter 3. Does not contain any of the special characters `< > \\ ' \" *` 4. Supports: 1. Lower case: `a-z` 2. Upper case: `A-Z` 3. Numbers: `0-9` 4. Spaces: ` ` 5. Special characters: `. , _ - ? + /`. + * + * @return self + */ + public function setName($name) + { + if (!is_null($name) && (mb_strlen($name) > 22)) { + throw new \InvalidArgumentException('invalid length for $name when calling StatementDescriptor., must be smaller than or equal to 22.'); + } + if (!is_null($name) && (mb_strlen($name) < 5)) { + throw new \InvalidArgumentException('invalid length for $name when calling StatementDescriptor., must be bigger than or equal to 5.'); + } + + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets description + * + * @return string|null + */ + public function getDescription() + { + return $this->container['description']; + } + + /** + * Sets description + * + * @param string|null $description A short description about the purchase. Other validations: 1. Contains only Latin characters. 2. Contain at least one letter 3. Does not contain any of the special characters `< > \\ ' \" *` 4. Supports: 1. Lower case: `a-z` 2. Upper case: `A-Z` 3. Numbers: `0-9` 4. Spaces: ` ` 5. Special characters: `. , _ - ? + /`. + * + * @return self + */ + public function setDescription($description) + { + if (!is_null($description) && (mb_strlen($description) > 22)) { + throw new \InvalidArgumentException('invalid length for $description when calling StatementDescriptor., must be smaller than or equal to 22.'); + } + if (!is_null($description) && (mb_strlen($description) < 5)) { + throw new \InvalidArgumentException('invalid length for $description when calling StatementDescriptor., must be bigger than or equal to 5.'); + } + + $this->container['description'] = $description; + + return $this; + } + + /** + * Gets city + * + * @return string|null + */ + public function getCity() + { + return $this->container['city']; + } + + /** + * Sets city + * + * @param string|null $city City from which the charge originated. + * + * @return self + */ + public function setCity($city) + { + if (!is_null($city) && (mb_strlen($city) > 13)) { + throw new \InvalidArgumentException('invalid length for $city when calling StatementDescriptor., must be smaller than or equal to 13.'); + } + if (!is_null($city) && (mb_strlen($city) < 1)) { + throw new \InvalidArgumentException('invalid length for $city when calling StatementDescriptor., must be bigger than or equal to 1.'); + } + + $this->container['city'] = $city; + + return $this; + } + + /** + * Gets phone_number + * + * @return string|null + */ + public function getPhoneNumber() + { + return $this->container['phone_number']; + } + + /** + * Sets phone_number + * + * @param string|null $phone_number The value in the phone number field of a customer's statement which should be formatted according to the [E164 number standard](https://www.twilio.com/docs/glossary/what-e164). + * + * @return self + */ + public function setPhoneNumber($phone_number) + { + if (!is_null($phone_number) && (mb_strlen($phone_number) > 20)) { + throw new \InvalidArgumentException('invalid length for $phone_number when calling StatementDescriptor., must be smaller than or equal to 20.'); + } + if (!is_null($phone_number) && (mb_strlen($phone_number) < 5)) { + throw new \InvalidArgumentException('invalid length for $phone_number when calling StatementDescriptor., must be bigger than or equal to 5.'); + } + if (!is_null($phone_number) && (!preg_match("/^\\+[1-9]\\d{1,14}$/", $phone_number))) { + throw new \InvalidArgumentException("invalid value for $phone_number when calling StatementDescriptor., must conform to the pattern /^\\+[1-9]\\d{1,14}$/."); + } + + $this->container['phone_number'] = $phone_number; + + return $this; + } + + /** + * Gets url + * + * @return string|null + */ + public function getUrl() + { + return $this->container['url']; + } + + /** + * Sets url + * + * @param string|null $url The value in the URL/web address field of a customer's statement. + * + * @return self + */ + public function setUrl($url) + { + if (!is_null($url) && (mb_strlen($url) > 13)) { + throw new \InvalidArgumentException('invalid length for $url when calling StatementDescriptor., must be smaller than or equal to 13.'); + } + if (!is_null($url) && (mb_strlen($url) < 1)) { + throw new \InvalidArgumentException('invalid length for $url when calling StatementDescriptor., must be bigger than or equal to 1.'); + } + + $this->container['url'] = $url; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/TaxId.php b/lib/model/TaxId.php new file mode 100644 index 0000000..82e33e0 --- /dev/null +++ b/lib/model/TaxId.php @@ -0,0 +1,489 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class TaxId implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'TaxId'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'value' => 'string', + 'kind' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'value' => null, + 'kind' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'value' => 'value', + 'kind' => 'kind' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'value' => 'setValue', + 'kind' => 'setKind' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'value' => 'getValue', + 'kind' => 'getKind' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const KIND_AE_TRN = 'ae.trn'; + public const KIND_AU_ABN = 'au.abn'; + public const KIND_AR_CUIT = 'ar.cuit'; + public const KIND_BR_CNPJ = 'br.cnpj'; + public const KIND_BR_CPF = 'br.cpf'; + public const KIND_CA_BN = 'ca.bn'; + public const KIND_CA_GST_HST = 'ca.gst_hst'; + public const KIND_CA_PST_BC = 'ca.pst_bc'; + public const KIND_CA_PST_MB = 'ca.pst_mb'; + public const KIND_CA_PST_SK = 'ca.pst_sk'; + public const KIND_CA_QST = 'ca.qst'; + public const KIND_CH_VAT = 'ch.vat'; + public const KIND_CL_TIN = 'cl.tin'; + public const KIND_ES_CIF = 'es.cif'; + public const KIND_EU_VAT = 'eu.vat'; + public const KIND_GB_VAT = 'gb.vat'; + public const KIND_HK_BR = 'hk.br'; + public const KIND_ID_NIK = 'id.nik'; + public const KIND_ID_NPWP = 'id.npwp'; + public const KIND_IN_GST = 'in.gst'; + public const KIND_JP_CN = 'jp.cn'; + public const KIND_JP_RN = 'jp.rn'; + public const KIND_KR_BRN = 'kr.brn'; + public const KIND_LI_UID = 'li.uid'; + public const KIND_MX_RFC = 'mx.rfc'; + public const KIND_MY_FRP = 'my.frp'; + public const KIND_MY_ITN = 'my.itn'; + public const KIND_MY_NRIC = 'my.nric'; + public const KIND_MY_SST = 'my.sst'; + public const KIND_NO_VAT = 'no.vat'; + public const KIND_NZ_GST = 'nz.gst'; + public const KIND_PH_TIN = 'ph.tin'; + public const KIND_RU_INN = 'ru.inn'; + public const KIND_RU_KPP = 'ru.kpp'; + public const KIND_SA_VAT = 'sa.vat'; + public const KIND_SG_GST = 'sg.gst'; + public const KIND_SG_UEN = 'sg.uen'; + public const KIND_TH_ID = 'th.id'; + public const KIND_TH_VAT = 'th.vat'; + public const KIND_TW_VAT = 'tw.vat'; + public const KIND_US_EIN = 'us.ein'; + public const KIND_ZA_VAT = 'za.vat'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getKindAllowableValues() + { + return [ + self::KIND_AE_TRN, + self::KIND_AU_ABN, + self::KIND_AR_CUIT, + self::KIND_BR_CNPJ, + self::KIND_BR_CPF, + self::KIND_CA_BN, + self::KIND_CA_GST_HST, + self::KIND_CA_PST_BC, + self::KIND_CA_PST_MB, + self::KIND_CA_PST_SK, + self::KIND_CA_QST, + self::KIND_CH_VAT, + self::KIND_CL_TIN, + self::KIND_ES_CIF, + self::KIND_EU_VAT, + self::KIND_GB_VAT, + self::KIND_HK_BR, + self::KIND_ID_NIK, + self::KIND_ID_NPWP, + self::KIND_IN_GST, + self::KIND_JP_CN, + self::KIND_JP_RN, + self::KIND_KR_BRN, + self::KIND_LI_UID, + self::KIND_MX_RFC, + self::KIND_MY_FRP, + self::KIND_MY_ITN, + self::KIND_MY_NRIC, + self::KIND_MY_SST, + self::KIND_NO_VAT, + self::KIND_NZ_GST, + self::KIND_PH_TIN, + self::KIND_RU_INN, + self::KIND_RU_KPP, + self::KIND_SA_VAT, + self::KIND_SG_GST, + self::KIND_SG_UEN, + self::KIND_TH_ID, + self::KIND_TH_VAT, + self::KIND_TW_VAT, + self::KIND_US_EIN, + self::KIND_ZA_VAT, + ]; + } + + /** + * 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['value'] = $data['value'] ?? null; + $this->container['kind'] = $data['kind'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['value'] === null) { + $invalidProperties[] = "'value' can't be null"; + } + if ((mb_strlen($this->container['value']) > 50)) { + $invalidProperties[] = "invalid value for 'value', the character length must be smaller than or equal to 50."; + } + + if ((mb_strlen($this->container['value']) < 1)) { + $invalidProperties[] = "invalid value for 'value', the character length must be bigger than or equal to 1."; + } + + if ($this->container['kind'] === null) { + $invalidProperties[] = "'kind' can't be null"; + } + $allowedValues = $this->getKindAllowableValues(); + if (!is_null($this->container['kind']) && !in_array($this->container['kind'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'kind', must be one of '%s'", + $this->container['kind'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets value + * + * @return string + */ + public function getValue() + { + return $this->container['value']; + } + + /** + * Sets value + * + * @param string $value The tax ID for the buyer. + * + * @return self + */ + public function setValue($value) + { + if ((mb_strlen($value) > 50)) { + throw new \InvalidArgumentException('invalid length for $value when calling TaxId., must be smaller than or equal to 50.'); + } + if ((mb_strlen($value) < 1)) { + throw new \InvalidArgumentException('invalid length for $value when calling TaxId., must be bigger than or equal to 1.'); + } + + $this->container['value'] = $value; + + return $this; + } + + /** + * Gets kind + * + * @return string + */ + public function getKind() + { + return $this->container['kind']; + } + + /** + * Sets kind + * + * @param string $kind The kind of tax ID. + * + * @return self + */ + public function setKind($kind) + { + $allowedValues = $this->getKindAllowableValues(); + if (!in_array($kind, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'kind', must be one of '%s'", + $kind, + implode("', '", $allowedValues) + ) + ); + } + $this->container['kind'] = $kind; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/ThreeDSecureData.php b/lib/model/ThreeDSecureData.php new file mode 100644 index 0000000..2565cf9 --- /dev/null +++ b/lib/model/ThreeDSecureData.php @@ -0,0 +1,464 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class ThreeDSecureData implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ThreeDSecureData'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'cavv' => 'string', + 'eci' => 'string', + 'version' => 'string', + 'directory_response' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'cavv' => null, + 'eci' => null, + 'version' => null, + 'directory_response' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'cavv' => 'cavv', + 'eci' => 'eci', + 'version' => 'version', + 'directory_response' => 'directory_response' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'cavv' => 'setCavv', + 'eci' => 'setEci', + 'version' => 'setVersion', + 'directory_response' => 'setDirectoryResponse' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'cavv' => 'getCavv', + 'eci' => 'getEci', + 'version' => 'getVersion', + 'directory_response' => 'getDirectoryResponse' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['cavv'] = $data['cavv'] ?? null; + $this->container['eci'] = $data['eci'] ?? null; + $this->container['version'] = $data['version'] ?? null; + $this->container['directory_response'] = $data['directory_response'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['cavv'] === null) { + $invalidProperties[] = "'cavv' can't be null"; + } + if ($this->container['eci'] === null) { + $invalidProperties[] = "'eci' can't be null"; + } + if ((mb_strlen($this->container['eci']) > 2)) { + $invalidProperties[] = "invalid value for 'eci', the character length must be smaller than or equal to 2."; + } + + if ((mb_strlen($this->container['eci']) < 1)) { + $invalidProperties[] = "invalid value for 'eci', the character length must be bigger than or equal to 1."; + } + + if (!preg_match("/^0?\\d$/", $this->container['eci'])) { + $invalidProperties[] = "invalid value for 'eci', must be conform to the pattern /^0?\\d$/."; + } + + if ($this->container['version'] === null) { + $invalidProperties[] = "'version' can't be null"; + } + if (!preg_match("/^[1-2].?[\\d+.?]{0,3}$/", $this->container['version'])) { + $invalidProperties[] = "invalid value for 'version', must be conform to the pattern /^[1-2].?[\\d+.?]{0,3}$/."; + } + + if ($this->container['directory_response'] === null) { + $invalidProperties[] = "'directory_response' can't be null"; + } + if ((mb_strlen($this->container['directory_response']) > 1)) { + $invalidProperties[] = "invalid value for 'directory_response', the character length must be smaller than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets cavv + * + * @return string + */ + public function getCavv() + { + return $this->container['cavv']; + } + + /** + * Sets cavv + * + * @param string $cavv The cardholder authentication value or AAV. + * + * @return self + */ + public function setCavv($cavv) + { + $this->container['cavv'] = $cavv; + + return $this; + } + + /** + * Gets eci + * + * @return string + */ + public function getEci() + { + return $this->container['eci']; + } + + /** + * Sets eci + * + * @param string $eci The electronic commerce indicator for the 3DS transaction. + * + * @return self + */ + public function setEci($eci) + { + if ((mb_strlen($eci) > 2)) { + throw new \InvalidArgumentException('invalid length for $eci when calling ThreeDSecureData., must be smaller than or equal to 2.'); + } + if ((mb_strlen($eci) < 1)) { + throw new \InvalidArgumentException('invalid length for $eci when calling ThreeDSecureData., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^0?\\d$/", $eci))) { + throw new \InvalidArgumentException("invalid value for $eci when calling ThreeDSecureData., must conform to the pattern /^0?\\d$/."); + } + + $this->container['eci'] = $eci; + + return $this; + } + + /** + * Gets version + * + * @return string + */ + public function getVersion() + { + return $this->container['version']; + } + + /** + * Sets version + * + * @param string $version The version of 3-D Secure that was used. + * + * @return self + */ + public function setVersion($version) + { + + if ((!preg_match("/^[1-2].?[\\d+.?]{0,3}$/", $version))) { + throw new \InvalidArgumentException("invalid value for $version when calling ThreeDSecureData., must conform to the pattern /^[1-2].?[\\d+.?]{0,3}$/."); + } + + $this->container['version'] = $version; + + return $this; + } + + /** + * Gets directory_response + * + * @return string + */ + public function getDirectoryResponse() + { + return $this->container['directory_response']; + } + + /** + * Sets directory_response + * + * @param string $directory_response For 3-D Secure version 1, the enrolment response. For 3-D Secure version , the transaction status from the `ARes`. + * + * @return self + */ + public function setDirectoryResponse($directory_response) + { + if ((mb_strlen($directory_response) > 1)) { + throw new \InvalidArgumentException('invalid length for $directory_response when calling ThreeDSecureData., must be smaller than or equal to 1.'); + } + + $this->container['directory_response'] = $directory_response; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/ThreeDSecureDataV1.php b/lib/model/ThreeDSecureDataV1.php new file mode 100644 index 0000000..c7315a6 --- /dev/null +++ b/lib/model/ThreeDSecureDataV1.php @@ -0,0 +1,579 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class ThreeDSecureDataV1 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ThreeDSecureDataV1'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'cavv' => 'string', + 'eci' => 'string', + 'version' => 'string', + 'directory_response' => 'string', + 'authentication_response' => 'string', + 'cavv_algorithm' => 'string', + 'xid' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'cavv' => null, + 'eci' => null, + 'version' => null, + 'directory_response' => null, + 'authentication_response' => null, + 'cavv_algorithm' => null, + 'xid' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'cavv' => 'cavv', + 'eci' => 'eci', + 'version' => 'version', + 'directory_response' => 'directory_response', + 'authentication_response' => 'authentication_response', + 'cavv_algorithm' => 'cavv_algorithm', + 'xid' => 'xid' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'cavv' => 'setCavv', + 'eci' => 'setEci', + 'version' => 'setVersion', + 'directory_response' => 'setDirectoryResponse', + 'authentication_response' => 'setAuthenticationResponse', + 'cavv_algorithm' => 'setCavvAlgorithm', + 'xid' => 'setXid' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'cavv' => 'getCavv', + 'eci' => 'getEci', + 'version' => 'getVersion', + 'directory_response' => 'getDirectoryResponse', + 'authentication_response' => 'getAuthenticationResponse', + 'cavv_algorithm' => 'getCavvAlgorithm', + 'xid' => 'getXid' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['cavv'] = $data['cavv'] ?? null; + $this->container['eci'] = $data['eci'] ?? null; + $this->container['version'] = $data['version'] ?? null; + $this->container['directory_response'] = $data['directory_response'] ?? null; + $this->container['authentication_response'] = $data['authentication_response'] ?? null; + $this->container['cavv_algorithm'] = $data['cavv_algorithm'] ?? null; + $this->container['xid'] = $data['xid'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['cavv'] === null) { + $invalidProperties[] = "'cavv' can't be null"; + } + if ($this->container['eci'] === null) { + $invalidProperties[] = "'eci' can't be null"; + } + if ((mb_strlen($this->container['eci']) > 2)) { + $invalidProperties[] = "invalid value for 'eci', the character length must be smaller than or equal to 2."; + } + + if ((mb_strlen($this->container['eci']) < 1)) { + $invalidProperties[] = "invalid value for 'eci', the character length must be bigger than or equal to 1."; + } + + if (!preg_match("/^0?\\d$/", $this->container['eci'])) { + $invalidProperties[] = "invalid value for 'eci', must be conform to the pattern /^0?\\d$/."; + } + + if ($this->container['version'] === null) { + $invalidProperties[] = "'version' can't be null"; + } + if (!preg_match("/^[1-2].?[\\d+.?]{0,3}$/", $this->container['version'])) { + $invalidProperties[] = "invalid value for 'version', must be conform to the pattern /^[1-2].?[\\d+.?]{0,3}$/."; + } + + if ($this->container['directory_response'] === null) { + $invalidProperties[] = "'directory_response' can't be null"; + } + if ((mb_strlen($this->container['directory_response']) > 1)) { + $invalidProperties[] = "invalid value for 'directory_response', the character length must be smaller than or equal to 1."; + } + + if ($this->container['authentication_response'] === null) { + $invalidProperties[] = "'authentication_response' can't be null"; + } + if ((mb_strlen($this->container['authentication_response']) > 1)) { + $invalidProperties[] = "invalid value for 'authentication_response', the character length must be smaller than or equal to 1."; + } + + if ($this->container['cavv_algorithm'] === null) { + $invalidProperties[] = "'cavv_algorithm' can't be null"; + } + if ((mb_strlen($this->container['cavv_algorithm']) > 1)) { + $invalidProperties[] = "invalid value for 'cavv_algorithm', the character length must be smaller than or equal to 1."; + } + + if ($this->container['xid'] === null) { + $invalidProperties[] = "'xid' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets cavv + * + * @return string + */ + public function getCavv() + { + return $this->container['cavv']; + } + + /** + * Sets cavv + * + * @param string $cavv The cardholder authentication value or AAV. + * + * @return self + */ + public function setCavv($cavv) + { + $this->container['cavv'] = $cavv; + + return $this; + } + + /** + * Gets eci + * + * @return string + */ + public function getEci() + { + return $this->container['eci']; + } + + /** + * Sets eci + * + * @param string $eci The electronic commerce indicator for the 3DS transaction. + * + * @return self + */ + public function setEci($eci) + { + if ((mb_strlen($eci) > 2)) { + throw new \InvalidArgumentException('invalid length for $eci when calling ThreeDSecureDataV1., must be smaller than or equal to 2.'); + } + if ((mb_strlen($eci) < 1)) { + throw new \InvalidArgumentException('invalid length for $eci when calling ThreeDSecureDataV1., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^0?\\d$/", $eci))) { + throw new \InvalidArgumentException("invalid value for $eci when calling ThreeDSecureDataV1., must conform to the pattern /^0?\\d$/."); + } + + $this->container['eci'] = $eci; + + return $this; + } + + /** + * Gets version + * + * @return string + */ + public function getVersion() + { + return $this->container['version']; + } + + /** + * Sets version + * + * @param string $version The version of 3-D Secure that was used. + * + * @return self + */ + public function setVersion($version) + { + + if ((!preg_match("/^[1-2].?[\\d+.?]{0,3}$/", $version))) { + throw new \InvalidArgumentException("invalid value for $version when calling ThreeDSecureDataV1., must conform to the pattern /^[1-2].?[\\d+.?]{0,3}$/."); + } + + $this->container['version'] = $version; + + return $this; + } + + /** + * Gets directory_response + * + * @return string + */ + public function getDirectoryResponse() + { + return $this->container['directory_response']; + } + + /** + * Sets directory_response + * + * @param string $directory_response For 3-D Secure version 1, the enrolment response. For 3-D Secure version , the transaction status from the `ARes`. + * + * @return self + */ + public function setDirectoryResponse($directory_response) + { + if ((mb_strlen($directory_response) > 1)) { + throw new \InvalidArgumentException('invalid length for $directory_response when calling ThreeDSecureDataV1., must be smaller than or equal to 1.'); + } + + $this->container['directory_response'] = $directory_response; + + return $this; + } + + /** + * Gets authentication_response + * + * @return string + */ + public function getAuthenticationResponse() + { + return $this->container['authentication_response']; + } + + /** + * Sets authentication_response + * + * @param string $authentication_response The authentication response. + * + * @return self + */ + public function setAuthenticationResponse($authentication_response) + { + if ((mb_strlen($authentication_response) > 1)) { + throw new \InvalidArgumentException('invalid length for $authentication_response when calling ThreeDSecureDataV1., must be smaller than or equal to 1.'); + } + + $this->container['authentication_response'] = $authentication_response; + + return $this; + } + + /** + * Gets cavv_algorithm + * + * @return string + */ + public function getCavvAlgorithm() + { + return $this->container['cavv_algorithm']; + } + + /** + * Sets cavv_algorithm + * + * @param string $cavv_algorithm The CAVV Algorithm used. + * + * @return self + */ + public function setCavvAlgorithm($cavv_algorithm) + { + if ((mb_strlen($cavv_algorithm) > 1)) { + throw new \InvalidArgumentException('invalid length for $cavv_algorithm when calling ThreeDSecureDataV1., must be smaller than or equal to 1.'); + } + + $this->container['cavv_algorithm'] = $cavv_algorithm; + + return $this; + } + + /** + * Gets xid + * + * @return string + */ + public function getXid() + { + return $this->container['xid']; + } + + /** + * Sets xid + * + * @param string $xid The transaction identifier. + * + * @return self + */ + public function setXid($xid) + { + $this->container['xid'] = $xid; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/ThreeDSecureDataV1AllOf.php b/lib/model/ThreeDSecureDataV1AllOf.php new file mode 100644 index 0000000..7d96124 --- /dev/null +++ b/lib/model/ThreeDSecureDataV1AllOf.php @@ -0,0 +1,408 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class ThreeDSecureDataV1AllOf implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ThreeDSecureDataV1_allOf'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'authentication_response' => 'string', + 'cavv_algorithm' => 'string', + 'xid' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'authentication_response' => null, + 'cavv_algorithm' => null, + 'xid' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'authentication_response' => 'authentication_response', + 'cavv_algorithm' => 'cavv_algorithm', + 'xid' => 'xid' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'authentication_response' => 'setAuthenticationResponse', + 'cavv_algorithm' => 'setCavvAlgorithm', + 'xid' => 'setXid' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'authentication_response' => 'getAuthenticationResponse', + 'cavv_algorithm' => 'getCavvAlgorithm', + 'xid' => 'getXid' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['authentication_response'] = $data['authentication_response'] ?? null; + $this->container['cavv_algorithm'] = $data['cavv_algorithm'] ?? null; + $this->container['xid'] = $data['xid'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['authentication_response'] === null) { + $invalidProperties[] = "'authentication_response' can't be null"; + } + if ((mb_strlen($this->container['authentication_response']) > 1)) { + $invalidProperties[] = "invalid value for 'authentication_response', the character length must be smaller than or equal to 1."; + } + + if ($this->container['cavv_algorithm'] === null) { + $invalidProperties[] = "'cavv_algorithm' can't be null"; + } + if ((mb_strlen($this->container['cavv_algorithm']) > 1)) { + $invalidProperties[] = "invalid value for 'cavv_algorithm', the character length must be smaller than or equal to 1."; + } + + if ($this->container['xid'] === null) { + $invalidProperties[] = "'xid' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets authentication_response + * + * @return string + */ + public function getAuthenticationResponse() + { + return $this->container['authentication_response']; + } + + /** + * Sets authentication_response + * + * @param string $authentication_response The authentication response. + * + * @return self + */ + public function setAuthenticationResponse($authentication_response) + { + if ((mb_strlen($authentication_response) > 1)) { + throw new \InvalidArgumentException('invalid length for $authentication_response when calling ThreeDSecureDataV1AllOf., must be smaller than or equal to 1.'); + } + + $this->container['authentication_response'] = $authentication_response; + + return $this; + } + + /** + * Gets cavv_algorithm + * + * @return string + */ + public function getCavvAlgorithm() + { + return $this->container['cavv_algorithm']; + } + + /** + * Sets cavv_algorithm + * + * @param string $cavv_algorithm The CAVV Algorithm used. + * + * @return self + */ + public function setCavvAlgorithm($cavv_algorithm) + { + if ((mb_strlen($cavv_algorithm) > 1)) { + throw new \InvalidArgumentException('invalid length for $cavv_algorithm when calling ThreeDSecureDataV1AllOf., must be smaller than or equal to 1.'); + } + + $this->container['cavv_algorithm'] = $cavv_algorithm; + + return $this; + } + + /** + * Gets xid + * + * @return string + */ + public function getXid() + { + return $this->container['xid']; + } + + /** + * Sets xid + * + * @param string $xid The transaction identifier. + * + * @return self + */ + public function setXid($xid) + { + $this->container['xid'] = $xid; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/ThreeDSecureDataV1V2.php b/lib/model/ThreeDSecureDataV1V2.php new file mode 100644 index 0000000..7cae61f --- /dev/null +++ b/lib/model/ThreeDSecureDataV1V2.php @@ -0,0 +1,612 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class ThreeDSecureDataV1V2 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ThreeDSecureDataV1V2'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'cavv' => 'string', + 'eci' => 'string', + 'version' => 'string', + 'directory_response' => 'string', + 'authentication_response' => 'string', + 'cavv_algorithm' => 'string', + 'xid' => 'string', + 'directory_transaction_id' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'cavv' => null, + 'eci' => null, + 'version' => null, + 'directory_response' => null, + 'authentication_response' => null, + 'cavv_algorithm' => null, + 'xid' => null, + 'directory_transaction_id' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'cavv' => 'cavv', + 'eci' => 'eci', + 'version' => 'version', + 'directory_response' => 'directory_response', + 'authentication_response' => 'authentication_response', + 'cavv_algorithm' => 'cavv_algorithm', + 'xid' => 'xid', + 'directory_transaction_id' => 'directory_transaction_id' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'cavv' => 'setCavv', + 'eci' => 'setEci', + 'version' => 'setVersion', + 'directory_response' => 'setDirectoryResponse', + 'authentication_response' => 'setAuthenticationResponse', + 'cavv_algorithm' => 'setCavvAlgorithm', + 'xid' => 'setXid', + 'directory_transaction_id' => 'setDirectoryTransactionId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'cavv' => 'getCavv', + 'eci' => 'getEci', + 'version' => 'getVersion', + 'directory_response' => 'getDirectoryResponse', + 'authentication_response' => 'getAuthenticationResponse', + 'cavv_algorithm' => 'getCavvAlgorithm', + 'xid' => 'getXid', + 'directory_transaction_id' => 'getDirectoryTransactionId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['cavv'] = $data['cavv'] ?? null; + $this->container['eci'] = $data['eci'] ?? null; + $this->container['version'] = $data['version'] ?? null; + $this->container['directory_response'] = $data['directory_response'] ?? null; + $this->container['authentication_response'] = $data['authentication_response'] ?? null; + $this->container['cavv_algorithm'] = $data['cavv_algorithm'] ?? null; + $this->container['xid'] = $data['xid'] ?? null; + $this->container['directory_transaction_id'] = $data['directory_transaction_id'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['cavv'] === null) { + $invalidProperties[] = "'cavv' can't be null"; + } + if ($this->container['eci'] === null) { + $invalidProperties[] = "'eci' can't be null"; + } + if ((mb_strlen($this->container['eci']) > 2)) { + $invalidProperties[] = "invalid value for 'eci', the character length must be smaller than or equal to 2."; + } + + if ((mb_strlen($this->container['eci']) < 1)) { + $invalidProperties[] = "invalid value for 'eci', the character length must be bigger than or equal to 1."; + } + + if (!preg_match("/^0?\\d$/", $this->container['eci'])) { + $invalidProperties[] = "invalid value for 'eci', must be conform to the pattern /^0?\\d$/."; + } + + if ($this->container['version'] === null) { + $invalidProperties[] = "'version' can't be null"; + } + if (!preg_match("/^[1-2].?[\\d+.?]{0,3}$/", $this->container['version'])) { + $invalidProperties[] = "invalid value for 'version', must be conform to the pattern /^[1-2].?[\\d+.?]{0,3}$/."; + } + + if ($this->container['directory_response'] === null) { + $invalidProperties[] = "'directory_response' can't be null"; + } + if ((mb_strlen($this->container['directory_response']) > 1)) { + $invalidProperties[] = "invalid value for 'directory_response', the character length must be smaller than or equal to 1."; + } + + if ($this->container['authentication_response'] === null) { + $invalidProperties[] = "'authentication_response' can't be null"; + } + if ((mb_strlen($this->container['authentication_response']) > 1)) { + $invalidProperties[] = "invalid value for 'authentication_response', the character length must be smaller than or equal to 1."; + } + + if ($this->container['cavv_algorithm'] === null) { + $invalidProperties[] = "'cavv_algorithm' can't be null"; + } + if ((mb_strlen($this->container['cavv_algorithm']) > 1)) { + $invalidProperties[] = "invalid value for 'cavv_algorithm', the character length must be smaller than or equal to 1."; + } + + if ($this->container['xid'] === null) { + $invalidProperties[] = "'xid' can't be null"; + } + if ($this->container['directory_transaction_id'] === null) { + $invalidProperties[] = "'directory_transaction_id' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets cavv + * + * @return string + */ + public function getCavv() + { + return $this->container['cavv']; + } + + /** + * Sets cavv + * + * @param string $cavv The cardholder authentication value or AAV. + * + * @return self + */ + public function setCavv($cavv) + { + $this->container['cavv'] = $cavv; + + return $this; + } + + /** + * Gets eci + * + * @return string + */ + public function getEci() + { + return $this->container['eci']; + } + + /** + * Sets eci + * + * @param string $eci The electronic commerce indicator for the 3DS transaction. + * + * @return self + */ + public function setEci($eci) + { + if ((mb_strlen($eci) > 2)) { + throw new \InvalidArgumentException('invalid length for $eci when calling ThreeDSecureDataV1V2., must be smaller than or equal to 2.'); + } + if ((mb_strlen($eci) < 1)) { + throw new \InvalidArgumentException('invalid length for $eci when calling ThreeDSecureDataV1V2., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^0?\\d$/", $eci))) { + throw new \InvalidArgumentException("invalid value for $eci when calling ThreeDSecureDataV1V2., must conform to the pattern /^0?\\d$/."); + } + + $this->container['eci'] = $eci; + + return $this; + } + + /** + * Gets version + * + * @return string + */ + public function getVersion() + { + return $this->container['version']; + } + + /** + * Sets version + * + * @param string $version The version of 3-D Secure that was used. + * + * @return self + */ + public function setVersion($version) + { + + if ((!preg_match("/^[1-2].?[\\d+.?]{0,3}$/", $version))) { + throw new \InvalidArgumentException("invalid value for $version when calling ThreeDSecureDataV1V2., must conform to the pattern /^[1-2].?[\\d+.?]{0,3}$/."); + } + + $this->container['version'] = $version; + + return $this; + } + + /** + * Gets directory_response + * + * @return string + */ + public function getDirectoryResponse() + { + return $this->container['directory_response']; + } + + /** + * Sets directory_response + * + * @param string $directory_response For 3-D Secure version 1, the enrolment response. For 3-D Secure version , the transaction status from the `ARes`. + * + * @return self + */ + public function setDirectoryResponse($directory_response) + { + if ((mb_strlen($directory_response) > 1)) { + throw new \InvalidArgumentException('invalid length for $directory_response when calling ThreeDSecureDataV1V2., must be smaller than or equal to 1.'); + } + + $this->container['directory_response'] = $directory_response; + + return $this; + } + + /** + * Gets authentication_response + * + * @return string + */ + public function getAuthenticationResponse() + { + return $this->container['authentication_response']; + } + + /** + * Sets authentication_response + * + * @param string $authentication_response The transaction status from the challenge result (not required for frictionless). + * + * @return self + */ + public function setAuthenticationResponse($authentication_response) + { + if ((mb_strlen($authentication_response) > 1)) { + throw new \InvalidArgumentException('invalid length for $authentication_response when calling ThreeDSecureDataV1V2., must be smaller than or equal to 1.'); + } + + $this->container['authentication_response'] = $authentication_response; + + return $this; + } + + /** + * Gets cavv_algorithm + * + * @return string + */ + public function getCavvAlgorithm() + { + return $this->container['cavv_algorithm']; + } + + /** + * Sets cavv_algorithm + * + * @param string $cavv_algorithm The CAVV Algorithm used. + * + * @return self + */ + public function setCavvAlgorithm($cavv_algorithm) + { + if ((mb_strlen($cavv_algorithm) > 1)) { + throw new \InvalidArgumentException('invalid length for $cavv_algorithm when calling ThreeDSecureDataV1V2., must be smaller than or equal to 1.'); + } + + $this->container['cavv_algorithm'] = $cavv_algorithm; + + return $this; + } + + /** + * Gets xid + * + * @return string + */ + public function getXid() + { + return $this->container['xid']; + } + + /** + * Sets xid + * + * @param string $xid The transaction identifier. + * + * @return self + */ + public function setXid($xid) + { + $this->container['xid'] = $xid; + + return $this; + } + + /** + * Gets directory_transaction_id + * + * @return string + */ + public function getDirectoryTransactionId() + { + return $this->container['directory_transaction_id']; + } + + /** + * Sets directory_transaction_id + * + * @param string $directory_transaction_id The transaction identifier. + * + * @return self + */ + public function setDirectoryTransactionId($directory_transaction_id) + { + $this->container['directory_transaction_id'] = $directory_transaction_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/ThreeDSecureDataV2.php b/lib/model/ThreeDSecureDataV2.php new file mode 100644 index 0000000..b9966dd --- /dev/null +++ b/lib/model/ThreeDSecureDataV2.php @@ -0,0 +1,535 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class ThreeDSecureDataV2 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ThreeDSecureDataV2'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'cavv' => 'string', + 'eci' => 'string', + 'version' => 'string', + 'directory_response' => 'string', + 'authentication_response' => 'string', + 'directory_transaction_id' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'cavv' => null, + 'eci' => null, + 'version' => null, + 'directory_response' => null, + 'authentication_response' => null, + 'directory_transaction_id' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'cavv' => 'cavv', + 'eci' => 'eci', + 'version' => 'version', + 'directory_response' => 'directory_response', + 'authentication_response' => 'authentication_response', + 'directory_transaction_id' => 'directory_transaction_id' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'cavv' => 'setCavv', + 'eci' => 'setEci', + 'version' => 'setVersion', + 'directory_response' => 'setDirectoryResponse', + 'authentication_response' => 'setAuthenticationResponse', + 'directory_transaction_id' => 'setDirectoryTransactionId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'cavv' => 'getCavv', + 'eci' => 'getEci', + 'version' => 'getVersion', + 'directory_response' => 'getDirectoryResponse', + 'authentication_response' => 'getAuthenticationResponse', + 'directory_transaction_id' => 'getDirectoryTransactionId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['cavv'] = $data['cavv'] ?? null; + $this->container['eci'] = $data['eci'] ?? null; + $this->container['version'] = $data['version'] ?? null; + $this->container['directory_response'] = $data['directory_response'] ?? null; + $this->container['authentication_response'] = $data['authentication_response'] ?? null; + $this->container['directory_transaction_id'] = $data['directory_transaction_id'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['cavv'] === null) { + $invalidProperties[] = "'cavv' can't be null"; + } + if ($this->container['eci'] === null) { + $invalidProperties[] = "'eci' can't be null"; + } + if ((mb_strlen($this->container['eci']) > 2)) { + $invalidProperties[] = "invalid value for 'eci', the character length must be smaller than or equal to 2."; + } + + if ((mb_strlen($this->container['eci']) < 1)) { + $invalidProperties[] = "invalid value for 'eci', the character length must be bigger than or equal to 1."; + } + + if (!preg_match("/^0?\\d$/", $this->container['eci'])) { + $invalidProperties[] = "invalid value for 'eci', must be conform to the pattern /^0?\\d$/."; + } + + if ($this->container['version'] === null) { + $invalidProperties[] = "'version' can't be null"; + } + if (!preg_match("/^[1-2].?[\\d+.?]{0,3}$/", $this->container['version'])) { + $invalidProperties[] = "invalid value for 'version', must be conform to the pattern /^[1-2].?[\\d+.?]{0,3}$/."; + } + + if ($this->container['directory_response'] === null) { + $invalidProperties[] = "'directory_response' can't be null"; + } + if ((mb_strlen($this->container['directory_response']) > 1)) { + $invalidProperties[] = "invalid value for 'directory_response', the character length must be smaller than or equal to 1."; + } + + if (!is_null($this->container['authentication_response']) && (mb_strlen($this->container['authentication_response']) > 1)) { + $invalidProperties[] = "invalid value for 'authentication_response', the character length must be smaller than or equal to 1."; + } + + if ($this->container['directory_transaction_id'] === null) { + $invalidProperties[] = "'directory_transaction_id' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets cavv + * + * @return string + */ + public function getCavv() + { + return $this->container['cavv']; + } + + /** + * Sets cavv + * + * @param string $cavv The cardholder authentication value or AAV. + * + * @return self + */ + public function setCavv($cavv) + { + $this->container['cavv'] = $cavv; + + return $this; + } + + /** + * Gets eci + * + * @return string + */ + public function getEci() + { + return $this->container['eci']; + } + + /** + * Sets eci + * + * @param string $eci The electronic commerce indicator for the 3DS transaction. + * + * @return self + */ + public function setEci($eci) + { + if ((mb_strlen($eci) > 2)) { + throw new \InvalidArgumentException('invalid length for $eci when calling ThreeDSecureDataV2., must be smaller than or equal to 2.'); + } + if ((mb_strlen($eci) < 1)) { + throw new \InvalidArgumentException('invalid length for $eci when calling ThreeDSecureDataV2., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^0?\\d$/", $eci))) { + throw new \InvalidArgumentException("invalid value for $eci when calling ThreeDSecureDataV2., must conform to the pattern /^0?\\d$/."); + } + + $this->container['eci'] = $eci; + + return $this; + } + + /** + * Gets version + * + * @return string + */ + public function getVersion() + { + return $this->container['version']; + } + + /** + * Sets version + * + * @param string $version The version of 3-D Secure that was used. + * + * @return self + */ + public function setVersion($version) + { + + if ((!preg_match("/^[1-2].?[\\d+.?]{0,3}$/", $version))) { + throw new \InvalidArgumentException("invalid value for $version when calling ThreeDSecureDataV2., must conform to the pattern /^[1-2].?[\\d+.?]{0,3}$/."); + } + + $this->container['version'] = $version; + + return $this; + } + + /** + * Gets directory_response + * + * @return string + */ + public function getDirectoryResponse() + { + return $this->container['directory_response']; + } + + /** + * Sets directory_response + * + * @param string $directory_response For 3-D Secure version 1, the enrolment response. For 3-D Secure version , the transaction status from the `ARes`. + * + * @return self + */ + public function setDirectoryResponse($directory_response) + { + if ((mb_strlen($directory_response) > 1)) { + throw new \InvalidArgumentException('invalid length for $directory_response when calling ThreeDSecureDataV2., must be smaller than or equal to 1.'); + } + + $this->container['directory_response'] = $directory_response; + + return $this; + } + + /** + * Gets authentication_response + * + * @return string|null + */ + public function getAuthenticationResponse() + { + return $this->container['authentication_response']; + } + + /** + * Sets authentication_response + * + * @param string|null $authentication_response The transaction status from the challenge result (not required for frictionless). + * + * @return self + */ + public function setAuthenticationResponse($authentication_response) + { + if (!is_null($authentication_response) && (mb_strlen($authentication_response) > 1)) { + throw new \InvalidArgumentException('invalid length for $authentication_response when calling ThreeDSecureDataV2., must be smaller than or equal to 1.'); + } + + $this->container['authentication_response'] = $authentication_response; + + return $this; + } + + /** + * Gets directory_transaction_id + * + * @return string + */ + public function getDirectoryTransactionId() + { + return $this->container['directory_transaction_id']; + } + + /** + * Sets directory_transaction_id + * + * @param string $directory_transaction_id The transaction identifier. + * + * @return self + */ + public function setDirectoryTransactionId($directory_transaction_id) + { + $this->container['directory_transaction_id'] = $directory_transaction_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/ThreeDSecureDataV2AllOf.php b/lib/model/ThreeDSecureDataV2AllOf.php new file mode 100644 index 0000000..6bc87aa --- /dev/null +++ b/lib/model/ThreeDSecureDataV2AllOf.php @@ -0,0 +1,364 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class ThreeDSecureDataV2AllOf implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ThreeDSecureDataV2_allOf'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'authentication_response' => 'string', + 'directory_transaction_id' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'authentication_response' => null, + 'directory_transaction_id' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'authentication_response' => 'authentication_response', + 'directory_transaction_id' => 'directory_transaction_id' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'authentication_response' => 'setAuthenticationResponse', + 'directory_transaction_id' => 'setDirectoryTransactionId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'authentication_response' => 'getAuthenticationResponse', + 'directory_transaction_id' => 'getDirectoryTransactionId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['authentication_response'] = $data['authentication_response'] ?? null; + $this->container['directory_transaction_id'] = $data['directory_transaction_id'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['authentication_response']) && (mb_strlen($this->container['authentication_response']) > 1)) { + $invalidProperties[] = "invalid value for 'authentication_response', the character length must be smaller than or equal to 1."; + } + + if ($this->container['directory_transaction_id'] === null) { + $invalidProperties[] = "'directory_transaction_id' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets authentication_response + * + * @return string|null + */ + public function getAuthenticationResponse() + { + return $this->container['authentication_response']; + } + + /** + * Sets authentication_response + * + * @param string|null $authentication_response The transaction status from the challenge result (not required for frictionless). + * + * @return self + */ + public function setAuthenticationResponse($authentication_response) + { + if (!is_null($authentication_response) && (mb_strlen($authentication_response) > 1)) { + throw new \InvalidArgumentException('invalid length for $authentication_response when calling ThreeDSecureDataV2AllOf., must be smaller than or equal to 1.'); + } + + $this->container['authentication_response'] = $authentication_response; + + return $this; + } + + /** + * Gets directory_transaction_id + * + * @return string + */ + public function getDirectoryTransactionId() + { + return $this->container['directory_transaction_id']; + } + + /** + * Sets directory_transaction_id + * + * @param string $directory_transaction_id The transaction identifier. + * + * @return self + */ + public function setDirectoryTransactionId($directory_transaction_id) + { + $this->container['directory_transaction_id'] = $directory_transaction_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/ThreeDSecureSummary.php b/lib/model/ThreeDSecureSummary.php new file mode 100644 index 0000000..0002820 --- /dev/null +++ b/lib/model/ThreeDSecureSummary.php @@ -0,0 +1,497 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class ThreeDSecureSummary implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ThreeDSecureSummary'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'version' => 'string', + 'status' => 'string', + 'method' => 'string', + 'response_data' => '\Gr4vy\model\ThreeDSecureDataV1V2' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'version' => null, + 'status' => null, + 'method' => null, + 'response_data' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'version' => 'version', + 'status' => 'status', + 'method' => 'method', + 'response_data' => 'response_data' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'version' => 'setVersion', + 'status' => 'setStatus', + 'method' => 'setMethod', + 'response_data' => 'setResponseData' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'version' => 'getVersion', + 'status' => 'getStatus', + 'method' => 'getMethod', + 'response_data' => 'getResponseData' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const STATUS_SETUP_ERROR = 'setup_error'; + public const STATUS_ERROR = 'error'; + public const STATUS_DECLINED = 'declined'; + public const STATUS_CANCELLED = 'cancelled'; + public const STATUS_COMPLETE = 'complete'; + public const METHOD_CHALLENGE = 'challenge'; + public const METHOD_FRICTIONLESS = 'frictionless'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStatusAllowableValues() + { + return [ + self::STATUS_SETUP_ERROR, + self::STATUS_ERROR, + self::STATUS_DECLINED, + self::STATUS_CANCELLED, + self::STATUS_COMPLETE, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getMethodAllowableValues() + { + return [ + self::METHOD_CHALLENGE, + self::METHOD_FRICTIONLESS, + ]; + } + + /** + * 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['version'] = $data['version'] ?? null; + $this->container['status'] = $data['status'] ?? null; + $this->container['method'] = $data['method'] ?? null; + $this->container['response_data'] = $data['response_data'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['version']) && !preg_match("/^[1-2].?[\\d+.?]{0,3}$/", $this->container['version'])) { + $invalidProperties[] = "invalid value for 'version', must be conform to the pattern /^[1-2].?[\\d+.?]{0,3}$/."; + } + + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($this->container['status']) && !in_array($this->container['status'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'status', must be one of '%s'", + $this->container['status'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getMethodAllowableValues(); + if (!is_null($this->container['method']) && !in_array($this->container['method'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'method', must be one of '%s'", + $this->container['method'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets version + * + * @return string|null + */ + public function getVersion() + { + return $this->container['version']; + } + + /** + * Sets version + * + * @param string|null $version The version of 3DS used for this transaction. + * + * @return self + */ + public function setVersion($version) + { + + if (!is_null($version) && (!preg_match("/^[1-2].?[\\d+.?]{0,3}$/", $version))) { + throw new \InvalidArgumentException("invalid value for $version when calling ThreeDSecureSummary., must conform to the pattern /^[1-2].?[\\d+.?]{0,3}$/."); + } + + $this->container['version'] = $version; + + return $this; + } + + /** + * Gets status + * + * @return string|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param string|null $status The status of the 3DS challenge for this transaction. + * + * @return self + */ + public function setStatus($status) + { + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($status) && !in_array($status, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'status', must be one of '%s'", + $status, + implode("', '", $allowedValues) + ) + ); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets method + * + * @return string|null + */ + public function getMethod() + { + return $this->container['method']; + } + + /** + * Sets method + * + * @param string|null $method The method used for 3DS authentication for this transaction. + * + * @return self + */ + public function setMethod($method) + { + $allowedValues = $this->getMethodAllowableValues(); + if (!is_null($method) && !in_array($method, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'method', must be one of '%s'", + $method, + implode("', '", $allowedValues) + ) + ); + } + $this->container['method'] = $method; + + return $this; + } + + /** + * Gets response_data + * + * @return \Gr4vy\model\ThreeDSecureDataV1V2|null + */ + public function getResponseData() + { + return $this->container['response_data']; + } + + /** + * Sets response_data + * + * @param \Gr4vy\model\ThreeDSecureDataV1V2|null $response_data response_data + * + * @return self + */ + public function setResponseData($response_data) + { + $this->container['response_data'] = $response_data; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/TokenizedRequest.php b/lib/model/TokenizedRequest.php new file mode 100644 index 0000000..e136ee4 --- /dev/null +++ b/lib/model/TokenizedRequest.php @@ -0,0 +1,474 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class TokenizedRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'TokenizedRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'method' => 'string', + 'id' => 'string', + 'redirect_url' => 'string', + 'security_code' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'method' => null, + 'id' => null, + 'redirect_url' => null, + 'security_code' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'method' => 'method', + 'id' => 'id', + 'redirect_url' => 'redirect_url', + 'security_code' => 'security_code' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'method' => 'setMethod', + 'id' => 'setId', + 'redirect_url' => 'setRedirectUrl', + 'security_code' => 'setSecurityCode' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'method' => 'getMethod', + 'id' => 'getId', + 'redirect_url' => 'getRedirectUrl', + 'security_code' => 'getSecurityCode' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const METHOD_ID = 'id'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getMethodAllowableValues() + { + return [ + self::METHOD_ID, + ]; + } + + /** + * 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['method'] = $data['method'] ?? null; + $this->container['id'] = $data['id'] ?? null; + $this->container['redirect_url'] = $data['redirect_url'] ?? null; + $this->container['security_code'] = $data['security_code'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['method'] === null) { + $invalidProperties[] = "'method' can't be null"; + } + $allowedValues = $this->getMethodAllowableValues(); + if (!is_null($this->container['method']) && !in_array($this->container['method'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'method', must be one of '%s'", + $this->container['method'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['id'] === null) { + $invalidProperties[] = "'id' can't be null"; + } + if (!is_null($this->container['security_code']) && (mb_strlen($this->container['security_code']) > 4)) { + $invalidProperties[] = "invalid value for 'security_code', the character length must be smaller than or equal to 4."; + } + + if (!is_null($this->container['security_code']) && (mb_strlen($this->container['security_code']) < 3)) { + $invalidProperties[] = "invalid value for 'security_code', the character length must be bigger than or equal to 3."; + } + + if (!is_null($this->container['security_code']) && !preg_match("/^\\d{3,4}$/", $this->container['security_code'])) { + $invalidProperties[] = "invalid value for 'security_code', must be conform to the pattern /^\\d{3,4}$/."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets method + * + * @return string + */ + public function getMethod() + { + return $this->container['method']; + } + + /** + * Sets method + * + * @param string $method `id`. + * + * @return self + */ + public function setMethod($method) + { + $allowedValues = $this->getMethodAllowableValues(); + if (!in_array($method, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'method', must be one of '%s'", + $method, + implode("', '", $allowedValues) + ) + ); + } + $this->container['method'] = $method; + + return $this; + } + + /** + * Gets id + * + * @return string + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string $id A ID that represents a previously tokenized payment method. This token can represent any type of payment method. + * + * @return self + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets redirect_url + * + * @return string|null + */ + public function getRedirectUrl() + { + return $this->container['redirect_url']; + } + + /** + * Sets redirect_url + * + * @param string|null $redirect_url We strongly recommended providing a `redirect_url` for stored cards when 3-D Secure is enabled and `three_d_secure_data` is not provided. This will be appended with both a transaction ID and status (e.g. `https://example.com/callback? gr4vy_transaction_id=123&gr4vy_transaction_status=capture_succeeded`) after 3-D Secure has completed. + * + * @return self + */ + public function setRedirectUrl($redirect_url) + { + $this->container['redirect_url'] = $redirect_url; + + return $this; + } + + /** + * Gets security_code + * + * @return string|null + */ + public function getSecurityCode() + { + return $this->container['security_code']; + } + + /** + * Sets security_code + * + * @param string|null $security_code The 3 or 4 digit security code often found on the card. This often referred to as the CVV or CVD. The security code can only be set if the stored payment method represents a card. + * + * @return self + */ + public function setSecurityCode($security_code) + { + if (!is_null($security_code) && (mb_strlen($security_code) > 4)) { + throw new \InvalidArgumentException('invalid length for $security_code when calling TokenizedRequest., must be smaller than or equal to 4.'); + } + if (!is_null($security_code) && (mb_strlen($security_code) < 3)) { + throw new \InvalidArgumentException('invalid length for $security_code when calling TokenizedRequest., must be bigger than or equal to 3.'); + } + if (!is_null($security_code) && (!preg_match("/^\\d{3,4}$/", $security_code))) { + throw new \InvalidArgumentException("invalid value for $security_code when calling TokenizedRequest., must conform to the pattern /^\\d{3,4}$/."); + } + + $this->container['security_code'] = $security_code; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/Transaction.php b/lib/model/Transaction.php new file mode 100644 index 0000000..8109c06 --- /dev/null +++ b/lib/model/Transaction.php @@ -0,0 +1,1616 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class Transaction implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'Transaction'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'id' => 'string', + 'status' => 'string', + 'intent' => 'string', + 'amount' => 'int', + 'captured_amount' => 'int', + 'refunded_amount' => 'int', + 'currency' => 'string', + 'country' => 'string', + 'payment_method' => '\Gr4vy\model\TransactionPaymentMethod', + 'buyer' => '\Gr4vy\model\TransactionBuyer', + 'created_at' => '\DateTime', + 'external_identifier' => 'string', + 'updated_at' => '\DateTime', + 'payment_service' => '\Gr4vy\model\PaymentMethodTokenPaymentService', + 'merchant_initiated' => 'bool', + 'payment_source' => 'string', + 'is_subsequent_payment' => 'bool', + 'statement_descriptor' => '\Gr4vy\model\TransactionStatementDescriptor', + 'cart_items' => '\Gr4vy\model\CartItem[]', + 'scheme_transaction_id' => 'string', + 'raw_response_code' => 'string', + 'raw_response_description' => 'string', + 'avs_response_code' => 'string', + 'cvv_response_code' => 'string', + 'method' => 'string', + 'payment_service_transaction_id' => 'string', + 'metadata' => 'array', + 'three_d_secure' => '\Gr4vy\model\ThreeDSecureSummary', + 'authorized_at' => '\DateTime', + 'captured_at' => '\DateTime', + 'voided_at' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'id' => 'uuid', + 'status' => null, + 'intent' => null, + 'amount' => null, + 'captured_amount' => null, + 'refunded_amount' => null, + 'currency' => null, + 'country' => null, + 'payment_method' => null, + 'buyer' => null, + 'created_at' => 'date-time', + 'external_identifier' => null, + 'updated_at' => 'date-time', + 'payment_service' => null, + 'merchant_initiated' => null, + 'payment_source' => null, + 'is_subsequent_payment' => null, + 'statement_descriptor' => null, + 'cart_items' => null, + 'scheme_transaction_id' => null, + 'raw_response_code' => null, + 'raw_response_description' => null, + 'avs_response_code' => null, + 'cvv_response_code' => null, + 'method' => null, + 'payment_service_transaction_id' => null, + 'metadata' => null, + 'three_d_secure' => null, + 'authorized_at' => 'date-time', + 'captured_at' => 'date-time', + 'voided_at' => 'date-time' + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'id' => 'id', + 'status' => 'status', + 'intent' => 'intent', + 'amount' => 'amount', + 'captured_amount' => 'captured_amount', + 'refunded_amount' => 'refunded_amount', + 'currency' => 'currency', + 'country' => 'country', + 'payment_method' => 'payment_method', + 'buyer' => 'buyer', + 'created_at' => 'created_at', + 'external_identifier' => 'external_identifier', + 'updated_at' => 'updated_at', + 'payment_service' => 'payment_service', + 'merchant_initiated' => 'merchant_initiated', + 'payment_source' => 'payment_source', + 'is_subsequent_payment' => 'is_subsequent_payment', + 'statement_descriptor' => 'statement_descriptor', + 'cart_items' => 'cart_items', + 'scheme_transaction_id' => 'scheme_transaction_id', + 'raw_response_code' => 'raw_response_code', + 'raw_response_description' => 'raw_response_description', + 'avs_response_code' => 'avs_response_code', + 'cvv_response_code' => 'cvv_response_code', + 'method' => 'method', + 'payment_service_transaction_id' => 'payment_service_transaction_id', + 'metadata' => 'metadata', + 'three_d_secure' => 'three_d_secure', + 'authorized_at' => 'authorized_at', + 'captured_at' => 'captured_at', + 'voided_at' => 'voided_at' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'id' => 'setId', + 'status' => 'setStatus', + 'intent' => 'setIntent', + 'amount' => 'setAmount', + 'captured_amount' => 'setCapturedAmount', + 'refunded_amount' => 'setRefundedAmount', + 'currency' => 'setCurrency', + 'country' => 'setCountry', + 'payment_method' => 'setPaymentMethod', + 'buyer' => 'setBuyer', + 'created_at' => 'setCreatedAt', + 'external_identifier' => 'setExternalIdentifier', + 'updated_at' => 'setUpdatedAt', + 'payment_service' => 'setPaymentService', + 'merchant_initiated' => 'setMerchantInitiated', + 'payment_source' => 'setPaymentSource', + 'is_subsequent_payment' => 'setIsSubsequentPayment', + 'statement_descriptor' => 'setStatementDescriptor', + 'cart_items' => 'setCartItems', + 'scheme_transaction_id' => 'setSchemeTransactionId', + 'raw_response_code' => 'setRawResponseCode', + 'raw_response_description' => 'setRawResponseDescription', + 'avs_response_code' => 'setAvsResponseCode', + 'cvv_response_code' => 'setCvvResponseCode', + 'method' => 'setMethod', + 'payment_service_transaction_id' => 'setPaymentServiceTransactionId', + 'metadata' => 'setMetadata', + 'three_d_secure' => 'setThreeDSecure', + 'authorized_at' => 'setAuthorizedAt', + 'captured_at' => 'setCapturedAt', + 'voided_at' => 'setVoidedAt' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'id' => 'getId', + 'status' => 'getStatus', + 'intent' => 'getIntent', + 'amount' => 'getAmount', + 'captured_amount' => 'getCapturedAmount', + 'refunded_amount' => 'getRefundedAmount', + 'currency' => 'getCurrency', + 'country' => 'getCountry', + 'payment_method' => 'getPaymentMethod', + 'buyer' => 'getBuyer', + 'created_at' => 'getCreatedAt', + 'external_identifier' => 'getExternalIdentifier', + 'updated_at' => 'getUpdatedAt', + 'payment_service' => 'getPaymentService', + 'merchant_initiated' => 'getMerchantInitiated', + 'payment_source' => 'getPaymentSource', + 'is_subsequent_payment' => 'getIsSubsequentPayment', + 'statement_descriptor' => 'getStatementDescriptor', + 'cart_items' => 'getCartItems', + 'scheme_transaction_id' => 'getSchemeTransactionId', + 'raw_response_code' => 'getRawResponseCode', + 'raw_response_description' => 'getRawResponseDescription', + 'avs_response_code' => 'getAvsResponseCode', + 'cvv_response_code' => 'getCvvResponseCode', + 'method' => 'getMethod', + 'payment_service_transaction_id' => 'getPaymentServiceTransactionId', + 'metadata' => 'getMetadata', + 'three_d_secure' => 'getThreeDSecure', + 'authorized_at' => 'getAuthorizedAt', + 'captured_at' => 'getCapturedAt', + 'voided_at' => 'getVoidedAt' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_TRANSACTION = 'transaction'; + public const STATUS_PROCESSING = 'processing'; + public const STATUS_BUYER_APPROVAL_PENDING = 'buyer_approval_pending'; + public const STATUS_AUTHORIZATION_SUCCEEDED = 'authorization_succeeded'; + public const STATUS_AUTHORIZATION_FAILED = 'authorization_failed'; + public const STATUS_AUTHORIZATION_DECLINED = 'authorization_declined'; + public const STATUS_CAPTURE_PENDING = 'capture_pending'; + public const STATUS_CAPTURE_SUCCEEDED = 'capture_succeeded'; + public const STATUS_AUTHORIZATION_VOID_PENDING = 'authorization_void_pending'; + public const STATUS_AUTHORIZATION_VOIDED = 'authorization_voided'; + public const INTENT_AUTHORIZE = 'authorize'; + public const INTENT_CAPTURE = 'capture'; + public const PAYMENT_SOURCE_ECOMMERCE = 'ecommerce'; + public const PAYMENT_SOURCE_MOTO = 'moto'; + public const PAYMENT_SOURCE_RECURRING = 'recurring'; + public const PAYMENT_SOURCE_INSTALLMENT = 'installment'; + public const PAYMENT_SOURCE_CARD_ON_FILE = 'card_on_file'; + public const AVS_RESPONSE_CODE_NO_MATCH = 'no_match'; + public const AVS_RESPONSE_CODE_MATCH = 'match'; + public const AVS_RESPONSE_CODE_PARTIAL_MATCH_ADDRESS = 'partial_match_address'; + public const AVS_RESPONSE_CODE_PARTIAL_MATCH_POSTCODE = 'partial_match_postcode'; + public const AVS_RESPONSE_CODE_UNAVAILABLE = 'unavailable'; + public const CVV_RESPONSE_CODE_NO_MATCH = 'no_match'; + public const CVV_RESPONSE_CODE_MATCH = 'match'; + public const CVV_RESPONSE_CODE_UNAVAILABLE = 'unavailable'; + public const CVV_RESPONSE_CODE_NOT_PROVIDED = 'not_provided'; + public const METHOD_AFTERPAY = 'afterpay'; + public const METHOD_APPLEPAY = 'applepay'; + public const METHOD_BANKED = 'banked'; + public const METHOD_BITPAY = 'bitpay'; + public const METHOD_BOLETO = 'boleto'; + public const METHOD_CARD = 'card'; + public const METHOD_CLEARPAY = 'clearpay'; + public const METHOD_DANA = 'dana'; + public const METHOD_FORTUMO = 'fortumo'; + public const METHOD_GCASH = 'gcash'; + public const METHOD_GOCARDLESS = 'gocardless'; + public const METHOD_GOOGLEPAY = 'googlepay'; + public const METHOD_GRABPAY = 'grabpay'; + public const METHOD_KLARNA = 'klarna'; + public const METHOD_OVO = 'ovo'; + public const METHOD_PAYMAYA = 'paymaya'; + public const METHOD_PAYPAL = 'paypal'; + public const METHOD_PIX = 'pix'; + public const METHOD_RABBITLINEPAY = 'rabbitlinepay'; + public const METHOD_SCALAPAY = 'scalapay'; + public const METHOD_SHOPEEPAY = 'shopeepay'; + public const METHOD_STRIPEDD = 'stripedd'; + public const METHOD_TRUEMONEY = 'truemoney'; + public const METHOD_TRUSTLY = 'trustly'; + public const METHOD_ZIPPAY = 'zippay'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_TRANSACTION, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStatusAllowableValues() + { + return [ + self::STATUS_PROCESSING, + self::STATUS_BUYER_APPROVAL_PENDING, + self::STATUS_AUTHORIZATION_SUCCEEDED, + self::STATUS_AUTHORIZATION_FAILED, + self::STATUS_AUTHORIZATION_DECLINED, + self::STATUS_CAPTURE_PENDING, + self::STATUS_CAPTURE_SUCCEEDED, + self::STATUS_AUTHORIZATION_VOID_PENDING, + self::STATUS_AUTHORIZATION_VOIDED, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getIntentAllowableValues() + { + return [ + self::INTENT_AUTHORIZE, + self::INTENT_CAPTURE, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getPaymentSourceAllowableValues() + { + return [ + self::PAYMENT_SOURCE_ECOMMERCE, + self::PAYMENT_SOURCE_MOTO, + self::PAYMENT_SOURCE_RECURRING, + self::PAYMENT_SOURCE_INSTALLMENT, + self::PAYMENT_SOURCE_CARD_ON_FILE, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getAvsResponseCodeAllowableValues() + { + return [ + self::AVS_RESPONSE_CODE_NO_MATCH, + self::AVS_RESPONSE_CODE_MATCH, + self::AVS_RESPONSE_CODE_PARTIAL_MATCH_ADDRESS, + self::AVS_RESPONSE_CODE_PARTIAL_MATCH_POSTCODE, + self::AVS_RESPONSE_CODE_UNAVAILABLE, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getCvvResponseCodeAllowableValues() + { + return [ + self::CVV_RESPONSE_CODE_NO_MATCH, + self::CVV_RESPONSE_CODE_MATCH, + self::CVV_RESPONSE_CODE_UNAVAILABLE, + self::CVV_RESPONSE_CODE_NOT_PROVIDED, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getMethodAllowableValues() + { + return [ + self::METHOD_AFTERPAY, + self::METHOD_APPLEPAY, + self::METHOD_BANKED, + self::METHOD_BITPAY, + self::METHOD_BOLETO, + self::METHOD_CARD, + self::METHOD_CLEARPAY, + self::METHOD_DANA, + self::METHOD_FORTUMO, + self::METHOD_GCASH, + self::METHOD_GOCARDLESS, + self::METHOD_GOOGLEPAY, + self::METHOD_GRABPAY, + self::METHOD_KLARNA, + self::METHOD_OVO, + self::METHOD_PAYMAYA, + self::METHOD_PAYPAL, + self::METHOD_PIX, + self::METHOD_RABBITLINEPAY, + self::METHOD_SCALAPAY, + self::METHOD_SHOPEEPAY, + self::METHOD_STRIPEDD, + self::METHOD_TRUEMONEY, + self::METHOD_TRUSTLY, + self::METHOD_ZIPPAY, + ]; + } + + /** + * 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['type'] = $data['type'] ?? null; + $this->container['id'] = $data['id'] ?? null; + $this->container['status'] = $data['status'] ?? null; + $this->container['intent'] = $data['intent'] ?? null; + $this->container['amount'] = $data['amount'] ?? null; + $this->container['captured_amount'] = $data['captured_amount'] ?? null; + $this->container['refunded_amount'] = $data['refunded_amount'] ?? null; + $this->container['currency'] = $data['currency'] ?? null; + $this->container['country'] = $data['country'] ?? null; + $this->container['payment_method'] = $data['payment_method'] ?? null; + $this->container['buyer'] = $data['buyer'] ?? null; + $this->container['created_at'] = $data['created_at'] ?? null; + $this->container['external_identifier'] = $data['external_identifier'] ?? null; + $this->container['updated_at'] = $data['updated_at'] ?? null; + $this->container['payment_service'] = $data['payment_service'] ?? null; + $this->container['merchant_initiated'] = $data['merchant_initiated'] ?? false; + $this->container['payment_source'] = $data['payment_source'] ?? null; + $this->container['is_subsequent_payment'] = $data['is_subsequent_payment'] ?? false; + $this->container['statement_descriptor'] = $data['statement_descriptor'] ?? null; + $this->container['cart_items'] = $data['cart_items'] ?? null; + $this->container['scheme_transaction_id'] = $data['scheme_transaction_id'] ?? null; + $this->container['raw_response_code'] = $data['raw_response_code'] ?? null; + $this->container['raw_response_description'] = $data['raw_response_description'] ?? null; + $this->container['avs_response_code'] = $data['avs_response_code'] ?? null; + $this->container['cvv_response_code'] = $data['cvv_response_code'] ?? null; + $this->container['method'] = $data['method'] ?? null; + $this->container['payment_service_transaction_id'] = $data['payment_service_transaction_id'] ?? null; + $this->container['metadata'] = $data['metadata'] ?? null; + $this->container['three_d_secure'] = $data['three_d_secure'] ?? null; + $this->container['authorized_at'] = $data['authorized_at'] ?? null; + $this->container['captured_at'] = $data['captured_at'] ?? null; + $this->container['voided_at'] = $data['voided_at'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($this->container['status']) && !in_array($this->container['status'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'status', must be one of '%s'", + $this->container['status'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getIntentAllowableValues(); + if (!is_null($this->container['intent']) && !in_array($this->container['intent'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'intent', must be one of '%s'", + $this->container['intent'], + implode("', '", $allowedValues) + ); + } + + if (!is_null($this->container['amount']) && ($this->container['amount'] > 99999999)) { + $invalidProperties[] = "invalid value for 'amount', must be smaller than or equal to 99999999."; + } + + if (!is_null($this->container['amount']) && ($this->container['amount'] < 0)) { + $invalidProperties[] = "invalid value for 'amount', must be bigger than or equal to 0."; + } + + if (!is_null($this->container['captured_amount']) && ($this->container['captured_amount'] > 99999999)) { + $invalidProperties[] = "invalid value for 'captured_amount', must be smaller than or equal to 99999999."; + } + + if (!is_null($this->container['captured_amount']) && ($this->container['captured_amount'] < 0)) { + $invalidProperties[] = "invalid value for 'captured_amount', must be bigger than or equal to 0."; + } + + if (!is_null($this->container['refunded_amount']) && ($this->container['refunded_amount'] > 99999999)) { + $invalidProperties[] = "invalid value for 'refunded_amount', must be smaller than or equal to 99999999."; + } + + if (!is_null($this->container['refunded_amount']) && ($this->container['refunded_amount'] < 0)) { + $invalidProperties[] = "invalid value for 'refunded_amount', must be bigger than or equal to 0."; + } + + $allowedValues = $this->getPaymentSourceAllowableValues(); + if (!is_null($this->container['payment_source']) && !in_array($this->container['payment_source'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'payment_source', must be one of '%s'", + $this->container['payment_source'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getAvsResponseCodeAllowableValues(); + if (!is_null($this->container['avs_response_code']) && !in_array($this->container['avs_response_code'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'avs_response_code', must be one of '%s'", + $this->container['avs_response_code'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getCvvResponseCodeAllowableValues(); + if (!is_null($this->container['cvv_response_code']) && !in_array($this->container['cvv_response_code'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'cvv_response_code', must be one of '%s'", + $this->container['cvv_response_code'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getMethodAllowableValues(); + if (!is_null($this->container['method']) && !in_array($this->container['method'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'method', must be one of '%s'", + $this->container['method'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type The type of this resource. Is always `transaction`. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id The unique identifier for this transaction. + * + * @return self + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets status + * + * @return string|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param string|null $status The status of the transaction. The status may change over time as asynchronous processing events occur. + * + * @return self + */ + public function setStatus($status) + { + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($status) && !in_array($status, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'status', must be one of '%s'", + $status, + implode("', '", $allowedValues) + ) + ); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets intent + * + * @return string|null + */ + public function getIntent() + { + return $this->container['intent']; + } + + /** + * Sets intent + * + * @param string|null $intent The original `intent` used when the transaction was [created](#operation/authorize-new-transaction). + * + * @return self + */ + public function setIntent($intent) + { + $allowedValues = $this->getIntentAllowableValues(); + if (!is_null($intent) && !in_array($intent, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'intent', must be one of '%s'", + $intent, + implode("', '", $allowedValues) + ) + ); + } + $this->container['intent'] = $intent; + + return $this; + } + + /** + * Gets amount + * + * @return int|null + */ + public function getAmount() + { + return $this->container['amount']; + } + + /** + * Sets amount + * + * @param int|null $amount The authorized amount for this transaction. This can be more than the actual captured amount and part of this amount may be refunded. + * + * @return self + */ + public function setAmount($amount) + { + + if (!is_null($amount) && ($amount > 99999999)) { + throw new \InvalidArgumentException('invalid value for $amount when calling Transaction., must be smaller than or equal to 99999999.'); + } + if (!is_null($amount) && ($amount < 0)) { + throw new \InvalidArgumentException('invalid value for $amount when calling Transaction., must be bigger than or equal to 0.'); + } + + $this->container['amount'] = $amount; + + return $this; + } + + /** + * Gets captured_amount + * + * @return int|null + */ + public function getCapturedAmount() + { + return $this->container['captured_amount']; + } + + /** + * Sets captured_amount + * + * @param int|null $captured_amount The captured amount for this transaction. This can be the total or a portion of the authorized amount. + * + * @return self + */ + public function setCapturedAmount($captured_amount) + { + + if (!is_null($captured_amount) && ($captured_amount > 99999999)) { + throw new \InvalidArgumentException('invalid value for $captured_amount when calling Transaction., must be smaller than or equal to 99999999.'); + } + if (!is_null($captured_amount) && ($captured_amount < 0)) { + throw new \InvalidArgumentException('invalid value for $captured_amount when calling Transaction., must be bigger than or equal to 0.'); + } + + $this->container['captured_amount'] = $captured_amount; + + return $this; + } + + /** + * Gets refunded_amount + * + * @return int|null + */ + public function getRefundedAmount() + { + return $this->container['refunded_amount']; + } + + /** + * Sets refunded_amount + * + * @param int|null $refunded_amount The refunded amount for this transaction. This can be the total or a portion of the captured amount. + * + * @return self + */ + public function setRefundedAmount($refunded_amount) + { + + if (!is_null($refunded_amount) && ($refunded_amount > 99999999)) { + throw new \InvalidArgumentException('invalid value for $refunded_amount when calling Transaction., must be smaller than or equal to 99999999.'); + } + if (!is_null($refunded_amount) && ($refunded_amount < 0)) { + throw new \InvalidArgumentException('invalid value for $refunded_amount when calling Transaction., must be bigger than or equal to 0.'); + } + + $this->container['refunded_amount'] = $refunded_amount; + + return $this; + } + + /** + * Gets currency + * + * @return string|null + */ + public function getCurrency() + { + return $this->container['currency']; + } + + /** + * Sets currency + * + * @param string|null $currency The currency code for this transaction. + * + * @return self + */ + public function setCurrency($currency) + { + $this->container['currency'] = $currency; + + return $this; + } + + /** + * Gets country + * + * @return string|null + */ + public function getCountry() + { + return $this->container['country']; + } + + /** + * Sets country + * + * @param string|null $country The 2-letter ISO code of the country of the transaction. This is used to filter the payment services that is used to process the transaction. + * + * @return self + */ + public function setCountry($country) + { + $this->container['country'] = $country; + + return $this; + } + + /** + * Gets payment_method + * + * @return \Gr4vy\model\TransactionPaymentMethod|null + */ + public function getPaymentMethod() + { + return $this->container['payment_method']; + } + + /** + * Sets payment_method + * + * @param \Gr4vy\model\TransactionPaymentMethod|null $payment_method payment_method + * + * @return self + */ + public function setPaymentMethod($payment_method) + { + $this->container['payment_method'] = $payment_method; + + return $this; + } + + /** + * Gets buyer + * + * @return \Gr4vy\model\TransactionBuyer|null + */ + public function getBuyer() + { + return $this->container['buyer']; + } + + /** + * Sets buyer + * + * @param \Gr4vy\model\TransactionBuyer|null $buyer buyer + * + * @return self + */ + public function setBuyer($buyer) + { + $this->container['buyer'] = $buyer; + + return $this; + } + + /** + * Gets created_at + * + * @return \DateTime|null + */ + public function getCreatedAt() + { + return $this->container['created_at']; + } + + /** + * Sets created_at + * + * @param \DateTime|null $created_at The date and time when this transaction was created in our system. + * + * @return self + */ + public function setCreatedAt($created_at) + { + $this->container['created_at'] = $created_at; + + return $this; + } + + /** + * Gets external_identifier + * + * @return string|null + */ + public function getExternalIdentifier() + { + return $this->container['external_identifier']; + } + + /** + * Sets external_identifier + * + * @param string|null $external_identifier An external identifier that can be used to match the transaction against your own records. + * + * @return self + */ + public function setExternalIdentifier($external_identifier) + { + $this->container['external_identifier'] = $external_identifier; + + return $this; + } + + /** + * Gets updated_at + * + * @return \DateTime|null + */ + public function getUpdatedAt() + { + return $this->container['updated_at']; + } + + /** + * Sets updated_at + * + * @param \DateTime|null $updated_at Defines when the transaction was last updated. + * + * @return self + */ + public function setUpdatedAt($updated_at) + { + $this->container['updated_at'] = $updated_at; + + return $this; + } + + /** + * Gets payment_service + * + * @return \Gr4vy\model\PaymentMethodTokenPaymentService|null + */ + public function getPaymentService() + { + return $this->container['payment_service']; + } + + /** + * Sets payment_service + * + * @param \Gr4vy\model\PaymentMethodTokenPaymentService|null $payment_service payment_service + * + * @return self + */ + public function setPaymentService($payment_service) + { + $this->container['payment_service'] = $payment_service; + + return $this; + } + + /** + * Gets merchant_initiated + * + * @return bool|null + */ + public function getMerchantInitiated() + { + return $this->container['merchant_initiated']; + } + + /** + * Sets merchant_initiated + * + * @param bool|null $merchant_initiated Indicates whether the transaction was initiated by the merchant (true) or customer (false). + * + * @return self + */ + public function setMerchantInitiated($merchant_initiated) + { + $this->container['merchant_initiated'] = $merchant_initiated; + + return $this; + } + + /** + * Gets payment_source + * + * @return string|null + */ + public function getPaymentSource() + { + return $this->container['payment_source']; + } + + /** + * Sets payment_source + * + * @param string|null $payment_source The source of the transaction. Defaults to `ecommerce`. + * + * @return self + */ + public function setPaymentSource($payment_source) + { + $allowedValues = $this->getPaymentSourceAllowableValues(); + if (!is_null($payment_source) && !in_array($payment_source, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'payment_source', must be one of '%s'", + $payment_source, + implode("', '", $allowedValues) + ) + ); + } + $this->container['payment_source'] = $payment_source; + + return $this; + } + + /** + * Gets is_subsequent_payment + * + * @return bool|null + */ + public function getIsSubsequentPayment() + { + return $this->container['is_subsequent_payment']; + } + + /** + * Sets is_subsequent_payment + * + * @param bool|null $is_subsequent_payment Indicates whether the transaction represents a subsequent payment coming from a setup recurring payment. Please note there are some restrictions on how this flag may be used. The flag can only be `false` (or not set) when the transaction meets one of the following criteria: * It is not `merchant_initiated`. * `payment_source` is set to `card_on_file`. The flag can only be set to `true` when the transaction meets one of the following criteria: * It is not `merchant_initiated`. * `payment_source` is set to `recurring` or `installment` and `merchant_initiated` is set to `true`. * `payment_source` is set to `card_on_file`. + * + * @return self + */ + public function setIsSubsequentPayment($is_subsequent_payment) + { + $this->container['is_subsequent_payment'] = $is_subsequent_payment; + + return $this; + } + + /** + * Gets statement_descriptor + * + * @return \Gr4vy\model\TransactionStatementDescriptor|null + */ + public function getStatementDescriptor() + { + return $this->container['statement_descriptor']; + } + + /** + * Sets statement_descriptor + * + * @param \Gr4vy\model\TransactionStatementDescriptor|null $statement_descriptor statement_descriptor + * + * @return self + */ + public function setStatementDescriptor($statement_descriptor) + { + $this->container['statement_descriptor'] = $statement_descriptor; + + return $this; + } + + /** + * Gets cart_items + * + * @return \Gr4vy\model\CartItem[]|null + */ + public function getCartItems() + { + return $this->container['cart_items']; + } + + /** + * Sets cart_items + * + * @param \Gr4vy\model\CartItem[]|null $cart_items An array of cart items that represents the line items of a transaction. + * + * @return self + */ + public function setCartItems($cart_items) + { + + + $this->container['cart_items'] = $cart_items; + + return $this; + } + + /** + * Gets scheme_transaction_id + * + * @return string|null + */ + public function getSchemeTransactionId() + { + return $this->container['scheme_transaction_id']; + } + + /** + * Sets scheme_transaction_id + * + * @param string|null $scheme_transaction_id An identifier for the transaction used by the scheme itself, when available. e.g. the Visa Transaction Identifier, or Mastercard Trace ID. + * + * @return self + */ + public function setSchemeTransactionId($scheme_transaction_id) + { + $this->container['scheme_transaction_id'] = $scheme_transaction_id; + + return $this; + } + + /** + * Gets raw_response_code + * + * @return string|null + */ + public function getRawResponseCode() + { + return $this->container['raw_response_code']; + } + + /** + * Sets raw_response_code + * + * @param string|null $raw_response_code This is the response code received from the payment service. This can be set to any value and is not standardized across different payment services. + * + * @return self + */ + public function setRawResponseCode($raw_response_code) + { + $this->container['raw_response_code'] = $raw_response_code; + + return $this; + } + + /** + * Gets raw_response_description + * + * @return string|null + */ + public function getRawResponseDescription() + { + return $this->container['raw_response_description']; + } + + /** + * Sets raw_response_description + * + * @param string|null $raw_response_description This is the response description received from the payment service. This can be set to any value and is not standardized across different payment services. + * + * @return self + */ + public function setRawResponseDescription($raw_response_description) + { + $this->container['raw_response_description'] = $raw_response_description; + + return $this; + } + + /** + * Gets avs_response_code + * + * @return string|null + */ + public function getAvsResponseCode() + { + return $this->container['avs_response_code']; + } + + /** + * Sets avs_response_code + * + * @param string|null $avs_response_code The response code received from the payment service for the Address Verification Check (AVS). This code is mapped to a standardized Gr4vy AVS response code. - `no_match` - neither address or postal code match - `match` - both address and postal code match - `partial_match_address` - address matches but postal code does not - `partial_match_postcode` - postal code matches but address does not - `unavailable ` - AVS is unavailable for card/country The value of this field can be `null` if the payment service did not provide a response. + * + * @return self + */ + public function setAvsResponseCode($avs_response_code) + { + $allowedValues = $this->getAvsResponseCodeAllowableValues(); + if (!is_null($avs_response_code) && !in_array($avs_response_code, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'avs_response_code', must be one of '%s'", + $avs_response_code, + implode("', '", $allowedValues) + ) + ); + } + $this->container['avs_response_code'] = $avs_response_code; + + return $this; + } + + /** + * Gets cvv_response_code + * + * @return string|null + */ + public function getCvvResponseCode() + { + return $this->container['cvv_response_code']; + } + + /** + * Sets cvv_response_code + * + * @param string|null $cvv_response_code The response code received from the payment service for the Card Verification Value (CVV). This code is mapped to a standardized Gr4vy CVV response code. - `no_match` - the CVV does not match the expected value - `match` - the CVV matches the expected value - `unavailable ` - CVV check unavailable for card our country - `not_provided ` - CVV not provided The value of this field can be `null` if the payment service did not provide a response. + * + * @return self + */ + public function setCvvResponseCode($cvv_response_code) + { + $allowedValues = $this->getCvvResponseCodeAllowableValues(); + if (!is_null($cvv_response_code) && !in_array($cvv_response_code, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'cvv_response_code', must be one of '%s'", + $cvv_response_code, + implode("', '", $allowedValues) + ) + ); + } + $this->container['cvv_response_code'] = $cvv_response_code; + + return $this; + } + + /** + * Gets method + * + * @return string|null + */ + public function getMethod() + { + return $this->container['method']; + } + + /** + * Sets method + * + * @param string|null $method method + * + * @return self + */ + public function setMethod($method) + { + $allowedValues = $this->getMethodAllowableValues(); + if (!is_null($method) && !in_array($method, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'method', must be one of '%s'", + $method, + implode("', '", $allowedValues) + ) + ); + } + $this->container['method'] = $method; + + return $this; + } + + /** + * Gets payment_service_transaction_id + * + * @return string|null + */ + public function getPaymentServiceTransactionId() + { + return $this->container['payment_service_transaction_id']; + } + + /** + * Sets payment_service_transaction_id + * + * @param string|null $payment_service_transaction_id The payment service's unique ID for the transaction. + * + * @return self + */ + public function setPaymentServiceTransactionId($payment_service_transaction_id) + { + $this->container['payment_service_transaction_id'] = $payment_service_transaction_id; + + return $this; + } + + /** + * Gets metadata + * + * @return array|null + */ + public function getMetadata() + { + return $this->container['metadata']; + } + + /** + * Sets metadata + * + * @param array|null $metadata Additional information about the transaction stored as key-value pairs. + * + * @return self + */ + public function setMetadata($metadata) + { + $this->container['metadata'] = $metadata; + + return $this; + } + + /** + * Gets three_d_secure + * + * @return \Gr4vy\model\ThreeDSecureSummary|null + */ + public function getThreeDSecure() + { + return $this->container['three_d_secure']; + } + + /** + * Sets three_d_secure + * + * @param \Gr4vy\model\ThreeDSecureSummary|null $three_d_secure three_d_secure + * + * @return self + */ + public function setThreeDSecure($three_d_secure) + { + $this->container['three_d_secure'] = $three_d_secure; + + return $this; + } + + /** + * Gets authorized_at + * + * @return \DateTime|null + */ + public function getAuthorizedAt() + { + return $this->container['authorized_at']; + } + + /** + * Sets authorized_at + * + * @param \DateTime|null $authorized_at The date and time when this transaction was authorized in the payment service. Don't use this field to determine whether the transaction was authorized. A `null` value doesn't necessarily imply that the transaction wasn't authorized, it can mean that the payment service doesn't provide this value, that it didn't provide it at the time the transaction was authorized or that the transaction was authorized before the introduction of this field. + * + * @return self + */ + public function setAuthorizedAt($authorized_at) + { + $this->container['authorized_at'] = $authorized_at; + + return $this; + } + + /** + * Gets captured_at + * + * @return \DateTime|null + */ + public function getCapturedAt() + { + return $this->container['captured_at']; + } + + /** + * Sets captured_at + * + * @param \DateTime|null $captured_at The date and time when this transaction was captured in the payment service. Don't use this field to determine whether the transaction was captured. A `null` value doesn't necessarily imply that the transaction wasn't captured, it can mean that the payment service doesn't provide this value, that it didn't provide it at the time the transaction was captured or that the transaction was captured before the introduction of this field. + * + * @return self + */ + public function setCapturedAt($captured_at) + { + $this->container['captured_at'] = $captured_at; + + return $this; + } + + /** + * Gets voided_at + * + * @return \DateTime|null + */ + public function getVoidedAt() + { + return $this->container['voided_at']; + } + + /** + * Sets voided_at + * + * @param \DateTime|null $voided_at The date and time when this transaction was voided in the payment service. Don't use this field to determine whether the transaction was voided. A `null` value doesn't necessarily imply that the transaction wasn't voided, it can mean that the payment service doesn't provide this value, that it didn't provide it at the time the transaction was voided or that the transaction was voided before the introduction of this field. + * + * @return self + */ + public function setVoidedAt($voided_at) + { + $this->container['voided_at'] = $voided_at; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/TransactionBuyer.php b/lib/model/TransactionBuyer.php new file mode 100644 index 0000000..22f6eef --- /dev/null +++ b/lib/model/TransactionBuyer.php @@ -0,0 +1,505 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class TransactionBuyer implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'Transaction_buyer'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'id' => 'string', + 'external_identifier' => 'string', + 'display_name' => 'string', + 'billing_details' => '\Gr4vy\model\BuyerSnapshotBillingDetails' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'id' => 'uuid', + 'external_identifier' => null, + 'display_name' => null, + 'billing_details' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'id' => 'id', + 'external_identifier' => 'external_identifier', + 'display_name' => 'display_name', + 'billing_details' => 'billing_details' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'id' => 'setId', + 'external_identifier' => 'setExternalIdentifier', + 'display_name' => 'setDisplayName', + 'billing_details' => 'setBillingDetails' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'id' => 'getId', + 'external_identifier' => 'getExternalIdentifier', + 'display_name' => 'getDisplayName', + 'billing_details' => 'getBillingDetails' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_BUYER = 'buyer'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_BUYER, + ]; + } + + /** + * 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['type'] = $data['type'] ?? null; + $this->container['id'] = $data['id'] ?? null; + $this->container['external_identifier'] = $data['external_identifier'] ?? null; + $this->container['display_name'] = $data['display_name'] ?? null; + $this->container['billing_details'] = $data['billing_details'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + if (!is_null($this->container['external_identifier']) && (mb_strlen($this->container['external_identifier']) > 200)) { + $invalidProperties[] = "invalid value for 'external_identifier', the character length must be smaller than or equal to 200."; + } + + if (!is_null($this->container['external_identifier']) && (mb_strlen($this->container['external_identifier']) < 1)) { + $invalidProperties[] = "invalid value for 'external_identifier', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['display_name']) && (mb_strlen($this->container['display_name']) > 200)) { + $invalidProperties[] = "invalid value for 'display_name', the character length must be smaller than or equal to 200."; + } + + if (!is_null($this->container['display_name']) && (mb_strlen($this->container['display_name']) < 1)) { + $invalidProperties[] = "invalid value for 'display_name', the character length must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type The type of this resource. Is always `buyer`. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id The unique Gr4vy ID for this buyer. + * + * @return self + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets external_identifier + * + * @return string|null + */ + public function getExternalIdentifier() + { + return $this->container['external_identifier']; + } + + /** + * Sets external_identifier + * + * @param string|null $external_identifier An external identifier that can be used to match the buyer against your own records. + * + * @return self + */ + public function setExternalIdentifier($external_identifier) + { + if (!is_null($external_identifier) && (mb_strlen($external_identifier) > 200)) { + throw new \InvalidArgumentException('invalid length for $external_identifier when calling TransactionBuyer., must be smaller than or equal to 200.'); + } + if (!is_null($external_identifier) && (mb_strlen($external_identifier) < 1)) { + throw new \InvalidArgumentException('invalid length for $external_identifier when calling TransactionBuyer., must be bigger than or equal to 1.'); + } + + $this->container['external_identifier'] = $external_identifier; + + return $this; + } + + /** + * Gets display_name + * + * @return string|null + */ + public function getDisplayName() + { + return $this->container['display_name']; + } + + /** + * Sets display_name + * + * @param string|null $display_name A unique name for this buyer which is used in the Gr4vy admin panel to give a buyer a human readable name. + * + * @return self + */ + public function setDisplayName($display_name) + { + if (!is_null($display_name) && (mb_strlen($display_name) > 200)) { + throw new \InvalidArgumentException('invalid length for $display_name when calling TransactionBuyer., must be smaller than or equal to 200.'); + } + if (!is_null($display_name) && (mb_strlen($display_name) < 1)) { + throw new \InvalidArgumentException('invalid length for $display_name when calling TransactionBuyer., must be bigger than or equal to 1.'); + } + + $this->container['display_name'] = $display_name; + + return $this; + } + + /** + * Gets billing_details + * + * @return \Gr4vy\model\BuyerSnapshotBillingDetails|null + */ + public function getBillingDetails() + { + return $this->container['billing_details']; + } + + /** + * Sets billing_details + * + * @param \Gr4vy\model\BuyerSnapshotBillingDetails|null $billing_details billing_details + * + * @return self + */ + public function setBillingDetails($billing_details) + { + $this->container['billing_details'] = $billing_details; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/TransactionCaptureRequest.php b/lib/model/TransactionCaptureRequest.php new file mode 100644 index 0000000..e45f53f --- /dev/null +++ b/lib/model/TransactionCaptureRequest.php @@ -0,0 +1,340 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class TransactionCaptureRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'TransactionCaptureRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'amount' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'amount' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'amount' => 'amount' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'amount' => 'setAmount' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'amount' => 'getAmount' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['amount'] = $data['amount'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['amount']) && ($this->container['amount'] > 99999999)) { + $invalidProperties[] = "invalid value for 'amount', must be smaller than or equal to 99999999."; + } + + if (!is_null($this->container['amount']) && ($this->container['amount'] < 1)) { + $invalidProperties[] = "invalid value for 'amount', must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets amount + * + * @return int|null + */ + public function getAmount() + { + return $this->container['amount']; + } + + /** + * Sets amount + * + * @param int|null $amount The monetary amount to capture an authorization for, in the smallest currency unit for the given currency, for example `1299` cents to create an authorization for `$12.99`. When omitted blank, this will capture the entire amount. Capturing an amount that is greater than the authorized amount is not supported. + * + * @return self + */ + public function setAmount($amount) + { + + if (!is_null($amount) && ($amount > 99999999)) { + throw new \InvalidArgumentException('invalid value for $amount when calling TransactionCaptureRequest., must be smaller than or equal to 99999999.'); + } + if (!is_null($amount) && ($amount < 1)) { + throw new \InvalidArgumentException('invalid value for $amount when calling TransactionCaptureRequest., must be bigger than or equal to 1.'); + } + + $this->container['amount'] = $amount; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/TransactionPaymentMethod.php b/lib/model/TransactionPaymentMethod.php new file mode 100644 index 0000000..4fd145a --- /dev/null +++ b/lib/model/TransactionPaymentMethod.php @@ -0,0 +1,741 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class TransactionPaymentMethod implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'Transaction_payment_method'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'id' => 'string', + 'method' => 'string', + 'external_identifier' => 'string', + 'label' => 'string', + 'scheme' => 'string', + 'expiration_date' => 'string', + 'approval_target' => 'string', + 'approval_url' => 'string', + 'currency' => 'string', + 'country' => 'string', + 'details' => '\Gr4vy\model\PaymentMethodDetailsCard' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'id' => 'uuid', + 'method' => null, + 'external_identifier' => null, + 'label' => null, + 'scheme' => null, + 'expiration_date' => null, + 'approval_target' => null, + 'approval_url' => null, + 'currency' => null, + 'country' => null, + 'details' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'id' => 'id', + 'method' => 'method', + 'external_identifier' => 'external_identifier', + 'label' => 'label', + 'scheme' => 'scheme', + 'expiration_date' => 'expiration_date', + 'approval_target' => 'approval_target', + 'approval_url' => 'approval_url', + 'currency' => 'currency', + 'country' => 'country', + 'details' => 'details' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'id' => 'setId', + 'method' => 'setMethod', + 'external_identifier' => 'setExternalIdentifier', + 'label' => 'setLabel', + 'scheme' => 'setScheme', + 'expiration_date' => 'setExpirationDate', + 'approval_target' => 'setApprovalTarget', + 'approval_url' => 'setApprovalUrl', + 'currency' => 'setCurrency', + 'country' => 'setCountry', + 'details' => 'setDetails' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'id' => 'getId', + 'method' => 'getMethod', + 'external_identifier' => 'getExternalIdentifier', + 'label' => 'getLabel', + 'scheme' => 'getScheme', + 'expiration_date' => 'getExpirationDate', + 'approval_target' => 'getApprovalTarget', + 'approval_url' => 'getApprovalUrl', + 'currency' => 'getCurrency', + 'country' => 'getCountry', + 'details' => 'getDetails' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_PAYMENT_METHOD = 'payment-method'; + public const APPROVAL_TARGET_ANY = 'any'; + public const APPROVAL_TARGET_NEW_WINDOW = 'new_window'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_PAYMENT_METHOD, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getApprovalTargetAllowableValues() + { + return [ + self::APPROVAL_TARGET_ANY, + self::APPROVAL_TARGET_NEW_WINDOW, + ]; + } + + /** + * 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['type'] = $data['type'] ?? null; + $this->container['id'] = $data['id'] ?? null; + $this->container['method'] = $data['method'] ?? null; + $this->container['external_identifier'] = $data['external_identifier'] ?? null; + $this->container['label'] = $data['label'] ?? null; + $this->container['scheme'] = $data['scheme'] ?? null; + $this->container['expiration_date'] = $data['expiration_date'] ?? null; + $this->container['approval_target'] = $data['approval_target'] ?? null; + $this->container['approval_url'] = $data['approval_url'] ?? null; + $this->container['currency'] = $data['currency'] ?? null; + $this->container['country'] = $data['country'] ?? null; + $this->container['details'] = $data['details'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + if (!is_null($this->container['expiration_date']) && (mb_strlen($this->container['expiration_date']) > 5)) { + $invalidProperties[] = "invalid value for 'expiration_date', the character length must be smaller than or equal to 5."; + } + + if (!is_null($this->container['expiration_date']) && (mb_strlen($this->container['expiration_date']) < 5)) { + $invalidProperties[] = "invalid value for 'expiration_date', the character length must be bigger than or equal to 5."; + } + + if (!is_null($this->container['expiration_date']) && !preg_match("/^\\d{2}\/\\d{2}$/", $this->container['expiration_date'])) { + $invalidProperties[] = "invalid value for 'expiration_date', must be conform to the pattern /^\\d{2}\/\\d{2}$/."; + } + + $allowedValues = $this->getApprovalTargetAllowableValues(); + if (!is_null($this->container['approval_target']) && !in_array($this->container['approval_target'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'approval_target', must be one of '%s'", + $this->container['approval_target'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type `payment-method`. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id The unique ID of the payment method. + * + * @return self + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets method + * + * @return string|null + */ + public function getMethod() + { + return $this->container['method']; + } + + /** + * Sets method + * + * @param string|null $method method + * + * @return self + */ + public function setMethod($method) + { + $this->container['method'] = $method; + + return $this; + } + + /** + * Gets external_identifier + * + * @return string|null + */ + public function getExternalIdentifier() + { + return $this->container['external_identifier']; + } + + /** + * Sets external_identifier + * + * @param string|null $external_identifier An external identifier that can be used to match the payment method against your own records. + * + * @return self + */ + public function setExternalIdentifier($external_identifier) + { + $this->container['external_identifier'] = $external_identifier; + + return $this; + } + + /** + * Gets label + * + * @return string|null + */ + public function getLabel() + { + return $this->container['label']; + } + + /** + * Sets label + * + * @param string|null $label A label for the payment method. This can be the last 4 digits for a card, or the email address for an alternative payment method. + * + * @return self + */ + public function setLabel($label) + { + $this->container['label'] = $label; + + return $this; + } + + /** + * Gets scheme + * + * @return string|null + */ + public function getScheme() + { + return $this->container['scheme']; + } + + /** + * Sets scheme + * + * @param string|null $scheme An additional label used to differentiate different sub-types of a payment method. Most notably this can include the type of card used in a transaction. + * + * @return self + */ + public function setScheme($scheme) + { + $this->container['scheme'] = $scheme; + + return $this; + } + + /** + * Gets expiration_date + * + * @return string|null + */ + public function getExpirationDate() + { + return $this->container['expiration_date']; + } + + /** + * Sets expiration_date + * + * @param string|null $expiration_date The expiration date for this payment method. This is mostly used by cards where the card might have an expiration date. + * + * @return self + */ + public function setExpirationDate($expiration_date) + { + if (!is_null($expiration_date) && (mb_strlen($expiration_date) > 5)) { + throw new \InvalidArgumentException('invalid length for $expiration_date when calling TransactionPaymentMethod., must be smaller than or equal to 5.'); + } + if (!is_null($expiration_date) && (mb_strlen($expiration_date) < 5)) { + throw new \InvalidArgumentException('invalid length for $expiration_date when calling TransactionPaymentMethod., must be bigger than or equal to 5.'); + } + if (!is_null($expiration_date) && (!preg_match("/^\\d{2}\/\\d{2}$/", $expiration_date))) { + throw new \InvalidArgumentException("invalid value for $expiration_date when calling TransactionPaymentMethod., must conform to the pattern /^\\d{2}\/\\d{2}$/."); + } + + $this->container['expiration_date'] = $expiration_date; + + return $this; + } + + /** + * Gets approval_target + * + * @return string|null + */ + public function getApprovalTarget() + { + return $this->container['approval_target']; + } + + /** + * Sets approval_target + * + * @param string|null $approval_target The browser target that an approval URL must be opened in. If `any` or `null`, then there is no specific requirement. + * + * @return self + */ + public function setApprovalTarget($approval_target) + { + $allowedValues = $this->getApprovalTargetAllowableValues(); + if (!is_null($approval_target) && !in_array($approval_target, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'approval_target', must be one of '%s'", + $approval_target, + implode("', '", $allowedValues) + ) + ); + } + $this->container['approval_target'] = $approval_target; + + return $this; + } + + /** + * Gets approval_url + * + * @return string|null + */ + public function getApprovalUrl() + { + return $this->container['approval_url']; + } + + /** + * Sets approval_url + * + * @param string|null $approval_url The optional URL that the buyer needs to be redirected to to further authorize their payment. + * + * @return self + */ + public function setApprovalUrl($approval_url) + { + $this->container['approval_url'] = $approval_url; + + return $this; + } + + /** + * Gets currency + * + * @return string|null + */ + public function getCurrency() + { + return $this->container['currency']; + } + + /** + * Sets currency + * + * @param string|null $currency The ISO-4217 currency code that this payment method can be used for. If this value is `null` the payment method may be used for multiple currencies. + * + * @return self + */ + public function setCurrency($currency) + { + $this->container['currency'] = $currency; + + return $this; + } + + /** + * Gets country + * + * @return string|null + */ + public function getCountry() + { + return $this->container['country']; + } + + /** + * Sets country + * + * @param string|null $country The 2-letter ISO code of the country this payment method can be used for. If this value is `null` the payment method may be used in multiple countries. + * + * @return self + */ + public function setCountry($country) + { + $this->container['country'] = $country; + + return $this; + } + + /** + * Gets details + * + * @return \Gr4vy\model\PaymentMethodDetailsCard|null + */ + public function getDetails() + { + return $this->container['details']; + } + + /** + * Sets details + * + * @param \Gr4vy\model\PaymentMethodDetailsCard|null $details details + * + * @return self + */ + public function setDetails($details) + { + $this->container['details'] = $details; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/TransactionPaymentMethodRequest.php b/lib/model/TransactionPaymentMethodRequest.php new file mode 100644 index 0000000..469e75e --- /dev/null +++ b/lib/model/TransactionPaymentMethodRequest.php @@ -0,0 +1,633 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class TransactionPaymentMethodRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'TransactionPaymentMethodRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'method' => 'string', + 'number' => 'string', + 'expiration_date' => 'string', + 'security_code' => 'string', + 'external_identifier' => 'string', + 'buyer_id' => 'string', + 'buyer_external_identifier' => 'string', + 'redirect_url' => 'string', + 'id' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'method' => null, + 'number' => null, + 'expiration_date' => null, + 'security_code' => null, + 'external_identifier' => null, + 'buyer_id' => 'uuid', + 'buyer_external_identifier' => null, + 'redirect_url' => null, + 'id' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'method' => 'method', + 'number' => 'number', + 'expiration_date' => 'expiration_date', + 'security_code' => 'security_code', + 'external_identifier' => 'external_identifier', + 'buyer_id' => 'buyer_id', + 'buyer_external_identifier' => 'buyer_external_identifier', + 'redirect_url' => 'redirect_url', + 'id' => 'id' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'method' => 'setMethod', + 'number' => 'setNumber', + 'expiration_date' => 'setExpirationDate', + 'security_code' => 'setSecurityCode', + 'external_identifier' => 'setExternalIdentifier', + 'buyer_id' => 'setBuyerId', + 'buyer_external_identifier' => 'setBuyerExternalIdentifier', + 'redirect_url' => 'setRedirectUrl', + 'id' => 'setId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'method' => 'getMethod', + 'number' => 'getNumber', + 'expiration_date' => 'getExpirationDate', + 'security_code' => 'getSecurityCode', + 'external_identifier' => 'getExternalIdentifier', + 'buyer_id' => 'getBuyerId', + 'buyer_external_identifier' => 'getBuyerExternalIdentifier', + 'redirect_url' => 'getRedirectUrl', + 'id' => 'getId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['method'] = $data['method'] ?? null; + $this->container['number'] = $data['number'] ?? null; + $this->container['expiration_date'] = $data['expiration_date'] ?? null; + $this->container['security_code'] = $data['security_code'] ?? null; + $this->container['external_identifier'] = $data['external_identifier'] ?? null; + $this->container['buyer_id'] = $data['buyer_id'] ?? null; + $this->container['buyer_external_identifier'] = $data['buyer_external_identifier'] ?? null; + $this->container['redirect_url'] = $data['redirect_url'] ?? null; + $this->container['id'] = $data['id'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['method'] === null) { + $invalidProperties[] = "'method' can't be null"; + } + if (!is_null($this->container['number']) && (mb_strlen($this->container['number']) > 19)) { + $invalidProperties[] = "invalid value for 'number', the character length must be smaller than or equal to 19."; + } + + if (!is_null($this->container['number']) && (mb_strlen($this->container['number']) < 13)) { + $invalidProperties[] = "invalid value for 'number', the character length must be bigger than or equal to 13."; + } + + if (!is_null($this->container['number']) && !preg_match("/^[0-9]{13,19}$/", $this->container['number'])) { + $invalidProperties[] = "invalid value for 'number', must be conform to the pattern /^[0-9]{13,19}$/."; + } + + if (!is_null($this->container['expiration_date']) && (mb_strlen($this->container['expiration_date']) > 5)) { + $invalidProperties[] = "invalid value for 'expiration_date', the character length must be smaller than or equal to 5."; + } + + if (!is_null($this->container['expiration_date']) && (mb_strlen($this->container['expiration_date']) < 5)) { + $invalidProperties[] = "invalid value for 'expiration_date', the character length must be bigger than or equal to 5."; + } + + if (!is_null($this->container['expiration_date']) && !preg_match("/^\\d\\d\/\\d\\d$/", $this->container['expiration_date'])) { + $invalidProperties[] = "invalid value for 'expiration_date', must be conform to the pattern /^\\d\\d\/\\d\\d$/."; + } + + if (!is_null($this->container['security_code']) && (mb_strlen($this->container['security_code']) > 4)) { + $invalidProperties[] = "invalid value for 'security_code', the character length must be smaller than or equal to 4."; + } + + if (!is_null($this->container['security_code']) && (mb_strlen($this->container['security_code']) < 3)) { + $invalidProperties[] = "invalid value for 'security_code', the character length must be bigger than or equal to 3."; + } + + if (!is_null($this->container['security_code']) && !preg_match("/^\\d{3,4}$/", $this->container['security_code'])) { + $invalidProperties[] = "invalid value for 'security_code', must be conform to the pattern /^\\d{3,4}$/."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets method + * + * @return string + */ + public function getMethod() + { + return $this->container['method']; + } + + /** + * Sets method + * + * @param string $method method + * + * @return self + */ + public function setMethod($method) + { + $this->container['method'] = $method; + + return $this; + } + + /** + * Gets number + * + * @return string|null + */ + public function getNumber() + { + return $this->container['number']; + } + + /** + * Sets number + * + * @param string|null $number The 13-19 digit number for this credit card as it can be found on the front of the card. If a card has been stored with us previously, this number will represent the unique tokenized card ID provided via our API. + * + * @return self + */ + public function setNumber($number) + { + if (!is_null($number) && (mb_strlen($number) > 19)) { + throw new \InvalidArgumentException('invalid length for $number when calling TransactionPaymentMethodRequest., must be smaller than or equal to 19.'); + } + if (!is_null($number) && (mb_strlen($number) < 13)) { + throw new \InvalidArgumentException('invalid length for $number when calling TransactionPaymentMethodRequest., must be bigger than or equal to 13.'); + } + if (!is_null($number) && (!preg_match("/^[0-9]{13,19}$/", $number))) { + throw new \InvalidArgumentException("invalid value for $number when calling TransactionPaymentMethodRequest., must conform to the pattern /^[0-9]{13,19}$/."); + } + + $this->container['number'] = $number; + + return $this; + } + + /** + * Gets expiration_date + * + * @return string|null + */ + public function getExpirationDate() + { + return $this->container['expiration_date']; + } + + /** + * Sets expiration_date + * + * @param string|null $expiration_date The expiration date of the card, formatted `MM/YY`. If a card has been previously stored with us this value is optional. If the `number` of this card represents a tokenized card, then this value is ignored. + * + * @return self + */ + public function setExpirationDate($expiration_date) + { + if (!is_null($expiration_date) && (mb_strlen($expiration_date) > 5)) { + throw new \InvalidArgumentException('invalid length for $expiration_date when calling TransactionPaymentMethodRequest., must be smaller than or equal to 5.'); + } + if (!is_null($expiration_date) && (mb_strlen($expiration_date) < 5)) { + throw new \InvalidArgumentException('invalid length for $expiration_date when calling TransactionPaymentMethodRequest., must be bigger than or equal to 5.'); + } + if (!is_null($expiration_date) && (!preg_match("/^\\d\\d\/\\d\\d$/", $expiration_date))) { + throw new \InvalidArgumentException("invalid value for $expiration_date when calling TransactionPaymentMethodRequest., must conform to the pattern /^\\d\\d\/\\d\\d$/."); + } + + $this->container['expiration_date'] = $expiration_date; + + return $this; + } + + /** + * Gets security_code + * + * @return string|null + */ + public function getSecurityCode() + { + return $this->container['security_code']; + } + + /** + * Sets security_code + * + * @param string|null $security_code The 3 or 4 digit security code often found on the card. This often referred to as the CVV or CVD. If the `number` of this card represents a tokenized card, then this value is ignored. + * + * @return self + */ + public function setSecurityCode($security_code) + { + if (!is_null($security_code) && (mb_strlen($security_code) > 4)) { + throw new \InvalidArgumentException('invalid length for $security_code when calling TransactionPaymentMethodRequest., must be smaller than or equal to 4.'); + } + if (!is_null($security_code) && (mb_strlen($security_code) < 3)) { + throw new \InvalidArgumentException('invalid length for $security_code when calling TransactionPaymentMethodRequest., must be bigger than or equal to 3.'); + } + if (!is_null($security_code) && (!preg_match("/^\\d{3,4}$/", $security_code))) { + throw new \InvalidArgumentException("invalid value for $security_code when calling TransactionPaymentMethodRequest., must conform to the pattern /^\\d{3,4}$/."); + } + + $this->container['security_code'] = $security_code; + + return $this; + } + + /** + * Gets external_identifier + * + * @return string|null + */ + public function getExternalIdentifier() + { + return $this->container['external_identifier']; + } + + /** + * Sets external_identifier + * + * @param string|null $external_identifier An external identifier that can be used to match the card against your own records. + * + * @return self + */ + public function setExternalIdentifier($external_identifier) + { + $this->container['external_identifier'] = $external_identifier; + + return $this; + } + + /** + * Gets buyer_id + * + * @return string|null + */ + public function getBuyerId() + { + return $this->container['buyer_id']; + } + + /** + * Sets buyer_id + * + * @param string|null $buyer_id The ID of the buyer to associate this payment method to. If this field is provided then the `buyer_external_identifier` field needs to be unset. + * + * @return self + */ + public function setBuyerId($buyer_id) + { + $this->container['buyer_id'] = $buyer_id; + + return $this; + } + + /** + * Gets buyer_external_identifier + * + * @return string|null + */ + public function getBuyerExternalIdentifier() + { + return $this->container['buyer_external_identifier']; + } + + /** + * Sets buyer_external_identifier + * + * @param string|null $buyer_external_identifier The `external_identifier` of the buyer to associate this payment method to. If this field is provided then the `buyer_id` field needs to be unset. + * + * @return self + */ + public function setBuyerExternalIdentifier($buyer_external_identifier) + { + $this->container['buyer_external_identifier'] = $buyer_external_identifier; + + return $this; + } + + /** + * Gets redirect_url + * + * @return string|null + */ + public function getRedirectUrl() + { + return $this->container['redirect_url']; + } + + /** + * Sets redirect_url + * + * @param string|null $redirect_url The redirect URL to redirect a buyer to after they have authorized their transaction or payment method. This only applies to payment methods that require buyer approval. + * + * @return self + */ + public function setRedirectUrl($redirect_url) + { + $this->container['redirect_url'] = $redirect_url; + + return $this; + } + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id An identifier for a previously tokenized payment method. This id can represent any type of payment method. + * + * @return self + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/TransactionRefundRequest.php b/lib/model/TransactionRefundRequest.php new file mode 100644 index 0000000..d105643 --- /dev/null +++ b/lib/model/TransactionRefundRequest.php @@ -0,0 +1,340 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class TransactionRefundRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'TransactionRefundRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'amount' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'amount' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'amount' => 'amount' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'amount' => 'setAmount' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'amount' => 'getAmount' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['amount'] = $data['amount'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['amount']) && ($this->container['amount'] > 99999999)) { + $invalidProperties[] = "invalid value for 'amount', must be smaller than or equal to 99999999."; + } + + if (!is_null($this->container['amount']) && ($this->container['amount'] < 1)) { + $invalidProperties[] = "invalid value for 'amount', must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets amount + * + * @return int|null + */ + public function getAmount() + { + return $this->container['amount']; + } + + /** + * Sets amount + * + * @param int|null $amount The amount requested to refund. If omitted, a full refund will be requested. Otherwise, the amount must be lower than or equal to the remaining balance in the associated transaction. Negative and zero-amount refunds are not supported. + * + * @return self + */ + public function setAmount($amount) + { + + if (!is_null($amount) && ($amount > 99999999)) { + throw new \InvalidArgumentException('invalid value for $amount when calling TransactionRefundRequest., must be smaller than or equal to 99999999.'); + } + if (!is_null($amount) && ($amount < 1)) { + throw new \InvalidArgumentException('invalid value for $amount when calling TransactionRefundRequest., must be bigger than or equal to 1.'); + } + + $this->container['amount'] = $amount; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/TransactionRequest.php b/lib/model/TransactionRequest.php new file mode 100644 index 0000000..2c91f50 --- /dev/null +++ b/lib/model/TransactionRequest.php @@ -0,0 +1,889 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class TransactionRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'TransactionRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'amount' => 'int', + 'currency' => 'string', + 'country' => 'string', + 'payment_method' => '\Gr4vy\model\TransactionPaymentMethodRequest', + 'store' => 'bool', + 'intent' => 'string', + 'external_identifier' => 'string', + 'three_d_secure_data' => '\Gr4vy\model\ThreeDSecureDataV1V2', + 'merchant_initiated' => 'bool', + 'payment_source' => 'string', + 'is_subsequent_payment' => 'bool', + 'metadata' => 'array', + 'statement_descriptor' => '\Gr4vy\model\TransactionStatementDescriptor', + 'cart_items' => '\Gr4vy\model\CartItem[]', + 'previous_scheme_transaction_id' => 'string', + 'browser_info' => '\Gr4vy\model\TransactionRequestBrowserInfo' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'amount' => null, + 'currency' => null, + 'country' => null, + 'payment_method' => null, + 'store' => null, + 'intent' => null, + 'external_identifier' => null, + 'three_d_secure_data' => null, + 'merchant_initiated' => null, + 'payment_source' => null, + 'is_subsequent_payment' => null, + 'metadata' => null, + 'statement_descriptor' => null, + 'cart_items' => null, + 'previous_scheme_transaction_id' => null, + 'browser_info' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'amount' => 'amount', + 'currency' => 'currency', + 'country' => 'country', + 'payment_method' => 'payment_method', + 'store' => 'store', + 'intent' => 'intent', + 'external_identifier' => 'external_identifier', + 'three_d_secure_data' => 'three_d_secure_data', + 'merchant_initiated' => 'merchant_initiated', + 'payment_source' => 'payment_source', + 'is_subsequent_payment' => 'is_subsequent_payment', + 'metadata' => 'metadata', + 'statement_descriptor' => 'statement_descriptor', + 'cart_items' => 'cart_items', + 'previous_scheme_transaction_id' => 'previous_scheme_transaction_id', + 'browser_info' => 'browser_info' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'amount' => 'setAmount', + 'currency' => 'setCurrency', + 'country' => 'setCountry', + 'payment_method' => 'setPaymentMethod', + 'store' => 'setStore', + 'intent' => 'setIntent', + 'external_identifier' => 'setExternalIdentifier', + 'three_d_secure_data' => 'setThreeDSecureData', + 'merchant_initiated' => 'setMerchantInitiated', + 'payment_source' => 'setPaymentSource', + 'is_subsequent_payment' => 'setIsSubsequentPayment', + 'metadata' => 'setMetadata', + 'statement_descriptor' => 'setStatementDescriptor', + 'cart_items' => 'setCartItems', + 'previous_scheme_transaction_id' => 'setPreviousSchemeTransactionId', + 'browser_info' => 'setBrowserInfo' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'amount' => 'getAmount', + 'currency' => 'getCurrency', + 'country' => 'getCountry', + 'payment_method' => 'getPaymentMethod', + 'store' => 'getStore', + 'intent' => 'getIntent', + 'external_identifier' => 'getExternalIdentifier', + 'three_d_secure_data' => 'getThreeDSecureData', + 'merchant_initiated' => 'getMerchantInitiated', + 'payment_source' => 'getPaymentSource', + 'is_subsequent_payment' => 'getIsSubsequentPayment', + 'metadata' => 'getMetadata', + 'statement_descriptor' => 'getStatementDescriptor', + 'cart_items' => 'getCartItems', + 'previous_scheme_transaction_id' => 'getPreviousSchemeTransactionId', + 'browser_info' => 'getBrowserInfo' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const INTENT_AUTHORIZE = 'authorize'; + public const INTENT_CAPTURE = 'capture'; + public const PAYMENT_SOURCE_ECOMMERCE = 'ecommerce'; + public const PAYMENT_SOURCE_MOTO = 'moto'; + public const PAYMENT_SOURCE_RECURRING = 'recurring'; + public const PAYMENT_SOURCE_INSTALLMENT = 'installment'; + public const PAYMENT_SOURCE_CARD_ON_FILE = 'card_on_file'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getIntentAllowableValues() + { + return [ + self::INTENT_AUTHORIZE, + self::INTENT_CAPTURE, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getPaymentSourceAllowableValues() + { + return [ + self::PAYMENT_SOURCE_ECOMMERCE, + self::PAYMENT_SOURCE_MOTO, + self::PAYMENT_SOURCE_RECURRING, + self::PAYMENT_SOURCE_INSTALLMENT, + self::PAYMENT_SOURCE_CARD_ON_FILE, + ]; + } + + /** + * 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['amount'] = $data['amount'] ?? null; + $this->container['currency'] = $data['currency'] ?? null; + $this->container['country'] = $data['country'] ?? null; + $this->container['payment_method'] = $data['payment_method'] ?? null; + $this->container['store'] = $data['store'] ?? false; + $this->container['intent'] = $data['intent'] ?? 'authorize'; + $this->container['external_identifier'] = $data['external_identifier'] ?? null; + $this->container['three_d_secure_data'] = $data['three_d_secure_data'] ?? null; + $this->container['merchant_initiated'] = $data['merchant_initiated'] ?? false; + $this->container['payment_source'] = $data['payment_source'] ?? null; + $this->container['is_subsequent_payment'] = $data['is_subsequent_payment'] ?? false; + $this->container['metadata'] = $data['metadata'] ?? null; + $this->container['statement_descriptor'] = $data['statement_descriptor'] ?? null; + $this->container['cart_items'] = $data['cart_items'] ?? null; + $this->container['previous_scheme_transaction_id'] = $data['previous_scheme_transaction_id'] ?? null; + $this->container['browser_info'] = $data['browser_info'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['amount'] === null) { + $invalidProperties[] = "'amount' can't be null"; + } + if (($this->container['amount'] > 99999999)) { + $invalidProperties[] = "invalid value for 'amount', must be smaller than or equal to 99999999."; + } + + if (($this->container['amount'] < 0)) { + $invalidProperties[] = "invalid value for 'amount', must be bigger than or equal to 0."; + } + + if ($this->container['currency'] === null) { + $invalidProperties[] = "'currency' can't be null"; + } + if ($this->container['payment_method'] === null) { + $invalidProperties[] = "'payment_method' can't be null"; + } + $allowedValues = $this->getIntentAllowableValues(); + if (!is_null($this->container['intent']) && !in_array($this->container['intent'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'intent', must be one of '%s'", + $this->container['intent'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getPaymentSourceAllowableValues(); + if (!is_null($this->container['payment_source']) && !in_array($this->container['payment_source'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'payment_source', must be one of '%s'", + $this->container['payment_source'], + implode("', '", $allowedValues) + ); + } + + if (!is_null($this->container['metadata']) && (count($this->container['metadata']) > 20)) { + $invalidProperties[] = "invalid value for 'metadata', number of items must be less than or equal to 20."; + } + + if (!is_null($this->container['cart_items']) && (count($this->container['cart_items']) > 249)) { + $invalidProperties[] = "invalid value for 'cart_items', number of items must be less than or equal to 249."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets amount + * + * @return int + */ + public function getAmount() + { + return $this->container['amount']; + } + + /** + * Sets amount + * + * @param int $amount The monetary amount to create an authorization for, in the smallest currency unit for the given currency, for example `1299` cents to create an authorization for `$12.99`. If the `intent` is set to `capture`, an amount greater than zero must be supplied. + * + * @return self + */ + public function setAmount($amount) + { + + if (($amount > 99999999)) { + throw new \InvalidArgumentException('invalid value for $amount when calling TransactionRequest., must be smaller than or equal to 99999999.'); + } + if (($amount < 0)) { + throw new \InvalidArgumentException('invalid value for $amount when calling TransactionRequest., must be bigger than or equal to 0.'); + } + + $this->container['amount'] = $amount; + + return $this; + } + + /** + * Gets currency + * + * @return string + */ + public function getCurrency() + { + return $this->container['currency']; + } + + /** + * Sets currency + * + * @param string $currency A supported ISO-4217 currency code. For redirect requests, this value must match the one specified for `currency` in `payment_method`. + * + * @return self + */ + public function setCurrency($currency) + { + $this->container['currency'] = $currency; + + return $this; + } + + /** + * Gets country + * + * @return string|null + */ + public function getCountry() + { + return $this->container['country']; + } + + /** + * Sets country + * + * @param string|null $country The 2-letter ISO code of the country of the transaction. This is used to filter the payment services that is used to process the transaction. If this value is provided for redirect requests and it's not `null`, it must match the one specified for `country` in `payment_method`. Otherwise, the value specified for `country` in `payment_method` will be assumed implicitly. + * + * @return self + */ + public function setCountry($country) + { + $this->container['country'] = $country; + + return $this; + } + + /** + * Gets payment_method + * + * @return \Gr4vy\model\TransactionPaymentMethodRequest + */ + public function getPaymentMethod() + { + return $this->container['payment_method']; + } + + /** + * Sets payment_method + * + * @param \Gr4vy\model\TransactionPaymentMethodRequest $payment_method payment_method + * + * @return self + */ + public function setPaymentMethod($payment_method) + { + $this->container['payment_method'] = $payment_method; + + return $this; + } + + /** + * Gets store + * + * @return bool|null + */ + public function getStore() + { + return $this->container['store']; + } + + /** + * Sets store + * + * @param bool|null $store Whether or not to also try and store the payment method with us so that it can be used again for future use. This is only supported for payment methods that support this feature. There are also a few restrictions on how the flag may be set: * The flag has to be set to `true` when the `payment_source` is set to `recurring` or `installment`, and `merchant_initiated` is set to `false`. * The flag has to be set to `false` (or not set) when using a previously tokenized payment method. + * + * @return self + */ + public function setStore($store) + { + $this->container['store'] = $store; + + return $this; + } + + /** + * Gets intent + * + * @return string|null + */ + public function getIntent() + { + return $this->container['intent']; + } + + /** + * Sets intent + * + * @param string|null $intent Defines the intent of this API call. This determines the desired initial state of the transaction. * `authorize` - (Default) Optionally approves and then authorizes a transaction but does not capture the funds. * `capture` - Optionally approves and then authorizes and captures the funds of the transaction. + * + * @return self + */ + public function setIntent($intent) + { + $allowedValues = $this->getIntentAllowableValues(); + if (!is_null($intent) && !in_array($intent, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'intent', must be one of '%s'", + $intent, + implode("', '", $allowedValues) + ) + ); + } + $this->container['intent'] = $intent; + + return $this; + } + + /** + * Gets external_identifier + * + * @return string|null + */ + public function getExternalIdentifier() + { + return $this->container['external_identifier']; + } + + /** + * Sets external_identifier + * + * @param string|null $external_identifier An external identifier that can be used to match the transaction against your own records. + * + * @return self + */ + public function setExternalIdentifier($external_identifier) + { + $this->container['external_identifier'] = $external_identifier; + + return $this; + } + + /** + * Gets three_d_secure_data + * + * @return \Gr4vy\model\ThreeDSecureDataV1V2|null + */ + public function getThreeDSecureData() + { + return $this->container['three_d_secure_data']; + } + + /** + * Sets three_d_secure_data + * + * @param \Gr4vy\model\ThreeDSecureDataV1V2|null $three_d_secure_data three_d_secure_data + * + * @return self + */ + public function setThreeDSecureData($three_d_secure_data) + { + $this->container['three_d_secure_data'] = $three_d_secure_data; + + return $this; + } + + /** + * Gets merchant_initiated + * + * @return bool|null + */ + public function getMerchantInitiated() + { + return $this->container['merchant_initiated']; + } + + /** + * Sets merchant_initiated + * + * @param bool|null $merchant_initiated Indicates whether the transaction was initiated by the merchant (true) or customer (false). + * + * @return self + */ + public function setMerchantInitiated($merchant_initiated) + { + $this->container['merchant_initiated'] = $merchant_initiated; + + return $this; + } + + /** + * Gets payment_source + * + * @return string|null + */ + public function getPaymentSource() + { + return $this->container['payment_source']; + } + + /** + * Sets payment_source + * + * @param string|null $payment_source The source of the transaction. Defaults to `ecommerce`. + * + * @return self + */ + public function setPaymentSource($payment_source) + { + $allowedValues = $this->getPaymentSourceAllowableValues(); + if (!is_null($payment_source) && !in_array($payment_source, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'payment_source', must be one of '%s'", + $payment_source, + implode("', '", $allowedValues) + ) + ); + } + $this->container['payment_source'] = $payment_source; + + return $this; + } + + /** + * Gets is_subsequent_payment + * + * @return bool|null + */ + public function getIsSubsequentPayment() + { + return $this->container['is_subsequent_payment']; + } + + /** + * Sets is_subsequent_payment + * + * @param bool|null $is_subsequent_payment Indicates whether the transaction represents a subsequent payment coming from a setup recurring payment. Please note there are some restrictions on how this flag may be used. The flag can only be `false` (or not set) when the transaction meets one of the following criteria: * It is not `merchant_initiated`. * `payment_source` is set to `card_on_file`. The flag can only be set to `true` when the transaction meets one of the following criteria: * It is not `merchant_initiated`. * `payment_source` is set to `recurring` or `installment` and `merchant_initiated` is set to `true`. * `payment_source` is set to `card_on_file`. + * + * @return self + */ + public function setIsSubsequentPayment($is_subsequent_payment) + { + $this->container['is_subsequent_payment'] = $is_subsequent_payment; + + return $this; + } + + /** + * Gets metadata + * + * @return array|null + */ + public function getMetadata() + { + return $this->container['metadata']; + } + + /** + * Sets metadata + * + * @param array|null $metadata Any additional information about the transaction that you would like to store as key-value pairs. This data is passed to payment service providers that support it. Please visit https://gr4vy.com/docs/ under `Connections` for more information on how specific providers support metadata. + * + * @return self + */ + public function setMetadata($metadata) + { + + if (!is_null($metadata) && (count($metadata) > 20)) { + throw new \InvalidArgumentException('invalid value for $metadata when calling TransactionRequest., number of items must be less than or equal to 20.'); + } + $this->container['metadata'] = $metadata; + + return $this; + } + + /** + * Gets statement_descriptor + * + * @return \Gr4vy\model\TransactionStatementDescriptor|null + */ + public function getStatementDescriptor() + { + return $this->container['statement_descriptor']; + } + + /** + * Sets statement_descriptor + * + * @param \Gr4vy\model\TransactionStatementDescriptor|null $statement_descriptor statement_descriptor + * + * @return self + */ + public function setStatementDescriptor($statement_descriptor) + { + $this->container['statement_descriptor'] = $statement_descriptor; + + return $this; + } + + /** + * Gets cart_items + * + * @return \Gr4vy\model\CartItem[]|null + */ + public function getCartItems() + { + return $this->container['cart_items']; + } + + /** + * Sets cart_items + * + * @param \Gr4vy\model\CartItem[]|null $cart_items An array of cart items that represents the line items of a transaction. + * + * @return self + */ + public function setCartItems($cart_items) + { + + if (!is_null($cart_items) && (count($cart_items) > 249)) { + throw new \InvalidArgumentException('invalid value for $cart_items when calling TransactionRequest., number of items must be less than or equal to 249.'); + } + $this->container['cart_items'] = $cart_items; + + return $this; + } + + /** + * Gets previous_scheme_transaction_id + * + * @return string|null + */ + public function getPreviousSchemeTransactionId() + { + return $this->container['previous_scheme_transaction_id']; + } + + /** + * Sets previous_scheme_transaction_id + * + * @param string|null $previous_scheme_transaction_id A scheme's transaction identifier to use in connecting a merchant initiated transaction to a previous customer initiated transaction. If not provided, and a qualifying customer initiated transaction has been previously made, then Gr4vy will populate this value with the identifier returned for that transaction. e.g. the Visa Transaction Identifier, or Mastercard Trace ID. + * + * @return self + */ + public function setPreviousSchemeTransactionId($previous_scheme_transaction_id) + { + $this->container['previous_scheme_transaction_id'] = $previous_scheme_transaction_id; + + return $this; + } + + /** + * Gets browser_info + * + * @return \Gr4vy\model\TransactionRequestBrowserInfo|null + */ + public function getBrowserInfo() + { + return $this->container['browser_info']; + } + + /** + * Sets browser_info + * + * @param \Gr4vy\model\TransactionRequestBrowserInfo|null $browser_info browser_info + * + * @return self + */ + public function setBrowserInfo($browser_info) + { + $this->container['browser_info'] = $browser_info; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/TransactionRequestBrowserInfo.php b/lib/model/TransactionRequestBrowserInfo.php new file mode 100644 index 0000000..5cd1846 --- /dev/null +++ b/lib/model/TransactionRequestBrowserInfo.php @@ -0,0 +1,654 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class TransactionRequestBrowserInfo implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'TransactionRequest_browser_info'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'java_enabled' => 'bool', + 'javascript_enabled' => 'bool', + 'language' => 'string', + 'color_depth' => 'float', + 'screen_height' => 'float', + 'screen_width' => 'float', + 'time_zone_offset' => 'float', + 'user_device' => 'string', + 'user_agent' => 'string', + 'accept_header' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'java_enabled' => null, + 'javascript_enabled' => null, + 'language' => null, + 'color_depth' => null, + 'screen_height' => null, + 'screen_width' => null, + 'time_zone_offset' => null, + 'user_device' => null, + 'user_agent' => null, + 'accept_header' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'java_enabled' => 'java_enabled', + 'javascript_enabled' => 'javascript_enabled', + 'language' => 'language', + 'color_depth' => 'color_depth', + 'screen_height' => 'screen_height', + 'screen_width' => 'screen_width', + 'time_zone_offset' => 'time_zone_offset', + 'user_device' => 'user_device', + 'user_agent' => 'user_agent', + 'accept_header' => 'accept_header' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'java_enabled' => 'setJavaEnabled', + 'javascript_enabled' => 'setJavascriptEnabled', + 'language' => 'setLanguage', + 'color_depth' => 'setColorDepth', + 'screen_height' => 'setScreenHeight', + 'screen_width' => 'setScreenWidth', + 'time_zone_offset' => 'setTimeZoneOffset', + 'user_device' => 'setUserDevice', + 'user_agent' => 'setUserAgent', + 'accept_header' => 'setAcceptHeader' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'java_enabled' => 'getJavaEnabled', + 'javascript_enabled' => 'getJavascriptEnabled', + 'language' => 'getLanguage', + 'color_depth' => 'getColorDepth', + 'screen_height' => 'getScreenHeight', + 'screen_width' => 'getScreenWidth', + 'time_zone_offset' => 'getTimeZoneOffset', + 'user_device' => 'getUserDevice', + 'user_agent' => 'getUserAgent', + 'accept_header' => 'getAcceptHeader' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const USER_DEVICE_DESKTOP = 'desktop'; + public const USER_DEVICE_MOBILE = 'mobile'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getUserDeviceAllowableValues() + { + return [ + self::USER_DEVICE_DESKTOP, + self::USER_DEVICE_MOBILE, + ]; + } + + /** + * 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['java_enabled'] = $data['java_enabled'] ?? null; + $this->container['javascript_enabled'] = $data['javascript_enabled'] ?? null; + $this->container['language'] = $data['language'] ?? null; + $this->container['color_depth'] = $data['color_depth'] ?? null; + $this->container['screen_height'] = $data['screen_height'] ?? null; + $this->container['screen_width'] = $data['screen_width'] ?? null; + $this->container['time_zone_offset'] = $data['time_zone_offset'] ?? null; + $this->container['user_device'] = $data['user_device'] ?? null; + $this->container['user_agent'] = $data['user_agent'] ?? null; + $this->container['accept_header'] = $data['accept_header'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['java_enabled'] === null) { + $invalidProperties[] = "'java_enabled' can't be null"; + } + if ($this->container['javascript_enabled'] === null) { + $invalidProperties[] = "'javascript_enabled' can't be null"; + } + if ($this->container['language'] === null) { + $invalidProperties[] = "'language' can't be null"; + } + if ($this->container['color_depth'] === null) { + $invalidProperties[] = "'color_depth' can't be null"; + } + if ($this->container['screen_height'] === null) { + $invalidProperties[] = "'screen_height' can't be null"; + } + if ($this->container['screen_width'] === null) { + $invalidProperties[] = "'screen_width' can't be null"; + } + if ($this->container['time_zone_offset'] === null) { + $invalidProperties[] = "'time_zone_offset' can't be null"; + } + if ($this->container['user_device'] === null) { + $invalidProperties[] = "'user_device' can't be null"; + } + $allowedValues = $this->getUserDeviceAllowableValues(); + if (!is_null($this->container['user_device']) && !in_array($this->container['user_device'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'user_device', must be one of '%s'", + $this->container['user_device'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['user_agent'] === null) { + $invalidProperties[] = "'user_agent' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets java_enabled + * + * @return bool + */ + public function getJavaEnabled() + { + return $this->container['java_enabled']; + } + + /** + * Sets java_enabled + * + * @param bool $java_enabled Indicates whether the client browser supports Java. + * + * @return self + */ + public function setJavaEnabled($java_enabled) + { + $this->container['java_enabled'] = $java_enabled; + + return $this; + } + + /** + * Gets javascript_enabled + * + * @return bool + */ + public function getJavascriptEnabled() + { + return $this->container['javascript_enabled']; + } + + /** + * Sets javascript_enabled + * + * @param bool $javascript_enabled Indicates whether the client browser supports JavaScript. + * + * @return self + */ + public function setJavascriptEnabled($javascript_enabled) + { + $this->container['javascript_enabled'] = $javascript_enabled; + + return $this; + } + + /** + * Gets language + * + * @return string + */ + public function getLanguage() + { + return $this->container['language']; + } + + /** + * Sets language + * + * @param string $language The preferred language of the buyer, usually the language of the browser UI. + * + * @return self + */ + public function setLanguage($language) + { + $this->container['language'] = $language; + + return $this; + } + + /** + * Gets color_depth + * + * @return float + */ + public function getColorDepth() + { + return $this->container['color_depth']; + } + + /** + * Sets color_depth + * + * @param float $color_depth The color depth of the screen. + * + * @return self + */ + public function setColorDepth($color_depth) + { + $this->container['color_depth'] = $color_depth; + + return $this; + } + + /** + * Gets screen_height + * + * @return float + */ + public function getScreenHeight() + { + return $this->container['screen_height']; + } + + /** + * Sets screen_height + * + * @param float $screen_height The height of the screen in pixels. + * + * @return self + */ + public function setScreenHeight($screen_height) + { + $this->container['screen_height'] = $screen_height; + + return $this; + } + + /** + * Gets screen_width + * + * @return float + */ + public function getScreenWidth() + { + return $this->container['screen_width']; + } + + /** + * Sets screen_width + * + * @param float $screen_width The width of the screen in pixels. + * + * @return self + */ + public function setScreenWidth($screen_width) + { + $this->container['screen_width'] = $screen_width; + + return $this; + } + + /** + * Gets time_zone_offset + * + * @return float + */ + public function getTimeZoneOffset() + { + return $this->container['time_zone_offset']; + } + + /** + * Sets time_zone_offset + * + * @param float $time_zone_offset Time-zone offset in minutes between UTC and buyer location. + * + * @return self + */ + public function setTimeZoneOffset($time_zone_offset) + { + $this->container['time_zone_offset'] = $time_zone_offset; + + return $this; + } + + /** + * Gets user_device + * + * @return string + */ + public function getUserDevice() + { + return $this->container['user_device']; + } + + /** + * Sets user_device + * + * @param string $user_device The platform that is being used to access the website. + * + * @return self + */ + public function setUserDevice($user_device) + { + $allowedValues = $this->getUserDeviceAllowableValues(); + if (!in_array($user_device, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'user_device', must be one of '%s'", + $user_device, + implode("', '", $allowedValues) + ) + ); + } + $this->container['user_device'] = $user_device; + + return $this; + } + + /** + * Gets user_agent + * + * @return string + */ + public function getUserAgent() + { + return $this->container['user_agent']; + } + + /** + * Sets user_agent + * + * @param string $user_agent The user agent string for the current browser. + * + * @return self + */ + public function setUserAgent($user_agent) + { + $this->container['user_agent'] = $user_agent; + + return $this; + } + + /** + * Gets accept_header + * + * @return string|null + */ + public function getAcceptHeader() + { + return $this->container['accept_header']; + } + + /** + * Sets accept_header + * + * @param string|null $accept_header The `Accept` header of the request from the buyer's browser. + * + * @return self + */ + public function setAcceptHeader($accept_header) + { + $this->container['accept_header'] = $accept_header; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/TransactionStatementDescriptor.php b/lib/model/TransactionStatementDescriptor.php new file mode 100644 index 0000000..cccf81c --- /dev/null +++ b/lib/model/TransactionStatementDescriptor.php @@ -0,0 +1,525 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class TransactionStatementDescriptor implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'Transaction_statement_descriptor'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'name' => 'string', + 'description' => 'string', + 'city' => 'string', + 'phone_number' => 'string', + 'url' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'name' => null, + 'description' => null, + 'city' => null, + 'phone_number' => null, + 'url' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'name' => 'name', + 'description' => 'description', + 'city' => 'city', + 'phone_number' => 'phone_number', + 'url' => 'url' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'name' => 'setName', + 'description' => 'setDescription', + 'city' => 'setCity', + 'phone_number' => 'setPhoneNumber', + 'url' => 'setUrl' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'name' => 'getName', + 'description' => 'getDescription', + 'city' => 'getCity', + 'phone_number' => 'getPhoneNumber', + 'url' => 'getUrl' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['name'] = $data['name'] ?? null; + $this->container['description'] = $data['description'] ?? null; + $this->container['city'] = $data['city'] ?? null; + $this->container['phone_number'] = $data['phone_number'] ?? null; + $this->container['url'] = $data['url'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['name']) && (mb_strlen($this->container['name']) > 22)) { + $invalidProperties[] = "invalid value for 'name', the character length must be smaller than or equal to 22."; + } + + if (!is_null($this->container['name']) && (mb_strlen($this->container['name']) < 5)) { + $invalidProperties[] = "invalid value for 'name', the character length must be bigger than or equal to 5."; + } + + if (!is_null($this->container['description']) && (mb_strlen($this->container['description']) > 22)) { + $invalidProperties[] = "invalid value for 'description', the character length must be smaller than or equal to 22."; + } + + if (!is_null($this->container['description']) && (mb_strlen($this->container['description']) < 5)) { + $invalidProperties[] = "invalid value for 'description', the character length must be bigger than or equal to 5."; + } + + if (!is_null($this->container['city']) && (mb_strlen($this->container['city']) > 13)) { + $invalidProperties[] = "invalid value for 'city', the character length must be smaller than or equal to 13."; + } + + if (!is_null($this->container['city']) && (mb_strlen($this->container['city']) < 1)) { + $invalidProperties[] = "invalid value for 'city', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['phone_number']) && (mb_strlen($this->container['phone_number']) > 20)) { + $invalidProperties[] = "invalid value for 'phone_number', the character length must be smaller than or equal to 20."; + } + + if (!is_null($this->container['phone_number']) && (mb_strlen($this->container['phone_number']) < 5)) { + $invalidProperties[] = "invalid value for 'phone_number', the character length must be bigger than or equal to 5."; + } + + if (!is_null($this->container['phone_number']) && !preg_match("/^\\+[1-9]\\d{1,14}$/", $this->container['phone_number'])) { + $invalidProperties[] = "invalid value for 'phone_number', must be conform to the pattern /^\\+[1-9]\\d{1,14}$/."; + } + + if (!is_null($this->container['url']) && (mb_strlen($this->container['url']) > 13)) { + $invalidProperties[] = "invalid value for 'url', the character length must be smaller than or equal to 13."; + } + + if (!is_null($this->container['url']) && (mb_strlen($this->container['url']) < 1)) { + $invalidProperties[] = "invalid value for 'url', the character length must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name Reflects your doing business as (DBA) name. Other validations: 1. Contains only Latin characters. 2. Contain at least one letter 3. Does not contain any of the special characters `< > \\ ' \" *` 4. Supports: 1. Lower case: `a-z` 2. Upper case: `A-Z` 3. Numbers: `0-9` 4. Spaces: ` ` 5. Special characters: `. , _ - ? + /`. + * + * @return self + */ + public function setName($name) + { + if (!is_null($name) && (mb_strlen($name) > 22)) { + throw new \InvalidArgumentException('invalid length for $name when calling TransactionStatementDescriptor., must be smaller than or equal to 22.'); + } + if (!is_null($name) && (mb_strlen($name) < 5)) { + throw new \InvalidArgumentException('invalid length for $name when calling TransactionStatementDescriptor., must be bigger than or equal to 5.'); + } + + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets description + * + * @return string|null + */ + public function getDescription() + { + return $this->container['description']; + } + + /** + * Sets description + * + * @param string|null $description A short description about the purchase. Other validations: 1. Contains only Latin characters. 2. Contain at least one letter 3. Does not contain any of the special characters `< > \\ ' \" *` 4. Supports: 1. Lower case: `a-z` 2. Upper case: `A-Z` 3. Numbers: `0-9` 4. Spaces: ` ` 5. Special characters: `. , _ - ? + /`. + * + * @return self + */ + public function setDescription($description) + { + if (!is_null($description) && (mb_strlen($description) > 22)) { + throw new \InvalidArgumentException('invalid length for $description when calling TransactionStatementDescriptor., must be smaller than or equal to 22.'); + } + if (!is_null($description) && (mb_strlen($description) < 5)) { + throw new \InvalidArgumentException('invalid length for $description when calling TransactionStatementDescriptor., must be bigger than or equal to 5.'); + } + + $this->container['description'] = $description; + + return $this; + } + + /** + * Gets city + * + * @return string|null + */ + public function getCity() + { + return $this->container['city']; + } + + /** + * Sets city + * + * @param string|null $city City from which the charge originated. + * + * @return self + */ + public function setCity($city) + { + if (!is_null($city) && (mb_strlen($city) > 13)) { + throw new \InvalidArgumentException('invalid length for $city when calling TransactionStatementDescriptor., must be smaller than or equal to 13.'); + } + if (!is_null($city) && (mb_strlen($city) < 1)) { + throw new \InvalidArgumentException('invalid length for $city when calling TransactionStatementDescriptor., must be bigger than or equal to 1.'); + } + + $this->container['city'] = $city; + + return $this; + } + + /** + * Gets phone_number + * + * @return string|null + */ + public function getPhoneNumber() + { + return $this->container['phone_number']; + } + + /** + * Sets phone_number + * + * @param string|null $phone_number The value in the phone number field of a customer's statement which should be formatted according to the [E164 number standard](https://www.twilio.com/docs/glossary/what-e164). + * + * @return self + */ + public function setPhoneNumber($phone_number) + { + if (!is_null($phone_number) && (mb_strlen($phone_number) > 20)) { + throw new \InvalidArgumentException('invalid length for $phone_number when calling TransactionStatementDescriptor., must be smaller than or equal to 20.'); + } + if (!is_null($phone_number) && (mb_strlen($phone_number) < 5)) { + throw new \InvalidArgumentException('invalid length for $phone_number when calling TransactionStatementDescriptor., must be bigger than or equal to 5.'); + } + if (!is_null($phone_number) && (!preg_match("/^\\+[1-9]\\d{1,14}$/", $phone_number))) { + throw new \InvalidArgumentException("invalid value for $phone_number when calling TransactionStatementDescriptor., must conform to the pattern /^\\+[1-9]\\d{1,14}$/."); + } + + $this->container['phone_number'] = $phone_number; + + return $this; + } + + /** + * Gets url + * + * @return string|null + */ + public function getUrl() + { + return $this->container['url']; + } + + /** + * Sets url + * + * @param string|null $url The value in the URL/web address field of a customer's statement. + * + * @return self + */ + public function setUrl($url) + { + if (!is_null($url) && (mb_strlen($url) > 13)) { + throw new \InvalidArgumentException('invalid length for $url when calling TransactionStatementDescriptor., must be smaller than or equal to 13.'); + } + if (!is_null($url) && (mb_strlen($url) < 1)) { + throw new \InvalidArgumentException('invalid length for $url when calling TransactionStatementDescriptor., must be bigger than or equal to 1.'); + } + + $this->container['url'] = $url; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/TransactionSummary.php b/lib/model/TransactionSummary.php new file mode 100644 index 0000000..6d26223 --- /dev/null +++ b/lib/model/TransactionSummary.php @@ -0,0 +1,1076 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class TransactionSummary implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'TransactionSummary'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'id' => 'string', + 'status' => 'string', + 'intent' => 'string', + 'amount' => 'int', + 'captured_amount' => 'int', + 'refunded_amount' => 'int', + 'currency' => 'string', + 'country' => 'string', + 'payment_method' => '\Gr4vy\model\TransactionPaymentMethod', + 'buyer' => '\Gr4vy\model\TransactionBuyer', + 'created_at' => '\DateTime', + 'external_identifier' => 'string', + 'updated_at' => '\DateTime', + 'payment_service' => '\Gr4vy\model\PaymentMethodTokenPaymentService', + 'method' => 'string', + 'raw_response_code' => 'string', + 'raw_response_description' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'id' => 'uuid', + 'status' => null, + 'intent' => null, + 'amount' => null, + 'captured_amount' => null, + 'refunded_amount' => null, + 'currency' => null, + 'country' => null, + 'payment_method' => null, + 'buyer' => null, + 'created_at' => 'date-time', + 'external_identifier' => null, + 'updated_at' => 'date-time', + 'payment_service' => null, + 'method' => null, + 'raw_response_code' => null, + 'raw_response_description' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'id' => 'id', + 'status' => 'status', + 'intent' => 'intent', + 'amount' => 'amount', + 'captured_amount' => 'captured_amount', + 'refunded_amount' => 'refunded_amount', + 'currency' => 'currency', + 'country' => 'country', + 'payment_method' => 'payment_method', + 'buyer' => 'buyer', + 'created_at' => 'created_at', + 'external_identifier' => 'external_identifier', + 'updated_at' => 'updated_at', + 'payment_service' => 'payment_service', + 'method' => 'method', + 'raw_response_code' => 'raw_response_code', + 'raw_response_description' => 'raw_response_description' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'id' => 'setId', + 'status' => 'setStatus', + 'intent' => 'setIntent', + 'amount' => 'setAmount', + 'captured_amount' => 'setCapturedAmount', + 'refunded_amount' => 'setRefundedAmount', + 'currency' => 'setCurrency', + 'country' => 'setCountry', + 'payment_method' => 'setPaymentMethod', + 'buyer' => 'setBuyer', + 'created_at' => 'setCreatedAt', + 'external_identifier' => 'setExternalIdentifier', + 'updated_at' => 'setUpdatedAt', + 'payment_service' => 'setPaymentService', + 'method' => 'setMethod', + 'raw_response_code' => 'setRawResponseCode', + 'raw_response_description' => 'setRawResponseDescription' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'id' => 'getId', + 'status' => 'getStatus', + 'intent' => 'getIntent', + 'amount' => 'getAmount', + 'captured_amount' => 'getCapturedAmount', + 'refunded_amount' => 'getRefundedAmount', + 'currency' => 'getCurrency', + 'country' => 'getCountry', + 'payment_method' => 'getPaymentMethod', + 'buyer' => 'getBuyer', + 'created_at' => 'getCreatedAt', + 'external_identifier' => 'getExternalIdentifier', + 'updated_at' => 'getUpdatedAt', + 'payment_service' => 'getPaymentService', + 'method' => 'getMethod', + 'raw_response_code' => 'getRawResponseCode', + 'raw_response_description' => 'getRawResponseDescription' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_TRANSACTION = 'transaction'; + public const STATUS_PROCESSING = 'processing'; + public const STATUS_BUYER_APPROVAL_PENDING = 'buyer_approval_pending'; + public const STATUS_AUTHORIZATION_SUCCEEDED = 'authorization_succeeded'; + public const STATUS_AUTHORIZATION_FAILED = 'authorization_failed'; + public const STATUS_AUTHORIZATION_DECLINED = 'authorization_declined'; + public const STATUS_CAPTURE_PENDING = 'capture_pending'; + public const STATUS_CAPTURE_SUCCEEDED = 'capture_succeeded'; + public const STATUS_AUTHORIZATION_VOID_PENDING = 'authorization_void_pending'; + public const STATUS_AUTHORIZATION_VOIDED = 'authorization_voided'; + public const INTENT_AUTHORIZE = 'authorize'; + public const INTENT_CAPTURE = 'capture'; + public const METHOD_AFTERPAY = 'afterpay'; + public const METHOD_APPLEPAY = 'applepay'; + public const METHOD_BANKED = 'banked'; + public const METHOD_BITPAY = 'bitpay'; + public const METHOD_BOLETO = 'boleto'; + public const METHOD_CARD = 'card'; + public const METHOD_CLEARPAY = 'clearpay'; + public const METHOD_DANA = 'dana'; + public const METHOD_FORTUMO = 'fortumo'; + public const METHOD_GCASH = 'gcash'; + public const METHOD_GOCARDLESS = 'gocardless'; + public const METHOD_GOOGLEPAY = 'googlepay'; + public const METHOD_GRABPAY = 'grabpay'; + public const METHOD_KLARNA = 'klarna'; + public const METHOD_OVO = 'ovo'; + public const METHOD_PAYMAYA = 'paymaya'; + public const METHOD_PAYPAL = 'paypal'; + public const METHOD_PIX = 'pix'; + public const METHOD_RABBITLINEPAY = 'rabbitlinepay'; + public const METHOD_SCALAPAY = 'scalapay'; + public const METHOD_SHOPEEPAY = 'shopeepay'; + public const METHOD_STRIPEDD = 'stripedd'; + public const METHOD_TRUEMONEY = 'truemoney'; + public const METHOD_TRUSTLY = 'trustly'; + public const METHOD_ZIPPAY = 'zippay'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_TRANSACTION, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStatusAllowableValues() + { + return [ + self::STATUS_PROCESSING, + self::STATUS_BUYER_APPROVAL_PENDING, + self::STATUS_AUTHORIZATION_SUCCEEDED, + self::STATUS_AUTHORIZATION_FAILED, + self::STATUS_AUTHORIZATION_DECLINED, + self::STATUS_CAPTURE_PENDING, + self::STATUS_CAPTURE_SUCCEEDED, + self::STATUS_AUTHORIZATION_VOID_PENDING, + self::STATUS_AUTHORIZATION_VOIDED, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getIntentAllowableValues() + { + return [ + self::INTENT_AUTHORIZE, + self::INTENT_CAPTURE, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getMethodAllowableValues() + { + return [ + self::METHOD_AFTERPAY, + self::METHOD_APPLEPAY, + self::METHOD_BANKED, + self::METHOD_BITPAY, + self::METHOD_BOLETO, + self::METHOD_CARD, + self::METHOD_CLEARPAY, + self::METHOD_DANA, + self::METHOD_FORTUMO, + self::METHOD_GCASH, + self::METHOD_GOCARDLESS, + self::METHOD_GOOGLEPAY, + self::METHOD_GRABPAY, + self::METHOD_KLARNA, + self::METHOD_OVO, + self::METHOD_PAYMAYA, + self::METHOD_PAYPAL, + self::METHOD_PIX, + self::METHOD_RABBITLINEPAY, + self::METHOD_SCALAPAY, + self::METHOD_SHOPEEPAY, + self::METHOD_STRIPEDD, + self::METHOD_TRUEMONEY, + self::METHOD_TRUSTLY, + self::METHOD_ZIPPAY, + ]; + } + + /** + * 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['type'] = $data['type'] ?? null; + $this->container['id'] = $data['id'] ?? null; + $this->container['status'] = $data['status'] ?? null; + $this->container['intent'] = $data['intent'] ?? null; + $this->container['amount'] = $data['amount'] ?? null; + $this->container['captured_amount'] = $data['captured_amount'] ?? null; + $this->container['refunded_amount'] = $data['refunded_amount'] ?? null; + $this->container['currency'] = $data['currency'] ?? null; + $this->container['country'] = $data['country'] ?? null; + $this->container['payment_method'] = $data['payment_method'] ?? null; + $this->container['buyer'] = $data['buyer'] ?? null; + $this->container['created_at'] = $data['created_at'] ?? null; + $this->container['external_identifier'] = $data['external_identifier'] ?? null; + $this->container['updated_at'] = $data['updated_at'] ?? null; + $this->container['payment_service'] = $data['payment_service'] ?? null; + $this->container['method'] = $data['method'] ?? null; + $this->container['raw_response_code'] = $data['raw_response_code'] ?? null; + $this->container['raw_response_description'] = $data['raw_response_description'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($this->container['status']) && !in_array($this->container['status'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'status', must be one of '%s'", + $this->container['status'], + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getIntentAllowableValues(); + if (!is_null($this->container['intent']) && !in_array($this->container['intent'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'intent', must be one of '%s'", + $this->container['intent'], + implode("', '", $allowedValues) + ); + } + + if (!is_null($this->container['amount']) && ($this->container['amount'] > 99999999)) { + $invalidProperties[] = "invalid value for 'amount', must be smaller than or equal to 99999999."; + } + + if (!is_null($this->container['amount']) && ($this->container['amount'] < 0)) { + $invalidProperties[] = "invalid value for 'amount', must be bigger than or equal to 0."; + } + + if (!is_null($this->container['captured_amount']) && ($this->container['captured_amount'] > 99999999)) { + $invalidProperties[] = "invalid value for 'captured_amount', must be smaller than or equal to 99999999."; + } + + if (!is_null($this->container['captured_amount']) && ($this->container['captured_amount'] < 0)) { + $invalidProperties[] = "invalid value for 'captured_amount', must be bigger than or equal to 0."; + } + + if (!is_null($this->container['refunded_amount']) && ($this->container['refunded_amount'] > 99999999)) { + $invalidProperties[] = "invalid value for 'refunded_amount', must be smaller than or equal to 99999999."; + } + + if (!is_null($this->container['refunded_amount']) && ($this->container['refunded_amount'] < 0)) { + $invalidProperties[] = "invalid value for 'refunded_amount', must be bigger than or equal to 0."; + } + + $allowedValues = $this->getMethodAllowableValues(); + if (!is_null($this->container['method']) && !in_array($this->container['method'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'method', must be one of '%s'", + $this->container['method'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type The type of this resource. Is always `transaction`. + * + * @return self + */ + public function setType($type) + { + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($type) && !in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id The unique identifier for this transaction. + * + * @return self + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets status + * + * @return string|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param string|null $status The status of the transaction. The status may change over time as asynchronous processing events occur. + * + * @return self + */ + public function setStatus($status) + { + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($status) && !in_array($status, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'status', must be one of '%s'", + $status, + implode("', '", $allowedValues) + ) + ); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets intent + * + * @return string|null + */ + public function getIntent() + { + return $this->container['intent']; + } + + /** + * Sets intent + * + * @param string|null $intent The original `intent` used when the transaction was [created](#operation/authorize-new-transaction). + * + * @return self + */ + public function setIntent($intent) + { + $allowedValues = $this->getIntentAllowableValues(); + if (!is_null($intent) && !in_array($intent, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'intent', must be one of '%s'", + $intent, + implode("', '", $allowedValues) + ) + ); + } + $this->container['intent'] = $intent; + + return $this; + } + + /** + * Gets amount + * + * @return int|null + */ + public function getAmount() + { + return $this->container['amount']; + } + + /** + * Sets amount + * + * @param int|null $amount The authorized amount for this transaction. This can be more than the actual captured amount and part of this amount may be refunded. + * + * @return self + */ + public function setAmount($amount) + { + + if (!is_null($amount) && ($amount > 99999999)) { + throw new \InvalidArgumentException('invalid value for $amount when calling TransactionSummary., must be smaller than or equal to 99999999.'); + } + if (!is_null($amount) && ($amount < 0)) { + throw new \InvalidArgumentException('invalid value for $amount when calling TransactionSummary., must be bigger than or equal to 0.'); + } + + $this->container['amount'] = $amount; + + return $this; + } + + /** + * Gets captured_amount + * + * @return int|null + */ + public function getCapturedAmount() + { + return $this->container['captured_amount']; + } + + /** + * Sets captured_amount + * + * @param int|null $captured_amount The captured amount for this transaction. This can be the total or a portion of the authorized amount. + * + * @return self + */ + public function setCapturedAmount($captured_amount) + { + + if (!is_null($captured_amount) && ($captured_amount > 99999999)) { + throw new \InvalidArgumentException('invalid value for $captured_amount when calling TransactionSummary., must be smaller than or equal to 99999999.'); + } + if (!is_null($captured_amount) && ($captured_amount < 0)) { + throw new \InvalidArgumentException('invalid value for $captured_amount when calling TransactionSummary., must be bigger than or equal to 0.'); + } + + $this->container['captured_amount'] = $captured_amount; + + return $this; + } + + /** + * Gets refunded_amount + * + * @return int|null + */ + public function getRefundedAmount() + { + return $this->container['refunded_amount']; + } + + /** + * Sets refunded_amount + * + * @param int|null $refunded_amount The refunded amount for this transaction. This can be the total or a portion of the captured amount. + * + * @return self + */ + public function setRefundedAmount($refunded_amount) + { + + if (!is_null($refunded_amount) && ($refunded_amount > 99999999)) { + throw new \InvalidArgumentException('invalid value for $refunded_amount when calling TransactionSummary., must be smaller than or equal to 99999999.'); + } + if (!is_null($refunded_amount) && ($refunded_amount < 0)) { + throw new \InvalidArgumentException('invalid value for $refunded_amount when calling TransactionSummary., must be bigger than or equal to 0.'); + } + + $this->container['refunded_amount'] = $refunded_amount; + + return $this; + } + + /** + * Gets currency + * + * @return string|null + */ + public function getCurrency() + { + return $this->container['currency']; + } + + /** + * Sets currency + * + * @param string|null $currency The currency code for this transaction. + * + * @return self + */ + public function setCurrency($currency) + { + $this->container['currency'] = $currency; + + return $this; + } + + /** + * Gets country + * + * @return string|null + */ + public function getCountry() + { + return $this->container['country']; + } + + /** + * Sets country + * + * @param string|null $country The 2-letter ISO code of the country of the transaction. This is used to filter the payment services that is used to process the transaction. + * + * @return self + */ + public function setCountry($country) + { + $this->container['country'] = $country; + + return $this; + } + + /** + * Gets payment_method + * + * @return \Gr4vy\model\TransactionPaymentMethod|null + */ + public function getPaymentMethod() + { + return $this->container['payment_method']; + } + + /** + * Sets payment_method + * + * @param \Gr4vy\model\TransactionPaymentMethod|null $payment_method payment_method + * + * @return self + */ + public function setPaymentMethod($payment_method) + { + $this->container['payment_method'] = $payment_method; + + return $this; + } + + /** + * Gets buyer + * + * @return \Gr4vy\model\TransactionBuyer|null + */ + public function getBuyer() + { + return $this->container['buyer']; + } + + /** + * Sets buyer + * + * @param \Gr4vy\model\TransactionBuyer|null $buyer buyer + * + * @return self + */ + public function setBuyer($buyer) + { + $this->container['buyer'] = $buyer; + + return $this; + } + + /** + * Gets created_at + * + * @return \DateTime|null + */ + public function getCreatedAt() + { + return $this->container['created_at']; + } + + /** + * Sets created_at + * + * @param \DateTime|null $created_at The date and time when this transaction was created in our system. + * + * @return self + */ + public function setCreatedAt($created_at) + { + $this->container['created_at'] = $created_at; + + return $this; + } + + /** + * Gets external_identifier + * + * @return string|null + */ + public function getExternalIdentifier() + { + return $this->container['external_identifier']; + } + + /** + * Sets external_identifier + * + * @param string|null $external_identifier An external identifier that can be used to match the transaction against your own records. + * + * @return self + */ + public function setExternalIdentifier($external_identifier) + { + $this->container['external_identifier'] = $external_identifier; + + return $this; + } + + /** + * Gets updated_at + * + * @return \DateTime|null + */ + public function getUpdatedAt() + { + return $this->container['updated_at']; + } + + /** + * Sets updated_at + * + * @param \DateTime|null $updated_at Defines when the transaction was last updated. + * + * @return self + */ + public function setUpdatedAt($updated_at) + { + $this->container['updated_at'] = $updated_at; + + return $this; + } + + /** + * Gets payment_service + * + * @return \Gr4vy\model\PaymentMethodTokenPaymentService|null + */ + public function getPaymentService() + { + return $this->container['payment_service']; + } + + /** + * Sets payment_service + * + * @param \Gr4vy\model\PaymentMethodTokenPaymentService|null $payment_service payment_service + * + * @return self + */ + public function setPaymentService($payment_service) + { + $this->container['payment_service'] = $payment_service; + + return $this; + } + + /** + * Gets method + * + * @return string|null + */ + public function getMethod() + { + return $this->container['method']; + } + + /** + * Sets method + * + * @param string|null $method method + * + * @return self + */ + public function setMethod($method) + { + $allowedValues = $this->getMethodAllowableValues(); + if (!is_null($method) && !in_array($method, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'method', must be one of '%s'", + $method, + implode("', '", $allowedValues) + ) + ); + } + $this->container['method'] = $method; + + return $this; + } + + /** + * Gets raw_response_code + * + * @return string|null + */ + public function getRawResponseCode() + { + return $this->container['raw_response_code']; + } + + /** + * Sets raw_response_code + * + * @param string|null $raw_response_code This is the response code received from the payment service. This can be set to any value and is not standardized across different payment services. + * + * @return self + */ + public function setRawResponseCode($raw_response_code) + { + $this->container['raw_response_code'] = $raw_response_code; + + return $this; + } + + /** + * Gets raw_response_description + * + * @return string|null + */ + public function getRawResponseDescription() + { + return $this->container['raw_response_description']; + } + + /** + * Sets raw_response_description + * + * @param string|null $raw_response_description This is the response description received from the payment service. This can be set to any value and is not standardized across different payment services. + * + * @return self + */ + public function setRawResponseDescription($raw_response_description) + { + $this->container['raw_response_description'] = $raw_response_description; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/Transactions.php b/lib/model/Transactions.php new file mode 100644 index 0000000..bb73359 --- /dev/null +++ b/lib/model/Transactions.php @@ -0,0 +1,460 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class Transactions implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'Transactions'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'items' => '\Gr4vy\model\TransactionSummary[]', + 'limit' => 'int', + 'next_cursor' => 'string', + 'previous_cursor' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'items' => null, + 'limit' => 'int32', + 'next_cursor' => null, + 'previous_cursor' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'items' => 'items', + 'limit' => 'limit', + 'next_cursor' => 'next_cursor', + 'previous_cursor' => 'previous_cursor' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'items' => 'setItems', + 'limit' => 'setLimit', + 'next_cursor' => 'setNextCursor', + 'previous_cursor' => 'setPreviousCursor' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'items' => 'getItems', + 'limit' => 'getLimit', + 'next_cursor' => 'getNextCursor', + 'previous_cursor' => 'getPreviousCursor' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['items'] = $data['items'] ?? null; + $this->container['limit'] = $data['limit'] ?? 20; + $this->container['next_cursor'] = $data['next_cursor'] ?? null; + $this->container['previous_cursor'] = $data['previous_cursor'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['limit']) && ($this->container['limit'] > 500)) { + $invalidProperties[] = "invalid value for 'limit', must be smaller than or equal to 500."; + } + + if (!is_null($this->container['limit']) && ($this->container['limit'] < 1)) { + $invalidProperties[] = "invalid value for 'limit', must be bigger than or equal to 1."; + } + + if (!is_null($this->container['next_cursor']) && (mb_strlen($this->container['next_cursor']) > 1000)) { + $invalidProperties[] = "invalid value for 'next_cursor', the character length must be smaller than or equal to 1000."; + } + + if (!is_null($this->container['next_cursor']) && (mb_strlen($this->container['next_cursor']) < 1)) { + $invalidProperties[] = "invalid value for 'next_cursor', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['previous_cursor']) && (mb_strlen($this->container['previous_cursor']) > 1000)) { + $invalidProperties[] = "invalid value for 'previous_cursor', the character length must be smaller than or equal to 1000."; + } + + if (!is_null($this->container['previous_cursor']) && (mb_strlen($this->container['previous_cursor']) < 1)) { + $invalidProperties[] = "invalid value for 'previous_cursor', the character length must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets items + * + * @return \Gr4vy\model\TransactionSummary[]|null + */ + public function getItems() + { + return $this->container['items']; + } + + /** + * Sets items + * + * @param \Gr4vy\model\TransactionSummary[]|null $items A list of transactions. + * + * @return self + */ + public function setItems($items) + { + $this->container['items'] = $items; + + return $this; + } + + /** + * Gets limit + * + * @return int|null + */ + public function getLimit() + { + return $this->container['limit']; + } + + /** + * Sets limit + * + * @param int|null $limit The limit applied to request. This represents the number of items that are at maximum returned by this request. + * + * @return self + */ + public function setLimit($limit) + { + + if (!is_null($limit) && ($limit > 500)) { + throw new \InvalidArgumentException('invalid value for $limit when calling Transactions., must be smaller than or equal to 500.'); + } + if (!is_null($limit) && ($limit < 1)) { + throw new \InvalidArgumentException('invalid value for $limit when calling Transactions., must be bigger than or equal to 1.'); + } + + $this->container['limit'] = $limit; + + return $this; + } + + /** + * Gets next_cursor + * + * @return string|null + */ + public function getNextCursor() + { + return $this->container['next_cursor']; + } + + /** + * Sets next_cursor + * + * @param string|null $next_cursor The cursor that represents the next page of results. Use the `cursor` query parameter to fetch this page of items. + * + * @return self + */ + public function setNextCursor($next_cursor) + { + if (!is_null($next_cursor) && (mb_strlen($next_cursor) > 1000)) { + throw new \InvalidArgumentException('invalid length for $next_cursor when calling Transactions., must be smaller than or equal to 1000.'); + } + if (!is_null($next_cursor) && (mb_strlen($next_cursor) < 1)) { + throw new \InvalidArgumentException('invalid length for $next_cursor when calling Transactions., must be bigger than or equal to 1.'); + } + + $this->container['next_cursor'] = $next_cursor; + + return $this; + } + + /** + * Gets previous_cursor + * + * @return string|null + */ + public function getPreviousCursor() + { + return $this->container['previous_cursor']; + } + + /** + * Sets previous_cursor + * + * @param string|null $previous_cursor The cursor that represents the next page of results. Use the `cursor` query parameter to fetch this page of items. + * + * @return self + */ + public function setPreviousCursor($previous_cursor) + { + if (!is_null($previous_cursor) && (mb_strlen($previous_cursor) > 1000)) { + throw new \InvalidArgumentException('invalid length for $previous_cursor when calling Transactions., must be smaller than or equal to 1000.'); + } + if (!is_null($previous_cursor) && (mb_strlen($previous_cursor) < 1)) { + throw new \InvalidArgumentException('invalid length for $previous_cursor when calling Transactions., must be bigger than or equal to 1.'); + } + + $this->container['previous_cursor'] = $previous_cursor; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/TransactionsBatchCaptureRequest.php b/lib/model/TransactionsBatchCaptureRequest.php new file mode 100644 index 0000000..679784d --- /dev/null +++ b/lib/model/TransactionsBatchCaptureRequest.php @@ -0,0 +1,439 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class TransactionsBatchCaptureRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'TransactionsBatchCaptureRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'amount' => 'int', + 'currency' => 'string', + 'external_identifier' => 'string', + 'transaction_id' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'amount' => null, + 'currency' => null, + 'external_identifier' => null, + 'transaction_id' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'amount' => 'amount', + 'currency' => 'currency', + 'external_identifier' => 'external_identifier', + 'transaction_id' => 'transaction_id' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'amount' => 'setAmount', + 'currency' => 'setCurrency', + 'external_identifier' => 'setExternalIdentifier', + 'transaction_id' => 'setTransactionId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'amount' => 'getAmount', + 'currency' => 'getCurrency', + 'external_identifier' => 'getExternalIdentifier', + 'transaction_id' => 'getTransactionId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['amount'] = $data['amount'] ?? null; + $this->container['currency'] = $data['currency'] ?? null; + $this->container['external_identifier'] = $data['external_identifier'] ?? null; + $this->container['transaction_id'] = $data['transaction_id'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['amount'] === null) { + $invalidProperties[] = "'amount' can't be null"; + } + if (($this->container['amount'] > 99999999)) { + $invalidProperties[] = "invalid value for 'amount', must be smaller than or equal to 99999999."; + } + + if (($this->container['amount'] < 0)) { + $invalidProperties[] = "invalid value for 'amount', must be bigger than or equal to 0."; + } + + if ($this->container['currency'] === null) { + $invalidProperties[] = "'currency' can't be null"; + } + if ($this->container['transaction_id'] === null) { + $invalidProperties[] = "'transaction_id' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets amount + * + * @return int + */ + public function getAmount() + { + return $this->container['amount']; + } + + /** + * Sets amount + * + * @param int $amount The (partial) amount to capture. When left blank, this will capture the entire amount. + * + * @return self + */ + public function setAmount($amount) + { + + if (($amount > 99999999)) { + throw new \InvalidArgumentException('invalid value for $amount when calling TransactionsBatchCaptureRequest., must be smaller than or equal to 99999999.'); + } + if (($amount < 0)) { + throw new \InvalidArgumentException('invalid value for $amount when calling TransactionsBatchCaptureRequest., must be bigger than or equal to 0.'); + } + + $this->container['amount'] = $amount; + + return $this; + } + + /** + * Gets currency + * + * @return string + */ + public function getCurrency() + { + return $this->container['currency']; + } + + /** + * Sets currency + * + * @param string $currency A supported ISO-4217 currency code. + * + * @return self + */ + public function setCurrency($currency) + { + $this->container['currency'] = $currency; + + return $this; + } + + /** + * Gets external_identifier + * + * @return string|null + */ + public function getExternalIdentifier() + { + return $this->container['external_identifier']; + } + + /** + * Sets external_identifier + * + * @param string|null $external_identifier An external identifier that can be used to match the transaction against your own records. + * + * @return self + */ + public function setExternalIdentifier($external_identifier) + { + $this->container['external_identifier'] = $external_identifier; + + return $this; + } + + /** + * Gets transaction_id + * + * @return string + */ + public function getTransactionId() + { + return $this->container['transaction_id']; + } + + /** + * Sets transaction_id + * + * @param string $transaction_id The ID of the transaction to capture. + * + * @return self + */ + public function setTransactionId($transaction_id) + { + $this->container['transaction_id'] = $transaction_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/model/UserRequest.php b/lib/model/UserRequest.php new file mode 100644 index 0000000..44274b0 --- /dev/null +++ b/lib/model/UserRequest.php @@ -0,0 +1,384 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class UserRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UserRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'display_name' => 'string', + 'email_address' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'display_name' => null, + 'email_address' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'display_name' => 'display_name', + 'email_address' => 'email_address' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'display_name' => 'setDisplayName', + 'email_address' => 'setEmailAddress' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'display_name' => 'getDisplayName', + 'email_address' => 'getEmailAddress' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['display_name'] = $data['display_name'] ?? null; + $this->container['email_address'] = $data['email_address'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['display_name']) && (mb_strlen($this->container['display_name']) > 1000)) { + $invalidProperties[] = "invalid value for 'display_name', the character length must be smaller than or equal to 1000."; + } + + if (!is_null($this->container['display_name']) && (mb_strlen($this->container['display_name']) < 1)) { + $invalidProperties[] = "invalid value for 'display_name', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['email_address']) && (mb_strlen($this->container['email_address']) > 200)) { + $invalidProperties[] = "invalid value for 'email_address', the character length must be smaller than or equal to 200."; + } + + if (!is_null($this->container['email_address']) && (mb_strlen($this->container['email_address']) < 1)) { + $invalidProperties[] = "invalid value for 'email_address', the character length must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets display_name + * + * @return string|null + */ + public function getDisplayName() + { + return $this->container['display_name']; + } + + /** + * Sets display_name + * + * @param string|null $display_name An external identifier that can be used to match the buyer against your own records. This value needs to be unique for all buyers. + * + * @return self + */ + public function setDisplayName($display_name) + { + if (!is_null($display_name) && (mb_strlen($display_name) > 1000)) { + throw new \InvalidArgumentException('invalid length for $display_name when calling UserRequest., must be smaller than or equal to 1000.'); + } + if (!is_null($display_name) && (mb_strlen($display_name) < 1)) { + throw new \InvalidArgumentException('invalid length for $display_name when calling UserRequest., must be bigger than or equal to 1.'); + } + + $this->container['display_name'] = $display_name; + + return $this; + } + + /** + * Gets email_address + * + * @return string|null + */ + public function getEmailAddress() + { + return $this->container['email_address']; + } + + /** + * Sets email_address + * + * @param string|null $email_address A unique name for this buyer which is used in the Gr4vy admin panel to give a buyer a human readable name. + * + * @return self + */ + public function setEmailAddress($email_address) + { + if (!is_null($email_address) && (mb_strlen($email_address) > 200)) { + throw new \InvalidArgumentException('invalid length for $email_address when calling UserRequest., must be smaller than or equal to 200.'); + } + if (!is_null($email_address) && (mb_strlen($email_address) < 1)) { + throw new \InvalidArgumentException('invalid length for $email_address when calling UserRequest., must be bigger than or equal to 1.'); + } + + $this->container['email_address'] = $email_address; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/openapi-generator-generate.sh b/openapi-generator-generate.sh new file mode 100755 index 0000000..bad03fd --- /dev/null +++ b/openapi-generator-generate.sh @@ -0,0 +1,12 @@ +rm -rf lib/api lib/model +docker run --rm \ + -v ${PWD}:/local openapitools/openapi-generator-cli:v6.0.0 generate \ + -i https://raw.githubusercontent.com/gr4vy/gr4vy-openapi/sdks/openapi.v1.json \ + -g php \ + --git-user-id gr4vy \ + --git-repo-id gr4vy-php \ + --enable-post-process-file \ + -o /local \ + -c /local/.openapi-generator-config.json + +sh ./.openapi-generator/replace.sh \ No newline at end of file diff --git a/phpunit.xml.dist b/phpunit.xml.dist index edf38f0..a0d2107 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -2,12 +2,14 @@ - ./lib + ./lib/api + ./lib/model ./test/Api + ./test/Model diff --git a/test/Api/BuyersApiTest.php b/test/Api/BuyersApiTest.php index f675a21..4cbaeea 100644 --- a/test/Api/BuyersApiTest.php +++ b/test/Api/BuyersApiTest.php @@ -29,6 +29,11 @@ namespace Gr4vy\Test\Api; use \Gr4vy\Gr4vyConfig; +use \Gr4vy\Api\BuyersApi; +use \Gr4vy\Configuration; +use \Gr4vy\ApiException; +use \Gr4vy\ObjectSerializer; +use \GuzzleHttp\Client; use PHPUnit\Framework\TestCase; /** @@ -82,13 +87,15 @@ public function testAddBuyer() { try { $config = new Gr4vyConfig(self::$gr4vyId, self::$privateKeyLocation); + $apiInstance = new BuyersApi(new Client(),$config->getConfig()); + $buyer_request = array("external_identifier"=>"testAddBuyer2","display_name"=>"🐶"); - $result = $config->addBuyer($buyer_request); + $result = $apiInstance->addBuyer($buyer_request); $this->assertArrayHasKey("id", $result); - $this->assertEquals($result["display_name"], "🐶"); + $this->assertEquals($result->getDisplayName(), "🐶"); - $result = $config->deleteBuyer($result["id"]); - $this->assertArrayHasKey("success", $result); + $result = $apiInstance->deleteBuyer($result->getId()); + $this->assertEmpty($result); } catch (Exception $e) { $this->fail("Exception thrown: " . $e->getMessage()); } @@ -104,13 +111,14 @@ public function testDeleteBuyer() { try { $config = new Gr4vyConfig(self::$gr4vyId, self::$privateKeyLocation); - $buyer_request = array("external_identifier"=>"testAddBuyer2","display_name"=>"Tester T."); - $result = $config->addBuyer($buyer_request); + $apiInstance = new BuyersApi(new Client(),$config->getConfig()); + + $buyer_request = array("external_identifier"=>"testDeleteBuyer","display_name"=>"Tester T."); + $result = $apiInstance->addBuyer($buyer_request); $this->assertArrayHasKey("id", $result); - $this->assertEquals($result["display_name"], "Tester T."); - $result = $config->deleteBuyer($result["id"]); - $this->assertArrayHasKey("success", $result); + $result = $apiInstance->deleteBuyer($result->getId()); + $this->assertEmpty($result); } catch (Exception $e) { $this->fail("Exception thrown: " . $e->getMessage()); @@ -127,16 +135,17 @@ public function testGetBuyer() { try { $config = new Gr4vyConfig(self::$gr4vyId, self::$privateKeyLocation); + $apiInstance = new BuyersApi(new Client(),$config->getConfig()); - $buyer_request = array("external_identifier"=>"testAddBuyer2","display_name"=>"Tester T."); - $result = $config->addBuyer($buyer_request); + $buyer_request = array("external_identifier"=>"testDeleteBuyer","display_name"=>"Tester T."); + $result = $apiInstance->addBuyer($buyer_request); $this->assertArrayHasKey("id", $result); - $result = $config->getBuyer($result["id"]); + $result = $apiInstance->getBuyer($result["id"]); $this->assertArrayHasKey("id", $result); - $result = $config->deleteBuyer($result["id"]); - $this->assertArrayHasKey("success", $result); + $result = $apiInstance->deleteBuyer($result->getId()); + $this->assertEmpty($result); } catch (Exception $e) { $this->fail("Exception thrown: " . $e->getMessage()); @@ -154,10 +163,12 @@ public function testListBuyers() try { $config = new Gr4vyConfig(self::$gr4vyId, self::$privateKeyLocation); - $result = $config->listBuyers(); - $this->assertGreaterThan(0, count($result["items"]), "Expected items to be greater than 0."); + $apiInstance = new BuyersApi(new Client(),$config->getConfig()); + $result = $apiInstance->listBuyers(); + $this->assertGreaterThan(0, count($result->getItems()), "Expected items to be greater than 0."); } catch (Exception $e) { $this->fail("Exception thrown: " . $e->getMessage()); + // echo 'Exception when calling BuyersApi->listBuyers: ', $e->getMessage(), PHP_EOL; } } @@ -171,18 +182,18 @@ public function testUpdateBuyer() { try { $config = new Gr4vyConfig(self::$gr4vyId, self::$privateKeyLocation); + $apiInstance = new BuyersApi(new Client(),$config->getConfig()); + + $buyer_request = array("external_identifier"=>"testAddBuyer3","display_name"=>"abc"); + $result = $apiInstance->addBuyer($buyer_request); - $buyer_request = array("external_identifier"=>"testAddBuyer6","display_name"=>"abc"); - $result = $config->addBuyer($buyer_request); - print_r($result); - $buyer_update = array("external_identifier"=>"testUpdateBuyer6"); - $result = $config->updateBuyer($result["id"], $buyer_update); - print_r($result); + $buyer_update = array("external_identifier"=>"testUpdateBuyer"); + $result = $apiInstance->updateBuyer($result->getId(), $buyer_update); $this->assertArrayHasKey("id", $result); - $this->assertEquals($result["external_identifier"], "testUpdateBuyer6"); + $this->assertEquals($result->getExternalIdentifier(), "testUpdateBuyer"); - $result = $config->deleteBuyer($result["id"]); - $this->assertArrayHasKey("success", $result); + $result = $apiInstance->deleteBuyer($result->getId()); + $this->assertEmpty($result); } catch (Exception $e) { $this->fail("Exception thrown: " . $e->getMessage()); } diff --git a/test/Api/MerchantAccountTest.php b/test/Api/MerchantAccountTest.php index 7ff779f..1120991 100644 --- a/test/Api/MerchantAccountTest.php +++ b/test/Api/MerchantAccountTest.php @@ -29,8 +29,15 @@ namespace Gr4vy\Test\Api; use \Gr4vy\Gr4vyConfig; +use \Gr4vy\Api\BuyersApi; +use \Gr4vy\Configuration; +use \Gr4vy\ApiException; +use \Gr4vy\ObjectSerializer; +use \GuzzleHttp\Client; use PHPUnit\Framework\TestCase; +use \Gr4vy\MerchantAccountHeaderSelector; + /** * BuyersApiTest Class Doc Comment @@ -83,9 +90,11 @@ public function testListBuyers() { try { - $config = new Gr4vyConfig(self::$gr4vyId, self::$privateKeyLocation, false, "sandbox", "default"); - $result = $config->listBuyers(); - $this->assertGreaterThan(0, count($result["items"]), "Expected items to be greater than 0."); + $headerSelector = new MerchantAccountHeaderSelector("default"); + $config = new Gr4vyConfig(self::$gr4vyId, self::$privateKeyLocation); + $apiInstance = new BuyersApi(new Client(),$config->getConfig(), $headerSelector); + $result = $apiInstance->listBuyers(); + $this->assertGreaterThan(0, count($result->getItems()), "Expected items to be greater than 0."); } catch (Exception $e) { $this->fail("Exception thrown: " . $e->getMessage()); // echo 'Exception when calling BuyersApi->listBuyers: ', $e->getMessage(), PHP_EOL; diff --git a/test/Api/PaymentMethodsApiTest.php b/test/Api/PaymentMethodsApiTest.php index 8db6845..c25c677 100644 --- a/test/Api/PaymentMethodsApiTest.php +++ b/test/Api/PaymentMethodsApiTest.php @@ -29,6 +29,11 @@ namespace Gr4vy\Test\Api; use \Gr4vy\Gr4vyConfig; +use \Gr4vy\Api\PaymentMethodsApi; +use \GuzzleHttp\Client; +use \Gr4vy\Configuration; +use \Gr4vy\ApiException; +use \Gr4vy\ObjectSerializer; use PHPUnit\Framework\TestCase; /** @@ -82,18 +87,20 @@ public function testDeletePaymentMethod() { try { $config = new Gr4vyConfig(self::$gr4vyId, self::$privateKeyLocation); + $apiInstance = new PaymentMethodsApi(new Client(),$config->getConfig()); + $payment_method_request = array( "method"=>"card", "number"=>"4111111111111111", "expiration_date"=>"11/25", "security_code"=>"123" ); - $result = $config->storePaymentMethod($payment_method_request); + $result = $apiInstance->storePaymentMethod($payment_method_request); $this->assertArrayHasKey("id", $result); - $this->assertEquals($result["method"], "card"); + $this->assertEquals($result->getMethod(), "card"); - $result = $config->deletePaymentMethod($result["id"]); - $this->assertArrayHasKey("success", $result); + $result = $apiInstance->deletePaymentMethod($result->getId()); + $this->assertEmpty($result); } catch (Exception $e) { $this->fail("Exception thrown: " . $e->getMessage()); } @@ -109,6 +116,7 @@ public function testGetPaymentMethod() { try { $config = new Gr4vyConfig(self::$gr4vyId, self::$privateKeyLocation); + $apiInstance = new PaymentMethodsApi(new Client(),$config->getConfig()); $payment_method_request = array( "method"=>"card", @@ -116,14 +124,15 @@ public function testGetPaymentMethod() "expiration_date"=>"11/25", "security_code"=>"123" ); - $result = $config->storePaymentMethod($payment_method_request); + $result = $apiInstance->storePaymentMethod($payment_method_request); $this->assertArrayHasKey("id", $result); + $this->assertEquals($result->getMethod(), "card"); - $result = $config->getPaymentMethod($result["id"]); + $result = $apiInstance->getPaymentMethod($result["id"]); $this->assertArrayHasKey("id", $result); - $result = $config->deletePaymentMethod($result["id"]); - $this->assertArrayHasKey("success", $result); + $result = $apiInstance->deletePaymentMethod($result->getId()); + $this->assertEmpty($result); } catch (Exception $e) { $this->fail("Exception thrown: " . $e->getMessage()); } @@ -137,11 +146,11 @@ public function testGetPaymentMethod() */ public function testListBuyerPaymentMethods() { - $this->markTestIncomplete('Not implemented'); try { $config = new Gr4vyConfig(self::$gr4vyId, self::$privateKeyLocation); - $result = $config->listBuyerPaymentMethods("baa7b3b3-a4f1-49e3-afb0-0f41b48f5aa2"); - $this->assertNotNull($result["items"]); + $apiInstance = new PaymentMethodsApi(new Client(),$config->getConfig()); + $result = $apiInstance->listBuyerPaymentMethods("baa7b3b3-a4f1-49e3-afb0-0f41b48f5aa2"); + $this->assertNotNull($result->getItems()); } catch (Exception $e) { $this->fail("Exception thrown: " . $e->getMessage()); @@ -156,11 +165,12 @@ public function testListBuyerPaymentMethods() */ public function testListPaymentMethods() { - // $this->markTestIncomplete('Not implemented'); + $this->markTestIncomplete('Not implemented'); try { $config = new Gr4vyConfig(self::$gr4vyId, self::$privateKeyLocation); - $result = $config->listPaymentMethods(); - $this->assertGreaterThan(0, count($result["items"]), "Expected items to be greater than 0."); + $apiInstance = new PaymentMethodsApi(new Client(),$config->getConfig()); + $result = $apiInstance->listPaymentMethods(); + $this->assertGreaterThan(0, count($result->getItems()), "Expected items to be greater than 0."); } catch (Exception $e) { $this->fail("Exception thrown: " . $e->getMessage()); } @@ -176,6 +186,7 @@ public function testStorePaymentMethod() { try { $config = new Gr4vyConfig(self::$gr4vyId, self::$privateKeyLocation); + $apiInstance = new PaymentMethodsApi(new Client(),$config->getConfig()); $payment_method_request = array( "method"=>"card", @@ -183,12 +194,12 @@ public function testStorePaymentMethod() "expiration_date"=>"11/25", "security_code"=>"123" ); - $result = $config->storePaymentMethod($payment_method_request); + $result = $apiInstance->storePaymentMethod($payment_method_request); $this->assertArrayHasKey("id", $result); - $this->assertEquals($result["method"], "card"); + $this->assertEquals($result->getMethod(), "card"); - $result = $config->deletePaymentMethod($result["id"]); - $this->assertArrayHasKey("success", $result); + $result = $apiInstance->deletePaymentMethod($result->getId()); + $this->assertEmpty($result); } catch (Exception $e) { $this->fail("Exception thrown: " . $e->getMessage()); } diff --git a/test/Api/PaymentOptionsApiTest.php b/test/Api/PaymentOptionsApiTest.php index af85ee6..e357b3b 100644 --- a/test/Api/PaymentOptionsApiTest.php +++ b/test/Api/PaymentOptionsApiTest.php @@ -29,6 +29,11 @@ namespace Gr4vy\Test\Api; use \Gr4vy\Gr4vyConfig; +use \Gr4vy\Api\PaymentOptionsApi; +use \GuzzleHttp\Client; +use \Gr4vy\Configuration; +use \Gr4vy\ApiException; +use \Gr4vy\ObjectSerializer; use PHPUnit\Framework\TestCase; /** @@ -82,35 +87,9 @@ public function testListPaymentOptions() { try { $config = new Gr4vyConfig(self::$gr4vyId, self::$privateKeyLocation); - $result = $config->listPaymentOptions(); - $this->assertGreaterThan(0, count($result["items"]), "Expected items to be greater than 0."); - } catch (Exception $e) { - $this->fail("Exception thrown: " . $e->getMessage()); - } - } - - /** - * Test case for postListPaymentOptions - * - * List payment options. - * - */ - public function testPostListPaymentOptions() - { - try { - $config = new Gr4vyConfig(self::$gr4vyId, self::$privateKeyLocation); - $payment_options_request = array( - "country"=>"US", - "currency"=>"USD", - "amount"=>1000, - "metadata"=>array( - "TypeOfPayment"=>"purchase", - "Carbon_FootPrint"=>"10" - ) - ); - - $result = $config->postListPaymentOptions($payment_options_request); - $this->assertGreaterThan(0, count($result["items"]), "Expected items to be greater than 0."); + $apiInstance = new PaymentOptionsApi(new Client(),$config->getConfig()); + $result = $apiInstance->listPaymentOptions(); + $this->assertGreaterThan(0, count($result->getItems()), "Expected items to be greater than 0."); } catch (Exception $e) { $this->fail("Exception thrown: " . $e->getMessage()); } diff --git a/test/Api/PaymentServiceDefinitionsApiTest.php b/test/Api/PaymentServiceDefinitionsApiTest.php index 8dcc1ab..a1bac4e 100644 --- a/test/Api/PaymentServiceDefinitionsApiTest.php +++ b/test/Api/PaymentServiceDefinitionsApiTest.php @@ -29,6 +29,11 @@ namespace Gr4vy\Test\Api; use \Gr4vy\Gr4vyConfig; +use \Gr4vy\Api\PaymentServiceDefinitionsApi; +use \GuzzleHttp\Client; +use \Gr4vy\Configuration; +use \Gr4vy\ApiException; +use \Gr4vy\ObjectSerializer; use PHPUnit\Framework\TestCase; /** @@ -82,10 +87,11 @@ public function testGetPaymentServiceDefinition() { try { $config = new Gr4vyConfig(self::$gr4vyId, self::$privateKeyLocation); - $result = $config->listPaymentServiceDefinitions(); - $this->assertGreaterThan(0, count($result["items"]), "Expected items to be greater than 0."); + $apiInstance = new PaymentServiceDefinitionsApi(new Client(),$config->getConfig()); + $result = $apiInstance->listPaymentServiceDefinitions(); + $this->assertGreaterThan(0, count($result->getItems()), "Expected items to be greater than 0."); - $result = $config->getPaymentServiceDefinition($result["items"][0]["id"]); + $result = $apiInstance->getPaymentServiceDefinition($result->getItems()[0]["id"]); $this->assertArrayHasKey("id", $result); } catch (Exception $e) { @@ -104,8 +110,9 @@ public function testListPaymentServiceDefinitions() try { $config = new Gr4vyConfig(self::$gr4vyId, self::$privateKeyLocation); - $result = $config->listPaymentServiceDefinitions(); - $this->assertGreaterThan(0, count($result["items"]), "Expected items to be greater than 0."); + $apiInstance = new PaymentServiceDefinitionsApi(new Client(),$config->getConfig()); + $result = $apiInstance->listPaymentServiceDefinitions(); + $this->assertGreaterThan(0, count($result->getItems()), "Expected items to be greater than 0."); } catch (Exception $e) { $this->fail("Exception thrown: " . $e->getMessage()); } diff --git a/test/Api/PaymentServicesApiTest.php b/test/Api/PaymentServicesApiTest.php index faaf774..9447790 100644 --- a/test/Api/PaymentServicesApiTest.php +++ b/test/Api/PaymentServicesApiTest.php @@ -29,6 +29,11 @@ namespace Gr4vy\Test\Api; use \Gr4vy\Gr4vyConfig; +use \Gr4vy\Api\PaymentServicesApi; +use \GuzzleHttp\Client; +use \Gr4vy\Configuration; +use \Gr4vy\ApiException; +use \Gr4vy\ObjectSerializer; use PHPUnit\Framework\TestCase; /** @@ -82,6 +87,7 @@ public function testAddPaymentService() { try { $config = new Gr4vyConfig(self::$gr4vyId, self::$privateKeyLocation); + $apiInstance = new PaymentServicesApi(new Client(),$config->getConfig()); $payment_service_request = array( "accepted_countries"=>array("GB", "US"), @@ -95,13 +101,13 @@ public function testAddPaymentService() ), "payment_service_definition_id" => "stripe-card" ); - $result = $config->addPaymentService($payment_service_request); + $result = $apiInstance->addPaymentService($payment_service_request); $this->assertArrayHasKey("id", $result); - $this->assertEquals($result["payment_service_definition_id"], "stripe-card"); + $this->assertEquals($result->getPaymentServiceDefinitionId(), "stripe-card"); - $result = $config->deletePaymentService($result["id"]); - $this->assertArrayHasKey("success", $result); + $result = $apiInstance->deletePaymentService($result->getId()); + $this->assertEmpty($result); } catch (Exception $e) { $this->fail("Exception thrown: " . $e->getMessage()); } @@ -117,6 +123,7 @@ public function testDeletePaymentService() { try { $config = new Gr4vyConfig(self::$gr4vyId, self::$privateKeyLocation); + $apiInstance = new PaymentServicesApi(new Client(),$config->getConfig()); $payment_service_request = array( "accepted_countries"=>array("GB", "US"), @@ -130,12 +137,13 @@ public function testDeletePaymentService() ), "payment_service_definition_id" => "stripe-card" ); - $result = $config->addPaymentService($payment_service_request); + $result = $apiInstance->addPaymentService($payment_service_request); $this->assertArrayHasKey("id", $result); + $this->assertEquals($result->getPaymentServiceDefinitionId(), "stripe-card"); - $result = $config->deletePaymentService($result["id"]); - $this->assertArrayHasKey("success", $result); + $result = $apiInstance->deletePaymentService($result->getId()); + $this->assertEmpty($result); } catch (Exception $e) { $this->fail("Exception thrown: " . $e->getMessage()); } @@ -151,6 +159,7 @@ public function testGetPaymentService() { try { $config = new Gr4vyConfig(self::$gr4vyId, self::$privateKeyLocation); + $apiInstance = new PaymentServicesApi(new Client(),$config->getConfig()); $payment_service_request = array( "accepted_countries"=>array("GB", "US"), @@ -164,15 +173,16 @@ public function testGetPaymentService() ), "payment_service_definition_id" => "stripe-card" ); - $result = $config->addPaymentService($payment_service_request); + $result = $apiInstance->addPaymentService($payment_service_request); $this->assertArrayHasKey("id", $result); + $this->assertEquals($result->getPaymentServiceDefinitionId(), "stripe-card"); - $result = $config->getPaymentService($result["id"]); + $result = $apiInstance->getPaymentService($result["id"]); $this->assertArrayHasKey("id", $result); - $result = $config->deletePaymentService($result["id"]); - $this->assertArrayHasKey("success", $result); + $result = $apiInstance->deletePaymentService($result->getId()); + $this->assertEmpty($result); } catch (Exception $e) { $this->fail("Exception thrown: " . $e->getMessage()); } @@ -188,8 +198,9 @@ public function testListPaymentServices() { try { $config = new Gr4vyConfig(self::$gr4vyId, self::$privateKeyLocation); - $result = $config->listPaymentServices(); - $this->assertGreaterThan(0, count($result["items"]), "Expected items to be greater than 0."); + $apiInstance = new PaymentServicesApi(new Client(),$config->getConfig()); + $result = $apiInstance->listPaymentServices(); + $this->assertGreaterThan(0, count($result->getItems()), "Expected items to be greater than 0."); } catch (Exception $e) { $this->fail("Exception thrown: " . $e->getMessage()); } @@ -205,6 +216,7 @@ public function testUpdatePaymentService() { try { $config = new Gr4vyConfig(self::$gr4vyId, self::$privateKeyLocation); + $apiInstance = new PaymentServicesApi(new Client(),$config->getConfig()); $payment_service_request = array( "accepted_countries"=>array("GB", "US"), @@ -218,19 +230,20 @@ public function testUpdatePaymentService() ), "payment_service_definition_id" => "stripe-card" ); - $result = $config->addPaymentService($payment_service_request); + $result = $apiInstance->addPaymentService($payment_service_request); $this->assertArrayHasKey("id", $result); + $this->assertEquals($result->getPaymentServiceDefinitionId(), "stripe-card"); $payment_service_update = array( "display_name" => "Stripe Update", ); - $result = $config->updatePaymentService($result["id"], $payment_service_update); + $result = $apiInstance->updatePaymentService($result["id"], $payment_service_update); $this->assertArrayHasKey("id", $result); - $this->assertEquals($result["display_name"], "Stripe Update"); + $this->assertEquals($result->getDisplayName(), "Stripe Update"); - $result = $config->deletePaymentService($result["id"]); - $this->assertArrayHasKey("success", $result); + $result = $apiInstance->deletePaymentService($result->getId()); + $this->assertEmpty($result); } catch (Exception $e) { $this->fail("Exception thrown: " . $e->getMessage()); } diff --git a/test/Api/ReportsApiTest.php b/test/Api/ReportsApiTest.php deleted file mode 100644 index e29b518..0000000 --- a/test/Api/ReportsApiTest.php +++ /dev/null @@ -1,92 +0,0 @@ -generateReportDownloadUrl("5e7882ac-1bda-413f-9e78-4fcf650657da", "83770ad3-2465-4a74-8bd4-3aa80849cf4b"); - $this->assertArrayHasKey("url", $result); - } catch (Exception $e) { - $this->fail("Exception thrown: " . $e->getMessage()); - } - } - -} diff --git a/test/Api/TokenApiTest.php b/test/Api/TokenApiTest.php index 0f861dc..c5614ed 100644 --- a/test/Api/TokenApiTest.php +++ b/test/Api/TokenApiTest.php @@ -3,6 +3,8 @@ namespace Gr4vy\Test\Api; use \Gr4vy\Gr4vyConfig; +use \Gr4vy\Api\BuyersApi; +use \GuzzleHttp\Client; use PHPUnit\Framework\TestCase; class TokenApiTest extends TestCase @@ -61,51 +63,23 @@ public function testGetEmbedToken() } } - public function testGetEmbedTokenWithCheckoutSessionPassedIn() - { - try { - $config = new Gr4vyConfig(self::$gr4vyId, self::$privateKeyLocation); - $checkoutSession = $config->newCheckoutSession(); - - $embed = array("amount"=> 200, "currency" => "USD", "buyer_id"=> "d757c76a-cbd7-4b56-95a3-40125b51b29c"); - $embedToken = $config->getEmbedToken($embed, $checkoutSession["id"]); - - $this->assertGreaterThan(0, strlen($embedToken), "Expected length to be greater than 0."); - } catch (Exception $e) { - $this->fail("Exception thrown: " . $e->getMessage()); - } - } - - public function testGetEmbedTokenWithCheckoutSession() - { - try { - $config = new Gr4vyConfig(self::$gr4vyId, self::$privateKeyLocation); - - $embed = array("amount"=> 200, "currency" => "USD", "buyer_id"=> "d757c76a-cbd7-4b56-95a3-40125b51b29c"); - $embedToken = $config->getEmbedTokenWithCheckoutSession($embed); - - $this->assertGreaterThan(0, strlen($embedToken), "Expected length to be greater than 0."); - } catch (Exception $e) { - $this->fail("Exception thrown: " . $e->getMessage()); - } - } - public function testAddBuyerAndEmbed() { try { $config = new Gr4vyConfig(self::$gr4vyId, self::$privateKeyLocation); + $apiInstance = new BuyersApi(new Client(),$config->getConfig()); - $buyer_request = array("display_name"=>"Tester T."); - $result = $config->addBuyer($buyer_request); + $buyer_request = array("external_identifier"=>"412231123","display_name"=>"Tester T."); + $result = $apiInstance->addBuyer($buyer_request); $this->assertArrayHasKey("id", $result); - $embed = array("amount"=> 200, "currency" => "USD", "buyer_id"=> $result["id"]); + $embed = array("amount"=> 200, "currency" => "USD", "buyer_id"=> $result->getId()); $embedToken = $config->getEmbedToken($embed); $this->assertGreaterThan(0, strlen($embedToken), "Expected length to be greater than 0."); - $result = $config->deleteBuyer($result["id"]); - $this->assertArrayHasKey("success", $result); + $result = $apiInstance->deleteBuyer($result->getId()); + $this->assertEmpty($result); } catch (Exception $e) { $this->fail("Exception thrown: " . $e->getMessage()); diff --git a/test/Api/TransactionsApiTest.php b/test/Api/TransactionsApiTest.php index 18fcf12..ddeeee6 100644 --- a/test/Api/TransactionsApiTest.php +++ b/test/Api/TransactionsApiTest.php @@ -29,6 +29,11 @@ namespace Gr4vy\Test\Api; use \Gr4vy\Gr4vyConfig; +use \Gr4vy\Api\TransactionsApi; +use \GuzzleHttp\Client; +use \Gr4vy\Configuration; +use \Gr4vy\ApiException; +use \Gr4vy\ObjectSerializer; use PHPUnit\Framework\TestCase; /** @@ -82,10 +87,12 @@ public function testAuthorizeNewTransaction() { try { $config = new Gr4vyConfig(self::$gr4vyId, self::$privateKeyLocation); + $apiInstance = new TransactionsApi(new Client(),$config->getConfig()); + //TODO: GBP/braintree was failing $transaction_request = array("amount"=>1000,"currency"=>"USD", "payment_method"=>array("method"=>"card", "number"=>"4111111111111111", "expiration_date"=> "01/24", "security_code"=>"432")); - $result = $config->authorizeNewTransaction($transaction_request); + $result = $apiInstance->authorizeNewTransaction($transaction_request); $this->assertArrayHasKey("id", $result); - $this->assertEquals($result["type"], "transaction"); + $this->assertEquals($result->getType(), "transaction"); } catch (Exception $e) { $this->fail("Exception thrown: " . $e->getMessage()); } @@ -99,18 +106,19 @@ public function testAuthorizeNewTransaction() */ public function testCaptureTransaction() { + $this->markTestIncomplete('Not implemented'); try { $config = new Gr4vyConfig(self::$gr4vyId, self::$privateKeyLocation); - $transaction_request = array("intent"=>"authorize", "amount"=>100,"currency"=>"USD", "payment_method"=>array("method"=>"card", "number"=>"4111111111111111", "expiration_date"=> "01/28", "security_code"=>"555")); - $result = $config->authorizeNewTransaction($transaction_request); + $apiInstance = new TransactionsApi(new Client(),$config->getConfig()); + $transaction_request = array("amount"=>100,"currency"=>"USD", "payment_method"=>array("method"=>"card", "number"=>"4111111111111111", "expiration_date"=> "01/28", "security_code"=>"555")); + $result = $apiInstance->authorizeNewTransaction($transaction_request); $this->assertArrayHasKey("id", $result); - $this->assertEquals($result["type"], "transaction"); + $this->assertEquals($result->getType(), "transaction"); - $capture_request = array("amount"=>100); - $result = $config->captureTransaction($result["id"], $capture_request); + $result = $apiInstance->captureTransaction($result["id"]); $this->assertArrayHasKey("id", $result); - $this->assertEquals($result["type"], "transaction"); + $this->assertEquals($result->getType(), "transaction"); } catch (Exception $e) { $this->fail("Exception thrown: " . $e->getMessage()); } @@ -126,14 +134,15 @@ public function testGetTransaction() { try { $config = new Gr4vyConfig(self::$gr4vyId, self::$privateKeyLocation); + $apiInstance = new TransactionsApi(new Client(),$config->getConfig()); $transaction_request = array("amount"=>10000,"currency"=>"USD", "payment_method"=>array("method"=>"card", "number"=>"4111111111111111", "expiration_date"=> "01/28", "security_code"=>"555")); - $result = $config->authorizeNewTransaction($transaction_request); + $result = $apiInstance->authorizeNewTransaction($transaction_request); $this->assertArrayHasKey("id", $result); - $this->assertEquals($result["type"], "transaction"); + $this->assertEquals($result->getType(), "transaction"); - $result = $config->getTransaction($result["id"]); + $result = $apiInstance->getTransaction($result["id"]); $this->assertArrayHasKey("id", $result); - $this->assertEquals($result["type"], "transaction"); + $this->assertEquals($result->getType(), "transaction"); } catch (Exception $e) { $this->fail("Exception thrown: " . $e->getMessage()); } @@ -149,28 +158,9 @@ public function testListTransactions() { try { $config = new Gr4vyConfig(self::$gr4vyId, self::$privateKeyLocation); - $result = $config->listTransactions(); - $this->assertGreaterThan(0, count($result["items"]), "Expected items to be greater than 0."); - } catch (Exception $e) { - $this->fail("Exception thrown: " . $e->getMessage()); - } - } - - /** - * Test case for listTransactions - * - * List transactions. - * - */ - public function testListTransactionsWithParams() - { - try { - $params = array( - "limit"=>2, - ); - $config = new Gr4vyConfig(self::$gr4vyId, self::$privateKeyLocation); - $result = $config->listTransactions($params); - $this->assertEquals(2, count($result["items"]), "Expected items to be equal to 2."); + $apiInstance = new TransactionsApi(new Client(),$config->getConfig()); + $result = $apiInstance->listTransactions(); + $this->assertGreaterThan(0, count($result->getItems()), "Expected items to be greater than 0."); } catch (Exception $e) { $this->fail("Exception thrown: " . $e->getMessage()); } @@ -184,44 +174,20 @@ public function testListTransactionsWithParams() */ public function testRefundTransaction() { + $this->markTestIncomplete('Not implemented'); try { $config = new Gr4vyConfig(self::$gr4vyId, self::$privateKeyLocation); - $transaction_request = array("amount"=>100,"currency"=>"USD", "intent"=>"capture", "payment_method"=>array("method"=>"card", "number"=>"4111111111111111", "expiration_date"=> "01/28", "security_code"=>"555")); - $result = $config->authorizeNewTransaction($transaction_request); - $this->assertArrayHasKey("id", $result); - $this->assertEquals($result["type"], "transaction"); - - $refund_request = array("amount"=>100); - - $result = $config->refundTransaction($result["id"], $refund_request); - $this->assertArrayHasKey("id", $result); - $this->assertEquals($result["type"], "refund"); - } catch (Exception $e) { - $this->fail("Exception thrown: " . $e->getMessage()); - } - } - - /** - * Test case for voidTransaction - * - * Void transaction. - * - */ - public function testVoidTransaction() - { - - try { - $config = new Gr4vyConfig(self::$gr4vyId, self::$privateKeyLocation); - $transaction_request = array("amount"=>100,"currency"=>"USD", "intent"=>"authorize", "payment_method"=>array("method"=>"card", "number"=>"4111111111111111", "expiration_date"=> "01/28", "security_code"=>"555")); - $result = $config->authorizeNewTransaction($transaction_request); + $apiInstance = new TransactionsApi(new Client(),$config->getConfig()); + $transaction_request = array("amount"=>100,"currency"=>"USD", "payment_method"=>array("method"=>"card", "number"=>"4111111111111111", "expiration_date"=> "01/28", "security_code"=>"555")); + $result = $apiInstance->authorizeNewTransaction($transaction_request); $this->assertArrayHasKey("id", $result); - $this->assertEquals($result["type"], "transaction"); + $this->assertEquals($result->getType(), "transaction"); - $result = $config->voidTransaction($result["id"]); + $result = $apiInstance->refundTransaction($result["id"]); + print_r($result); $this->assertArrayHasKey("id", $result); - $this->assertEquals($result["status"], "authorization_voided"); - // print_r($result); + $this->assertEquals($result->getType(), "transaction"); } catch (Exception $e) { $this->fail("Exception thrown: " . $e->getMessage()); }