diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index dd266405..766808d6 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -20,6 +20,7 @@ docs/Api/LogsApi.md docs/Api/OrdersApi.md docs/Api/PaymentLinkApi.md docs/Api/PaymentMethodsApi.md +docs/Api/PayoutOrdersApi.md docs/Api/PlansApi.md docs/Api/ProductsApi.md docs/Api/ShippingContactsApi.md @@ -153,6 +154,13 @@ docs/Model/PaymentMethodCashResponse.md docs/Model/PaymentMethodResponse.md docs/Model/PaymentMethodSpeiRecurrent.md docs/Model/PaymentMethodSpeiRequest.md +docs/Model/Payout.md +docs/Model/PayoutMethod.md +docs/Model/PayoutOrder.md +docs/Model/PayoutOrderPayoutsItem.md +docs/Model/PayoutOrderResponse.md +docs/Model/PayoutOrderResponseCustomerInfo.md +docs/Model/PayoutOrdersResponse.md docs/Model/PlanRequest.md docs/Model/PlanResponse.md docs/Model/PlanUpdateRequest.md @@ -209,6 +217,7 @@ lib/Api/LogsApi.php lib/Api/OrdersApi.php lib/Api/PaymentLinkApi.php lib/Api/PaymentMethodsApi.php +lib/Api/PayoutOrdersApi.php lib/Api/PlansApi.php lib/Api/ProductsApi.php lib/Api/ShippingContactsApi.php @@ -346,6 +355,13 @@ lib/Model/PaymentMethodCashResponse.php lib/Model/PaymentMethodResponse.php lib/Model/PaymentMethodSpeiRecurrent.php lib/Model/PaymentMethodSpeiRequest.php +lib/Model/Payout.php +lib/Model/PayoutMethod.php +lib/Model/PayoutOrder.php +lib/Model/PayoutOrderPayoutsItem.php +lib/Model/PayoutOrderResponse.php +lib/Model/PayoutOrderResponseCustomerInfo.php +lib/Model/PayoutOrdersResponse.php lib/Model/PlanRequest.php lib/Model/PlanResponse.php lib/Model/PlanUpdateRequest.php @@ -393,3 +409,4 @@ lib/Model/WhitelistlistRuleResponse.php lib/ObjectSerializer.php lib/ssl_data/ca_bundle.crt phpunit.xml.dist +test/Api/PayoutOrdersApiTest.php diff --git a/README.md b/README.md index 37a2e38d..80de88ec 100644 --- a/README.md +++ b/README.md @@ -130,6 +130,9 @@ Class | Method | HTTP request | Description *PaymentMethodsApi* | [**deleteCustomerPaymentMethods**](docs/Api/PaymentMethodsApi.md#deletecustomerpaymentmethods) | **DELETE** /customers/{id}/payment_sources/{payment_method_id} | Delete Payment Method *PaymentMethodsApi* | [**getCustomerPaymentMethods**](docs/Api/PaymentMethodsApi.md#getcustomerpaymentmethods) | **GET** /customers/{id}/payment_sources | Get Payment Methods *PaymentMethodsApi* | [**updateCustomerPaymentMethods**](docs/Api/PaymentMethodsApi.md#updatecustomerpaymentmethods) | **PUT** /customers/{id}/payment_sources/{payment_method_id} | Update Payment Method +*PayoutOrdersApi* | [**createPayoutOrder**](docs/Api/PayoutOrdersApi.md#createpayoutorder) | **POST** /payout_orders | Create payout order +*PayoutOrdersApi* | [**getPayoutOrderById**](docs/Api/PayoutOrdersApi.md#getpayoutorderbyid) | **GET** /payout_orders/{id} | Get Payout Order +*PayoutOrdersApi* | [**getPayoutOrders**](docs/Api/PayoutOrdersApi.md#getpayoutorders) | **GET** /payout_orders | Get a list of Payout Orders *PlansApi* | [**createPlan**](docs/Api/PlansApi.md#createplan) | **POST** /plans | Create Plan *PlansApi* | [**deletePlan**](docs/Api/PlansApi.md#deleteplan) | **DELETE** /plans/{id} | Delete Plan *PlansApi* | [**getPlan**](docs/Api/PlansApi.md#getplan) | **GET** /plans/{id} | Get Plan @@ -295,6 +298,13 @@ Class | Method | HTTP request | Description - [PaymentMethodResponse](docs/Model/PaymentMethodResponse.md) - [PaymentMethodSpeiRecurrent](docs/Model/PaymentMethodSpeiRecurrent.md) - [PaymentMethodSpeiRequest](docs/Model/PaymentMethodSpeiRequest.md) +- [Payout](docs/Model/Payout.md) +- [PayoutMethod](docs/Model/PayoutMethod.md) +- [PayoutOrder](docs/Model/PayoutOrder.md) +- [PayoutOrderPayoutsItem](docs/Model/PayoutOrderPayoutsItem.md) +- [PayoutOrderResponse](docs/Model/PayoutOrderResponse.md) +- [PayoutOrderResponseCustomerInfo](docs/Model/PayoutOrderResponseCustomerInfo.md) +- [PayoutOrdersResponse](docs/Model/PayoutOrdersResponse.md) - [PlanRequest](docs/Model/PlanRequest.md) - [PlanResponse](docs/Model/PlanResponse.md) - [PlanUpdateRequest](docs/Model/PlanUpdateRequest.md) @@ -365,5 +375,5 @@ engineering@conekta.com This PHP package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: - API version: `2.1.0` - - Package version: `6.0.6` + - Package version: `6.0.7` - Build package: `org.openapitools.codegen.languages.PhpClientCodegen` diff --git a/VERSION b/VERSION index b7ff1516..089b1e69 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.0.6 +6.0.7 diff --git a/composer.json b/composer.json index 46ac12f5..a3917f67 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "conekta/conekta-php", - "version": "6.0.6", + "version": "6.0.7", "description": "Conekta PHP Library", "type": "library", "keywords": [ diff --git a/config-php.json b/config-php.json index 89aacf37..24a7bffe 100644 --- a/config-php.json +++ b/config-php.json @@ -1,13 +1,13 @@ { "packageName": "conekta", "generateSourceCodeOnly": "false", - "artifactVersion": "6.0.6", + "artifactVersion": "6.0.7", "packageUrl": "https://developers.conekta.com/", "projectName": "conekta-php", "appDescriptionV2" : "Conekta PHP Library", "useOneOfDiscriminatorLookup" : true, "nonCompliantUseDiscriminatorIfCompositionFails" : false, - "httpUserAgent": "Conekta/v2 PhpBindings/6.0.6", + "httpUserAgent": "Conekta/v2 PhpBindings/6.0.7", "packageAuthors" : "engineering@conekta.com", "files": { "/local/CODE_OF_CONDUCT.md" : {}, diff --git a/docs/Api/PayoutOrdersApi.md b/docs/Api/PayoutOrdersApi.md new file mode 100644 index 00000000..31dc7001 --- /dev/null +++ b/docs/Api/PayoutOrdersApi.md @@ -0,0 +1,202 @@ +# Conekta\PayoutOrdersApi + +All URIs are relative to https://api.conekta.io, except if the operation defines another base path. + +| Method | HTTP request | Description | +| ------------- | ------------- | ------------- | +| [**createPayoutOrder()**](PayoutOrdersApi.md#createPayoutOrder) | **POST** /payout_orders | Create payout order | +| [**getPayoutOrderById()**](PayoutOrdersApi.md#getPayoutOrderById) | **GET** /payout_orders/{id} | Get Payout Order | +| [**getPayoutOrders()**](PayoutOrdersApi.md#getPayoutOrders) | **GET** /payout_orders | Get a list of Payout Orders | + + +## `createPayoutOrder()` + +```php +createPayoutOrder($payout_order, $accept_language): \Conekta\Model\PayoutOrderResponse +``` + +Create payout order + +Create a new payout order. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Conekta\Api\PayoutOrdersApi( + // 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 +); +$payout_order = new \Conekta\Model\PayoutOrder(); // \Conekta\Model\PayoutOrder | requested field for payout order +$accept_language = es; // string | Use for knowing which language to use + +try { + $result = $apiInstance->createPayoutOrder($payout_order, $accept_language); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling PayoutOrdersApi->createPayoutOrder: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +| Name | Type | Description | Notes | +| ------------- | ------------- | ------------- | ------------- | +| **payout_order** | [**\Conekta\Model\PayoutOrder**](../Model/PayoutOrder.md)| requested field for payout order | | +| **accept_language** | **string**| Use for knowing which language to use | [optional] [default to 'es'] | + +### Return type + +[**\Conekta\Model\PayoutOrderResponse**](../Model/PayoutOrderResponse.md) + +### Authorization + +[bearerAuth](../../README.md#bearerAuth) + +### HTTP request headers + +- **Content-Type**: `application/json` +- **Accept**: `application/vnd.conekta-v2.1.0+json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `getPayoutOrderById()` + +```php +getPayoutOrderById($id, $accept_language): \Conekta\Model\PayoutOrderResponse +``` + +Get Payout Order + +Gets a payout Order resource that corresponds to a payout order ID. + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Conekta\Api\PayoutOrdersApi( + // 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 +); +$id = 6307a60c41de27127515a575; // string | Identifier of the resource +$accept_language = es; // string | Use for knowing which language to use + +try { + $result = $apiInstance->getPayoutOrderById($id, $accept_language); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling PayoutOrdersApi->getPayoutOrderById: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +| Name | Type | Description | Notes | +| ------------- | ------------- | ------------- | ------------- | +| **id** | **string**| Identifier of the resource | | +| **accept_language** | **string**| Use for knowing which language to use | [optional] [default to 'es'] | + +### Return type + +[**\Conekta\Model\PayoutOrderResponse**](../Model/PayoutOrderResponse.md) + +### Authorization + +[bearerAuth](../../README.md#bearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/vnd.conekta-v2.1.0+json` + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + +## `getPayoutOrders()` + +```php +getPayoutOrders($accept_language, $limit, $search, $next, $previous): \Conekta\Model\PayoutOrdersResponse +``` + +Get a list of Payout Orders + +Get Payout order details in the form of a list + +### Example + +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + + +$apiInstance = new Conekta\Api\PayoutOrdersApi( + // 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 +); +$accept_language = es; // string | Use for knowing which language to use +$limit = 20; // int | The numbers of items to return, the maximum value is 250 +$search = 'search_example'; // string | General order search, e.g. by mail, reference etc. +$next = 'next_example'; // string | next page +$previous = 'previous_example'; // string | previous page + +try { + $result = $apiInstance->getPayoutOrders($accept_language, $limit, $search, $next, $previous); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling PayoutOrdersApi->getPayoutOrders: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +| Name | Type | Description | Notes | +| ------------- | ------------- | ------------- | ------------- | +| **accept_language** | **string**| Use for knowing which language to use | [optional] [default to 'es'] | +| **limit** | **int**| The numbers of items to return, the maximum value is 250 | [optional] [default to 20] | +| **search** | **string**| General order search, e.g. by mail, reference etc. | [optional] | +| **next** | **string**| next page | [optional] | +| **previous** | **string**| previous page | [optional] | + +### Return type + +[**\Conekta\Model\PayoutOrdersResponse**](../Model/PayoutOrdersResponse.md) + +### Authorization + +[bearerAuth](../../README.md#bearerAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: `application/vnd.conekta-v2.1.0+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/WebhooksApi.md b/docs/Api/WebhooksApi.md index a37aa959..ee2905cc 100644 --- a/docs/Api/WebhooksApi.md +++ b/docs/Api/WebhooksApi.md @@ -199,7 +199,7 @@ try { ## `getWebhooks()` ```php -getWebhooks($accept_language, $x_child_company_id, $limit, $search, $next, $previous): \Conekta\Model\GetWebhooksResponse +getWebhooks($accept_language, $x_child_company_id, $limit, $search, $url, $next, $previous): \Conekta\Model\GetWebhooksResponse ``` Get List of Webhooks @@ -227,11 +227,12 @@ $accept_language = es; // string | Use for knowing which language to use $x_child_company_id = 6441b6376b60c3a638da80af; // string | In the case of a holding company, the company id of the child company to which will process the request. $limit = 20; // int | The numbers of items to return, the maximum value is 250 $search = 'search_example'; // string | General order search, e.g. by mail, reference etc. +$url = 'url_example'; // string | url for webhook filter $next = 'next_example'; // string | next page $previous = 'previous_example'; // string | previous page try { - $result = $apiInstance->getWebhooks($accept_language, $x_child_company_id, $limit, $search, $next, $previous); + $result = $apiInstance->getWebhooks($accept_language, $x_child_company_id, $limit, $search, $url, $next, $previous); print_r($result); } catch (Exception $e) { echo 'Exception when calling WebhooksApi->getWebhooks: ', $e->getMessage(), PHP_EOL; @@ -246,6 +247,7 @@ try { | **x_child_company_id** | **string**| In the case of a holding company, the company id of the child company to which will process the request. | [optional] | | **limit** | **int**| The numbers of items to return, the maximum value is 250 | [optional] [default to 20] | | **search** | **string**| General order search, e.g. by mail, reference etc. | [optional] | +| **url** | **string**| url for webhook filter | [optional] | | **next** | **string**| next page | [optional] | | **previous** | **string**| previous page | [optional] | diff --git a/docs/Model/OrderResponseCheckout.md b/docs/Model/OrderResponseCheckout.md index d5f4666a..a4e0b3a3 100644 --- a/docs/Model/OrderResponseCheckout.md +++ b/docs/Model/OrderResponseCheckout.md @@ -23,6 +23,7 @@ Name | Type | Description | Notes **on_demand_enabled** | **bool** | | [optional] **paid_payments_count** | **int** | | [optional] **recurrent** | **bool** | | [optional] +**redirection_time** | **int** | number of seconds to wait before redirecting to the success_url | [optional] **slug** | **string** | | [optional] **sms_sent** | **int** | | [optional] **success_url** | **string** | | [optional] diff --git a/docs/Model/Payout.md b/docs/Model/Payout.md new file mode 100644 index 00000000..599af4f2 --- /dev/null +++ b/docs/Model/Payout.md @@ -0,0 +1,9 @@ +# # Payout + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**payout_method** | [**\Conekta\Model\PayoutMethod**](PayoutMethod.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/PayoutMethod.md b/docs/Model/PayoutMethod.md new file mode 100644 index 00000000..5a51ea67 --- /dev/null +++ b/docs/Model/PayoutMethod.md @@ -0,0 +1,9 @@ +# # PayoutMethod + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | The type of the payout 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/PayoutOrder.md b/docs/Model/PayoutOrder.md new file mode 100644 index 00000000..2a91d57f --- /dev/null +++ b/docs/Model/PayoutOrder.md @@ -0,0 +1,15 @@ +# # PayoutOrder + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**allowed_payout_methods** | **string[]** | The payout methods that are allowed for the payout order. | +**amount** | **int** | The amount of the payout order. | +**currency** | **string** | The currency in which the payout order is made. | [default to 'MXN'] +**customer_info** | [**\Conekta\Model\CustomerInfoJustCustomerId**](CustomerInfoJustCustomerId.md) | | +**metadata** | **array** | The metadata of the payout order. | [optional] +**payout** | [**\Conekta\Model\Payout**](Payout.md) | | +**reason** | **string** | The reason for the payout order. | + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PayoutOrderPayoutsItem.md b/docs/Model/PayoutOrderPayoutsItem.md new file mode 100644 index 00000000..9916dcff --- /dev/null +++ b/docs/Model/PayoutOrderPayoutsItem.md @@ -0,0 +1,16 @@ +# # PayoutOrderPayoutsItem + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**amount** | **int** | The amount of the payout. | +**currency** | **string** | The currency in which the payout is made. | +**expires_at** | **int** | The expiration date of the payout. | [optional] +**id** | **string** | The id of the payout. | +**livemode** | **bool** | The live mode of the payout. | +**object** | **string** | The object of the payout. | +**payout_order_id** | **string** | The id of the payout order. | [optional] +**status** | **string** | The status of the payout. | [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/PayoutOrderResponse.md b/docs/Model/PayoutOrderResponse.md new file mode 100644 index 00000000..89dbbadd --- /dev/null +++ b/docs/Model/PayoutOrderResponse.md @@ -0,0 +1,22 @@ +# # PayoutOrderResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**allowed_payout_methods** | **string[]** | The payout methods that are allowed for the payout order. | +**amount** | **int** | The amount of the payout order. | +**created_at** | **int** | The creation date of the payout order. | +**currency** | **string** | The currency in which the payout order is made. | [default to 'MXN'] +**customer_info** | [**\Conekta\Model\PayoutOrderResponseCustomerInfo**](PayoutOrderResponseCustomerInfo.md) | | +**expires_at** | **int** | The expiration date of the payout order. | [optional] +**id** | **string** | The id of the payout order. | +**livemode** | **bool** | The live mode of the payout order. | +**object** | **string** | The object of the payout order. | +**metadata** | **array** | The metadata of the payout order. | [optional] +**payouts** | [**\Conekta\Model\PayoutOrderPayoutsItem[]**](PayoutOrderPayoutsItem.md) | The payout information of the payout order. | +**reason** | **string** | The reason for the payout order. | +**status** | **string** | The status of the payout order. | [optional] +**updated_at** | **int** | The update date of the payout order. | + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PayoutOrderResponseCustomerInfo.md b/docs/Model/PayoutOrderResponseCustomerInfo.md new file mode 100644 index 00000000..7734fbe2 --- /dev/null +++ b/docs/Model/PayoutOrderResponseCustomerInfo.md @@ -0,0 +1,15 @@ +# # PayoutOrderResponseCustomerInfo + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**customer_custom_reference** | **string** | Custom reference | [optional] +**name** | **string** | | [optional] +**email** | **string** | | [optional] +**phone** | **string** | | [optional] +**corporate** | **bool** | | [optional] [default to false] +**object** | **string** | | [optional] +**id** | **string** | The id of the customer. | + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/PayoutOrdersResponse.md b/docs/Model/PayoutOrdersResponse.md new file mode 100644 index 00000000..e70ebcca --- /dev/null +++ b/docs/Model/PayoutOrdersResponse.md @@ -0,0 +1,13 @@ +# # PayoutOrdersResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**has_more** | **bool** | Indicates if there are more pages to be requested | +**object** | **string** | Object type, in this case is list | +**next_page_url** | **string** | URL of the next page. | [optional] +**previous_page_url** | **string** | Url of the previous page. | [optional] +**data** | [**\Conekta\Model\PayoutOrderResponse[]**](PayoutOrderResponse.md) | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/lib/Api/PayoutOrdersApi.php b/lib/Api/PayoutOrdersApi.php new file mode 100644 index 00000000..41edc45a --- /dev/null +++ b/lib/Api/PayoutOrdersApi.php @@ -0,0 +1,1521 @@ + [ + 'application/json', + ], + 'getPayoutOrderById' => [ + 'application/json', + ], + 'getPayoutOrders' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->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 createPayoutOrder + * + * Create payout order + * + * @param \Conekta\Model\PayoutOrder $payout_order requested field for payout order (required) + * @param string $accept_language Use for knowing which language to use (optional, default to 'es') + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createPayoutOrder'] to see the possible values for this operation + * + * @throws \Conekta\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \Conekta\Model\PayoutOrderResponse|\Conekta\Model\Error|\Conekta\Model\Error|\Conekta\Model\Error|\Conekta\Model\Error|\Conekta\Model\Error + */ + public function createPayoutOrder($payout_order, $accept_language = 'es', string $contentType = self::contentTypes['createPayoutOrder'][0]) + { + list($response) = $this->createPayoutOrderWithHttpInfo($payout_order, $accept_language, $contentType); + return $response; + } + + /** + * Operation createPayoutOrderWithHttpInfo + * + * Create payout order + * + * @param \Conekta\Model\PayoutOrder $payout_order requested field for payout order (required) + * @param string $accept_language Use for knowing which language to use (optional, default to 'es') + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createPayoutOrder'] to see the possible values for this operation + * + * @throws \Conekta\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \Conekta\Model\PayoutOrderResponse|\Conekta\Model\Error|\Conekta\Model\Error|\Conekta\Model\Error|\Conekta\Model\Error|\Conekta\Model\Error, HTTP status code, HTTP response headers (array of strings) + */ + public function createPayoutOrderWithHttpInfo($payout_order, $accept_language = 'es', string $contentType = self::contentTypes['createPayoutOrder'][0]) + { + $request = $this->createPayoutOrderRequest($payout_order, $accept_language, $contentType); + + 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 ('\Conekta\Model\PayoutOrderResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Conekta\Model\PayoutOrderResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\Conekta\Model\PayoutOrderResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 422: + if ('\Conekta\Model\Error' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Conekta\Model\Error' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\Conekta\Model\Error', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Conekta\Model\Error' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Conekta\Model\Error' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\Conekta\Model\Error', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 402: + if ('\Conekta\Model\Error' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Conekta\Model\Error' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\Conekta\Model\Error', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\Conekta\Model\Error' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Conekta\Model\Error' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\Conekta\Model\Error', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\Conekta\Model\Error' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Conekta\Model\Error' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\Conekta\Model\Error', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Conekta\Model\PayoutOrderResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Conekta\Model\PayoutOrderResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 422: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Conekta\Model\Error', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Conekta\Model\Error', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 402: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Conekta\Model\Error', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Conekta\Model\Error', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Conekta\Model\Error', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation createPayoutOrderAsync + * + * Create payout order + * + * @param \Conekta\Model\PayoutOrder $payout_order requested field for payout order (required) + * @param string $accept_language Use for knowing which language to use (optional, default to 'es') + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createPayoutOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createPayoutOrderAsync($payout_order, $accept_language = 'es', string $contentType = self::contentTypes['createPayoutOrder'][0]) + { + return $this->createPayoutOrderAsyncWithHttpInfo($payout_order, $accept_language, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation createPayoutOrderAsyncWithHttpInfo + * + * Create payout order + * + * @param \Conekta\Model\PayoutOrder $payout_order requested field for payout order (required) + * @param string $accept_language Use for knowing which language to use (optional, default to 'es') + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createPayoutOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createPayoutOrderAsyncWithHttpInfo($payout_order, $accept_language = 'es', string $contentType = self::contentTypes['createPayoutOrder'][0]) + { + $returnType = '\Conekta\Model\PayoutOrderResponse'; + $request = $this->createPayoutOrderRequest($payout_order, $accept_language, $contentType); + + 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 'createPayoutOrder' + * + * @param \Conekta\Model\PayoutOrder $payout_order requested field for payout order (required) + * @param string $accept_language Use for knowing which language to use (optional, default to 'es') + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createPayoutOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function createPayoutOrderRequest($payout_order, $accept_language = 'es', string $contentType = self::contentTypes['createPayoutOrder'][0]) + { + + // verify the required parameter 'payout_order' is set + if ($payout_order === null || (is_array($payout_order) && count($payout_order) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $payout_order when calling createPayoutOrder' + ); + } + + + + $resourcePath = '/payout_orders'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + // header params + if ($accept_language !== null) { + $headerParams['Accept-Language'] = ObjectSerializer::toHeaderValue($accept_language); + } + + + + $headers = $this->headerSelector->selectHeaders( + ['application/vnd.conekta-v2.1.0+json', ], + $contentType, + $multipart + ); + $headers = array_merge( + $this->headerSelector->getConektaUserAgent(), + $headers + ); + + // for model (json/xml) + if (isset($payout_order)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($payout_order)); + } else { + $httpBody = $payout_order; + } + } 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 (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer 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 + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getPayoutOrderById + * + * Get Payout Order + * + * @param string $id Identifier of the resource (required) + * @param string $accept_language Use for knowing which language to use (optional, default to 'es') + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPayoutOrderById'] to see the possible values for this operation + * + * @throws \Conekta\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \Conekta\Model\PayoutOrderResponse|\Conekta\Model\Error|\Conekta\Model\Error|\Conekta\Model\Error + */ + public function getPayoutOrderById($id, $accept_language = 'es', string $contentType = self::contentTypes['getPayoutOrderById'][0]) + { + list($response) = $this->getPayoutOrderByIdWithHttpInfo($id, $accept_language, $contentType); + return $response; + } + + /** + * Operation getPayoutOrderByIdWithHttpInfo + * + * Get Payout Order + * + * @param string $id Identifier of the resource (required) + * @param string $accept_language Use for knowing which language to use (optional, default to 'es') + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPayoutOrderById'] to see the possible values for this operation + * + * @throws \Conekta\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \Conekta\Model\PayoutOrderResponse|\Conekta\Model\Error|\Conekta\Model\Error|\Conekta\Model\Error, HTTP status code, HTTP response headers (array of strings) + */ + public function getPayoutOrderByIdWithHttpInfo($id, $accept_language = 'es', string $contentType = self::contentTypes['getPayoutOrderById'][0]) + { + $request = $this->getPayoutOrderByIdRequest($id, $accept_language, $contentType); + + 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 ('\Conekta\Model\PayoutOrderResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Conekta\Model\PayoutOrderResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\Conekta\Model\PayoutOrderResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Conekta\Model\Error' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Conekta\Model\Error' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\Conekta\Model\Error', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\Conekta\Model\Error' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Conekta\Model\Error' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\Conekta\Model\Error', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\Conekta\Model\Error' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Conekta\Model\Error' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\Conekta\Model\Error', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Conekta\Model\PayoutOrderResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Conekta\Model\PayoutOrderResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Conekta\Model\Error', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Conekta\Model\Error', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Conekta\Model\Error', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getPayoutOrderByIdAsync + * + * Get Payout Order + * + * @param string $id Identifier of the resource (required) + * @param string $accept_language Use for knowing which language to use (optional, default to 'es') + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPayoutOrderById'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPayoutOrderByIdAsync($id, $accept_language = 'es', string $contentType = self::contentTypes['getPayoutOrderById'][0]) + { + return $this->getPayoutOrderByIdAsyncWithHttpInfo($id, $accept_language, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getPayoutOrderByIdAsyncWithHttpInfo + * + * Get Payout Order + * + * @param string $id Identifier of the resource (required) + * @param string $accept_language Use for knowing which language to use (optional, default to 'es') + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPayoutOrderById'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPayoutOrderByIdAsyncWithHttpInfo($id, $accept_language = 'es', string $contentType = self::contentTypes['getPayoutOrderById'][0]) + { + $returnType = '\Conekta\Model\PayoutOrderResponse'; + $request = $this->getPayoutOrderByIdRequest($id, $accept_language, $contentType); + + 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 'getPayoutOrderById' + * + * @param string $id Identifier of the resource (required) + * @param string $accept_language Use for knowing which language to use (optional, default to 'es') + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPayoutOrderById'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getPayoutOrderByIdRequest($id, $accept_language = 'es', string $contentType = self::contentTypes['getPayoutOrderById'][0]) + { + + // verify the required parameter 'id' is set + if ($id === null || (is_array($id) && count($id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $id when calling getPayoutOrderById' + ); + } + + + + $resourcePath = '/payout_orders/{id}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + // header params + if ($accept_language !== null) { + $headerParams['Accept-Language'] = ObjectSerializer::toHeaderValue($accept_language); + } + + // path params + if ($id !== null) { + $resourcePath = str_replace( + '{' . 'id' . '}', + ObjectSerializer::toPathValue($id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/vnd.conekta-v2.1.0+json', ], + $contentType, + $multipart + ); + $headers = array_merge( + $this->headerSelector->getConektaUserAgent(), + $headers + ); + + // 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 (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer 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 + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getPayoutOrders + * + * Get a list of Payout Orders + * + * @param string $accept_language Use for knowing which language to use (optional, default to 'es') + * @param int $limit The numbers of items to return, the maximum value is 250 (optional, default to 20) + * @param string $search General order search, e.g. by mail, reference etc. (optional) + * @param string $next next page (optional) + * @param string $previous previous page (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPayoutOrders'] to see the possible values for this operation + * + * @throws \Conekta\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \Conekta\Model\PayoutOrdersResponse|\Conekta\Model\Error|\Conekta\Model\Error + */ + public function getPayoutOrders($accept_language = 'es', $limit = 20, $search = null, $next = null, $previous = null, string $contentType = self::contentTypes['getPayoutOrders'][0]) + { + list($response) = $this->getPayoutOrdersWithHttpInfo($accept_language, $limit, $search, $next, $previous, $contentType); + return $response; + } + + /** + * Operation getPayoutOrdersWithHttpInfo + * + * Get a list of Payout Orders + * + * @param string $accept_language Use for knowing which language to use (optional, default to 'es') + * @param int $limit The numbers of items to return, the maximum value is 250 (optional, default to 20) + * @param string $search General order search, e.g. by mail, reference etc. (optional) + * @param string $next next page (optional) + * @param string $previous previous page (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPayoutOrders'] to see the possible values for this operation + * + * @throws \Conekta\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \Conekta\Model\PayoutOrdersResponse|\Conekta\Model\Error|\Conekta\Model\Error, HTTP status code, HTTP response headers (array of strings) + */ + public function getPayoutOrdersWithHttpInfo($accept_language = 'es', $limit = 20, $search = null, $next = null, $previous = null, string $contentType = self::contentTypes['getPayoutOrders'][0]) + { + $request = $this->getPayoutOrdersRequest($accept_language, $limit, $search, $next, $previous, $contentType); + + 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 ('\Conekta\Model\PayoutOrdersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Conekta\Model\PayoutOrdersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\Conekta\Model\PayoutOrdersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\Conekta\Model\Error' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Conekta\Model\Error' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\Conekta\Model\Error', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\Conekta\Model\Error' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Conekta\Model\Error' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\Conekta\Model\Error', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Conekta\Model\PayoutOrdersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Conekta\Model\PayoutOrdersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Conekta\Model\Error', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Conekta\Model\Error', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getPayoutOrdersAsync + * + * Get a list of Payout Orders + * + * @param string $accept_language Use for knowing which language to use (optional, default to 'es') + * @param int $limit The numbers of items to return, the maximum value is 250 (optional, default to 20) + * @param string $search General order search, e.g. by mail, reference etc. (optional) + * @param string $next next page (optional) + * @param string $previous previous page (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPayoutOrders'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPayoutOrdersAsync($accept_language = 'es', $limit = 20, $search = null, $next = null, $previous = null, string $contentType = self::contentTypes['getPayoutOrders'][0]) + { + return $this->getPayoutOrdersAsyncWithHttpInfo($accept_language, $limit, $search, $next, $previous, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getPayoutOrdersAsyncWithHttpInfo + * + * Get a list of Payout Orders + * + * @param string $accept_language Use for knowing which language to use (optional, default to 'es') + * @param int $limit The numbers of items to return, the maximum value is 250 (optional, default to 20) + * @param string $search General order search, e.g. by mail, reference etc. (optional) + * @param string $next next page (optional) + * @param string $previous previous page (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPayoutOrders'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPayoutOrdersAsyncWithHttpInfo($accept_language = 'es', $limit = 20, $search = null, $next = null, $previous = null, string $contentType = self::contentTypes['getPayoutOrders'][0]) + { + $returnType = '\Conekta\Model\PayoutOrdersResponse'; + $request = $this->getPayoutOrdersRequest($accept_language, $limit, $search, $next, $previous, $contentType); + + 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 'getPayoutOrders' + * + * @param string $accept_language Use for knowing which language to use (optional, default to 'es') + * @param int $limit The numbers of items to return, the maximum value is 250 (optional, default to 20) + * @param string $search General order search, e.g. by mail, reference etc. (optional) + * @param string $next next page (optional) + * @param string $previous previous page (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPayoutOrders'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getPayoutOrdersRequest($accept_language = 'es', $limit = 20, $search = null, $next = null, $previous = null, string $contentType = self::contentTypes['getPayoutOrders'][0]) + { + + + if ($limit !== null && $limit > 250) { + throw new \InvalidArgumentException('invalid value for "$limit" when calling PayoutOrdersApi.getPayoutOrders, must be smaller than or equal to 250.'); + } + if ($limit !== null && $limit < 1) { + throw new \InvalidArgumentException('invalid value for "$limit" when calling PayoutOrdersApi.getPayoutOrders, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/payout_orders'; + $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( + $search, + 'search', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $next, + 'next', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $previous, + 'previous', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + + // header params + if ($accept_language !== null) { + $headerParams['Accept-Language'] = ObjectSerializer::toHeaderValue($accept_language); + } + + + + $headers = $this->headerSelector->selectHeaders( + ['application/vnd.conekta-v2.1.0+json', ], + $contentType, + $multipart + ); + $headers = array_merge( + $this->headerSelector->getConektaUserAgent(), + $headers + ); + + // 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 (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer 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 + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $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()); + } + } + $options[RequestOptions::SSL_KEY] = dirname(__DIR__, 1) . '/ssl_data/ca_bundle.crt'; + + return $options; + } +} diff --git a/lib/Api/WebhooksApi.php b/lib/Api/WebhooksApi.php index 6aeee6ed..313ee651 100644 --- a/lib/Api/WebhooksApi.php +++ b/lib/Api/WebhooksApi.php @@ -1411,6 +1411,7 @@ public function getWebhookRequest($id, $accept_language = 'es', $x_child_company * @param string $x_child_company_id In the case of a holding company, the company id of the child company to which will process the request. (optional) * @param int $limit The numbers of items to return, the maximum value is 250 (optional, default to 20) * @param string $search General order search, e.g. by mail, reference etc. (optional) + * @param string $url url for webhook filter (optional) * @param string $next next page (optional) * @param string $previous previous page (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getWebhooks'] to see the possible values for this operation @@ -1419,9 +1420,9 @@ public function getWebhookRequest($id, $accept_language = 'es', $x_child_company * @throws \InvalidArgumentException * @return \Conekta\Model\GetWebhooksResponse|\Conekta\Model\Error|\Conekta\Model\Error */ - public function getWebhooks($accept_language = 'es', $x_child_company_id = null, $limit = 20, $search = null, $next = null, $previous = null, string $contentType = self::contentTypes['getWebhooks'][0]) + public function getWebhooks($accept_language = 'es', $x_child_company_id = null, $limit = 20, $search = null, $url = null, $next = null, $previous = null, string $contentType = self::contentTypes['getWebhooks'][0]) { - list($response) = $this->getWebhooksWithHttpInfo($accept_language, $x_child_company_id, $limit, $search, $next, $previous, $contentType); + list($response) = $this->getWebhooksWithHttpInfo($accept_language, $x_child_company_id, $limit, $search, $url, $next, $previous, $contentType); return $response; } @@ -1434,6 +1435,7 @@ public function getWebhooks($accept_language = 'es', $x_child_company_id = null, * @param string $x_child_company_id In the case of a holding company, the company id of the child company to which will process the request. (optional) * @param int $limit The numbers of items to return, the maximum value is 250 (optional, default to 20) * @param string $search General order search, e.g. by mail, reference etc. (optional) + * @param string $url url for webhook filter (optional) * @param string $next next page (optional) * @param string $previous previous page (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getWebhooks'] to see the possible values for this operation @@ -1442,9 +1444,9 @@ public function getWebhooks($accept_language = 'es', $x_child_company_id = null, * @throws \InvalidArgumentException * @return array of \Conekta\Model\GetWebhooksResponse|\Conekta\Model\Error|\Conekta\Model\Error, HTTP status code, HTTP response headers (array of strings) */ - public function getWebhooksWithHttpInfo($accept_language = 'es', $x_child_company_id = null, $limit = 20, $search = null, $next = null, $previous = null, string $contentType = self::contentTypes['getWebhooks'][0]) + public function getWebhooksWithHttpInfo($accept_language = 'es', $x_child_company_id = null, $limit = 20, $search = null, $url = null, $next = null, $previous = null, string $contentType = self::contentTypes['getWebhooks'][0]) { - $request = $this->getWebhooksRequest($accept_language, $x_child_company_id, $limit, $search, $next, $previous, $contentType); + $request = $this->getWebhooksRequest($accept_language, $x_child_company_id, $limit, $search, $url, $next, $previous, $contentType); try { $options = $this->createHttpClientOption(); @@ -1633,6 +1635,7 @@ public function getWebhooksWithHttpInfo($accept_language = 'es', $x_child_compan * @param string $x_child_company_id In the case of a holding company, the company id of the child company to which will process the request. (optional) * @param int $limit The numbers of items to return, the maximum value is 250 (optional, default to 20) * @param string $search General order search, e.g. by mail, reference etc. (optional) + * @param string $url url for webhook filter (optional) * @param string $next next page (optional) * @param string $previous previous page (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getWebhooks'] to see the possible values for this operation @@ -1640,9 +1643,9 @@ public function getWebhooksWithHttpInfo($accept_language = 'es', $x_child_compan * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function getWebhooksAsync($accept_language = 'es', $x_child_company_id = null, $limit = 20, $search = null, $next = null, $previous = null, string $contentType = self::contentTypes['getWebhooks'][0]) + public function getWebhooksAsync($accept_language = 'es', $x_child_company_id = null, $limit = 20, $search = null, $url = null, $next = null, $previous = null, string $contentType = self::contentTypes['getWebhooks'][0]) { - return $this->getWebhooksAsyncWithHttpInfo($accept_language, $x_child_company_id, $limit, $search, $next, $previous, $contentType) + return $this->getWebhooksAsyncWithHttpInfo($accept_language, $x_child_company_id, $limit, $search, $url, $next, $previous, $contentType) ->then( function ($response) { return $response[0]; @@ -1659,6 +1662,7 @@ function ($response) { * @param string $x_child_company_id In the case of a holding company, the company id of the child company to which will process the request. (optional) * @param int $limit The numbers of items to return, the maximum value is 250 (optional, default to 20) * @param string $search General order search, e.g. by mail, reference etc. (optional) + * @param string $url url for webhook filter (optional) * @param string $next next page (optional) * @param string $previous previous page (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getWebhooks'] to see the possible values for this operation @@ -1666,10 +1670,10 @@ function ($response) { * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function getWebhooksAsyncWithHttpInfo($accept_language = 'es', $x_child_company_id = null, $limit = 20, $search = null, $next = null, $previous = null, string $contentType = self::contentTypes['getWebhooks'][0]) + public function getWebhooksAsyncWithHttpInfo($accept_language = 'es', $x_child_company_id = null, $limit = 20, $search = null, $url = null, $next = null, $previous = null, string $contentType = self::contentTypes['getWebhooks'][0]) { $returnType = '\Conekta\Model\GetWebhooksResponse'; - $request = $this->getWebhooksRequest($accept_language, $x_child_company_id, $limit, $search, $next, $previous, $contentType); + $request = $this->getWebhooksRequest($accept_language, $x_child_company_id, $limit, $search, $url, $next, $previous, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -1714,6 +1718,7 @@ function ($exception) { * @param string $x_child_company_id In the case of a holding company, the company id of the child company to which will process the request. (optional) * @param int $limit The numbers of items to return, the maximum value is 250 (optional, default to 20) * @param string $search General order search, e.g. by mail, reference etc. (optional) + * @param string $url url for webhook filter (optional) * @param string $next next page (optional) * @param string $previous previous page (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getWebhooks'] to see the possible values for this operation @@ -1721,7 +1726,7 @@ function ($exception) { * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function getWebhooksRequest($accept_language = 'es', $x_child_company_id = null, $limit = 20, $search = null, $next = null, $previous = null, string $contentType = self::contentTypes['getWebhooks'][0]) + public function getWebhooksRequest($accept_language = 'es', $x_child_company_id = null, $limit = 20, $search = null, $url = null, $next = null, $previous = null, string $contentType = self::contentTypes['getWebhooks'][0]) { @@ -1737,6 +1742,7 @@ public function getWebhooksRequest($accept_language = 'es', $x_child_company_id + $resourcePath = '/webhooks'; $formParams = []; $queryParams = []; @@ -1763,6 +1769,15 @@ public function getWebhooksRequest($accept_language = 'es', $x_child_company_id false // required ) ?? []); // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $url, + 'url', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( $next, 'next', // param base name diff --git a/lib/Configuration.php b/lib/Configuration.php index 0ea0a6ff..fa7d1adb 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -101,7 +101,7 @@ class Configuration * * @var string */ - protected $userAgent = 'Conekta/v2 PhpBindings/6.0.6'; + protected $userAgent = 'Conekta/v2 PhpBindings/6.0.7'; /** * Debug switch (default set to false) @@ -456,7 +456,7 @@ public static function toDebugReport() $report .= ' OS: ' . $uname . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 2.1.0' . PHP_EOL; - $report .= ' SDK Package Version: 6.0.6' . PHP_EOL; + $report .= ' SDK Package Version: 6.0.7' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; diff --git a/lib/HeaderSelector.php b/lib/HeaderSelector.php index c1f02d65..64a9b617 100644 --- a/lib/HeaderSelector.php +++ b/lib/HeaderSelector.php @@ -262,7 +262,7 @@ public function getConektaUserAgent(): array $uname = $uname_disabled ? '(disabled)' : \php_uname(); $userAgent = [ - 'bindings_version' => "6.0.6", + 'bindings_version' => "6.0.7", 'lang' => 'php', 'lang_version' => phpversion(), 'publisher' => 'conekta', diff --git a/lib/Model/OrderResponseCheckout.php b/lib/Model/OrderResponseCheckout.php index b9f825f4..b0eba4d3 100644 --- a/lib/Model/OrderResponseCheckout.php +++ b/lib/Model/OrderResponseCheckout.php @@ -77,6 +77,7 @@ class OrderResponseCheckout implements ModelInterface, ArrayAccess, \JsonSeriali 'on_demand_enabled' => 'bool', 'paid_payments_count' => 'int', 'recurrent' => 'bool', + 'redirection_time' => 'int', 'slug' => 'string', 'sms_sent' => 'int', 'success_url' => 'string', @@ -113,6 +114,7 @@ class OrderResponseCheckout implements ModelInterface, ArrayAccess, \JsonSeriali 'on_demand_enabled' => null, 'paid_payments_count' => null, 'recurrent' => null, + 'redirection_time' => 'int8', 'slug' => null, 'sms_sent' => null, 'success_url' => null, @@ -147,6 +149,7 @@ class OrderResponseCheckout implements ModelInterface, ArrayAccess, \JsonSeriali 'on_demand_enabled' => true, 'paid_payments_count' => false, 'recurrent' => false, + 'redirection_time' => true, 'slug' => false, 'sms_sent' => false, 'success_url' => false, @@ -261,6 +264,7 @@ public function isNullableSetToNull(string $property): bool 'on_demand_enabled' => 'on_demand_enabled', 'paid_payments_count' => 'paid_payments_count', 'recurrent' => 'recurrent', + 'redirection_time' => 'redirection_time', 'slug' => 'slug', 'sms_sent' => 'sms_sent', 'success_url' => 'success_url', @@ -295,6 +299,7 @@ public function isNullableSetToNull(string $property): bool 'on_demand_enabled' => 'setOnDemandEnabled', 'paid_payments_count' => 'setPaidPaymentsCount', 'recurrent' => 'setRecurrent', + 'redirection_time' => 'setRedirectionTime', 'slug' => 'setSlug', 'sms_sent' => 'setSmsSent', 'success_url' => 'setSuccessUrl', @@ -329,6 +334,7 @@ public function isNullableSetToNull(string $property): bool 'on_demand_enabled' => 'getOnDemandEnabled', 'paid_payments_count' => 'getPaidPaymentsCount', 'recurrent' => 'getRecurrent', + 'redirection_time' => 'getRedirectionTime', 'slug' => 'getSlug', 'sms_sent' => 'getSmsSent', 'success_url' => 'getSuccessUrl', @@ -414,6 +420,7 @@ public function __construct(array $data = null) $this->setIfExists('on_demand_enabled', $data ?? [], null); $this->setIfExists('paid_payments_count', $data ?? [], null); $this->setIfExists('recurrent', $data ?? [], null); + $this->setIfExists('redirection_time', $data ?? [], null); $this->setIfExists('slug', $data ?? [], null); $this->setIfExists('sms_sent', $data ?? [], null); $this->setIfExists('success_url', $data ?? [], null); @@ -993,6 +1000,40 @@ public function setRecurrent($recurrent) return $this; } + /** + * Gets redirection_time + * + * @return int|null + */ + public function getRedirectionTime() + { + return $this->container['redirection_time']; + } + + /** + * Sets redirection_time + * + * @param int|null $redirection_time number of seconds to wait before redirecting to the success_url + * + * @return self + */ + public function setRedirectionTime($redirection_time) + { + if (is_null($redirection_time)) { + array_push($this->openAPINullablesSetToNull, 'redirection_time'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('redirection_time', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['redirection_time'] = $redirection_time; + + return $this; + } + /** * Gets slug * diff --git a/lib/Model/Payout.php b/lib/Model/Payout.php new file mode 100644 index 00000000..e8855fe9 --- /dev/null +++ b/lib/Model/Payout.php @@ -0,0 +1,414 @@ + + */ +class Payout implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'payout'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'payout_method' => '\Conekta\Model\PayoutMethod' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'payout_method' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'payout_method' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * 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 nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'payout_method' => 'payout_method' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'payout_method' => 'setPayoutMethod' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'payout_method' => 'getPayoutMethod' + ]; + + /** + * 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->setIfExists('payout_method', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['payout_method'] === null) { + $invalidProperties[] = "'payout_method' 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 payout_method + * + * @return \Conekta\Model\PayoutMethod + */ + public function getPayoutMethod() + { + return $this->container['payout_method']; + } + + /** + * Sets payout_method + * + * @param \Conekta\Model\PayoutMethod $payout_method payout_method + * + * @return self + */ + public function setPayoutMethod($payout_method) + { + if (is_null($payout_method)) { + throw new \InvalidArgumentException('non-nullable payout_method cannot be null'); + } + $this->container['payout_method'] = $payout_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/PayoutMethod.php b/lib/Model/PayoutMethod.php new file mode 100644 index 00000000..049c6b6b --- /dev/null +++ b/lib/Model/PayoutMethod.php @@ -0,0 +1,414 @@ + + */ +class PayoutMethod implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'payout_method'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'type' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * 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 nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType' + ]; + + /** + * 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->setIfExists('type', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * 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"; + } + 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 the payout method. + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $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/PayoutOrder.php b/lib/Model/PayoutOrder.php new file mode 100644 index 00000000..d3b75c1e --- /dev/null +++ b/lib/Model/PayoutOrder.php @@ -0,0 +1,641 @@ + + */ +class PayoutOrder implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'payout_order'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'allowed_payout_methods' => 'string[]', + 'amount' => 'int', + 'currency' => 'string', + 'customer_info' => '\Conekta\Model\CustomerInfoJustCustomerId', + 'metadata' => 'array', + 'payout' => '\Conekta\Model\Payout', + 'reason' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'allowed_payout_methods' => null, + 'amount' => null, + 'currency' => null, + 'customer_info' => null, + 'metadata' => null, + 'payout' => null, + 'reason' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'allowed_payout_methods' => false, + 'amount' => false, + 'currency' => false, + 'customer_info' => false, + 'metadata' => false, + 'payout' => false, + 'reason' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * 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 nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'allowed_payout_methods' => 'allowed_payout_methods', + 'amount' => 'amount', + 'currency' => 'currency', + 'customer_info' => 'customer_info', + 'metadata' => 'metadata', + 'payout' => 'payout', + 'reason' => 'reason' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'allowed_payout_methods' => 'setAllowedPayoutMethods', + 'amount' => 'setAmount', + 'currency' => 'setCurrency', + 'customer_info' => 'setCustomerInfo', + 'metadata' => 'setMetadata', + 'payout' => 'setPayout', + 'reason' => 'setReason' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'allowed_payout_methods' => 'getAllowedPayoutMethods', + 'amount' => 'getAmount', + 'currency' => 'getCurrency', + 'customer_info' => 'getCustomerInfo', + 'metadata' => 'getMetadata', + 'payout' => 'getPayout', + 'reason' => 'getReason' + ]; + + /** + * 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->setIfExists('allowed_payout_methods', $data ?? [], null); + $this->setIfExists('amount', $data ?? [], null); + $this->setIfExists('currency', $data ?? [], 'MXN'); + $this->setIfExists('customer_info', $data ?? [], null); + $this->setIfExists('metadata', $data ?? [], null); + $this->setIfExists('payout', $data ?? [], null); + $this->setIfExists('reason', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['allowed_payout_methods'] === null) { + $invalidProperties[] = "'allowed_payout_methods' can't be null"; + } + if ($this->container['amount'] === null) { + $invalidProperties[] = "'amount' can't be null"; + } + if ($this->container['currency'] === null) { + $invalidProperties[] = "'currency' can't be null"; + } + if ($this->container['customer_info'] === null) { + $invalidProperties[] = "'customer_info' can't be null"; + } + if (!is_null($this->container['metadata']) && (count($this->container['metadata']) > 100)) { + $invalidProperties[] = "invalid value for 'metadata', number of items must be less than or equal to 100."; + } + + if ($this->container['payout'] === null) { + $invalidProperties[] = "'payout' can't be null"; + } + if ($this->container['reason'] === null) { + $invalidProperties[] = "'reason' 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 allowed_payout_methods + * + * @return string[] + */ + public function getAllowedPayoutMethods() + { + return $this->container['allowed_payout_methods']; + } + + /** + * Sets allowed_payout_methods + * + * @param string[] $allowed_payout_methods The payout methods that are allowed for the payout order. + * + * @return self + */ + public function setAllowedPayoutMethods($allowed_payout_methods) + { + if (is_null($allowed_payout_methods)) { + throw new \InvalidArgumentException('non-nullable allowed_payout_methods cannot be null'); + } + $this->container['allowed_payout_methods'] = $allowed_payout_methods; + + return $this; + } + + /** + * Gets amount + * + * @return int + */ + public function getAmount() + { + return $this->container['amount']; + } + + /** + * Sets amount + * + * @param int $amount The amount of the payout order. + * + * @return self + */ + public function setAmount($amount) + { + if (is_null($amount)) { + throw new \InvalidArgumentException('non-nullable amount cannot be null'); + } + $this->container['amount'] = $amount; + + return $this; + } + + /** + * Gets currency + * + * @return string + */ + public function getCurrency() + { + return $this->container['currency']; + } + + /** + * Sets currency + * + * @param string $currency The currency in which the payout order is made. + * + * @return self + */ + public function setCurrency($currency) + { + if (is_null($currency)) { + throw new \InvalidArgumentException('non-nullable currency cannot be null'); + } + $this->container['currency'] = $currency; + + return $this; + } + + /** + * Gets customer_info + * + * @return \Conekta\Model\CustomerInfoJustCustomerId + */ + public function getCustomerInfo() + { + return $this->container['customer_info']; + } + + /** + * Sets customer_info + * + * @param \Conekta\Model\CustomerInfoJustCustomerId $customer_info customer_info + * + * @return self + */ + public function setCustomerInfo($customer_info) + { + if (is_null($customer_info)) { + throw new \InvalidArgumentException('non-nullable customer_info cannot be null'); + } + $this->container['customer_info'] = $customer_info; + + return $this; + } + + /** + * Gets metadata + * + * @return array|null + */ + public function getMetadata() + { + return $this->container['metadata']; + } + + /** + * Sets metadata + * + * @param array|null $metadata The metadata of the payout order. + * + * @return self + */ + public function setMetadata($metadata) + { + if (is_null($metadata)) { + throw new \InvalidArgumentException('non-nullable metadata cannot be null'); + } + + if ((count($metadata) > 100)) { + throw new \InvalidArgumentException('invalid value for $metadata when calling PayoutOrder., number of items must be less than or equal to 100.'); + } + $this->container['metadata'] = $metadata; + + return $this; + } + + /** + * Gets payout + * + * @return \Conekta\Model\Payout + */ + public function getPayout() + { + return $this->container['payout']; + } + + /** + * Sets payout + * + * @param \Conekta\Model\Payout $payout payout + * + * @return self + */ + public function setPayout($payout) + { + if (is_null($payout)) { + throw new \InvalidArgumentException('non-nullable payout cannot be null'); + } + $this->container['payout'] = $payout; + + return $this; + } + + /** + * Gets reason + * + * @return string + */ + public function getReason() + { + return $this->container['reason']; + } + + /** + * Sets reason + * + * @param string $reason The reason for the payout order. + * + * @return self + */ + public function setReason($reason) + { + if (is_null($reason)) { + throw new \InvalidArgumentException('non-nullable reason cannot be null'); + } + $this->container['reason'] = $reason; + + 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/PayoutOrderPayoutsItem.php b/lib/Model/PayoutOrderPayoutsItem.php new file mode 100644 index 00000000..2913f0d4 --- /dev/null +++ b/lib/Model/PayoutOrderPayoutsItem.php @@ -0,0 +1,663 @@ + + */ +class PayoutOrderPayoutsItem implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'payout_order_payouts_item'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'amount' => 'int', + 'currency' => 'string', + 'expires_at' => 'int', + 'id' => 'string', + 'livemode' => 'bool', + 'object' => 'string', + 'payout_order_id' => 'string', + 'status' => '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, + 'expires_at' => 'int64', + 'id' => null, + 'livemode' => null, + 'object' => null, + 'payout_order_id' => null, + 'status' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'amount' => false, + 'currency' => false, + 'expires_at' => false, + 'id' => false, + 'livemode' => false, + 'object' => false, + 'payout_order_id' => false, + 'status' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * 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 nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * 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', + 'expires_at' => 'expires_at', + 'id' => 'id', + 'livemode' => 'livemode', + 'object' => 'object', + 'payout_order_id' => 'payout_order_id', + 'status' => 'status' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'amount' => 'setAmount', + 'currency' => 'setCurrency', + 'expires_at' => 'setExpiresAt', + 'id' => 'setId', + 'livemode' => 'setLivemode', + 'object' => 'setObject', + 'payout_order_id' => 'setPayoutOrderId', + 'status' => 'setStatus' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'amount' => 'getAmount', + 'currency' => 'getCurrency', + 'expires_at' => 'getExpiresAt', + 'id' => 'getId', + 'livemode' => 'getLivemode', + 'object' => 'getObject', + 'payout_order_id' => 'getPayoutOrderId', + 'status' => 'getStatus' + ]; + + /** + * 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->setIfExists('amount', $data ?? [], null); + $this->setIfExists('currency', $data ?? [], null); + $this->setIfExists('expires_at', $data ?? [], null); + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('livemode', $data ?? [], null); + $this->setIfExists('object', $data ?? [], null); + $this->setIfExists('payout_order_id', $data ?? [], null); + $this->setIfExists('status', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * 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['currency'] === null) { + $invalidProperties[] = "'currency' can't be null"; + } + if ($this->container['id'] === null) { + $invalidProperties[] = "'id' can't be null"; + } + if ($this->container['livemode'] === null) { + $invalidProperties[] = "'livemode' can't be null"; + } + if ($this->container['object'] === null) { + $invalidProperties[] = "'object' 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 amount of the payout. + * + * @return self + */ + public function setAmount($amount) + { + if (is_null($amount)) { + throw new \InvalidArgumentException('non-nullable amount cannot be null'); + } + $this->container['amount'] = $amount; + + return $this; + } + + /** + * Gets currency + * + * @return string + */ + public function getCurrency() + { + return $this->container['currency']; + } + + /** + * Sets currency + * + * @param string $currency The currency in which the payout is made. + * + * @return self + */ + public function setCurrency($currency) + { + if (is_null($currency)) { + throw new \InvalidArgumentException('non-nullable currency cannot be null'); + } + $this->container['currency'] = $currency; + + return $this; + } + + /** + * Gets expires_at + * + * @return int|null + */ + public function getExpiresAt() + { + return $this->container['expires_at']; + } + + /** + * Sets expires_at + * + * @param int|null $expires_at The expiration date of the payout. + * + * @return self + */ + public function setExpiresAt($expires_at) + { + if (is_null($expires_at)) { + throw new \InvalidArgumentException('non-nullable expires_at cannot be null'); + } + $this->container['expires_at'] = $expires_at; + + return $this; + } + + /** + * Gets id + * + * @return string + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string $id The id of the payout. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets livemode + * + * @return bool + */ + public function getLivemode() + { + return $this->container['livemode']; + } + + /** + * Sets livemode + * + * @param bool $livemode The live mode of the payout. + * + * @return self + */ + public function setLivemode($livemode) + { + if (is_null($livemode)) { + throw new \InvalidArgumentException('non-nullable livemode cannot be null'); + } + $this->container['livemode'] = $livemode; + + return $this; + } + + /** + * Gets object + * + * @return string + */ + public function getObject() + { + return $this->container['object']; + } + + /** + * Sets object + * + * @param string $object The object of the payout. + * + * @return self + */ + public function setObject($object) + { + if (is_null($object)) { + throw new \InvalidArgumentException('non-nullable object cannot be null'); + } + $this->container['object'] = $object; + + return $this; + } + + /** + * Gets payout_order_id + * + * @return string|null + */ + public function getPayoutOrderId() + { + return $this->container['payout_order_id']; + } + + /** + * Sets payout_order_id + * + * @param string|null $payout_order_id The id of the payout order. + * + * @return self + */ + public function setPayoutOrderId($payout_order_id) + { + if (is_null($payout_order_id)) { + throw new \InvalidArgumentException('non-nullable payout_order_id cannot be null'); + } + $this->container['payout_order_id'] = $payout_order_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 payout. + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + 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/PayoutOrderResponse.php b/lib/Model/PayoutOrderResponse.php new file mode 100644 index 00000000..19e5a592 --- /dev/null +++ b/lib/Model/PayoutOrderResponse.php @@ -0,0 +1,903 @@ + + */ +class PayoutOrderResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'payout_order_response'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'allowed_payout_methods' => 'string[]', + 'amount' => 'int', + 'created_at' => 'int', + 'currency' => 'string', + 'customer_info' => '\Conekta\Model\PayoutOrderResponseCustomerInfo', + 'expires_at' => 'int', + 'id' => 'string', + 'livemode' => 'bool', + 'object' => 'string', + 'metadata' => 'array', + 'payouts' => '\Conekta\Model\PayoutOrderPayoutsItem[]', + 'reason' => 'string', + 'status' => 'string', + 'updated_at' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'allowed_payout_methods' => null, + 'amount' => null, + 'created_at' => 'int64', + 'currency' => null, + 'customer_info' => null, + 'expires_at' => 'int64', + 'id' => null, + 'livemode' => null, + 'object' => null, + 'metadata' => null, + 'payouts' => null, + 'reason' => null, + 'status' => null, + 'updated_at' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'allowed_payout_methods' => false, + 'amount' => false, + 'created_at' => false, + 'currency' => false, + 'customer_info' => false, + 'expires_at' => false, + 'id' => false, + 'livemode' => false, + 'object' => false, + 'metadata' => false, + 'payouts' => false, + 'reason' => false, + 'status' => false, + 'updated_at' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * 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 nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'allowed_payout_methods' => 'allowed_payout_methods', + 'amount' => 'amount', + 'created_at' => 'created_at', + 'currency' => 'currency', + 'customer_info' => 'customer_info', + 'expires_at' => 'expires_at', + 'id' => 'id', + 'livemode' => 'livemode', + 'object' => 'object', + 'metadata' => 'metadata', + 'payouts' => 'payouts', + 'reason' => 'reason', + 'status' => 'status', + 'updated_at' => 'updated_at' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'allowed_payout_methods' => 'setAllowedPayoutMethods', + 'amount' => 'setAmount', + 'created_at' => 'setCreatedAt', + 'currency' => 'setCurrency', + 'customer_info' => 'setCustomerInfo', + 'expires_at' => 'setExpiresAt', + 'id' => 'setId', + 'livemode' => 'setLivemode', + 'object' => 'setObject', + 'metadata' => 'setMetadata', + 'payouts' => 'setPayouts', + 'reason' => 'setReason', + 'status' => 'setStatus', + 'updated_at' => 'setUpdatedAt' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'allowed_payout_methods' => 'getAllowedPayoutMethods', + 'amount' => 'getAmount', + 'created_at' => 'getCreatedAt', + 'currency' => 'getCurrency', + 'customer_info' => 'getCustomerInfo', + 'expires_at' => 'getExpiresAt', + 'id' => 'getId', + 'livemode' => 'getLivemode', + 'object' => 'getObject', + 'metadata' => 'getMetadata', + 'payouts' => 'getPayouts', + 'reason' => 'getReason', + 'status' => 'getStatus', + '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; + } + + + /** + * 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->setIfExists('allowed_payout_methods', $data ?? [], null); + $this->setIfExists('amount', $data ?? [], null); + $this->setIfExists('created_at', $data ?? [], null); + $this->setIfExists('currency', $data ?? [], 'MXN'); + $this->setIfExists('customer_info', $data ?? [], null); + $this->setIfExists('expires_at', $data ?? [], null); + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('livemode', $data ?? [], null); + $this->setIfExists('object', $data ?? [], null); + $this->setIfExists('metadata', $data ?? [], null); + $this->setIfExists('payouts', $data ?? [], null); + $this->setIfExists('reason', $data ?? [], null); + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('updated_at', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['allowed_payout_methods'] === null) { + $invalidProperties[] = "'allowed_payout_methods' can't be null"; + } + if ((count($this->container['allowed_payout_methods']) < 1)) { + $invalidProperties[] = "invalid value for 'allowed_payout_methods', number of items must be greater than or equal to 1."; + } + + if ($this->container['amount'] === null) { + $invalidProperties[] = "'amount' can't be null"; + } + if ($this->container['created_at'] === null) { + $invalidProperties[] = "'created_at' can't be null"; + } + if ($this->container['currency'] === null) { + $invalidProperties[] = "'currency' can't be null"; + } + if ($this->container['customer_info'] === null) { + $invalidProperties[] = "'customer_info' can't be null"; + } + if ($this->container['id'] === null) { + $invalidProperties[] = "'id' can't be null"; + } + if ($this->container['livemode'] === null) { + $invalidProperties[] = "'livemode' can't be null"; + } + if ($this->container['object'] === null) { + $invalidProperties[] = "'object' can't be null"; + } + if (!is_null($this->container['metadata']) && (count($this->container['metadata']) > 100)) { + $invalidProperties[] = "invalid value for 'metadata', number of items must be less than or equal to 100."; + } + + if ($this->container['payouts'] === null) { + $invalidProperties[] = "'payouts' can't be null"; + } + if ($this->container['reason'] === null) { + $invalidProperties[] = "'reason' can't be null"; + } + if ($this->container['updated_at'] === null) { + $invalidProperties[] = "'updated_at' 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 allowed_payout_methods + * + * @return string[] + */ + public function getAllowedPayoutMethods() + { + return $this->container['allowed_payout_methods']; + } + + /** + * Sets allowed_payout_methods + * + * @param string[] $allowed_payout_methods The payout methods that are allowed for the payout order. + * + * @return self + */ + public function setAllowedPayoutMethods($allowed_payout_methods) + { + if (is_null($allowed_payout_methods)) { + throw new \InvalidArgumentException('non-nullable allowed_payout_methods cannot be null'); + } + + + if ((count($allowed_payout_methods) < 1)) { + throw new \InvalidArgumentException('invalid length for $allowed_payout_methods when calling PayoutOrderResponse., number of items must be greater than or equal to 1.'); + } + $this->container['allowed_payout_methods'] = $allowed_payout_methods; + + return $this; + } + + /** + * Gets amount + * + * @return int + */ + public function getAmount() + { + return $this->container['amount']; + } + + /** + * Sets amount + * + * @param int $amount The amount of the payout order. + * + * @return self + */ + public function setAmount($amount) + { + if (is_null($amount)) { + throw new \InvalidArgumentException('non-nullable amount cannot be null'); + } + $this->container['amount'] = $amount; + + return $this; + } + + /** + * Gets created_at + * + * @return int + */ + public function getCreatedAt() + { + return $this->container['created_at']; + } + + /** + * Sets created_at + * + * @param int $created_at The creation date of the payout order. + * + * @return self + */ + public function setCreatedAt($created_at) + { + if (is_null($created_at)) { + throw new \InvalidArgumentException('non-nullable created_at cannot be null'); + } + $this->container['created_at'] = $created_at; + + return $this; + } + + /** + * Gets currency + * + * @return string + */ + public function getCurrency() + { + return $this->container['currency']; + } + + /** + * Sets currency + * + * @param string $currency The currency in which the payout order is made. + * + * @return self + */ + public function setCurrency($currency) + { + if (is_null($currency)) { + throw new \InvalidArgumentException('non-nullable currency cannot be null'); + } + $this->container['currency'] = $currency; + + return $this; + } + + /** + * Gets customer_info + * + * @return \Conekta\Model\PayoutOrderResponseCustomerInfo + */ + public function getCustomerInfo() + { + return $this->container['customer_info']; + } + + /** + * Sets customer_info + * + * @param \Conekta\Model\PayoutOrderResponseCustomerInfo $customer_info customer_info + * + * @return self + */ + public function setCustomerInfo($customer_info) + { + if (is_null($customer_info)) { + throw new \InvalidArgumentException('non-nullable customer_info cannot be null'); + } + $this->container['customer_info'] = $customer_info; + + return $this; + } + + /** + * Gets expires_at + * + * @return int|null + */ + public function getExpiresAt() + { + return $this->container['expires_at']; + } + + /** + * Sets expires_at + * + * @param int|null $expires_at The expiration date of the payout order. + * + * @return self + */ + public function setExpiresAt($expires_at) + { + if (is_null($expires_at)) { + throw new \InvalidArgumentException('non-nullable expires_at cannot be null'); + } + $this->container['expires_at'] = $expires_at; + + return $this; + } + + /** + * Gets id + * + * @return string + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string $id The id of the payout order. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets livemode + * + * @return bool + */ + public function getLivemode() + { + return $this->container['livemode']; + } + + /** + * Sets livemode + * + * @param bool $livemode The live mode of the payout order. + * + * @return self + */ + public function setLivemode($livemode) + { + if (is_null($livemode)) { + throw new \InvalidArgumentException('non-nullable livemode cannot be null'); + } + $this->container['livemode'] = $livemode; + + return $this; + } + + /** + * Gets object + * + * @return string + */ + public function getObject() + { + return $this->container['object']; + } + + /** + * Sets object + * + * @param string $object The object of the payout order. + * + * @return self + */ + public function setObject($object) + { + if (is_null($object)) { + throw new \InvalidArgumentException('non-nullable object cannot be null'); + } + $this->container['object'] = $object; + + return $this; + } + + /** + * Gets metadata + * + * @return array|null + */ + public function getMetadata() + { + return $this->container['metadata']; + } + + /** + * Sets metadata + * + * @param array|null $metadata The metadata of the payout order. + * + * @return self + */ + public function setMetadata($metadata) + { + if (is_null($metadata)) { + throw new \InvalidArgumentException('non-nullable metadata cannot be null'); + } + + if ((count($metadata) > 100)) { + throw new \InvalidArgumentException('invalid value for $metadata when calling PayoutOrderResponse., number of items must be less than or equal to 100.'); + } + $this->container['metadata'] = $metadata; + + return $this; + } + + /** + * Gets payouts + * + * @return \Conekta\Model\PayoutOrderPayoutsItem[] + */ + public function getPayouts() + { + return $this->container['payouts']; + } + + /** + * Sets payouts + * + * @param \Conekta\Model\PayoutOrderPayoutsItem[] $payouts The payout information of the payout order. + * + * @return self + */ + public function setPayouts($payouts) + { + if (is_null($payouts)) { + throw new \InvalidArgumentException('non-nullable payouts cannot be null'); + } + $this->container['payouts'] = $payouts; + + return $this; + } + + /** + * Gets reason + * + * @return string + */ + public function getReason() + { + return $this->container['reason']; + } + + /** + * Sets reason + * + * @param string $reason The reason for the payout order. + * + * @return self + */ + public function setReason($reason) + { + if (is_null($reason)) { + throw new \InvalidArgumentException('non-nullable reason cannot be null'); + } + $this->container['reason'] = $reason; + + return $this; + } + + /** + * Gets status + * + * @return string|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param string|null $status The status of the payout order. + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets updated_at + * + * @return int + */ + public function getUpdatedAt() + { + return $this->container['updated_at']; + } + + /** + * Sets updated_at + * + * @param int $updated_at The update date of the payout order. + * + * @return self + */ + public function setUpdatedAt($updated_at) + { + if (is_null($updated_at)) { + throw new \InvalidArgumentException('non-nullable updated_at cannot be null'); + } + $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/PayoutOrderResponseCustomerInfo.php b/lib/Model/PayoutOrderResponseCustomerInfo.php new file mode 100644 index 00000000..07e2bd55 --- /dev/null +++ b/lib/Model/PayoutOrderResponseCustomerInfo.php @@ -0,0 +1,625 @@ + + */ +class PayoutOrderResponseCustomerInfo implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'payout_order_response_customer_info'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'customer_custom_reference' => 'string', + 'name' => 'string', + 'email' => 'string', + 'phone' => 'string', + 'corporate' => 'bool', + 'object' => 'string', + 'id' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'customer_custom_reference' => null, + 'name' => null, + 'email' => 'email', + 'phone' => null, + 'corporate' => null, + 'object' => null, + 'id' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'customer_custom_reference' => true, + 'name' => false, + 'email' => false, + 'phone' => false, + 'corporate' => false, + 'object' => false, + 'id' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * 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 nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'customer_custom_reference' => 'customer_custom_reference', + 'name' => 'name', + 'email' => 'email', + 'phone' => 'phone', + 'corporate' => 'corporate', + 'object' => 'object', + 'id' => 'id' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'customer_custom_reference' => 'setCustomerCustomReference', + 'name' => 'setName', + 'email' => 'setEmail', + 'phone' => 'setPhone', + 'corporate' => 'setCorporate', + 'object' => 'setObject', + 'id' => 'setId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'customer_custom_reference' => 'getCustomerCustomReference', + 'name' => 'getName', + 'email' => 'getEmail', + 'phone' => 'getPhone', + 'corporate' => 'getCorporate', + 'object' => 'getObject', + '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->setIfExists('customer_custom_reference', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('email', $data ?? [], null); + $this->setIfExists('phone', $data ?? [], null); + $this->setIfExists('corporate', $data ?? [], false); + $this->setIfExists('object', $data ?? [], null); + $this->setIfExists('id', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['id'] === null) { + $invalidProperties[] = "'id' can't be null"; + } + 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 customer_custom_reference + * + * @return string|null + */ + public function getCustomerCustomReference() + { + return $this->container['customer_custom_reference']; + } + + /** + * Sets customer_custom_reference + * + * @param string|null $customer_custom_reference Custom reference + * + * @return self + */ + public function setCustomerCustomReference($customer_custom_reference) + { + if (is_null($customer_custom_reference)) { + array_push($this->openAPINullablesSetToNull, 'customer_custom_reference'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('customer_custom_reference', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['customer_custom_reference'] = $customer_custom_reference; + + return $this; + } + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name name + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets email + * + * @return string|null + */ + public function getEmail() + { + return $this->container['email']; + } + + /** + * Sets email + * + * @param string|null $email email + * + * @return self + */ + public function setEmail($email) + { + if (is_null($email)) { + throw new \InvalidArgumentException('non-nullable email cannot be null'); + } + $this->container['email'] = $email; + + return $this; + } + + /** + * Gets phone + * + * @return string|null + */ + public function getPhone() + { + return $this->container['phone']; + } + + /** + * Sets phone + * + * @param string|null $phone phone + * + * @return self + */ + public function setPhone($phone) + { + if (is_null($phone)) { + throw new \InvalidArgumentException('non-nullable phone cannot be null'); + } + $this->container['phone'] = $phone; + + return $this; + } + + /** + * Gets corporate + * + * @return bool|null + */ + public function getCorporate() + { + return $this->container['corporate']; + } + + /** + * Sets corporate + * + * @param bool|null $corporate corporate + * + * @return self + */ + public function setCorporate($corporate) + { + if (is_null($corporate)) { + throw new \InvalidArgumentException('non-nullable corporate cannot be null'); + } + $this->container['corporate'] = $corporate; + + return $this; + } + + /** + * Gets object + * + * @return string|null + */ + public function getObject() + { + return $this->container['object']; + } + + /** + * Sets object + * + * @param string|null $object object + * + * @return self + */ + public function setObject($object) + { + if (is_null($object)) { + throw new \InvalidArgumentException('non-nullable object cannot be null'); + } + $this->container['object'] = $object; + + return $this; + } + + /** + * Gets id + * + * @return string + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string $id The id of the customer. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $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/PayoutOrdersResponse.php b/lib/Model/PayoutOrdersResponse.php new file mode 100644 index 00000000..d7ff2396 --- /dev/null +++ b/lib/Model/PayoutOrdersResponse.php @@ -0,0 +1,566 @@ + + */ +class PayoutOrdersResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'payout_orders_response'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'has_more' => 'bool', + 'object' => 'string', + 'next_page_url' => 'string', + 'previous_page_url' => 'string', + 'data' => '\Conekta\Model\PayoutOrderResponse[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'has_more' => null, + 'object' => null, + 'next_page_url' => null, + 'previous_page_url' => null, + 'data' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'has_more' => false, + 'object' => false, + 'next_page_url' => true, + 'previous_page_url' => true, + 'data' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * 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 nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'has_more' => 'has_more', + 'object' => 'object', + 'next_page_url' => 'next_page_url', + 'previous_page_url' => 'previous_page_url', + 'data' => 'data' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'has_more' => 'setHasMore', + 'object' => 'setObject', + 'next_page_url' => 'setNextPageUrl', + 'previous_page_url' => 'setPreviousPageUrl', + 'data' => 'setData' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'has_more' => 'getHasMore', + 'object' => 'getObject', + 'next_page_url' => 'getNextPageUrl', + 'previous_page_url' => 'getPreviousPageUrl', + 'data' => 'getData' + ]; + + /** + * 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->setIfExists('has_more', $data ?? [], null); + $this->setIfExists('object', $data ?? [], null); + $this->setIfExists('next_page_url', $data ?? [], null); + $this->setIfExists('previous_page_url', $data ?? [], null); + $this->setIfExists('data', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['has_more'] === null) { + $invalidProperties[] = "'has_more' can't be null"; + } + if ($this->container['object'] === null) { + $invalidProperties[] = "'object' 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 has_more + * + * @return bool + */ + public function getHasMore() + { + return $this->container['has_more']; + } + + /** + * Sets has_more + * + * @param bool $has_more Indicates if there are more pages to be requested + * + * @return self + */ + public function setHasMore($has_more) + { + if (is_null($has_more)) { + throw new \InvalidArgumentException('non-nullable has_more cannot be null'); + } + $this->container['has_more'] = $has_more; + + return $this; + } + + /** + * Gets object + * + * @return string + */ + public function getObject() + { + return $this->container['object']; + } + + /** + * Sets object + * + * @param string $object Object type, in this case is list + * + * @return self + */ + public function setObject($object) + { + if (is_null($object)) { + throw new \InvalidArgumentException('non-nullable object cannot be null'); + } + $this->container['object'] = $object; + + return $this; + } + + /** + * Gets next_page_url + * + * @return string|null + */ + public function getNextPageUrl() + { + return $this->container['next_page_url']; + } + + /** + * Sets next_page_url + * + * @param string|null $next_page_url URL of the next page. + * + * @return self + */ + public function setNextPageUrl($next_page_url) + { + if (is_null($next_page_url)) { + array_push($this->openAPINullablesSetToNull, 'next_page_url'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('next_page_url', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['next_page_url'] = $next_page_url; + + return $this; + } + + /** + * Gets previous_page_url + * + * @return string|null + */ + public function getPreviousPageUrl() + { + return $this->container['previous_page_url']; + } + + /** + * Sets previous_page_url + * + * @param string|null $previous_page_url Url of the previous page. + * + * @return self + */ + public function setPreviousPageUrl($previous_page_url) + { + if (is_null($previous_page_url)) { + array_push($this->openAPINullablesSetToNull, 'previous_page_url'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('previous_page_url', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['previous_page_url'] = $previous_page_url; + + return $this; + } + + /** + * Gets data + * + * @return \Conekta\Model\PayoutOrderResponse[]|null + */ + public function getData() + { + return $this->container['data']; + } + + /** + * Sets data + * + * @param \Conekta\Model\PayoutOrderResponse[]|null $data data + * + * @return self + */ + public function setData($data) + { + if (is_null($data)) { + throw new \InvalidArgumentException('non-nullable data cannot be null'); + } + $this->container['data'] = $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/test/Api/PayoutOrdersApiTest.php b/test/Api/PayoutOrdersApiTest.php new file mode 100644 index 00000000..1875ae81 --- /dev/null +++ b/test/Api/PayoutOrdersApiTest.php @@ -0,0 +1,138 @@ +setHost(BaseTest::$host)->setAccessToken("key_xxx"); + self::$apiInstance = new PayoutOrdersApi(null, $config); + } + + /** + * Setup before running each test case + */ + public function setUp(): void + { + } + + /** + * Clean up after running each test case + */ + public function tearDown(): void + { + } + + /** + * Clean up after running all test cases + */ + public static function tearDownAfterClass(): void + { + } + + /** + * Test case for createPayoutOrder + * + * Create payout order. + * + * @throws ApiException + */ + public function testCreatePayoutOrder() + { + $request = new PayoutOrder( + [ + "currency" => "MXN", + "amount" => 3000, + "description" => "Payout order description", + "reference_id" => "reference_id", + "payment_method" => "card", + "payment_method_id" => "pm_3fae3e3e3e3e3e3e3e3e3e3e", + "customer" => [ + "name" => "John Doe", + "email" => "", + ] + ] + ); + $result = self::$apiInstance->createPayoutOrder($request) ; + + $this->assertNotEmpty($result, 'expected not empty result'); + $this->assertEquals('MXN', $result->getCurrency()); + $this->assertEquals(3000, $result->getAmount()); + + } + + /** + * Test case for getPayoutOrderById + * + * Get Payout Order. + * + */ + public function testGetPayoutOrderById() + { + $result = self::$apiInstance->getPayoutOrderById('f2654d66-d740-457a-9a8c-f96b5196f44e'); + + $this->assertNotEmpty($result, 'expected not empty result'); + $this->assertEquals('f2654d66-d740-457a-9a8c-f96b5196f44e', $result->getId()); + } + + /** + * Test case for getPayoutOrders + * + * Get a list of Payout Orders. + * + */ + public function testGetPayoutOrders() + { + $result = self::$apiInstance->getPayoutOrders(); + + $this->assertNotEmpty($result, 'expected not empty result'); + $this->assertIsArray($result->getData()); + } +}