From e27a5d87836c7f70b9a7712cdc3b4734629d7362 Mon Sep 17 00:00:00 2001 From: andreals Date: Mon, 24 Jun 2024 17:21:50 +0000 Subject: [PATCH] Automated commit message --- README.md | 48 +- composer.json | 2 +- doc/controllers/balance-operations.md | 42 +- doc/controllers/charges.md | 364 +++--- doc/controllers/customers.md | 474 +++---- doc/controllers/invoices.md | 204 +-- doc/controllers/orders.md | 300 ++--- doc/controllers/plans.md | 346 ++--- doc/controllers/recipients.md | 506 ++++---- doc/controllers/subscriptions.md | 1110 ++++++++--------- doc/controllers/tokens.md | 70 +- doc/controllers/transfers.md | 40 +- src/ApiHelper.php | 14 +- src/Authentication/BasicAuthManager.php | 27 +- .../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 | 436 +++---- src/Controllers/SubscriptionsController.php | 928 +++++++------- src/Controllers/TokensController.php | 40 +- src/Controllers/TransfersController.php | 24 +- src/PagarmeApiSDKClient.php | 5 +- 25 files changed, 3103 insertions(+), 3111 deletions(-) diff --git a/README.md b/README.md index 61390a0..c905b3f 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.9/doc/client.md) +**_Note:_** Documentation for the client can be found [here.](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.10/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.9/doc/$a/https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.9/basic-authentication.md) | The Credentials Setter for Basic Authentication | +| `basicAuthCredentials` | [`BasicAuthCredentials`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.10/doc/$a/https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.10/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.9/doc/$a/https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.9/basic-authentication.md) +* [`httpBasic (Basic Authentication)`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.10/doc/$a/https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.10/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.9/doc/models/error-exception.md) | -| 401 | Invalid API key | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.9/doc/models/error-exception.md) | -| 404 | An informed resource was not found | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.9/doc/models/error-exception.md) | -| 412 | Business validation error | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.9/doc/models/error-exception.md) | -| 422 | Contract validation error | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.9/doc/models/error-exception.md) | -| 500 | Internal server error | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.9/doc/models/error-exception.md) | +| 400 | Invalid request | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.10/doc/models/error-exception.md) | +| 401 | Invalid API key | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.10/doc/models/error-exception.md) | +| 404 | An informed resource was not found | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.10/doc/models/error-exception.md) | +| 412 | Business validation error | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.10/doc/models/error-exception.md) | +| 422 | Contract validation error | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.10/doc/models/error-exception.md) | +| 500 | Internal server error | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.10/doc/models/error-exception.md) | ## List of APIs -* [Subscriptions](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.9/doc/controllers/subscriptions.md) -* [Orders](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.9/doc/controllers/orders.md) -* [Plans](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.9/doc/controllers/plans.md) -* [Invoices](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.9/doc/controllers/invoices.md) -* [Customers](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.9/doc/controllers/customers.md) -* [Charges](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.9/doc/controllers/charges.md) -* [Recipients](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.9/doc/controllers/recipients.md) -* [Tokens](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.9/doc/controllers/tokens.md) -* [Transactions](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.9/doc/controllers/transactions.md) -* [Transfers](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.9/doc/controllers/transfers.md) -* [Payables](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.9/doc/controllers/payables.md) -* [Balance Operations](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.9/doc/controllers/balance-operations.md) +* [Subscriptions](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.10/doc/controllers/subscriptions.md) +* [Orders](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.10/doc/controllers/orders.md) +* [Plans](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.10/doc/controllers/plans.md) +* [Invoices](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.10/doc/controllers/invoices.md) +* [Customers](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.10/doc/controllers/customers.md) +* [Charges](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.10/doc/controllers/charges.md) +* [Recipients](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.10/doc/controllers/recipients.md) +* [Tokens](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.10/doc/controllers/tokens.md) +* [Transactions](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.10/doc/controllers/transactions.md) +* [Transfers](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.10/doc/controllers/transfers.md) +* [Payables](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.10/doc/controllers/payables.md) +* [Balance Operations](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.10/doc/controllers/balance-operations.md) ## Classes Documentation -* [ApiException](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.9/doc/api-exception.md) -* [HttpRequest](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.9/doc/http-request.md) -* [HttpResponse](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.9/doc/http-response.md) +* [ApiException](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.10/doc/api-exception.md) +* [HttpRequest](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.10/doc/http-request.md) +* [HttpResponse](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.10/doc/http-response.md) diff --git a/composer.json b/composer.json index fb364ce..177b00b 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "ext-json": "*", "apimatic/unirest-php": "^4.0.0", "apimatic/core-interfaces": "~0.1.5", - "apimatic/core": "~0.3.9" + "apimatic/core": "~0.3.10" }, "require-dev": { "squizlabs/php_codesniffer": "^3.5", diff --git a/doc/controllers/balance-operations.md b/doc/controllers/balance-operations.md index c397f2f..fcbcf9a 100644 --- a/doc/controllers/balance-operations.md +++ b/doc/controllers/balance-operations.md @@ -10,62 +10,62 @@ $balanceOperationsController = $client->getBalanceOperationsController(); ## Methods -* [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 Operations](../../doc/controllers/balance-operations.md#get-balance-operations) -# 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); ``` -# 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(); ``` diff --git a/doc/controllers/charges.md b/doc/controllers/charges.md index 525cdd3..3dcbff2 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) -* [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) +* [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) +* [Update Charge Due Date](../../doc/controllers/charges.md#update-charge-due-date) * [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( ``` -# Update Charge Payment Method +# Capture Charge -Updates a charge's payment method +Captures a charge ```php -function updateChargePaymentMethod( +function captureCharge( string $chargeId, - UpdateChargePaymentMethodRequest $request, + ?CreateCaptureChargeRequest $request = null, ?string $idempotencyKey = null ): GetChargeResponse ``` @@ -84,7 +84,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` | [`?CreateCaptureChargeRequest`](../../doc/models/create-capture-charge-request.md) | Body, Optional | Request for capturing a charge | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -96,97 +96,43 @@ function updateChargePaymentMethod( ```php $chargeId = 'charge_id8'; -$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 -); +$result = $chargesController->captureCharge($chargeId); ``` -# Get Charge Transactions +# Get Charge + +Get a charge from its id ```php -function getChargeTransactions( - string $chargeId, - ?int $page = null, - ?int $size = null -): ListChargeTransactionsResponse +function getCharge(string $chargeId): GetChargeResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `chargeId` | `string` | Template, Required | Charge Id | -| `page` | `?int` | Query, Optional | Page number | -| `size` | `?int` | Query, Optional | Page size | +| `chargeId` | `string` | Template, Required | Charge id | ## Response Type -[`ListChargeTransactionsResponse`](../../doc/models/list-charge-transactions-response.md) +[`GetChargeResponse`](../../doc/models/get-charge-response.md) ## Example Usage ```php $chargeId = 'charge_id8'; -$result = $chargesController->getChargeTransactions($chargeId); +$result = $chargesController->getCharge($chargeId); ``` -# Update Charge Due Date - -Updates the due date from a charge +# Confirm Payment ```php -function updateChargeDueDate( +function confirmPayment( string $chargeId, - UpdateChargeDueDateRequest $request, + ?CreateConfirmPaymentRequest $request = null, ?string $idempotencyKey = null ): GetChargeResponse ``` @@ -195,8 +141,8 @@ function updateChargeDueDate( | 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 | +| `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 @@ -208,66 +154,49 @@ function updateChargeDueDate( ```php $chargeId = 'charge_id8'; -$request = UpdateChargeDueDateRequestBuilder::init()->build(); - -$result = $chargesController->updateChargeDueDate( - $chargeId, - $request -); +$result = $chargesController->confirmPayment($chargeId); ``` -# Get Charges - -Lists all charges +# Get Charge Transactions ```php -function getCharges( +function getChargeTransactions( + string $chargeId, ?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 + ?int $size = null +): ListChargeTransactionsResponse ``` ## 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 -[`ListChargesResponse`](../../doc/models/list-charges-response.md) +[`ListChargeTransactionsResponse`](../../doc/models/list-charge-transactions-response.md) ## Example Usage ```php -$result = $chargesController->getCharges(); +$chargeId = 'charge_id8'; + +$result = $chargesController->getChargeTransactions($chargeId); ``` -# Capture Charge +# Update Charge Card -Captures a charge +Updates the card from a charge ```php -function captureCharge( +function updateChargeCard( string $chargeId, - ?CreateCaptureChargeRequest $request = null, + UpdateChargeCardRequest $request, ?string $idempotencyKey = null ): GetChargeResponse ``` @@ -277,7 +206,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` | [`UpdateChargeCardRequest`](../../doc/models/update-charge-card-request.md) | Body, Required | Request for updating a charge's card | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -289,18 +218,64 @@ function captureCharge( ```php $chargeId = 'charge_id8'; -$result = $chargesController->captureCharge($chargeId); +$request = UpdateChargeCardRequestBuilder::init( + false, + 'card_id2', + CreateCardRequestBuilder::init() + ->type('credit') + ->build(), + false +)->build(); + +$result = $chargesController->updateChargeCard( + $chargeId, + $request +); ``` -# Update Charge Card +# Create Charge -Updates the card from a charge +Creates a new charge ```php -function updateChargeCard( +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); +``` + + +# Update Charge Payment Method + +Updates a charge's payment method + +```php +function updateChargePaymentMethod( string $chargeId, - UpdateChargeCardRequest $request, + UpdateChargePaymentMethodRequest $request, ?string $idempotencyKey = null ): GetChargeResponse ``` @@ -310,7 +285,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` | [`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 @@ -322,35 +297,77 @@ function updateChargeCard( ```php $chargeId = 'charge_id8'; -$request = UpdateChargeCardRequestBuilder::init( +$request = UpdateChargePaymentMethodRequestBuilder::init( false, - 'card_id2', - CreateCardRequestBuilder::init() - ->type('credit') + 'payment_method4', + CreateCreditCardPaymentRequestBuilder::init() + ->installments(1) + ->capture(true) + ->recurrencyCycle('"first" or "subsequent"') ->build(), - false + 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->updateChargeCard( +$result = $chargesController->updateChargePaymentMethod( $chargeId, $request ); ``` -# Get Charge +# Update Charge Due Date -Get a charge from its id +Updates the due date from a charge ```php -function getCharge(string $chargeId): GetChargeResponse +function updateChargeDueDate( + string $chargeId, + UpdateChargeDueDateRequest $request, + ?string $idempotencyKey = null +): GetChargeResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `chargeId` | `string` | Template, Required | Charge id | +| `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 @@ -361,7 +378,12 @@ function getCharge(string $chargeId): GetChargeResponse ```php $chargeId = 'charge_id8'; -$result = $chargesController->getCharge($chargeId); +$request = UpdateChargeDueDateRequestBuilder::init()->build(); + +$result = $chargesController->updateChargeDueDate( + $chargeId, + $request +); ``` @@ -424,79 +446,57 @@ $result = $chargesController->retryCharge($chargeId); ``` -# Cancel Charge +# Get Charges -Cancel a charge +Lists all charges ```php -function cancelCharge( - string $chargeId, - ?CreateCancelChargeRequest $request = null, - ?string $idempotencyKey = null -): GetChargeResponse +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 ``` ## Parameters | 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 | -| `idempotencyKey` | `?string` | Header, Optional | - | +| `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 -[`GetChargeResponse`](../../doc/models/get-charge-response.md) +[`ListChargesResponse`](../../doc/models/list-charges-response.md) ## Example Usage ```php -$chargeId = 'charge_id8'; - -$result = $chargesController->cancelCharge($chargeId); -``` - - -# Create Charge - -Creates a new charge - -```php -function createCharge(CreateChargeRequest $request, ?string $idempotencyKey = null): GetChargeResponse +$result = $chargesController->getCharges(); ``` -## 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); -``` +# Cancel Charge -# Confirm Payment +Cancel a charge ```php -function confirmPayment( +function cancelCharge( string $chargeId, - ?CreateConfirmPaymentRequest $request = null, + ?CreateCancelChargeRequest $request = null, ?string $idempotencyKey = null ): GetChargeResponse ``` @@ -505,8 +505,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` | [`?CreateCancelChargeRequest`](../../doc/models/create-cancel-charge-request.md) | Body, Optional | Request for cancelling a charge | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -518,6 +518,6 @@ function confirmPayment( ```php $chargeId = 'charge_id8'; -$result = $chargesController->confirmPayment($chargeId); +$result = $chargesController->cancelCharge($chargeId); ``` diff --git a/doc/controllers/customers.md b/doc/controllers/customers.md index 4679a21..0a4031e 100644 --- a/doc/controllers/customers.md +++ b/doc/controllers/customers.md @@ -10,40 +10,39 @@ $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) -* [Create Card](../../doc/controllers/customers.md#create-card) * [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) * [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) -# Update Card +# Create Address -Updates a card +Creates a new address for a customer ```php -function updateCard( +function createAddress( string $customerId, - string $cardId, - UpdateCardRequest $request, + CreateAddressRequest $request, ?string $idempotencyKey = null -): GetCardResponse +): GetAddressResponse ``` ## Parameters @@ -51,62 +50,49 @@ 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 | +| `request` | [`CreateAddressRequest`](../../doc/models/create-address-request.md) | Body, Required | Request for creating 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'; - -$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' +$request = CreateAddressRequestBuilder::init( + 'street6', + 'number4', + 'zip_code0', + 'neighborhood2', + 'city6', + 'state2', + 'country0', + 'complement2', + 'line_10', + 'line_24' )->build(); -$result = $customersController->updateCard( +$result = $customersController->createAddress( $customerId, - $cardId, $request ); ``` -# Update Address +# Update Card -Updates an address +Updates a card ```php -function updateAddress( +function updateCard( string $customerId, - string $addressId, - UpdateAddressRequest $request, + string $cardId, + UpdateCardRequest $request, ?string $idempotencyKey = null -): GetAddressResponse +): GetCardResponse ``` ## Parameters @@ -114,33 +100,46 @@ 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 | +| `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'; -$addressId = 'address_id0'; +$cardId = 'card_id4'; -$request = UpdateAddressRequestBuilder::init( - 'number4', - 'complement2', +$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' ], - 'line_24' + 'label6' )->build(); -$result = $customersController->updateAddress( +$result = $customersController->updateCard( $customerId, - $addressId, + $cardId, $request ); ``` @@ -234,16 +233,12 @@ $result = $customersController->createCustomer($request); ``` -# Create Address +# Delete Access Tokens -Creates a new address for a customer +Delete a Customer's access tokens ```php -function createAddress( - string $customerId, - CreateAddressRequest $request, - ?string $idempotencyKey = null -): GetAddressResponse +function deleteAccessTokens(string $customerId): ListAccessTokensResponse ``` ## Parameters @@ -251,44 +246,31 @@ 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 | -| `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'; -$request = CreateAddressRequestBuilder::init( - 'street6', - 'number4', - 'zip_code0', - 'neighborhood2', - 'city6', - 'state2', - 'country0', - 'complement2', - 'line_10', - 'line_24' -)->build(); - -$result = $customersController->createAddress( - $customerId, - $request -); +$result = $customersController->deleteAccessTokens($customerId); ``` -# Delete Access Tokens +# Update Address -Delete a Customer's access tokens +Updates an address ```php -function deleteAccessTokens(string $customerId): ListAccessTokensResponse +function updateAddress( + string $customerId, + string $addressId, + UpdateAddressRequest $request, + ?string $idempotencyKey = null +): GetAddressResponse ``` ## Parameters @@ -296,17 +278,35 @@ function deleteAccessTokens(string $customerId): ListAccessTokensResponse | 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 -[`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); +$addressId = 'address_id0'; + +$request = UpdateAddressRequestBuilder::init( + 'number4', + 'complement2', + [ + 'key0' => 'metadata3' + ], + 'line_24' +)->build(); + +$result = $customersController->updateAddress( + $customerId, + $addressId, + $request +); ``` @@ -381,46 +381,6 @@ $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 @@ -467,54 +427,41 @@ $result = $customersController->getCustomers( ``` -# Update Customer +# Get Access Tokens -Updates a customer +Get all access tokens from a customer ```php -function updateCustomer( - string $customerId, - UpdateCustomerRequest $request, - ?string $idempotencyKey = null -): GetCustomerResponse +function getAccessTokens(string $customerId, ?int $page = null, ?int $size = null): ListAccessTokensResponse ``` ## Parameters | 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 | -| `idempotencyKey` | `?string` | Header, Optional | - | +| `customerId` | `string` | Template, Required | Customer Id | +| `page` | `?int` | Query, Optional | Page number | +| `size` | `?int` | Query, Optional | Page size | ## Response Type -[`GetCustomerResponse`](../../doc/models/get-customer-response.md) +[`ListAccessTokensResponse`](../../doc/models/list-access-tokens-response.md) ## Example Usage ```php $customerId = 'customer_id8'; -$request = UpdateCustomerRequestBuilder::init()->build(); - -$result = $customersController->updateCustomer( - $customerId, - $request -); +$result = $customersController->getAccessTokens($customerId); ``` -# 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 @@ -522,160 +469,170 @@ 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 Access Tokens +# Get Card -Get all access tokens from a customer +Get a customer's card ```php -function getAccessTokens(string $customerId, ?int $page = null, ?int $size = null): ListAccessTokensResponse +function getCard(string $customerId, string $cardId): GetCardResponse ``` ## 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 | +| `cardId` | `string` | Template, Required | Card id | ## Response Type -[`ListAccessTokensResponse`](../../doc/models/list-access-tokens-response.md) +[`GetCardResponse`](../../doc/models/get-card-response.md) ## Example Usage ```php $customerId = 'customer_id8'; -$result = $customersController->getAccessTokens($customerId); +$cardId = 'card_id4'; + +$result = $customersController->getCard( + $customerId, + $cardId +); ``` -# Get Cards +# Create Card -Get all cards from a customer +Creates a new card for a customer ```php -function getCards(string $customerId, ?int $page = null, ?int $size = null): ListCardsResponse +function createCard( + string $customerId, + CreateCardRequest $request, + ?string $idempotencyKey = null +): GetCardResponse ``` ## 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` | [`CreateCardRequest`](../../doc/models/create-card-request.md) | Body, Required | Request for creating a card | +| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`ListCardsResponse`](../../doc/models/list-cards-response.md) +[`GetCardResponse`](../../doc/models/get-card-response.md) ## Example Usage ```php $customerId = 'customer_id8'; -$result = $customersController->getCards($customerId); +$request = CreateCardRequestBuilder::init() + ->type('credit') + ->build(); + +$result = $customersController->createCard( + $customerId, + $request +); ``` -# Renew Card +# Get Access Token -Renew a card +Get a Customer's access token ```php -function renewCard(string $customerId, string $cardId, ?string $idempotencyKey = null): GetCardResponse +function getAccessToken(string $customerId, string $tokenId): GetAccessTokenResponse ``` ## 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 | +| `tokenId` | `string` | Template, Required | Token Id | ## 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'; +$tokenId = 'token_id6'; -$result = $customersController->renewCard( +$result = $customersController->getAccessToken( $customerId, - $cardId + $tokenId ); ``` -# Get Access Token +# Get Addresses -Get a Customer's access token +Gets all adressess from a customer ```php -function getAccessToken(string $customerId, string $tokenId): GetAccessTokenResponse +function getAddresses(string $customerId, ?int $page = null, ?int $size = null): ListAddressesResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `customerId` | `string` | Template, Required | Customer Id | -| `tokenId` | `string` | Template, Required | Token Id | +| `customerId` | `string` | Template, Required | Customer id | +| `page` | `?int` | Query, Optional | Page number | +| `size` | `?int` | Query, Optional | Page size | ## Response Type -[`GetAccessTokenResponse`](../../doc/models/get-access-token-response.md) +[`ListAddressesResponse`](../../doc/models/list-addresses-response.md) ## Example Usage ```php $customerId = 'customer_id8'; -$tokenId = 'token_id6'; - -$result = $customersController->getAccessToken( - $customerId, - $tokenId -); +$result = $customersController->getAddresses($customerId); ``` -# Update Customer Metadata +# Update Customer -Updates the metadata a customer +Updates a customer ```php -function updateCustomerMetadata( +function updateCustomer( string $customerId, - UpdateMetadataRequest $request, + UpdateCustomerRequest $request, ?string $idempotencyKey = null ): GetCustomerResponse ``` @@ -684,8 +641,8 @@ function updateCustomerMetadata( | 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 | +| `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 @@ -697,25 +654,25 @@ function updateCustomerMetadata( ```php $customerId = 'customer_id8'; -$request = UpdateMetadataRequestBuilder::init( - [ - 'key0' => 'metadata3' - ] -)->build(); +$request = UpdateCustomerRequestBuilder::init()->build(); -$result = $customersController->updateCustomerMetadata( +$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 @@ -723,112 +680,155 @@ 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 Addresses +# Get Cards -Gets all adressess from a customer +Get all cards from a customer ```php -function getAddresses(string $customerId, ?int $page = null, ?int $size = null): ListAddressesResponse +function getCards(string $customerId, ?int $page = null, ?int $size = null): ListCardsResponse ``` ## 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 -[`ListAddressesResponse`](../../doc/models/list-addresses-response.md) +[`ListCardsResponse`](../../doc/models/list-cards-response.md) ## Example Usage ```php $customerId = 'customer_id8'; -$result = $customersController->getAddresses($customerId); +$result = $customersController->getCards($customerId); ``` -# Get Customer +# Renew Card -Get a customer +Renew a card ```php -function getCustomer(string $customerId): GetCustomerResponse +function renewCard(string $customerId, string $cardId, ?string $idempotencyKey = null): GetCardResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `customerId` | `string` | Template, Required | Customer Id | +| `customerId` | `string` | Template, Required | Customer id | +| `cardId` | `string` | Template, Required | Card Id | +| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`GetCustomerResponse`](../../doc/models/get-customer-response.md) +[`GetCardResponse`](../../doc/models/get-card-response.md) ## Example Usage ```php $customerId = 'customer_id8'; -$result = $customersController->getCustomer($customerId); +$cardId = 'card_id4'; + +$result = $customersController->renewCard( + $customerId, + $cardId +); ``` -# Get Card +# Update Customer Metadata -Get a customer's card +Updates the metadata a customer ```php -function getCard(string $customerId, string $cardId): GetCardResponse +function updateCustomerMetadata( + string $customerId, + UpdateMetadataRequest $request, + ?string $idempotencyKey = null +): GetCustomerResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `customerId` | `string` | Template, Required | Customer id | -| `cardId` | `string` | Template, Required | Card id | +| `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 -[`GetCardResponse`](../../doc/models/get-card-response.md) +[`GetCustomerResponse`](../../doc/models/get-customer-response.md) ## Example Usage ```php $customerId = 'customer_id8'; -$cardId = 'card_id4'; +$request = UpdateMetadataRequestBuilder::init( + [ + 'key0' => 'metadata3' + ] +)->build(); -$result = $customersController->getCard( +$result = $customersController->updateCustomerMetadata( $customerId, - $cardId + $request ); ``` + +# 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 4400978..bdc4068 100644 --- a/doc/controllers/invoices.md +++ b/doc/controllers/invoices.md @@ -10,68 +10,76 @@ $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) -# Update Invoice Metadata +# Get Invoices -Updates the metadata from an invoice +Gets all invoices ```php -function updateInvoiceMetadata( - string $invoiceId, - UpdateMetadataRequest $request, - ?string $idempotencyKey = null -): 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 | | --- | --- | --- | --- | -| `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 | - | +| `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 -$invoiceId = 'invoice_id0'; - -$request = UpdateMetadataRequestBuilder::init( - [ - 'key0' => 'metadata3' - ] -)->build(); - -$result = $invoicesController->updateInvoiceMetadata( - $invoiceId, - $request -); +$result = $invoicesController->getInvoices(); ``` -# Get Partial Invoice +# Cancel Invoice + +Cancels an invoice ```php -function getPartialInvoice(string $subscriptionId): GetInvoiceResponse +function cancelInvoice(string $invoiceId, ?string $idempotencyKey = null): GetInvoiceResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | Subscription Id | +| `invoiceId` | `string` | Template, Required | Invoice id | +| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -80,25 +88,30 @@ function getPartialInvoice(string $subscriptionId): GetInvoiceResponse ## Example Usage ```php -$subscriptionId = 'subscription_id0'; +$invoiceId = 'invoice_id0'; -$result = $invoicesController->getPartialInvoice($subscriptionId); +$result = $invoicesController->cancelInvoice($invoiceId); ``` -# Cancel Invoice +# Update Invoice Status -Cancels an invoice +Updates the status from an invoice ```php -function cancelInvoice(string $invoiceId, ?string $idempotencyKey = null): GetInvoiceResponse +function updateInvoiceStatus( + string $invoiceId, + UpdateInvoiceStatusRequest $request, + ?string $idempotencyKey = null +): GetInvoiceResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `invoiceId` | `string` | Template, Required | Invoice id | +| `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 @@ -110,19 +123,25 @@ function cancelInvoice(string $invoiceId, ?string $idempotencyKey = null): GetIn ```php $invoiceId = 'invoice_id0'; -$result = $invoicesController->cancelInvoice($invoiceId); +$request = UpdateInvoiceStatusRequestBuilder::init( + 'status8' +)->build(); + +$result = $invoicesController->updateInvoiceStatus( + $invoiceId, + $request +); ``` -# Create Invoice +# Update Invoice Metadata -Create an Invoice +Updates the metadata from an invoice ```php -function createInvoice( - string $subscriptionId, - string $cycleId, - ?CreateInvoiceRequest $request = null, +function updateInvoiceMetadata( + string $invoiceId, + UpdateMetadataRequest $request, ?string $idempotencyKey = null ): GetInvoiceResponse ``` @@ -131,9 +150,8 @@ function createInvoice( | 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 | - | +| `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 @@ -143,77 +161,67 @@ function createInvoice( ## Example Usage ```php -$subscriptionId = 'subscription_id0'; +$invoiceId = 'invoice_id0'; -$cycleId = 'cycle_id6'; +$request = UpdateMetadataRequestBuilder::init( + [ + 'key0' => 'metadata3' + ] +)->build(); -$result = $invoicesController->createInvoice( - $subscriptionId, - $cycleId +$result = $invoicesController->updateInvoiceMetadata( + $invoiceId, + $request ); ``` -# Get Invoices - -Gets all invoices +# Get Partial 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 getPartialInvoice(string $subscriptionId): 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 | - | +| `subscriptionId` | `string` | Template, Required | Subscription Id | ## Response Type -[`ListInvoicesResponse`](../../doc/models/list-invoices-response.md) +[`GetInvoiceResponse`](../../doc/models/get-invoice-response.md) ## Example Usage ```php -$result = $invoicesController->getInvoices(); +$subscriptionId = 'subscription_id0'; + +$result = $invoicesController->getPartialInvoice($subscriptionId); ``` -# Get Invoice +# Create Invoice -Gets an invoice +Create an Invoice ```php -function getInvoice(string $invoiceId): GetInvoiceResponse +function createInvoice( + string $subscriptionId, + string $cycleId, + ?CreateInvoiceRequest $request = null, + ?string $idempotencyKey = null +): GetInvoiceResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `invoiceId` | `string` | Template, Required | Invoice Id | +| `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 @@ -222,22 +230,23 @@ function getInvoice(string $invoiceId): GetInvoiceResponse ## Example Usage ```php -$invoiceId = 'invoice_id0'; +$subscriptionId = 'subscription_id0'; -$result = $invoicesController->getInvoice($invoiceId); +$cycleId = 'cycle_id6'; + +$result = $invoicesController->createInvoice( + $subscriptionId, + $cycleId +); ``` -# Update Invoice Status +# Get Invoice -Updates the status from an invoice +Gets an invoice ```php -function updateInvoiceStatus( - string $invoiceId, - UpdateInvoiceStatusRequest $request, - ?string $idempotencyKey = null -): GetInvoiceResponse +function getInvoice(string $invoiceId): GetInvoiceResponse ``` ## Parameters @@ -245,8 +254,6 @@ function updateInvoiceStatus( | 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 @@ -257,13 +264,6 @@ function updateInvoiceStatus( ```php $invoiceId = 'invoice_id0'; -$request = UpdateInvoiceStatusRequestBuilder::init( - 'status8' -)->build(); - -$result = $invoicesController->updateInvoiceStatus( - $invoiceId, - $request -); +$result = $invoicesController->getInvoice($invoiceId); ``` diff --git a/doc/controllers/orders.md b/doc/controllers/orders.md index d14ef43..ac90fa1 100644 --- a/doc/controllers/orders.md +++ b/doc/controllers/orders.md @@ -10,66 +10,48 @@ $ordersController = $client->getOrdersController(); ## Methods -* [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) +* [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) * [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) -# Get Orders - -Gets all orders +# Delete All Order Items ```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 +function deleteAllOrderItems(string $orderId, ?string $idempotencyKey = null): GetOrderResponse ``` ## 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 | +| `orderId` | `string` | Template, Required | Order Id | +| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`ListOrderResponse`](../../doc/models/list-order-response.md) +[`GetOrderResponse`](../../doc/models/get-order-response.md) ## Example Usage ```php -$result = $ordersController->getOrders(); +$orderId = 'orderId2'; + +$result = $ordersController->deleteAllOrderItems($orderId); ``` -# Update Order Item +# Get Order Item ```php -function updateOrderItem( - string $orderId, - string $itemId, - UpdateOrderItemRequest $request, - ?string $idempotencyKey = null -): GetOrderItemResponse +function getOrderItem(string $orderId, string $itemId): GetOrderItemResponse ``` ## Parameters @@ -78,8 +60,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 @@ -92,32 +72,31 @@ $orderId = 'orderId2'; $itemId = 'itemId8'; -$request = UpdateOrderItemRequestBuilder::init( - 242, - 'description6', - 100, - 'category4' -)->build(); - -$result = $ordersController->updateOrderItem( +$result = $ordersController->getOrderItem( $orderId, - $itemId, - $request + $itemId ); ``` -# Delete All Order Items +# Update Order Metadata + +Updates the metadata from an order ```php -function deleteAllOrderItems(string $orderId, ?string $idempotencyKey = null): GetOrderResponse +function updateOrderMetadata( + string $orderId, + UpdateMetadataRequest $request, + ?string $idempotencyKey = null +): GetOrderResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `orderId` | `string` | Template, Required | Order Id | +| `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 @@ -127,9 +106,18 @@ function deleteAllOrderItems(string $orderId, ?string $idempotencyKey = null): G ## Example Usage ```php -$orderId = 'orderId2'; +$orderId = 'order_id6'; -$result = $ordersController->deleteAllOrderItems($orderId); +$request = UpdateMetadataRequestBuilder::init( + [ + 'key0' => 'metadata3' + ] +)->build(); + +$result = $ordersController->updateOrderMetadata( + $orderId, + $request +); ``` @@ -165,6 +153,118 @@ $result = $ordersController->deleteOrderItem( ``` +# 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 + +```php +$result = $ordersController->getOrders(); +``` + + +# Update Order Item + +```php +function updateOrderItem( + string $orderId, + string $itemId, + UpdateOrderItemRequest $request, + ?string $idempotencyKey = null +): GetOrderItemResponse +``` + +## Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `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 + +[`GetOrderItemResponse`](../../doc/models/get-order-item-response.md) + +## Example Usage + +```php +$orderId = 'orderId2'; + +$itemId = 'itemId8'; + +$request = UpdateOrderItemRequestBuilder::init( + 242, + 'description6', + 100, + 'category4' +)->build(); + +$result = $ordersController->updateOrderItem( + $orderId, + $itemId, + $request +); +``` + + # Close Order ```php @@ -310,103 +410,3 @@ $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 f2be784..993dd00 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](../../doc/controllers/plans.md#delete-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 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 +# Delete Plan Item -Deletes a plan +Removes an item from a plan ```php -function deletePlan(string $planId, ?string $idempotencyKey = null): GetPlanResponse +function deletePlanItem(string $planId, string $planItemId, ?string $idempotencyKey = null): GetPlanItemResponse ``` ## Parameters @@ -62,18 +62,24 @@ function deletePlan(string $planId, ?string $idempotencyKey = null): GetPlanResp | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `planId` | `string` | Template, Required | Plan id | +| `planItemId` | `string` | Template, Required | Plan item id | | `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'; -$result = $plansController->deletePlan($planId); +$planItemId = 'plan_item_id0'; + +$result = $plansController->deletePlanItem( + $planId, + $planItemId +); ``` @@ -119,72 +125,76 @@ $result = $plansController->updatePlanMetadata( ``` -# Update Plan Item +# Create Plan -Updates a plan item +Creates a new plan ```php -function updatePlanItem( - string $planId, - string $planItemId, - UpdatePlanItemRequest $body, - ?string $idempotencyKey = null -): GetPlanItemResponse +function createPlan(CreatePlanRequest $body, ?string $idempotencyKey = null): GetPlanResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `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 | +| `body` | [`CreatePlanRequest`](../../doc/models/create-plan-request.md) | Body, Required | Request for creating 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'; - -$body = UpdatePlanItemRequestBuilder::init( +$body = CreatePlanRequestBuilder::init( 'name6', 'description4', - 'status2', - UpdatePricingSchemeRequestBuilder::init( - 'scheme_type8', - [ - UpdatePriceBracketRequestBuilder::init( - 144, - 174 - )->build() - ] - )->build() + '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->updatePlanItem( - $planId, - $planItemId, - $body -); +$result = $plansController->createPlan($body); ``` -# Create Plan Item +# Update Plan -Adds a new item to a plan +Updates a plan ```php -function createPlanItem( - string $planId, - CreatePlanItemRequest $request, - ?string $idempotencyKey = null -): GetPlanItemResponse +function updatePlan(string $planId, UpdatePlanRequest $request, ?string $idempotencyKey = null): GetPlanResponse ``` ## Parameters @@ -192,40 +202,58 @@ function createPlanItem( | 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 | +| `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'; -$request = CreatePlanItemRequestBuilder::init( +$request = UpdatePlanRequestBuilder::init( 'name6', - CreatePricingSchemeRequestBuilder::init( - 'scheme_type8' - )->build(), - 'id6', - 'description6' + 'description6', + [ + 151, + 152 + ], + 'statement_descriptor6', + 'currency6', + 'interval4', + 114, + [ + 'payment_methods1', + 'payment_methods0', + 'payment_methods9' + ], + 'billing_type0', + 'status8', + false, + [ + 115 + ], + [ + 'key0' => 'metadata3' + ] )->build(); -$result = $plansController->createPlanItem( +$result = $plansController->updatePlan( $planId, $request ); ``` -# Get Plan Item +# Delete Plan -Gets a plan item +Deletes a plan ```php -function getPlanItem(string $planId, string $planItemId): GetPlanItemResponse +function deletePlan(string $planId, ?string $idempotencyKey = null): GetPlanResponse ``` ## Parameters @@ -233,96 +261,71 @@ function getPlanItem(string $planId, string $planItemId): GetPlanItemResponse | 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->getPlanItem( - $planId, - $planItemId -); +$result = $plansController->deletePlan($planId); ``` -# Create Plan +# Get Plans -Creates a new plan +Gets all plans ```php -function createPlan(CreatePlanRequest $body, ?string $idempotencyKey = null): GetPlanResponse +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 | | --- | --- | --- | --- | -| `body` | [`CreatePlanRequest`](../../doc/models/create-plan-request.md) | Body, Required | Request for creating a plan | -| `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 -[`GetPlanResponse`](../../doc/models/get-plan-response.md) +[`ListPlansResponse`](../../doc/models/list-plans-response.md) ## Example Usage ```php -$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); +$result = $plansController->getPlans(); ``` -# Delete Plan Item +# Update Plan Item -Removes an item from a plan +Updates a plan item ```php -function deletePlanItem(string $planId, string $planItemId, ?string $idempotencyKey = null): GetPlanItemResponse +function updatePlanItem( + string $planId, + string $planItemId, + UpdatePlanItemRequest $body, + ?string $idempotencyKey = null +): GetPlanItemResponse ``` ## Parameters @@ -331,6 +334,7 @@ function deletePlanItem(string $planId, string $planItemId, ?string $idempotency | --- | --- | --- | --- | | `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 @@ -344,58 +348,80 @@ $planId = 'plan_id8'; $planItemId = 'plan_item_id0'; -$result = $plansController->deletePlanItem( +$body = UpdatePlanItemRequestBuilder::init( + 'name6', + 'description4', + 'status2', + UpdatePricingSchemeRequestBuilder::init( + 'scheme_type8', + [ + UpdatePriceBracketRequestBuilder::init( + 144, + 174 + )->build() + ] + )->build() +)->build(); + +$result = $plansController->updatePlanItem( $planId, - $planItemId + $planItemId, + $body ); ``` -# Get Plans +# Create Plan Item -Gets all plans +Adds a new item to a 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 createPlanItem( + string $planId, + CreatePlanItemRequest $request, + ?string $idempotencyKey = null +): GetPlanItemResponse ``` ## 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 | +| `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 | - | ## Response Type -[`ListPlansResponse`](../../doc/models/list-plans-response.md) +[`GetPlanItemResponse`](../../doc/models/get-plan-item-response.md) ## Example Usage ```php -$result = $plansController->getPlans(); +$planId = 'plan_id8'; + +$request = CreatePlanItemRequestBuilder::init( + 'name6', + CreatePricingSchemeRequestBuilder::init( + 'scheme_type8' + )->build(), + 'id6', + 'description6' +)->build(); + +$result = $plansController->createPlanItem( + $planId, + $request +); ``` -# Update Plan +# Get Plan Item -Updates a plan +Gets a plan item ```php -function updatePlan(string $planId, UpdatePlanRequest $request, ?string $idempotencyKey = null): GetPlanResponse +function getPlanItem(string $planId, string $planItemId): GetPlanItemResponse ``` ## Parameters @@ -403,48 +429,22 @@ 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 | -| `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'; -$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(); +$planItemId = 'plan_item_id0'; -$result = $plansController->updatePlan( +$result = $plansController->getPlanItem( $planId, - $request + $planItemId ); ``` diff --git a/doc/controllers/recipients.md b/doc/controllers/recipients.md index b81d63f..580348e 100644 --- a/doc/controllers/recipients.md +++ b/doc/controllers/recipients.md @@ -11,26 +11,26 @@ $recipientsController = $client->getRecipientsController(); ## Methods * [Update Recipient](../../doc/controllers/recipients.md#update-recipient) -* [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) +* [Get Recipient](../../doc/controllers/recipients.md#get-recipient) +* [Get Balance](../../doc/controllers/recipients.md#get-balance) +* [Get Recipients](../../doc/controllers/recipients.md#get-recipients) * [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 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) +* [Get Recipient by Code](../../doc/controllers/recipients.md#get-recipient-by-code) +* [Update Automatic Anticipation Settings](../../doc/controllers/recipients.md#update-automatic-anticipation-settings) * [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) @@ -81,143 +81,114 @@ $result = $recipientsController->updateRecipient( ``` -# Create Anticipation - -Creates an anticipation +# Get Withdraw by Id ```php -function createAnticipation( - string $recipientId, - CreateAnticipationRequest $request, - ?string $idempotencyKey = null -): GetAnticipationResponse +function getWithdrawById(string $recipientId, string $withdrawalId): GetWithdrawResponse ``` ## 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 | - | +| `recipientId` | `string` | Template, Required | - | +| `withdrawalId` | `string` | Template, Required | - | ## Response Type -[`GetAnticipationResponse`](../../doc/models/get-anticipation-response.md) +[`GetWithdrawResponse`](../../doc/models/get-withdraw-response.md) ## Example Usage ```php $recipientId = 'recipient_id0'; -$request = CreateAnticipationRequestBuilder::init( - 242, - 'timeframe8', - DateTimeHelper::fromRfc3339DateTimeRequired('2016-03-13T12:52:32.123Z') -)->build(); +$withdrawalId = 'withdrawal_id2'; -$result = $recipientsController->createAnticipation( +$result = $recipientsController->getWithdrawById( $recipientId, - $request + $withdrawalId ); ``` -# Get Anticipation Limits +# Get Recipient -Gets the anticipation limits for a recipient +Retrieves recipient information ```php -function getAnticipationLimits( - string $recipientId, - string $timeframe, - \DateTime $paymentDate -): GetAnticipationLimitResponse +function getRecipient(string $recipientId): GetRecipientResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `recipientId` | `string` | Template, Required | Recipient id | -| `timeframe` | `string` | Query, Required | Timeframe | -| `paymentDate` | `DateTime` | Query, Required | Anticipation payment date | +| `recipientId` | `string` | Template, Required | Recipiend id | ## Response Type -[`GetAnticipationLimitResponse`](../../doc/models/get-anticipation-limit-response.md) +[`GetRecipientResponse`](../../doc/models/get-recipient-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 -); +$result = $recipientsController->getRecipient($recipientId); ``` -# Get Recipients +# Get Balance -Retrieves paginated recipients information +Get balance information for a recipient ```php -function getRecipients(?int $page = null, ?int $size = null): ListRecipientResponse +function getBalance(string $recipientId): GetBalanceResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `page` | `?int` | Query, Optional | Page number | -| `size` | `?int` | Query, Optional | Page size | +| `recipientId` | `string` | Template, Required | Recipient id | ## Response Type -[`ListRecipientResponse`](../../doc/models/list-recipient-response.md) +[`GetBalanceResponse`](../../doc/models/get-balance-response.md) ## Example Usage ```php -$result = $recipientsController->getRecipients(); +$recipientId = 'recipient_id0'; + +$result = $recipientsController->getBalance($recipientId); ``` -# Get Withdraw by Id +# Get Recipients + +Retrieves paginated recipients information ```php -function getWithdrawById(string $recipientId, string $withdrawalId): GetWithdrawResponse +function getRecipients(?int $page = null, ?int $size = null): ListRecipientResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `recipientId` | `string` | Template, Required | - | -| `withdrawalId` | `string` | Template, Required | - | +| `page` | `?int` | Query, Optional | Page number | +| `size` | `?int` | Query, Optional | Page size | ## Response Type -[`GetWithdrawResponse`](../../doc/models/get-withdraw-response.md) +[`ListRecipientResponse`](../../doc/models/list-recipient-response.md) ## Example Usage ```php -$recipientId = 'recipient_id0'; - -$withdrawalId = 'withdrawal_id2'; - -$result = $recipientsController->getWithdrawById( - $recipientId, - $withdrawalId -); +$result = $recipientsController->getRecipients(); ``` @@ -275,48 +246,6 @@ $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 @@ -422,44 +351,6 @@ $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 @@ -533,64 +424,19 @@ $result = $recipientsController->updateRecipientTransferSettings( ``` -# 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 +# Get Recipient by Code Retrieves recipient information ```php -function getRecipient(string $recipientId): GetRecipientResponse +function getRecipientByCode(string $code): GetRecipientResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `recipientId` | `string` | Template, Required | Recipiend id | +| `code` | `string` | Template, Required | Recipient code | ## Response Type @@ -599,18 +445,22 @@ function getRecipient(string $recipientId): GetRecipientResponse ## Example Usage ```php -$recipientId = 'recipient_id0'; +$code = 'code8'; -$result = $recipientsController->getRecipient($recipientId); +$result = $recipientsController->getRecipientByCode($code); ``` -# Get Balance +# Update Automatic Anticipation Settings -Get balance information for a recipient +Updates recipient metadata ```php -function getBalance(string $recipientId): GetBalanceResponse +function updateAutomaticAnticipationSettings( + string $recipientId, + UpdateAutomaticAnticipationSettingsRequest $request, + ?string $idempotencyKey = null +): GetRecipientResponse ``` ## Parameters @@ -618,56 +468,24 @@ function getBalance(string $recipientId): GetBalanceResponse | 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 -[`GetBalanceResponse`](../../doc/models/get-balance-response.md) +[`GetRecipientResponse`](../../doc/models/get-recipient-response.md) ## Example Usage ```php $recipientId = 'recipient_id0'; -$result = $recipientsController->getBalance($recipientId); -``` - - -# 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'; +$request = UpdateAutomaticAnticipationSettingsRequestBuilder::init()->build(); -$result = $recipientsController->getWithdrawals($recipientId); +$result = $recipientsController->updateAutomaticAnticipationSettings( + $recipientId, + $request +); ``` @@ -763,39 +581,126 @@ $result = $recipientsController->createRecipient($request); ``` -# Get Recipient by Code +# Get Default Recipient -Retrieves recipient information +```php +function getDefaultRecipient(): GetRecipientResponse +``` + +## Response Type + +[`GetRecipientResponse`](../../doc/models/get-recipient-response.md) + +## Example Usage ```php -function getRecipientByCode(string $code): GetRecipientResponse +$result = $recipientsController->getDefaultRecipient(); +``` + + +# Create Anticipation + +Creates an anticipation + +```php +function createAnticipation( + string $recipientId, + CreateAnticipationRequest $request, + ?string $idempotencyKey = null +): GetAnticipationResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `code` | `string` | Template, Required | Recipient code | +| `recipientId` | `string` | Template, Required | Recipient id | +| `request` | [`CreateAnticipationRequest`](../../doc/models/create-anticipation-request.md) | Body, Required | Anticipation data | +| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`GetRecipientResponse`](../../doc/models/get-recipient-response.md) +[`GetAnticipationResponse`](../../doc/models/get-anticipation-response.md) ## Example Usage ```php -$code = 'code8'; +$recipientId = 'recipient_id0'; -$result = $recipientsController->getRecipientByCode($code); +$request = CreateAnticipationRequestBuilder::init( + 242, + 'timeframe8', + DateTimeHelper::fromRfc3339DateTimeRequired('2016-03-13T12:52:32.123Z') +)->build(); + +$result = $recipientsController->createAnticipation( + $recipientId, + $request +); ``` -# Get Default Recipient +# Get Anticipation Limits + +Gets the anticipation limits for a recipient ```php -function getDefaultRecipient(): GetRecipientResponse +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 + +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) @@ -803,7 +708,102 @@ function getDefaultRecipient(): GetRecipientResponse ## Example Usage ```php -$result = $recipientsController->getDefaultRecipient(); +$recipientId = 'recipient_id0'; + +$request = UpdateMetadataRequestBuilder::init( + [ + 'key0' => 'metadata3' + ] +)->build(); + +$result = $recipientsController->updateRecipientMetadata( + $recipientId, + $request +); +``` + + +# 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 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); ``` @@ -819,7 +819,7 @@ function createKYCLink(string $recipientId): CreateKYCLinkResponse | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `recipientId` | `string` | Template, Required | - | +| `recipientId` | `string` | Template, Required | Recipient id | ## Response Type diff --git a/doc/controllers/subscriptions.md b/doc/controllers/subscriptions.md index cc41c0d..86ec72d 100644 --- a/doc/controllers/subscriptions.md +++ b/doc/controllers/subscriptions.md @@ -10,68 +10,42 @@ $subscriptionsController = $client->getSubscriptionsController(); ## Methods -* [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) +* [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) -* [Get Subscription Items](../../doc/controllers/subscriptions.md#get-subscription-items) * [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) +* [Delete Usage](../../doc/controllers/subscriptions.md#delete-usage) +* [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) +* [Get Subscription Items](../../doc/controllers/subscriptions.md#get-subscription-items) * [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 @@ -117,49 +91,6 @@ $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 @@ -202,88 +133,92 @@ $result = $subscriptionsController->createDiscount( ``` -# Create an Usage +# Update Subscription Billing Date -Create Usage +Updates the billing date from a subscription ```php -function createAnUsage(string $subscriptionId, string $itemId, ?string $idempotencyKey = null): GetUsageResponse +function updateSubscriptionBillingDate( + string $subscriptionId, + UpdateSubscriptionBillingDateRequest $request, + ?string $idempotencyKey = null +): GetSubscriptionResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | Subscription id | -| `itemId` | `string` | Template, Required | Item id | +| `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 -[`GetUsageResponse`](../../doc/models/get-usage-response.md) +[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$itemId = 'item_id0'; +$request = UpdateSubscriptionBillingDateRequestBuilder::init( + DateTimeHelper::fromRfc3339DateTimeRequired('2016-03-13T12:52:32.123Z') +)->build(); -$result = $subscriptionsController->createAnUsage( +$result = $subscriptionsController->updateSubscriptionBillingDate( $subscriptionId, - $itemId + $request ); ``` -# Update Current Cycle Status +# Update Subscription Start At + +Updates the start at date from a subscription ```php -function updateCurrentCycleStatus( +function updateSubscriptionStartAt( string $subscriptionId, - UpdateCurrentCycleStatusRequest $request, + UpdateSubscriptionStartAtRequest $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` | [`UpdateSubscriptionStartAtRequest`](../../doc/models/update-subscription-start-at-request.md) | Body, Required | Request for updating the subscription start 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 = UpdateSubscriptionStartAtRequestBuilder::init( + DateTimeHelper::fromRfc3339DateTimeRequired('2016-03-13T12:52:32.123Z') )->build(); -$subscriptionsController->updateCurrentCycleStatus( +$result = $subscriptionsController->updateSubscriptionStartAt( $subscriptionId, $request ); ``` -# Delete Discount +# Get Subscription -Deletes a discount +Gets a subscription ```php -function deleteDiscount( - string $subscriptionId, - string $discountId, - ?string $idempotencyKey = null -): GetDiscountResponse +function getSubscription(string $subscriptionId): GetSubscriptionResponse ``` ## Parameters @@ -291,43 +226,35 @@ function deleteDiscount( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `subscriptionId` | `string` | Template, Required | Subscription id | -| `discountId` | `string` | Template, Required | Discount Id | -| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`GetDiscountResponse`](../../doc/models/get-discount-response.md) +[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$discountId = 'discount_id8'; - -$result = $subscriptionsController->deleteDiscount( - $subscriptionId, - $discountId -); +$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 @@ -335,36 +262,38 @@ 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 | +| `group` | `?string` | Query, Optional | Identification group in the client system | +| `usedSince` | `?DateTime` | Query, Optional | - | +| `usedUntil` | `?DateTime` | Query, Optional | - | ## Response Type -[`ListSubscriptionItemsResponse`](../../doc/models/list-subscription-items-response.md) +[`ListUsagesResponse`](../../doc/models/list-usages-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$result = $subscriptionsController->getSubscriptionItems($subscriptionId); -``` +$itemId = 'item_id0'; +$result = $subscriptionsController->getUsages( + $subscriptionId, + $itemId +); +``` -# Update Subscription Payment Method -Updates the payment method from a subscription +# Update Latest Period End At ```php -function updateSubscriptionPaymentMethod( +function updateLatestPeriodEndAt( string $subscriptionId, - UpdateSubscriptionPaymentMethodRequest $request, + UpdateCurrentCycleEndDateRequest $request, ?string $idempotencyKey = null ): GetSubscriptionResponse ``` @@ -373,8 +302,8 @@ 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 | +| `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 @@ -386,111 +315,61 @@ function updateSubscriptionPaymentMethod( ```php $subscriptionId = 'subscription_id0'; -$request = UpdateSubscriptionPaymentMethodRequestBuilder::init( - 'payment_method4', - 'card_id2', - CreateCardRequestBuilder::init() - ->type('credit') - ->build() -)->build(); +$request = UpdateCurrentCycleEndDateRequestBuilder::init()->build(); -$result = $subscriptionsController->updateSubscriptionPaymentMethod( +$result = $subscriptionsController->updateLatestPeriodEndAt( $subscriptionId, $request ); ``` -# Get Subscription Item +# Delete Discount -Get Subscription Item +Deletes a discount ```php -function getSubscriptionItem(string $subscriptionId, string $itemId): GetSubscriptionItemResponse +function deleteDiscount( + string $subscriptionId, + string $discountId, + ?string $idempotencyKey = null +): GetDiscountResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | Subscription Id | -| `itemId` | `string` | Template, Required | Item id | +| `subscriptionId` | `string` | Template, Required | Subscription id | +| `discountId` | `string` | Template, Required | Discount Id | +| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`GetSubscriptionItemResponse`](../../doc/models/get-subscription-item-response.md) +[`GetDiscountResponse`](../../doc/models/get-discount-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$itemId = 'item_id0'; +$discountId = 'discount_id8'; -$result = $subscriptionsController->getSubscriptionItem( +$result = $subscriptionsController->deleteDiscount( $subscriptionId, - $itemId + $discountId ); ``` -# 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(); -``` - - -# Cancel Subscription +# Update Subscription Payment Method -Cancels a subscription +Updates the payment method from a subscription ```php -function cancelSubscription( +function updateSubscriptionPaymentMethod( string $subscriptionId, - ?CreateCancelSubscriptionRequest $request = null, + UpdateSubscriptionPaymentMethodRequest $request, ?string $idempotencyKey = null ): GetSubscriptionResponse ``` @@ -500,7 +379,7 @@ 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` | [`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 @@ -512,27 +391,31 @@ function cancelSubscription( ```php $subscriptionId = 'subscription_id0'; -$request = CreateCancelSubscriptionRequestBuilder::init( - true +$request = UpdateSubscriptionPaymentMethodRequestBuilder::init( + 'payment_method4', + 'card_id2', + CreateCardRequestBuilder::init() + ->type('credit') + ->build() )->build(); -$result = $subscriptionsController->cancelSubscription( +$result = $subscriptionsController->updateSubscriptionPaymentMethod( $subscriptionId, $request ); ``` -# Create Increment +# Cancel Subscription -Creates a increment +Cancels a subscription ```php -function createIncrement( +function cancelSubscription( string $subscriptionId, - CreateIncrementRequest $request, + ?CreateCancelSubscriptionRequest $request = null, ?string $idempotencyKey = null -): GetIncrementResponse +): GetSubscriptionResponse ``` ## Parameters @@ -540,109 +423,29 @@ function createIncrement( | 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 | +| `request` | [`?CreateCancelSubscriptionRequest`](../../doc/models/create-cancel-subscription-request.md) | Body, Optional | Request for cancelling a subscription | | `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'; -$request = CreateIncrementRequestBuilder::init( - 185.28, - 'increment_type8', - 'item_id6' +$request = CreateCancelSubscriptionRequestBuilder::init( + true )->build(); -$result = $subscriptionsController->createIncrement( +$result = $subscriptionsController->cancelSubscription( $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 @@ -768,37 +571,6 @@ $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 @@ -837,14 +609,14 @@ $result = $subscriptionsController->updateSubscriptionAffiliationId( ``` -# 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 ``` @@ -853,8 +625,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 @@ -866,96 +638,114 @@ function updateSubscriptionMetadata( ```php $subscriptionId = 'subscription_id0'; -$request = UpdateMetadataRequestBuilder::init( - [ - 'key0' => 'metadata3' - ] -)->build(); +$request = UpdateSubscriptionMinimumPriceRequestBuilder::init()->build(); -$result = $subscriptionsController->updateSubscriptionMetadata( +$result = $subscriptionsController->updateSubscriptionMiniumPrice( $subscriptionId, $request ); ``` -# Delete Increment - -Deletes a increment +# Get Subscription Cycle by Id ```php -function deleteIncrement( - string $subscriptionId, - string $incrementId, - ?string $idempotencyKey = null -): GetIncrementResponse +function getSubscriptionCycleById(string $subscriptionId, string $cycleId): GetPeriodResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | Subscription id | -| `incrementId` | `string` | Template, Required | Increment id | -| `idempotencyKey` | `?string` | Header, Optional | - | +| `subscriptionId` | `string` | Template, Required | The subscription id | +| `cycleId` | `string` | Template, Required | - | ## Response Type -[`GetIncrementResponse`](../../doc/models/get-increment-response.md) +[`GetPeriodResponse`](../../doc/models/get-period-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$incrementId = 'increment_id8'; +$cycleId = 'cycleId0'; -$result = $subscriptionsController->deleteIncrement( +$result = $subscriptionsController->getSubscriptionCycleById( $subscriptionId, - $incrementId + $cycleId ); ``` -# Get Subscription Cycles +# Get Usage Report ```php -function getSubscriptionCycles(string $subscriptionId, string $page, string $size): ListCyclesResponse +function getUsageReport(string $subscriptionId, string $periodId): GetUsageReportResponse ``` ## 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 | +| `periodId` | `string` | Template, Required | The period Id | ## Response Type -[`ListCyclesResponse`](../../doc/models/list-cycles-response.md) +[`GetUsageReportResponse`](../../doc/models/get-usage-report-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$page = 'page8'; - -$size = 'size0'; +$periodId = 'period_id0'; -$result = $subscriptionsController->getSubscriptionCycles( +$result = $subscriptionsController->getUsageReport( $subscriptionId, - $page, - $size + $periodId ); ``` -# Get Discounts +# Renew Subscription ```php -function getDiscounts(string $subscriptionId, int $page, int $size): ListDiscountsResponse +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 + +```php +function deleteUsage( + string $subscriptionId, + string $itemId, + string $usageId, + ?string $idempotencyKey = null +): GetUsageResponse ``` ## Parameters @@ -963,89 +753,117 @@ 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 | +| `itemId` | `string` | Template, Required | The subscription item id | +| `usageId` | `string` | Template, Required | The usage id | +| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`ListDiscountsResponse`](../../doc/models/list-discounts-response.md) +[`GetUsageResponse`](../../doc/models/get-usage-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$page = 30; +$itemId = 'item_id0'; -$size = 18; +$usageId = 'usage_id0'; -$result = $subscriptionsController->getDiscounts( +$result = $subscriptionsController->deleteUsage( $subscriptionId, - $page, - $size + $itemId, + $usageId ); ``` -# Update Subscription Billing Date +# Create an Usage -Updates the billing date from a subscription +Create Usage ```php -function updateSubscriptionBillingDate( +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 Current Cycle Status + +```php +function updateCurrentCycleStatus( string $subscriptionId, - UpdateSubscriptionBillingDateRequest $request, + UpdateCurrentCycleStatusRequest $request, ?string $idempotencyKey = null -): GetSubscriptionResponse +): void ``` ## 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 | +| `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 = UpdateSubscriptionBillingDateRequestBuilder::init( - DateTimeHelper::fromRfc3339DateTimeRequired('2016-03-13T12:52:32.123Z') +$request = UpdateCurrentCycleStatusRequestBuilder::init( + 'status8' )->build(); -$result = $subscriptionsController->updateSubscriptionBillingDate( +$subscriptionsController->updateCurrentCycleStatus( $subscriptionId, $request ); ``` -# Delete Subscription Item +# Get Subscription Item -Deletes a subscription item +Get Subscription Item ```php -function deleteSubscriptionItem( - string $subscriptionId, - string $subscriptionItemId, - ?string $idempotencyKey = null -): GetSubscriptionItemResponse +function getSubscriptionItem(string $subscriptionId, string $itemId): GetSubscriptionItemResponse ``` ## 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 | Subscription Id | +| `itemId` | `string` | Template, Required | Item id | ## Response Type @@ -1056,92 +874,88 @@ function deleteSubscriptionItem( ```php $subscriptionId = 'subscription_id0'; -$subscriptionItemId = 'subscription_item_id4'; +$itemId = 'item_id0'; -$result = $subscriptionsController->deleteSubscriptionItem( +$result = $subscriptionsController->getSubscriptionItem( $subscriptionId, - $subscriptionItemId + $itemId ); ``` -# Get Increments +# Get Increment by Id ```php -function getIncrements(string $subscriptionId, ?int $page = null, ?int $size = null): ListIncrementsResponse +function getIncrementById(string $subscriptionId, string $incrementId): GetIncrementResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | The subscription id | -| `page` | `?int` | Query, Optional | Page number | -| `size` | `?int` | Query, Optional | Page size | +| `subscriptionId` | `string` | Template, Required | The subscription Id | +| `incrementId` | `string` | Template, Required | The increment Id | ## Response Type -[`ListIncrementsResponse`](../../doc/models/list-increments-response.md) +[`GetIncrementResponse`](../../doc/models/get-increment-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$result = $subscriptionsController->getIncrements($subscriptionId); +$incrementId = 'increment_id8'; + +$result = $subscriptionsController->getIncrementById( + $subscriptionId, + $incrementId +); ``` -# Update Subscription Due Days +# Delete Increment -Updates the boleto due days from a subscription +Deletes a increment ```php -function updateSubscriptionDueDays( +function deleteIncrement( string $subscriptionId, - UpdateSubscriptionDueDaysRequest $request, + string $incrementId, ?string $idempotencyKey = null -): GetSubscriptionResponse +): GetIncrementResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | Subscription Id | -| `request` | [`UpdateSubscriptionDueDaysRequest`](../../doc/models/update-subscription-due-days-request.md) | Body, Required | - | +| `subscriptionId` | `string` | Template, Required | Subscription id | +| `incrementId` | `string` | Template, Required | Increment id | | `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 = UpdateSubscriptionDueDaysRequestBuilder::init( - 226 -)->build(); +$incrementId = 'increment_id8'; -$result = $subscriptionsController->updateSubscriptionDueDays( +$result = $subscriptionsController->deleteIncrement( $subscriptionId, - $request + $incrementId ); ``` -# Update Subscription Start At - -Updates the start at date from a subscription +# Get Discounts ```php -function updateSubscriptionStartAt( - string $subscriptionId, - UpdateSubscriptionStartAtRequest $request, - ?string $idempotencyKey = null -): GetSubscriptionResponse +function getDiscounts(string $subscriptionId, int $page, int $size): ListDiscountsResponse ``` ## Parameters @@ -1149,40 +963,40 @@ function updateSubscriptionStartAt( | 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 | -| `idempotencyKey` | `?string` | Header, Optional | - | +| `page` | `int` | Query, Required | Page number | +| `size` | `int` | Query, Required | Page size | ## Response Type -[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) +[`ListDiscountsResponse`](../../doc/models/list-discounts-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$request = UpdateSubscriptionStartAtRequestBuilder::init( - DateTimeHelper::fromRfc3339DateTimeRequired('2016-03-13T12:52:32.123Z') -)->build(); +$page = 30; -$result = $subscriptionsController->updateSubscriptionStartAt( +$size = 18; + +$result = $subscriptionsController->getDiscounts( $subscriptionId, - $request + $page, + $size ); ``` -# Update Subscription Item +# Update Subscription Due Days -Updates a subscription item +Updates the boleto due days from a subscription ```php -function updateSubscriptionItem( +function updateSubscriptionDueDays( string $subscriptionId, - string $itemId, - UpdateSubscriptionItemRequest $body, + UpdateSubscriptionDueDaysRequest $request, ?string $idempotencyKey = null -): GetSubscriptionItemResponse +): GetSubscriptionResponse ``` ## Parameters @@ -1190,40 +1004,25 @@ function updateSubscriptionItem( | 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 | +| `request` | [`UpdateSubscriptionDueDaysRequest`](../../doc/models/update-subscription-due-days-request.md) | Body, Required | - | | `idempotencyKey` | `?string` | Header, Optional | - | ## 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'; - -$body = UpdateSubscriptionItemRequestBuilder::init( - 'description4', - 'status2', - UpdatePricingSchemeRequestBuilder::init( - 'scheme_type8', - [ - UpdatePriceBracketRequestBuilder::init( - 144, - 174 - )->build() - ] - )->build(), - 'name6' +$request = UpdateSubscriptionDueDaysRequestBuilder::init( + 226 )->build(); -$result = $subscriptionsController->updateSubscriptionItem( +$result = $subscriptionsController->updateSubscriptionDueDays( $subscriptionId, - $itemId, - $body + $request ); ``` @@ -1281,19 +1080,18 @@ $result = $subscriptionsController->createSubscriptionItem( ``` -# Get Subscription - -Gets a subscription +# Update Split Subscription ```php -function getSubscription(string $subscriptionId): GetSubscriptionResponse +function updateSplitSubscription(string $id, UpdateSubscriptionSplitRequest $request): GetSubscriptionResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | Subscription id | +| `id` | `string` | Template, Required | Subscription's id | +| `request` | [`UpdateSubscriptionSplitRequest`](../../doc/models/update-subscription-split-request.md) | Body, Required | - | ## Response Type @@ -1302,27 +1100,42 @@ function getSubscription(string $subscriptionId): GetSubscriptionResponse ## Example Usage ```php -$subscriptionId = 'subscription_id0'; +$id = 'id0'; -$result = $subscriptionsController->getSubscription($subscriptionId); +$request = UpdateSubscriptionSplitRequestBuilder::init( + false, + [ + CreateSplitRequestBuilder::init( + 'type2', + 118, + 'recipient_id2' + )->build() + ] +)->build(); + +$result = $subscriptionsController->updateSplitSubscription( + $id, + $request +); ``` -# 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 @@ -1330,76 +1143,205 @@ 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->getSubscriptionItems($subscriptionId); +``` -$result = $subscriptionsController->getUsages( + +# 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 | - | + +## Response Type + +[`GetIncrementResponse`](../../doc/models/get-increment-response.md) + +## Example Usage + +```php +$subscriptionId = 'subscription_id0'; + +$request = CreateIncrementRequestBuilder::init( + 185.28, + 'increment_type8', + 'item_id6' +)->build(); + +$result = $subscriptionsController->createIncrement( $subscriptionId, - $itemId + $request ); ``` -# Update Latest Period End At +# Create Usage + +Creates a usage ```php -function updateLatestPeriodEndAt( +function createUsage( string $subscriptionId, - UpdateCurrentCycleEndDateRequest $request, + string $itemId, + CreateUsageRequest $body, ?string $idempotencyKey = null -): GetSubscriptionResponse +): GetUsageResponse ``` ## Parameters | 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 | +| `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 -[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) +[`GetUsageResponse`](../../doc/models/get-usage-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$request = UpdateCurrentCycleEndDateRequestBuilder::init()->build(); +$itemId = 'item_id0'; -$result = $subscriptionsController->updateLatestPeriodEndAt( +$body = CreateUsageRequestBuilder::init( + 156, + 'description4', + DateTimeHelper::fromRfc3339DateTimeRequired('2016-03-13T12:52:32.123Z') +)->build(); + +$result = $subscriptionsController->createUsage( $subscriptionId, - $request + $itemId, + $body ); ``` -# Update Subscription Minium Price +# Get Discount by Id -Atualização do valor mínimo da assinatura +```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 -function updateSubscriptionMiniumPrice( +$subscriptionId = 'subscription_id0'; + +$discountId = 'discountId0'; + +$result = $subscriptionsController->getDiscountById( + $subscriptionId, + $discountId +); +``` + + +# Update Subscription Metadata + +Updates the metadata from a subscription + +```php +function updateSubscriptionMetadata( string $subscriptionId, - UpdateSubscriptionMinimumPriceRequest $request, + UpdateMetadataRequest $request, ?string $idempotencyKey = null ): GetSubscriptionResponse ``` @@ -1408,8 +1350,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 @@ -1421,113 +1363,171 @@ 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 +# Get Subscription Cycles ```php -function getSubscriptionCycleById(string $subscriptionId, string $cycleId): GetPeriodResponse +function getSubscriptionCycles(string $subscriptionId, string $page, string $size): ListCyclesResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | The subscription id | -| `cycleId` | `string` | Template, Required | - | +| `subscriptionId` | `string` | Template, Required | Subscription Id | +| `page` | `string` | Query, Required | Page number | +| `size` | `string` | Query, Required | Page size | ## Response Type -[`GetPeriodResponse`](../../doc/models/get-period-response.md) +[`ListCyclesResponse`](../../doc/models/list-cycles-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$cycleId = 'cycleId0'; +$page = 'page8'; -$result = $subscriptionsController->getSubscriptionCycleById( +$size = 'size0'; + +$result = $subscriptionsController->getSubscriptionCycles( $subscriptionId, - $cycleId + $page, + $size ); ``` -# Get Usage Report +# Delete Subscription Item + +Deletes a subscription item ```php -function getUsageReport(string $subscriptionId, string $periodId): GetUsageReportResponse +function deleteSubscriptionItem( + string $subscriptionId, + string $subscriptionItemId, + ?string $idempotencyKey = null +): GetSubscriptionItemResponse ``` ## 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 | +| `subscriptionItemId` | `string` | Template, Required | Subscription item id | +| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`GetUsageReportResponse`](../../doc/models/get-usage-report-response.md) +[`GetSubscriptionItemResponse`](../../doc/models/get-subscription-item-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$periodId = 'period_id0'; +$subscriptionItemId = 'subscription_item_id4'; -$result = $subscriptionsController->getUsageReport( +$result = $subscriptionsController->deleteSubscriptionItem( $subscriptionId, - $periodId + $subscriptionItemId ); ``` -# Update Split Subscription +# Get Increments ```php -function updateSplitSubscription(string $id, UpdateSubscriptionSplitRequest $request): GetSubscriptionResponse +function getIncrements(string $subscriptionId, ?int $page = null, ?int $size = null): ListIncrementsResponse ``` ## 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 | The subscription id | +| `page` | `?int` | Query, Optional | Page number | +| `size` | `?int` | Query, Optional | Page size | ## Response Type -[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) +[`ListIncrementsResponse`](../../doc/models/list-increments-response.md) ## Example Usage ```php -$id = 'id0'; +$subscriptionId = 'subscription_id0'; -$request = UpdateSubscriptionSplitRequestBuilder::init( - false, - [ - CreateSplitRequestBuilder::init( - 'type2', - 118, - 'recipient_id2' - )->build() - ] +$result = $subscriptionsController->getIncrements($subscriptionId); +``` + + +# Update Subscription Item + +Updates a subscription item + +```php +function updateSubscriptionItem( + string $subscriptionId, + string $itemId, + UpdateSubscriptionItemRequest $body, + ?string $idempotencyKey = null +): GetSubscriptionItemResponse +``` + +## 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 | - | + +## Response Type + +[`GetSubscriptionItemResponse`](../../doc/models/get-subscription-item-response.md) + +## Example Usage + +```php +$subscriptionId = 'subscription_id0'; + +$itemId = 'item_id0'; + +$body = UpdateSubscriptionItemRequestBuilder::init( + 'description4', + 'status2', + UpdatePricingSchemeRequestBuilder::init( + 'scheme_type8', + [ + UpdatePriceBracketRequestBuilder::init( + 144, + 174 + )->build() + ] + )->build(), + 'name6' )->build(); -$result = $subscriptionsController->updateSplitSubscription( - $id, - $request +$result = $subscriptionsController->updateSubscriptionItem( + $subscriptionId, + $itemId, + $body ); ``` diff --git a/doc/controllers/tokens.md b/doc/controllers/tokens.md index 732e7a7..c1f26bb 100644 --- a/doc/controllers/tokens.md +++ b/doc/controllers/tokens.md @@ -10,29 +10,26 @@ $tokensController = $client->getTokensController(); ## Methods -* [Create Token](../../doc/controllers/tokens.md#create-token) * [Get Token](../../doc/controllers/tokens.md#get-token) +* [Create Token](../../doc/controllers/tokens.md#create-token) -# 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 @@ -41,44 +38,36 @@ 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 ); ``` -# 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 @@ -87,13 +76,24 @@ 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 ); ``` diff --git a/doc/controllers/transfers.md b/doc/controllers/transfers.md index 36eb1cb..d933c61 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) -* [Create Transfer](../../doc/controllers/transfers.md#create-transfer) * [Get Transfers](../../doc/controllers/transfers.md#get-transfers) +* [Create Transfer](../../doc/controllers/transfers.md#create-transfer) # Get Transfer by Id @@ -40,6 +40,25 @@ $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 @@ -68,22 +87,3 @@ $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/src/ApiHelper.php b/src/ApiHelper.php index 5c6c677..41d4b38 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\GetPrivateLabelTransactionResponse::class, Models\GetCashTransactionResponse::class, + Models\GetPrivateLabelTransactionResponse::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 68f3a06..319ac02 100644 --- a/src/Authentication/BasicAuthManager.php +++ b/src/Authentication/BasicAuthManager.php @@ -11,6 +11,7 @@ namespace PagarmeApiSDKLib\Authentication; use Core\Authentication\CoreAuth; +use PagarmeApiSDKLib\ConfigurationDefaults; use Core\Request\Parameters\HeaderParam; use Core\Utils\CoreHelper; use PagarmeApiSDKLib\BasicAuthCredentials; @@ -20,24 +21,18 @@ */ class BasicAuthManager extends CoreAuth implements BasicAuthCredentials { - private $basicAuthUserName; - - private $basicAuthPassword; - /** - * Returns an instance of this class. - * - * @param string $basicAuthUserName The username to use with basic authentication - * @param string $basicAuthPassword The password to use with basic authentication + * @var array */ - public function __construct(string $basicAuthUserName, string $basicAuthPassword) + private $config; + + public function __construct(array $config) { + $this->config = $config; parent::__construct(HeaderParam::init( 'Authorization', - CoreHelper::getBasicAuthEncodedString($basicAuthUserName, $basicAuthPassword) + CoreHelper::getBasicAuthEncodedString($this->getBasicAuthUserName(), $this->getBasicAuthPassword()) )->requiredNonEmpty()); - $this->basicAuthUserName = $basicAuthUserName; - $this->basicAuthPassword = $basicAuthPassword; } /** @@ -45,7 +40,7 @@ public function __construct(string $basicAuthUserName, string $basicAuthPassword */ public function getBasicAuthUserName(): string { - return $this->basicAuthUserName; + return $this->config['basicAuthUserName'] ?? ConfigurationDefaults::BASIC_AUTH_USER_NAME; } /** @@ -53,7 +48,7 @@ public function getBasicAuthUserName(): string */ public function getBasicAuthPassword(): string { - return $this->basicAuthPassword; + return $this->config['basicAuthPassword'] ?? ConfigurationDefaults::BASIC_AUTH_PASSWORD; } /** @@ -64,7 +59,7 @@ public function getBasicAuthPassword(): string */ public function equals(string $basicAuthUserName, string $basicAuthPassword): bool { - return $basicAuthUserName == $this->basicAuthUserName && - $basicAuthPassword == $this->basicAuthPassword; + return $basicAuthUserName == $this->getBasicAuthUserName() && + $basicAuthPassword == $this->getBasicAuthPassword(); } } diff --git a/src/Controllers/BalanceOperationsController.php b/src/Controllers/BalanceOperationsController.php index a030c80..d716b34 100644 --- a/src/Controllers/BalanceOperationsController.php +++ b/src/Controllers/BalanceOperationsController.php @@ -20,6 +20,24 @@ 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 @@ -51,22 +69,4 @@ 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 22a3033..8b7899c 100644 --- a/src/Controllers/ChargesController.php +++ b/src/Controllers/ChargesController.php @@ -62,23 +62,22 @@ public function updateChargeMetadata( } /** - * Updates a charge's payment method + * Captures a charge * * @param string $chargeId Charge id - * @param UpdateChargePaymentMethodRequest $request Request for updating the payment method from - * a charge + * @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 updateChargePaymentMethod( + public function captureCharge( string $chargeId, - UpdateChargePaymentMethodRequest $request, + ?CreateCaptureChargeRequest $request = null, ?string $idempotencyKey = null ): GetChargeResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/charges/{charge_id}/payment-method') + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/charges/{charge_id}/capture') ->auth('httpBasic') ->parameters( TemplateParam::init('charge_id', $chargeId), @@ -92,49 +91,40 @@ public function updateChargePaymentMethod( } /** - * @param string $chargeId Charge Id - * @param int|null $page Page number - * @param int|null $size Page size + * Get a charge from its id * - * @return ListChargeTransactionsResponse Response from the API call + * @param string $chargeId Charge id + * + * @return GetChargeResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getChargeTransactions( - string $chargeId, - ?int $page = null, - ?int $size = null - ): ListChargeTransactionsResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/charges/{charge_id}/transactions') + public function getCharge(string $chargeId): GetChargeResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/charges/{charge_id}') ->auth('httpBasic') - ->parameters( - TemplateParam::init('charge_id', $chargeId), - QueryParam::init('page', $page), - QueryParam::init('size', $size) - ); + ->parameters(TemplateParam::init('charge_id', $chargeId)); - $_resHandler = $this->responseHandler()->type(ListChargeTransactionsResponse::class); + $_resHandler = $this->responseHandler()->type(GetChargeResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Updates the due date from a charge - * - * @param string $chargeId Charge Id - * @param UpdateChargeDueDateRequest $request Request for updating the due date + * @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 updateChargeDueDate( + public function confirmPayment( string $chargeId, - UpdateChargeDueDateRequest $request, + ?CreateConfirmPaymentRequest $request = null, ?string $idempotencyKey = null ): GetChargeResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/Charges/{charge_id}/due-date') + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/charges/{charge_id}/confirm-payment') ->auth('httpBasic') ->parameters( TemplateParam::init('charge_id', $chargeId), @@ -148,72 +138,49 @@ public function updateChargeDueDate( } /** - * Lists all charges - * + * @param string $chargeId Charge Id * @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 ListChargesResponse Response from the API call + * @return ListChargeTransactionsResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getCharges( + public function getChargeTransactions( + string $chargeId, ?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') + ?int $size = null + ): ListChargeTransactionsResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/charges/{charge_id}/transactions') ->auth('httpBasic') ->parameters( + TemplateParam::init('charge_id', $chargeId), 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']) + QueryParam::init('size', $size) ); - $_resHandler = $this->responseHandler()->type(ListChargesResponse::class); + $_resHandler = $this->responseHandler()->type(ListChargeTransactionsResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Captures a charge + * Updates the card from a charge * * @param string $chargeId Charge id - * @param CreateCaptureChargeRequest|null $request Request for capturing 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 captureCharge( + public function updateChargeCard( string $chargeId, - ?CreateCaptureChargeRequest $request = null, + UpdateChargeCardRequest $request, ?string $idempotencyKey = null ): GetChargeResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/charges/{charge_id}/capture') + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/charges/{charge_id}/card') ->auth('httpBasic') ->parameters( TemplateParam::init('charge_id', $chargeId), @@ -227,22 +194,44 @@ public function captureCharge( } /** - * Updates the card from a charge + * 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 * * @param string $chargeId Charge id - * @param UpdateChargeCardRequest $request Request for updating a charge's card + * @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 updateChargeCard( + public function updateChargePaymentMethod( string $chargeId, - UpdateChargeCardRequest $request, + UpdateChargePaymentMethodRequest $request, ?string $idempotencyKey = null ): GetChargeResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/charges/{charge_id}/card') + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/charges/{charge_id}/payment-method') ->auth('httpBasic') ->parameters( TemplateParam::init('charge_id', $chargeId), @@ -256,19 +245,28 @@ public function updateChargeCard( } /** - * Get a charge from its id + * Updates the due date from a charge * - * @param string $chargeId Charge id + * @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 getCharge(string $chargeId): GetChargeResponse - { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/charges/{charge_id}') + public function updateChargeDueDate( + string $chargeId, + UpdateChargeDueDateRequest $request, + ?string $idempotencyKey = null + ): GetChargeResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/Charges/{charge_id}/due-date') ->auth('httpBasic') - ->parameters(TemplateParam::init('charge_id', $chargeId)); + ->parameters( + TemplateParam::init('charge_id', $chargeId), + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) + ); $_resHandler = $this->responseHandler()->type(GetChargeResponse::class); @@ -329,70 +327,72 @@ public function retryCharge(string $chargeId, ?string $idempotencyKey = null): G } /** - * Cancel a charge + * Lists all charges * - * @param string $chargeId Charge id - * @param CreateCancelChargeRequest|null $request Request for cancelling a charge - * @param string|null $idempotencyKey + * @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 GetChargeResponse Response from the API call + * @return ListChargesResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function cancelCharge( - string $chargeId, - ?CreateCancelChargeRequest $request = null, - ?string $idempotencyKey = null - ): GetChargeResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/charges/{charge_id}') + 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') ->auth('httpBasic') ->parameters( - TemplateParam::init('charge_id', $chargeId), - BodyParam::init($request), - HeaderParam::init('idempotency-key', $idempotencyKey) + 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']) ); - $_resHandler = $this->responseHandler()->type(GetChargeResponse::class); + $_resHandler = $this->responseHandler()->type(ListChargesResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Creates a new charge - * - * @param CreateChargeRequest $request Request for creating a charge - * @param string|null $idempotencyKey - * - * @return GetChargeResponse Response from the API call + * Cancel a charge * - * @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); - } - - /** - * @param string $chargeId - * @param CreateConfirmPaymentRequest|null $request Request for confirm payment + * @param string $chargeId Charge id + * @param CreateCancelChargeRequest|null $request Request for cancelling a charge * @param string|null $idempotencyKey * * @return GetChargeResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function confirmPayment( + public function cancelCharge( string $chargeId, - ?CreateConfirmPaymentRequest $request = null, + ?CreateCancelChargeRequest $request = null, ?string $idempotencyKey = null ): GetChargeResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/charges/{charge_id}/confirm-payment') + $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/charges/{charge_id}') ->auth('httpBasic') ->parameters( TemplateParam::init('charge_id', $chargeId), diff --git a/src/Controllers/CustomersController.php b/src/Controllers/CustomersController.php index 52a7fe7..0bcf106 100644 --- a/src/Controllers/CustomersController.php +++ b/src/Controllers/CustomersController.php @@ -36,65 +36,62 @@ class CustomersController extends BaseController { /** - * Updates a card + * Creates a new address for a customer * * @param string $customerId Customer Id - * @param string $cardId Card id - * @param UpdateCardRequest $request Request for updating a card + * @param CreateAddressRequest $request Request for creating 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 createAddress( string $customerId, - string $cardId, - UpdateCardRequest $request, + CreateAddressRequest $request, ?string $idempotencyKey = null - ): GetCardResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/customers/{customer_id}/cards/{card_id}') + ): GetAddressResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/customers/{customer_id}/addresses') ->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); + $_resHandler = $this->responseHandler()->type(GetAddressResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Updates an address + * Updates a card * * @param string $customerId Customer Id - * @param string $addressId Address Id - * @param UpdateAddressRequest $request Request for updating 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 updateAddress( + public function updateCard( string $customerId, - string $addressId, - UpdateAddressRequest $request, + string $cardId, + UpdateCardRequest $request, ?string $idempotencyKey = null - ): GetAddressResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/customers/{customer_id}/addresses/{address_id}') + ): GetCardResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/customers/{customer_id}/cards/{card_id}') ->auth('httpBasic') ->parameters( TemplateParam::init('customer_id', $customerId), - TemplateParam::init('address_id', $addressId), + 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); } @@ -153,50 +150,53 @@ public function createCustomer(CreateCustomerRequest $request, ?string $idempote } /** - * Creates a new address for a customer + * Delete a Customer's access tokens * * @param string $customerId Customer Id - * @param CreateAddressRequest $request Request for creating 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 createAddress( - string $customerId, - CreateAddressRequest $request, - ?string $idempotencyKey = null - ): GetAddressResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/customers/{customer_id}/addresses') + public function deleteAccessTokens(string $customerId): ListAccessTokensResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/customers/{customer_id}/access-tokens/') ->auth('httpBasic') - ->parameters( - TemplateParam::init('customer_id', $customerId), - 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); } /** - * Delete a Customer's access tokens + * Updates an address * * @param string $customerId Customer Id + * @param string $addressId Address Id + * @param UpdateAddressRequest $request Request for updating 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 updateAddress( + string $customerId, + string $addressId, + UpdateAddressRequest $request, + ?string $idempotencyKey = null + ): GetAddressResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/customers/{customer_id}/addresses/{address_id}') ->auth('httpBasic') - ->parameters(TemplateParam::init('customer_id', $customerId)); + ->parameters( + TemplateParam::init('customer_id', $customerId), + TemplateParam::init('address_id', $addressId), + 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); } @@ -257,35 +257,6 @@ 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 * @@ -325,51 +296,95 @@ public function getCustomers( } /** - * Updates a customer + * Get all access tokens from a customer * - * @param string $customerId Customer id - * @param UpdateCustomerRequest $request Request for updating 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 + * + * @param string $customerId Customer Id + * @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 deleteCard(string $customerId, string $cardId, ?string $idempotencyKey = null): GetCardResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/customers/{customer_id}/cards/{card_id}') ->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 card * - * @param string $customerId Customer Id - * @param CreateAccessTokenRequest $request Request for creating a access token + * @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); + } + + /** + * 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 GetAccessTokenResponse Response from the API call + * @return GetCardResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function createAccessToken( + public function createCard( string $customerId, - CreateAccessTokenRequest $request, + CreateCardRequest $request, ?string $idempotencyKey = null - ): GetAccessTokenResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/customers/{customer_id}/access-tokens') + ): GetCardResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/customers/{customer_id}/cards') ->auth('httpBasic') ->parameters( TemplateParam::init('customer_id', $customerId), @@ -377,51 +392,52 @@ public function createAccessToken( HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetAccessTokenResponse::class); + $_resHandler = $this->responseHandler()->type(GetCardResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Get all access tokens from a customer + * Get a Customer's access token * * @param string $customerId Customer Id - * @param int|null $page Page number - * @param int|null $size Page size + * @param string $tokenId Token Id * - * @return ListAccessTokensResponse Response from the API call + * @return GetAccessTokenResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getAccessTokens(string $customerId, ?int $page = null, ?int $size = null): ListAccessTokensResponse + public function getAccessToken(string $customerId, string $tokenId): GetAccessTokenResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/customers/{customer_id}/access-tokens') + $_reqBuilder = $this->requestBuilder( + RequestMethod::GET, + '/customers/{customer_id}/access-tokens/{token_id}' + ) ->auth('httpBasic') ->parameters( TemplateParam::init('customer_id', $customerId), - QueryParam::init('page', $page), - QueryParam::init('size', $size) + TemplateParam::init('token_id', $tokenId) ); - $_resHandler = $this->responseHandler()->type(ListAccessTokensResponse::class); + $_resHandler = $this->responseHandler()->type(GetAccessTokenResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Get all cards from a customer + * Gets all adressess 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 ListCardsResponse Response from the API call + * @return ListAddressesResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getCards(string $customerId, ?int $page = null, ?int $size = null): ListCardsResponse + public function getAddresses(string $customerId, ?int $page = null, ?int $size = null): ListAddressesResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/customers/{customer_id}/cards') + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/customers/{customer_id}/addresses') ->auth('httpBasic') ->parameters( TemplateParam::init('customer_id', $customerId), @@ -429,57 +445,62 @@ public function getCards(string $customerId, ?int $page = null, ?int $size = nul QueryParam::init('size', $size) ); - $_resHandler = $this->responseHandler()->type(ListCardsResponse::class); + $_resHandler = $this->responseHandler()->type(ListAddressesResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Renew a card + * Updates a customer * * @param string $customerId Customer id - * @param string $cardId Card 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 renewCard(string $customerId, string $cardId, ?string $idempotencyKey = null): GetCardResponse - { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/customers/{customer_id}/cards/{card_id}/renew') + 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); + $_resHandler = $this->responseHandler()->type(GetCustomerResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Get a Customer's access token + * Creates a access token for a customer * * @param string $customerId Customer Id - * @param string $tokenId Token Id + * @param CreateAccessTokenRequest $request Request for creating a access token + * @param string|null $idempotencyKey * * @return GetAccessTokenResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getAccessToken(string $customerId, string $tokenId): GetAccessTokenResponse - { - $_reqBuilder = $this->requestBuilder( - RequestMethod::GET, - '/customers/{customer_id}/access-tokens/{token_id}' - ) + public function createAccessToken( + string $customerId, + CreateAccessTokenRequest $request, + ?string $idempotencyKey = null + ): GetAccessTokenResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/customers/{customer_id}/access-tokens') ->auth('httpBasic') ->parameters( TemplateParam::init('customer_id', $customerId), - TemplateParam::init('token_id', $tokenId) + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) ); $_resHandler = $this->responseHandler()->type(GetAccessTokenResponse::class); @@ -488,38 +509,35 @@ public function getAccessToken(string $customerId, string $tokenId): GetAccessTo } /** - * Updates the metadata a customer + * Get all cards 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 ListCardsResponse 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 getCards(string $customerId, ?int $page = null, ?int $size = null): ListCardsResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/customers/{customer_id}/cards') ->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(ListCardsResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Delete a customer's card + * Renew a card * - * @param string $customerId Customer Id + * @param string $customerId Customer id * @param string $cardId Card Id * @param string|null $idempotencyKey * @@ -527,9 +545,9 @@ public function updateCustomerMetadata( * * @throws ApiException Thrown if API call fails */ - public function deleteCard(string $customerId, string $cardId, ?string $idempotencyKey = null): GetCardResponse + public function renewCard(string $customerId, string $cardId, ?string $idempotencyKey = null): GetCardResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/customers/{customer_id}/cards/{card_id}') + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/customers/{customer_id}/cards/{card_id}/renew') ->auth('httpBasic') ->parameters( TemplateParam::init('customer_id', $customerId), @@ -543,27 +561,30 @@ public function deleteCard(string $customerId, string $cardId, ?string $idempote } /** - * Gets all adressess 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 ListAddressesResponse Response from the API call + * @return GetCustomerResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getAddresses(string $customerId, ?int $page = null, ?int $size = null): ListAddressesResponse - { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/customers/{customer_id}/addresses') + 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(ListAddressesResponse::class); + $_resHandler = $this->responseHandler()->type(GetCustomerResponse::class); return $this->execute($_reqBuilder, $_resHandler); } @@ -587,25 +608,4 @@ 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 b875abc..4c3a0a8 100644 --- a/src/Controllers/InvoicesController.php +++ b/src/Controllers/InvoicesController.php @@ -26,49 +26,56 @@ class InvoicesController extends BaseController { /** - * 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); - - 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); + $_resHandler = $this->responseHandler()->type(ListInvoicesResponse::class); return $this->execute($_reqBuilder, $_resHandler); } @@ -98,31 +105,25 @@ public function cancelInvoice(string $invoiceId, ?string $idempotencyKey = null) } /** - * 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) ); @@ -133,74 +134,47 @@ public function createInvoice( } /** - * 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); } /** - * Gets an invoice - * - * @param string $invoiceId Invoice Id + * @param string $subscriptionId Subscription Id * * @return GetInvoiceResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getInvoice(string $invoiceId): GetInvoiceResponse + public function getPartialInvoice(string $subscriptionId): GetInvoiceResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/invoices/{invoice_id}') - ->auth('httpBasic') - ->parameters(TemplateParam::init('invoice_id', $invoiceId)); + $_reqBuilder = $this->requestBuilder( + RequestMethod::GET, + '/subscriptions/{subscription_id}/partial-invoice' + )->auth('httpBasic')->parameters(TemplateParam::init('subscription_id', $subscriptionId)); $_resHandler = $this->responseHandler()->type(GetInvoiceResponse::class); @@ -208,25 +182,31 @@ public function getInvoice(string $invoiceId): GetInvoiceResponse } /** - * 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) ); @@ -235,4 +215,24 @@ public function updateInvoiceStatus( 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 71c36cc..f9617fc 100644 --- a/src/Controllers/OrdersController.php +++ b/src/Controllers/OrdersController.php @@ -29,44 +29,23 @@ class OrdersController extends BaseController { /** - * Gets all orders - * - * @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 string $orderId Order Id + * @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 deleteAllOrderItems(string $orderId, ?string $idempotencyKey = null): GetOrderResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/orders/{orderId}/items') ->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) + TemplateParam::init('orderId', $orderId), + HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(ListOrderResponse::class); + $_resHandler = $this->responseHandler()->type(GetOrderResponse::class); return $this->execute($_reqBuilder, $_resHandler); } @@ -74,27 +53,16 @@ public function getOrders( /** * @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 updateOrderItem( - string $orderId, - string $itemId, - UpdateOrderItemRequest $request, - ?string $idempotencyKey = null - ): GetOrderItemResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/orders/{orderId}/items/{itemId}') + public function getOrderItem(string $orderId, string $itemId): GetOrderItemResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/orders/{orderId}/items/{itemId}') ->auth('httpBasic') - ->parameters( - TemplateParam::init('orderId', $orderId), - TemplateParam::init('itemId', $itemId), - BodyParam::init($request), - HeaderParam::init('idempotency-key', $idempotencyKey) - ); + ->parameters(TemplateParam::init('orderId', $orderId), TemplateParam::init('itemId', $itemId)); $_resHandler = $this->responseHandler()->type(GetOrderItemResponse::class); @@ -102,19 +70,26 @@ public function updateOrderItem( } /** - * @param string $orderId Order Id + * Updates the metadata from 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 deleteAllOrderItems(string $orderId, ?string $idempotencyKey = null): GetOrderResponse - { - $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/orders/{orderId}/items') + public function updateOrderMetadata( + string $orderId, + UpdateMetadataRequest $request, + ?string $idempotencyKey = null + ): GetOrderResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/Orders/{order_id}/metadata') ->auth('httpBasic') ->parameters( - TemplateParam::init('orderId', $orderId), + TemplateParam::init('order_id', $orderId), + BodyParam::init($request), HeaderParam::init('idempotency-key', $idempotencyKey) ); @@ -151,26 +126,19 @@ public function deleteOrderItem( } /** - * @param string $id Order Id - * @param UpdateOrderStatusRequest $request Update Order Model - * @param string|null $idempotencyKey + * Gets an order + * + * @param string $orderId Order id * * @return GetOrderResponse 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 getOrder(string $orderId): GetOrderResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/orders/{order_id}') ->auth('httpBasic') - ->parameters( - TemplateParam::init('id', $id), - BodyParam::init($request), - HeaderParam::init('idempotency-key', $idempotencyKey) - ); + ->parameters(TemplateParam::init('order_id', $orderId)); $_resHandler = $this->responseHandler()->type(GetOrderResponse::class); @@ -178,44 +146,69 @@ public function closeOrder( } /** - * Creates a new Order + * Gets all orders * - * @param CreateOrderRequest $body Request for creating an order - * @param string|null $idempotencyKey + * @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 GetOrderResponse Response from the API call + * @return ListOrderResponse 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 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(BodyParam::init($body), HeaderParam::init('idempotency-key', $idempotencyKey)); + ->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) + ); - $_resHandler = $this->responseHandler()->type(GetOrderResponse::class); + $_resHandler = $this->responseHandler()->type(ListOrderResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** * @param string $orderId Order Id - * @param CreateOrderItemRequest $request Order Item Model + * @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 createOrderItem( + public function updateOrderItem( string $orderId, - CreateOrderItemRequest $request, + string $itemId, + UpdateOrderItemRequest $request, ?string $idempotencyKey = null ): GetOrderItemResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/orders/{orderId}/items') + $_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/orders/{orderId}/items/{itemId}') ->auth('httpBasic') ->parameters( TemplateParam::init('orderId', $orderId), + TemplateParam::init('itemId', $itemId), BodyParam::init($request), HeaderParam::init('idempotency-key', $idempotencyKey) ); @@ -226,47 +219,47 @@ public function createOrderItem( } /** - * @param string $orderId Order Id - * @param string $itemId Item Id + * @param string $id Order Id + * @param UpdateOrderStatusRequest $request Update Order Model + * @param string|null $idempotencyKey * - * @return GetOrderItemResponse Response from the API call + * @return GetOrderResponse 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 closeOrder( + string $id, + UpdateOrderStatusRequest $request, + ?string $idempotencyKey = null + ): GetOrderResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/orders/{id}/closed') ->auth('httpBasic') - ->parameters(TemplateParam::init('orderId', $orderId), TemplateParam::init('itemId', $itemId)); + ->parameters( + TemplateParam::init('id', $id), + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) + ); - $_resHandler = $this->responseHandler()->type(GetOrderItemResponse::class); + $_resHandler = $this->responseHandler()->type(GetOrderResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Updates the metadata from an order + * Creates a new Order * - * @param string $orderId The order id - * @param UpdateMetadataRequest $request Request for updating the order metadata + * @param CreateOrderRequest $body Request for creating an order * @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 createOrder(CreateOrderRequest $body, ?string $idempotencyKey = null): GetOrderResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/orders') ->auth('httpBasic') - ->parameters( - TemplateParam::init('order_id', $orderId), - BodyParam::init($request), - HeaderParam::init('idempotency-key', $idempotencyKey) - ); + ->parameters(BodyParam::init($body), HeaderParam::init('idempotency-key', $idempotencyKey)); $_resHandler = $this->responseHandler()->type(GetOrderResponse::class); @@ -274,21 +267,28 @@ public function updateOrderMetadata( } /** - * Gets an order - * - * @param string $orderId Order id + * @param string $orderId Order Id + * @param CreateOrderItemRequest $request Order Item Model + * @param string|null $idempotencyKey * - * @return GetOrderResponse Response from the API call + * @return GetOrderItemResponse 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 createOrderItem( + string $orderId, + CreateOrderItemRequest $request, + ?string $idempotencyKey = null + ): GetOrderItemResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/orders/{orderId}/items') ->auth('httpBasic') - ->parameters(TemplateParam::init('order_id', $orderId)); + ->parameters( + TemplateParam::init('orderId', $orderId), + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) + ); - $_resHandler = $this->responseHandler()->type(GetOrderResponse::class); + $_resHandler = $this->responseHandler()->type(GetOrderItemResponse::class); return $this->execute($_reqBuilder, $_resHandler); } diff --git a/src/Controllers/PlansController.php b/src/Controllers/PlansController.php index a834244..0b20bbb 100644 --- a/src/Controllers/PlansController.php +++ b/src/Controllers/PlansController.php @@ -49,25 +49,30 @@ public function getPlan(string $planId): GetPlanResponse } /** - * Deletes a plan + * Removes an item from a plan * * @param string $planId Plan id + * @param string $planItemId Plan item id * @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 deletePlan(string $planId, ?string $idempotencyKey = null): GetPlanResponse - { - $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/plans/{plan_id}') + 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); } @@ -102,54 +107,43 @@ public function updatePlanMetadata( } /** - * Updates a plan item + * Creates a new plan * - * @param string $planId Plan id - * @param string $planItemId Plan item id - * @param UpdatePlanItemRequest $body Request for updating the plan item + * @param CreatePlanRequest $body Request for creating 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 updatePlanItem( - string $planId, - string $planItemId, - UpdatePlanItemRequest $body, - ?string $idempotencyKey = null - ): GetPlanItemResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/plans/{plan_id}/items/{plan_item_id}') + public function createPlan(CreatePlanRequest $body, ?string $idempotencyKey = null): GetPlanResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/plans') ->auth('httpBasic') - ->parameters( - TemplateParam::init('plan_id', $planId), - TemplateParam::init('plan_item_id', $planItemId), - BodyParam::init($body), - HeaderParam::init('idempotency-key', $idempotencyKey) - ); + ->parameters(BodyParam::init($body), HeaderParam::init('idempotency-key', $idempotencyKey)); - $_resHandler = $this->responseHandler()->type(GetPlanItemResponse::class); + $_resHandler = $this->responseHandler()->type(GetPlanResponse::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), @@ -157,78 +151,31 @@ public function createPlanItem( HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetPlanItemResponse::class); + $_resHandler = $this->responseHandler()->type(GetPlanResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Gets a plan item + * Deletes a plan * * @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 createPlan(CreatePlanRequest $body, ?string $idempotencyKey = null): GetPlanResponse + public function deletePlan(string $planId, ?string $idempotencyKey = null): GetPlanResponse { - $_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}') + $_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); } @@ -277,22 +224,54 @@ public function getPlans( } /** - * Updates a plan + * Updates a plan item * * @param string $planId Plan id - * @param UpdatePlanRequest $request Request for updating a plan + * @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 updatePlan( + public function updatePlanItem( string $planId, - UpdatePlanRequest $request, + string $planItemId, + UpdatePlanItemRequest $body, ?string $idempotencyKey = null - ): GetPlanResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/plans/{plan_id}') + ): 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 + * + * @param string $planId Plan id + * @param CreatePlanItemRequest $request Request for creating a plan item + * @param string|null $idempotencyKey + * + * @return GetPlanItemResponse Response from the API call + * + * @throws ApiException Thrown if API call fails + */ + public function createPlanItem( + string $planId, + CreatePlanItemRequest $request, + ?string $idempotencyKey = null + ): GetPlanItemResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/plans/{plan_id}/items') ->auth('httpBasic') ->parameters( TemplateParam::init('plan_id', $planId), @@ -300,7 +279,28 @@ 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); + } + + /** + * 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); } diff --git a/src/Controllers/RecipientsController.php b/src/Controllers/RecipientsController.php index cb31c36..64f5458 100644 --- a/src/Controllers/RecipientsController.php +++ b/src/Controllers/RecipientsController.php @@ -70,106 +70,87 @@ public function updateRecipient( } /** - * Creates an anticipation - * - * @param string $recipientId Recipient id - * @param CreateAnticipationRequest $request Anticipation data - * @param string|null $idempotencyKey + * @param string $recipientId + * @param string $withdrawalId * - * @return GetAnticipationResponse Response from the API call + * @return GetWithdrawResponse 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') + public function getWithdrawById(string $recipientId, string $withdrawalId): GetWithdrawResponse + { + $_reqBuilder = $this->requestBuilder( + RequestMethod::GET, + '/recipients/{recipient_id}/withdrawals/{withdrawal_id}' + ) ->auth('httpBasic') ->parameters( TemplateParam::init('recipient_id', $recipientId), - BodyParam::init($request), - HeaderParam::init('idempotency-key', $idempotencyKey) + TemplateParam::init('withdrawal_id', $withdrawalId) ); - $_resHandler = $this->responseHandler()->type(GetAnticipationResponse::class); + $_resHandler = $this->responseHandler()->type(GetWithdrawResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Gets the anticipation limits for a recipient + * Retrieves recipient information * - * @param string $recipientId Recipient id - * @param string $timeframe Timeframe - * @param \DateTime $paymentDate Anticipation payment date + * @param string $recipientId Recipiend id * - * @return GetAnticipationLimitResponse Response from the API call + * @return GetRecipientResponse 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') + public function getRecipient(string $recipientId): GetRecipientResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/{recipient_id}') ->auth('httpBasic') - ->parameters( - TemplateParam::init('recipient_id', $recipientId), - QueryParam::init('timeframe', $timeframe), - QueryParam::init('payment_date', $paymentDate) - ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']) - ); + ->parameters(TemplateParam::init('recipient_id', $recipientId)); - $_resHandler = $this->responseHandler()->type(GetAnticipationLimitResponse::class); + $_resHandler = $this->responseHandler()->type(GetRecipientResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Retrieves paginated recipients information + * Get balance information for a recipient * - * @param int|null $page Page number - * @param int|null $size Page size + * @param string $recipientId Recipient id * - * @return ListRecipientResponse Response from the API call + * @return GetBalanceResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getRecipients(?int $page = null, ?int $size = null): ListRecipientResponse + public function getBalance(string $recipientId): GetBalanceResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients') + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/{recipient_id}/balance') ->auth('httpBasic') - ->parameters(QueryParam::init('page', $page), QueryParam::init('size', $size)); + ->parameters(TemplateParam::init('recipient_id', $recipientId)); - $_resHandler = $this->responseHandler()->type(ListRecipientResponse::class); + $_resHandler = $this->responseHandler()->type(GetBalanceResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * @param string $recipientId - * @param string $withdrawalId + * Retrieves paginated recipients information * - * @return GetWithdrawResponse Response from the API call + * @param int|null $page Page number + * @param int|null $size Page size + * + * @return ListRecipientResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getWithdrawById(string $recipientId, string $withdrawalId): GetWithdrawResponse + public function getRecipients(?int $page = null, ?int $size = null): ListRecipientResponse { - $_reqBuilder = $this->requestBuilder( - RequestMethod::GET, - '/recipients/{recipient_id}/withdrawals/{withdrawal_id}' - ) + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients') ->auth('httpBasic') - ->parameters( - TemplateParam::init('recipient_id', $recipientId), - TemplateParam::init('withdrawal_id', $withdrawalId) - ); + ->parameters(QueryParam::init('page', $page), QueryParam::init('size', $size)); - $_resHandler = $this->responseHandler()->type(GetWithdrawResponse::class); + $_resHandler = $this->responseHandler()->type(ListRecipientResponse::class); return $this->execute($_reqBuilder, $_resHandler); } @@ -206,35 +187,6 @@ 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 * @@ -322,25 +274,47 @@ public function createWithdraw(string $recipientId, CreateWithdrawRequest $reque } /** - * Updates recipient metadata + * Gets an anticipation * * @param string $recipientId Recipient id - * @param UpdateAutomaticAnticipationSettingsRequest $request Metadata + * @param string $anticipationId Anticipation id + * + * @return GetAnticipationResponse Response from the API call + * + * @throws ApiException Thrown if API call fails + */ + public function getAnticipation(string $recipientId, string $anticipationId): GetAnticipationResponse + { + $_reqBuilder = $this->requestBuilder( + RequestMethod::GET, + '/recipients/{recipient_id}/anticipations/{anticipation_id}' + ) + ->auth('httpBasic') + ->parameters( + TemplateParam::init('recipient_id', $recipientId), + TemplateParam::init('anticipation_id', $anticipationId) + ); + + $_resHandler = $this->responseHandler()->type(GetAnticipationResponse::class); + + return $this->execute($_reqBuilder, $_resHandler); + } + + /** + * @param string $recipientId Recipient Identificator + * @param UpdateTransferSettingsRequest $request * @param string|null $idempotencyKey * * @return GetRecipientResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateAutomaticAnticipationSettings( + public function updateRecipientTransferSettings( string $recipientId, - UpdateAutomaticAnticipationSettingsRequest $request, + UpdateTransferSettingsRequest $request, ?string $idempotencyKey = null ): GetRecipientResponse { - $_reqBuilder = $this->requestBuilder( - RequestMethod::PATCH, - '/recipients/{recipient_id}/automatic-anticipation-settings' - ) + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/recipients/{recipient_id}/transfer-settings') ->auth('httpBasic') ->parameters( TemplateParam::init('recipient_id', $recipientId), @@ -354,47 +328,45 @@ public function updateAutomaticAnticipationSettings( } /** - * Gets an anticipation + * Retrieves recipient information * - * @param string $recipientId Recipient id - * @param string $anticipationId Anticipation id + * @param string $code Recipient code * - * @return GetAnticipationResponse Response from the API call + * @return GetRecipientResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getAnticipation(string $recipientId, string $anticipationId): GetAnticipationResponse + public function getRecipientByCode(string $code): GetRecipientResponse { - $_reqBuilder = $this->requestBuilder( - RequestMethod::GET, - '/recipients/{recipient_id}/anticipations/{anticipation_id}' - ) + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/{code}') ->auth('httpBasic') - ->parameters( - TemplateParam::init('recipient_id', $recipientId), - TemplateParam::init('anticipation_id', $anticipationId) - ); + ->parameters(TemplateParam::init('code', $code)); - $_resHandler = $this->responseHandler()->type(GetAnticipationResponse::class); + $_resHandler = $this->responseHandler()->type(GetRecipientResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * @param string $recipientId Recipient Identificator - * @param UpdateTransferSettingsRequest $request + * 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 updateRecipientTransferSettings( + public function updateAutomaticAnticipationSettings( string $recipientId, - UpdateTransferSettingsRequest $request, + UpdateAutomaticAnticipationSettingsRequest $request, ?string $idempotencyKey = null ): GetRecipientResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/recipients/{recipient_id}/transfer-settings') + $_reqBuilder = $this->requestBuilder( + RequestMethod::PATCH, + '/recipients/{recipient_id}/automatic-anticipation-settings' + ) ->auth('httpBasic') ->parameters( TemplateParam::init('recipient_id', $recipientId), @@ -408,70 +380,51 @@ public function updateRecipientTransferSettings( } /** - * Retrieves a paginated list of anticipations from a recipient + * Creates a transfer for 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 + * @param string $recipientId Recipient Id + * @param CreateTransferRequest $request Transfer data + * @param string|null $idempotencyKey * - * @return ListAnticipationResponse Response from the API call + * @return GetTransferResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getAnticipations( + public function createTransfer( 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') + CreateTransferRequest $request, + ?string $idempotencyKey = null + ): GetTransferResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/recipients/{recipient_id}/transfers') ->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']) + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(ListAnticipationResponse::class); + $_resHandler = $this->responseHandler()->type(GetTransferResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Retrieves recipient information + * Creates a new recipient * - * @param string $recipientId Recipiend id + * @param CreateRecipientRequest $request Recipient data + * @param string|null $idempotencyKey * * @return GetRecipientResponse 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 createRecipient( + CreateRecipientRequest $request, + ?string $idempotencyKey = null + ): GetRecipientResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/recipients') ->auth('httpBasic') - ->parameters(TemplateParam::init('recipient_id', $recipientId)); + ->parameters(BodyParam::init($request), HeaderParam::init('idempotency-key', $idempotencyKey)); $_resHandler = $this->responseHandler()->type(GetRecipientResponse::class); @@ -479,111 +432,101 @@ public function getRecipient(string $recipientId): GetRecipientResponse } /** - * Get balance information for a recipient - * - * @param string $recipientId Recipient id - * - * @return GetBalanceResponse Response from the API call + * @return GetRecipientResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getBalance(string $recipientId): GetBalanceResponse + public function getDefaultRecipient(): GetRecipientResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/{recipient_id}/balance') - ->auth('httpBasic') - ->parameters(TemplateParam::init('recipient_id', $recipientId)); + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/default')->auth('httpBasic'); - $_resHandler = $this->responseHandler()->type(GetBalanceResponse::class); + $_resHandler = $this->responseHandler()->type(GetRecipientResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Gets a paginated list of transfers for the recipient + * Creates an anticipation * - * @param string $recipientId - * @param int|null $page - * @param int|null $size - * @param string|null $status - * @param \DateTime|null $createdSince - * @param \DateTime|null $createdUntil + * @param string $recipientId Recipient id + * @param CreateAnticipationRequest $request Anticipation data + * @param string|null $idempotencyKey * - * @return ListWithdrawals Response from the API call + * @return GetAnticipationResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getWithdrawals( + public function createAnticipation( 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') + CreateAnticipationRequest $request, + ?string $idempotencyKey = null + ): GetAnticipationResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/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('created_since', $createdSince) - ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), - QueryParam::init('created_until', $createdUntil) - ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']) + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(ListWithdrawals::class); + $_resHandler = $this->responseHandler()->type(GetAnticipationResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Creates a transfer for a recipient + * Gets the anticipation limits for a recipient * - * @param string $recipientId Recipient Id - * @param CreateTransferRequest $request Transfer data - * @param string|null $idempotencyKey + * @param string $recipientId Recipient id + * @param string $timeframe Timeframe + * @param \DateTime $paymentDate Anticipation payment date * - * @return GetTransferResponse Response from the API call + * @return GetAnticipationLimitResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function createTransfer( + public function getAnticipationLimits( string $recipientId, - CreateTransferRequest $request, - ?string $idempotencyKey = null - ): GetTransferResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/recipients/{recipient_id}/transfers') + string $timeframe, + \DateTime $paymentDate + ): GetAnticipationLimitResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/{recipient_id}/anticipation_limits') ->auth('httpBasic') ->parameters( TemplateParam::init('recipient_id', $recipientId), - BodyParam::init($request), - HeaderParam::init('idempotency-key', $idempotencyKey) + QueryParam::init('timeframe', $timeframe), + QueryParam::init('payment_date', $paymentDate) + ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']) ); - $_resHandler = $this->responseHandler()->type(GetTransferResponse::class); + $_resHandler = $this->responseHandler()->type(GetAnticipationLimitResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Creates a new recipient + * Updates recipient metadata * - * @param CreateRecipientRequest $request Recipient data + * @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 createRecipient( - CreateRecipientRequest $request, + public function updateRecipientMetadata( + string $recipientId, + UpdateMetadataRequest $request, ?string $idempotencyKey = null ): GetRecipientResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/recipients') + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/recipients/{recipient_id}/metadata') ->auth('httpBasic') - ->parameters(BodyParam::init($request), HeaderParam::init('idempotency-key', $idempotencyKey)); + ->parameters( + TemplateParam::init('recipient_id', $recipientId), + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) + ); $_resHandler = $this->responseHandler()->type(GetRecipientResponse::class); @@ -591,35 +534,92 @@ public function createRecipient( } /** - * Retrieves recipient information + * Retrieves a paginated list of anticipations from a recipient * - * @param string $code Recipient code + * @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 GetRecipientResponse Response from the API call + * @return ListAnticipationResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getRecipientByCode(string $code): GetRecipientResponse - { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/{code}') + 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('code', $code)); + ->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(GetRecipientResponse::class); + $_resHandler = $this->responseHandler()->type(ListAnticipationResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * @return GetRecipientResponse Response from the API call + * 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 getDefaultRecipient(): GetRecipientResponse - { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/default')->auth('httpBasic'); + 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') + ->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']) + ); - $_resHandler = $this->responseHandler()->type(GetRecipientResponse::class); + $_resHandler = $this->responseHandler()->type(ListWithdrawals::class); return $this->execute($_reqBuilder, $_resHandler); } @@ -627,7 +627,7 @@ public function getDefaultRecipient(): GetRecipientResponse /** * Create a KYC link * - * @param string $recipientId + * @param string $recipientId Recipient id * * @return CreateKYCLinkResponse Response from the API call * diff --git a/src/Controllers/SubscriptionsController.php b/src/Controllers/SubscriptionsController.php index e1df1b4..a7cf2dc 100644 --- a/src/Controllers/SubscriptionsController.php +++ b/src/Controllers/SubscriptionsController.php @@ -52,44 +52,51 @@ class SubscriptionsController extends BaseController { /** - * @param string $subscriptionId + * Updates the credit card from a subscription + * + * @param string $subscriptionId Subscription id + * @param UpdateSubscriptionCardRequest $request Request for updating a card * @param string|null $idempotencyKey * - * @return GetPeriodResponse Response from the API call + * @return GetSubscriptionResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function renewSubscription(string $subscriptionId, ?string $idempotencyKey = null): GetPeriodResponse - { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/subscriptions/{subscription_id}/cycles') + public function updateSubscriptionCard( + string $subscriptionId, + UpdateSubscriptionCardRequest $request, + ?string $idempotencyKey = null + ): GetSubscriptionResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/subscriptions/{subscription_id}/card') ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), + BodyParam::init($request), HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetPeriodResponse::class); + $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Updates the credit card from a subscription + * Creates a discount * * @param string $subscriptionId Subscription id - * @param UpdateSubscriptionCardRequest $request Request for updating a card + * @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 updateSubscriptionCard( + public function createDiscount( string $subscriptionId, - UpdateSubscriptionCardRequest $request, + CreateDiscountRequest $request, ?string $idempotencyKey = null - ): GetSubscriptionResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/subscriptions/{subscription_id}/card') + ): GetDiscountResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/subscriptions/{subscription_id}/discounts') ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), @@ -97,63 +104,59 @@ public function updateSubscriptionCard( HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); + $_resHandler = $this->responseHandler()->type(GetDiscountResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Deletes a usage + * Updates the billing date from a subscription * * @param string $subscriptionId The subscription id - * @param string $itemId The subscription item id - * @param string $usageId The usage id + * @param UpdateSubscriptionBillingDateRequest $request Request for updating the subscription + * billing date * @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( + public function updateSubscriptionBillingDate( string $subscriptionId, - string $itemId, - string $usageId, + UpdateSubscriptionBillingDateRequest $request, ?string $idempotencyKey = null - ): GetUsageResponse { - $_reqBuilder = $this->requestBuilder( - RequestMethod::DELETE, - '/subscriptions/{subscription_id}/items/{item_id}/usages/{usage_id}' - ) + ): GetSubscriptionResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/subscriptions/{subscription_id}/billing-date') ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), - TemplateParam::init('item_id', $itemId), - TemplateParam::init('usage_id', $usageId), + BodyParam::init($request), HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetUsageResponse::class); + $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Creates a discount + * Updates the start at date from a subscription * - * @param string $subscriptionId Subscription id - * @param CreateDiscountRequest $request Request for creating a discount + * @param string $subscriptionId The subscription id + * @param UpdateSubscriptionStartAtRequest $request Request for updating the subscription start + * date * @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 updateSubscriptionStartAt( string $subscriptionId, - CreateDiscountRequest $request, + UpdateSubscriptionStartAtRequest $request, ?string $idempotencyKey = null - ): GetDiscountResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/subscriptions/{subscription_id}/discounts') + ): GetSubscriptionResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/subscriptions/{subscription_id}/start-at') ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), @@ -161,59 +164,97 @@ 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); } /** - * Create Usage + * Gets a subscription * * @param string $subscriptionId Subscription id - * @param string $itemId Item id - * @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 createAnUsage( + 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, string $itemId, - ?string $idempotencyKey = null - ): GetUsageResponse { + ?int $page = null, + ?int $size = null, + ?string $code = null, + ?string $group = null, + ?\DateTime $usedSince = null, + ?\DateTime $usedUntil = null + ): ListUsagesResponse { $_reqBuilder = $this->requestBuilder( - RequestMethod::POST, + RequestMethod::GET, '/subscriptions/{subscription_id}/items/{item_id}/usages' ) ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), TemplateParam::init('item_id', $itemId), - HeaderParam::init('idempotency-key', $idempotencyKey) + 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(GetUsageResponse::class); + $_resHandler = $this->responseHandler()->type(ListUsagesResponse::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 UpdateCurrentCycleEndDateRequest $request Request for updating the end date of the + * current signature cycle * @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 updateLatestPeriodEndAt( string $subscriptionId, - UpdateCurrentCycleStatusRequest $request, + UpdateCurrentCycleEndDateRequest $request, ?string $idempotencyKey = null - ): void { - $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/subscriptions/{subscription_id}/cycle-status') + ): GetSubscriptionResponse { + $_reqBuilder = $this->requestBuilder( + RequestMethod::PATCH, + '/subscriptions/{subscription_id}/periods/latest/end-at' + ) ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), @@ -221,7 +262,9 @@ public function updateCurrentCycleStatus( HeaderParam::init('idempotency-key', $idempotencyKey) ); - $this->execute($_reqBuilder); + $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); + + return $this->execute($_reqBuilder, $_resHandler); } /** @@ -256,53 +299,6 @@ public function deleteDiscount( 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 - * - * @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') - ->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) - ); - - $_resHandler = $this->responseHandler()->type(ListSubscriptionItemsResponse::class); - - return $this->execute($_reqBuilder, $_resHandler); - } - /** * Updates the payment method from a subscription * @@ -337,110 +333,76 @@ public function updateSubscriptionPaymentMethod( } /** - * Get Subscription Item + * Cancels a subscription * - * @param string $subscriptionId Subscription Id - * @param string $itemId Item id + * @param string $subscriptionId Subscription id + * @param CreateCancelSubscriptionRequest|null $request Request for cancelling a subscription + * @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 getSubscriptionItem(string $subscriptionId, string $itemId): GetSubscriptionItemResponse - { - $_reqBuilder = $this->requestBuilder( - RequestMethod::GET, - '/subscriptions/{subscription_id}/items/{item_id}' - ) + public function cancelSubscription( + string $subscriptionId, + ?CreateCancelSubscriptionRequest $request = null, + ?string $idempotencyKey = null + ): GetSubscriptionResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/subscriptions/{subscription_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); } /** - * Gets all subscriptions + * Creates a new 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 CreateSubscriptionRequest $body Request for creating a subscription + * @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') + public function createSubscription( + CreateSubscriptionRequest $body, + ?string $idempotencyKey = null + ): GetSubscriptionResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/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']) - ); + ->parameters(BodyParam::init($body), HeaderParam::init('idempotency-key', $idempotencyKey)); - $_resHandler = $this->responseHandler()->type(ListSubscriptionsResponse::class); + $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Cancels a subscription - * - * @param string $subscriptionId Subscription id - * @param CreateCancelSubscriptionRequest|null $request Request for cancelling a subscription + * @param string $subscriptionId + * @param UpdateSubscriptionAffiliationIdRequest $request Request for updating a subscription + * affiliation id * @param string|null $idempotencyKey * * @return GetSubscriptionResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function cancelSubscription( + public function updateSubscriptionAffiliationId( string $subscriptionId, - ?CreateCancelSubscriptionRequest $request = null, + UpdateSubscriptionAffiliationIdRequest $request, ?string $idempotencyKey = null ): GetSubscriptionResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/subscriptions/{subscription_id}') + $_reqBuilder = $this->requestBuilder( + RequestMethod::PATCH, + '/subscriptions/{subscription_id}/gateway-affiliation-id' + ) ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), @@ -454,22 +416,26 @@ public function cancelSubscription( } /** - * Creates a increment + * Atualização do valor mínimo da assinatura * - * @param string $subscriptionId Subscription id - * @param CreateIncrementRequest $request Request for creating a increment + * @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 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 updateSubscriptionMiniumPrice( string $subscriptionId, - CreateIncrementRequest $request, + UpdateSubscriptionMinimumPriceRequest $request, ?string $idempotencyKey = null - ): GetIncrementResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/subscriptions/{subscription_id}/increments') + ): GetSubscriptionResponse { + $_reqBuilder = $this->requestBuilder( + RequestMethod::PATCH, + '/subscriptions/{subscription_id}/minimum_price' + ) ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), @@ -477,167 +443,166 @@ 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 - * - * @param string $subscriptionId Subscription Id - * @param string $itemId Item id - * @param CreateUsageRequest $body Request for creating a usage - * @param string|null $idempotencyKey + * @param string $subscriptionId The subscription id + * @param string $cycleId * - * @return GetUsageResponse Response from the API call + * @return GetPeriodResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function createUsage( - string $subscriptionId, - string $itemId, - CreateUsageRequest $body, - ?string $idempotencyKey = null - ): GetUsageResponse { + public function getSubscriptionCycleById(string $subscriptionId, string $cycleId): GetPeriodResponse + { $_reqBuilder = $this->requestBuilder( - RequestMethod::POST, - '/subscriptions/{subscription_id}/items/{item_id}/usages' + RequestMethod::GET, + '/subscriptions/{subscription_id}/cycles/{cycleId}' ) ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), - TemplateParam::init('item_id', $itemId), - BodyParam::init($body), - HeaderParam::init('idempotency-key', $idempotencyKey) + TemplateParam::init('cycleId', $cycleId) ); - $_resHandler = $this->responseHandler()->type(GetUsageResponse::class); + $_resHandler = $this->responseHandler()->type(GetPeriodResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * @param string $subscriptionId The subscription id - * @param string $discountId + * @param string $subscriptionId The subscription Id + * @param string $periodId The period Id * - * @return GetDiscountResponse Response from the API call + * @return GetUsageReportResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getDiscountById(string $subscriptionId, string $discountId): GetDiscountResponse + public function getUsageReport(string $subscriptionId, string $periodId): GetUsageReportResponse { $_reqBuilder = $this->requestBuilder( RequestMethod::GET, - '/subscriptions/{subscription_id}/discounts/{discountId}' + '/subscriptions/{subscription_id}/periods/{period_id}/usages/report' ) ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), - TemplateParam::init('discountId', $discountId) + TemplateParam::init('period_id', $periodId) ); - $_resHandler = $this->responseHandler()->type(GetDiscountResponse::class); + $_resHandler = $this->responseHandler()->type(GetUsageReportResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Creates a new subscription - * - * @param CreateSubscriptionRequest $body Request for creating a subscription + * @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 createSubscription( - CreateSubscriptionRequest $body, - ?string $idempotencyKey = null - ): GetSubscriptionResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/subscriptions') + public function renewSubscription(string $subscriptionId, ?string $idempotencyKey = null): GetPeriodResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/subscriptions/{subscription_id}/cycles') ->auth('httpBasic') - ->parameters(BodyParam::init($body), HeaderParam::init('idempotency-key', $idempotencyKey)); + ->parameters( + TemplateParam::init('subscription_id', $subscriptionId), + HeaderParam::init('idempotency-key', $idempotencyKey) + ); - $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); + $_resHandler = $this->responseHandler()->type(GetPeriodResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * @param string $subscriptionId The subscription Id - * @param string $incrementId The increment Id + * Deletes a usage * - * @return GetIncrementResponse Response from the API call + * @param string $subscriptionId The subscription id + * @param string $itemId The subscription item id + * @param string $usageId The usage id + * @param string|null $idempotencyKey + * + * @return GetUsageResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getIncrementById(string $subscriptionId, string $incrementId): GetIncrementResponse - { + public function deleteUsage( + string $subscriptionId, + string $itemId, + string $usageId, + ?string $idempotencyKey = null + ): GetUsageResponse { $_reqBuilder = $this->requestBuilder( - RequestMethod::GET, - '/subscriptions/{subscription_id}/increments/{increment_id}' + RequestMethod::DELETE, + '/subscriptions/{subscription_id}/items/{item_id}/usages/{usage_id}' ) ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), - TemplateParam::init('increment_id', $incrementId) + TemplateParam::init('item_id', $itemId), + TemplateParam::init('usage_id', $usageId), + HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetIncrementResponse::class); + $_resHandler = $this->responseHandler()->type(GetUsageResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * @param string $subscriptionId - * @param UpdateSubscriptionAffiliationIdRequest $request Request for updating a subscription - * affiliation id + * Create Usage + * + * @param string $subscriptionId Subscription id + * @param string $itemId Item 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 updateSubscriptionAffiliationId( + public function createAnUsage( string $subscriptionId, - UpdateSubscriptionAffiliationIdRequest $request, + string $itemId, ?string $idempotencyKey = null - ): GetSubscriptionResponse { + ): GetUsageResponse { $_reqBuilder = $this->requestBuilder( - RequestMethod::PATCH, - '/subscriptions/{subscription_id}/gateway-affiliation-id' + RequestMethod::POST, + '/subscriptions/{subscription_id}/items/{item_id}/usages' ) ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), - BodyParam::init($request), + TemplateParam::init('item_id', $itemId), HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); + $_resHandler = $this->responseHandler()->type(GetUsageResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Updates the metadata from a subscription - * - * @param string $subscriptionId The subscription id - * @param UpdateMetadataRequest $request Request for updating the subscrption metadata + * @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 updateSubscriptionMetadata( + public function updateCurrentCycleStatus( string $subscriptionId, - UpdateMetadataRequest $request, + UpdateCurrentCycleStatusRequest $request, ?string $idempotencyKey = null - ): GetSubscriptionResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/Subscriptions/{subscription_id}/metadata') + ): void { + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/subscriptions/{subscription_id}/cycle-status') ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), @@ -645,7 +610,57 @@ public function updateSubscriptionMetadata( HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); + $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 + { + $_reqBuilder = $this->requestBuilder( + RequestMethod::GET, + '/subscriptions/{subscription_id}/items/{item_id}' + ) + ->auth('httpBasic') + ->parameters( + TemplateParam::init('subscription_id', $subscriptionId), + TemplateParam::init('item_id', $itemId) + ); + + $_resHandler = $this->responseHandler()->type(GetSubscriptionItemResponse::class); + + return $this->execute($_reqBuilder, $_resHandler); + } + + /** + * @param string $subscriptionId The subscription Id + * @param string $incrementId The increment Id + * + * @return GetIncrementResponse 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}' + ) + ->auth('httpBasic') + ->parameters( + TemplateParam::init('subscription_id', $subscriptionId), + TemplateParam::init('increment_id', $incrementId) + ); + + $_resHandler = $this->responseHandler()->type(GetIncrementResponse::class); return $this->execute($_reqBuilder, $_resHandler); } @@ -682,30 +697,6 @@ 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 @@ -731,23 +722,25 @@ public function getDiscounts(string $subscriptionId, int $page, int $size): List } /** - * Updates the billing date from a subscription + * Updates the boleto due days from a subscription * - * @param string $subscriptionId The subscription id - * @param UpdateSubscriptionBillingDateRequest $request Request for updating the subscription - * billing date + * @param string $subscriptionId Subscription Id + * @param UpdateSubscriptionDueDaysRequest $request * @param string|null $idempotencyKey * * @return GetSubscriptionResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateSubscriptionBillingDate( + public function updateSubscriptionDueDays( string $subscriptionId, - UpdateSubscriptionBillingDateRequest $request, + UpdateSubscriptionDueDaysRequest $request, ?string $idempotencyKey = null ): GetSubscriptionResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/subscriptions/{subscription_id}/billing-date') + $_reqBuilder = $this->requestBuilder( + RequestMethod::PATCH, + '/subscriptions/{subscription_id}/boleto-due-days' + ) ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), @@ -761,29 +754,26 @@ public function updateSubscriptionBillingDate( } /** - * Deletes a subscription item + * Creates a new Subscription item * * @param string $subscriptionId Subscription id - * @param string $subscriptionItemId Subscription item 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 deleteSubscriptionItem( + public function createSubscriptionItem( string $subscriptionId, - string $subscriptionItemId, + CreateSubscriptionItemRequest $request, ?string $idempotencyKey = null ): GetSubscriptionItemResponse { - $_reqBuilder = $this->requestBuilder( - RequestMethod::DELETE, - '/subscriptions/{subscription_id}/items/{subscription_item_id}' - ) + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/subscriptions/{subscription_id}/items') ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), - TemplateParam::init('subscription_item_id', $subscriptionItemId), + BodyParam::init($request), HeaderParam::init('idempotency-key', $idempotencyKey) ); @@ -793,241 +783,240 @@ public function deleteSubscriptionItem( } /** - * @param string $subscriptionId The subscription id - * @param int|null $page Page number - * @param int|null $size Page size + * @param string $id Subscription's id + * @param UpdateSubscriptionSplitRequest $request * - * @return ListIncrementsResponse Response from the API call + * @return GetSubscriptionResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getIncrements(string $subscriptionId, ?int $page = null, ?int $size = null): ListIncrementsResponse - { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/subscriptions/{subscription_id}/increments/') + public function updateSplitSubscription( + string $id, + UpdateSubscriptionSplitRequest $request + ): GetSubscriptionResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/subscriptions/{id}/split') ->auth('httpBasic') - ->parameters( - TemplateParam::init('subscription_id', $subscriptionId), - QueryParam::init('page', $page), - QueryParam::init('size', $size) - ); + ->parameters(TemplateParam::init('id', $id), BodyParam::init($request)); - $_resHandler = $this->responseHandler()->type(ListIncrementsResponse::class); + $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Updates the boleto due days from a subscription + * Get Subscription Items * - * @param string $subscriptionId Subscription Id - * @param UpdateSubscriptionDueDaysRequest $request - * @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 updateSubscriptionDueDays( + public function getSubscriptionItems( string $subscriptionId, - UpdateSubscriptionDueDaysRequest $request, - ?string $idempotencyKey = null - ): GetSubscriptionResponse { - $_reqBuilder = $this->requestBuilder( - RequestMethod::PATCH, - '/subscriptions/{subscription_id}/boleto-due-days' - ) + ?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); } /** - * Updates the start at date from a subscription + * Gets all subscriptions * - * @param string $subscriptionId The subscription id - * @param UpdateSubscriptionStartAtRequest $request Request for updating the subscription start - * date - * @param string|null $idempotencyKey + * @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 GetSubscriptionResponse Response from the API call + * @return ListSubscriptionsResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateSubscriptionStartAt( - string $subscriptionId, - UpdateSubscriptionStartAtRequest $request, - ?string $idempotencyKey = null - ): GetSubscriptionResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/subscriptions/{subscription_id}/start-at') + 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); } /** - * Updates a subscription item + * Creates a increment * - * @param string $subscriptionId Subscription Id - * @param string $itemId Item id - * @param UpdateSubscriptionItemRequest $body Request for updating a subscription item + * @param string $subscriptionId Subscription id + * @param CreateIncrementRequest $request Request for creating a increment * @param string|null $idempotencyKey * - * @return GetSubscriptionItemResponse Response from the API call + * @return GetIncrementResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateSubscriptionItem( + public function createIncrement( string $subscriptionId, - string $itemId, - UpdateSubscriptionItemRequest $body, + CreateIncrementRequest $request, ?string $idempotencyKey = null - ): GetSubscriptionItemResponse { - $_reqBuilder = $this->requestBuilder( - RequestMethod::PUT, - '/subscriptions/{subscription_id}/items/{item_id}' - ) + ): GetIncrementResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/subscriptions/{subscription_id}/increments') ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), - TemplateParam::init('item_id', $itemId), - BodyParam::init($body), + BodyParam::init($request), HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetSubscriptionItemResponse::class); + $_resHandler = $this->responseHandler()->type(GetIncrementResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Creates a new Subscription item + * Creates a usage * - * @param string $subscriptionId Subscription id - * @param CreateSubscriptionItemRequest $request Request for creating a subscription item + * @param string $subscriptionId Subscription Id + * @param string $itemId Item id + * @param CreateUsageRequest $body Request for creating a usage * @param string|null $idempotencyKey * - * @return GetSubscriptionItemResponse Response from the API call + * @return GetUsageResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function createSubscriptionItem( + public function createUsage( string $subscriptionId, - CreateSubscriptionItemRequest $request, + string $itemId, + CreateUsageRequest $body, ?string $idempotencyKey = null - ): GetSubscriptionItemResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/subscriptions/{subscription_id}/items') + ): GetUsageResponse { + $_reqBuilder = $this->requestBuilder( + RequestMethod::POST, + '/subscriptions/{subscription_id}/items/{item_id}/usages' + ) ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), - BodyParam::init($request), + TemplateParam::init('item_id', $itemId), + BodyParam::init($body), HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetSubscriptionItemResponse::class); - - return $this->execute($_reqBuilder, $_resHandler); - } - - /** - * Gets a subscription - * - * @param string $subscriptionId Subscription id - * - * @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); + $_resHandler = $this->responseHandler()->type(GetUsageResponse::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 + * @param string $discountId * - * @return ListUsagesResponse Response from the API call + * @return GetDiscountResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getUsages( - string $subscriptionId, - string $itemId, - ?int $page = null, - ?int $size = null, - ?string $code = null, - ?string $group = null, - ?\DateTime $usedSince = null, - ?\DateTime $usedUntil = null - ): ListUsagesResponse { + public function getDiscountById(string $subscriptionId, string $discountId): GetDiscountResponse + { $_reqBuilder = $this->requestBuilder( RequestMethod::GET, - '/subscriptions/{subscription_id}/items/{item_id}/usages' + '/subscriptions/{subscription_id}/discounts/{discountId}' ) ->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']) + TemplateParam::init('discountId', $discountId) ); - $_resHandler = $this->responseHandler()->type(ListUsagesResponse::class); + $_resHandler = $this->responseHandler()->type(GetDiscountResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * @param string $subscriptionId - * @param UpdateCurrentCycleEndDateRequest $request Request for updating the end date of the - * current signature cycle + * Updates the metadata from a subscription + * + * @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 updateLatestPeriodEndAt( + public function updateSubscriptionMetadata( string $subscriptionId, - UpdateCurrentCycleEndDateRequest $request, + UpdateMetadataRequest $request, ?string $idempotencyKey = null ): GetSubscriptionResponse { - $_reqBuilder = $this->requestBuilder( - RequestMethod::PATCH, - '/subscriptions/{subscription_id}/periods/latest/end-at' - ) + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/Subscriptions/{subscription_id}/metadata') ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), @@ -1041,105 +1030,116 @@ public function updateLatestPeriodEndAt( } /** - * Atualização do valor mínimo da assinatura - * * @param string $subscriptionId Subscription Id - * @param UpdateSubscriptionMinimumPriceRequest $request Request da requisição com o valor - * mínimo que será configurado - * @param string|null $idempotencyKey + * @param string $page Page number + * @param string $size Page size * - * @return GetSubscriptionResponse Response from the API call + * @return ListCyclesResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateSubscriptionMiniumPrice( - string $subscriptionId, - UpdateSubscriptionMinimumPriceRequest $request, - ?string $idempotencyKey = null - ): GetSubscriptionResponse { - $_reqBuilder = $this->requestBuilder( - RequestMethod::PATCH, - '/subscriptions/{subscription_id}/minimum_price' - ) + 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), - BodyParam::init($request), - HeaderParam::init('idempotency-key', $idempotencyKey) + QueryParam::init('page', $page), + QueryParam::init('size', $size) ); - $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); + $_resHandler = $this->responseHandler()->type(ListCyclesResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * @param string $subscriptionId The subscription id - * @param string $cycleId + * Deletes a subscription item * - * @return GetPeriodResponse Response from the API call + * @param string $subscriptionId Subscription id + * @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 getSubscriptionCycleById(string $subscriptionId, string $cycleId): GetPeriodResponse - { + public function deleteSubscriptionItem( + string $subscriptionId, + string $subscriptionItemId, + ?string $idempotencyKey = null + ): GetSubscriptionItemResponse { $_reqBuilder = $this->requestBuilder( - RequestMethod::GET, - '/subscriptions/{subscription_id}/cycles/{cycleId}' + RequestMethod::DELETE, + '/subscriptions/{subscription_id}/items/{subscription_item_id}' ) ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), - TemplateParam::init('cycleId', $cycleId) + TemplateParam::init('subscription_item_id', $subscriptionItemId), + HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetPeriodResponse::class); + $_resHandler = $this->responseHandler()->type(GetSubscriptionItemResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * @param string $subscriptionId The subscription Id - * @param string $periodId The period Id + * @param string $subscriptionId The subscription id + * @param int|null $page Page number + * @param int|null $size Page size * - * @return GetUsageReportResponse Response from the API call + * @return ListIncrementsResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getUsageReport(string $subscriptionId, string $periodId): GetUsageReportResponse + public function getIncrements(string $subscriptionId, ?int $page = null, ?int $size = null): ListIncrementsResponse { - $_reqBuilder = $this->requestBuilder( - RequestMethod::GET, - '/subscriptions/{subscription_id}/periods/{period_id}/usages/report' - ) + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/subscriptions/{subscription_id}/increments/') ->auth('httpBasic') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), - TemplateParam::init('period_id', $periodId) + QueryParam::init('page', $page), + QueryParam::init('size', $size) ); - $_resHandler = $this->responseHandler()->type(GetUsageReportResponse::class); + $_resHandler = $this->responseHandler()->type(ListIncrementsResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * @param string $id Subscription's id - * @param UpdateSubscriptionSplitRequest $request + * Updates a subscription item * - * @return GetSubscriptionResponse Response from the API call + * @param string $subscriptionId Subscription Id + * @param string $itemId Item id + * @param UpdateSubscriptionItemRequest $body Request for updating a subscription item + * @param string|null $idempotencyKey + * + * @return GetSubscriptionItemResponse 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') + public function updateSubscriptionItem( + string $subscriptionId, + string $itemId, + UpdateSubscriptionItemRequest $body, + ?string $idempotencyKey = null + ): GetSubscriptionItemResponse { + $_reqBuilder = $this->requestBuilder( + RequestMethod::PUT, + '/subscriptions/{subscription_id}/items/{item_id}' + ) ->auth('httpBasic') - ->parameters(TemplateParam::init('id', $id), BodyParam::init($request)); + ->parameters( + TemplateParam::init('subscription_id', $subscriptionId), + TemplateParam::init('item_id', $itemId), + BodyParam::init($body), + HeaderParam::init('idempotency-key', $idempotencyKey) + ); - $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); + $_resHandler = $this->responseHandler()->type(GetSubscriptionItemResponse::class); return $this->execute($_reqBuilder, $_resHandler); } diff --git a/src/Controllers/TokensController.php b/src/Controllers/TokensController.php index 93b56be..87e0e5c 100644 --- a/src/Controllers/TokensController.php +++ b/src/Controllers/TokensController.php @@ -21,25 +21,19 @@ class TokensController extends BaseController { /** + * Gets a token from its id + * + * @param string $id Token id * @param string $publicKey Public key - * @param CreateTokenRequest $request Request for creating a token - * @param string|null $idempotencyKey * * @return GetTokenResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function createToken( - string $publicKey, - CreateTokenRequest $request, - ?string $idempotencyKey = null - ): GetTokenResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/tokens?appId={public_key}') - ->parameters( - TemplateParam::init('public_key', $publicKey), - BodyParam::init($request), - HeaderParam::init('idempotency-key', $idempotencyKey) - ); + 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); @@ -47,19 +41,25 @@ public function createToken( } /** - * Gets a token from its id - * - * @param string $id Token id * @param string $publicKey Public key + * @param CreateTokenRequest $request Request for creating a token + * @param string|null $idempotencyKey * * @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)); + public function createToken( + string $publicKey, + CreateTokenRequest $request, + ?string $idempotencyKey = null + ): GetTokenResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/tokens?appId={public_key}') + ->parameters( + TemplateParam::init('public_key', $publicKey), + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) + ); $_resHandler = $this->responseHandler()->type(GetTokenResponse::class); diff --git a/src/Controllers/TransfersController.php b/src/Controllers/TransfersController.php index ae71c1e..b9611cf 100644 --- a/src/Controllers/TransfersController.php +++ b/src/Controllers/TransfersController.php @@ -39,35 +39,35 @@ public function getTransferById(string $transferId): GetTransfer } /** - * @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); } /** - * 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); } diff --git a/src/PagarmeApiSDKClient.php b/src/PagarmeApiSDKClient.php index 7713e74..6075532 100644 --- a/src/PagarmeApiSDKClient.php +++ b/src/PagarmeApiSDKClient.php @@ -74,10 +74,7 @@ class PagarmeApiSDKClient implements ConfigurationInterface public function __construct(array $config = []) { $this->config = array_merge(ConfigurationDefaults::_ALL, CoreHelper::clone($config)); - $this->basicAuthManager = new BasicAuthManager( - $this->config['basicAuthUserName'] ?? ConfigurationDefaults::BASIC_AUTH_USER_NAME, - $this->config['basicAuthPassword'] ?? ConfigurationDefaults::BASIC_AUTH_PASSWORD - ); + $this->basicAuthManager = new BasicAuthManager($this->config); $this->client = ClientBuilder::init(new HttpClient(Configuration::init($this))) ->converter(new CompatibilityConverter()) ->jsonHelper(ApiHelper::getJsonHelper())