From 844015778276ad39d339992b947780c1b16c084e Mon Sep 17 00:00:00 2001 From: andreals Date: Thu, 9 May 2024 13:01:16 +0000 Subject: [PATCH] Automated commit message --- README.md | 48 +- composer.json | 4 +- doc/controllers/balance-operations.md | 42 +- doc/controllers/charges.md | 364 +++--- doc/controllers/customers.md | 478 ++++--- doc/controllers/invoices.md | 204 +-- doc/controllers/orders.md | 304 +++-- doc/controllers/plans.md | 346 ++--- doc/controllers/recipients.md | 488 ++++---- doc/controllers/subscriptions.md | 1114 ++++++++--------- doc/controllers/tokens.md | 70 +- doc/controllers/transfers.md | 40 +- doc/models/create-customer-request.md | 2 +- doc/models/create-kyc-link-response.md | 27 + doc/models/create-order-request.md | 2 +- doc/models/create-subscription-request.md | 2 +- src/ApiHelper.php | 14 +- src/Authentication/BasicAuthManager.php | 9 +- .../BalanceOperationsController.php | 36 +- src/Controllers/ChargesController.php | 236 ++-- src/Controllers/CustomersController.php | 354 +++--- src/Controllers/InvoicesController.php | 208 +-- src/Controllers/OrdersController.php | 216 ++-- src/Controllers/PlansController.php | 184 +-- src/Controllers/RecipientsController.php | 443 +++---- src/Controllers/SubscriptionsController.php | 952 +++++++------- src/Controllers/TokensController.php | 40 +- src/Controllers/TransfersController.php | 24 +- .../Builders/CreateKYCLinkResponseBuilder.php | 102 ++ src/Models/CreateKYCLinkResponse.php | 155 +++ src/PagarmeApiSDKClient.php | 2 +- 31 files changed, 3419 insertions(+), 3091 deletions(-) create mode 100644 doc/models/create-kyc-link-response.md create mode 100644 src/Models/Builders/CreateKYCLinkResponseBuilder.php create mode 100644 src/Models/CreateKYCLinkResponse.php diff --git a/README.md b/README.md index a23aafc..23a4cae 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ To run your project, right click on your PHP file inside your Test project and c ## Initialize the API Client -**_Note:_** Documentation for the client can be found [here.](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.7/doc/client.md) +**_Note:_** Documentation for the client can be found [here.](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.8/doc/client.md) The following parameters are configurable for the API Client: @@ -115,7 +115,7 @@ The following parameters are configurable for the API Client: | `retryOnTimeout` | `bool` | Whether to retry on request timeout.
*Default*: `true` | | `httpStatusCodesToRetry` | `array` | Http status codes to retry against.
*Default*: `408, 413, 429, 500, 502, 503, 504, 521, 522, 524` | | `httpMethodsToRetry` | `array` | Http methods to retry against.
*Default*: `'GET', 'PUT'` | -| `basicAuthCredentials` | [`BasicAuthCredentials`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.7/doc/$a/https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.7/basic-authentication.md) | The Credentials Setter for Basic Authentication | +| `basicAuthCredentials` | [`BasicAuthCredentials`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.8/doc/$a/https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.8/basic-authentication.md) | The Credentials Setter for Basic Authentication | The API client can be initialized as follows: @@ -135,7 +135,7 @@ $client = PagarmeApiSDKClientBuilder::init() This API uses the following authentication schemes. -* [`httpBasic (Basic Authentication)`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.7/doc/$a/https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.7/basic-authentication.md) +* [`httpBasic (Basic Authentication)`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.8/doc/$a/https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.8/basic-authentication.md) ## API Errors @@ -143,31 +143,31 @@ Here is the list of errors that the API might throw. | HTTP Status Code | Error Description | Exception Class | | --- | --- | --- | -| 400 | Invalid request | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.7/doc/models/error-exception.md) | -| 401 | Invalid API key | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.7/doc/models/error-exception.md) | -| 404 | An informed resource was not found | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.7/doc/models/error-exception.md) | -| 412 | Business validation error | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.7/doc/models/error-exception.md) | -| 422 | Contract validation error | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.7/doc/models/error-exception.md) | -| 500 | Internal server error | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.7/doc/models/error-exception.md) | +| 400 | Invalid request | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.8/doc/models/error-exception.md) | +| 401 | Invalid API key | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.8/doc/models/error-exception.md) | +| 404 | An informed resource was not found | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.8/doc/models/error-exception.md) | +| 412 | Business validation error | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.8/doc/models/error-exception.md) | +| 422 | Contract validation error | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.8/doc/models/error-exception.md) | +| 500 | Internal server error | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.8/doc/models/error-exception.md) | ## List of APIs -* [Subscriptions](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.7/doc/controllers/subscriptions.md) -* [Orders](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.7/doc/controllers/orders.md) -* [Plans](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.7/doc/controllers/plans.md) -* [Invoices](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.7/doc/controllers/invoices.md) -* [Customers](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.7/doc/controllers/customers.md) -* [Charges](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.7/doc/controllers/charges.md) -* [Recipients](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.7/doc/controllers/recipients.md) -* [Tokens](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.7/doc/controllers/tokens.md) -* [Transactions](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.7/doc/controllers/transactions.md) -* [Transfers](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.7/doc/controllers/transfers.md) -* [Payables](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.7/doc/controllers/payables.md) -* [Balance Operations](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.7/doc/controllers/balance-operations.md) +* [Subscriptions](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.8/doc/controllers/subscriptions.md) +* [Orders](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.8/doc/controllers/orders.md) +* [Plans](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.8/doc/controllers/plans.md) +* [Invoices](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.8/doc/controllers/invoices.md) +* [Customers](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.8/doc/controllers/customers.md) +* [Charges](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.8/doc/controllers/charges.md) +* [Recipients](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.8/doc/controllers/recipients.md) +* [Tokens](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.8/doc/controllers/tokens.md) +* [Transactions](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.8/doc/controllers/transactions.md) +* [Transfers](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.8/doc/controllers/transfers.md) +* [Payables](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.8/doc/controllers/payables.md) +* [Balance Operations](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.8/doc/controllers/balance-operations.md) ## Classes Documentation -* [ApiException](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.7/doc/api-exception.md) -* [HttpRequest](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.7/doc/http-request.md) -* [HttpResponse](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.7/doc/http-response.md) +* [ApiException](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.8/doc/api-exception.md) +* [HttpRequest](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.8/doc/http-request.md) +* [HttpResponse](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.8/doc/http-response.md) diff --git a/composer.json b/composer.json index 09d1ffa..0bf44ed 100644 --- a/composer.json +++ b/composer.json @@ -22,8 +22,8 @@ "php": "^7.2 || ^8.0", "ext-json": "*", "apimatic/unirest-php": "^4.0.0", - "apimatic/core-interfaces": "~0.1.0", - "apimatic/core": "~0.3.0" + "apimatic/core-interfaces": "~0.1.4", + "apimatic/core": "~0.3.8" }, "require-dev": { "squizlabs/php_codesniffer": "^3.5", diff --git a/doc/controllers/balance-operations.md b/doc/controllers/balance-operations.md index fcbcf9a..c397f2f 100644 --- a/doc/controllers/balance-operations.md +++ b/doc/controllers/balance-operations.md @@ -10,62 +10,62 @@ $balanceOperationsController = $client->getBalanceOperationsController(); ## Methods -* [Get Balance Operation by Id](../../doc/controllers/balance-operations.md#get-balance-operation-by-id) * [Get Balance Operations](../../doc/controllers/balance-operations.md#get-balance-operations) +* [Get Balance Operation by Id](../../doc/controllers/balance-operations.md#get-balance-operation-by-id) -# Get Balance Operation by Id +# Get Balance Operations ```php -function getBalanceOperationById(int $id): GetBalanceOperationResponse +function getBalanceOperations( + ?string $status = null, + ?\DateTime $createdSince = null, + ?\DateTime $createdUntil = null, + ?string $recipientId = null +): ListBalanceOperationResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `id` | `int` | Template, Required | - | +| `status` | `?string` | Query, Optional | - | +| `createdSince` | `?DateTime` | Query, Optional | - | +| `createdUntil` | `?DateTime` | Query, Optional | - | +| `recipientId` | `?string` | Query, Optional | - | ## Response Type -[`GetBalanceOperationResponse`](../../doc/models/get-balance-operation-response.md) +[`ListBalanceOperationResponse`](../../doc/models/list-balance-operation-response.md) ## Example Usage ```php -$id = 112; - -$result = $balanceOperationsController->getBalanceOperationById($id); +$result = $balanceOperationsController->getBalanceOperations(); ``` -# Get Balance Operations +# Get Balance Operation by Id ```php -function getBalanceOperations( - ?string $status = null, - ?\DateTime $createdSince = null, - ?\DateTime $createdUntil = null, - ?string $recipientId = null -): ListBalanceOperationResponse +function getBalanceOperationById(int $id): GetBalanceOperationResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `status` | `?string` | Query, Optional | - | -| `createdSince` | `?DateTime` | Query, Optional | - | -| `createdUntil` | `?DateTime` | Query, Optional | - | -| `recipientId` | `?string` | Query, Optional | - | +| `id` | `int` | Template, Required | - | ## Response Type -[`ListBalanceOperationResponse`](../../doc/models/list-balance-operation-response.md) +[`GetBalanceOperationResponse`](../../doc/models/get-balance-operation-response.md) ## Example Usage ```php -$result = $balanceOperationsController->getBalanceOperations(); +$id = 112; + +$result = $balanceOperationsController->getBalanceOperationById($id); ``` diff --git a/doc/controllers/charges.md b/doc/controllers/charges.md index 3dcbff2..525cdd3 100644 --- a/doc/controllers/charges.md +++ b/doc/controllers/charges.md @@ -11,18 +11,18 @@ $chargesController = $client->getChargesController(); ## Methods * [Update Charge Metadata](../../doc/controllers/charges.md#update-charge-metadata) -* [Capture Charge](../../doc/controllers/charges.md#capture-charge) -* [Get Charge](../../doc/controllers/charges.md#get-charge) -* [Confirm Payment](../../doc/controllers/charges.md#confirm-payment) -* [Get Charge Transactions](../../doc/controllers/charges.md#get-charge-transactions) -* [Update Charge Card](../../doc/controllers/charges.md#update-charge-card) -* [Create Charge](../../doc/controllers/charges.md#create-charge) * [Update Charge Payment Method](../../doc/controllers/charges.md#update-charge-payment-method) +* [Get Charge Transactions](../../doc/controllers/charges.md#get-charge-transactions) * [Update Charge Due Date](../../doc/controllers/charges.md#update-charge-due-date) +* [Get Charges](../../doc/controllers/charges.md#get-charges) +* [Capture Charge](../../doc/controllers/charges.md#capture-charge) +* [Update Charge Card](../../doc/controllers/charges.md#update-charge-card) +* [Get Charge](../../doc/controllers/charges.md#get-charge) * [Get Charges Summary](../../doc/controllers/charges.md#get-charges-summary) * [Retry Charge](../../doc/controllers/charges.md#retry-charge) -* [Get Charges](../../doc/controllers/charges.md#get-charges) * [Cancel Charge](../../doc/controllers/charges.md#cancel-charge) +* [Create Charge](../../doc/controllers/charges.md#create-charge) +* [Confirm Payment](../../doc/controllers/charges.md#confirm-payment) # Update Charge Metadata @@ -67,14 +67,14 @@ $result = $chargesController->updateChargeMetadata( ``` -# Capture Charge +# Update Charge Payment Method -Captures a charge +Updates a charge's payment method ```php -function captureCharge( +function updateChargePaymentMethod( string $chargeId, - ?CreateCaptureChargeRequest $request = null, + UpdateChargePaymentMethodRequest $request, ?string $idempotencyKey = null ): GetChargeResponse ``` @@ -84,7 +84,7 @@ function captureCharge( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `chargeId` | `string` | Template, Required | Charge id | -| `request` | [`?CreateCaptureChargeRequest`](../../doc/models/create-capture-charge-request.md) | Body, Optional | Request for capturing a charge | +| `request` | [`UpdateChargePaymentMethodRequest`](../../doc/models/update-charge-payment-method-request.md) | Body, Required | Request for updating the payment method from a charge | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -96,43 +96,97 @@ function captureCharge( ```php $chargeId = 'charge_id8'; -$result = $chargesController->captureCharge($chargeId); -``` +$request = UpdateChargePaymentMethodRequestBuilder::init( + false, + 'payment_method4', + CreateCreditCardPaymentRequestBuilder::init() + ->installments(1) + ->capture(true) + ->recurrencyCycle('"first" or "subsequent"') + ->build(), + CreateDebitCardPaymentRequestBuilder::init()->build(), + CreateBoletoPaymentRequestBuilder::init( + 226, + 'instructions2', + CreateAddressRequestBuilder::init( + 'street8', + 'number4', + 'zip_code2', + 'neighborhood4', + 'city2', + 'state6', + 'country2', + 'complement6', + 'line_18', + 'line_26' + )->build(), + 'document_number6', + 'statement_descriptor0' + )->build(), + CreateVoucherPaymentRequestBuilder::init() + ->recurrencyCycle('"first" or "subsequent"') + ->build(), + CreateCashPaymentRequestBuilder::init( + 'description0', + false + )->build(), + CreateBankTransferPaymentRequestBuilder::init( + 'bank0', + 236 + )->build(), + CreatePrivateLabelPaymentRequestBuilder::init() + ->installments(1) + ->capture(true) + ->recurrencyCycle('"first" or "subsequent"') + ->build() +)->build(); +$result = $chargesController->updateChargePaymentMethod( + $chargeId, + $request +); +``` -# Get Charge -Get a charge from its id +# Get Charge Transactions ```php -function getCharge(string $chargeId): GetChargeResponse +function getChargeTransactions( + string $chargeId, + ?int $page = null, + ?int $size = null +): ListChargeTransactionsResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `chargeId` | `string` | Template, Required | Charge id | +| `chargeId` | `string` | Template, Required | Charge Id | +| `page` | `?int` | Query, Optional | Page number | +| `size` | `?int` | Query, Optional | Page size | ## Response Type -[`GetChargeResponse`](../../doc/models/get-charge-response.md) +[`ListChargeTransactionsResponse`](../../doc/models/list-charge-transactions-response.md) ## Example Usage ```php $chargeId = 'charge_id8'; -$result = $chargesController->getCharge($chargeId); +$result = $chargesController->getChargeTransactions($chargeId); ``` -# Confirm Payment +# Update Charge Due Date + +Updates the due date from a charge ```php -function confirmPayment( +function updateChargeDueDate( string $chargeId, - ?CreateConfirmPaymentRequest $request = null, + UpdateChargeDueDateRequest $request, ?string $idempotencyKey = null ): GetChargeResponse ``` @@ -141,8 +195,8 @@ function confirmPayment( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `chargeId` | `string` | Template, Required | - | -| `request` | [`?CreateConfirmPaymentRequest`](../../doc/models/create-confirm-payment-request.md) | Body, Optional | Request for confirm payment | +| `chargeId` | `string` | Template, Required | Charge Id | +| `request` | [`UpdateChargeDueDateRequest`](../../doc/models/update-charge-due-date-request.md) | Body, Required | Request for updating the due date | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -154,49 +208,66 @@ function confirmPayment( ```php $chargeId = 'charge_id8'; -$result = $chargesController->confirmPayment($chargeId); +$request = UpdateChargeDueDateRequestBuilder::init()->build(); + +$result = $chargesController->updateChargeDueDate( + $chargeId, + $request +); ``` -# Get Charge Transactions +# Get Charges + +Lists all charges ```php -function getChargeTransactions( - string $chargeId, +function getCharges( ?int $page = null, - ?int $size = null -): ListChargeTransactionsResponse + ?int $size = null, + ?string $code = null, + ?string $status = null, + ?string $paymentMethod = null, + ?string $customerId = null, + ?string $orderId = null, + ?\DateTime $createdSince = null, + ?\DateTime $createdUntil = null +): ListChargesResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `chargeId` | `string` | Template, Required | Charge Id | | `page` | `?int` | Query, Optional | Page number | | `size` | `?int` | Query, Optional | Page size | +| `code` | `?string` | Query, Optional | Filter for charge's code | +| `status` | `?string` | Query, Optional | Filter for charge's status | +| `paymentMethod` | `?string` | Query, Optional | Filter for charge's payment method | +| `customerId` | `?string` | Query, Optional | Filter for charge's customer id | +| `orderId` | `?string` | Query, Optional | Filter for charge's order id | +| `createdSince` | `?DateTime` | Query, Optional | Filter for the beginning of the range for charge's creation | +| `createdUntil` | `?DateTime` | Query, Optional | Filter for the end of the range for charge's creation | ## Response Type -[`ListChargeTransactionsResponse`](../../doc/models/list-charge-transactions-response.md) +[`ListChargesResponse`](../../doc/models/list-charges-response.md) ## Example Usage ```php -$chargeId = 'charge_id8'; - -$result = $chargesController->getChargeTransactions($chargeId); +$result = $chargesController->getCharges(); ``` -# Update Charge Card +# Capture Charge -Updates the card from a charge +Captures a charge ```php -function updateChargeCard( +function captureCharge( string $chargeId, - UpdateChargeCardRequest $request, + ?CreateCaptureChargeRequest $request = null, ?string $idempotencyKey = null ): GetChargeResponse ``` @@ -206,7 +277,7 @@ function updateChargeCard( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `chargeId` | `string` | Template, Required | Charge id | -| `request` | [`UpdateChargeCardRequest`](../../doc/models/update-charge-card-request.md) | Body, Required | Request for updating a charge's card | +| `request` | [`?CreateCaptureChargeRequest`](../../doc/models/create-capture-charge-request.md) | Body, Optional | Request for capturing a charge | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -218,64 +289,18 @@ function updateChargeCard( ```php $chargeId = 'charge_id8'; -$request = UpdateChargeCardRequestBuilder::init( - false, - 'card_id2', - CreateCardRequestBuilder::init() - ->type('credit') - ->build(), - false -)->build(); - -$result = $chargesController->updateChargeCard( - $chargeId, - $request -); -``` - - -# Create Charge - -Creates a new charge - -```php -function createCharge(CreateChargeRequest $request, ?string $idempotencyKey = null): GetChargeResponse -``` - -## Parameters - -| Parameter | Type | Tags | Description | -| --- | --- | --- | --- | -| `request` | [`CreateChargeRequest`](../../doc/models/create-charge-request.md) | Body, Required | Request for creating a charge | -| `idempotencyKey` | `?string` | Header, Optional | - | - -## Response Type - -[`GetChargeResponse`](../../doc/models/get-charge-response.md) - -## Example Usage - -```php -$request = CreateChargeRequestBuilder::init( - 242, - CreatePaymentRequestBuilder::init( - 'payment_method4' - )->build(), - 'order_id0' -)->build(); - -$result = $chargesController->createCharge($request); +$result = $chargesController->captureCharge($chargeId); ``` -# Update Charge Payment Method +# Update Charge Card -Updates a charge's payment method +Updates the card from a charge ```php -function updateChargePaymentMethod( +function updateChargeCard( string $chargeId, - UpdateChargePaymentMethodRequest $request, + UpdateChargeCardRequest $request, ?string $idempotencyKey = null ): GetChargeResponse ``` @@ -285,7 +310,7 @@ function updateChargePaymentMethod( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `chargeId` | `string` | Template, Required | Charge id | -| `request` | [`UpdateChargePaymentMethodRequest`](../../doc/models/update-charge-payment-method-request.md) | Body, Required | Request for updating the payment method from a charge | +| `request` | [`UpdateChargeCardRequest`](../../doc/models/update-charge-card-request.md) | Body, Required | Request for updating a charge's card | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -297,77 +322,35 @@ function updateChargePaymentMethod( ```php $chargeId = 'charge_id8'; -$request = UpdateChargePaymentMethodRequestBuilder::init( +$request = UpdateChargeCardRequestBuilder::init( false, - 'payment_method4', - CreateCreditCardPaymentRequestBuilder::init() - ->installments(1) - ->capture(true) - ->recurrencyCycle('"first" or "subsequent"') - ->build(), - CreateDebitCardPaymentRequestBuilder::init()->build(), - CreateBoletoPaymentRequestBuilder::init( - 226, - 'instructions2', - CreateAddressRequestBuilder::init( - 'street8', - 'number4', - 'zip_code2', - 'neighborhood4', - 'city2', - 'state6', - 'country2', - 'complement6', - 'line_18', - 'line_26' - )->build(), - 'document_number6', - 'statement_descriptor0' - )->build(), - CreateVoucherPaymentRequestBuilder::init() - ->recurrencyCycle('"first" or "subsequent"') + 'card_id2', + CreateCardRequestBuilder::init() + ->type('credit') ->build(), - CreateCashPaymentRequestBuilder::init( - 'description0', - false - )->build(), - CreateBankTransferPaymentRequestBuilder::init( - 'bank0', - 236 - )->build(), - CreatePrivateLabelPaymentRequestBuilder::init() - ->installments(1) - ->capture(true) - ->recurrencyCycle('"first" or "subsequent"') - ->build() + false )->build(); -$result = $chargesController->updateChargePaymentMethod( +$result = $chargesController->updateChargeCard( $chargeId, $request ); ``` -# Update Charge Due Date +# Get Charge -Updates the due date from a charge +Get a charge from its id ```php -function updateChargeDueDate( - string $chargeId, - UpdateChargeDueDateRequest $request, - ?string $idempotencyKey = null -): GetChargeResponse +function getCharge(string $chargeId): GetChargeResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `chargeId` | `string` | Template, Required | Charge Id | -| `request` | [`UpdateChargeDueDateRequest`](../../doc/models/update-charge-due-date-request.md) | Body, Required | Request for updating the due date | -| `idempotencyKey` | `?string` | Header, Optional | - | +| `chargeId` | `string` | Template, Required | Charge id | ## Response Type @@ -378,12 +361,7 @@ function updateChargeDueDate( ```php $chargeId = 'charge_id8'; -$request = UpdateChargeDueDateRequestBuilder::init()->build(); - -$result = $chargesController->updateChargeDueDate( - $chargeId, - $request -); +$result = $chargesController->getCharge($chargeId); ``` @@ -446,57 +424,79 @@ $result = $chargesController->retryCharge($chargeId); ``` -# Get Charges +# Cancel Charge -Lists all charges +Cancel a charge ```php -function getCharges( - ?int $page = null, - ?int $size = null, - ?string $code = null, - ?string $status = null, - ?string $paymentMethod = null, - ?string $customerId = null, - ?string $orderId = null, - ?\DateTime $createdSince = null, - ?\DateTime $createdUntil = null -): ListChargesResponse +function cancelCharge( + string $chargeId, + ?CreateCancelChargeRequest $request = null, + ?string $idempotencyKey = null +): GetChargeResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `page` | `?int` | Query, Optional | Page number | -| `size` | `?int` | Query, Optional | Page size | -| `code` | `?string` | Query, Optional | Filter for charge's code | -| `status` | `?string` | Query, Optional | Filter for charge's status | -| `paymentMethod` | `?string` | Query, Optional | Filter for charge's payment method | -| `customerId` | `?string` | Query, Optional | Filter for charge's customer id | -| `orderId` | `?string` | Query, Optional | Filter for charge's order id | -| `createdSince` | `?DateTime` | Query, Optional | Filter for the beginning of the range for charge's creation | -| `createdUntil` | `?DateTime` | Query, Optional | Filter for the end of the range for charge's creation | +| `chargeId` | `string` | Template, Required | Charge id | +| `request` | [`?CreateCancelChargeRequest`](../../doc/models/create-cancel-charge-request.md) | Body, Optional | Request for cancelling a charge | +| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`ListChargesResponse`](../../doc/models/list-charges-response.md) +[`GetChargeResponse`](../../doc/models/get-charge-response.md) ## Example Usage ```php -$result = $chargesController->getCharges(); +$chargeId = 'charge_id8'; + +$result = $chargesController->cancelCharge($chargeId); ``` -# Cancel Charge +# Create Charge -Cancel a charge +Creates a new charge ```php -function cancelCharge( +function createCharge(CreateChargeRequest $request, ?string $idempotencyKey = null): GetChargeResponse +``` + +## Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `request` | [`CreateChargeRequest`](../../doc/models/create-charge-request.md) | Body, Required | Request for creating a charge | +| `idempotencyKey` | `?string` | Header, Optional | - | + +## Response Type + +[`GetChargeResponse`](../../doc/models/get-charge-response.md) + +## Example Usage + +```php +$request = CreateChargeRequestBuilder::init( + 242, + CreatePaymentRequestBuilder::init( + 'payment_method4' + )->build(), + 'order_id0' +)->build(); + +$result = $chargesController->createCharge($request); +``` + + +# Confirm Payment + +```php +function confirmPayment( string $chargeId, - ?CreateCancelChargeRequest $request = null, + ?CreateConfirmPaymentRequest $request = null, ?string $idempotencyKey = null ): GetChargeResponse ``` @@ -505,8 +505,8 @@ function cancelCharge( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `chargeId` | `string` | Template, Required | Charge id | -| `request` | [`?CreateCancelChargeRequest`](../../doc/models/create-cancel-charge-request.md) | Body, Optional | Request for cancelling a charge | +| `chargeId` | `string` | Template, Required | - | +| `request` | [`?CreateConfirmPaymentRequest`](../../doc/models/create-confirm-payment-request.md) | Body, Optional | Request for confirm payment | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -518,6 +518,6 @@ function cancelCharge( ```php $chargeId = 'charge_id8'; -$result = $chargesController->cancelCharge($chargeId); +$result = $chargesController->confirmPayment($chargeId); ``` diff --git a/doc/controllers/customers.md b/doc/controllers/customers.md index e7d88e3..4679a21 100644 --- a/doc/controllers/customers.md +++ b/doc/controllers/customers.md @@ -10,39 +10,40 @@ $customersController = $client->getCustomersController(); ## Methods -* [Create Address](../../doc/controllers/customers.md#create-address) * [Update Card](../../doc/controllers/customers.md#update-card) +* [Update Address](../../doc/controllers/customers.md#update-address) * [Delete Access Token](../../doc/controllers/customers.md#delete-access-token) * [Create Customer](../../doc/controllers/customers.md#create-customer) +* [Create Address](../../doc/controllers/customers.md#create-address) * [Delete Access Tokens](../../doc/controllers/customers.md#delete-access-tokens) -* [Update Address](../../doc/controllers/customers.md#update-address) * [Get Address](../../doc/controllers/customers.md#get-address) * [Delete Address](../../doc/controllers/customers.md#delete-address) -* [Get Customers](../../doc/controllers/customers.md#get-customers) -* [Get Access Tokens](../../doc/controllers/customers.md#get-access-tokens) -* [Delete Card](../../doc/controllers/customers.md#delete-card) -* [Get Card](../../doc/controllers/customers.md#get-card) * [Create Card](../../doc/controllers/customers.md#create-card) -* [Get Access Token](../../doc/controllers/customers.md#get-access-token) -* [Get Addresses](../../doc/controllers/customers.md#get-addresses) +* [Get Customers](../../doc/controllers/customers.md#get-customers) * [Update Customer](../../doc/controllers/customers.md#update-customer) * [Create Access Token](../../doc/controllers/customers.md#create-access-token) +* [Get Access Tokens](../../doc/controllers/customers.md#get-access-tokens) * [Get Cards](../../doc/controllers/customers.md#get-cards) * [Renew Card](../../doc/controllers/customers.md#renew-card) +* [Get Access Token](../../doc/controllers/customers.md#get-access-token) * [Update Customer Metadata](../../doc/controllers/customers.md#update-customer-metadata) +* [Delete Card](../../doc/controllers/customers.md#delete-card) +* [Get Addresses](../../doc/controllers/customers.md#get-addresses) * [Get Customer](../../doc/controllers/customers.md#get-customer) +* [Get Card](../../doc/controllers/customers.md#get-card) -# Create Address +# Update Card -Creates a new address for a customer +Updates a card ```php -function createAddress( +function updateCard( string $customerId, - CreateAddressRequest $request, + string $cardId, + UpdateCardRequest $request, ?string $idempotencyKey = null -): GetAddressResponse +): GetCardResponse ``` ## Parameters @@ -50,49 +51,62 @@ function createAddress( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `customerId` | `string` | Template, Required | Customer Id | -| `request` | [`CreateAddressRequest`](../../doc/models/create-address-request.md) | Body, Required | Request for creating an address | +| `cardId` | `string` | Template, Required | Card id | +| `request` | [`UpdateCardRequest`](../../doc/models/update-card-request.md) | Body, Required | Request for updating a card | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`GetAddressResponse`](../../doc/models/get-address-response.md) +[`GetCardResponse`](../../doc/models/get-card-response.md) ## Example Usage ```php $customerId = 'customer_id8'; -$request = CreateAddressRequestBuilder::init( - 'street6', - 'number4', - 'zip_code0', - 'neighborhood2', - 'city6', - 'state2', - 'country0', - 'complement2', - 'line_10', - 'line_24' +$cardId = 'card_id4'; + +$request = UpdateCardRequestBuilder::init( + 'holder_name2', + 10, + 30, + CreateAddressRequestBuilder::init( + 'street8', + 'number4', + 'zip_code2', + 'neighborhood4', + 'city2', + 'state6', + 'country2', + 'complement6', + 'line_18', + 'line_26' + )->build(), + [ + 'key0' => 'metadata3' + ], + 'label6' )->build(); -$result = $customersController->createAddress( +$result = $customersController->updateCard( $customerId, + $cardId, $request ); ``` -# Update Card +# Update Address -Updates a card +Updates an address ```php -function updateCard( +function updateAddress( string $customerId, - string $cardId, - UpdateCardRequest $request, + string $addressId, + UpdateAddressRequest $request, ?string $idempotencyKey = null -): GetCardResponse +): GetAddressResponse ``` ## Parameters @@ -100,46 +114,33 @@ function updateCard( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `customerId` | `string` | Template, Required | Customer Id | -| `cardId` | `string` | Template, Required | Card id | -| `request` | [`UpdateCardRequest`](../../doc/models/update-card-request.md) | Body, Required | Request for updating a card | +| `addressId` | `string` | Template, Required | Address Id | +| `request` | [`UpdateAddressRequest`](../../doc/models/update-address-request.md) | Body, Required | Request for updating an address | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`GetCardResponse`](../../doc/models/get-card-response.md) +[`GetAddressResponse`](../../doc/models/get-address-response.md) ## Example Usage ```php $customerId = 'customer_id8'; -$cardId = 'card_id4'; +$addressId = 'address_id0'; -$request = UpdateCardRequestBuilder::init( - 'holder_name2', - 10, - 30, - CreateAddressRequestBuilder::init( - 'street8', - 'number4', - 'zip_code2', - 'neighborhood4', - 'city2', - 'state6', - 'country2', - 'complement6', - 'line_18', - 'line_26' - )->build(), +$request = UpdateAddressRequestBuilder::init( + 'number4', + 'complement2', [ 'key0' => 'metadata3' ], - 'label6' + 'line_24' )->build(); -$result = $customersController->updateCard( +$result = $customersController->updateAddress( $customerId, - $cardId, + $addressId, $request ); ``` @@ -206,9 +207,7 @@ function createCustomer(CreateCustomerRequest $request, ?string $idempotencyKey ```php $request = CreateCustomerRequestBuilder::init( - '{ - "name": "Tony Stark" -}', + 'Tony Stark', 'email0', 'document0', 'type4', @@ -235,12 +234,16 @@ $result = $customersController->createCustomer($request); ``` -# Delete Access Tokens +# Create Address -Delete a Customer's access tokens +Creates a new address for a customer ```php -function deleteAccessTokens(string $customerId): ListAccessTokensResponse +function createAddress( + string $customerId, + CreateAddressRequest $request, + ?string $idempotencyKey = null +): GetAddressResponse ``` ## Parameters @@ -248,31 +251,44 @@ function deleteAccessTokens(string $customerId): ListAccessTokensResponse | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `customerId` | `string` | Template, Required | Customer Id | +| `request` | [`CreateAddressRequest`](../../doc/models/create-address-request.md) | Body, Required | Request for creating an address | +| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`ListAccessTokensResponse`](../../doc/models/list-access-tokens-response.md) +[`GetAddressResponse`](../../doc/models/get-address-response.md) ## Example Usage ```php $customerId = 'customer_id8'; -$result = $customersController->deleteAccessTokens($customerId); +$request = CreateAddressRequestBuilder::init( + 'street6', + 'number4', + 'zip_code0', + 'neighborhood2', + 'city6', + 'state2', + 'country0', + 'complement2', + 'line_10', + 'line_24' +)->build(); + +$result = $customersController->createAddress( + $customerId, + $request +); ``` -# Update Address +# Delete Access Tokens -Updates an address +Delete a Customer's access tokens ```php -function updateAddress( - string $customerId, - string $addressId, - UpdateAddressRequest $request, - ?string $idempotencyKey = null -): GetAddressResponse +function deleteAccessTokens(string $customerId): ListAccessTokensResponse ``` ## Parameters @@ -280,35 +296,17 @@ function updateAddress( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `customerId` | `string` | Template, Required | Customer Id | -| `addressId` | `string` | Template, Required | Address Id | -| `request` | [`UpdateAddressRequest`](../../doc/models/update-address-request.md) | Body, Required | Request for updating an address | -| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`GetAddressResponse`](../../doc/models/get-address-response.md) +[`ListAccessTokensResponse`](../../doc/models/list-access-tokens-response.md) ## Example Usage ```php $customerId = 'customer_id8'; -$addressId = 'address_id0'; - -$request = UpdateAddressRequestBuilder::init( - 'number4', - 'complement2', - [ - 'key0' => 'metadata3' - ], - 'line_24' -)->build(); - -$result = $customersController->updateAddress( - $customerId, - $addressId, - $request -); +$result = $customersController->deleteAccessTokens($customerId); ``` @@ -383,6 +381,46 @@ $result = $customersController->deleteAddress( ``` +# Create Card + +Creates a new card for a customer + +```php +function createCard( + string $customerId, + CreateCardRequest $request, + ?string $idempotencyKey = null +): GetCardResponse +``` + +## Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `customerId` | `string` | Template, Required | Customer id | +| `request` | [`CreateCardRequest`](../../doc/models/create-card-request.md) | Body, Required | Request for creating a card | +| `idempotencyKey` | `?string` | Header, Optional | - | + +## Response Type + +[`GetCardResponse`](../../doc/models/get-card-response.md) + +## Example Usage + +```php +$customerId = 'customer_id8'; + +$request = CreateCardRequestBuilder::init() + ->type('credit') + ->build(); + +$result = $customersController->createCard( + $customerId, + $request +); +``` + + # Get Customers Get all Customers @@ -429,41 +467,54 @@ $result = $customersController->getCustomers( ``` -# Get Access Tokens +# Update Customer -Get all access tokens from a customer +Updates a customer ```php -function getAccessTokens(string $customerId, ?int $page = null, ?int $size = null): ListAccessTokensResponse +function updateCustomer( + string $customerId, + UpdateCustomerRequest $request, + ?string $idempotencyKey = null +): GetCustomerResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `customerId` | `string` | Template, Required | Customer Id | -| `page` | `?int` | Query, Optional | Page number | -| `size` | `?int` | Query, Optional | Page size | +| `customerId` | `string` | Template, Required | Customer id | +| `request` | [`UpdateCustomerRequest`](../../doc/models/update-customer-request.md) | Body, Required | Request for updating a customer | +| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`ListAccessTokensResponse`](../../doc/models/list-access-tokens-response.md) +[`GetCustomerResponse`](../../doc/models/get-customer-response.md) ## Example Usage ```php $customerId = 'customer_id8'; -$result = $customersController->getAccessTokens($customerId); +$request = UpdateCustomerRequestBuilder::init()->build(); + +$result = $customersController->updateCustomer( + $customerId, + $request +); ``` -# Delete Card +# Create Access Token -Delete a customer's card +Creates a access token for a customer ```php -function deleteCard(string $customerId, string $cardId, ?string $idempotencyKey = null): GetCardResponse +function createAccessToken( + string $customerId, + CreateAccessTokenRequest $request, + ?string $idempotencyKey = null +): GetAccessTokenResponse ``` ## Parameters @@ -471,170 +522,160 @@ function deleteCard(string $customerId, string $cardId, ?string $idempotencyKey | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `customerId` | `string` | Template, Required | Customer Id | -| `cardId` | `string` | Template, Required | Card Id | +| `request` | [`CreateAccessTokenRequest`](../../doc/models/create-access-token-request.md) | Body, Required | Request for creating a access token | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`GetCardResponse`](../../doc/models/get-card-response.md) +[`GetAccessTokenResponse`](../../doc/models/get-access-token-response.md) ## Example Usage ```php $customerId = 'customer_id8'; -$cardId = 'card_id4'; +$request = CreateAccessTokenRequestBuilder::init()->build(); -$result = $customersController->deleteCard( +$result = $customersController->createAccessToken( $customerId, - $cardId + $request ); ``` -# Get Card +# Get Access Tokens -Get a customer's card +Get all access tokens from a customer ```php -function getCard(string $customerId, string $cardId): GetCardResponse +function getAccessTokens(string $customerId, ?int $page = null, ?int $size = null): ListAccessTokensResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `customerId` | `string` | Template, Required | Customer id | -| `cardId` | `string` | Template, Required | Card id | +| `customerId` | `string` | Template, Required | Customer Id | +| `page` | `?int` | Query, Optional | Page number | +| `size` | `?int` | Query, Optional | Page size | ## Response Type -[`GetCardResponse`](../../doc/models/get-card-response.md) +[`ListAccessTokensResponse`](../../doc/models/list-access-tokens-response.md) ## Example Usage ```php $customerId = 'customer_id8'; -$cardId = 'card_id4'; - -$result = $customersController->getCard( - $customerId, - $cardId -); +$result = $customersController->getAccessTokens($customerId); ``` -# Create Card +# Get Cards -Creates a new card for a customer +Get all cards from a customer ```php -function createCard( - string $customerId, - CreateCardRequest $request, - ?string $idempotencyKey = null -): GetCardResponse +function getCards(string $customerId, ?int $page = null, ?int $size = null): ListCardsResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `customerId` | `string` | Template, Required | Customer id | -| `request` | [`CreateCardRequest`](../../doc/models/create-card-request.md) | Body, Required | Request for creating a card | -| `idempotencyKey` | `?string` | Header, Optional | - | +| `customerId` | `string` | Template, Required | Customer Id | +| `page` | `?int` | Query, Optional | Page number | +| `size` | `?int` | Query, Optional | Page size | ## Response Type -[`GetCardResponse`](../../doc/models/get-card-response.md) +[`ListCardsResponse`](../../doc/models/list-cards-response.md) ## Example Usage ```php $customerId = 'customer_id8'; -$request = CreateCardRequestBuilder::init() - ->type('credit') - ->build(); - -$result = $customersController->createCard( - $customerId, - $request -); +$result = $customersController->getCards($customerId); ``` -# Get Access Token +# Renew Card -Get a Customer's access token +Renew a card ```php -function getAccessToken(string $customerId, string $tokenId): GetAccessTokenResponse +function renewCard(string $customerId, string $cardId, ?string $idempotencyKey = null): GetCardResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `customerId` | `string` | Template, Required | Customer Id | -| `tokenId` | `string` | Template, Required | Token Id | +| `customerId` | `string` | Template, Required | Customer id | +| `cardId` | `string` | Template, Required | Card Id | +| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`GetAccessTokenResponse`](../../doc/models/get-access-token-response.md) +[`GetCardResponse`](../../doc/models/get-card-response.md) ## Example Usage ```php $customerId = 'customer_id8'; -$tokenId = 'token_id6'; +$cardId = 'card_id4'; -$result = $customersController->getAccessToken( +$result = $customersController->renewCard( $customerId, - $tokenId + $cardId ); ``` -# Get Addresses +# Get Access Token -Gets all adressess from a customer +Get a Customer's access token ```php -function getAddresses(string $customerId, ?int $page = null, ?int $size = null): ListAddressesResponse +function getAccessToken(string $customerId, string $tokenId): GetAccessTokenResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `customerId` | `string` | Template, Required | Customer id | -| `page` | `?int` | Query, Optional | Page number | -| `size` | `?int` | Query, Optional | Page size | +| `customerId` | `string` | Template, Required | Customer Id | +| `tokenId` | `string` | Template, Required | Token Id | ## Response Type -[`ListAddressesResponse`](../../doc/models/list-addresses-response.md) +[`GetAccessTokenResponse`](../../doc/models/get-access-token-response.md) ## Example Usage ```php $customerId = 'customer_id8'; -$result = $customersController->getAddresses($customerId); +$tokenId = 'token_id6'; + +$result = $customersController->getAccessToken( + $customerId, + $tokenId +); ``` -# Update Customer +# Update Customer Metadata -Updates a customer +Updates the metadata a customer ```php -function updateCustomer( +function updateCustomerMetadata( string $customerId, - UpdateCustomerRequest $request, + UpdateMetadataRequest $request, ?string $idempotencyKey = null ): GetCustomerResponse ``` @@ -643,8 +684,8 @@ function updateCustomer( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `customerId` | `string` | Template, Required | Customer id | -| `request` | [`UpdateCustomerRequest`](../../doc/models/update-customer-request.md) | Body, Required | Request for updating a customer | +| `customerId` | `string` | Template, Required | The customer id | +| `request` | [`UpdateMetadataRequest`](../../doc/models/update-metadata-request.md) | Body, Required | Request for updating the customer metadata | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -656,25 +697,25 @@ function updateCustomer( ```php $customerId = 'customer_id8'; -$request = UpdateCustomerRequestBuilder::init()->build(); +$request = UpdateMetadataRequestBuilder::init( + [ + 'key0' => 'metadata3' + ] +)->build(); -$result = $customersController->updateCustomer( +$result = $customersController->updateCustomerMetadata( $customerId, $request ); ``` -# Create Access Token +# Delete Card -Creates a access token for a customer +Delete a customer's card ```php -function createAccessToken( - string $customerId, - CreateAccessTokenRequest $request, - ?string $idempotencyKey = null -): GetAccessTokenResponse +function deleteCard(string $customerId, string $cardId, ?string $idempotencyKey = null): GetCardResponse ``` ## Parameters @@ -682,155 +723,112 @@ function createAccessToken( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `customerId` | `string` | Template, Required | Customer Id | -| `request` | [`CreateAccessTokenRequest`](../../doc/models/create-access-token-request.md) | Body, Required | Request for creating a access token | +| `cardId` | `string` | Template, Required | Card Id | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`GetAccessTokenResponse`](../../doc/models/get-access-token-response.md) +[`GetCardResponse`](../../doc/models/get-card-response.md) ## Example Usage ```php $customerId = 'customer_id8'; -$request = CreateAccessTokenRequestBuilder::init()->build(); +$cardId = 'card_id4'; -$result = $customersController->createAccessToken( +$result = $customersController->deleteCard( $customerId, - $request + $cardId ); ``` -# Get Cards +# Get Addresses -Get all cards from a customer +Gets all adressess from a customer ```php -function getCards(string $customerId, ?int $page = null, ?int $size = null): ListCardsResponse +function getAddresses(string $customerId, ?int $page = null, ?int $size = null): ListAddressesResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `customerId` | `string` | Template, Required | Customer Id | +| `customerId` | `string` | Template, Required | Customer id | | `page` | `?int` | Query, Optional | Page number | | `size` | `?int` | Query, Optional | Page size | ## Response Type -[`ListCardsResponse`](../../doc/models/list-cards-response.md) +[`ListAddressesResponse`](../../doc/models/list-addresses-response.md) ## Example Usage ```php $customerId = 'customer_id8'; -$result = $customersController->getCards($customerId); +$result = $customersController->getAddresses($customerId); ``` -# Renew Card +# Get Customer -Renew a card +Get a customer ```php -function renewCard(string $customerId, string $cardId, ?string $idempotencyKey = null): GetCardResponse +function getCustomer(string $customerId): GetCustomerResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `customerId` | `string` | Template, Required | Customer id | -| `cardId` | `string` | Template, Required | Card Id | -| `idempotencyKey` | `?string` | Header, Optional | - | +| `customerId` | `string` | Template, Required | Customer Id | ## Response Type -[`GetCardResponse`](../../doc/models/get-card-response.md) +[`GetCustomerResponse`](../../doc/models/get-customer-response.md) ## Example Usage ```php $customerId = 'customer_id8'; -$cardId = 'card_id4'; - -$result = $customersController->renewCard( - $customerId, - $cardId -); +$result = $customersController->getCustomer($customerId); ``` -# Update Customer Metadata +# Get Card -Updates the metadata a customer +Get a customer's card ```php -function updateCustomerMetadata( - string $customerId, - UpdateMetadataRequest $request, - ?string $idempotencyKey = null -): GetCustomerResponse +function getCard(string $customerId, string $cardId): GetCardResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `customerId` | `string` | Template, Required | The customer id | -| `request` | [`UpdateMetadataRequest`](../../doc/models/update-metadata-request.md) | Body, Required | Request for updating the customer metadata | -| `idempotencyKey` | `?string` | Header, Optional | - | +| `customerId` | `string` | Template, Required | Customer id | +| `cardId` | `string` | Template, Required | Card id | ## Response Type -[`GetCustomerResponse`](../../doc/models/get-customer-response.md) +[`GetCardResponse`](../../doc/models/get-card-response.md) ## Example Usage ```php $customerId = 'customer_id8'; -$request = UpdateMetadataRequestBuilder::init( - [ - 'key0' => 'metadata3' - ] -)->build(); +$cardId = 'card_id4'; -$result = $customersController->updateCustomerMetadata( +$result = $customersController->getCard( $customerId, - $request + $cardId ); ``` - -# Get Customer - -Get a customer - -```php -function getCustomer(string $customerId): GetCustomerResponse -``` - -## Parameters - -| Parameter | Type | Tags | Description | -| --- | --- | --- | --- | -| `customerId` | `string` | Template, Required | Customer Id | - -## Response Type - -[`GetCustomerResponse`](../../doc/models/get-customer-response.md) - -## Example Usage - -```php -$customerId = 'customer_id8'; - -$result = $customersController->getCustomer($customerId); -``` - diff --git a/doc/controllers/invoices.md b/doc/controllers/invoices.md index bdc4068..4400978 100644 --- a/doc/controllers/invoices.md +++ b/doc/controllers/invoices.md @@ -10,76 +10,68 @@ $invoicesController = $client->getInvoicesController(); ## Methods -* [Get Invoices](../../doc/controllers/invoices.md#get-invoices) -* [Cancel Invoice](../../doc/controllers/invoices.md#cancel-invoice) -* [Update Invoice Status](../../doc/controllers/invoices.md#update-invoice-status) * [Update Invoice Metadata](../../doc/controllers/invoices.md#update-invoice-metadata) * [Get Partial Invoice](../../doc/controllers/invoices.md#get-partial-invoice) +* [Cancel Invoice](../../doc/controllers/invoices.md#cancel-invoice) * [Create Invoice](../../doc/controllers/invoices.md#create-invoice) +* [Get Invoices](../../doc/controllers/invoices.md#get-invoices) * [Get Invoice](../../doc/controllers/invoices.md#get-invoice) +* [Update Invoice Status](../../doc/controllers/invoices.md#update-invoice-status) -# Get Invoices +# Update Invoice Metadata -Gets all invoices +Updates the metadata from an invoice ```php -function getInvoices( - ?int $page = null, - ?int $size = null, - ?string $code = null, - ?string $customerId = null, - ?string $subscriptionId = null, - ?\DateTime $createdSince = null, - ?\DateTime $createdUntil = null, - ?string $status = null, - ?\DateTime $dueSince = null, - ?\DateTime $dueUntil = null, - ?string $customerDocument = null -): ListInvoicesResponse +function updateInvoiceMetadata( + string $invoiceId, + UpdateMetadataRequest $request, + ?string $idempotencyKey = null +): GetInvoiceResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `page` | `?int` | Query, Optional | Page number | -| `size` | `?int` | Query, Optional | Page size | -| `code` | `?string` | Query, Optional | Filter for Invoice's code | -| `customerId` | `?string` | Query, Optional | Filter for Invoice's customer id | -| `subscriptionId` | `?string` | Query, Optional | Filter for Invoice's subscription id | -| `createdSince` | `?DateTime` | Query, Optional | Filter for Invoice's creation date start range | -| `createdUntil` | `?DateTime` | Query, Optional | Filter for Invoices creation date end range | -| `status` | `?string` | Query, Optional | Filter for Invoice's status | -| `dueSince` | `?DateTime` | Query, Optional | Filter for Invoice's due date start range | -| `dueUntil` | `?DateTime` | Query, Optional | Filter for Invoice's due date end range | -| `customerDocument` | `?string` | Query, Optional | - | +| `invoiceId` | `string` | Template, Required | The invoice id | +| `request` | [`UpdateMetadataRequest`](../../doc/models/update-metadata-request.md) | Body, Required | Request for updating the invoice metadata | +| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`ListInvoicesResponse`](../../doc/models/list-invoices-response.md) +[`GetInvoiceResponse`](../../doc/models/get-invoice-response.md) ## Example Usage ```php -$result = $invoicesController->getInvoices(); -``` +$invoiceId = 'invoice_id0'; + +$request = UpdateMetadataRequestBuilder::init( + [ + 'key0' => 'metadata3' + ] +)->build(); +$result = $invoicesController->updateInvoiceMetadata( + $invoiceId, + $request +); +``` -# Cancel Invoice -Cancels an invoice +# Get Partial Invoice ```php -function cancelInvoice(string $invoiceId, ?string $idempotencyKey = null): GetInvoiceResponse +function getPartialInvoice(string $subscriptionId): GetInvoiceResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `invoiceId` | `string` | Template, Required | Invoice id | -| `idempotencyKey` | `?string` | Header, Optional | - | +| `subscriptionId` | `string` | Template, Required | Subscription Id | ## Response Type @@ -88,30 +80,25 @@ function cancelInvoice(string $invoiceId, ?string $idempotencyKey = null): GetIn ## Example Usage ```php -$invoiceId = 'invoice_id0'; +$subscriptionId = 'subscription_id0'; -$result = $invoicesController->cancelInvoice($invoiceId); +$result = $invoicesController->getPartialInvoice($subscriptionId); ``` -# Update Invoice Status +# Cancel Invoice -Updates the status from an invoice +Cancels an invoice ```php -function updateInvoiceStatus( - string $invoiceId, - UpdateInvoiceStatusRequest $request, - ?string $idempotencyKey = null -): GetInvoiceResponse +function cancelInvoice(string $invoiceId, ?string $idempotencyKey = null): GetInvoiceResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `invoiceId` | `string` | Template, Required | Invoice Id | -| `request` | [`UpdateInvoiceStatusRequest`](../../doc/models/update-invoice-status-request.md) | Body, Required | Request for updating an invoice's status | +| `invoiceId` | `string` | Template, Required | Invoice id | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -123,25 +110,19 @@ function updateInvoiceStatus( ```php $invoiceId = 'invoice_id0'; -$request = UpdateInvoiceStatusRequestBuilder::init( - 'status8' -)->build(); - -$result = $invoicesController->updateInvoiceStatus( - $invoiceId, - $request -); +$result = $invoicesController->cancelInvoice($invoiceId); ``` -# Update Invoice Metadata +# Create Invoice -Updates the metadata from an invoice +Create an Invoice ```php -function updateInvoiceMetadata( - string $invoiceId, - UpdateMetadataRequest $request, +function createInvoice( + string $subscriptionId, + string $cycleId, + ?CreateInvoiceRequest $request = null, ?string $idempotencyKey = null ): GetInvoiceResponse ``` @@ -150,8 +131,9 @@ function updateInvoiceMetadata( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `invoiceId` | `string` | Template, Required | The invoice id | -| `request` | [`UpdateMetadataRequest`](../../doc/models/update-metadata-request.md) | Body, Required | Request for updating the invoice metadata | +| `subscriptionId` | `string` | Template, Required | Subscription Id | +| `cycleId` | `string` | Template, Required | Cycle Id | +| `request` | [`?CreateInvoiceRequest`](../../doc/models/create-invoice-request.md) | Body, Optional | - | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -161,67 +143,77 @@ function updateInvoiceMetadata( ## Example Usage ```php -$invoiceId = 'invoice_id0'; +$subscriptionId = 'subscription_id0'; -$request = UpdateMetadataRequestBuilder::init( - [ - 'key0' => 'metadata3' - ] -)->build(); +$cycleId = 'cycle_id6'; -$result = $invoicesController->updateInvoiceMetadata( - $invoiceId, - $request +$result = $invoicesController->createInvoice( + $subscriptionId, + $cycleId ); ``` -# Get Partial Invoice +# Get Invoices + +Gets all invoices ```php -function getPartialInvoice(string $subscriptionId): GetInvoiceResponse +function getInvoices( + ?int $page = null, + ?int $size = null, + ?string $code = null, + ?string $customerId = null, + ?string $subscriptionId = null, + ?\DateTime $createdSince = null, + ?\DateTime $createdUntil = null, + ?string $status = null, + ?\DateTime $dueSince = null, + ?\DateTime $dueUntil = null, + ?string $customerDocument = null +): ListInvoicesResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | Subscription Id | +| `page` | `?int` | Query, Optional | Page number | +| `size` | `?int` | Query, Optional | Page size | +| `code` | `?string` | Query, Optional | Filter for Invoice's code | +| `customerId` | `?string` | Query, Optional | Filter for Invoice's customer id | +| `subscriptionId` | `?string` | Query, Optional | Filter for Invoice's subscription id | +| `createdSince` | `?DateTime` | Query, Optional | Filter for Invoice's creation date start range | +| `createdUntil` | `?DateTime` | Query, Optional | Filter for Invoices creation date end range | +| `status` | `?string` | Query, Optional | Filter for Invoice's status | +| `dueSince` | `?DateTime` | Query, Optional | Filter for Invoice's due date start range | +| `dueUntil` | `?DateTime` | Query, Optional | Filter for Invoice's due date end range | +| `customerDocument` | `?string` | Query, Optional | - | ## Response Type -[`GetInvoiceResponse`](../../doc/models/get-invoice-response.md) +[`ListInvoicesResponse`](../../doc/models/list-invoices-response.md) ## Example Usage ```php -$subscriptionId = 'subscription_id0'; - -$result = $invoicesController->getPartialInvoice($subscriptionId); +$result = $invoicesController->getInvoices(); ``` -# Create Invoice +# Get Invoice -Create an Invoice +Gets an invoice ```php -function createInvoice( - string $subscriptionId, - string $cycleId, - ?CreateInvoiceRequest $request = null, - ?string $idempotencyKey = null -): GetInvoiceResponse +function getInvoice(string $invoiceId): GetInvoiceResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | Subscription Id | -| `cycleId` | `string` | Template, Required | Cycle Id | -| `request` | [`?CreateInvoiceRequest`](../../doc/models/create-invoice-request.md) | Body, Optional | - | -| `idempotencyKey` | `?string` | Header, Optional | - | +| `invoiceId` | `string` | Template, Required | Invoice Id | ## Response Type @@ -230,23 +222,22 @@ function createInvoice( ## Example Usage ```php -$subscriptionId = 'subscription_id0'; - -$cycleId = 'cycle_id6'; +$invoiceId = 'invoice_id0'; -$result = $invoicesController->createInvoice( - $subscriptionId, - $cycleId -); +$result = $invoicesController->getInvoice($invoiceId); ``` -# Get Invoice +# Update Invoice Status -Gets an invoice +Updates the status from an invoice ```php -function getInvoice(string $invoiceId): GetInvoiceResponse +function updateInvoiceStatus( + string $invoiceId, + UpdateInvoiceStatusRequest $request, + ?string $idempotencyKey = null +): GetInvoiceResponse ``` ## Parameters @@ -254,6 +245,8 @@ function getInvoice(string $invoiceId): GetInvoiceResponse | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `invoiceId` | `string` | Template, Required | Invoice Id | +| `request` | [`UpdateInvoiceStatusRequest`](../../doc/models/update-invoice-status-request.md) | Body, Required | Request for updating an invoice's status | +| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -264,6 +257,13 @@ function getInvoice(string $invoiceId): GetInvoiceResponse ```php $invoiceId = 'invoice_id0'; -$result = $invoicesController->getInvoice($invoiceId); +$request = UpdateInvoiceStatusRequestBuilder::init( + 'status8' +)->build(); + +$result = $invoicesController->updateInvoiceStatus( + $invoiceId, + $request +); ``` diff --git a/doc/controllers/orders.md b/doc/controllers/orders.md index c5dbfda..d14ef43 100644 --- a/doc/controllers/orders.md +++ b/doc/controllers/orders.md @@ -10,48 +10,66 @@ $ordersController = $client->getOrdersController(); ## Methods -* [Delete All Order Items](../../doc/controllers/orders.md#delete-all-order-items) -* [Get Order Item](../../doc/controllers/orders.md#get-order-item) -* [Update Order Metadata](../../doc/controllers/orders.md#update-order-metadata) -* [Delete Order Item](../../doc/controllers/orders.md#delete-order-item) -* [Get Order](../../doc/controllers/orders.md#get-order) * [Get Orders](../../doc/controllers/orders.md#get-orders) * [Update Order Item](../../doc/controllers/orders.md#update-order-item) +* [Delete All Order Items](../../doc/controllers/orders.md#delete-all-order-items) +* [Delete Order Item](../../doc/controllers/orders.md#delete-order-item) * [Close Order](../../doc/controllers/orders.md#close-order) * [Create Order](../../doc/controllers/orders.md#create-order) * [Create Order Item](../../doc/controllers/orders.md#create-order-item) +* [Get Order Item](../../doc/controllers/orders.md#get-order-item) +* [Update Order Metadata](../../doc/controllers/orders.md#update-order-metadata) +* [Get Order](../../doc/controllers/orders.md#get-order) -# Delete All Order Items +# Get Orders + +Gets all orders ```php -function deleteAllOrderItems(string $orderId, ?string $idempotencyKey = null): GetOrderResponse +function getOrders( + ?int $page = null, + ?int $size = null, + ?string $code = null, + ?string $status = null, + ?\DateTime $createdSince = null, + ?\DateTime $createdUntil = null, + ?string $customerId = null +): ListOrderResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `orderId` | `string` | Template, Required | Order Id | -| `idempotencyKey` | `?string` | Header, Optional | - | +| `page` | `?int` | Query, Optional | Page number | +| `size` | `?int` | Query, Optional | Page size | +| `code` | `?string` | Query, Optional | Filter for order's code | +| `status` | `?string` | Query, Optional | Filter for order's status | +| `createdSince` | `?DateTime` | Query, Optional | Filter for order's creation date start range | +| `createdUntil` | `?DateTime` | Query, Optional | Filter for order's creation date end range | +| `customerId` | `?string` | Query, Optional | Filter for order's customer id | ## Response Type -[`GetOrderResponse`](../../doc/models/get-order-response.md) +[`ListOrderResponse`](../../doc/models/list-order-response.md) ## Example Usage ```php -$orderId = 'orderId2'; - -$result = $ordersController->deleteAllOrderItems($orderId); +$result = $ordersController->getOrders(); ``` -# Get Order Item +# Update Order Item ```php -function getOrderItem(string $orderId, string $itemId): GetOrderItemResponse +function updateOrderItem( + string $orderId, + string $itemId, + UpdateOrderItemRequest $request, + ?string $idempotencyKey = null +): GetOrderItemResponse ``` ## Parameters @@ -60,6 +78,8 @@ function getOrderItem(string $orderId, string $itemId): GetOrderItemResponse | --- | --- | --- | --- | | `orderId` | `string` | Template, Required | Order Id | | `itemId` | `string` | Template, Required | Item Id | +| `request` | [`UpdateOrderItemRequest`](../../doc/models/update-order-item-request.md) | Body, Required | Item Model | +| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -72,59 +92,25 @@ $orderId = 'orderId2'; $itemId = 'itemId8'; -$result = $ordersController->getOrderItem( - $orderId, - $itemId -); -``` - - -# Update Order Metadata - -Updates the metadata from an order - -```php -function updateOrderMetadata( - string $orderId, - UpdateMetadataRequest $request, - ?string $idempotencyKey = null -): GetOrderResponse -``` - -## Parameters - -| Parameter | Type | Tags | Description | -| --- | --- | --- | --- | -| `orderId` | `string` | Template, Required | The order id | -| `request` | [`UpdateMetadataRequest`](../../doc/models/update-metadata-request.md) | Body, Required | Request for updating the order metadata | -| `idempotencyKey` | `?string` | Header, Optional | - | - -## Response Type - -[`GetOrderResponse`](../../doc/models/get-order-response.md) - -## Example Usage - -```php -$orderId = 'order_id6'; - -$request = UpdateMetadataRequestBuilder::init( - [ - 'key0' => 'metadata3' - ] +$request = UpdateOrderItemRequestBuilder::init( + 242, + 'description6', + 100, + 'category4' )->build(); -$result = $ordersController->updateOrderMetadata( +$result = $ordersController->updateOrderItem( $orderId, + $itemId, $request ); ``` -# Delete Order Item +# Delete All Order Items ```php -function deleteOrderItem(string $orderId, string $itemId, ?string $idempotencyKey = null): GetOrderItemResponse +function deleteAllOrderItems(string $orderId, ?string $idempotencyKey = null): GetOrderResponse ``` ## Parameters @@ -132,102 +118,25 @@ function deleteOrderItem(string $orderId, string $itemId, ?string $idempotencyKe | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orderId` | `string` | Template, Required | Order Id | -| `itemId` | `string` | Template, Required | Item Id | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`GetOrderItemResponse`](../../doc/models/get-order-item-response.md) - -## Example Usage - -```php -$orderId = 'orderId2'; - -$itemId = 'itemId8'; - -$result = $ordersController->deleteOrderItem( - $orderId, - $itemId -); -``` - - -# Get Order - -Gets an order - -```php -function getOrder(string $orderId): GetOrderResponse -``` - -## Parameters - -| Parameter | Type | Tags | Description | -| --- | --- | --- | --- | -| `orderId` | `string` | Template, Required | Order id | - -## Response Type - [`GetOrderResponse`](../../doc/models/get-order-response.md) ## Example Usage ```php -$orderId = 'order_id6'; - -$result = $ordersController->getOrder($orderId); -``` - - -# Get Orders - -Gets all orders - -```php -function getOrders( - ?int $page = null, - ?int $size = null, - ?string $code = null, - ?string $status = null, - ?\DateTime $createdSince = null, - ?\DateTime $createdUntil = null, - ?string $customerId = null -): ListOrderResponse -``` - -## Parameters - -| Parameter | Type | Tags | Description | -| --- | --- | --- | --- | -| `page` | `?int` | Query, Optional | Page number | -| `size` | `?int` | Query, Optional | Page size | -| `code` | `?string` | Query, Optional | Filter for order's code | -| `status` | `?string` | Query, Optional | Filter for order's status | -| `createdSince` | `?DateTime` | Query, Optional | Filter for order's creation date start range | -| `createdUntil` | `?DateTime` | Query, Optional | Filter for order's creation date end range | -| `customerId` | `?string` | Query, Optional | Filter for order's customer id | - -## Response Type - -[`ListOrderResponse`](../../doc/models/list-order-response.md) - -## Example Usage +$orderId = 'orderId2'; -```php -$result = $ordersController->getOrders(); +$result = $ordersController->deleteAllOrderItems($orderId); ``` -# Update Order Item +# Delete Order Item ```php -function updateOrderItem( - string $orderId, - string $itemId, - UpdateOrderItemRequest $request, - ?string $idempotencyKey = null -): GetOrderItemResponse +function deleteOrderItem(string $orderId, string $itemId, ?string $idempotencyKey = null): GetOrderItemResponse ``` ## Parameters @@ -236,7 +145,6 @@ function updateOrderItem( | --- | --- | --- | --- | | `orderId` | `string` | Template, Required | Order Id | | `itemId` | `string` | Template, Required | Item Id | -| `request` | [`UpdateOrderItemRequest`](../../doc/models/update-order-item-request.md) | Body, Required | Item Model | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -250,17 +158,9 @@ $orderId = 'orderId2'; $itemId = 'itemId8'; -$request = UpdateOrderItemRequestBuilder::init( - 242, - 'description6', - 100, - 'category4' -)->build(); - -$result = $ordersController->updateOrderItem( +$result = $ordersController->deleteOrderItem( $orderId, - $itemId, - $request + $itemId ); ``` @@ -335,9 +235,7 @@ $body = CreateOrderRequestBuilder::init( )->build() ], CreateCustomerRequestBuilder::init( - '{ - "name": "Tony Stark" -}', + 'Tony Stark', 'email6', 'document6', 'type0', @@ -412,3 +310,103 @@ $result = $ordersController->createOrderItem( ); ``` + +# Get Order Item + +```php +function getOrderItem(string $orderId, string $itemId): GetOrderItemResponse +``` + +## Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `orderId` | `string` | Template, Required | Order Id | +| `itemId` | `string` | Template, Required | Item Id | + +## Response Type + +[`GetOrderItemResponse`](../../doc/models/get-order-item-response.md) + +## Example Usage + +```php +$orderId = 'orderId2'; + +$itemId = 'itemId8'; + +$result = $ordersController->getOrderItem( + $orderId, + $itemId +); +``` + + +# Update Order Metadata + +Updates the metadata from an order + +```php +function updateOrderMetadata( + string $orderId, + UpdateMetadataRequest $request, + ?string $idempotencyKey = null +): GetOrderResponse +``` + +## Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `orderId` | `string` | Template, Required | The order id | +| `request` | [`UpdateMetadataRequest`](../../doc/models/update-metadata-request.md) | Body, Required | Request for updating the order metadata | +| `idempotencyKey` | `?string` | Header, Optional | - | + +## Response Type + +[`GetOrderResponse`](../../doc/models/get-order-response.md) + +## Example Usage + +```php +$orderId = 'order_id6'; + +$request = UpdateMetadataRequestBuilder::init( + [ + 'key0' => 'metadata3' + ] +)->build(); + +$result = $ordersController->updateOrderMetadata( + $orderId, + $request +); +``` + + +# Get Order + +Gets an order + +```php +function getOrder(string $orderId): GetOrderResponse +``` + +## Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `orderId` | `string` | Template, Required | Order id | + +## Response Type + +[`GetOrderResponse`](../../doc/models/get-order-response.md) + +## Example Usage + +```php +$orderId = 'order_id6'; + +$result = $ordersController->getOrder($orderId); +``` + diff --git a/doc/controllers/plans.md b/doc/controllers/plans.md index 993dd00..f2be784 100644 --- a/doc/controllers/plans.md +++ b/doc/controllers/plans.md @@ -11,15 +11,15 @@ $plansController = $client->getPlansController(); ## Methods * [Get Plan](../../doc/controllers/plans.md#get-plan) -* [Delete Plan Item](../../doc/controllers/plans.md#delete-plan-item) -* [Update Plan Metadata](../../doc/controllers/plans.md#update-plan-metadata) -* [Create Plan](../../doc/controllers/plans.md#create-plan) -* [Update Plan](../../doc/controllers/plans.md#update-plan) * [Delete Plan](../../doc/controllers/plans.md#delete-plan) -* [Get Plans](../../doc/controllers/plans.md#get-plans) +* [Update Plan Metadata](../../doc/controllers/plans.md#update-plan-metadata) * [Update Plan Item](../../doc/controllers/plans.md#update-plan-item) * [Create Plan Item](../../doc/controllers/plans.md#create-plan-item) * [Get Plan Item](../../doc/controllers/plans.md#get-plan-item) +* [Create Plan](../../doc/controllers/plans.md#create-plan) +* [Delete Plan Item](../../doc/controllers/plans.md#delete-plan-item) +* [Get Plans](../../doc/controllers/plans.md#get-plans) +* [Update Plan](../../doc/controllers/plans.md#update-plan) # Get Plan @@ -49,12 +49,12 @@ $result = $plansController->getPlan($planId); ``` -# Delete Plan Item +# Delete Plan -Removes an item from a plan +Deletes a plan ```php -function deletePlanItem(string $planId, string $planItemId, ?string $idempotencyKey = null): GetPlanItemResponse +function deletePlan(string $planId, ?string $idempotencyKey = null): GetPlanResponse ``` ## Parameters @@ -62,24 +62,18 @@ function deletePlanItem(string $planId, string $planItemId, ?string $idempotency | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `planId` | `string` | Template, Required | Plan id | -| `planItemId` | `string` | Template, Required | Plan item id | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`GetPlanItemResponse`](../../doc/models/get-plan-item-response.md) +[`GetPlanResponse`](../../doc/models/get-plan-response.md) ## Example Usage ```php $planId = 'plan_id8'; -$planItemId = 'plan_item_id0'; - -$result = $plansController->deletePlanItem( - $planId, - $planItemId -); +$result = $plansController->deletePlan($planId); ``` @@ -125,76 +119,72 @@ $result = $plansController->updatePlanMetadata( ``` -# Create Plan +# Update Plan Item -Creates a new plan +Updates a plan item ```php -function createPlan(CreatePlanRequest $body, ?string $idempotencyKey = null): GetPlanResponse +function updatePlanItem( + string $planId, + string $planItemId, + UpdatePlanItemRequest $body, + ?string $idempotencyKey = null +): GetPlanItemResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `body` | [`CreatePlanRequest`](../../doc/models/create-plan-request.md) | Body, Required | Request for creating a plan | +| `planId` | `string` | Template, Required | Plan id | +| `planItemId` | `string` | Template, Required | Plan item id | +| `body` | [`UpdatePlanItemRequest`](../../doc/models/update-plan-item-request.md) | Body, Required | Request for updating the plan item | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`GetPlanResponse`](../../doc/models/get-plan-response.md) +[`GetPlanItemResponse`](../../doc/models/get-plan-item-response.md) ## Example Usage ```php -$body = CreatePlanRequestBuilder::init( +$planId = 'plan_id8'; + +$planItemId = 'plan_item_id0'; + +$body = UpdatePlanItemRequestBuilder::init( 'name6', 'description4', - 'statement_descriptor6', - [ - CreatePlanItemRequestBuilder::init( - 'name8', - CreatePricingSchemeRequestBuilder::init( - 'scheme_type8' - )->build(), - 'id8', - 'description2' - )->build() - ], - false, - [ - 'payment_methods9' - ], - [ - 207 - ], - 'currency6', - 'interval6', - 170, - [ - 201, - 200 - ], - 'billing_type0', - CreatePricingSchemeRequestBuilder::init( - 'scheme_type8' - )->build(), - [ - 'key0' => 'metadata7', - 'key1' => 'metadata8' - ] + 'status2', + UpdatePricingSchemeRequestBuilder::init( + 'scheme_type8', + [ + UpdatePriceBracketRequestBuilder::init( + 144, + 174 + )->build() + ] + )->build() )->build(); -$result = $plansController->createPlan($body); +$result = $plansController->updatePlanItem( + $planId, + $planItemId, + $body +); ``` -# Update Plan +# Create Plan Item -Updates a plan +Adds a new item to a plan ```php -function updatePlan(string $planId, UpdatePlanRequest $request, ?string $idempotencyKey = null): GetPlanResponse +function createPlanItem( + string $planId, + CreatePlanItemRequest $request, + ?string $idempotencyKey = null +): GetPlanItemResponse ``` ## Parameters @@ -202,58 +192,40 @@ function updatePlan(string $planId, UpdatePlanRequest $request, ?string $idempot | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `planId` | `string` | Template, Required | Plan id | -| `request` | [`UpdatePlanRequest`](../../doc/models/update-plan-request.md) | Body, Required | Request for updating a plan | +| `request` | [`CreatePlanItemRequest`](../../doc/models/create-plan-item-request.md) | Body, Required | Request for creating a plan item | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`GetPlanResponse`](../../doc/models/get-plan-response.md) +[`GetPlanItemResponse`](../../doc/models/get-plan-item-response.md) ## Example Usage ```php $planId = 'plan_id8'; -$request = UpdatePlanRequestBuilder::init( +$request = CreatePlanItemRequestBuilder::init( 'name6', - 'description6', - [ - 151, - 152 - ], - 'statement_descriptor6', - 'currency6', - 'interval4', - 114, - [ - 'payment_methods1', - 'payment_methods0', - 'payment_methods9' - ], - 'billing_type0', - 'status8', - false, - [ - 115 - ], - [ - 'key0' => 'metadata3' - ] + CreatePricingSchemeRequestBuilder::init( + 'scheme_type8' + )->build(), + 'id6', + 'description6' )->build(); -$result = $plansController->updatePlan( +$result = $plansController->createPlanItem( $planId, $request ); ``` -# Delete Plan +# Get Plan Item -Deletes a plan +Gets a plan item ```php -function deletePlan(string $planId, ?string $idempotencyKey = null): GetPlanResponse +function getPlanItem(string $planId, string $planItemId): GetPlanItemResponse ``` ## Parameters @@ -261,71 +233,96 @@ function deletePlan(string $planId, ?string $idempotencyKey = null): GetPlanResp | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `planId` | `string` | Template, Required | Plan id | -| `idempotencyKey` | `?string` | Header, Optional | - | +| `planItemId` | `string` | Template, Required | Plan item id | ## Response Type -[`GetPlanResponse`](../../doc/models/get-plan-response.md) +[`GetPlanItemResponse`](../../doc/models/get-plan-item-response.md) ## Example Usage ```php $planId = 'plan_id8'; -$result = $plansController->deletePlan($planId); +$planItemId = 'plan_item_id0'; + +$result = $plansController->getPlanItem( + $planId, + $planItemId +); ``` -# Get Plans +# Create Plan -Gets all plans +Creates a new plan ```php -function getPlans( - ?int $page = null, - ?int $size = null, - ?string $name = null, - ?string $status = null, - ?string $billingType = null, - ?\DateTime $createdSince = null, - ?\DateTime $createdUntil = null -): ListPlansResponse +function createPlan(CreatePlanRequest $body, ?string $idempotencyKey = null): GetPlanResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `page` | `?int` | Query, Optional | Page number | -| `size` | `?int` | Query, Optional | Page size | -| `name` | `?string` | Query, Optional | Filter for Plan's name | -| `status` | `?string` | Query, Optional | Filter for Plan's status | -| `billingType` | `?string` | Query, Optional | Filter for plan's billing type | -| `createdSince` | `?DateTime` | Query, Optional | Filter for plan's creation date start range | -| `createdUntil` | `?DateTime` | Query, Optional | Filter for plan's creation date end range | +| `body` | [`CreatePlanRequest`](../../doc/models/create-plan-request.md) | Body, Required | Request for creating a plan | +| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`ListPlansResponse`](../../doc/models/list-plans-response.md) +[`GetPlanResponse`](../../doc/models/get-plan-response.md) ## Example Usage ```php -$result = $plansController->getPlans(); +$body = CreatePlanRequestBuilder::init( + 'name6', + 'description4', + 'statement_descriptor6', + [ + CreatePlanItemRequestBuilder::init( + 'name8', + CreatePricingSchemeRequestBuilder::init( + 'scheme_type8' + )->build(), + 'id8', + 'description2' + )->build() + ], + false, + [ + 'payment_methods9' + ], + [ + 207 + ], + 'currency6', + 'interval6', + 170, + [ + 201, + 200 + ], + 'billing_type0', + CreatePricingSchemeRequestBuilder::init( + 'scheme_type8' + )->build(), + [ + 'key0' => 'metadata7', + 'key1' => 'metadata8' + ] +)->build(); + +$result = $plansController->createPlan($body); ``` -# Update Plan Item +# Delete Plan Item -Updates a plan item +Removes an item from a plan ```php -function updatePlanItem( - string $planId, - string $planItemId, - UpdatePlanItemRequest $body, - ?string $idempotencyKey = null -): GetPlanItemResponse +function deletePlanItem(string $planId, string $planItemId, ?string $idempotencyKey = null): GetPlanItemResponse ``` ## Parameters @@ -334,7 +331,6 @@ function updatePlanItem( | --- | --- | --- | --- | | `planId` | `string` | Template, Required | Plan id | | `planItemId` | `string` | Template, Required | Plan item id | -| `body` | [`UpdatePlanItemRequest`](../../doc/models/update-plan-item-request.md) | Body, Required | Request for updating the plan item | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -348,80 +344,58 @@ $planId = 'plan_id8'; $planItemId = 'plan_item_id0'; -$body = UpdatePlanItemRequestBuilder::init( - 'name6', - 'description4', - 'status2', - UpdatePricingSchemeRequestBuilder::init( - 'scheme_type8', - [ - UpdatePriceBracketRequestBuilder::init( - 144, - 174 - )->build() - ] - )->build() -)->build(); - -$result = $plansController->updatePlanItem( +$result = $plansController->deletePlanItem( $planId, - $planItemId, - $body + $planItemId ); ``` -# Create Plan Item +# Get Plans -Adds a new item to a plan +Gets all plans ```php -function createPlanItem( - string $planId, - CreatePlanItemRequest $request, - ?string $idempotencyKey = null -): GetPlanItemResponse +function getPlans( + ?int $page = null, + ?int $size = null, + ?string $name = null, + ?string $status = null, + ?string $billingType = null, + ?\DateTime $createdSince = null, + ?\DateTime $createdUntil = null +): ListPlansResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `planId` | `string` | Template, Required | Plan id | -| `request` | [`CreatePlanItemRequest`](../../doc/models/create-plan-item-request.md) | Body, Required | Request for creating a plan item | -| `idempotencyKey` | `?string` | Header, Optional | - | +| `page` | `?int` | Query, Optional | Page number | +| `size` | `?int` | Query, Optional | Page size | +| `name` | `?string` | Query, Optional | Filter for Plan's name | +| `status` | `?string` | Query, Optional | Filter for Plan's status | +| `billingType` | `?string` | Query, Optional | Filter for plan's billing type | +| `createdSince` | `?DateTime` | Query, Optional | Filter for plan's creation date start range | +| `createdUntil` | `?DateTime` | Query, Optional | Filter for plan's creation date end range | ## Response Type -[`GetPlanItemResponse`](../../doc/models/get-plan-item-response.md) +[`ListPlansResponse`](../../doc/models/list-plans-response.md) ## Example Usage ```php -$planId = 'plan_id8'; - -$request = CreatePlanItemRequestBuilder::init( - 'name6', - CreatePricingSchemeRequestBuilder::init( - 'scheme_type8' - )->build(), - 'id6', - 'description6' -)->build(); - -$result = $plansController->createPlanItem( - $planId, - $request -); +$result = $plansController->getPlans(); ``` -# Get Plan Item +# Update Plan -Gets a plan item +Updates a plan ```php -function getPlanItem(string $planId, string $planItemId): GetPlanItemResponse +function updatePlan(string $planId, UpdatePlanRequest $request, ?string $idempotencyKey = null): GetPlanResponse ``` ## Parameters @@ -429,22 +403,48 @@ function getPlanItem(string $planId, string $planItemId): GetPlanItemResponse | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `planId` | `string` | Template, Required | Plan id | -| `planItemId` | `string` | Template, Required | Plan item id | +| `request` | [`UpdatePlanRequest`](../../doc/models/update-plan-request.md) | Body, Required | Request for updating a plan | +| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`GetPlanItemResponse`](../../doc/models/get-plan-item-response.md) +[`GetPlanResponse`](../../doc/models/get-plan-response.md) ## Example Usage ```php $planId = 'plan_id8'; -$planItemId = 'plan_item_id0'; +$request = UpdatePlanRequestBuilder::init( + 'name6', + 'description6', + [ + 151, + 152 + ], + 'statement_descriptor6', + 'currency6', + 'interval4', + 114, + [ + 'payment_methods1', + 'payment_methods0', + 'payment_methods9' + ], + 'billing_type0', + 'status8', + false, + [ + 115 + ], + [ + 'key0' => 'metadata3' + ] +)->build(); -$result = $plansController->getPlanItem( +$result = $plansController->updatePlan( $planId, - $planItemId + $request ); ``` diff --git a/doc/controllers/recipients.md b/doc/controllers/recipients.md index 10c6457..b81d63f 100644 --- a/doc/controllers/recipients.md +++ b/doc/controllers/recipients.md @@ -11,26 +11,27 @@ $recipientsController = $client->getRecipientsController(); ## Methods * [Update Recipient](../../doc/controllers/recipients.md#update-recipient) -* [Get Withdraw by Id](../../doc/controllers/recipients.md#get-withdraw-by-id) -* [Get Recipient](../../doc/controllers/recipients.md#get-recipient) -* [Get Balance](../../doc/controllers/recipients.md#get-balance) +* [Create Anticipation](../../doc/controllers/recipients.md#create-anticipation) +* [Get Anticipation Limits](../../doc/controllers/recipients.md#get-anticipation-limits) * [Get Recipients](../../doc/controllers/recipients.md#get-recipients) +* [Get Withdraw by Id](../../doc/controllers/recipients.md#get-withdraw-by-id) * [Update Recipient Default Bank Account](../../doc/controllers/recipients.md#update-recipient-default-bank-account) +* [Update Recipient Metadata](../../doc/controllers/recipients.md#update-recipient-metadata) * [Get Transfers](../../doc/controllers/recipients.md#get-transfers) * [Get Transfer](../../doc/controllers/recipients.md#get-transfer) * [Create Withdraw](../../doc/controllers/recipients.md#create-withdraw) +* [Update Automatic Anticipation Settings](../../doc/controllers/recipients.md#update-automatic-anticipation-settings) * [Get Anticipation](../../doc/controllers/recipients.md#get-anticipation) * [Update Recipient Transfer Settings](../../doc/controllers/recipients.md#update-recipient-transfer-settings) -* [Get Recipient by Code](../../doc/controllers/recipients.md#get-recipient-by-code) -* [Update Automatic Anticipation Settings](../../doc/controllers/recipients.md#update-automatic-anticipation-settings) +* [Get Anticipations](../../doc/controllers/recipients.md#get-anticipations) +* [Get Recipient](../../doc/controllers/recipients.md#get-recipient) +* [Get Balance](../../doc/controllers/recipients.md#get-balance) +* [Get Withdrawals](../../doc/controllers/recipients.md#get-withdrawals) * [Create Transfer](../../doc/controllers/recipients.md#create-transfer) * [Create Recipient](../../doc/controllers/recipients.md#create-recipient) +* [Get Recipient by Code](../../doc/controllers/recipients.md#get-recipient-by-code) * [Get Default Recipient](../../doc/controllers/recipients.md#get-default-recipient) -* [Create Anticipation](../../doc/controllers/recipients.md#create-anticipation) -* [Get Anticipation Limits](../../doc/controllers/recipients.md#get-anticipation-limits) -* [Update Recipient Metadata](../../doc/controllers/recipients.md#update-recipient-metadata) -* [Get Anticipations](../../doc/controllers/recipients.md#get-anticipations) -* [Get Withdrawals](../../doc/controllers/recipients.md#get-withdrawals) +* [Create KYC Link](../../doc/controllers/recipients.md#create-kyc-link) # Update Recipient @@ -80,114 +81,143 @@ $result = $recipientsController->updateRecipient( ``` -# Get Withdraw by Id +# Create Anticipation + +Creates an anticipation ```php -function getWithdrawById(string $recipientId, string $withdrawalId): GetWithdrawResponse +function createAnticipation( + string $recipientId, + CreateAnticipationRequest $request, + ?string $idempotencyKey = null +): GetAnticipationResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `recipientId` | `string` | Template, Required | - | -| `withdrawalId` | `string` | Template, Required | - | +| `recipientId` | `string` | Template, Required | Recipient id | +| `request` | [`CreateAnticipationRequest`](../../doc/models/create-anticipation-request.md) | Body, Required | Anticipation data | +| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`GetWithdrawResponse`](../../doc/models/get-withdraw-response.md) +[`GetAnticipationResponse`](../../doc/models/get-anticipation-response.md) ## Example Usage ```php $recipientId = 'recipient_id0'; -$withdrawalId = 'withdrawal_id2'; +$request = CreateAnticipationRequestBuilder::init( + 242, + 'timeframe8', + DateTimeHelper::fromRfc3339DateTimeRequired('2016-03-13T12:52:32.123Z') +)->build(); -$result = $recipientsController->getWithdrawById( +$result = $recipientsController->createAnticipation( $recipientId, - $withdrawalId + $request ); ``` -# Get Recipient +# Get Anticipation Limits -Retrieves recipient information +Gets the anticipation limits for a recipient ```php -function getRecipient(string $recipientId): GetRecipientResponse +function getAnticipationLimits( + string $recipientId, + string $timeframe, + \DateTime $paymentDate +): GetAnticipationLimitResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `recipientId` | `string` | Template, Required | Recipiend id | +| `recipientId` | `string` | Template, Required | Recipient id | +| `timeframe` | `string` | Query, Required | Timeframe | +| `paymentDate` | `DateTime` | Query, Required | Anticipation payment date | ## Response Type -[`GetRecipientResponse`](../../doc/models/get-recipient-response.md) +[`GetAnticipationLimitResponse`](../../doc/models/get-anticipation-limit-response.md) ## Example Usage ```php $recipientId = 'recipient_id0'; -$result = $recipientsController->getRecipient($recipientId); +$timeframe = 'timeframe2'; + +$paymentDate = DateTimeHelper::fromRfc3339DateTimeRequired('2016-03-13T12:52:32.123Z'); + +$result = $recipientsController->getAnticipationLimits( + $recipientId, + $timeframe, + $paymentDate +); ``` -# Get Balance +# Get Recipients -Get balance information for a recipient +Retrieves paginated recipients information ```php -function getBalance(string $recipientId): GetBalanceResponse +function getRecipients(?int $page = null, ?int $size = null): ListRecipientResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `recipientId` | `string` | Template, Required | Recipient id | +| `page` | `?int` | Query, Optional | Page number | +| `size` | `?int` | Query, Optional | Page size | ## Response Type -[`GetBalanceResponse`](../../doc/models/get-balance-response.md) +[`ListRecipientResponse`](../../doc/models/list-recipient-response.md) ## Example Usage ```php -$recipientId = 'recipient_id0'; - -$result = $recipientsController->getBalance($recipientId); +$result = $recipientsController->getRecipients(); ``` -# Get Recipients - -Retrieves paginated recipients information +# Get Withdraw by Id ```php -function getRecipients(?int $page = null, ?int $size = null): ListRecipientResponse +function getWithdrawById(string $recipientId, string $withdrawalId): GetWithdrawResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `page` | `?int` | Query, Optional | Page number | -| `size` | `?int` | Query, Optional | Page size | +| `recipientId` | `string` | Template, Required | - | +| `withdrawalId` | `string` | Template, Required | - | ## Response Type -[`ListRecipientResponse`](../../doc/models/list-recipient-response.md) +[`GetWithdrawResponse`](../../doc/models/get-withdraw-response.md) ## Example Usage ```php -$result = $recipientsController->getRecipients(); +$recipientId = 'recipient_id0'; + +$withdrawalId = 'withdrawal_id2'; + +$result = $recipientsController->getWithdrawById( + $recipientId, + $withdrawalId +); ``` @@ -245,6 +275,48 @@ $result = $recipientsController->updateRecipientDefaultBankAccount( ``` +# Update Recipient Metadata + +Updates recipient metadata + +```php +function updateRecipientMetadata( + string $recipientId, + UpdateMetadataRequest $request, + ?string $idempotencyKey = null +): GetRecipientResponse +``` + +## Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `recipientId` | `string` | Template, Required | Recipient id | +| `request` | [`UpdateMetadataRequest`](../../doc/models/update-metadata-request.md) | Body, Required | Metadata | +| `idempotencyKey` | `?string` | Header, Optional | - | + +## Response Type + +[`GetRecipientResponse`](../../doc/models/get-recipient-response.md) + +## Example Usage + +```php +$recipientId = 'recipient_id0'; + +$request = UpdateMetadataRequestBuilder::init( + [ + 'key0' => 'metadata3' + ] +)->build(); + +$result = $recipientsController->updateRecipientMetadata( + $recipientId, + $request +); +``` + + # Get Transfers Gets a paginated list of transfers for the recipient @@ -350,6 +422,44 @@ $result = $recipientsController->createWithdraw( ``` +# Update Automatic Anticipation Settings + +Updates recipient metadata + +```php +function updateAutomaticAnticipationSettings( + string $recipientId, + UpdateAutomaticAnticipationSettingsRequest $request, + ?string $idempotencyKey = null +): GetRecipientResponse +``` + +## Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `recipientId` | `string` | Template, Required | Recipient id | +| `request` | [`UpdateAutomaticAnticipationSettingsRequest`](../../doc/models/update-automatic-anticipation-settings-request.md) | Body, Required | Metadata | +| `idempotencyKey` | `?string` | Header, Optional | - | + +## Response Type + +[`GetRecipientResponse`](../../doc/models/get-recipient-response.md) + +## Example Usage + +```php +$recipientId = 'recipient_id0'; + +$request = UpdateAutomaticAnticipationSettingsRequestBuilder::init()->build(); + +$result = $recipientsController->updateAutomaticAnticipationSettings( + $recipientId, + $request +); +``` + + # Get Anticipation Gets an anticipation @@ -423,19 +533,64 @@ $result = $recipientsController->updateRecipientTransferSettings( ``` -# Get Recipient by Code +# Get Anticipations + +Retrieves a paginated list of anticipations from a recipient + +```php +function getAnticipations( + string $recipientId, + ?int $page = null, + ?int $size = null, + ?string $status = null, + ?string $timeframe = null, + ?\DateTime $paymentDateSince = null, + ?\DateTime $paymentDateUntil = null, + ?\DateTime $createdSince = null, + ?\DateTime $createdUntil = null +): ListAnticipationResponse +``` + +## Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `recipientId` | `string` | Template, Required | Recipient id | +| `page` | `?int` | Query, Optional | Page number | +| `size` | `?int` | Query, Optional | Page size | +| `status` | `?string` | Query, Optional | Filter for anticipation status | +| `timeframe` | `?string` | Query, Optional | Filter for anticipation timeframe | +| `paymentDateSince` | `?DateTime` | Query, Optional | Filter for start range for anticipation payment date | +| `paymentDateUntil` | `?DateTime` | Query, Optional | Filter for end range for anticipation payment date | +| `createdSince` | `?DateTime` | Query, Optional | Filter for start range for anticipation creation date | +| `createdUntil` | `?DateTime` | Query, Optional | Filter for end range for anticipation creation date | + +## Response Type + +[`ListAnticipationResponse`](../../doc/models/list-anticipation-response.md) + +## Example Usage + +```php +$recipientId = 'recipient_id0'; + +$result = $recipientsController->getAnticipations($recipientId); +``` + + +# Get Recipient Retrieves recipient information ```php -function getRecipientByCode(string $code): GetRecipientResponse +function getRecipient(string $recipientId): GetRecipientResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `code` | `string` | Template, Required | Recipient code | +| `recipientId` | `string` | Template, Required | Recipiend id | ## Response Type @@ -444,22 +599,18 @@ function getRecipientByCode(string $code): GetRecipientResponse ## Example Usage ```php -$code = 'code8'; +$recipientId = 'recipient_id0'; -$result = $recipientsController->getRecipientByCode($code); +$result = $recipientsController->getRecipient($recipientId); ``` -# Update Automatic Anticipation Settings +# Get Balance -Updates recipient metadata +Get balance information for a recipient ```php -function updateAutomaticAnticipationSettings( - string $recipientId, - UpdateAutomaticAnticipationSettingsRequest $request, - ?string $idempotencyKey = null -): GetRecipientResponse +function getBalance(string $recipientId): GetBalanceResponse ``` ## Parameters @@ -467,24 +618,56 @@ function updateAutomaticAnticipationSettings( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `recipientId` | `string` | Template, Required | Recipient id | -| `request` | [`UpdateAutomaticAnticipationSettingsRequest`](../../doc/models/update-automatic-anticipation-settings-request.md) | Body, Required | Metadata | -| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`GetRecipientResponse`](../../doc/models/get-recipient-response.md) +[`GetBalanceResponse`](../../doc/models/get-balance-response.md) ## Example Usage ```php $recipientId = 'recipient_id0'; -$request = UpdateAutomaticAnticipationSettingsRequestBuilder::init()->build(); +$result = $recipientsController->getBalance($recipientId); +``` -$result = $recipientsController->updateAutomaticAnticipationSettings( - $recipientId, - $request -); + +# Get Withdrawals + +Gets a paginated list of transfers for the recipient + +```php +function getWithdrawals( + string $recipientId, + ?int $page = null, + ?int $size = null, + ?string $status = null, + ?\DateTime $createdSince = null, + ?\DateTime $createdUntil = null +): ListWithdrawals +``` + +## Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `recipientId` | `string` | Template, Required | - | +| `page` | `?int` | Query, Optional | - | +| `size` | `?int` | Query, Optional | - | +| `status` | `?string` | Query, Optional | - | +| `createdSince` | `?DateTime` | Query, Optional | - | +| `createdUntil` | `?DateTime` | Query, Optional | - | + +## Response Type + +[`ListWithdrawals`](../../doc/models/list-withdrawals.md) + +## Example Usage + +```php +$recipientId = 'recipient_id0'; + +$result = $recipientsController->getWithdrawals($recipientId); ``` @@ -580,125 +763,19 @@ $result = $recipientsController->createRecipient($request); ``` -# Get Default Recipient - -```php -function getDefaultRecipient(): GetRecipientResponse -``` - -## Response Type - -[`GetRecipientResponse`](../../doc/models/get-recipient-response.md) - -## Example Usage - -```php -$result = $recipientsController->getDefaultRecipient(); -``` - - -# Create Anticipation - -Creates an anticipation - -```php -function createAnticipation( - string $recipientId, - CreateAnticipationRequest $request, - ?string $idempotencyKey = null -): GetAnticipationResponse -``` - -## Parameters - -| Parameter | Type | Tags | Description | -| --- | --- | --- | --- | -| `recipientId` | `string` | Template, Required | Recipient id | -| `request` | [`CreateAnticipationRequest`](../../doc/models/create-anticipation-request.md) | Body, Required | Anticipation data | -| `idempotencyKey` | `?string` | Header, Optional | - | - -## Response Type - -[`GetAnticipationResponse`](../../doc/models/get-anticipation-response.md) - -## Example Usage - -```php -$recipientId = 'recipient_id0'; - -$request = CreateAnticipationRequestBuilder::init( - 242, - 'timeframe8', - DateTimeHelper::fromRfc3339DateTimeRequired('2016-03-13T12:52:32.123Z') -)->build(); - -$result = $recipientsController->createAnticipation( - $recipientId, - $request -); -``` - - -# Get Anticipation Limits - -Gets the anticipation limits for a recipient - -```php -function getAnticipationLimits( - string $recipientId, - string $timeframe, - \DateTime $paymentDate -): GetAnticipationLimitResponse -``` - -## Parameters - -| Parameter | Type | Tags | Description | -| --- | --- | --- | --- | -| `recipientId` | `string` | Template, Required | Recipient id | -| `timeframe` | `string` | Query, Required | Timeframe | -| `paymentDate` | `DateTime` | Query, Required | Anticipation payment date | - -## Response Type - -[`GetAnticipationLimitResponse`](../../doc/models/get-anticipation-limit-response.md) - -## Example Usage - -```php -$recipientId = 'recipient_id0'; - -$timeframe = 'timeframe2'; - -$paymentDate = DateTimeHelper::fromRfc3339DateTimeRequired('2016-03-13T12:52:32.123Z'); - -$result = $recipientsController->getAnticipationLimits( - $recipientId, - $timeframe, - $paymentDate -); -``` - - -# Update Recipient Metadata +# Get Recipient by Code -Updates recipient metadata +Retrieves recipient information ```php -function updateRecipientMetadata( - string $recipientId, - UpdateMetadataRequest $request, - ?string $idempotencyKey = null -): GetRecipientResponse +function getRecipientByCode(string $code): GetRecipientResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `recipientId` | `string` | Template, Required | Recipient id | -| `request` | [`UpdateMetadataRequest`](../../doc/models/update-metadata-request.md) | Body, Required | Metadata | -| `idempotencyKey` | `?string` | Header, Optional | - | +| `code` | `string` | Template, Required | Recipient code | ## Response Type @@ -707,79 +784,35 @@ function updateRecipientMetadata( ## Example Usage ```php -$recipientId = 'recipient_id0'; - -$request = UpdateMetadataRequestBuilder::init( - [ - 'key0' => 'metadata3' - ] -)->build(); +$code = 'code8'; -$result = $recipientsController->updateRecipientMetadata( - $recipientId, - $request -); +$result = $recipientsController->getRecipientByCode($code); ``` -# Get Anticipations - -Retrieves a paginated list of anticipations from a recipient +# Get Default Recipient ```php -function getAnticipations( - string $recipientId, - ?int $page = null, - ?int $size = null, - ?string $status = null, - ?string $timeframe = null, - ?\DateTime $paymentDateSince = null, - ?\DateTime $paymentDateUntil = null, - ?\DateTime $createdSince = null, - ?\DateTime $createdUntil = null -): ListAnticipationResponse +function getDefaultRecipient(): GetRecipientResponse ``` -## Parameters - -| Parameter | Type | Tags | Description | -| --- | --- | --- | --- | -| `recipientId` | `string` | Template, Required | Recipient id | -| `page` | `?int` | Query, Optional | Page number | -| `size` | `?int` | Query, Optional | Page size | -| `status` | `?string` | Query, Optional | Filter for anticipation status | -| `timeframe` | `?string` | Query, Optional | Filter for anticipation timeframe | -| `paymentDateSince` | `?DateTime` | Query, Optional | Filter for start range for anticipation payment date | -| `paymentDateUntil` | `?DateTime` | Query, Optional | Filter for end range for anticipation payment date | -| `createdSince` | `?DateTime` | Query, Optional | Filter for start range for anticipation creation date | -| `createdUntil` | `?DateTime` | Query, Optional | Filter for end range for anticipation creation date | - ## Response Type -[`ListAnticipationResponse`](../../doc/models/list-anticipation-response.md) +[`GetRecipientResponse`](../../doc/models/get-recipient-response.md) ## Example Usage ```php -$recipientId = 'recipient_id0'; - -$result = $recipientsController->getAnticipations($recipientId); +$result = $recipientsController->getDefaultRecipient(); ``` -# Get Withdrawals +# Create KYC Link -Gets a paginated list of transfers for the recipient +Create a KYC link ```php -function getWithdrawals( - string $recipientId, - ?int $page = null, - ?int $size = null, - ?string $status = null, - ?\DateTime $createdSince = null, - ?\DateTime $createdUntil = null -): ListWithdrawals +function createKYCLink(string $recipientId): CreateKYCLinkResponse ``` ## Parameters @@ -787,21 +820,16 @@ function getWithdrawals( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `recipientId` | `string` | Template, Required | - | -| `page` | `?int` | Query, Optional | - | -| `size` | `?int` | Query, Optional | - | -| `status` | `?string` | Query, Optional | - | -| `createdSince` | `?DateTime` | Query, Optional | - | -| `createdUntil` | `?DateTime` | Query, Optional | - | ## Response Type -[`ListWithdrawals`](../../doc/models/list-withdrawals.md) +[`CreateKYCLinkResponse`](../../doc/models/create-kyc-link-response.md) ## Example Usage ```php $recipientId = 'recipient_id0'; -$result = $recipientsController->getWithdrawals($recipientId); +$result = $recipientsController->createKYCLink($recipientId); ``` diff --git a/doc/controllers/subscriptions.md b/doc/controllers/subscriptions.md index bb1213b..cc41c0d 100644 --- a/doc/controllers/subscriptions.md +++ b/doc/controllers/subscriptions.md @@ -10,42 +10,68 @@ $subscriptionsController = $client->getSubscriptionsController(); ## Methods -* [Update Subscription Card](../../doc/controllers/subscriptions.md#update-subscription-card) -* [Create Discount](../../doc/controllers/subscriptions.md#create-discount) -* [Update Subscription Billing Date](../../doc/controllers/subscriptions.md#update-subscription-billing-date) -* [Update Subscription Start At](../../doc/controllers/subscriptions.md#update-subscription-start-at) -* [Get Subscription](../../doc/controllers/subscriptions.md#get-subscription) -* [Get Usages](../../doc/controllers/subscriptions.md#get-usages) -* [Update Latest Period End At](../../doc/controllers/subscriptions.md#update-latest-period-end-at) -* [Delete Discount](../../doc/controllers/subscriptions.md#delete-discount) -* [Update Subscription Payment Method](../../doc/controllers/subscriptions.md#update-subscription-payment-method) -* [Cancel Subscription](../../doc/controllers/subscriptions.md#cancel-subscription) -* [Create Subscription](../../doc/controllers/subscriptions.md#create-subscription) -* [Update Subscription Affiliation Id](../../doc/controllers/subscriptions.md#update-subscription-affiliation-id) -* [Update Subscription Minium Price](../../doc/controllers/subscriptions.md#update-subscription-minium-price) -* [Get Subscription Cycle by Id](../../doc/controllers/subscriptions.md#get-subscription-cycle-by-id) -* [Get Usage Report](../../doc/controllers/subscriptions.md#get-usage-report) * [Renew Subscription](../../doc/controllers/subscriptions.md#renew-subscription) +* [Update Subscription Card](../../doc/controllers/subscriptions.md#update-subscription-card) * [Delete Usage](../../doc/controllers/subscriptions.md#delete-usage) +* [Create Discount](../../doc/controllers/subscriptions.md#create-discount) * [Create an Usage](../../doc/controllers/subscriptions.md#create-an-usage) * [Update Current Cycle Status](../../doc/controllers/subscriptions.md#update-current-cycle-status) -* [Get Subscription Item](../../doc/controllers/subscriptions.md#get-subscription-item) -* [Get Increment by Id](../../doc/controllers/subscriptions.md#get-increment-by-id) -* [Delete Increment](../../doc/controllers/subscriptions.md#delete-increment) -* [Get Discounts](../../doc/controllers/subscriptions.md#get-discounts) -* [Update Subscription Due Days](../../doc/controllers/subscriptions.md#update-subscription-due-days) -* [Create Subscription Item](../../doc/controllers/subscriptions.md#create-subscription-item) -* [Update Split Subscription](../../doc/controllers/subscriptions.md#update-split-subscription) +* [Delete Discount](../../doc/controllers/subscriptions.md#delete-discount) * [Get Subscription Items](../../doc/controllers/subscriptions.md#get-subscription-items) +* [Update Subscription Payment Method](../../doc/controllers/subscriptions.md#update-subscription-payment-method) +* [Get Subscription Item](../../doc/controllers/subscriptions.md#get-subscription-item) * [Get Subscriptions](../../doc/controllers/subscriptions.md#get-subscriptions) +* [Cancel Subscription](../../doc/controllers/subscriptions.md#cancel-subscription) * [Create Increment](../../doc/controllers/subscriptions.md#create-increment) * [Create Usage](../../doc/controllers/subscriptions.md#create-usage) * [Get Discount by Id](../../doc/controllers/subscriptions.md#get-discount-by-id) +* [Create Subscription](../../doc/controllers/subscriptions.md#create-subscription) +* [Get Increment by Id](../../doc/controllers/subscriptions.md#get-increment-by-id) +* [Update Subscription Affiliation Id](../../doc/controllers/subscriptions.md#update-subscription-affiliation-id) * [Update Subscription Metadata](../../doc/controllers/subscriptions.md#update-subscription-metadata) +* [Delete Increment](../../doc/controllers/subscriptions.md#delete-increment) * [Get Subscription Cycles](../../doc/controllers/subscriptions.md#get-subscription-cycles) +* [Get Discounts](../../doc/controllers/subscriptions.md#get-discounts) +* [Update Subscription Billing Date](../../doc/controllers/subscriptions.md#update-subscription-billing-date) * [Delete Subscription Item](../../doc/controllers/subscriptions.md#delete-subscription-item) * [Get Increments](../../doc/controllers/subscriptions.md#get-increments) +* [Update Subscription Due Days](../../doc/controllers/subscriptions.md#update-subscription-due-days) +* [Update Subscription Start At](../../doc/controllers/subscriptions.md#update-subscription-start-at) * [Update Subscription Item](../../doc/controllers/subscriptions.md#update-subscription-item) +* [Create Subscription Item](../../doc/controllers/subscriptions.md#create-subscription-item) +* [Get Subscription](../../doc/controllers/subscriptions.md#get-subscription) +* [Get Usages](../../doc/controllers/subscriptions.md#get-usages) +* [Update Latest Period End At](../../doc/controllers/subscriptions.md#update-latest-period-end-at) +* [Update Subscription Minium Price](../../doc/controllers/subscriptions.md#update-subscription-minium-price) +* [Get Subscription Cycle by Id](../../doc/controllers/subscriptions.md#get-subscription-cycle-by-id) +* [Get Usage Report](../../doc/controllers/subscriptions.md#get-usage-report) +* [Update Split Subscription](../../doc/controllers/subscriptions.md#update-split-subscription) + + +# Renew Subscription + +```php +function renewSubscription(string $subscriptionId, ?string $idempotencyKey = null): GetPeriodResponse +``` + +## Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `subscriptionId` | `string` | Template, Required | - | +| `idempotencyKey` | `?string` | Header, Optional | - | + +## Response Type + +[`GetPeriodResponse`](../../doc/models/get-period-response.md) + +## Example Usage + +```php +$subscriptionId = 'subscription_id0'; + +$result = $subscriptionsController->renewSubscription($subscriptionId); +``` # Update Subscription Card @@ -91,6 +117,49 @@ $result = $subscriptionsController->updateSubscriptionCard( ``` +# Delete Usage + +Deletes a usage + +```php +function deleteUsage( + string $subscriptionId, + string $itemId, + string $usageId, + ?string $idempotencyKey = null +): GetUsageResponse +``` + +## Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `subscriptionId` | `string` | Template, Required | The subscription id | +| `itemId` | `string` | Template, Required | The subscription item id | +| `usageId` | `string` | Template, Required | The usage id | +| `idempotencyKey` | `?string` | Header, Optional | - | + +## Response Type + +[`GetUsageResponse`](../../doc/models/get-usage-response.md) + +## Example Usage + +```php +$subscriptionId = 'subscription_id0'; + +$itemId = 'item_id0'; + +$usageId = 'usage_id0'; + +$result = $subscriptionsController->deleteUsage( + $subscriptionId, + $itemId, + $usageId +); +``` + + # Create Discount Creates a discount @@ -133,92 +202,88 @@ $result = $subscriptionsController->createDiscount( ``` -# Update Subscription Billing Date +# Create an Usage -Updates the billing date from a subscription +Create Usage ```php -function updateSubscriptionBillingDate( - string $subscriptionId, - UpdateSubscriptionBillingDateRequest $request, - ?string $idempotencyKey = null -): GetSubscriptionResponse +function createAnUsage(string $subscriptionId, string $itemId, ?string $idempotencyKey = null): GetUsageResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | The subscription id | -| `request` | [`UpdateSubscriptionBillingDateRequest`](../../doc/models/update-subscription-billing-date-request.md) | Body, Required | Request for updating the subscription billing date | +| `subscriptionId` | `string` | Template, Required | Subscription id | +| `itemId` | `string` | Template, Required | Item id | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) +[`GetUsageResponse`](../../doc/models/get-usage-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$request = UpdateSubscriptionBillingDateRequestBuilder::init( - DateTimeHelper::fromRfc3339DateTimeRequired('2016-03-13T12:52:32.123Z') -)->build(); +$itemId = 'item_id0'; -$result = $subscriptionsController->updateSubscriptionBillingDate( +$result = $subscriptionsController->createAnUsage( $subscriptionId, - $request + $itemId ); ``` -# Update Subscription Start At - -Updates the start at date from a subscription +# Update Current Cycle Status ```php -function updateSubscriptionStartAt( +function updateCurrentCycleStatus( string $subscriptionId, - UpdateSubscriptionStartAtRequest $request, + UpdateCurrentCycleStatusRequest $request, ?string $idempotencyKey = null -): GetSubscriptionResponse +): void ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | The subscription id | -| `request` | [`UpdateSubscriptionStartAtRequest`](../../doc/models/update-subscription-start-at-request.md) | Body, Required | Request for updating the subscription start date | +| `subscriptionId` | `string` | Template, Required | Subscription Id | +| `request` | [`UpdateCurrentCycleStatusRequest`](../../doc/models/update-current-cycle-status-request.md) | Body, Required | Request for updating the end date of the subscription current status | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) +`void` ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$request = UpdateSubscriptionStartAtRequestBuilder::init( - DateTimeHelper::fromRfc3339DateTimeRequired('2016-03-13T12:52:32.123Z') +$request = UpdateCurrentCycleStatusRequestBuilder::init( + 'status8' )->build(); -$result = $subscriptionsController->updateSubscriptionStartAt( +$subscriptionsController->updateCurrentCycleStatus( $subscriptionId, $request ); ``` -# Get Subscription +# Delete Discount -Gets a subscription +Deletes a discount ```php -function getSubscription(string $subscriptionId): GetSubscriptionResponse +function deleteDiscount( + string $subscriptionId, + string $discountId, + ?string $idempotencyKey = null +): GetDiscountResponse ``` ## Parameters @@ -226,35 +291,43 @@ function getSubscription(string $subscriptionId): GetSubscriptionResponse | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `subscriptionId` | `string` | Template, Required | Subscription id | +| `discountId` | `string` | Template, Required | Discount Id | +| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) +[`GetDiscountResponse`](../../doc/models/get-discount-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$result = $subscriptionsController->getSubscription($subscriptionId); +$discountId = 'discount_id8'; + +$result = $subscriptionsController->deleteDiscount( + $subscriptionId, + $discountId +); ``` -# Get Usages +# Get Subscription Items -Lists all usages from a subscription item +Get Subscription Items ```php -function getUsages( +function getSubscriptionItems( string $subscriptionId, - string $itemId, ?int $page = null, ?int $size = null, + ?string $name = null, ?string $code = null, - ?string $group = null, - ?\DateTime $usedSince = null, - ?\DateTime $usedUntil = null -): ListUsagesResponse + ?string $status = null, + ?string $description = null, + ?string $createdSince = null, + ?string $createdUntil = null +): ListSubscriptionItemsResponse ``` ## Parameters @@ -262,38 +335,36 @@ function getUsages( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `subscriptionId` | `string` | Template, Required | The subscription id | -| `itemId` | `string` | Template, Required | The subscription item id | | `page` | `?int` | Query, Optional | Page number | | `size` | `?int` | Query, Optional | Page size | +| `name` | `?string` | Query, Optional | The item name | | `code` | `?string` | Query, Optional | Identification code in the client system | -| `group` | `?string` | Query, Optional | Identification group in the client system | -| `usedSince` | `?DateTime` | Query, Optional | - | -| `usedUntil` | `?DateTime` | Query, Optional | - | +| `status` | `?string` | Query, Optional | The item statis | +| `description` | `?string` | Query, Optional | The item description | +| `createdSince` | `?string` | Query, Optional | Filter for item's creation date start range | +| `createdUntil` | `?string` | Query, Optional | Filter for item's creation date end range | ## Response Type -[`ListUsagesResponse`](../../doc/models/list-usages-response.md) +[`ListSubscriptionItemsResponse`](../../doc/models/list-subscription-items-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$itemId = 'item_id0'; - -$result = $subscriptionsController->getUsages( - $subscriptionId, - $itemId -); +$result = $subscriptionsController->getSubscriptionItems($subscriptionId); ``` -# Update Latest Period End At +# Update Subscription Payment Method + +Updates the payment method from a subscription ```php -function updateLatestPeriodEndAt( +function updateSubscriptionPaymentMethod( string $subscriptionId, - UpdateCurrentCycleEndDateRequest $request, + UpdateSubscriptionPaymentMethodRequest $request, ?string $idempotencyKey = null ): GetSubscriptionResponse ``` @@ -302,8 +373,8 @@ function updateLatestPeriodEndAt( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | - | -| `request` | [`UpdateCurrentCycleEndDateRequest`](../../doc/models/update-current-cycle-end-date-request.md) | Body, Required | Request for updating the end date of the current signature cycle | +| `subscriptionId` | `string` | Template, Required | Subscription id | +| `request` | [`UpdateSubscriptionPaymentMethodRequest`](../../doc/models/update-subscription-payment-method-request.md) | Body, Required | Request for updating the paymentmethod from a subscription | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -315,61 +386,111 @@ function updateLatestPeriodEndAt( ```php $subscriptionId = 'subscription_id0'; -$request = UpdateCurrentCycleEndDateRequestBuilder::init()->build(); +$request = UpdateSubscriptionPaymentMethodRequestBuilder::init( + 'payment_method4', + 'card_id2', + CreateCardRequestBuilder::init() + ->type('credit') + ->build() +)->build(); -$result = $subscriptionsController->updateLatestPeriodEndAt( +$result = $subscriptionsController->updateSubscriptionPaymentMethod( $subscriptionId, $request ); ``` -# Delete Discount +# Get Subscription Item -Deletes a discount +Get Subscription Item ```php -function deleteDiscount( - string $subscriptionId, - string $discountId, - ?string $idempotencyKey = null -): GetDiscountResponse +function getSubscriptionItem(string $subscriptionId, string $itemId): GetSubscriptionItemResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | Subscription id | -| `discountId` | `string` | Template, Required | Discount Id | -| `idempotencyKey` | `?string` | Header, Optional | - | +| `subscriptionId` | `string` | Template, Required | Subscription Id | +| `itemId` | `string` | Template, Required | Item id | ## Response Type -[`GetDiscountResponse`](../../doc/models/get-discount-response.md) +[`GetSubscriptionItemResponse`](../../doc/models/get-subscription-item-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$discountId = 'discount_id8'; +$itemId = 'item_id0'; -$result = $subscriptionsController->deleteDiscount( +$result = $subscriptionsController->getSubscriptionItem( $subscriptionId, - $discountId + $itemId ); ``` -# Update Subscription Payment Method +# Get Subscriptions -Updates the payment method from a subscription +Gets all subscriptions ```php -function updateSubscriptionPaymentMethod( +function getSubscriptions( + ?int $page = null, + ?int $size = null, + ?string $code = null, + ?string $billingType = null, + ?string $customerId = null, + ?string $planId = null, + ?string $cardId = null, + ?string $status = null, + ?\DateTime $nextBillingSince = null, + ?\DateTime $nextBillingUntil = null, + ?\DateTime $createdSince = null, + ?\DateTime $createdUntil = null +): ListSubscriptionsResponse +``` + +## Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `page` | `?int` | Query, Optional | Page number | +| `size` | `?int` | Query, Optional | Page size | +| `code` | `?string` | Query, Optional | Filter for subscription's code | +| `billingType` | `?string` | Query, Optional | Filter for subscription's billing type | +| `customerId` | `?string` | Query, Optional | Filter for subscription's customer id | +| `planId` | `?string` | Query, Optional | Filter for subscription's plan id | +| `cardId` | `?string` | Query, Optional | Filter for subscription's card id | +| `status` | `?string` | Query, Optional | Filter for subscription's status | +| `nextBillingSince` | `?DateTime` | Query, Optional | Filter for subscription's next billing date start range | +| `nextBillingUntil` | `?DateTime` | Query, Optional | Filter for subscription's next billing date end range | +| `createdSince` | `?DateTime` | Query, Optional | Filter for subscription's creation date start range | +| `createdUntil` | `?DateTime` | Query, Optional | Filter for subscriptions creation date end range | + +## Response Type + +[`ListSubscriptionsResponse`](../../doc/models/list-subscriptions-response.md) + +## Example Usage + +```php +$result = $subscriptionsController->getSubscriptions(); +``` + + +# Cancel Subscription + +Cancels a subscription + +```php +function cancelSubscription( string $subscriptionId, - UpdateSubscriptionPaymentMethodRequest $request, + ?CreateCancelSubscriptionRequest $request = null, ?string $idempotencyKey = null ): GetSubscriptionResponse ``` @@ -379,7 +500,7 @@ function updateSubscriptionPaymentMethod( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `subscriptionId` | `string` | Template, Required | Subscription id | -| `request` | [`UpdateSubscriptionPaymentMethodRequest`](../../doc/models/update-subscription-payment-method-request.md) | Body, Required | Request for updating the paymentmethod from a subscription | +| `request` | [`?CreateCancelSubscriptionRequest`](../../doc/models/create-cancel-subscription-request.md) | Body, Optional | Request for cancelling a subscription | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -391,31 +512,27 @@ function updateSubscriptionPaymentMethod( ```php $subscriptionId = 'subscription_id0'; -$request = UpdateSubscriptionPaymentMethodRequestBuilder::init( - 'payment_method4', - 'card_id2', - CreateCardRequestBuilder::init() - ->type('credit') - ->build() +$request = CreateCancelSubscriptionRequestBuilder::init( + true )->build(); -$result = $subscriptionsController->updateSubscriptionPaymentMethod( +$result = $subscriptionsController->cancelSubscription( $subscriptionId, $request ); ``` -# Cancel Subscription +# Create Increment -Cancels a subscription +Creates a increment ```php -function cancelSubscription( +function createIncrement( string $subscriptionId, - ?CreateCancelSubscriptionRequest $request = null, + CreateIncrementRequest $request, ?string $idempotencyKey = null -): GetSubscriptionResponse +): GetIncrementResponse ``` ## Parameters @@ -423,29 +540,109 @@ function cancelSubscription( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `subscriptionId` | `string` | Template, Required | Subscription id | -| `request` | [`?CreateCancelSubscriptionRequest`](../../doc/models/create-cancel-subscription-request.md) | Body, Optional | Request for cancelling a subscription | +| `request` | [`CreateIncrementRequest`](../../doc/models/create-increment-request.md) | Body, Required | Request for creating a increment | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) +[`GetIncrementResponse`](../../doc/models/get-increment-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$request = CreateCancelSubscriptionRequestBuilder::init( - true +$request = CreateIncrementRequestBuilder::init( + 185.28, + 'increment_type8', + 'item_id6' )->build(); -$result = $subscriptionsController->cancelSubscription( +$result = $subscriptionsController->createIncrement( $subscriptionId, $request ); ``` +# Create Usage + +Creates a usage + +```php +function createUsage( + string $subscriptionId, + string $itemId, + CreateUsageRequest $body, + ?string $idempotencyKey = null +): GetUsageResponse +``` + +## Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `subscriptionId` | `string` | Template, Required | Subscription Id | +| `itemId` | `string` | Template, Required | Item id | +| `body` | [`CreateUsageRequest`](../../doc/models/create-usage-request.md) | Body, Required | Request for creating a usage | +| `idempotencyKey` | `?string` | Header, Optional | - | + +## Response Type + +[`GetUsageResponse`](../../doc/models/get-usage-response.md) + +## Example Usage + +```php +$subscriptionId = 'subscription_id0'; + +$itemId = 'item_id0'; + +$body = CreateUsageRequestBuilder::init( + 156, + 'description4', + DateTimeHelper::fromRfc3339DateTimeRequired('2016-03-13T12:52:32.123Z') +)->build(); + +$result = $subscriptionsController->createUsage( + $subscriptionId, + $itemId, + $body +); +``` + + +# Get Discount by Id + +```php +function getDiscountById(string $subscriptionId, string $discountId): GetDiscountResponse +``` + +## Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `subscriptionId` | `string` | Template, Required | The subscription id | +| `discountId` | `string` | Template, Required | - | + +## Response Type + +[`GetDiscountResponse`](../../doc/models/get-discount-response.md) + +## Example Usage + +```php +$subscriptionId = 'subscription_id0'; + +$discountId = 'discountId0'; + +$result = $subscriptionsController->getDiscountById( + $subscriptionId, + $discountId +); +``` + + # Create Subscription Creates a new subscription @@ -473,9 +670,7 @@ function createSubscription( ```php $body = CreateSubscriptionRequestBuilder::init( CreateCustomerRequestBuilder::init( - '{ - "name": "Tony Stark" -}', + 'Tony Stark', 'email6', 'document6', 'type0', @@ -573,6 +768,37 @@ $result = $subscriptionsController->createSubscription($body); ``` +# Get Increment by Id + +```php +function getIncrementById(string $subscriptionId, string $incrementId): GetIncrementResponse +``` + +## Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `subscriptionId` | `string` | Template, Required | The subscription Id | +| `incrementId` | `string` | Template, Required | The increment Id | + +## Response Type + +[`GetIncrementResponse`](../../doc/models/get-increment-response.md) + +## Example Usage + +```php +$subscriptionId = 'subscription_id0'; + +$incrementId = 'increment_id8'; + +$result = $subscriptionsController->getIncrementById( + $subscriptionId, + $incrementId +); +``` + + # Update Subscription Affiliation Id ```php @@ -611,14 +837,14 @@ $result = $subscriptionsController->updateSubscriptionAffiliationId( ``` -# Update Subscription Minium Price +# Update Subscription Metadata -Atualização do valor mínimo da assinatura +Updates the metadata from a subscription ```php -function updateSubscriptionMiniumPrice( +function updateSubscriptionMetadata( string $subscriptionId, - UpdateSubscriptionMinimumPriceRequest $request, + UpdateMetadataRequest $request, ?string $idempotencyKey = null ): GetSubscriptionResponse ``` @@ -627,8 +853,8 @@ function updateSubscriptionMiniumPrice( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | Subscription Id | -| `request` | [`UpdateSubscriptionMinimumPriceRequest`](../../doc/models/update-subscription-minimum-price-request.md) | Body, Required | Request da requisição com o valor mínimo que será configurado | +| `subscriptionId` | `string` | Template, Required | The subscription id | +| `request` | [`UpdateMetadataRequest`](../../doc/models/update-metadata-request.md) | Body, Required | Request for updating the subscrption metadata | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -640,114 +866,96 @@ function updateSubscriptionMiniumPrice( ```php $subscriptionId = 'subscription_id0'; -$request = UpdateSubscriptionMinimumPriceRequestBuilder::init()->build(); +$request = UpdateMetadataRequestBuilder::init( + [ + 'key0' => 'metadata3' + ] +)->build(); -$result = $subscriptionsController->updateSubscriptionMiniumPrice( +$result = $subscriptionsController->updateSubscriptionMetadata( $subscriptionId, $request ); ``` -# Get Subscription Cycle by Id +# Delete Increment + +Deletes a increment ```php -function getSubscriptionCycleById(string $subscriptionId, string $cycleId): GetPeriodResponse +function deleteIncrement( + string $subscriptionId, + string $incrementId, + ?string $idempotencyKey = null +): GetIncrementResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | The subscription id | -| `cycleId` | `string` | Template, Required | - | +| `subscriptionId` | `string` | Template, Required | Subscription id | +| `incrementId` | `string` | Template, Required | Increment id | +| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`GetPeriodResponse`](../../doc/models/get-period-response.md) +[`GetIncrementResponse`](../../doc/models/get-increment-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$cycleId = 'cycleId0'; +$incrementId = 'increment_id8'; -$result = $subscriptionsController->getSubscriptionCycleById( +$result = $subscriptionsController->deleteIncrement( $subscriptionId, - $cycleId + $incrementId ); ``` -# Get Usage Report +# Get Subscription Cycles ```php -function getUsageReport(string $subscriptionId, string $periodId): GetUsageReportResponse +function getSubscriptionCycles(string $subscriptionId, string $page, string $size): ListCyclesResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | The subscription Id | -| `periodId` | `string` | Template, Required | The period Id | +| `subscriptionId` | `string` | Template, Required | Subscription Id | +| `page` | `string` | Query, Required | Page number | +| `size` | `string` | Query, Required | Page size | ## Response Type -[`GetUsageReportResponse`](../../doc/models/get-usage-report-response.md) +[`ListCyclesResponse`](../../doc/models/list-cycles-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$periodId = 'period_id0'; +$page = 'page8'; -$result = $subscriptionsController->getUsageReport( +$size = 'size0'; + +$result = $subscriptionsController->getSubscriptionCycles( $subscriptionId, - $periodId + $page, + $size ); ``` -# Renew Subscription - -```php -function renewSubscription(string $subscriptionId, ?string $idempotencyKey = null): GetPeriodResponse -``` - -## Parameters - -| Parameter | Type | Tags | Description | -| --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | - | -| `idempotencyKey` | `?string` | Header, Optional | - | - -## Response Type - -[`GetPeriodResponse`](../../doc/models/get-period-response.md) - -## Example Usage - -```php -$subscriptionId = 'subscription_id0'; - -$result = $subscriptionsController->renewSubscription($subscriptionId); -``` - - -# Delete Usage - -Deletes a usage +# Get Discounts ```php -function deleteUsage( - string $subscriptionId, - string $itemId, - string $usageId, - ?string $idempotencyKey = null -): GetUsageResponse +function getDiscounts(string $subscriptionId, int $page, int $size): ListDiscountsResponse ``` ## Parameters @@ -755,117 +963,89 @@ function deleteUsage( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `subscriptionId` | `string` | Template, Required | The subscription id | -| `itemId` | `string` | Template, Required | The subscription item id | -| `usageId` | `string` | Template, Required | The usage id | -| `idempotencyKey` | `?string` | Header, Optional | - | +| `page` | `int` | Query, Required | Page number | +| `size` | `int` | Query, Required | Page size | ## Response Type -[`GetUsageResponse`](../../doc/models/get-usage-response.md) +[`ListDiscountsResponse`](../../doc/models/list-discounts-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$itemId = 'item_id0'; +$page = 30; -$usageId = 'usage_id0'; +$size = 18; -$result = $subscriptionsController->deleteUsage( +$result = $subscriptionsController->getDiscounts( $subscriptionId, - $itemId, - $usageId + $page, + $size ); ``` -# Create an Usage - -Create Usage - -```php -function createAnUsage(string $subscriptionId, string $itemId, ?string $idempotencyKey = null): GetUsageResponse -``` - -## Parameters - -| Parameter | Type | Tags | Description | -| --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | Subscription id | -| `itemId` | `string` | Template, Required | Item id | -| `idempotencyKey` | `?string` | Header, Optional | - | - -## Response Type - -[`GetUsageResponse`](../../doc/models/get-usage-response.md) - -## Example Usage - -```php -$subscriptionId = 'subscription_id0'; - -$itemId = 'item_id0'; - -$result = $subscriptionsController->createAnUsage( - $subscriptionId, - $itemId -); -``` - +# Update Subscription Billing Date -# Update Current Cycle Status +Updates the billing date from a subscription ```php -function updateCurrentCycleStatus( +function updateSubscriptionBillingDate( string $subscriptionId, - UpdateCurrentCycleStatusRequest $request, + UpdateSubscriptionBillingDateRequest $request, ?string $idempotencyKey = null -): void +): GetSubscriptionResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | Subscription Id | -| `request` | [`UpdateCurrentCycleStatusRequest`](../../doc/models/update-current-cycle-status-request.md) | Body, Required | Request for updating the end date of the subscription current status | +| `subscriptionId` | `string` | Template, Required | The subscription id | +| `request` | [`UpdateSubscriptionBillingDateRequest`](../../doc/models/update-subscription-billing-date-request.md) | Body, Required | Request for updating the subscription billing date | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -`void` +[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$request = UpdateCurrentCycleStatusRequestBuilder::init( - 'status8' +$request = UpdateSubscriptionBillingDateRequestBuilder::init( + DateTimeHelper::fromRfc3339DateTimeRequired('2016-03-13T12:52:32.123Z') )->build(); -$subscriptionsController->updateCurrentCycleStatus( +$result = $subscriptionsController->updateSubscriptionBillingDate( $subscriptionId, $request ); ``` -# Get Subscription Item +# Delete Subscription Item -Get Subscription Item +Deletes a subscription item ```php -function getSubscriptionItem(string $subscriptionId, string $itemId): GetSubscriptionItemResponse +function deleteSubscriptionItem( + string $subscriptionId, + string $subscriptionItemId, + ?string $idempotencyKey = null +): GetSubscriptionItemResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | Subscription Id | -| `itemId` | `string` | Template, Required | Item id | +| `subscriptionId` | `string` | Template, Required | Subscription id | +| `subscriptionItemId` | `string` | Template, Required | Subscription item id | +| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -876,88 +1056,92 @@ function getSubscriptionItem(string $subscriptionId, string $itemId): GetSubscri ```php $subscriptionId = 'subscription_id0'; -$itemId = 'item_id0'; +$subscriptionItemId = 'subscription_item_id4'; -$result = $subscriptionsController->getSubscriptionItem( +$result = $subscriptionsController->deleteSubscriptionItem( $subscriptionId, - $itemId + $subscriptionItemId ); ``` -# Get Increment by Id +# Get Increments ```php -function getIncrementById(string $subscriptionId, string $incrementId): GetIncrementResponse +function getIncrements(string $subscriptionId, ?int $page = null, ?int $size = null): ListIncrementsResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | The subscription Id | -| `incrementId` | `string` | Template, Required | The increment Id | +| `subscriptionId` | `string` | Template, Required | The subscription id | +| `page` | `?int` | Query, Optional | Page number | +| `size` | `?int` | Query, Optional | Page size | ## Response Type -[`GetIncrementResponse`](../../doc/models/get-increment-response.md) +[`ListIncrementsResponse`](../../doc/models/list-increments-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$incrementId = 'increment_id8'; - -$result = $subscriptionsController->getIncrementById( - $subscriptionId, - $incrementId -); +$result = $subscriptionsController->getIncrements($subscriptionId); ``` -# Delete Increment +# Update Subscription Due Days -Deletes a increment +Updates the boleto due days from a subscription ```php -function deleteIncrement( +function updateSubscriptionDueDays( string $subscriptionId, - string $incrementId, + UpdateSubscriptionDueDaysRequest $request, ?string $idempotencyKey = null -): GetIncrementResponse +): GetSubscriptionResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | Subscription id | -| `incrementId` | `string` | Template, Required | Increment id | +| `subscriptionId` | `string` | Template, Required | Subscription Id | +| `request` | [`UpdateSubscriptionDueDaysRequest`](../../doc/models/update-subscription-due-days-request.md) | Body, Required | - | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`GetIncrementResponse`](../../doc/models/get-increment-response.md) +[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$incrementId = 'increment_id8'; +$request = UpdateSubscriptionDueDaysRequestBuilder::init( + 226 +)->build(); -$result = $subscriptionsController->deleteIncrement( +$result = $subscriptionsController->updateSubscriptionDueDays( $subscriptionId, - $incrementId + $request ); ``` -# Get Discounts +# Update Subscription Start At + +Updates the start at date from a subscription ```php -function getDiscounts(string $subscriptionId, int $page, int $size): ListDiscountsResponse +function updateSubscriptionStartAt( + string $subscriptionId, + UpdateSubscriptionStartAtRequest $request, + ?string $idempotencyKey = null +): GetSubscriptionResponse ``` ## Parameters @@ -965,40 +1149,40 @@ function getDiscounts(string $subscriptionId, int $page, int $size): ListDiscoun | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `subscriptionId` | `string` | Template, Required | The subscription id | -| `page` | `int` | Query, Required | Page number | -| `size` | `int` | Query, Required | Page size | +| `request` | [`UpdateSubscriptionStartAtRequest`](../../doc/models/update-subscription-start-at-request.md) | Body, Required | Request for updating the subscription start date | +| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`ListDiscountsResponse`](../../doc/models/list-discounts-response.md) +[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$page = 30; - -$size = 18; +$request = UpdateSubscriptionStartAtRequestBuilder::init( + DateTimeHelper::fromRfc3339DateTimeRequired('2016-03-13T12:52:32.123Z') +)->build(); -$result = $subscriptionsController->getDiscounts( +$result = $subscriptionsController->updateSubscriptionStartAt( $subscriptionId, - $page, - $size + $request ); ``` -# Update Subscription Due Days +# Update Subscription Item -Updates the boleto due days from a subscription +Updates a subscription item ```php -function updateSubscriptionDueDays( +function updateSubscriptionItem( string $subscriptionId, - UpdateSubscriptionDueDaysRequest $request, + string $itemId, + UpdateSubscriptionItemRequest $body, ?string $idempotencyKey = null -): GetSubscriptionResponse +): GetSubscriptionItemResponse ``` ## Parameters @@ -1006,25 +1190,40 @@ function updateSubscriptionDueDays( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `subscriptionId` | `string` | Template, Required | Subscription Id | -| `request` | [`UpdateSubscriptionDueDaysRequest`](../../doc/models/update-subscription-due-days-request.md) | Body, Required | - | +| `itemId` | `string` | Template, Required | Item id | +| `body` | [`UpdateSubscriptionItemRequest`](../../doc/models/update-subscription-item-request.md) | Body, Required | Request for updating a subscription item | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) +[`GetSubscriptionItemResponse`](../../doc/models/get-subscription-item-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$request = UpdateSubscriptionDueDaysRequestBuilder::init( - 226 +$itemId = 'item_id0'; + +$body = UpdateSubscriptionItemRequestBuilder::init( + 'description4', + 'status2', + UpdatePricingSchemeRequestBuilder::init( + 'scheme_type8', + [ + UpdatePriceBracketRequestBuilder::init( + 144, + 174 + )->build() + ] + )->build(), + 'name6' )->build(); -$result = $subscriptionsController->updateSubscriptionDueDays( +$result = $subscriptionsController->updateSubscriptionItem( $subscriptionId, - $request + $itemId, + $body ); ``` @@ -1082,18 +1281,19 @@ $result = $subscriptionsController->createSubscriptionItem( ``` -# Update Split Subscription +# Get Subscription + +Gets a subscription ```php -function updateSplitSubscription(string $id, UpdateSubscriptionSplitRequest $request): GetSubscriptionResponse +function getSubscription(string $subscriptionId): GetSubscriptionResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `id` | `string` | Template, Required | Subscription's id | -| `request` | [`UpdateSubscriptionSplitRequest`](../../doc/models/update-subscription-split-request.md) | Body, Required | - | +| `subscriptionId` | `string` | Template, Required | Subscription id | ## Response Type @@ -1102,42 +1302,27 @@ function updateSplitSubscription(string $id, UpdateSubscriptionSplitRequest $req ## Example Usage ```php -$id = 'id0'; - -$request = UpdateSubscriptionSplitRequestBuilder::init( - false, - [ - CreateSplitRequestBuilder::init( - 'type2', - 118, - 'recipient_id2' - )->build() - ] -)->build(); +$subscriptionId = 'subscription_id0'; -$result = $subscriptionsController->updateSplitSubscription( - $id, - $request -); +$result = $subscriptionsController->getSubscription($subscriptionId); ``` -# Get Subscription Items +# Get Usages -Get Subscription Items +Lists all usages from a subscription item ```php -function getSubscriptionItems( +function getUsages( string $subscriptionId, + string $itemId, ?int $page = null, ?int $size = null, - ?string $name = null, ?string $code = null, - ?string $status = null, - ?string $description = null, - ?string $createdSince = null, - ?string $createdUntil = null -): ListSubscriptionItemsResponse + ?string $group = null, + ?\DateTime $usedSince = null, + ?\DateTime $usedUntil = null +): ListUsagesResponse ``` ## Parameters @@ -1145,205 +1330,76 @@ function getSubscriptionItems( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `subscriptionId` | `string` | Template, Required | The subscription id | +| `itemId` | `string` | Template, Required | The subscription item id | | `page` | `?int` | Query, Optional | Page number | | `size` | `?int` | Query, Optional | Page size | -| `name` | `?string` | Query, Optional | The item name | | `code` | `?string` | Query, Optional | Identification code in the client system | -| `status` | `?string` | Query, Optional | The item statis | -| `description` | `?string` | Query, Optional | The item description | -| `createdSince` | `?string` | Query, Optional | Filter for item's creation date start range | -| `createdUntil` | `?string` | Query, Optional | Filter for item's creation date end range | - -## Response Type - -[`ListSubscriptionItemsResponse`](../../doc/models/list-subscription-items-response.md) - -## Example Usage - -```php -$subscriptionId = 'subscription_id0'; - -$result = $subscriptionsController->getSubscriptionItems($subscriptionId); -``` - - -# Get Subscriptions - -Gets all subscriptions - -```php -function getSubscriptions( - ?int $page = null, - ?int $size = null, - ?string $code = null, - ?string $billingType = null, - ?string $customerId = null, - ?string $planId = null, - ?string $cardId = null, - ?string $status = null, - ?\DateTime $nextBillingSince = null, - ?\DateTime $nextBillingUntil = null, - ?\DateTime $createdSince = null, - ?\DateTime $createdUntil = null -): ListSubscriptionsResponse -``` - -## Parameters - -| Parameter | Type | Tags | Description | -| --- | --- | --- | --- | -| `page` | `?int` | Query, Optional | Page number | -| `size` | `?int` | Query, Optional | Page size | -| `code` | `?string` | Query, Optional | Filter for subscription's code | -| `billingType` | `?string` | Query, Optional | Filter for subscription's billing type | -| `customerId` | `?string` | Query, Optional | Filter for subscription's customer id | -| `planId` | `?string` | Query, Optional | Filter for subscription's plan id | -| `cardId` | `?string` | Query, Optional | Filter for subscription's card id | -| `status` | `?string` | Query, Optional | Filter for subscription's status | -| `nextBillingSince` | `?DateTime` | Query, Optional | Filter for subscription's next billing date start range | -| `nextBillingUntil` | `?DateTime` | Query, Optional | Filter for subscription's next billing date end range | -| `createdSince` | `?DateTime` | Query, Optional | Filter for subscription's creation date start range | -| `createdUntil` | `?DateTime` | Query, Optional | Filter for subscriptions creation date end range | - -## Response Type - -[`ListSubscriptionsResponse`](../../doc/models/list-subscriptions-response.md) - -## Example Usage - -```php -$result = $subscriptionsController->getSubscriptions(); -``` - - -# Create Increment - -Creates a increment - -```php -function createIncrement( - string $subscriptionId, - CreateIncrementRequest $request, - ?string $idempotencyKey = null -): GetIncrementResponse -``` - -## Parameters - -| Parameter | Type | Tags | Description | -| --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | Subscription id | -| `request` | [`CreateIncrementRequest`](../../doc/models/create-increment-request.md) | Body, Required | Request for creating a increment | -| `idempotencyKey` | `?string` | Header, Optional | - | +| `group` | `?string` | Query, Optional | Identification group in the client system | +| `usedSince` | `?DateTime` | Query, Optional | - | +| `usedUntil` | `?DateTime` | Query, Optional | - | ## Response Type -[`GetIncrementResponse`](../../doc/models/get-increment-response.md) +[`ListUsagesResponse`](../../doc/models/list-usages-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$request = CreateIncrementRequestBuilder::init( - 185.28, - 'increment_type8', - 'item_id6' -)->build(); +$itemId = 'item_id0'; -$result = $subscriptionsController->createIncrement( +$result = $subscriptionsController->getUsages( $subscriptionId, - $request + $itemId ); ``` -# Create Usage - -Creates a usage +# Update Latest Period End At ```php -function createUsage( +function updateLatestPeriodEndAt( string $subscriptionId, - string $itemId, - CreateUsageRequest $body, + UpdateCurrentCycleEndDateRequest $request, ?string $idempotencyKey = null -): GetUsageResponse +): GetSubscriptionResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | Subscription Id | -| `itemId` | `string` | Template, Required | Item id | -| `body` | [`CreateUsageRequest`](../../doc/models/create-usage-request.md) | Body, Required | Request for creating a usage | +| `subscriptionId` | `string` | Template, Required | - | +| `request` | [`UpdateCurrentCycleEndDateRequest`](../../doc/models/update-current-cycle-end-date-request.md) | Body, Required | Request for updating the end date of the current signature cycle | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`GetUsageResponse`](../../doc/models/get-usage-response.md) - -## Example Usage - -```php -$subscriptionId = 'subscription_id0'; - -$itemId = 'item_id0'; - -$body = CreateUsageRequestBuilder::init( - 156, - 'description4', - DateTimeHelper::fromRfc3339DateTimeRequired('2016-03-13T12:52:32.123Z') -)->build(); - -$result = $subscriptionsController->createUsage( - $subscriptionId, - $itemId, - $body -); -``` - - -# Get Discount by Id - -```php -function getDiscountById(string $subscriptionId, string $discountId): GetDiscountResponse -``` - -## Parameters - -| Parameter | Type | Tags | Description | -| --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | The subscription id | -| `discountId` | `string` | Template, Required | - | - -## Response Type - -[`GetDiscountResponse`](../../doc/models/get-discount-response.md) +[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$discountId = 'discountId0'; +$request = UpdateCurrentCycleEndDateRequestBuilder::init()->build(); -$result = $subscriptionsController->getDiscountById( +$result = $subscriptionsController->updateLatestPeriodEndAt( $subscriptionId, - $discountId + $request ); ``` -# Update Subscription Metadata +# Update Subscription Minium Price -Updates the metadata from a subscription +Atualização do valor mínimo da assinatura ```php -function updateSubscriptionMetadata( +function updateSubscriptionMiniumPrice( string $subscriptionId, - UpdateMetadataRequest $request, + UpdateSubscriptionMinimumPriceRequest $request, ?string $idempotencyKey = null ): GetSubscriptionResponse ``` @@ -1352,8 +1408,8 @@ function updateSubscriptionMetadata( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | The subscription id | -| `request` | [`UpdateMetadataRequest`](../../doc/models/update-metadata-request.md) | Body, Required | Request for updating the subscrption metadata | +| `subscriptionId` | `string` | Template, Required | Subscription Id | +| `request` | [`UpdateSubscriptionMinimumPriceRequest`](../../doc/models/update-subscription-minimum-price-request.md) | Body, Required | Request da requisição com o valor mínimo que será configurado | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -1365,171 +1421,113 @@ function updateSubscriptionMetadata( ```php $subscriptionId = 'subscription_id0'; -$request = UpdateMetadataRequestBuilder::init( - [ - 'key0' => 'metadata3' - ] -)->build(); +$request = UpdateSubscriptionMinimumPriceRequestBuilder::init()->build(); -$result = $subscriptionsController->updateSubscriptionMetadata( +$result = $subscriptionsController->updateSubscriptionMiniumPrice( $subscriptionId, $request ); ``` -# Get Subscription Cycles +# Get Subscription Cycle by Id ```php -function getSubscriptionCycles(string $subscriptionId, string $page, string $size): ListCyclesResponse +function getSubscriptionCycleById(string $subscriptionId, string $cycleId): GetPeriodResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | Subscription Id | -| `page` | `string` | Query, Required | Page number | -| `size` | `string` | Query, Required | Page size | +| `subscriptionId` | `string` | Template, Required | The subscription id | +| `cycleId` | `string` | Template, Required | - | ## Response Type -[`ListCyclesResponse`](../../doc/models/list-cycles-response.md) +[`GetPeriodResponse`](../../doc/models/get-period-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$page = 'page8'; - -$size = 'size0'; +$cycleId = 'cycleId0'; -$result = $subscriptionsController->getSubscriptionCycles( +$result = $subscriptionsController->getSubscriptionCycleById( $subscriptionId, - $page, - $size + $cycleId ); ``` -# Delete Subscription Item - -Deletes a subscription item +# Get Usage Report ```php -function deleteSubscriptionItem( - string $subscriptionId, - string $subscriptionItemId, - ?string $idempotencyKey = null -): GetSubscriptionItemResponse +function getUsageReport(string $subscriptionId, string $periodId): GetUsageReportResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | Subscription id | -| `subscriptionItemId` | `string` | Template, Required | Subscription item id | -| `idempotencyKey` | `?string` | Header, Optional | - | +| `subscriptionId` | `string` | Template, Required | The subscription Id | +| `periodId` | `string` | Template, Required | The period Id | ## Response Type -[`GetSubscriptionItemResponse`](../../doc/models/get-subscription-item-response.md) +[`GetUsageReportResponse`](../../doc/models/get-usage-report-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$subscriptionItemId = 'subscription_item_id4'; +$periodId = 'period_id0'; -$result = $subscriptionsController->deleteSubscriptionItem( +$result = $subscriptionsController->getUsageReport( $subscriptionId, - $subscriptionItemId + $periodId ); ``` -# Get Increments - -```php -function getIncrements(string $subscriptionId, ?int $page = null, ?int $size = null): ListIncrementsResponse -``` - -## Parameters - -| Parameter | Type | Tags | Description | -| --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | The subscription id | -| `page` | `?int` | Query, Optional | Page number | -| `size` | `?int` | Query, Optional | Page size | - -## Response Type - -[`ListIncrementsResponse`](../../doc/models/list-increments-response.md) - -## Example Usage - -```php -$subscriptionId = 'subscription_id0'; - -$result = $subscriptionsController->getIncrements($subscriptionId); -``` - - -# Update Subscription Item - -Updates a subscription item +# Update Split Subscription ```php -function updateSubscriptionItem( - string $subscriptionId, - string $itemId, - UpdateSubscriptionItemRequest $body, - ?string $idempotencyKey = null -): GetSubscriptionItemResponse +function updateSplitSubscription(string $id, UpdateSubscriptionSplitRequest $request): GetSubscriptionResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | Subscription Id | -| `itemId` | `string` | Template, Required | Item id | -| `body` | [`UpdateSubscriptionItemRequest`](../../doc/models/update-subscription-item-request.md) | Body, Required | Request for updating a subscription item | -| `idempotencyKey` | `?string` | Header, Optional | - | +| `id` | `string` | Template, Required | Subscription's id | +| `request` | [`UpdateSubscriptionSplitRequest`](../../doc/models/update-subscription-split-request.md) | Body, Required | - | ## Response Type -[`GetSubscriptionItemResponse`](../../doc/models/get-subscription-item-response.md) +[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) ## Example Usage ```php -$subscriptionId = 'subscription_id0'; - -$itemId = 'item_id0'; +$id = 'id0'; -$body = UpdateSubscriptionItemRequestBuilder::init( - 'description4', - 'status2', - UpdatePricingSchemeRequestBuilder::init( - 'scheme_type8', - [ - UpdatePriceBracketRequestBuilder::init( - 144, - 174 - )->build() - ] - )->build(), - 'name6' +$request = UpdateSubscriptionSplitRequestBuilder::init( + false, + [ + CreateSplitRequestBuilder::init( + 'type2', + 118, + 'recipient_id2' + )->build() + ] )->build(); -$result = $subscriptionsController->updateSubscriptionItem( - $subscriptionId, - $itemId, - $body +$result = $subscriptionsController->updateSplitSubscription( + $id, + $request ); ``` diff --git a/doc/controllers/tokens.md b/doc/controllers/tokens.md index c1f26bb..732e7a7 100644 --- a/doc/controllers/tokens.md +++ b/doc/controllers/tokens.md @@ -10,26 +10,29 @@ $tokensController = $client->getTokensController(); ## Methods -* [Get Token](../../doc/controllers/tokens.md#get-token) * [Create Token](../../doc/controllers/tokens.md#create-token) +* [Get Token](../../doc/controllers/tokens.md#get-token) -# Get Token - -Gets a token from its id +# Create Token :information_source: **Note** This endpoint does not require authentication. ```php -function getToken(string $id, string $publicKey): GetTokenResponse +function createToken( + string $publicKey, + CreateTokenRequest $request, + ?string $idempotencyKey = null +): GetTokenResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `id` | `string` | Template, Required | Token id | | `publicKey` | `string` | Template, Required | Public key | +| `request` | [`CreateTokenRequest`](../../doc/models/create-token-request.md) | Body, Required | Request for creating a token | +| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -38,36 +41,44 @@ function getToken(string $id, string $publicKey): GetTokenResponse ## Example Usage ```php -$id = 'id0'; - $publicKey = 'public_key6'; -$result = $tokensController->getToken( - $id, - $publicKey +$request = CreateTokenRequestBuilder::init( + 'card', + CreateCardTokenRequestBuilder::init( + 'number6', + 'holder_name2', + 228, + 68, + 'cvv4', + 'brand0', + 'label6' + )->build() +)->build(); + +$result = $tokensController->createToken( + $publicKey, + $request ); ``` -# Create Token +# Get Token + +Gets a token from its id :information_source: **Note** This endpoint does not require authentication. ```php -function createToken( - string $publicKey, - CreateTokenRequest $request, - ?string $idempotencyKey = null -): GetTokenResponse +function getToken(string $id, string $publicKey): GetTokenResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | +| `id` | `string` | Template, Required | Token id | | `publicKey` | `string` | Template, Required | Public key | -| `request` | [`CreateTokenRequest`](../../doc/models/create-token-request.md) | Body, Required | Request for creating a token | -| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -76,24 +87,13 @@ function createToken( ## Example Usage ```php -$publicKey = 'public_key6'; +$id = 'id0'; -$request = CreateTokenRequestBuilder::init( - 'card', - CreateCardTokenRequestBuilder::init( - 'number6', - 'holder_name2', - 228, - 68, - 'cvv4', - 'brand0', - 'label6' - )->build() -)->build(); +$publicKey = 'public_key6'; -$result = $tokensController->createToken( - $publicKey, - $request +$result = $tokensController->getToken( + $id, + $publicKey ); ``` diff --git a/doc/controllers/transfers.md b/doc/controllers/transfers.md index d933c61..36eb1cb 100644 --- a/doc/controllers/transfers.md +++ b/doc/controllers/transfers.md @@ -11,8 +11,8 @@ $transfersController = $client->getTransfersController(); ## Methods * [Get Transfer by Id](../../doc/controllers/transfers.md#get-transfer-by-id) -* [Get Transfers](../../doc/controllers/transfers.md#get-transfers) * [Create Transfer](../../doc/controllers/transfers.md#create-transfer) +* [Get Transfers](../../doc/controllers/transfers.md#get-transfers) # Get Transfer by Id @@ -40,25 +40,6 @@ $result = $transfersController->getTransferById($transferId); ``` -# Get Transfers - -Gets all transfers - -```php -function getTransfers(): ListTransfers -``` - -## Response Type - -[`ListTransfers`](../../doc/models/list-transfers.md) - -## Example Usage - -```php -$result = $transfersController->getTransfers(); -``` - - # Create Transfer ```php @@ -87,3 +68,22 @@ $request = CreateTransferBuilder::init( $result = $transfersController->createTransfer($request); ``` + +# Get Transfers + +Gets all transfers + +```php +function getTransfers(): ListTransfers +``` + +## Response Type + +[`ListTransfers`](../../doc/models/list-transfers.md) + +## Example Usage + +```php +$result = $transfersController->getTransfers(); +``` + diff --git a/doc/models/create-customer-request.md b/doc/models/create-customer-request.md index b92488d..c495398 100644 --- a/doc/models/create-customer-request.md +++ b/doc/models/create-customer-request.md @@ -26,7 +26,7 @@ Request for creating a new customer ```json { - "name": "{\n \"name\": \"Tony Stark\"\n}", + "name": "Tony Stark", "email": "email8", "document": "document8", "type": "type2", diff --git a/doc/models/create-kyc-link-response.md b/doc/models/create-kyc-link-response.md new file mode 100644 index 0000000..5e36e2f --- /dev/null +++ b/doc/models/create-kyc-link-response.md @@ -0,0 +1,27 @@ + +# Create KYC Link Response + +KYC Link + +## Structure + +`CreateKYCLinkResponse` + +## Fields + +| Name | Type | Tags | Description | Getter | Setter | +| --- | --- | --- | --- | --- | --- | +| `base64` | `?string` | Optional | Base64 | getBase64(): ?string | setBase64(?string base64): void | +| `url` | `?string` | Optional | URL | getUrl(): ?string | setUrl(?string url): void | +| `expirationDate` | `?string` | Optional | Expiration Date | getExpirationDate(): ?string | setExpirationDate(?string expirationDate): void | + +## Example (as JSON) + +```json +{ + "base64": "base644", + "url": "url0", + "expiration_date": "expiration_date0" +} +``` + diff --git a/doc/models/create-order-request.md b/doc/models/create-order-request.md index 2c7e0ea..143a174 100644 --- a/doc/models/create-order-request.md +++ b/doc/models/create-order-request.md @@ -42,7 +42,7 @@ Request for creating an order } ], "customer": { - "name": "{\n \"name\": \"Tony Stark\"\n}", + "name": "Tony Stark", "email": "email6", "document": "document6", "type": "type0", diff --git a/doc/models/create-subscription-request.md b/doc/models/create-subscription-request.md index cc1e234..beae941 100644 --- a/doc/models/create-subscription-request.md +++ b/doc/models/create-subscription-request.md @@ -50,7 +50,7 @@ Request for creating a subcription ```json { "customer": { - "name": "{\n \"name\": \"Tony Stark\"\n}", + "name": "Tony Stark", "email": "email6", "document": "document6", "type": "type0", diff --git a/src/ApiHelper.php b/src/ApiHelper.php index 41d4b38..5c6c677 100644 --- a/src/ApiHelper.php +++ b/src/ApiHelper.php @@ -27,26 +27,26 @@ class ApiHelper */ private const INHERITED_MODELS_MAP = [ Models\GetTransactionResponse::class => [ + Models\GetBankTransferTransactionResponse::class, Models\GetSafetyPayTransactionResponse::class, Models\GetVoucherTransactionResponse::class, - Models\GetBankTransferTransactionResponse::class, Models\GetBoletoTransactionResponse::class, Models\GetDebitCardTransactionResponse::class, - Models\GetCashTransactionResponse::class, Models\GetPrivateLabelTransactionResponse::class, + Models\GetCashTransactionResponse::class, Models\GetCreditCardTransactionResponse::class, Models\GetPixTransactionResponse::class ], - Models\CreateRegisterInformationBaseRequest::class => [ - Models\CreateRegisterInformationIndividualRequest::class, - Models\CreateRegisterInformationCorporationRequest::class - ], Models\GetMovementObjectBaseResponse::class => [ + Models\GetMovementObjectRefundResponse::class, Models\GetMovementObjectFeeCollectionResponse::class, Models\GetMovementObjectPayableResponse::class, - Models\GetMovementObjectRefundResponse::class, Models\GetMovementObjectTransferResponse::class, Models\GetMovementObjectSettlementResponse::class + ], + Models\CreateRegisterInformationBaseRequest::class => [ + Models\CreateRegisterInformationIndividualRequest::class, + Models\CreateRegisterInformationCorporationRequest::class ] ]; diff --git a/src/Authentication/BasicAuthManager.php b/src/Authentication/BasicAuthManager.php index 91ce7af..68f3a06 100644 --- a/src/Authentication/BasicAuthManager.php +++ b/src/Authentication/BasicAuthManager.php @@ -12,6 +12,7 @@ use Core\Authentication\CoreAuth; use Core\Request\Parameters\HeaderParam; +use Core\Utils\CoreHelper; use PagarmeApiSDKLib\BasicAuthCredentials; /** @@ -31,10 +32,10 @@ class BasicAuthManager extends CoreAuth implements BasicAuthCredentials */ public function __construct(string $basicAuthUserName, string $basicAuthPassword) { - parent::__construct( - HeaderParam::init('Authorization', 'Basic ' . base64_encode("$basicAuthUserName:$basicAuthPassword")) - ->required() - ); + parent::__construct(HeaderParam::init( + 'Authorization', + CoreHelper::getBasicAuthEncodedString($basicAuthUserName, $basicAuthPassword) + )->requiredNonEmpty()); $this->basicAuthUserName = $basicAuthUserName; $this->basicAuthPassword = $basicAuthPassword; } diff --git a/src/Controllers/BalanceOperationsController.php b/src/Controllers/BalanceOperationsController.php index d716b34..a030c80 100644 --- a/src/Controllers/BalanceOperationsController.php +++ b/src/Controllers/BalanceOperationsController.php @@ -20,24 +20,6 @@ class BalanceOperationsController extends BaseController { - /** - * @param int $id - * - * @return GetBalanceOperationResponse Response from the API call - * - * @throws ApiException Thrown if API call fails - */ - public function getBalanceOperationById(int $id): GetBalanceOperationResponse - { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/balance/operations/{id}') - ->auth('httpBasic') - ->parameters(TemplateParam::init('id', $id)); - - $_resHandler = $this->responseHandler()->type(GetBalanceOperationResponse::class); - - return $this->execute($_reqBuilder, $_resHandler); - } - /** * @param string|null $status * @param \DateTime|null $createdSince @@ -69,4 +51,22 @@ public function getBalanceOperations( return $this->execute($_reqBuilder, $_resHandler); } + + /** + * @param int $id + * + * @return GetBalanceOperationResponse Response from the API call + * + * @throws ApiException Thrown if API call fails + */ + public function getBalanceOperationById(int $id): GetBalanceOperationResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/balance/operations/{id}') + ->auth('httpBasic') + ->parameters(TemplateParam::init('id', $id)); + + $_resHandler = $this->responseHandler()->type(GetBalanceOperationResponse::class); + + return $this->execute($_reqBuilder, $_resHandler); + } } diff --git a/src/Controllers/ChargesController.php b/src/Controllers/ChargesController.php index 8b7899c..22a3033 100644 --- a/src/Controllers/ChargesController.php +++ b/src/Controllers/ChargesController.php @@ -62,22 +62,23 @@ public function updateChargeMetadata( } /** - * Captures a charge + * Updates a charge's payment method * * @param string $chargeId Charge id - * @param CreateCaptureChargeRequest|null $request Request for capturing a charge + * @param UpdateChargePaymentMethodRequest $request Request for updating the payment method from + * a charge * @param string|null $idempotencyKey * * @return GetChargeResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function captureCharge( + public function updateChargePaymentMethod( string $chargeId, - ?CreateCaptureChargeRequest $request = null, + UpdateChargePaymentMethodRequest $request, ?string $idempotencyKey = null ): GetChargeResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/charges/{charge_id}/capture') + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/charges/{charge_id}/payment-method') ->auth('httpBasic') ->parameters( TemplateParam::init('charge_id', $chargeId), @@ -91,40 +92,49 @@ public function captureCharge( } /** - * Get a charge from its id - * - * @param string $chargeId Charge id + * @param string $chargeId Charge Id + * @param int|null $page Page number + * @param int|null $size Page size * - * @return GetChargeResponse Response from the API call + * @return ListChargeTransactionsResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getCharge(string $chargeId): GetChargeResponse - { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/charges/{charge_id}') + public function getChargeTransactions( + string $chargeId, + ?int $page = null, + ?int $size = null + ): ListChargeTransactionsResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/charges/{charge_id}/transactions') ->auth('httpBasic') - ->parameters(TemplateParam::init('charge_id', $chargeId)); + ->parameters( + TemplateParam::init('charge_id', $chargeId), + QueryParam::init('page', $page), + QueryParam::init('size', $size) + ); - $_resHandler = $this->responseHandler()->type(GetChargeResponse::class); + $_resHandler = $this->responseHandler()->type(ListChargeTransactionsResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * @param string $chargeId - * @param CreateConfirmPaymentRequest|null $request Request for confirm payment + * Updates the due date from a charge + * + * @param string $chargeId Charge Id + * @param UpdateChargeDueDateRequest $request Request for updating the due date * @param string|null $idempotencyKey * * @return GetChargeResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function confirmPayment( + public function updateChargeDueDate( string $chargeId, - ?CreateConfirmPaymentRequest $request = null, + UpdateChargeDueDateRequest $request, ?string $idempotencyKey = null ): GetChargeResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/charges/{charge_id}/confirm-payment') + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/Charges/{charge_id}/due-date') ->auth('httpBasic') ->parameters( TemplateParam::init('charge_id', $chargeId), @@ -138,49 +148,72 @@ public function confirmPayment( } /** - * @param string $chargeId Charge Id + * Lists all charges + * * @param int|null $page Page number * @param int|null $size Page size + * @param string|null $code Filter for charge's code + * @param string|null $status Filter for charge's status + * @param string|null $paymentMethod Filter for charge's payment method + * @param string|null $customerId Filter for charge's customer id + * @param string|null $orderId Filter for charge's order id + * @param \DateTime|null $createdSince Filter for the beginning of the range for charge's + * creation + * @param \DateTime|null $createdUntil Filter for the end of the range for charge's creation * - * @return ListChargeTransactionsResponse Response from the API call + * @return ListChargesResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getChargeTransactions( - string $chargeId, + public function getCharges( ?int $page = null, - ?int $size = null - ): ListChargeTransactionsResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/charges/{charge_id}/transactions') + ?int $size = null, + ?string $code = null, + ?string $status = null, + ?string $paymentMethod = null, + ?string $customerId = null, + ?string $orderId = null, + ?\DateTime $createdSince = null, + ?\DateTime $createdUntil = null + ): ListChargesResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/charges') ->auth('httpBasic') ->parameters( - TemplateParam::init('charge_id', $chargeId), QueryParam::init('page', $page), - QueryParam::init('size', $size) + QueryParam::init('size', $size), + QueryParam::init('code', $code), + QueryParam::init('status', $status), + QueryParam::init('payment_method', $paymentMethod), + QueryParam::init('customer_id', $customerId), + QueryParam::init('order_id', $orderId), + QueryParam::init('created_since', $createdSince) + ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), + QueryParam::init('created_until', $createdUntil) + ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']) ); - $_resHandler = $this->responseHandler()->type(ListChargeTransactionsResponse::class); + $_resHandler = $this->responseHandler()->type(ListChargesResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Updates the card from a charge + * Captures a charge * * @param string $chargeId Charge id - * @param UpdateChargeCardRequest $request Request for updating a charge's card + * @param CreateCaptureChargeRequest|null $request Request for capturing a charge * @param string|null $idempotencyKey * * @return GetChargeResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateChargeCard( + public function captureCharge( string $chargeId, - UpdateChargeCardRequest $request, + ?CreateCaptureChargeRequest $request = null, ?string $idempotencyKey = null ): GetChargeResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/charges/{charge_id}/card') + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/charges/{charge_id}/capture') ->auth('httpBasic') ->parameters( TemplateParam::init('charge_id', $chargeId), @@ -194,44 +227,22 @@ public function updateChargeCard( } /** - * Creates a new charge - * - * @param CreateChargeRequest $request Request for creating a charge - * @param string|null $idempotencyKey - * - * @return GetChargeResponse Response from the API call - * - * @throws ApiException Thrown if API call fails - */ - public function createCharge(CreateChargeRequest $request, ?string $idempotencyKey = null): GetChargeResponse - { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/Charges') - ->auth('httpBasic') - ->parameters(BodyParam::init($request), HeaderParam::init('idempotency-key', $idempotencyKey)); - - $_resHandler = $this->responseHandler()->type(GetChargeResponse::class); - - return $this->execute($_reqBuilder, $_resHandler); - } - - /** - * Updates a charge's payment method + * Updates the card from a charge * * @param string $chargeId Charge id - * @param UpdateChargePaymentMethodRequest $request Request for updating the payment method from - * a charge + * @param UpdateChargeCardRequest $request Request for updating a charge's card * @param string|null $idempotencyKey * * @return GetChargeResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateChargePaymentMethod( + public function updateChargeCard( string $chargeId, - UpdateChargePaymentMethodRequest $request, + UpdateChargeCardRequest $request, ?string $idempotencyKey = null ): GetChargeResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/charges/{charge_id}/payment-method') + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/charges/{charge_id}/card') ->auth('httpBasic') ->parameters( TemplateParam::init('charge_id', $chargeId), @@ -245,28 +256,19 @@ public function updateChargePaymentMethod( } /** - * Updates the due date from a charge + * Get a charge from its id * - * @param string $chargeId Charge Id - * @param UpdateChargeDueDateRequest $request Request for updating the due date - * @param string|null $idempotencyKey + * @param string $chargeId Charge id * * @return GetChargeResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateChargeDueDate( - string $chargeId, - UpdateChargeDueDateRequest $request, - ?string $idempotencyKey = null - ): GetChargeResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/Charges/{charge_id}/due-date') + public function getCharge(string $chargeId): GetChargeResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/charges/{charge_id}') ->auth('httpBasic') - ->parameters( - TemplateParam::init('charge_id', $chargeId), - BodyParam::init($request), - HeaderParam::init('idempotency-key', $idempotencyKey) - ); + ->parameters(TemplateParam::init('charge_id', $chargeId)); $_resHandler = $this->responseHandler()->type(GetChargeResponse::class); @@ -327,72 +329,70 @@ public function retryCharge(string $chargeId, ?string $idempotencyKey = null): G } /** - * Lists all charges + * Cancel a charge * - * @param int|null $page Page number - * @param int|null $size Page size - * @param string|null $code Filter for charge's code - * @param string|null $status Filter for charge's status - * @param string|null $paymentMethod Filter for charge's payment method - * @param string|null $customerId Filter for charge's customer id - * @param string|null $orderId Filter for charge's order id - * @param \DateTime|null $createdSince Filter for the beginning of the range for charge's - * creation - * @param \DateTime|null $createdUntil Filter for the end of the range for charge's creation + * @param string $chargeId Charge id + * @param CreateCancelChargeRequest|null $request Request for cancelling a charge + * @param string|null $idempotencyKey * - * @return ListChargesResponse Response from the API call + * @return GetChargeResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getCharges( - ?int $page = null, - ?int $size = null, - ?string $code = null, - ?string $status = null, - ?string $paymentMethod = null, - ?string $customerId = null, - ?string $orderId = null, - ?\DateTime $createdSince = null, - ?\DateTime $createdUntil = null - ): ListChargesResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/charges') + public function cancelCharge( + string $chargeId, + ?CreateCancelChargeRequest $request = null, + ?string $idempotencyKey = null + ): GetChargeResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/charges/{charge_id}') ->auth('httpBasic') ->parameters( - QueryParam::init('page', $page), - QueryParam::init('size', $size), - QueryParam::init('code', $code), - QueryParam::init('status', $status), - QueryParam::init('payment_method', $paymentMethod), - QueryParam::init('customer_id', $customerId), - QueryParam::init('order_id', $orderId), - QueryParam::init('created_since', $createdSince) - ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), - QueryParam::init('created_until', $createdUntil) - ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']) + TemplateParam::init('charge_id', $chargeId), + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(ListChargesResponse::class); + $_resHandler = $this->responseHandler()->type(GetChargeResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Cancel a charge + * Creates a new charge * - * @param string $chargeId Charge id - * @param CreateCancelChargeRequest|null $request Request for cancelling a charge + * @param CreateChargeRequest $request Request for creating a charge * @param string|null $idempotencyKey * * @return GetChargeResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function cancelCharge( + public function createCharge(CreateChargeRequest $request, ?string $idempotencyKey = null): GetChargeResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/Charges') + ->auth('httpBasic') + ->parameters(BodyParam::init($request), HeaderParam::init('idempotency-key', $idempotencyKey)); + + $_resHandler = $this->responseHandler()->type(GetChargeResponse::class); + + return $this->execute($_reqBuilder, $_resHandler); + } + + /** + * @param string $chargeId + * @param CreateConfirmPaymentRequest|null $request Request for confirm payment + * @param string|null $idempotencyKey + * + * @return GetChargeResponse Response from the API call + * + * @throws ApiException Thrown if API call fails + */ + public function confirmPayment( string $chargeId, - ?CreateCancelChargeRequest $request = null, + ?CreateConfirmPaymentRequest $request = null, ?string $idempotencyKey = null ): GetChargeResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/charges/{charge_id}') + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/charges/{charge_id}/confirm-payment') ->auth('httpBasic') ->parameters( TemplateParam::init('charge_id', $chargeId), diff --git a/src/Controllers/CustomersController.php b/src/Controllers/CustomersController.php index 0bcf106..52a7fe7 100644 --- a/src/Controllers/CustomersController.php +++ b/src/Controllers/CustomersController.php @@ -36,62 +36,65 @@ class CustomersController extends BaseController { /** - * Creates a new address for a customer + * Updates a card * * @param string $customerId Customer Id - * @param CreateAddressRequest $request Request for creating an address + * @param string $cardId Card id + * @param UpdateCardRequest $request Request for updating a card * @param string|null $idempotencyKey * - * @return GetAddressResponse Response from the API call + * @return GetCardResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function createAddress( + public function updateCard( string $customerId, - CreateAddressRequest $request, + string $cardId, + UpdateCardRequest $request, ?string $idempotencyKey = null - ): GetAddressResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/customers/{customer_id}/addresses') + ): GetCardResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/customers/{customer_id}/cards/{card_id}') ->auth('httpBasic') ->parameters( TemplateParam::init('customer_id', $customerId), + TemplateParam::init('card_id', $cardId), BodyParam::init($request), HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetAddressResponse::class); + $_resHandler = $this->responseHandler()->type(GetCardResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Updates a card + * Updates an address * * @param string $customerId Customer Id - * @param string $cardId Card id - * @param UpdateCardRequest $request Request for updating a card + * @param string $addressId Address Id + * @param UpdateAddressRequest $request Request for updating an address * @param string|null $idempotencyKey * - * @return GetCardResponse Response from the API call + * @return GetAddressResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateCard( + public function updateAddress( string $customerId, - string $cardId, - UpdateCardRequest $request, + string $addressId, + UpdateAddressRequest $request, ?string $idempotencyKey = null - ): GetCardResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/customers/{customer_id}/cards/{card_id}') + ): GetAddressResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/customers/{customer_id}/addresses/{address_id}') ->auth('httpBasic') ->parameters( TemplateParam::init('customer_id', $customerId), - TemplateParam::init('card_id', $cardId), + TemplateParam::init('address_id', $addressId), BodyParam::init($request), HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetCardResponse::class); + $_resHandler = $this->responseHandler()->type(GetAddressResponse::class); return $this->execute($_reqBuilder, $_resHandler); } @@ -150,53 +153,50 @@ public function createCustomer(CreateCustomerRequest $request, ?string $idempote } /** - * Delete a Customer's access tokens + * Creates a new address for a customer * * @param string $customerId Customer Id + * @param CreateAddressRequest $request Request for creating an address + * @param string|null $idempotencyKey * - * @return ListAccessTokensResponse Response from the API call + * @return GetAddressResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function deleteAccessTokens(string $customerId): ListAccessTokensResponse - { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/customers/{customer_id}/access-tokens/') + public function createAddress( + string $customerId, + CreateAddressRequest $request, + ?string $idempotencyKey = null + ): GetAddressResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/customers/{customer_id}/addresses') ->auth('httpBasic') - ->parameters(TemplateParam::init('customer_id', $customerId)); + ->parameters( + TemplateParam::init('customer_id', $customerId), + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) + ); - $_resHandler = $this->responseHandler()->type(ListAccessTokensResponse::class); + $_resHandler = $this->responseHandler()->type(GetAddressResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Updates an address + * Delete a Customer's access tokens * * @param string $customerId Customer Id - * @param string $addressId Address Id - * @param UpdateAddressRequest $request Request for updating an address - * @param string|null $idempotencyKey * - * @return GetAddressResponse Response from the API call + * @return ListAccessTokensResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateAddress( - string $customerId, - string $addressId, - UpdateAddressRequest $request, - ?string $idempotencyKey = null - ): GetAddressResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/customers/{customer_id}/addresses/{address_id}') + public function deleteAccessTokens(string $customerId): ListAccessTokensResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/customers/{customer_id}/access-tokens/') ->auth('httpBasic') - ->parameters( - TemplateParam::init('customer_id', $customerId), - TemplateParam::init('address_id', $addressId), - BodyParam::init($request), - HeaderParam::init('idempotency-key', $idempotencyKey) - ); + ->parameters(TemplateParam::init('customer_id', $customerId)); - $_resHandler = $this->responseHandler()->type(GetAddressResponse::class); + $_resHandler = $this->responseHandler()->type(ListAccessTokensResponse::class); return $this->execute($_reqBuilder, $_resHandler); } @@ -257,6 +257,35 @@ public function deleteAddress( return $this->execute($_reqBuilder, $_resHandler); } + /** + * Creates a new card for a customer + * + * @param string $customerId Customer id + * @param CreateCardRequest $request Request for creating a card + * @param string|null $idempotencyKey + * + * @return GetCardResponse Response from the API call + * + * @throws ApiException Thrown if API call fails + */ + public function createCard( + string $customerId, + CreateCardRequest $request, + ?string $idempotencyKey = null + ): GetCardResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/customers/{customer_id}/cards') + ->auth('httpBasic') + ->parameters( + TemplateParam::init('customer_id', $customerId), + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) + ); + + $_resHandler = $this->responseHandler()->type(GetCardResponse::class); + + return $this->execute($_reqBuilder, $_resHandler); + } + /** * Get all Customers * @@ -296,95 +325,51 @@ public function getCustomers( } /** - * Get all access tokens from a customer - * - * @param string $customerId Customer Id - * @param int|null $page Page number - * @param int|null $size Page size - * - * @return ListAccessTokensResponse Response from the API call - * - * @throws ApiException Thrown if API call fails - */ - public function getAccessTokens(string $customerId, ?int $page = null, ?int $size = null): ListAccessTokensResponse - { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/customers/{customer_id}/access-tokens') - ->auth('httpBasic') - ->parameters( - TemplateParam::init('customer_id', $customerId), - QueryParam::init('page', $page), - QueryParam::init('size', $size) - ); - - $_resHandler = $this->responseHandler()->type(ListAccessTokensResponse::class); - - return $this->execute($_reqBuilder, $_resHandler); - } - - /** - * Delete a customer's card + * Updates a customer * - * @param string $customerId Customer Id - * @param string $cardId Card Id + * @param string $customerId Customer id + * @param UpdateCustomerRequest $request Request for updating a customer * @param string|null $idempotencyKey * - * @return GetCardResponse Response from the API call + * @return GetCustomerResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function deleteCard(string $customerId, string $cardId, ?string $idempotencyKey = null): GetCardResponse - { - $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/customers/{customer_id}/cards/{card_id}') + public function updateCustomer( + string $customerId, + UpdateCustomerRequest $request, + ?string $idempotencyKey = null + ): GetCustomerResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/customers/{customer_id}') ->auth('httpBasic') ->parameters( TemplateParam::init('customer_id', $customerId), - TemplateParam::init('card_id', $cardId), + BodyParam::init($request), HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetCardResponse::class); - - return $this->execute($_reqBuilder, $_resHandler); - } - - /** - * Get a customer's card - * - * @param string $customerId Customer id - * @param string $cardId Card id - * - * @return GetCardResponse Response from the API call - * - * @throws ApiException Thrown if API call fails - */ - public function getCard(string $customerId, string $cardId): GetCardResponse - { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/customers/{customer_id}/cards/{card_id}') - ->auth('httpBasic') - ->parameters(TemplateParam::init('customer_id', $customerId), TemplateParam::init('card_id', $cardId)); - - $_resHandler = $this->responseHandler()->type(GetCardResponse::class); + $_resHandler = $this->responseHandler()->type(GetCustomerResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Creates a new card for a customer + * Creates a access token for a customer * - * @param string $customerId Customer id - * @param CreateCardRequest $request Request for creating a card + * @param string $customerId Customer Id + * @param CreateAccessTokenRequest $request Request for creating a access token * @param string|null $idempotencyKey * - * @return GetCardResponse Response from the API call + * @return GetAccessTokenResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function createCard( + public function createAccessToken( string $customerId, - CreateCardRequest $request, + CreateAccessTokenRequest $request, ?string $idempotencyKey = null - ): GetCardResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/customers/{customer_id}/cards') + ): GetAccessTokenResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/customers/{customer_id}/access-tokens') ->auth('httpBasic') ->parameters( TemplateParam::init('customer_id', $customerId), @@ -392,52 +377,51 @@ public function createCard( HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetCardResponse::class); + $_resHandler = $this->responseHandler()->type(GetAccessTokenResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Get a Customer's access token + * Get all access tokens from a customer * * @param string $customerId Customer Id - * @param string $tokenId Token Id + * @param int|null $page Page number + * @param int|null $size Page size * - * @return GetAccessTokenResponse Response from the API call + * @return ListAccessTokensResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getAccessToken(string $customerId, string $tokenId): GetAccessTokenResponse + public function getAccessTokens(string $customerId, ?int $page = null, ?int $size = null): ListAccessTokensResponse { - $_reqBuilder = $this->requestBuilder( - RequestMethod::GET, - '/customers/{customer_id}/access-tokens/{token_id}' - ) + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/customers/{customer_id}/access-tokens') ->auth('httpBasic') ->parameters( TemplateParam::init('customer_id', $customerId), - TemplateParam::init('token_id', $tokenId) + QueryParam::init('page', $page), + QueryParam::init('size', $size) ); - $_resHandler = $this->responseHandler()->type(GetAccessTokenResponse::class); + $_resHandler = $this->responseHandler()->type(ListAccessTokensResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Gets all adressess from a customer + * Get all cards from a customer * - * @param string $customerId Customer id + * @param string $customerId Customer Id * @param int|null $page Page number * @param int|null $size Page size * - * @return ListAddressesResponse Response from the API call + * @return ListCardsResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getAddresses(string $customerId, ?int $page = null, ?int $size = null): ListAddressesResponse + public function getCards(string $customerId, ?int $page = null, ?int $size = null): ListCardsResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/customers/{customer_id}/addresses') + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/customers/{customer_id}/cards') ->auth('httpBasic') ->parameters( TemplateParam::init('customer_id', $customerId), @@ -445,62 +429,57 @@ public function getAddresses(string $customerId, ?int $page = null, ?int $size = QueryParam::init('size', $size) ); - $_resHandler = $this->responseHandler()->type(ListAddressesResponse::class); + $_resHandler = $this->responseHandler()->type(ListCardsResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Updates a customer + * Renew a card * * @param string $customerId Customer id - * @param UpdateCustomerRequest $request Request for updating a customer + * @param string $cardId Card Id * @param string|null $idempotencyKey * - * @return GetCustomerResponse Response from the API call + * @return GetCardResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateCustomer( - string $customerId, - UpdateCustomerRequest $request, - ?string $idempotencyKey = null - ): GetCustomerResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/customers/{customer_id}') + public function renewCard(string $customerId, string $cardId, ?string $idempotencyKey = null): GetCardResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/customers/{customer_id}/cards/{card_id}/renew') ->auth('httpBasic') ->parameters( TemplateParam::init('customer_id', $customerId), - BodyParam::init($request), + TemplateParam::init('card_id', $cardId), HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetCustomerResponse::class); + $_resHandler = $this->responseHandler()->type(GetCardResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Creates a access token for a customer + * Get a Customer's access token * * @param string $customerId Customer Id - * @param CreateAccessTokenRequest $request Request for creating a access token - * @param string|null $idempotencyKey + * @param string $tokenId Token Id * * @return GetAccessTokenResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function createAccessToken( - string $customerId, - CreateAccessTokenRequest $request, - ?string $idempotencyKey = null - ): GetAccessTokenResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/customers/{customer_id}/access-tokens') + public function getAccessToken(string $customerId, string $tokenId): GetAccessTokenResponse + { + $_reqBuilder = $this->requestBuilder( + RequestMethod::GET, + '/customers/{customer_id}/access-tokens/{token_id}' + ) ->auth('httpBasic') ->parameters( TemplateParam::init('customer_id', $customerId), - BodyParam::init($request), - HeaderParam::init('idempotency-key', $idempotencyKey) + TemplateParam::init('token_id', $tokenId) ); $_resHandler = $this->responseHandler()->type(GetAccessTokenResponse::class); @@ -509,35 +488,38 @@ public function createAccessToken( } /** - * Get all cards from a customer + * Updates the metadata a customer * - * @param string $customerId Customer Id - * @param int|null $page Page number - * @param int|null $size Page size + * @param string $customerId The customer id + * @param UpdateMetadataRequest $request Request for updating the customer metadata + * @param string|null $idempotencyKey * - * @return ListCardsResponse Response from the API call + * @return GetCustomerResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getCards(string $customerId, ?int $page = null, ?int $size = null): ListCardsResponse - { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/customers/{customer_id}/cards') + public function updateCustomerMetadata( + string $customerId, + UpdateMetadataRequest $request, + ?string $idempotencyKey = null + ): GetCustomerResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/Customers/{customer_id}/metadata') ->auth('httpBasic') ->parameters( TemplateParam::init('customer_id', $customerId), - QueryParam::init('page', $page), - QueryParam::init('size', $size) + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(ListCardsResponse::class); + $_resHandler = $this->responseHandler()->type(GetCustomerResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Renew a card + * Delete a customer's card * - * @param string $customerId Customer id + * @param string $customerId Customer Id * @param string $cardId Card Id * @param string|null $idempotencyKey * @@ -545,9 +527,9 @@ public function getCards(string $customerId, ?int $page = null, ?int $size = nul * * @throws ApiException Thrown if API call fails */ - public function renewCard(string $customerId, string $cardId, ?string $idempotencyKey = null): GetCardResponse + public function deleteCard(string $customerId, string $cardId, ?string $idempotencyKey = null): GetCardResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/customers/{customer_id}/cards/{card_id}/renew') + $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/customers/{customer_id}/cards/{card_id}') ->auth('httpBasic') ->parameters( TemplateParam::init('customer_id', $customerId), @@ -561,30 +543,27 @@ public function renewCard(string $customerId, string $cardId, ?string $idempoten } /** - * Updates the metadata a customer + * Gets all adressess from a customer * - * @param string $customerId The customer id - * @param UpdateMetadataRequest $request Request for updating the customer metadata - * @param string|null $idempotencyKey + * @param string $customerId Customer id + * @param int|null $page Page number + * @param int|null $size Page size * - * @return GetCustomerResponse Response from the API call + * @return ListAddressesResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateCustomerMetadata( - string $customerId, - UpdateMetadataRequest $request, - ?string $idempotencyKey = null - ): GetCustomerResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/Customers/{customer_id}/metadata') + public function getAddresses(string $customerId, ?int $page = null, ?int $size = null): ListAddressesResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/customers/{customer_id}/addresses') ->auth('httpBasic') ->parameters( TemplateParam::init('customer_id', $customerId), - BodyParam::init($request), - HeaderParam::init('idempotency-key', $idempotencyKey) + QueryParam::init('page', $page), + QueryParam::init('size', $size) ); - $_resHandler = $this->responseHandler()->type(GetCustomerResponse::class); + $_resHandler = $this->responseHandler()->type(ListAddressesResponse::class); return $this->execute($_reqBuilder, $_resHandler); } @@ -608,4 +587,25 @@ public function getCustomer(string $customerId): GetCustomerResponse return $this->execute($_reqBuilder, $_resHandler); } + + /** + * Get a customer's card + * + * @param string $customerId Customer id + * @param string $cardId Card id + * + * @return GetCardResponse Response from the API call + * + * @throws ApiException Thrown if API call fails + */ + public function getCard(string $customerId, string $cardId): GetCardResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/customers/{customer_id}/cards/{card_id}') + ->auth('httpBasic') + ->parameters(TemplateParam::init('customer_id', $customerId), TemplateParam::init('card_id', $cardId)); + + $_resHandler = $this->responseHandler()->type(GetCardResponse::class); + + return $this->execute($_reqBuilder, $_resHandler); + } } diff --git a/src/Controllers/InvoicesController.php b/src/Controllers/InvoicesController.php index 4c3a0a8..b875abc 100644 --- a/src/Controllers/InvoicesController.php +++ b/src/Controllers/InvoicesController.php @@ -26,56 +26,49 @@ class InvoicesController extends BaseController { /** - * Gets all invoices + * Updates the metadata from an invoice * - * @param int|null $page Page number - * @param int|null $size Page size - * @param string|null $code Filter for Invoice's code - * @param string|null $customerId Filter for Invoice's customer id - * @param string|null $subscriptionId Filter for Invoice's subscription id - * @param \DateTime|null $createdSince Filter for Invoice's creation date start range - * @param \DateTime|null $createdUntil Filter for Invoices creation date end range - * @param string|null $status Filter for Invoice's status - * @param \DateTime|null $dueSince Filter for Invoice's due date start range - * @param \DateTime|null $dueUntil Filter for Invoice's due date end range - * @param string|null $customerDocument + * @param string $invoiceId The invoice id + * @param UpdateMetadataRequest $request Request for updating the invoice metadata + * @param string|null $idempotencyKey * - * @return ListInvoicesResponse Response from the API call + * @return GetInvoiceResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getInvoices( - ?int $page = null, - ?int $size = null, - ?string $code = null, - ?string $customerId = null, - ?string $subscriptionId = null, - ?\DateTime $createdSince = null, - ?\DateTime $createdUntil = null, - ?string $status = null, - ?\DateTime $dueSince = null, - ?\DateTime $dueUntil = null, - ?string $customerDocument = null - ): ListInvoicesResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/invoices') + public function updateInvoiceMetadata( + string $invoiceId, + UpdateMetadataRequest $request, + ?string $idempotencyKey = null + ): GetInvoiceResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/invoices/{invoice_id}/metadata') ->auth('httpBasic') ->parameters( - QueryParam::init('page', $page), - QueryParam::init('size', $size), - QueryParam::init('code', $code), - QueryParam::init('customer_id', $customerId), - QueryParam::init('subscription_id', $subscriptionId), - QueryParam::init('created_since', $createdSince) - ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), - QueryParam::init('created_until', $createdUntil) - ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), - QueryParam::init('status', $status), - QueryParam::init('due_since', $dueSince)->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), - QueryParam::init('due_until', $dueUntil)->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), - QueryParam::init('customer_document', $customerDocument) + TemplateParam::init('invoice_id', $invoiceId), + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(ListInvoicesResponse::class); + $_resHandler = $this->responseHandler()->type(GetInvoiceResponse::class); + + return $this->execute($_reqBuilder, $_resHandler); + } + + /** + * @param string $subscriptionId Subscription Id + * + * @return GetInvoiceResponse Response from the API call + * + * @throws ApiException Thrown if API call fails + */ + public function getPartialInvoice(string $subscriptionId): GetInvoiceResponse + { + $_reqBuilder = $this->requestBuilder( + RequestMethod::GET, + '/subscriptions/{subscription_id}/partial-invoice' + )->auth('httpBasic')->parameters(TemplateParam::init('subscription_id', $subscriptionId)); + + $_resHandler = $this->responseHandler()->type(GetInvoiceResponse::class); return $this->execute($_reqBuilder, $_resHandler); } @@ -105,25 +98,31 @@ public function cancelInvoice(string $invoiceId, ?string $idempotencyKey = null) } /** - * Updates the status from an invoice + * Create an Invoice * - * @param string $invoiceId Invoice Id - * @param UpdateInvoiceStatusRequest $request Request for updating an invoice's status + * @param string $subscriptionId Subscription Id + * @param string $cycleId Cycle Id + * @param CreateInvoiceRequest|null $request * @param string|null $idempotencyKey * * @return GetInvoiceResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateInvoiceStatus( - string $invoiceId, - UpdateInvoiceStatusRequest $request, + public function createInvoice( + string $subscriptionId, + string $cycleId, + ?CreateInvoiceRequest $request = null, ?string $idempotencyKey = null ): GetInvoiceResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/invoices/{invoice_id}/status') + $_reqBuilder = $this->requestBuilder( + RequestMethod::POST, + '/subscriptions/{subscription_id}/cycles/{cycle_id}/pay' + ) ->auth('httpBasic') ->parameters( - TemplateParam::init('invoice_id', $invoiceId), + TemplateParam::init('subscription_id', $subscriptionId), + TemplateParam::init('cycle_id', $cycleId), BodyParam::init($request), HeaderParam::init('idempotency-key', $idempotencyKey) ); @@ -134,47 +133,74 @@ public function updateInvoiceStatus( } /** - * Updates the metadata from an invoice + * Gets all invoices * - * @param string $invoiceId The invoice id - * @param UpdateMetadataRequest $request Request for updating the invoice metadata - * @param string|null $idempotencyKey + * @param int|null $page Page number + * @param int|null $size Page size + * @param string|null $code Filter for Invoice's code + * @param string|null $customerId Filter for Invoice's customer id + * @param string|null $subscriptionId Filter for Invoice's subscription id + * @param \DateTime|null $createdSince Filter for Invoice's creation date start range + * @param \DateTime|null $createdUntil Filter for Invoices creation date end range + * @param string|null $status Filter for Invoice's status + * @param \DateTime|null $dueSince Filter for Invoice's due date start range + * @param \DateTime|null $dueUntil Filter for Invoice's due date end range + * @param string|null $customerDocument * - * @return GetInvoiceResponse Response from the API call + * @return ListInvoicesResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateInvoiceMetadata( - string $invoiceId, - UpdateMetadataRequest $request, - ?string $idempotencyKey = null - ): GetInvoiceResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/invoices/{invoice_id}/metadata') + public function getInvoices( + ?int $page = null, + ?int $size = null, + ?string $code = null, + ?string $customerId = null, + ?string $subscriptionId = null, + ?\DateTime $createdSince = null, + ?\DateTime $createdUntil = null, + ?string $status = null, + ?\DateTime $dueSince = null, + ?\DateTime $dueUntil = null, + ?string $customerDocument = null + ): ListInvoicesResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/invoices') ->auth('httpBasic') ->parameters( - TemplateParam::init('invoice_id', $invoiceId), - BodyParam::init($request), - HeaderParam::init('idempotency-key', $idempotencyKey) + QueryParam::init('page', $page), + QueryParam::init('size', $size), + QueryParam::init('code', $code), + QueryParam::init('customer_id', $customerId), + QueryParam::init('subscription_id', $subscriptionId), + QueryParam::init('created_since', $createdSince) + ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), + QueryParam::init('created_until', $createdUntil) + ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), + QueryParam::init('status', $status), + QueryParam::init('due_since', $dueSince)->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), + QueryParam::init('due_until', $dueUntil)->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), + QueryParam::init('customer_document', $customerDocument) ); - $_resHandler = $this->responseHandler()->type(GetInvoiceResponse::class); + $_resHandler = $this->responseHandler()->type(ListInvoicesResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * @param string $subscriptionId Subscription Id + * Gets an invoice + * + * @param string $invoiceId Invoice Id * * @return GetInvoiceResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getPartialInvoice(string $subscriptionId): GetInvoiceResponse + public function getInvoice(string $invoiceId): GetInvoiceResponse { - $_reqBuilder = $this->requestBuilder( - RequestMethod::GET, - '/subscriptions/{subscription_id}/partial-invoice' - )->auth('httpBasic')->parameters(TemplateParam::init('subscription_id', $subscriptionId)); + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/invoices/{invoice_id}') + ->auth('httpBasic') + ->parameters(TemplateParam::init('invoice_id', $invoiceId)); $_resHandler = $this->responseHandler()->type(GetInvoiceResponse::class); @@ -182,31 +208,25 @@ public function getPartialInvoice(string $subscriptionId): GetInvoiceResponse } /** - * Create an Invoice + * Updates the status from an invoice * - * @param string $subscriptionId Subscription Id - * @param string $cycleId Cycle Id - * @param CreateInvoiceRequest|null $request + * @param string $invoiceId Invoice Id + * @param UpdateInvoiceStatusRequest $request Request for updating an invoice's status * @param string|null $idempotencyKey * * @return GetInvoiceResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function createInvoice( - string $subscriptionId, - string $cycleId, - ?CreateInvoiceRequest $request = null, + public function updateInvoiceStatus( + string $invoiceId, + UpdateInvoiceStatusRequest $request, ?string $idempotencyKey = null ): GetInvoiceResponse { - $_reqBuilder = $this->requestBuilder( - RequestMethod::POST, - '/subscriptions/{subscription_id}/cycles/{cycle_id}/pay' - ) + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/invoices/{invoice_id}/status') ->auth('httpBasic') ->parameters( - TemplateParam::init('subscription_id', $subscriptionId), - TemplateParam::init('cycle_id', $cycleId), + TemplateParam::init('invoice_id', $invoiceId), BodyParam::init($request), HeaderParam::init('idempotency-key', $idempotencyKey) ); @@ -215,24 +235,4 @@ public function createInvoice( return $this->execute($_reqBuilder, $_resHandler); } - - /** - * Gets an invoice - * - * @param string $invoiceId Invoice Id - * - * @return GetInvoiceResponse Response from the API call - * - * @throws ApiException Thrown if API call fails - */ - public function getInvoice(string $invoiceId): GetInvoiceResponse - { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/invoices/{invoice_id}') - ->auth('httpBasic') - ->parameters(TemplateParam::init('invoice_id', $invoiceId)); - - $_resHandler = $this->responseHandler()->type(GetInvoiceResponse::class); - - return $this->execute($_reqBuilder, $_resHandler); - } } diff --git a/src/Controllers/OrdersController.php b/src/Controllers/OrdersController.php index f9617fc..71c36cc 100644 --- a/src/Controllers/OrdersController.php +++ b/src/Controllers/OrdersController.php @@ -29,23 +29,44 @@ class OrdersController extends BaseController { /** - * @param string $orderId Order Id - * @param string|null $idempotencyKey + * Gets all orders * - * @return GetOrderResponse Response from the API call + * @param int|null $page Page number + * @param int|null $size Page size + * @param string|null $code Filter for order's code + * @param string|null $status Filter for order's status + * @param \DateTime|null $createdSince Filter for order's creation date start range + * @param \DateTime|null $createdUntil Filter for order's creation date end range + * @param string|null $customerId Filter for order's customer id + * + * @return ListOrderResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function deleteAllOrderItems(string $orderId, ?string $idempotencyKey = null): GetOrderResponse - { - $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/orders/{orderId}/items') + public function getOrders( + ?int $page = null, + ?int $size = null, + ?string $code = null, + ?string $status = null, + ?\DateTime $createdSince = null, + ?\DateTime $createdUntil = null, + ?string $customerId = null + ): ListOrderResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/orders') ->auth('httpBasic') ->parameters( - TemplateParam::init('orderId', $orderId), - HeaderParam::init('idempotency-key', $idempotencyKey) + QueryParam::init('page', $page), + QueryParam::init('size', $size), + QueryParam::init('code', $code), + QueryParam::init('status', $status), + QueryParam::init('created_since', $createdSince) + ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), + QueryParam::init('created_until', $createdUntil) + ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), + QueryParam::init('customer_id', $customerId) ); - $_resHandler = $this->responseHandler()->type(GetOrderResponse::class); + $_resHandler = $this->responseHandler()->type(ListOrderResponse::class); return $this->execute($_reqBuilder, $_resHandler); } @@ -53,16 +74,27 @@ public function deleteAllOrderItems(string $orderId, ?string $idempotencyKey = n /** * @param string $orderId Order Id * @param string $itemId Item Id + * @param UpdateOrderItemRequest $request Item Model + * @param string|null $idempotencyKey * * @return GetOrderItemResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getOrderItem(string $orderId, string $itemId): GetOrderItemResponse - { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/orders/{orderId}/items/{itemId}') + public function updateOrderItem( + string $orderId, + string $itemId, + UpdateOrderItemRequest $request, + ?string $idempotencyKey = null + ): GetOrderItemResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/orders/{orderId}/items/{itemId}') ->auth('httpBasic') - ->parameters(TemplateParam::init('orderId', $orderId), TemplateParam::init('itemId', $itemId)); + ->parameters( + TemplateParam::init('orderId', $orderId), + TemplateParam::init('itemId', $itemId), + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) + ); $_resHandler = $this->responseHandler()->type(GetOrderItemResponse::class); @@ -70,26 +102,19 @@ public function getOrderItem(string $orderId, string $itemId): GetOrderItemRespo } /** - * Updates the metadata from an order - * - * @param string $orderId The order id - * @param UpdateMetadataRequest $request Request for updating the order metadata + * @param string $orderId Order Id * @param string|null $idempotencyKey * * @return GetOrderResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateOrderMetadata( - string $orderId, - UpdateMetadataRequest $request, - ?string $idempotencyKey = null - ): GetOrderResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/Orders/{order_id}/metadata') + public function deleteAllOrderItems(string $orderId, ?string $idempotencyKey = null): GetOrderResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/orders/{orderId}/items') ->auth('httpBasic') ->parameters( - TemplateParam::init('order_id', $orderId), - BodyParam::init($request), + TemplateParam::init('orderId', $orderId), HeaderParam::init('idempotency-key', $idempotencyKey) ); @@ -126,19 +151,26 @@ public function deleteOrderItem( } /** - * Gets an order - * - * @param string $orderId Order id + * @param string $id Order Id + * @param UpdateOrderStatusRequest $request Update Order Model + * @param string|null $idempotencyKey * * @return GetOrderResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getOrder(string $orderId): GetOrderResponse - { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/orders/{order_id}') + public function closeOrder( + string $id, + UpdateOrderStatusRequest $request, + ?string $idempotencyKey = null + ): GetOrderResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/orders/{id}/closed') ->auth('httpBasic') - ->parameters(TemplateParam::init('order_id', $orderId)); + ->parameters( + TemplateParam::init('id', $id), + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) + ); $_resHandler = $this->responseHandler()->type(GetOrderResponse::class); @@ -146,69 +178,44 @@ public function getOrder(string $orderId): GetOrderResponse } /** - * Gets all orders + * Creates a new Order * - * @param int|null $page Page number - * @param int|null $size Page size - * @param string|null $code Filter for order's code - * @param string|null $status Filter for order's status - * @param \DateTime|null $createdSince Filter for order's creation date start range - * @param \DateTime|null $createdUntil Filter for order's creation date end range - * @param string|null $customerId Filter for order's customer id + * @param CreateOrderRequest $body Request for creating an order + * @param string|null $idempotencyKey * - * @return ListOrderResponse Response from the API call + * @return GetOrderResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getOrders( - ?int $page = null, - ?int $size = null, - ?string $code = null, - ?string $status = null, - ?\DateTime $createdSince = null, - ?\DateTime $createdUntil = null, - ?string $customerId = null - ): ListOrderResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/orders') + public function createOrder(CreateOrderRequest $body, ?string $idempotencyKey = null): GetOrderResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/orders') ->auth('httpBasic') - ->parameters( - QueryParam::init('page', $page), - QueryParam::init('size', $size), - QueryParam::init('code', $code), - QueryParam::init('status', $status), - QueryParam::init('created_since', $createdSince) - ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), - QueryParam::init('created_until', $createdUntil) - ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), - QueryParam::init('customer_id', $customerId) - ); + ->parameters(BodyParam::init($body), HeaderParam::init('idempotency-key', $idempotencyKey)); - $_resHandler = $this->responseHandler()->type(ListOrderResponse::class); + $_resHandler = $this->responseHandler()->type(GetOrderResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** * @param string $orderId Order Id - * @param string $itemId Item Id - * @param UpdateOrderItemRequest $request Item Model + * @param CreateOrderItemRequest $request Order Item Model * @param string|null $idempotencyKey * * @return GetOrderItemResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateOrderItem( + public function createOrderItem( string $orderId, - string $itemId, - UpdateOrderItemRequest $request, + CreateOrderItemRequest $request, ?string $idempotencyKey = null ): GetOrderItemResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/orders/{orderId}/items/{itemId}') + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/orders/{orderId}/items') ->auth('httpBasic') ->parameters( TemplateParam::init('orderId', $orderId), - TemplateParam::init('itemId', $itemId), BodyParam::init($request), HeaderParam::init('idempotency-key', $idempotencyKey) ); @@ -219,47 +226,47 @@ public function updateOrderItem( } /** - * @param string $id Order Id - * @param UpdateOrderStatusRequest $request Update Order Model - * @param string|null $idempotencyKey + * @param string $orderId Order Id + * @param string $itemId Item Id * - * @return GetOrderResponse Response from the API call + * @return GetOrderItemResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function closeOrder( - string $id, - UpdateOrderStatusRequest $request, - ?string $idempotencyKey = null - ): GetOrderResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/orders/{id}/closed') + public function getOrderItem(string $orderId, string $itemId): GetOrderItemResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/orders/{orderId}/items/{itemId}') ->auth('httpBasic') - ->parameters( - TemplateParam::init('id', $id), - BodyParam::init($request), - HeaderParam::init('idempotency-key', $idempotencyKey) - ); + ->parameters(TemplateParam::init('orderId', $orderId), TemplateParam::init('itemId', $itemId)); - $_resHandler = $this->responseHandler()->type(GetOrderResponse::class); + $_resHandler = $this->responseHandler()->type(GetOrderItemResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Creates a new Order + * Updates the metadata from an order * - * @param CreateOrderRequest $body Request for creating an order + * @param string $orderId The order id + * @param UpdateMetadataRequest $request Request for updating the order metadata * @param string|null $idempotencyKey * * @return GetOrderResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function createOrder(CreateOrderRequest $body, ?string $idempotencyKey = null): GetOrderResponse - { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/orders') + public function updateOrderMetadata( + string $orderId, + UpdateMetadataRequest $request, + ?string $idempotencyKey = null + ): GetOrderResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/Orders/{order_id}/metadata') ->auth('httpBasic') - ->parameters(BodyParam::init($body), HeaderParam::init('idempotency-key', $idempotencyKey)); + ->parameters( + TemplateParam::init('order_id', $orderId), + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) + ); $_resHandler = $this->responseHandler()->type(GetOrderResponse::class); @@ -267,28 +274,21 @@ public function createOrder(CreateOrderRequest $body, ?string $idempotencyKey = } /** - * @param string $orderId Order Id - * @param CreateOrderItemRequest $request Order Item Model - * @param string|null $idempotencyKey + * Gets an order * - * @return GetOrderItemResponse Response from the API call + * @param string $orderId Order id + * + * @return GetOrderResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function createOrderItem( - string $orderId, - CreateOrderItemRequest $request, - ?string $idempotencyKey = null - ): GetOrderItemResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/orders/{orderId}/items') + public function getOrder(string $orderId): GetOrderResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/orders/{order_id}') ->auth('httpBasic') - ->parameters( - TemplateParam::init('orderId', $orderId), - BodyParam::init($request), - HeaderParam::init('idempotency-key', $idempotencyKey) - ); + ->parameters(TemplateParam::init('order_id', $orderId)); - $_resHandler = $this->responseHandler()->type(GetOrderItemResponse::class); + $_resHandler = $this->responseHandler()->type(GetOrderResponse::class); return $this->execute($_reqBuilder, $_resHandler); } diff --git a/src/Controllers/PlansController.php b/src/Controllers/PlansController.php index 0b20bbb..a834244 100644 --- a/src/Controllers/PlansController.php +++ b/src/Controllers/PlansController.php @@ -49,30 +49,25 @@ public function getPlan(string $planId): GetPlanResponse } /** - * Removes an item from a plan + * Deletes a plan * * @param string $planId Plan id - * @param string $planItemId Plan item id * @param string|null $idempotencyKey * - * @return GetPlanItemResponse Response from the API call + * @return GetPlanResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function deletePlanItem( - string $planId, - string $planItemId, - ?string $idempotencyKey = null - ): GetPlanItemResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/plans/{plan_id}/items/{plan_item_id}') + public function deletePlan(string $planId, ?string $idempotencyKey = null): GetPlanResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/plans/{plan_id}') ->auth('httpBasic') ->parameters( TemplateParam::init('plan_id', $planId), - TemplateParam::init('plan_item_id', $planItemId), HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetPlanItemResponse::class); + $_resHandler = $this->responseHandler()->type(GetPlanResponse::class); return $this->execute($_reqBuilder, $_resHandler); } @@ -107,43 +102,54 @@ public function updatePlanMetadata( } /** - * Creates a new plan + * Updates a plan item * - * @param CreatePlanRequest $body Request for creating a plan + * @param string $planId Plan id + * @param string $planItemId Plan item id + * @param UpdatePlanItemRequest $body Request for updating the plan item * @param string|null $idempotencyKey * - * @return GetPlanResponse Response from the API call + * @return GetPlanItemResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function createPlan(CreatePlanRequest $body, ?string $idempotencyKey = null): GetPlanResponse - { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/plans') + public function updatePlanItem( + string $planId, + string $planItemId, + UpdatePlanItemRequest $body, + ?string $idempotencyKey = null + ): GetPlanItemResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/plans/{plan_id}/items/{plan_item_id}') ->auth('httpBasic') - ->parameters(BodyParam::init($body), HeaderParam::init('idempotency-key', $idempotencyKey)); + ->parameters( + TemplateParam::init('plan_id', $planId), + TemplateParam::init('plan_item_id', $planItemId), + BodyParam::init($body), + HeaderParam::init('idempotency-key', $idempotencyKey) + ); - $_resHandler = $this->responseHandler()->type(GetPlanResponse::class); + $_resHandler = $this->responseHandler()->type(GetPlanItemResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Updates a plan + * Adds a new item to a plan * * @param string $planId Plan id - * @param UpdatePlanRequest $request Request for updating a plan + * @param CreatePlanItemRequest $request Request for creating a plan item * @param string|null $idempotencyKey * - * @return GetPlanResponse Response from the API call + * @return GetPlanItemResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updatePlan( + public function createPlanItem( string $planId, - UpdatePlanRequest $request, + CreatePlanItemRequest $request, ?string $idempotencyKey = null - ): GetPlanResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/plans/{plan_id}') + ): GetPlanItemResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/plans/{plan_id}/items') ->auth('httpBasic') ->parameters( TemplateParam::init('plan_id', $planId), @@ -151,31 +157,78 @@ public function updatePlan( HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetPlanResponse::class); + $_resHandler = $this->responseHandler()->type(GetPlanItemResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Deletes a plan + * Gets a plan item * * @param string $planId Plan id + * @param string $planItemId Plan item id + * + * @return GetPlanItemResponse Response from the API call + * + * @throws ApiException Thrown if API call fails + */ + public function getPlanItem(string $planId, string $planItemId): GetPlanItemResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/plans/{plan_id}/items/{plan_item_id}') + ->auth('httpBasic') + ->parameters(TemplateParam::init('plan_id', $planId), TemplateParam::init('plan_item_id', $planItemId)); + + $_resHandler = $this->responseHandler()->type(GetPlanItemResponse::class); + + return $this->execute($_reqBuilder, $_resHandler); + } + + /** + * Creates a new plan + * + * @param CreatePlanRequest $body Request for creating a plan * @param string|null $idempotencyKey * * @return GetPlanResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function deletePlan(string $planId, ?string $idempotencyKey = null): GetPlanResponse + public function createPlan(CreatePlanRequest $body, ?string $idempotencyKey = null): GetPlanResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/plans/{plan_id}') + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/plans') + ->auth('httpBasic') + ->parameters(BodyParam::init($body), HeaderParam::init('idempotency-key', $idempotencyKey)); + + $_resHandler = $this->responseHandler()->type(GetPlanResponse::class); + + return $this->execute($_reqBuilder, $_resHandler); + } + + /** + * Removes an item from a plan + * + * @param string $planId Plan id + * @param string $planItemId Plan item id + * @param string|null $idempotencyKey + * + * @return GetPlanItemResponse Response from the API call + * + * @throws ApiException Thrown if API call fails + */ + public function deletePlanItem( + string $planId, + string $planItemId, + ?string $idempotencyKey = null + ): GetPlanItemResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/plans/{plan_id}/items/{plan_item_id}') ->auth('httpBasic') ->parameters( TemplateParam::init('plan_id', $planId), + TemplateParam::init('plan_item_id', $planItemId), HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetPlanResponse::class); + $_resHandler = $this->responseHandler()->type(GetPlanItemResponse::class); return $this->execute($_reqBuilder, $_resHandler); } @@ -224,54 +277,22 @@ public function getPlans( } /** - * Updates a plan item - * - * @param string $planId Plan id - * @param string $planItemId Plan item id - * @param UpdatePlanItemRequest $body Request for updating the plan item - * @param string|null $idempotencyKey - * - * @return GetPlanItemResponse Response from the API call - * - * @throws ApiException Thrown if API call fails - */ - public function updatePlanItem( - string $planId, - string $planItemId, - UpdatePlanItemRequest $body, - ?string $idempotencyKey = null - ): GetPlanItemResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/plans/{plan_id}/items/{plan_item_id}') - ->auth('httpBasic') - ->parameters( - TemplateParam::init('plan_id', $planId), - TemplateParam::init('plan_item_id', $planItemId), - BodyParam::init($body), - HeaderParam::init('idempotency-key', $idempotencyKey) - ); - - $_resHandler = $this->responseHandler()->type(GetPlanItemResponse::class); - - return $this->execute($_reqBuilder, $_resHandler); - } - - /** - * Adds a new item to a plan + * Updates a plan * * @param string $planId Plan id - * @param CreatePlanItemRequest $request Request for creating a plan item + * @param UpdatePlanRequest $request Request for updating a plan * @param string|null $idempotencyKey * - * @return GetPlanItemResponse Response from the API call + * @return GetPlanResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function createPlanItem( + public function updatePlan( string $planId, - CreatePlanItemRequest $request, + UpdatePlanRequest $request, ?string $idempotencyKey = null - ): GetPlanItemResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/plans/{plan_id}/items') + ): GetPlanResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/plans/{plan_id}') ->auth('httpBasic') ->parameters( TemplateParam::init('plan_id', $planId), @@ -279,28 +300,7 @@ public function createPlanItem( HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetPlanItemResponse::class); - - return $this->execute($_reqBuilder, $_resHandler); - } - - /** - * Gets a plan item - * - * @param string $planId Plan id - * @param string $planItemId Plan item id - * - * @return GetPlanItemResponse Response from the API call - * - * @throws ApiException Thrown if API call fails - */ - public function getPlanItem(string $planId, string $planItemId): GetPlanItemResponse - { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/plans/{plan_id}/items/{plan_item_id}') - ->auth('httpBasic') - ->parameters(TemplateParam::init('plan_id', $planId), TemplateParam::init('plan_item_id', $planItemId)); - - $_resHandler = $this->responseHandler()->type(GetPlanItemResponse::class); + $_resHandler = $this->responseHandler()->type(GetPlanResponse::class); return $this->execute($_reqBuilder, $_resHandler); } diff --git a/src/Controllers/RecipientsController.php b/src/Controllers/RecipientsController.php index ed6442f..cb31c36 100644 --- a/src/Controllers/RecipientsController.php +++ b/src/Controllers/RecipientsController.php @@ -17,6 +17,7 @@ use CoreInterfaces\Core\Request\RequestMethod; use PagarmeApiSDKLib\Exceptions\ApiException; use PagarmeApiSDKLib\Models\CreateAnticipationRequest; +use PagarmeApiSDKLib\Models\CreateKYCLinkResponse; use PagarmeApiSDKLib\Models\CreateRecipientRequest; use PagarmeApiSDKLib\Models\CreateTransferRequest; use PagarmeApiSDKLib\Models\CreateWithdrawRequest; @@ -69,87 +70,106 @@ public function updateRecipient( } /** - * @param string $recipientId - * @param string $withdrawalId + * Creates an anticipation * - * @return GetWithdrawResponse Response from the API call + * @param string $recipientId Recipient id + * @param CreateAnticipationRequest $request Anticipation data + * @param string|null $idempotencyKey + * + * @return GetAnticipationResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getWithdrawById(string $recipientId, string $withdrawalId): GetWithdrawResponse - { - $_reqBuilder = $this->requestBuilder( - RequestMethod::GET, - '/recipients/{recipient_id}/withdrawals/{withdrawal_id}' - ) + public function createAnticipation( + string $recipientId, + CreateAnticipationRequest $request, + ?string $idempotencyKey = null + ): GetAnticipationResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/recipients/{recipient_id}/anticipations') ->auth('httpBasic') ->parameters( TemplateParam::init('recipient_id', $recipientId), - TemplateParam::init('withdrawal_id', $withdrawalId) + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetWithdrawResponse::class); + $_resHandler = $this->responseHandler()->type(GetAnticipationResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Retrieves recipient information + * Gets the anticipation limits for a recipient * - * @param string $recipientId Recipiend id + * @param string $recipientId Recipient id + * @param string $timeframe Timeframe + * @param \DateTime $paymentDate Anticipation payment date * - * @return GetRecipientResponse Response from the API call + * @return GetAnticipationLimitResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getRecipient(string $recipientId): GetRecipientResponse - { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/{recipient_id}') + public function getAnticipationLimits( + string $recipientId, + string $timeframe, + \DateTime $paymentDate + ): GetAnticipationLimitResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/{recipient_id}/anticipation_limits') ->auth('httpBasic') - ->parameters(TemplateParam::init('recipient_id', $recipientId)); + ->parameters( + TemplateParam::init('recipient_id', $recipientId), + QueryParam::init('timeframe', $timeframe), + QueryParam::init('payment_date', $paymentDate) + ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']) + ); - $_resHandler = $this->responseHandler()->type(GetRecipientResponse::class); + $_resHandler = $this->responseHandler()->type(GetAnticipationLimitResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Get balance information for a recipient + * Retrieves paginated recipients information * - * @param string $recipientId Recipient id + * @param int|null $page Page number + * @param int|null $size Page size * - * @return GetBalanceResponse Response from the API call + * @return ListRecipientResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getBalance(string $recipientId): GetBalanceResponse + public function getRecipients(?int $page = null, ?int $size = null): ListRecipientResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/{recipient_id}/balance') + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients') ->auth('httpBasic') - ->parameters(TemplateParam::init('recipient_id', $recipientId)); + ->parameters(QueryParam::init('page', $page), QueryParam::init('size', $size)); - $_resHandler = $this->responseHandler()->type(GetBalanceResponse::class); + $_resHandler = $this->responseHandler()->type(ListRecipientResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Retrieves paginated recipients information - * - * @param int|null $page Page number - * @param int|null $size Page size + * @param string $recipientId + * @param string $withdrawalId * - * @return ListRecipientResponse Response from the API call + * @return GetWithdrawResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getRecipients(?int $page = null, ?int $size = null): ListRecipientResponse + public function getWithdrawById(string $recipientId, string $withdrawalId): GetWithdrawResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients') + $_reqBuilder = $this->requestBuilder( + RequestMethod::GET, + '/recipients/{recipient_id}/withdrawals/{withdrawal_id}' + ) ->auth('httpBasic') - ->parameters(QueryParam::init('page', $page), QueryParam::init('size', $size)); + ->parameters( + TemplateParam::init('recipient_id', $recipientId), + TemplateParam::init('withdrawal_id', $withdrawalId) + ); - $_resHandler = $this->responseHandler()->type(ListRecipientResponse::class); + $_resHandler = $this->responseHandler()->type(GetWithdrawResponse::class); return $this->execute($_reqBuilder, $_resHandler); } @@ -186,6 +206,35 @@ public function updateRecipientDefaultBankAccount( return $this->execute($_reqBuilder, $_resHandler); } + /** + * Updates recipient metadata + * + * @param string $recipientId Recipient id + * @param UpdateMetadataRequest $request Metadata + * @param string|null $idempotencyKey + * + * @return GetRecipientResponse Response from the API call + * + * @throws ApiException Thrown if API call fails + */ + public function updateRecipientMetadata( + string $recipientId, + UpdateMetadataRequest $request, + ?string $idempotencyKey = null + ): GetRecipientResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/recipients/{recipient_id}/metadata') + ->auth('httpBasic') + ->parameters( + TemplateParam::init('recipient_id', $recipientId), + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) + ); + + $_resHandler = $this->responseHandler()->type(GetRecipientResponse::class); + + return $this->execute($_reqBuilder, $_resHandler); + } + /** * Gets a paginated list of transfers for the recipient * @@ -272,6 +321,38 @@ public function createWithdraw(string $recipientId, CreateWithdrawRequest $reque return $this->execute($_reqBuilder, $_resHandler); } + /** + * Updates recipient metadata + * + * @param string $recipientId Recipient id + * @param UpdateAutomaticAnticipationSettingsRequest $request Metadata + * @param string|null $idempotencyKey + * + * @return GetRecipientResponse Response from the API call + * + * @throws ApiException Thrown if API call fails + */ + public function updateAutomaticAnticipationSettings( + string $recipientId, + UpdateAutomaticAnticipationSettingsRequest $request, + ?string $idempotencyKey = null + ): GetRecipientResponse { + $_reqBuilder = $this->requestBuilder( + RequestMethod::PATCH, + '/recipients/{recipient_id}/automatic-anticipation-settings' + ) + ->auth('httpBasic') + ->parameters( + TemplateParam::init('recipient_id', $recipientId), + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) + ); + + $_resHandler = $this->responseHandler()->type(GetRecipientResponse::class); + + return $this->execute($_reqBuilder, $_resHandler); + } + /** * Gets an anticipation * @@ -326,20 +407,71 @@ public function updateRecipientTransferSettings( return $this->execute($_reqBuilder, $_resHandler); } + /** + * Retrieves a paginated list of anticipations from a recipient + * + * @param string $recipientId Recipient id + * @param int|null $page Page number + * @param int|null $size Page size + * @param string|null $status Filter for anticipation status + * @param string|null $timeframe Filter for anticipation timeframe + * @param \DateTime|null $paymentDateSince Filter for start range for anticipation payment date + * @param \DateTime|null $paymentDateUntil Filter for end range for anticipation payment date + * @param \DateTime|null $createdSince Filter for start range for anticipation creation date + * @param \DateTime|null $createdUntil Filter for end range for anticipation creation date + * + * @return ListAnticipationResponse Response from the API call + * + * @throws ApiException Thrown if API call fails + */ + public function getAnticipations( + string $recipientId, + ?int $page = null, + ?int $size = null, + ?string $status = null, + ?string $timeframe = null, + ?\DateTime $paymentDateSince = null, + ?\DateTime $paymentDateUntil = null, + ?\DateTime $createdSince = null, + ?\DateTime $createdUntil = null + ): ListAnticipationResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/{recipient_id}/anticipations') + ->auth('httpBasic') + ->parameters( + TemplateParam::init('recipient_id', $recipientId), + QueryParam::init('page', $page), + QueryParam::init('size', $size), + QueryParam::init('status', $status), + QueryParam::init('timeframe', $timeframe), + QueryParam::init('payment_date_since', $paymentDateSince) + ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), + QueryParam::init('payment_date_until', $paymentDateUntil) + ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), + QueryParam::init('created_since', $createdSince) + ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), + QueryParam::init('created_until', $createdUntil) + ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']) + ); + + $_resHandler = $this->responseHandler()->type(ListAnticipationResponse::class); + + return $this->execute($_reqBuilder, $_resHandler); + } + /** * Retrieves recipient information * - * @param string $code Recipient code + * @param string $recipientId Recipiend id * * @return GetRecipientResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getRecipientByCode(string $code): GetRecipientResponse + public function getRecipient(string $recipientId): GetRecipientResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/{code}') + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/{recipient_id}') ->auth('httpBasic') - ->parameters(TemplateParam::init('code', $code)); + ->parameters(TemplateParam::init('recipient_id', $recipientId)); $_resHandler = $this->responseHandler()->type(GetRecipientResponse::class); @@ -347,33 +479,61 @@ public function getRecipientByCode(string $code): GetRecipientResponse } /** - * Updates recipient metadata + * Get balance information for a recipient * * @param string $recipientId Recipient id - * @param UpdateAutomaticAnticipationSettingsRequest $request Metadata - * @param string|null $idempotencyKey * - * @return GetRecipientResponse Response from the API call + * @return GetBalanceResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateAutomaticAnticipationSettings( + public function getBalance(string $recipientId): GetBalanceResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/{recipient_id}/balance') + ->auth('httpBasic') + ->parameters(TemplateParam::init('recipient_id', $recipientId)); + + $_resHandler = $this->responseHandler()->type(GetBalanceResponse::class); + + return $this->execute($_reqBuilder, $_resHandler); + } + + /** + * Gets a paginated list of transfers for the recipient + * + * @param string $recipientId + * @param int|null $page + * @param int|null $size + * @param string|null $status + * @param \DateTime|null $createdSince + * @param \DateTime|null $createdUntil + * + * @return ListWithdrawals Response from the API call + * + * @throws ApiException Thrown if API call fails + */ + public function getWithdrawals( string $recipientId, - UpdateAutomaticAnticipationSettingsRequest $request, - ?string $idempotencyKey = null - ): GetRecipientResponse { - $_reqBuilder = $this->requestBuilder( - RequestMethod::PATCH, - '/recipients/{recipient_id}/automatic-anticipation-settings' - ) + ?int $page = null, + ?int $size = null, + ?string $status = null, + ?\DateTime $createdSince = null, + ?\DateTime $createdUntil = null + ): ListWithdrawals { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/{recipient_id}/withdrawals') ->auth('httpBasic') ->parameters( TemplateParam::init('recipient_id', $recipientId), - BodyParam::init($request), - HeaderParam::init('idempotency-key', $idempotencyKey) + QueryParam::init('page', $page), + QueryParam::init('size', $size), + QueryParam::init('status', $status), + QueryParam::init('created_since', $createdSince) + ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), + QueryParam::init('created_until', $createdUntil) + ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']) ); - $_resHandler = $this->responseHandler()->type(GetRecipientResponse::class); + $_resHandler = $this->responseHandler()->type(ListWithdrawals::class); return $this->execute($_reqBuilder, $_resHandler); } @@ -431,101 +591,19 @@ public function createRecipient( } /** - * @return GetRecipientResponse Response from the API call - * - * @throws ApiException Thrown if API call fails - */ - public function getDefaultRecipient(): GetRecipientResponse - { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/default')->auth('httpBasic'); - - $_resHandler = $this->responseHandler()->type(GetRecipientResponse::class); - - return $this->execute($_reqBuilder, $_resHandler); - } - - /** - * Creates an anticipation - * - * @param string $recipientId Recipient id - * @param CreateAnticipationRequest $request Anticipation data - * @param string|null $idempotencyKey - * - * @return GetAnticipationResponse Response from the API call - * - * @throws ApiException Thrown if API call fails - */ - public function createAnticipation( - string $recipientId, - CreateAnticipationRequest $request, - ?string $idempotencyKey = null - ): GetAnticipationResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/recipients/{recipient_id}/anticipations') - ->auth('httpBasic') - ->parameters( - TemplateParam::init('recipient_id', $recipientId), - BodyParam::init($request), - HeaderParam::init('idempotency-key', $idempotencyKey) - ); - - $_resHandler = $this->responseHandler()->type(GetAnticipationResponse::class); - - return $this->execute($_reqBuilder, $_resHandler); - } - - /** - * Gets the anticipation limits for a recipient - * - * @param string $recipientId Recipient id - * @param string $timeframe Timeframe - * @param \DateTime $paymentDate Anticipation payment date - * - * @return GetAnticipationLimitResponse Response from the API call - * - * @throws ApiException Thrown if API call fails - */ - public function getAnticipationLimits( - string $recipientId, - string $timeframe, - \DateTime $paymentDate - ): GetAnticipationLimitResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/{recipient_id}/anticipation_limits') - ->auth('httpBasic') - ->parameters( - TemplateParam::init('recipient_id', $recipientId), - QueryParam::init('timeframe', $timeframe), - QueryParam::init('payment_date', $paymentDate) - ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']) - ); - - $_resHandler = $this->responseHandler()->type(GetAnticipationLimitResponse::class); - - return $this->execute($_reqBuilder, $_resHandler); - } - - /** - * Updates recipient metadata + * Retrieves recipient information * - * @param string $recipientId Recipient id - * @param UpdateMetadataRequest $request Metadata - * @param string|null $idempotencyKey + * @param string $code Recipient code * * @return GetRecipientResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateRecipientMetadata( - string $recipientId, - UpdateMetadataRequest $request, - ?string $idempotencyKey = null - ): GetRecipientResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/recipients/{recipient_id}/metadata') + public function getRecipientByCode(string $code): GetRecipientResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/{code}') ->auth('httpBasic') - ->parameters( - TemplateParam::init('recipient_id', $recipientId), - BodyParam::init($request), - HeaderParam::init('idempotency-key', $idempotencyKey) - ); + ->parameters(TemplateParam::init('code', $code)); $_resHandler = $this->responseHandler()->type(GetRecipientResponse::class); @@ -533,92 +611,35 @@ public function updateRecipientMetadata( } /** - * Retrieves a paginated list of anticipations from a recipient - * - * @param string $recipientId Recipient id - * @param int|null $page Page number - * @param int|null $size Page size - * @param string|null $status Filter for anticipation status - * @param string|null $timeframe Filter for anticipation timeframe - * @param \DateTime|null $paymentDateSince Filter for start range for anticipation payment date - * @param \DateTime|null $paymentDateUntil Filter for end range for anticipation payment date - * @param \DateTime|null $createdSince Filter for start range for anticipation creation date - * @param \DateTime|null $createdUntil Filter for end range for anticipation creation date - * - * @return ListAnticipationResponse Response from the API call + * @return GetRecipientResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getAnticipations( - string $recipientId, - ?int $page = null, - ?int $size = null, - ?string $status = null, - ?string $timeframe = null, - ?\DateTime $paymentDateSince = null, - ?\DateTime $paymentDateUntil = null, - ?\DateTime $createdSince = null, - ?\DateTime $createdUntil = null - ): ListAnticipationResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/{recipient_id}/anticipations') - ->auth('httpBasic') - ->parameters( - TemplateParam::init('recipient_id', $recipientId), - QueryParam::init('page', $page), - QueryParam::init('size', $size), - QueryParam::init('status', $status), - QueryParam::init('timeframe', $timeframe), - QueryParam::init('payment_date_since', $paymentDateSince) - ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), - QueryParam::init('payment_date_until', $paymentDateUntil) - ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), - QueryParam::init('created_since', $createdSince) - ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), - QueryParam::init('created_until', $createdUntil) - ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']) - ); + public function getDefaultRecipient(): GetRecipientResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/default')->auth('httpBasic'); - $_resHandler = $this->responseHandler()->type(ListAnticipationResponse::class); + $_resHandler = $this->responseHandler()->type(GetRecipientResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Gets a paginated list of transfers for the recipient + * Create a KYC link * * @param string $recipientId - * @param int|null $page - * @param int|null $size - * @param string|null $status - * @param \DateTime|null $createdSince - * @param \DateTime|null $createdUntil * - * @return ListWithdrawals Response from the API call + * @return CreateKYCLinkResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getWithdrawals( - string $recipientId, - ?int $page = null, - ?int $size = null, - ?string $status = null, - ?\DateTime $createdSince = null, - ?\DateTime $createdUntil = null - ): ListWithdrawals { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/{recipient_id}/withdrawals') + public function createKYCLink(string $recipientId): CreateKYCLinkResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/recipients/{recipient_id}/kyc_link') ->auth('httpBasic') - ->parameters( - TemplateParam::init('recipient_id', $recipientId), - QueryParam::init('page', $page), - QueryParam::init('size', $size), - QueryParam::init('status', $status), - QueryParam::init('created_since', $createdSince) - ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), - QueryParam::init('created_until', $createdUntil) - ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']) - ); + ->parameters(TemplateParam::init('recipient_id', $recipientId)); - $_resHandler = $this->responseHandler()->type(ListWithdrawals::class); + $_resHandler = $this->responseHandler()->type(CreateKYCLinkResponse::class); return $this->execute($_reqBuilder, $_resHandler); } diff --git a/src/Controllers/SubscriptionsController.php b/src/Controllers/SubscriptionsController.php index a7cf2dc..e1df1b4 100644 --- a/src/Controllers/SubscriptionsController.php +++ b/src/Controllers/SubscriptionsController.php @@ -52,51 +52,44 @@ class SubscriptionsController extends BaseController { /** - * Updates the credit card from a subscription - * - * @param string $subscriptionId Subscription id - * @param UpdateSubscriptionCardRequest $request Request for updating a card + * @param string $subscriptionId * @param string|null $idempotencyKey * - * @return GetSubscriptionResponse Response from the API call + * @return GetPeriodResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateSubscriptionCard( - string $subscriptionId, - UpdateSubscriptionCardRequest $request, - ?string $idempotencyKey = null - ): GetSubscriptionResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/subscriptions/{subscription_id}/card') + public function renewSubscription(string $subscriptionId, ?string $idempotencyKey = null): GetPeriodResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/subscriptions/{subscription_id}/cycles') ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), - BodyParam::init($request), HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); + $_resHandler = $this->responseHandler()->type(GetPeriodResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Creates a discount + * Updates the credit card from a subscription * * @param string $subscriptionId Subscription id - * @param CreateDiscountRequest $request Request for creating a discount + * @param UpdateSubscriptionCardRequest $request Request for updating a card * @param string|null $idempotencyKey * - * @return GetDiscountResponse Response from the API call + * @return GetSubscriptionResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function createDiscount( + public function updateSubscriptionCard( string $subscriptionId, - CreateDiscountRequest $request, + UpdateSubscriptionCardRequest $request, ?string $idempotencyKey = null - ): GetDiscountResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/subscriptions/{subscription_id}/discounts') + ): GetSubscriptionResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/subscriptions/{subscription_id}/card') ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), @@ -104,59 +97,63 @@ public function createDiscount( HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetDiscountResponse::class); + $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Updates the billing date from a subscription + * Deletes a usage * * @param string $subscriptionId The subscription id - * @param UpdateSubscriptionBillingDateRequest $request Request for updating the subscription - * billing date + * @param string $itemId The subscription item id + * @param string $usageId The usage id * @param string|null $idempotencyKey * - * @return GetSubscriptionResponse Response from the API call + * @return GetUsageResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateSubscriptionBillingDate( + public function deleteUsage( string $subscriptionId, - UpdateSubscriptionBillingDateRequest $request, + string $itemId, + string $usageId, ?string $idempotencyKey = null - ): GetSubscriptionResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/subscriptions/{subscription_id}/billing-date') + ): GetUsageResponse { + $_reqBuilder = $this->requestBuilder( + RequestMethod::DELETE, + '/subscriptions/{subscription_id}/items/{item_id}/usages/{usage_id}' + ) ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), - BodyParam::init($request), + TemplateParam::init('item_id', $itemId), + TemplateParam::init('usage_id', $usageId), HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); + $_resHandler = $this->responseHandler()->type(GetUsageResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Updates the start at date from a subscription + * Creates a discount * - * @param string $subscriptionId The subscription id - * @param UpdateSubscriptionStartAtRequest $request Request for updating the subscription start - * date + * @param string $subscriptionId Subscription id + * @param CreateDiscountRequest $request Request for creating a discount * @param string|null $idempotencyKey * - * @return GetSubscriptionResponse Response from the API call + * @return GetDiscountResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateSubscriptionStartAt( + public function createDiscount( string $subscriptionId, - UpdateSubscriptionStartAtRequest $request, + CreateDiscountRequest $request, ?string $idempotencyKey = null - ): GetSubscriptionResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/subscriptions/{subscription_id}/start-at') + ): GetDiscountResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/subscriptions/{subscription_id}/discounts') ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), @@ -164,97 +161,59 @@ public function updateSubscriptionStartAt( HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); + $_resHandler = $this->responseHandler()->type(GetDiscountResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Gets a subscription + * Create Usage * * @param string $subscriptionId Subscription id + * @param string $itemId Item id + * @param string|null $idempotencyKey * - * @return GetSubscriptionResponse Response from the API call - * - * @throws ApiException Thrown if API call fails - */ - public function getSubscription(string $subscriptionId): GetSubscriptionResponse - { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/subscriptions/{subscription_id}') - ->auth('httpBasic') - ->parameters(TemplateParam::init('subscription_id', $subscriptionId)); - - $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); - - return $this->execute($_reqBuilder, $_resHandler); - } - - /** - * Lists all usages from a subscription item - * - * @param string $subscriptionId The subscription id - * @param string $itemId The subscription item id - * @param int|null $page Page number - * @param int|null $size Page size - * @param string|null $code Identification code in the client system - * @param string|null $group Identification group in the client system - * @param \DateTime|null $usedSince - * @param \DateTime|null $usedUntil - * - * @return ListUsagesResponse Response from the API call + * @return GetUsageResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getUsages( + public function createAnUsage( string $subscriptionId, string $itemId, - ?int $page = null, - ?int $size = null, - ?string $code = null, - ?string $group = null, - ?\DateTime $usedSince = null, - ?\DateTime $usedUntil = null - ): ListUsagesResponse { + ?string $idempotencyKey = null + ): GetUsageResponse { $_reqBuilder = $this->requestBuilder( - RequestMethod::GET, + RequestMethod::POST, '/subscriptions/{subscription_id}/items/{item_id}/usages' ) ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), TemplateParam::init('item_id', $itemId), - QueryParam::init('page', $page), - QueryParam::init('size', $size), - QueryParam::init('code', $code), - QueryParam::init('group', $group), - QueryParam::init('used_since', $usedSince)->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), - QueryParam::init('used_until', $usedUntil)->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']) + HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(ListUsagesResponse::class); + $_resHandler = $this->responseHandler()->type(GetUsageResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * @param string $subscriptionId - * @param UpdateCurrentCycleEndDateRequest $request Request for updating the end date of the - * current signature cycle + * @param string $subscriptionId Subscription Id + * @param UpdateCurrentCycleStatusRequest $request Request for updating the end date of the + * subscription current status * @param string|null $idempotencyKey * - * @return GetSubscriptionResponse Response from the API call + * @return void Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateLatestPeriodEndAt( + public function updateCurrentCycleStatus( string $subscriptionId, - UpdateCurrentCycleEndDateRequest $request, + UpdateCurrentCycleStatusRequest $request, ?string $idempotencyKey = null - ): GetSubscriptionResponse { - $_reqBuilder = $this->requestBuilder( - RequestMethod::PATCH, - '/subscriptions/{subscription_id}/periods/latest/end-at' - ) + ): void { + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/subscriptions/{subscription_id}/cycle-status') ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), @@ -262,9 +221,7 @@ public function updateLatestPeriodEndAt( HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); - - return $this->execute($_reqBuilder, $_resHandler); + $this->execute($_reqBuilder); } /** @@ -300,55 +257,73 @@ public function deleteDiscount( } /** - * Updates the payment method from a subscription + * Get Subscription Items * - * @param string $subscriptionId Subscription id - * @param UpdateSubscriptionPaymentMethodRequest $request Request for updating the paymentmethod - * from a subscription - * @param string|null $idempotencyKey + * @param string $subscriptionId The subscription id + * @param int|null $page Page number + * @param int|null $size Page size + * @param string|null $name The item name + * @param string|null $code Identification code in the client system + * @param string|null $status The item statis + * @param string|null $description The item description + * @param string|null $createdSince Filter for item's creation date start range + * @param string|null $createdUntil Filter for item's creation date end range * - * @return GetSubscriptionResponse Response from the API call + * @return ListSubscriptionItemsResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateSubscriptionPaymentMethod( + public function getSubscriptionItems( string $subscriptionId, - UpdateSubscriptionPaymentMethodRequest $request, - ?string $idempotencyKey = null - ): GetSubscriptionResponse { - $_reqBuilder = $this->requestBuilder( - RequestMethod::PATCH, - '/subscriptions/{subscription_id}/payment-method' - ) + ?int $page = null, + ?int $size = null, + ?string $name = null, + ?string $code = null, + ?string $status = null, + ?string $description = null, + ?string $createdSince = null, + ?string $createdUntil = null + ): ListSubscriptionItemsResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/subscriptions/{subscription_id}/items') ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), - BodyParam::init($request), - HeaderParam::init('idempotency-key', $idempotencyKey) + QueryParam::init('page', $page), + QueryParam::init('size', $size), + QueryParam::init('name', $name), + QueryParam::init('code', $code), + QueryParam::init('status', $status), + QueryParam::init('description', $description), + QueryParam::init('created_since', $createdSince), + QueryParam::init('created_until', $createdUntil) ); - $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); + $_resHandler = $this->responseHandler()->type(ListSubscriptionItemsResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Cancels a subscription + * Updates the payment method from a subscription * * @param string $subscriptionId Subscription id - * @param CreateCancelSubscriptionRequest|null $request Request for cancelling a subscription + * @param UpdateSubscriptionPaymentMethodRequest $request Request for updating the paymentmethod + * from a subscription * @param string|null $idempotencyKey * * @return GetSubscriptionResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function cancelSubscription( + public function updateSubscriptionPaymentMethod( string $subscriptionId, - ?CreateCancelSubscriptionRequest $request = null, + UpdateSubscriptionPaymentMethodRequest $request, ?string $idempotencyKey = null ): GetSubscriptionResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/subscriptions/{subscription_id}') + $_reqBuilder = $this->requestBuilder( + RequestMethod::PATCH, + '/subscriptions/{subscription_id}/payment-method' + ) ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), @@ -362,80 +337,110 @@ public function cancelSubscription( } /** - * Creates a new subscription + * Get Subscription Item * - * @param CreateSubscriptionRequest $body Request for creating a subscription - * @param string|null $idempotencyKey + * @param string $subscriptionId Subscription Id + * @param string $itemId Item id * - * @return GetSubscriptionResponse Response from the API call + * @return GetSubscriptionItemResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function createSubscription( - CreateSubscriptionRequest $body, - ?string $idempotencyKey = null - ): GetSubscriptionResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/subscriptions') + public function getSubscriptionItem(string $subscriptionId, string $itemId): GetSubscriptionItemResponse + { + $_reqBuilder = $this->requestBuilder( + RequestMethod::GET, + '/subscriptions/{subscription_id}/items/{item_id}' + ) ->auth('httpBasic') - ->parameters(BodyParam::init($body), HeaderParam::init('idempotency-key', $idempotencyKey)); + ->parameters( + TemplateParam::init('subscription_id', $subscriptionId), + TemplateParam::init('item_id', $itemId) + ); - $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); + $_resHandler = $this->responseHandler()->type(GetSubscriptionItemResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * @param string $subscriptionId - * @param UpdateSubscriptionAffiliationIdRequest $request Request for updating a subscription - * affiliation id - * @param string|null $idempotencyKey - * - * @return GetSubscriptionResponse Response from the API call + * Gets all subscriptions * - * @throws ApiException Thrown if API call fails - */ - public function updateSubscriptionAffiliationId( - string $subscriptionId, - UpdateSubscriptionAffiliationIdRequest $request, - ?string $idempotencyKey = null - ): GetSubscriptionResponse { - $_reqBuilder = $this->requestBuilder( - RequestMethod::PATCH, - '/subscriptions/{subscription_id}/gateway-affiliation-id' - ) + * @param int|null $page Page number + * @param int|null $size Page size + * @param string|null $code Filter for subscription's code + * @param string|null $billingType Filter for subscription's billing type + * @param string|null $customerId Filter for subscription's customer id + * @param string|null $planId Filter for subscription's plan id + * @param string|null $cardId Filter for subscription's card id + * @param string|null $status Filter for subscription's status + * @param \DateTime|null $nextBillingSince Filter for subscription's next billing date start + * range + * @param \DateTime|null $nextBillingUntil Filter for subscription's next billing date end range + * @param \DateTime|null $createdSince Filter for subscription's creation date start range + * @param \DateTime|null $createdUntil Filter for subscriptions creation date end range + * + * @return ListSubscriptionsResponse Response from the API call + * + * @throws ApiException Thrown if API call fails + */ + public function getSubscriptions( + ?int $page = null, + ?int $size = null, + ?string $code = null, + ?string $billingType = null, + ?string $customerId = null, + ?string $planId = null, + ?string $cardId = null, + ?string $status = null, + ?\DateTime $nextBillingSince = null, + ?\DateTime $nextBillingUntil = null, + ?\DateTime $createdSince = null, + ?\DateTime $createdUntil = null + ): ListSubscriptionsResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/subscriptions') ->auth('httpBasic') ->parameters( - TemplateParam::init('subscription_id', $subscriptionId), - BodyParam::init($request), - HeaderParam::init('idempotency-key', $idempotencyKey) + QueryParam::init('page', $page), + QueryParam::init('size', $size), + QueryParam::init('code', $code), + QueryParam::init('billing_type', $billingType), + QueryParam::init('customer_id', $customerId), + QueryParam::init('plan_id', $planId), + QueryParam::init('card_id', $cardId), + QueryParam::init('status', $status), + QueryParam::init('next_billing_since', $nextBillingSince) + ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), + QueryParam::init('next_billing_until', $nextBillingUntil) + ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), + QueryParam::init('created_since', $createdSince) + ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), + QueryParam::init('created_until', $createdUntil) + ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']) ); - $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); + $_resHandler = $this->responseHandler()->type(ListSubscriptionsResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Atualização do valor mínimo da assinatura + * Cancels a subscription * - * @param string $subscriptionId Subscription Id - * @param UpdateSubscriptionMinimumPriceRequest $request Request da requisição com o valor - * mínimo que será configurado + * @param string $subscriptionId Subscription id + * @param CreateCancelSubscriptionRequest|null $request Request for cancelling a subscription * @param string|null $idempotencyKey * * @return GetSubscriptionResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateSubscriptionMiniumPrice( + public function cancelSubscription( string $subscriptionId, - UpdateSubscriptionMinimumPriceRequest $request, + ?CreateCancelSubscriptionRequest $request = null, ?string $idempotencyKey = null ): GetSubscriptionResponse { - $_reqBuilder = $this->requestBuilder( - RequestMethod::PATCH, - '/subscriptions/{subscription_id}/minimum_price' - ) + $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/subscriptions/{subscription_id}') ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), @@ -449,218 +454,198 @@ public function updateSubscriptionMiniumPrice( } /** - * @param string $subscriptionId The subscription id - * @param string $cycleId + * Creates a increment * - * @return GetPeriodResponse Response from the API call + * @param string $subscriptionId Subscription id + * @param CreateIncrementRequest $request Request for creating a increment + * @param string|null $idempotencyKey + * + * @return GetIncrementResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getSubscriptionCycleById(string $subscriptionId, string $cycleId): GetPeriodResponse - { - $_reqBuilder = $this->requestBuilder( - RequestMethod::GET, - '/subscriptions/{subscription_id}/cycles/{cycleId}' - ) + public function createIncrement( + string $subscriptionId, + CreateIncrementRequest $request, + ?string $idempotencyKey = null + ): GetIncrementResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/subscriptions/{subscription_id}/increments') ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), - TemplateParam::init('cycleId', $cycleId) + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetPeriodResponse::class); + $_resHandler = $this->responseHandler()->type(GetIncrementResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * @param string $subscriptionId The subscription Id - * @param string $periodId The period Id + * Creates a usage * - * @return GetUsageReportResponse Response from the API call + * @param string $subscriptionId Subscription Id + * @param string $itemId Item id + * @param CreateUsageRequest $body Request for creating a usage + * @param string|null $idempotencyKey + * + * @return GetUsageResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getUsageReport(string $subscriptionId, string $periodId): GetUsageReportResponse - { + public function createUsage( + string $subscriptionId, + string $itemId, + CreateUsageRequest $body, + ?string $idempotencyKey = null + ): GetUsageResponse { $_reqBuilder = $this->requestBuilder( - RequestMethod::GET, - '/subscriptions/{subscription_id}/periods/{period_id}/usages/report' + RequestMethod::POST, + '/subscriptions/{subscription_id}/items/{item_id}/usages' ) ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), - TemplateParam::init('period_id', $periodId) + TemplateParam::init('item_id', $itemId), + BodyParam::init($body), + HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetUsageReportResponse::class); + $_resHandler = $this->responseHandler()->type(GetUsageResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * @param string $subscriptionId - * @param string|null $idempotencyKey + * @param string $subscriptionId The subscription id + * @param string $discountId * - * @return GetPeriodResponse Response from the API call + * @return GetDiscountResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function renewSubscription(string $subscriptionId, ?string $idempotencyKey = null): GetPeriodResponse + public function getDiscountById(string $subscriptionId, string $discountId): GetDiscountResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/subscriptions/{subscription_id}/cycles') + $_reqBuilder = $this->requestBuilder( + RequestMethod::GET, + '/subscriptions/{subscription_id}/discounts/{discountId}' + ) ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), - HeaderParam::init('idempotency-key', $idempotencyKey) + TemplateParam::init('discountId', $discountId) ); - $_resHandler = $this->responseHandler()->type(GetPeriodResponse::class); + $_resHandler = $this->responseHandler()->type(GetDiscountResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Deletes a usage + * Creates a new subscription * - * @param string $subscriptionId The subscription id - * @param string $itemId The subscription item id - * @param string $usageId The usage id + * @param CreateSubscriptionRequest $body Request for creating a subscription * @param string|null $idempotencyKey * - * @return GetUsageResponse Response from the API call + * @return GetSubscriptionResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function deleteUsage( - string $subscriptionId, - string $itemId, - string $usageId, + public function createSubscription( + CreateSubscriptionRequest $body, ?string $idempotencyKey = null - ): GetUsageResponse { - $_reqBuilder = $this->requestBuilder( - RequestMethod::DELETE, - '/subscriptions/{subscription_id}/items/{item_id}/usages/{usage_id}' - ) + ): GetSubscriptionResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/subscriptions') ->auth('httpBasic') - ->parameters( - TemplateParam::init('subscription_id', $subscriptionId), - TemplateParam::init('item_id', $itemId), - TemplateParam::init('usage_id', $usageId), - HeaderParam::init('idempotency-key', $idempotencyKey) - ); + ->parameters(BodyParam::init($body), HeaderParam::init('idempotency-key', $idempotencyKey)); - $_resHandler = $this->responseHandler()->type(GetUsageResponse::class); + $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Create Usage - * - * @param string $subscriptionId Subscription id - * @param string $itemId Item id - * @param string|null $idempotencyKey + * @param string $subscriptionId The subscription Id + * @param string $incrementId The increment Id * - * @return GetUsageResponse Response from the API call + * @return GetIncrementResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function createAnUsage( - string $subscriptionId, - string $itemId, - ?string $idempotencyKey = null - ): GetUsageResponse { + public function getIncrementById(string $subscriptionId, string $incrementId): GetIncrementResponse + { $_reqBuilder = $this->requestBuilder( - RequestMethod::POST, - '/subscriptions/{subscription_id}/items/{item_id}/usages' + RequestMethod::GET, + '/subscriptions/{subscription_id}/increments/{increment_id}' ) ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), - TemplateParam::init('item_id', $itemId), - HeaderParam::init('idempotency-key', $idempotencyKey) + TemplateParam::init('increment_id', $incrementId) ); - $_resHandler = $this->responseHandler()->type(GetUsageResponse::class); + $_resHandler = $this->responseHandler()->type(GetIncrementResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * @param string $subscriptionId Subscription Id - * @param UpdateCurrentCycleStatusRequest $request Request for updating the end date of the - * subscription current status + * @param string $subscriptionId + * @param UpdateSubscriptionAffiliationIdRequest $request Request for updating a subscription + * affiliation id * @param string|null $idempotencyKey * - * @return void Response from the API call + * @return GetSubscriptionResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateCurrentCycleStatus( + public function updateSubscriptionAffiliationId( string $subscriptionId, - UpdateCurrentCycleStatusRequest $request, + UpdateSubscriptionAffiliationIdRequest $request, ?string $idempotencyKey = null - ): void { - $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/subscriptions/{subscription_id}/cycle-status') - ->auth('httpBasic') - ->parameters( - TemplateParam::init('subscription_id', $subscriptionId), - BodyParam::init($request), - HeaderParam::init('idempotency-key', $idempotencyKey) - ); - - $this->execute($_reqBuilder); - } - - /** - * Get Subscription Item - * - * @param string $subscriptionId Subscription Id - * @param string $itemId Item id - * - * @return GetSubscriptionItemResponse Response from the API call - * - * @throws ApiException Thrown if API call fails - */ - public function getSubscriptionItem(string $subscriptionId, string $itemId): GetSubscriptionItemResponse - { + ): GetSubscriptionResponse { $_reqBuilder = $this->requestBuilder( - RequestMethod::GET, - '/subscriptions/{subscription_id}/items/{item_id}' + RequestMethod::PATCH, + '/subscriptions/{subscription_id}/gateway-affiliation-id' ) ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), - TemplateParam::init('item_id', $itemId) + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetSubscriptionItemResponse::class); + $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * @param string $subscriptionId The subscription Id - * @param string $incrementId The increment Id + * Updates the metadata from a subscription * - * @return GetIncrementResponse Response from the API call + * @param string $subscriptionId The subscription id + * @param UpdateMetadataRequest $request Request for updating the subscrption metadata + * @param string|null $idempotencyKey + * + * @return GetSubscriptionResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getIncrementById(string $subscriptionId, string $incrementId): GetIncrementResponse - { - $_reqBuilder = $this->requestBuilder( - RequestMethod::GET, - '/subscriptions/{subscription_id}/increments/{increment_id}' - ) + public function updateSubscriptionMetadata( + string $subscriptionId, + UpdateMetadataRequest $request, + ?string $idempotencyKey = null + ): GetSubscriptionResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/Subscriptions/{subscription_id}/metadata') ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), - TemplateParam::init('increment_id', $incrementId) + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetIncrementResponse::class); + $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); return $this->execute($_reqBuilder, $_resHandler); } @@ -697,6 +682,30 @@ public function deleteIncrement( return $this->execute($_reqBuilder, $_resHandler); } + /** + * @param string $subscriptionId Subscription Id + * @param string $page Page number + * @param string $size Page size + * + * @return ListCyclesResponse Response from the API call + * + * @throws ApiException Thrown if API call fails + */ + public function getSubscriptionCycles(string $subscriptionId, string $page, string $size): ListCyclesResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/subscriptions/{subscription_id}/cycles') + ->auth('httpBasic') + ->parameters( + TemplateParam::init('subscription_id', $subscriptionId), + QueryParam::init('page', $page), + QueryParam::init('size', $size) + ); + + $_resHandler = $this->responseHandler()->type(ListCyclesResponse::class); + + return $this->execute($_reqBuilder, $_resHandler); + } + /** * @param string $subscriptionId The subscription id * @param int $page Page number @@ -722,25 +731,23 @@ public function getDiscounts(string $subscriptionId, int $page, int $size): List } /** - * Updates the boleto due days from a subscription + * Updates the billing date from a subscription * - * @param string $subscriptionId Subscription Id - * @param UpdateSubscriptionDueDaysRequest $request + * @param string $subscriptionId The subscription id + * @param UpdateSubscriptionBillingDateRequest $request Request for updating the subscription + * billing date * @param string|null $idempotencyKey * * @return GetSubscriptionResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateSubscriptionDueDays( + public function updateSubscriptionBillingDate( string $subscriptionId, - UpdateSubscriptionDueDaysRequest $request, + UpdateSubscriptionBillingDateRequest $request, ?string $idempotencyKey = null ): GetSubscriptionResponse { - $_reqBuilder = $this->requestBuilder( - RequestMethod::PATCH, - '/subscriptions/{subscription_id}/boleto-due-days' - ) + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/subscriptions/{subscription_id}/billing-date') ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), @@ -754,26 +761,29 @@ public function updateSubscriptionDueDays( } /** - * Creates a new Subscription item + * Deletes a subscription item * * @param string $subscriptionId Subscription id - * @param CreateSubscriptionItemRequest $request Request for creating a subscription item + * @param string $subscriptionItemId Subscription item id * @param string|null $idempotencyKey * * @return GetSubscriptionItemResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function createSubscriptionItem( + public function deleteSubscriptionItem( string $subscriptionId, - CreateSubscriptionItemRequest $request, + string $subscriptionItemId, ?string $idempotencyKey = null ): GetSubscriptionItemResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/subscriptions/{subscription_id}/items') + $_reqBuilder = $this->requestBuilder( + RequestMethod::DELETE, + '/subscriptions/{subscription_id}/items/{subscription_item_id}' + ) ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), - BodyParam::init($request), + TemplateParam::init('subscription_item_id', $subscriptionItemId), HeaderParam::init('idempotency-key', $idempotencyKey) ); @@ -783,151 +793,79 @@ public function createSubscriptionItem( } /** - * @param string $id Subscription's id - * @param UpdateSubscriptionSplitRequest $request - * - * @return GetSubscriptionResponse Response from the API call - * - * @throws ApiException Thrown if API call fails - */ - public function updateSplitSubscription( - string $id, - UpdateSubscriptionSplitRequest $request - ): GetSubscriptionResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/subscriptions/{id}/split') - ->auth('httpBasic') - ->parameters(TemplateParam::init('id', $id), BodyParam::init($request)); - - $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); - - return $this->execute($_reqBuilder, $_resHandler); - } - - /** - * Get Subscription Items - * * @param string $subscriptionId The subscription id * @param int|null $page Page number * @param int|null $size Page size - * @param string|null $name The item name - * @param string|null $code Identification code in the client system - * @param string|null $status The item statis - * @param string|null $description The item description - * @param string|null $createdSince Filter for item's creation date start range - * @param string|null $createdUntil Filter for item's creation date end range * - * @return ListSubscriptionItemsResponse Response from the API call + * @return ListIncrementsResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getSubscriptionItems( - string $subscriptionId, - ?int $page = null, - ?int $size = null, - ?string $name = null, - ?string $code = null, - ?string $status = null, - ?string $description = null, - ?string $createdSince = null, - ?string $createdUntil = null - ): ListSubscriptionItemsResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/subscriptions/{subscription_id}/items') + public function getIncrements(string $subscriptionId, ?int $page = null, ?int $size = null): ListIncrementsResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/subscriptions/{subscription_id}/increments/') ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), QueryParam::init('page', $page), - QueryParam::init('size', $size), - QueryParam::init('name', $name), - QueryParam::init('code', $code), - QueryParam::init('status', $status), - QueryParam::init('description', $description), - QueryParam::init('created_since', $createdSince), - QueryParam::init('created_until', $createdUntil) + QueryParam::init('size', $size) ); - $_resHandler = $this->responseHandler()->type(ListSubscriptionItemsResponse::class); + $_resHandler = $this->responseHandler()->type(ListIncrementsResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Gets all subscriptions + * Updates the boleto due days from a subscription * - * @param int|null $page Page number - * @param int|null $size Page size - * @param string|null $code Filter for subscription's code - * @param string|null $billingType Filter for subscription's billing type - * @param string|null $customerId Filter for subscription's customer id - * @param string|null $planId Filter for subscription's plan id - * @param string|null $cardId Filter for subscription's card id - * @param string|null $status Filter for subscription's status - * @param \DateTime|null $nextBillingSince Filter for subscription's next billing date start - * range - * @param \DateTime|null $nextBillingUntil Filter for subscription's next billing date end range - * @param \DateTime|null $createdSince Filter for subscription's creation date start range - * @param \DateTime|null $createdUntil Filter for subscriptions creation date end range + * @param string $subscriptionId Subscription Id + * @param UpdateSubscriptionDueDaysRequest $request + * @param string|null $idempotencyKey * - * @return ListSubscriptionsResponse Response from the API call + * @return GetSubscriptionResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getSubscriptions( - ?int $page = null, - ?int $size = null, - ?string $code = null, - ?string $billingType = null, - ?string $customerId = null, - ?string $planId = null, - ?string $cardId = null, - ?string $status = null, - ?\DateTime $nextBillingSince = null, - ?\DateTime $nextBillingUntil = null, - ?\DateTime $createdSince = null, - ?\DateTime $createdUntil = null - ): ListSubscriptionsResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/subscriptions') - ->auth('httpBasic') - ->parameters( - QueryParam::init('page', $page), - QueryParam::init('size', $size), - QueryParam::init('code', $code), - QueryParam::init('billing_type', $billingType), - QueryParam::init('customer_id', $customerId), - QueryParam::init('plan_id', $planId), - QueryParam::init('card_id', $cardId), - QueryParam::init('status', $status), - QueryParam::init('next_billing_since', $nextBillingSince) - ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), - QueryParam::init('next_billing_until', $nextBillingUntil) - ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), - QueryParam::init('created_since', $createdSince) - ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), - QueryParam::init('created_until', $createdUntil) - ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']) + public function updateSubscriptionDueDays( + string $subscriptionId, + UpdateSubscriptionDueDaysRequest $request, + ?string $idempotencyKey = null + ): GetSubscriptionResponse { + $_reqBuilder = $this->requestBuilder( + RequestMethod::PATCH, + '/subscriptions/{subscription_id}/boleto-due-days' + ) + ->auth('httpBasic') + ->parameters( + TemplateParam::init('subscription_id', $subscriptionId), + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(ListSubscriptionsResponse::class); + $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Creates a increment + * Updates the start at date from a subscription * - * @param string $subscriptionId Subscription id - * @param CreateIncrementRequest $request Request for creating a increment + * @param string $subscriptionId The subscription id + * @param UpdateSubscriptionStartAtRequest $request Request for updating the subscription start + * date * @param string|null $idempotencyKey * - * @return GetIncrementResponse Response from the API call + * @return GetSubscriptionResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function createIncrement( + public function updateSubscriptionStartAt( string $subscriptionId, - CreateIncrementRequest $request, + UpdateSubscriptionStartAtRequest $request, ?string $idempotencyKey = null - ): GetIncrementResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/subscriptions/{subscription_id}/increments') + ): GetSubscriptionResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/subscriptions/{subscription_id}/start-at') ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), @@ -935,32 +873,32 @@ public function createIncrement( HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetIncrementResponse::class); + $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Creates a usage + * Updates a subscription item * * @param string $subscriptionId Subscription Id * @param string $itemId Item id - * @param CreateUsageRequest $body Request for creating a usage + * @param UpdateSubscriptionItemRequest $body Request for updating a subscription item * @param string|null $idempotencyKey * - * @return GetUsageResponse Response from the API call + * @return GetSubscriptionItemResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function createUsage( + public function updateSubscriptionItem( string $subscriptionId, string $itemId, - CreateUsageRequest $body, + UpdateSubscriptionItemRequest $body, ?string $idempotencyKey = null - ): GetUsageResponse { + ): GetSubscriptionItemResponse { $_reqBuilder = $this->requestBuilder( - RequestMethod::POST, - '/subscriptions/{subscription_id}/items/{item_id}/usages' + RequestMethod::PUT, + '/subscriptions/{subscription_id}/items/{item_id}' ) ->auth('httpBasic') ->parameters( @@ -970,176 +908,238 @@ public function createUsage( HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetUsageResponse::class); + $_resHandler = $this->responseHandler()->type(GetSubscriptionItemResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * @param string $subscriptionId The subscription id - * @param string $discountId + * Creates a new Subscription item * - * @return GetDiscountResponse Response from the API call + * @param string $subscriptionId Subscription id + * @param CreateSubscriptionItemRequest $request Request for creating a subscription item + * @param string|null $idempotencyKey + * + * @return GetSubscriptionItemResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getDiscountById(string $subscriptionId, string $discountId): GetDiscountResponse - { - $_reqBuilder = $this->requestBuilder( - RequestMethod::GET, - '/subscriptions/{subscription_id}/discounts/{discountId}' - ) + public function createSubscriptionItem( + string $subscriptionId, + CreateSubscriptionItemRequest $request, + ?string $idempotencyKey = null + ): GetSubscriptionItemResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/subscriptions/{subscription_id}/items') ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), - TemplateParam::init('discountId', $discountId) + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetDiscountResponse::class); + $_resHandler = $this->responseHandler()->type(GetSubscriptionItemResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Updates the metadata from a subscription + * Gets a subscription * - * @param string $subscriptionId The subscription id - * @param UpdateMetadataRequest $request Request for updating the subscrption metadata - * @param string|null $idempotencyKey + * @param string $subscriptionId Subscription id * * @return GetSubscriptionResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateSubscriptionMetadata( + public function getSubscription(string $subscriptionId): GetSubscriptionResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/subscriptions/{subscription_id}') + ->auth('httpBasic') + ->parameters(TemplateParam::init('subscription_id', $subscriptionId)); + + $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); + + return $this->execute($_reqBuilder, $_resHandler); + } + + /** + * Lists all usages from a subscription item + * + * @param string $subscriptionId The subscription id + * @param string $itemId The subscription item id + * @param int|null $page Page number + * @param int|null $size Page size + * @param string|null $code Identification code in the client system + * @param string|null $group Identification group in the client system + * @param \DateTime|null $usedSince + * @param \DateTime|null $usedUntil + * + * @return ListUsagesResponse Response from the API call + * + * @throws ApiException Thrown if API call fails + */ + public function getUsages( string $subscriptionId, - UpdateMetadataRequest $request, - ?string $idempotencyKey = null - ): GetSubscriptionResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/Subscriptions/{subscription_id}/metadata') + string $itemId, + ?int $page = null, + ?int $size = null, + ?string $code = null, + ?string $group = null, + ?\DateTime $usedSince = null, + ?\DateTime $usedUntil = null + ): ListUsagesResponse { + $_reqBuilder = $this->requestBuilder( + RequestMethod::GET, + '/subscriptions/{subscription_id}/items/{item_id}/usages' + ) ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), - BodyParam::init($request), - HeaderParam::init('idempotency-key', $idempotencyKey) + TemplateParam::init('item_id', $itemId), + QueryParam::init('page', $page), + QueryParam::init('size', $size), + QueryParam::init('code', $code), + QueryParam::init('group', $group), + QueryParam::init('used_since', $usedSince)->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), + QueryParam::init('used_until', $usedUntil)->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']) ); - $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); + $_resHandler = $this->responseHandler()->type(ListUsagesResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * @param string $subscriptionId Subscription Id - * @param string $page Page number - * @param string $size Page size + * @param string $subscriptionId + * @param UpdateCurrentCycleEndDateRequest $request Request for updating the end date of the + * current signature cycle + * @param string|null $idempotencyKey * - * @return ListCyclesResponse Response from the API call + * @return GetSubscriptionResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getSubscriptionCycles(string $subscriptionId, string $page, string $size): ListCyclesResponse - { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/subscriptions/{subscription_id}/cycles') + public function updateLatestPeriodEndAt( + string $subscriptionId, + UpdateCurrentCycleEndDateRequest $request, + ?string $idempotencyKey = null + ): GetSubscriptionResponse { + $_reqBuilder = $this->requestBuilder( + RequestMethod::PATCH, + '/subscriptions/{subscription_id}/periods/latest/end-at' + ) ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), - QueryParam::init('page', $page), - QueryParam::init('size', $size) + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(ListCyclesResponse::class); + $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Deletes a subscription item + * Atualização do valor mínimo da assinatura * - * @param string $subscriptionId Subscription id - * @param string $subscriptionItemId Subscription item id + * @param string $subscriptionId Subscription Id + * @param UpdateSubscriptionMinimumPriceRequest $request Request da requisição com o valor + * mínimo que será configurado * @param string|null $idempotencyKey * - * @return GetSubscriptionItemResponse Response from the API call + * @return GetSubscriptionResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function deleteSubscriptionItem( + public function updateSubscriptionMiniumPrice( string $subscriptionId, - string $subscriptionItemId, + UpdateSubscriptionMinimumPriceRequest $request, ?string $idempotencyKey = null - ): GetSubscriptionItemResponse { + ): GetSubscriptionResponse { $_reqBuilder = $this->requestBuilder( - RequestMethod::DELETE, - '/subscriptions/{subscription_id}/items/{subscription_item_id}' + RequestMethod::PATCH, + '/subscriptions/{subscription_id}/minimum_price' ) ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), - TemplateParam::init('subscription_item_id', $subscriptionItemId), + BodyParam::init($request), HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetSubscriptionItemResponse::class); + $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** * @param string $subscriptionId The subscription id - * @param int|null $page Page number - * @param int|null $size Page size + * @param string $cycleId * - * @return ListIncrementsResponse Response from the API call + * @return GetPeriodResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getIncrements(string $subscriptionId, ?int $page = null, ?int $size = null): ListIncrementsResponse + public function getSubscriptionCycleById(string $subscriptionId, string $cycleId): GetPeriodResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/subscriptions/{subscription_id}/increments/') + $_reqBuilder = $this->requestBuilder( + RequestMethod::GET, + '/subscriptions/{subscription_id}/cycles/{cycleId}' + ) ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), - QueryParam::init('page', $page), - QueryParam::init('size', $size) + TemplateParam::init('cycleId', $cycleId) ); - $_resHandler = $this->responseHandler()->type(ListIncrementsResponse::class); + $_resHandler = $this->responseHandler()->type(GetPeriodResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Updates a subscription item - * - * @param string $subscriptionId Subscription Id - * @param string $itemId Item id - * @param UpdateSubscriptionItemRequest $body Request for updating a subscription item - * @param string|null $idempotencyKey + * @param string $subscriptionId The subscription Id + * @param string $periodId The period Id * - * @return GetSubscriptionItemResponse Response from the API call + * @return GetUsageReportResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateSubscriptionItem( - string $subscriptionId, - string $itemId, - UpdateSubscriptionItemRequest $body, - ?string $idempotencyKey = null - ): GetSubscriptionItemResponse { + public function getUsageReport(string $subscriptionId, string $periodId): GetUsageReportResponse + { $_reqBuilder = $this->requestBuilder( - RequestMethod::PUT, - '/subscriptions/{subscription_id}/items/{item_id}' + RequestMethod::GET, + '/subscriptions/{subscription_id}/periods/{period_id}/usages/report' ) ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), - TemplateParam::init('item_id', $itemId), - BodyParam::init($body), - HeaderParam::init('idempotency-key', $idempotencyKey) + TemplateParam::init('period_id', $periodId) ); - $_resHandler = $this->responseHandler()->type(GetSubscriptionItemResponse::class); + $_resHandler = $this->responseHandler()->type(GetUsageReportResponse::class); + + return $this->execute($_reqBuilder, $_resHandler); + } + + /** + * @param string $id Subscription's id + * @param UpdateSubscriptionSplitRequest $request + * + * @return GetSubscriptionResponse Response from the API call + * + * @throws ApiException Thrown if API call fails + */ + public function updateSplitSubscription( + string $id, + UpdateSubscriptionSplitRequest $request + ): GetSubscriptionResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/subscriptions/{id}/split') + ->auth('httpBasic') + ->parameters(TemplateParam::init('id', $id), BodyParam::init($request)); + + $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); return $this->execute($_reqBuilder, $_resHandler); } diff --git a/src/Controllers/TokensController.php b/src/Controllers/TokensController.php index 87e0e5c..93b56be 100644 --- a/src/Controllers/TokensController.php +++ b/src/Controllers/TokensController.php @@ -20,26 +20,6 @@ class TokensController extends BaseController { - /** - * Gets a token from its id - * - * @param string $id Token id - * @param string $publicKey Public key - * - * @return GetTokenResponse Response from the API call - * - * @throws ApiException Thrown if API call fails - */ - public function getToken(string $id, string $publicKey): GetTokenResponse - { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/tokens/{id}?appId={public_key}') - ->parameters(TemplateParam::init('id', $id), TemplateParam::init('public_key', $publicKey)); - - $_resHandler = $this->responseHandler()->type(GetTokenResponse::class); - - return $this->execute($_reqBuilder, $_resHandler); - } - /** * @param string $publicKey Public key * @param CreateTokenRequest $request Request for creating a token @@ -65,4 +45,24 @@ public function createToken( return $this->execute($_reqBuilder, $_resHandler); } + + /** + * Gets a token from its id + * + * @param string $id Token id + * @param string $publicKey Public key + * + * @return GetTokenResponse Response from the API call + * + * @throws ApiException Thrown if API call fails + */ + public function getToken(string $id, string $publicKey): GetTokenResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/tokens/{id}?appId={public_key}') + ->parameters(TemplateParam::init('id', $id), TemplateParam::init('public_key', $publicKey)); + + $_resHandler = $this->responseHandler()->type(GetTokenResponse::class); + + return $this->execute($_reqBuilder, $_resHandler); + } } diff --git a/src/Controllers/TransfersController.php b/src/Controllers/TransfersController.php index b9611cf..ae71c1e 100644 --- a/src/Controllers/TransfersController.php +++ b/src/Controllers/TransfersController.php @@ -39,35 +39,35 @@ public function getTransferById(string $transferId): GetTransfer } /** - * Gets all transfers + * @param CreateTransfer $request * - * @return ListTransfers Response from the API call + * @return GetTransfer Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getTransfers(): ListTransfers + public function createTransfer(CreateTransfer $request): GetTransfer { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/transfers')->auth('httpBasic'); + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/transfers/recipients') + ->auth('httpBasic') + ->parameters(BodyParam::init($request)); - $_resHandler = $this->responseHandler()->type(ListTransfers::class); + $_resHandler = $this->responseHandler()->type(GetTransfer::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * @param CreateTransfer $request + * Gets all transfers * - * @return GetTransfer Response from the API call + * @return ListTransfers Response from the API call * * @throws ApiException Thrown if API call fails */ - public function createTransfer(CreateTransfer $request): GetTransfer + public function getTransfers(): ListTransfers { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/transfers/recipients') - ->auth('httpBasic') - ->parameters(BodyParam::init($request)); + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/transfers')->auth('httpBasic'); - $_resHandler = $this->responseHandler()->type(GetTransfer::class); + $_resHandler = $this->responseHandler()->type(ListTransfers::class); return $this->execute($_reqBuilder, $_resHandler); } diff --git a/src/Models/Builders/CreateKYCLinkResponseBuilder.php b/src/Models/Builders/CreateKYCLinkResponseBuilder.php new file mode 100644 index 0000000..a8e0af5 --- /dev/null +++ b/src/Models/Builders/CreateKYCLinkResponseBuilder.php @@ -0,0 +1,102 @@ +instance = $instance; + } + + /** + * Initializes a new create kyclink response Builder object. + */ + public static function init(): self + { + return new self(new CreateKYCLinkResponse()); + } + + /** + * Sets base 64 field. + */ + public function base64(?string $value): self + { + $this->instance->setBase64($value); + return $this; + } + + /** + * Unsets base 64 field. + */ + public function unsetBase64(): self + { + $this->instance->unsetBase64(); + return $this; + } + + /** + * Sets url field. + */ + public function url(?string $value): self + { + $this->instance->setUrl($value); + return $this; + } + + /** + * Unsets url field. + */ + public function unsetUrl(): self + { + $this->instance->unsetUrl(); + return $this; + } + + /** + * Sets expiration date field. + */ + public function expirationDate(?string $value): self + { + $this->instance->setExpirationDate($value); + return $this; + } + + /** + * Unsets expiration date field. + */ + public function unsetExpirationDate(): self + { + $this->instance->unsetExpirationDate(); + return $this; + } + + /** + * Initializes a new create kyclink response object. + */ + public function build(): CreateKYCLinkResponse + { + return CoreHelper::clone($this->instance); + } +} diff --git a/src/Models/CreateKYCLinkResponse.php b/src/Models/CreateKYCLinkResponse.php new file mode 100644 index 0000000..09d3d0c --- /dev/null +++ b/src/Models/CreateKYCLinkResponse.php @@ -0,0 +1,155 @@ +base64) == 0) { + return null; + } + return $this->base64['value']; + } + + /** + * Sets Base 64. + * Base64 + * + * @maps base64 + */ + public function setBase64(?string $base64): void + { + $this->base64['value'] = $base64; + } + + /** + * Unsets Base 64. + * Base64 + */ + public function unsetBase64(): void + { + $this->base64 = []; + } + + /** + * Returns Url. + * URL + */ + public function getUrl(): ?string + { + if (count($this->url) == 0) { + return null; + } + return $this->url['value']; + } + + /** + * Sets Url. + * URL + * + * @maps url + */ + public function setUrl(?string $url): void + { + $this->url['value'] = $url; + } + + /** + * Unsets Url. + * URL + */ + public function unsetUrl(): void + { + $this->url = []; + } + + /** + * Returns Expiration Date. + * Expiration Date + */ + public function getExpirationDate(): ?string + { + if (count($this->expirationDate) == 0) { + return null; + } + return $this->expirationDate['value']; + } + + /** + * Sets Expiration Date. + * Expiration Date + * + * @maps expiration_date + */ + public function setExpirationDate(?string $expirationDate): void + { + $this->expirationDate['value'] = $expirationDate; + } + + /** + * Unsets Expiration Date. + * Expiration Date + */ + public function unsetExpirationDate(): void + { + $this->expirationDate = []; + } + + /** + * Encode this object to JSON + * + * @param bool $asArrayWhenEmpty Whether to serialize this model as an array whenever no fields + * are set. (default: false) + * + * @return array|stdClass + */ + #[\ReturnTypeWillChange] // @phan-suppress-current-line PhanUndeclaredClassAttribute for (php < 8.1) + public function jsonSerialize(bool $asArrayWhenEmpty = false) + { + $json = []; + if (!empty($this->base64)) { + $json['base64'] = $this->base64['value']; + } + if (!empty($this->url)) { + $json['url'] = $this->url['value']; + } + if (!empty($this->expirationDate)) { + $json['expiration_date'] = $this->expirationDate['value']; + } + + return (!$asArrayWhenEmpty && empty($json)) ? new stdClass() : $json; + } +} diff --git a/src/PagarmeApiSDKClient.php b/src/PagarmeApiSDKClient.php index ba7888e..c48a679 100644 --- a/src/PagarmeApiSDKClient.php +++ b/src/PagarmeApiSDKClient.php @@ -82,7 +82,7 @@ public function __construct(array $config = []) ->converter(new CompatibilityConverter()) ->jsonHelper(ApiHelper::getJsonHelper()) ->apiCallback($this->config['httpCallback'] ?? null) - ->userAgent('PagarmeApiSDK - PHP 6.8.7') + ->userAgent('PagarmeApiSDK - PHP 6.8.8') ->globalConfig($this->getGlobalConfiguration()) ->globalErrors($this->getGlobalErrors()) ->serverUrls(self::ENVIRONMENT_MAP[$this->getEnvironment()], Server::DEFAULT_)