diff --git a/README.md b/README.md index aa2437c..47b0f82 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.4/doc/client.md) +**_Note:_** Documentation for the client can be found [here.](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/client.md) The following parameters are configurable for the API Client: @@ -115,54 +115,46 @@ 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'` | -| `basicAuthUserName` | `string` | The username to use with basic authentication | -| `basicAuthPassword` | `string` | The password to use with basic authentication | The API client can be initialized as follows: ```php $client = PagarmeApiSDKClientBuilder::init() - ->basicAuthUserName('BasicAuthUserName') - ->basicAuthPassword('BasicAuthPassword') ->serviceRefererName('ServiceRefererName') ->build(); ``` -## Authorization - -This API uses `Basic Authentication`. - ## API Errors 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.4/doc/models/error-exception.md) | -| 401 | Invalid API key | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.4/doc/models/error-exception.md) | -| 404 | An informed resource was not found | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.4/doc/models/error-exception.md) | -| 412 | Business validation error | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.4/doc/models/error-exception.md) | -| 422 | Contract validation error | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.4/doc/models/error-exception.md) | -| 500 | Internal server error | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.4/doc/models/error-exception.md) | +| 400 | Invalid request | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/models/error-exception.md) | +| 401 | Invalid API key | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/models/error-exception.md) | +| 404 | An informed resource was not found | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/models/error-exception.md) | +| 412 | Business validation error | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/models/error-exception.md) | +| 422 | Contract validation error | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/models/error-exception.md) | +| 500 | Internal server error | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/models/error-exception.md) | ## List of APIs -* [Subscriptions](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.4/doc/controllers/subscriptions.md) -* [Orders](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.4/doc/controllers/orders.md) -* [Plans](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.4/doc/controllers/plans.md) -* [Invoices](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.4/doc/controllers/invoices.md) -* [Customers](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.4/doc/controllers/customers.md) -* [Charges](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.4/doc/controllers/charges.md) -* [Recipients](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.4/doc/controllers/recipients.md) -* [Tokens](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.4/doc/controllers/tokens.md) -* [Transactions](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.4/doc/controllers/transactions.md) -* [Transfers](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.4/doc/controllers/transfers.md) -* [Payables](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.4/doc/controllers/payables.md) -* [Balance Operations](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.4/doc/controllers/balance-operations.md) +* [Subscriptions](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/controllers/subscriptions.md) +* [Orders](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/controllers/orders.md) +* [Plans](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/controllers/plans.md) +* [Invoices](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/controllers/invoices.md) +* [Customers](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/controllers/customers.md) +* [Charges](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/controllers/charges.md) +* [Recipients](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/controllers/recipients.md) +* [Tokens](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/controllers/tokens.md) +* [Transactions](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/controllers/transactions.md) +* [Transfers](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/controllers/transfers.md) +* [Payables](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/controllers/payables.md) +* [Balance Operations](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/controllers/balance-operations.md) ## Classes Documentation -* [ApiException](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.4/doc/api-exception.md) -* [HttpRequest](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.4/doc/http-request.md) -* [HttpResponse](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.4/doc/http-response.md) +* [ApiException](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/api-exception.md) +* [HttpRequest](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/http-request.md) +* [HttpResponse](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/http-response.md) diff --git a/doc/client.md b/doc/client.md index d437a11..0071fb8 100644 --- a/doc/client.md +++ b/doc/client.md @@ -15,15 +15,11 @@ 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'` | -| `basicAuthUserName` | `string` | The username to use with basic authentication | -| `basicAuthPassword` | `string` | The password to use with basic authentication | The API client can be initialized as follows: ```php $client = PagarmeApiSDKClientBuilder::init() - ->basicAuthUserName('BasicAuthUserName') - ->basicAuthPassword('BasicAuthPassword') ->serviceRefererName('ServiceRefererName') ->build(); ``` diff --git a/doc/controllers/charges.md b/doc/controllers/charges.md index d0529df..525cdd3 100644 --- a/doc/controllers/charges.md +++ b/doc/controllers/charges.md @@ -12,17 +12,17 @@ $chargesController = $client->getChargesController(); * [Update Charge Metadata](../../doc/controllers/charges.md#update-charge-metadata) * [Update Charge Payment Method](../../doc/controllers/charges.md#update-charge-payment-method) -* [Update Charge Card](../../doc/controllers/charges.md#update-charge-card) -* [Get Charges Summary](../../doc/controllers/charges.md#get-charges-summary) -* [Create Charge](../../doc/controllers/charges.md#create-charge) * [Get Charge Transactions](../../doc/controllers/charges.md#get-charge-transactions) +* [Update Charge Due Date](../../doc/controllers/charges.md#update-charge-due-date) +* [Get Charges](../../doc/controllers/charges.md#get-charges) * [Capture Charge](../../doc/controllers/charges.md#capture-charge) +* [Update Charge Card](../../doc/controllers/charges.md#update-charge-card) * [Get Charge](../../doc/controllers/charges.md#get-charge) +* [Get Charges Summary](../../doc/controllers/charges.md#get-charges-summary) +* [Retry Charge](../../doc/controllers/charges.md#retry-charge) * [Cancel Charge](../../doc/controllers/charges.md#cancel-charge) -* [Get Charges](../../doc/controllers/charges.md#get-charges) +* [Create Charge](../../doc/controllers/charges.md#create-charge) * [Confirm Payment](../../doc/controllers/charges.md#confirm-payment) -* [Update Charge Due Date](../../doc/controllers/charges.md#update-charge-due-date) -* [Retry Charge](../../doc/controllers/charges.md#retry-charge) # Update Charge Metadata @@ -148,155 +148,159 @@ $result = $chargesController->updateChargePaymentMethod( ``` -# Update Charge Card - -Updates the card from a charge +# Get Charge Transactions ```php -function updateChargeCard( +function getChargeTransactions( string $chargeId, - UpdateChargeCardRequest $request, - ?string $idempotencyKey = null -): GetChargeResponse + ?int $page = null, + ?int $size = null +): ListChargeTransactionsResponse ``` ## Parameters | 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 | -| `idempotencyKey` | `?string` | Header, Optional | - | +| `chargeId` | `string` | Template, Required | Charge Id | +| `page` | `?int` | Query, Optional | Page number | +| `size` | `?int` | Query, Optional | Page size | ## Response Type -[`GetChargeResponse`](../../doc/models/get-charge-response.md) +[`ListChargeTransactionsResponse`](../../doc/models/list-charge-transactions-response.md) ## Example Usage ```php $chargeId = 'charge_id8'; -$request = UpdateChargeCardRequestBuilder::init( - false, - 'card_id2', - CreateCardRequestBuilder::init() - ->type('credit') - ->build(), - false -)->build(); - -$result = $chargesController->updateChargeCard( - $chargeId, - $request -); +$result = $chargesController->getChargeTransactions($chargeId); ``` -# Get Charges Summary +# Update Charge Due Date + +Updates the due date from a charge ```php -function getChargesSummary( - string $status, - ?\DateTime $createdSince = null, - ?\DateTime $createdUntil = null -): GetChargesSummaryResponse +function updateChargeDueDate( + string $chargeId, + UpdateChargeDueDateRequest $request, + ?string $idempotencyKey = null +): GetChargeResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `status` | `string` | Query, Required | - | -| `createdSince` | `?DateTime` | Query, Optional | - | -| `createdUntil` | `?DateTime` | Query, Optional | - | +| `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 -[`GetChargesSummaryResponse`](../../doc/models/get-charges-summary-response.md) +[`GetChargeResponse`](../../doc/models/get-charge-response.md) ## Example Usage ```php -$status = 'status8'; +$chargeId = 'charge_id8'; -$result = $chargesController->getChargesSummary($status); +$request = UpdateChargeDueDateRequestBuilder::init()->build(); + +$result = $chargesController->updateChargeDueDate( + $chargeId, + $request +); ``` -# Create Charge +# Get Charges -Creates a new charge +Lists all charges ```php -function createCharge(CreateChargeRequest $request, ?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 | | --- | --- | --- | --- | -| `request` | [`CreateChargeRequest`](../../doc/models/create-charge-request.md) | Body, Required | Request for creating 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 -$request = CreateChargeRequestBuilder::init( - 242, - CreatePaymentRequestBuilder::init( - 'payment_method4' - )->build(), - 'order_id0' -)->build(); - -$result = $chargesController->createCharge($request); +$result = $chargesController->getCharges(); ``` -# Get Charge Transactions +# Capture Charge + +Captures a charge ```php -function getChargeTransactions( +function captureCharge( string $chargeId, - ?int $page = null, - ?int $size = null -): ListChargeTransactionsResponse + ?CreateCaptureChargeRequest $request = null, + ?string $idempotencyKey = null +): 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 | +| `request` | [`?CreateCaptureChargeRequest`](../../doc/models/create-capture-charge-request.md) | Body, Optional | Request for capturing a charge | +| `idempotencyKey` | `?string` | Header, Optional | - | ## 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->captureCharge($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 ``` @@ -306,7 +310,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 @@ -318,7 +322,19 @@ 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 +); ``` @@ -349,88 +365,73 @@ $result = $chargesController->getCharge($chargeId); ``` -# Cancel Charge - -Cancel a charge +# Get Charges Summary ```php -function cancelCharge( - string $chargeId, - ?CreateCancelChargeRequest $request = null, - ?string $idempotencyKey = null -): GetChargeResponse +function getChargesSummary( + string $status, + ?\DateTime $createdSince = null, + ?\DateTime $createdUntil = null +): GetChargesSummaryResponse ``` ## 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 | - | +| `status` | `string` | Query, Required | - | +| `createdSince` | `?DateTime` | Query, Optional | - | +| `createdUntil` | `?DateTime` | Query, Optional | - | ## Response Type -[`GetChargeResponse`](../../doc/models/get-charge-response.md) +[`GetChargesSummaryResponse`](../../doc/models/get-charges-summary-response.md) ## Example Usage ```php -$chargeId = 'charge_id8'; +$status = 'status8'; -$result = $chargesController->cancelCharge($chargeId); +$result = $chargesController->getChargesSummary($status); ``` -# Get Charges +# Retry Charge -Lists all charges +Retries a charge ```php -function getCharges( - ?int $page = null, - ?int $size = null, - ?string $code = null, - ?string $status = null, - ?string $paymentMethod = null, - ?string $customerId = null, - ?string $orderId = null, - ?\DateTime $createdSince = null, - ?\DateTime $createdUntil = null -): ListChargesResponse +function retryCharge(string $chargeId, ?string $idempotencyKey = null): GetChargeResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `page` | `?int` | Query, Optional | Page number | -| `size` | `?int` | Query, Optional | Page size | -| `code` | `?string` | Query, Optional | Filter for charge's code | -| `status` | `?string` | Query, Optional | Filter for charge's status | -| `paymentMethod` | `?string` | Query, Optional | Filter for charge's payment method | -| `customerId` | `?string` | Query, Optional | Filter for charge's customer id | -| `orderId` | `?string` | Query, Optional | Filter for charge's order id | -| `createdSince` | `?DateTime` | Query, Optional | Filter for the beginning of the range for charge's creation | -| `createdUntil` | `?DateTime` | Query, Optional | Filter for the end of the range for charge's creation | +| `chargeId` | `string` | Template, Required | Charge id | +| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`ListChargesResponse`](../../doc/models/list-charges-response.md) +[`GetChargeResponse`](../../doc/models/get-charge-response.md) ## Example Usage ```php -$result = $chargesController->getCharges(); +$chargeId = 'charge_id8'; + +$result = $chargesController->retryCharge($chargeId); ``` -# Confirm Payment +# Cancel Charge + +Cancel a charge ```php -function confirmPayment( +function cancelCharge( string $chargeId, - ?CreateConfirmPaymentRequest $request = null, + ?CreateCancelChargeRequest $request = null, ?string $idempotencyKey = null ): GetChargeResponse ``` @@ -439,8 +440,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 @@ -452,28 +453,23 @@ function confirmPayment( ```php $chargeId = 'charge_id8'; -$result = $chargesController->confirmPayment($chargeId); +$result = $chargesController->cancelCharge($chargeId); ``` -# Update Charge Due Date +# Create Charge -Updates the due date from a charge +Creates a new charge ```php -function updateChargeDueDate( - string $chargeId, - UpdateChargeDueDateRequest $request, - ?string $idempotencyKey = null -): GetChargeResponse +function createCharge(CreateChargeRequest $request, ?string $idempotencyKey = null): GetChargeResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `chargeId` | `string` | Template, Required | Charge Id | -| `request` | [`UpdateChargeDueDateRequest`](../../doc/models/update-charge-due-date-request.md) | Body, Required | Request for updating the due date | +| `request` | [`CreateChargeRequest`](../../doc/models/create-charge-request.md) | Body, Required | Request for creating a charge | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -483,30 +479,34 @@ function updateChargeDueDate( ## Example Usage ```php -$chargeId = 'charge_id8'; - -$request = UpdateChargeDueDateRequestBuilder::init()->build(); +$request = CreateChargeRequestBuilder::init( + 242, + CreatePaymentRequestBuilder::init( + 'payment_method4' + )->build(), + 'order_id0' +)->build(); -$result = $chargesController->updateChargeDueDate( - $chargeId, - $request -); +$result = $chargesController->createCharge($request); ``` -# Retry Charge - -Retries a charge +# Confirm Payment ```php -function retryCharge(string $chargeId, ?string $idempotencyKey = null): GetChargeResponse +function confirmPayment( + string $chargeId, + ?CreateConfirmPaymentRequest $request = null, + ?string $idempotencyKey = null +): GetChargeResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `chargeId` | `string` | Template, Required | Charge id | +| `chargeId` | `string` | Template, Required | - | +| `request` | [`?CreateConfirmPaymentRequest`](../../doc/models/create-confirm-payment-request.md) | Body, Optional | Request for confirm payment | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -518,6 +518,6 @@ function retryCharge(string $chargeId, ?string $idempotencyKey = null): GetCharg ```php $chargeId = 'charge_id8'; -$result = $chargesController->retryCharge($chargeId); +$result = $chargesController->confirmPayment($chargeId); ``` diff --git a/doc/controllers/customers.md b/doc/controllers/customers.md index 25d6651..e6c9872 100644 --- a/doc/controllers/customers.md +++ b/doc/controllers/customers.md @@ -13,24 +13,24 @@ $customersController = $client->getCustomersController(); * [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 Address](../../doc/controllers/customers.md#create-address) * [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) +* [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) +* [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 Address](../../doc/controllers/customers.md#get-address) -* [Delete Address](../../doc/controllers/customers.md#delete-address) * [Get Access Token](../../doc/controllers/customers.md#get-access-token) * [Update Customer Metadata](../../doc/controllers/customers.md#update-customer-metadata) -* [Get Card](../../doc/controllers/customers.md#get-card) -* [Delete Access Tokens](../../doc/controllers/customers.md#delete-access-tokens) -* [Create Access Token](../../doc/controllers/customers.md#create-access-token) -* [Get Access Tokens](../../doc/controllers/customers.md#get-access-tokens) -* [Get Customers](../../doc/controllers/customers.md#get-customers) -* [Update Customer](../../doc/controllers/customers.md#update-customer) * [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 @@ -184,55 +184,6 @@ $result = $customersController->deleteAccessToken( ``` -# Create Address - -Creates a new address for a customer - -```php -function createAddress( - string $customerId, - CreateAddressRequest $request, - ?string $idempotencyKey = null -): GetAddressResponse -``` - -## Parameters - -| 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) - -## 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 -); -``` - - # Create Customer Creates a new customer @@ -285,52 +236,61 @@ $result = $customersController->createCustomer($request); ``` -# Create Card +# Create Address -Creates a new card for a customer +Creates a new address for a customer ```php -function createCard( +function createAddress( string $customerId, - CreateCardRequest $request, + CreateAddressRequest $request, ?string $idempotencyKey = null -): GetCardResponse +): GetAddressResponse ``` ## 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 | +| `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 -[`GetCardResponse`](../../doc/models/get-card-response.md) +[`GetAddressResponse`](../../doc/models/get-address-response.md) ## Example Usage ```php $customerId = 'customer_id8'; -$request = CreateCardRequestBuilder::init() - ->type('credit') - ->build(); +$request = CreateAddressRequestBuilder::init( + 'street6', + 'number4', + 'zip_code0', + 'neighborhood2', + 'city6', + 'state2', + 'country0', + 'complement2', + 'line_10', + 'line_24' +)->build(); -$result = $customersController->createCard( +$result = $customersController->createAddress( $customerId, $request ); ``` -# Get Cards +# Delete Access Tokens -Get all cards from a customer +Delete a Customer's access tokens ```php -function getCards(string $customerId, ?int $page = null, ?int $size = null): ListCardsResponse +function deleteAccessTokens(string $customerId): ListAccessTokensResponse ``` ## Parameters @@ -338,28 +298,26 @@ function getCards(string $customerId, ?int $page = null, ?int $size = null): Lis | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `customerId` | `string` | Template, Required | Customer Id | -| `page` | `?int` | Query, Optional | Page number | -| `size` | `?int` | Query, Optional | Page size | ## Response Type -[`ListCardsResponse`](../../doc/models/list-cards-response.md) +[`ListAccessTokensResponse`](../../doc/models/list-access-tokens-response.md) ## Example Usage ```php $customerId = 'customer_id8'; -$result = $customersController->getCards($customerId); +$result = $customersController->deleteAccessTokens($customerId); ``` -# Renew Card +# Get Address -Renew a card +Get a customer's address ```php -function renewCard(string $customerId, string $cardId, ?string $idempotencyKey = null): GetCardResponse +function getAddress(string $customerId, string $addressId): GetAddressResponse ``` ## Parameters @@ -367,41 +325,45 @@ function renewCard(string $customerId, string $cardId, ?string $idempotencyKey = | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `customerId` | `string` | Template, Required | Customer id | -| `cardId` | `string` | Template, Required | Card Id | -| `idempotencyKey` | `?string` | Header, Optional | - | +| `addressId` | `string` | Template, Required | Address Id | ## Response Type -[`GetCardResponse`](../../doc/models/get-card-response.md) +[`GetAddressResponse`](../../doc/models/get-address-response.md) ## Example Usage ```php $customerId = 'customer_id8'; -$cardId = 'card_id4'; +$addressId = 'address_id0'; -$result = $customersController->renewCard( +$result = $customersController->getAddress( $customerId, - $cardId + $addressId ); ``` -# Get Address +# Delete Address -Get a customer's address +Delete a Customer's address ```php -function getAddress(string $customerId, string $addressId): GetAddressResponse +function deleteAddress( + string $customerId, + string $addressId, + ?string $idempotencyKey = null +): GetAddressResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `customerId` | `string` | Template, Required | Customer id | +| `customerId` | `string` | Template, Required | Customer Id | | `addressId` | `string` | Template, Required | Address Id | +| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -414,92 +376,107 @@ $customerId = 'customer_id8'; $addressId = 'address_id0'; -$result = $customersController->getAddress( +$result = $customersController->deleteAddress( $customerId, $addressId ); ``` -# Delete Address +# Create Card -Delete a Customer's address +Creates a new card for a customer ```php -function deleteAddress( +function createCard( string $customerId, - string $addressId, + CreateCardRequest $request, ?string $idempotencyKey = null -): GetAddressResponse +): GetCardResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `customerId` | `string` | Template, Required | Customer Id | -| `addressId` | `string` | Template, Required | Address Id | +| `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 -[`GetAddressResponse`](../../doc/models/get-address-response.md) +[`GetCardResponse`](../../doc/models/get-card-response.md) ## Example Usage ```php $customerId = 'customer_id8'; -$addressId = 'address_id0'; +$request = CreateCardRequestBuilder::init() + ->type('credit') + ->build(); -$result = $customersController->deleteAddress( +$result = $customersController->createCard( $customerId, - $addressId + $request ); ``` -# Get Access Token +# Get Customers -Get a Customer's access token +Get all Customers ```php -function getAccessToken(string $customerId, string $tokenId): GetAccessTokenResponse +function getCustomers( + ?string $name = null, + ?string $document = null, + ?int $page = 1, + ?int $size = 10, + ?string $email = null, + ?string $code = null +): ListCustomersResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `customerId` | `string` | Template, Required | Customer Id | -| `tokenId` | `string` | Template, Required | Token Id | +| `name` | `?string` | Query, Optional | Name of the Customer | +| `document` | `?string` | Query, Optional | Document of the Customer | +| `page` | `?int` | Query, Optional | Current page the the search | +| `size` | `?int` | Query, Optional | Quantity pages of the search | +| `email` | `?string` | Query, Optional | Customer's email | +| `code` | `?string` | Query, Optional | Customer's code | ## Response Type -[`GetAccessTokenResponse`](../../doc/models/get-access-token-response.md) +[`ListCustomersResponse`](../../doc/models/list-customers-response.md) ## Example Usage ```php -$customerId = 'customer_id8'; +$page = 1; -$tokenId = 'token_id6'; +$size = 10; -$result = $customersController->getAccessToken( - $customerId, - $tokenId +$result = $customersController->getCustomers( + null, + null, + $page, + $size ); ``` -# 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 ``` @@ -508,8 +485,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 @@ -521,58 +498,59 @@ function updateCustomerMetadata( ```php $customerId = 'customer_id8'; -$request = UpdateMetadataRequestBuilder::init( - [ - 'key0' => 'metadata3' - ] -)->build(); +$request = UpdateCustomerRequestBuilder::init()->build(); -$result = $customersController->updateCustomerMetadata( +$result = $customersController->updateCustomer( $customerId, $request ); ``` -# Get Card +# Create Access Token -Get a customer's card +Creates a access token for a customer ```php -function getCard(string $customerId, string $cardId): GetCardResponse +function createAccessToken( + string $customerId, + CreateAccessTokenRequest $request, + ?string $idempotencyKey = null +): GetAccessTokenResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `customerId` | `string` | Template, Required | Customer id | -| `cardId` | `string` | Template, Required | Card id | +| `customerId` | `string` | Template, Required | Customer 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->getCard( +$result = $customersController->createAccessToken( $customerId, - $cardId + $request ); ``` -# Delete Access Tokens +# Get Access Tokens -Delete a Customer's access tokens +Get all access tokens from a customer ```php -function deleteAccessTokens(string $customerId): ListAccessTokensResponse +function getAccessTokens(string $customerId, ?int $page = null, ?int $size = null): ListAccessTokensResponse ``` ## Parameters @@ -580,6 +558,8 @@ function deleteAccessTokens(string $customerId): ListAccessTokensResponse | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `customerId` | `string` | Template, Required | Customer Id | +| `page` | `?int` | Query, Optional | Page number | +| `size` | `?int` | Query, Optional | Page size | ## Response Type @@ -590,20 +570,16 @@ function deleteAccessTokens(string $customerId): ListAccessTokensResponse ```php $customerId = 'customer_id8'; -$result = $customersController->deleteAccessTokens($customerId); +$result = $customersController->getAccessTokens($customerId); ``` -# Create Access Token +# Get Cards -Creates a access token for a customer +Get all cards from a customer ```php -function createAccessToken( - string $customerId, - CreateAccessTokenRequest $request, - ?string $idempotencyKey = null -): GetAccessTokenResponse +function getCards(string $customerId, ?int $page = null, ?int $size = null): ListCardsResponse ``` ## Parameters @@ -611,110 +587,97 @@ 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 | -| `idempotencyKey` | `?string` | Header, Optional | - | +| `page` | `?int` | Query, Optional | Page number | +| `size` | `?int` | Query, Optional | Page size | ## Response Type -[`GetAccessTokenResponse`](../../doc/models/get-access-token-response.md) +[`ListCardsResponse`](../../doc/models/list-cards-response.md) ## Example Usage ```php $customerId = 'customer_id8'; -$request = CreateAccessTokenRequestBuilder::init()->build(); - -$result = $customersController->createAccessToken( - $customerId, - $request -); +$result = $customersController->getCards($customerId); ``` -# Get Access Tokens +# Renew Card -Get all access tokens from a customer +Renew a card ```php -function getAccessTokens(string $customerId, ?int $page = null, ?int $size = null): ListAccessTokensResponse +function renewCard(string $customerId, string $cardId, ?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 | +| `cardId` | `string` | Template, Required | Card Id | +| `idempotencyKey` | `?string` | Header, Optional | - | ## 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->renewCard( + $customerId, + $cardId +); ``` -# Get Customers +# Get Access Token -Get all Customers +Get a Customer's access token ```php -function getCustomers( - ?string $name = null, - ?string $document = null, - ?int $page = 1, - ?int $size = 10, - ?string $email = null, - ?string $code = null -): ListCustomersResponse +function getAccessToken(string $customerId, string $tokenId): GetAccessTokenResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `name` | `?string` | Query, Optional | Name of the Customer | -| `document` | `?string` | Query, Optional | Document of the Customer | -| `page` | `?int` | Query, Optional | Current page the the search | -| `size` | `?int` | Query, Optional | Quantity pages of the search | -| `email` | `?string` | Query, Optional | Customer's email | -| `code` | `?string` | Query, Optional | Customer's code | +| `customerId` | `string` | Template, Required | Customer Id | +| `tokenId` | `string` | Template, Required | Token Id | ## Response Type -[`ListCustomersResponse`](../../doc/models/list-customers-response.md) +[`GetAccessTokenResponse`](../../doc/models/get-access-token-response.md) ## Example Usage ```php -$page = 1; +$customerId = 'customer_id8'; -$size = 10; +$tokenId = 'token_id6'; -$result = $customersController->getCustomers( - null, - null, - $page, - $size +$result = $customersController->getAccessToken( + $customerId, + $tokenId ); ``` -# Update Customer +# Update Customer Metadata -Updates a customer +Updates the metadata a customer ```php -function updateCustomer( +function updateCustomerMetadata( string $customerId, - UpdateCustomerRequest $request, + UpdateMetadataRequest $request, ?string $idempotencyKey = null ): GetCustomerResponse ``` @@ -723,8 +686,8 @@ function updateCustomer( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `customerId` | `string` | Template, Required | Customer id | -| `request` | [`UpdateCustomerRequest`](../../doc/models/update-customer-request.md) | Body, Required | Request for updating a customer | +| `customerId` | `string` | Template, Required | The customer id | +| `request` | [`UpdateMetadataRequest`](../../doc/models/update-metadata-request.md) | Body, Required | Request for updating the customer metadata | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -736,9 +699,13 @@ function updateCustomer( ```php $customerId = 'customer_id8'; -$request = UpdateCustomerRequestBuilder::init()->build(); +$request = UpdateMetadataRequestBuilder::init( + [ + 'key0' => 'metadata3' + ] +)->build(); -$result = $customersController->updateCustomer( +$result = $customersController->updateCustomerMetadata( $customerId, $request ); @@ -834,3 +801,36 @@ $customerId = 'customer_id8'; $result = $customersController->getCustomer($customerId); ``` + +# Get Card + +Get a customer's card + +```php +function getCard(string $customerId, string $cardId): GetCardResponse +``` + +## Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `customerId` | `string` | Template, Required | Customer id | +| `cardId` | `string` | Template, Required | Card id | + +## Response Type + +[`GetCardResponse`](../../doc/models/get-card-response.md) + +## Example Usage + +```php +$customerId = 'customer_id8'; + +$cardId = 'card_id4'; + +$result = $customersController->getCard( + $customerId, + $cardId +); +``` + diff --git a/doc/controllers/invoices.md b/doc/controllers/invoices.md index 147c228..4400978 100644 --- a/doc/controllers/invoices.md +++ b/doc/controllers/invoices.md @@ -10,24 +10,23 @@ $invoicesController = $client->getInvoicesController(); ## Methods -* [Create Invoice](../../doc/controllers/invoices.md#create-invoice) -* [Get Invoices](../../doc/controllers/invoices.md#get-invoices) -* [Cancel Invoice](../../doc/controllers/invoices.md#cancel-invoice) * [Update Invoice Metadata](../../doc/controllers/invoices.md#update-invoice-metadata) * [Get Partial Invoice](../../doc/controllers/invoices.md#get-partial-invoice) -* [Update Invoice Status](../../doc/controllers/invoices.md#update-invoice-status) +* [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) -# 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 ``` @@ -36,9 +35,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 @@ -48,61 +46,43 @@ 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); ``` @@ -134,14 +114,15 @@ $result = $invoicesController->cancelInvoice($invoiceId); ``` -# Update Invoice Metadata +# Create Invoice -Updates the metadata from an invoice +Create an Invoice ```php -function updateInvoiceMetadata( - string $invoiceId, - UpdateMetadataRequest $request, +function createInvoice( + string $subscriptionId, + string $cycleId, + ?CreateInvoiceRequest $request = null, ?string $idempotencyKey = null ): GetInvoiceResponse ``` @@ -150,8 +131,9 @@ function updateInvoiceMetadata( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `invoiceId` | `string` | Template, Required | The invoice id | -| `request` | [`UpdateMetadataRequest`](../../doc/models/update-metadata-request.md) | Body, Required | Request for updating the invoice metadata | +| `subscriptionId` | `string` | Template, Required | Subscription Id | +| `cycleId` | `string` | Template, Required | Cycle Id | +| `request` | [`?CreateInvoiceRequest`](../../doc/models/create-invoice-request.md) | Body, Optional | - | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -161,56 +143,70 @@ function updateInvoiceMetadata( ## Example Usage ```php -$invoiceId = 'invoice_id0'; +$subscriptionId = 'subscription_id0'; -$request = UpdateMetadataRequestBuilder::init( - [ - 'key0' => 'metadata3' - ] -)->build(); +$cycleId = 'cycle_id6'; -$result = $invoicesController->updateInvoiceMetadata( - $invoiceId, - $request +$result = $invoicesController->createInvoice( + $subscriptionId, + $cycleId ); ``` -# Get Partial Invoice +# Get Invoices + +Gets all invoices ```php -function getPartialInvoice(string $subscriptionId): GetInvoiceResponse +function getInvoices( + ?int $page = null, + ?int $size = null, + ?string $code = null, + ?string $customerId = null, + ?string $subscriptionId = null, + ?\DateTime $createdSince = null, + ?\DateTime $createdUntil = null, + ?string $status = null, + ?\DateTime $dueSince = null, + ?\DateTime $dueUntil = null, + ?string $customerDocument = null +): ListInvoicesResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | Subscription Id | +| `page` | `?int` | Query, Optional | Page number | +| `size` | `?int` | Query, Optional | Page size | +| `code` | `?string` | Query, Optional | Filter for Invoice's code | +| `customerId` | `?string` | Query, Optional | Filter for Invoice's customer id | +| `subscriptionId` | `?string` | Query, Optional | Filter for Invoice's subscription id | +| `createdSince` | `?DateTime` | Query, Optional | Filter for Invoice's creation date start range | +| `createdUntil` | `?DateTime` | Query, Optional | Filter for Invoices creation date end range | +| `status` | `?string` | Query, Optional | Filter for Invoice's status | +| `dueSince` | `?DateTime` | Query, Optional | Filter for Invoice's due date start range | +| `dueUntil` | `?DateTime` | Query, Optional | Filter for Invoice's due date end range | +| `customerDocument` | `?string` | Query, Optional | - | ## Response Type -[`GetInvoiceResponse`](../../doc/models/get-invoice-response.md) +[`ListInvoicesResponse`](../../doc/models/list-invoices-response.md) ## Example Usage ```php -$subscriptionId = 'subscription_id0'; - -$result = $invoicesController->getPartialInvoice($subscriptionId); +$result = $invoicesController->getInvoices(); ``` -# 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 @@ -218,8 +214,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 @@ -230,23 +224,20 @@ function updateInvoiceStatus( ```php $invoiceId = 'invoice_id0'; -$request = UpdateInvoiceStatusRequestBuilder::init( - 'status8' -)->build(); - -$result = $invoicesController->updateInvoiceStatus( - $invoiceId, - $request -); +$result = $invoicesController->getInvoice($invoiceId); ``` -# Get Invoice +# Update Invoice Status -Gets an invoice +Updates the status from an invoice ```php -function getInvoice(string $invoiceId): GetInvoiceResponse +function updateInvoiceStatus( + string $invoiceId, + UpdateInvoiceStatusRequest $request, + ?string $idempotencyKey = null +): GetInvoiceResponse ``` ## Parameters @@ -254,6 +245,8 @@ function getInvoice(string $invoiceId): GetInvoiceResponse | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `invoiceId` | `string` | Template, Required | Invoice Id | +| `request` | [`UpdateInvoiceStatusRequest`](../../doc/models/update-invoice-status-request.md) | Body, Required | Request for updating an invoice's status | +| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -264,6 +257,13 @@ function getInvoice(string $invoiceId): GetInvoiceResponse ```php $invoiceId = 'invoice_id0'; -$result = $invoicesController->getInvoice($invoiceId); +$request = UpdateInvoiceStatusRequestBuilder::init( + 'status8' +)->build(); + +$result = $invoicesController->updateInvoiceStatus( + $invoiceId, + $request +); ``` diff --git a/doc/controllers/orders.md b/doc/controllers/orders.md index 9becc00..17c7232 100644 --- a/doc/controllers/orders.md +++ b/doc/controllers/orders.md @@ -11,15 +11,15 @@ $ordersController = $client->getOrdersController(); ## Methods * [Get Orders](../../doc/controllers/orders.md#get-orders) -* [Get Order Item](../../doc/controllers/orders.md#get-order-item) -* [Get Order](../../doc/controllers/orders.md#get-order) -* [Close Order](../../doc/controllers/orders.md#close-order) -* [Create Order](../../doc/controllers/orders.md#create-order) * [Update Order Item](../../doc/controllers/orders.md#update-order-item) * [Delete All Order Items](../../doc/controllers/orders.md#delete-all-order-items) -* [Update Order Metadata](../../doc/controllers/orders.md#update-order-metadata) * [Delete Order Item](../../doc/controllers/orders.md#delete-order-item) +* [Close Order](../../doc/controllers/orders.md#close-order) +* [Create Order](../../doc/controllers/orders.md#create-order) * [Create Order Item](../../doc/controllers/orders.md#create-order-item) +* [Get Order Item](../../doc/controllers/orders.md#get-order-item) +* [Update Order Metadata](../../doc/controllers/orders.md#update-order-metadata) +* [Get Order](../../doc/controllers/orders.md#get-order) # Get Orders @@ -61,10 +61,15 @@ $result = $ordersController->getOrders(); ``` -# Get Order Item +# Update Order Item ```php -function getOrderItem(string $orderId, string $itemId): GetOrderItemResponse +function updateOrderItem( + string $orderId, + string $itemId, + UpdateOrderItemRequest $request, + ?string $idempotencyKey = null +): GetOrderItemResponse ``` ## Parameters @@ -73,6 +78,8 @@ function getOrderItem(string $orderId, string $itemId): GetOrderItemResponse | --- | --- | --- | --- | | `orderId` | `string` | Template, Required | Order Id | | `itemId` | `string` | Template, Required | Item Id | +| `request` | [`UpdateOrderItemRequest`](../../doc/models/update-order-item-request.md) | Body, Required | Item Model | +| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -85,26 +92,33 @@ $orderId = 'orderId2'; $itemId = 'itemId8'; -$result = $ordersController->getOrderItem( +$request = UpdateOrderItemRequestBuilder::init( + 242, + 'description6', + 100, + 'category4' +)->build(); + +$result = $ordersController->updateOrderItem( $orderId, - $itemId + $itemId, + $request ); ``` -# Get Order - -Gets an order +# Delete All Order Items ```php -function getOrder(string $orderId): GetOrderResponse +function deleteAllOrderItems(string $orderId, ?string $idempotencyKey = null): GetOrderResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `orderId` | `string` | Template, Required | Order id | +| `orderId` | `string` | Template, Required | Order Id | +| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -113,9 +127,41 @@ function getOrder(string $orderId): GetOrderResponse ## Example Usage ```php -$orderId = 'order_id6'; +$orderId = 'orderId2'; -$result = $ordersController->getOrder($orderId); +$result = $ordersController->deleteAllOrderItems($orderId); +``` + + +# Delete Order Item + +```php +function deleteOrderItem(string $orderId, string $itemId, ?string $idempotencyKey = null): GetOrderItemResponse +``` + +## Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `orderId` | `string` | Template, Required | Order Id | +| `itemId` | `string` | Template, Required | Item Id | +| `idempotencyKey` | `?string` | Header, Optional | - | + +## Response Type + +[`GetOrderItemResponse`](../../doc/models/get-order-item-response.md) + +## Example Usage + +```php +$orderId = 'orderId2'; + +$itemId = 'itemId8'; + +$result = $ordersController->deleteOrderItem( + $orderId, + $itemId +); ``` @@ -226,13 +272,12 @@ $result = $ordersController->createOrder($body); ``` -# Update Order Item +# Create Order Item ```php -function updateOrderItem( +function createOrderItem( string $orderId, - string $itemId, - UpdateOrderItemRequest $request, + CreateOrderItemRequest $request, ?string $idempotencyKey = null ): GetOrderItemResponse ``` @@ -242,8 +287,7 @@ function updateOrderItem( | 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 | +| `request` | [`CreateOrderItemRequest`](../../doc/models/create-order-item-request.md) | Body, Required | Order Item Model | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -255,27 +299,24 @@ function updateOrderItem( ```php $orderId = 'orderId2'; -$itemId = 'itemId8'; - -$request = UpdateOrderItemRequestBuilder::init( +$request = CreateOrderItemRequestBuilder::init( 242, 'description6', 100, 'category4' )->build(); -$result = $ordersController->updateOrderItem( +$result = $ordersController->createOrderItem( $orderId, - $itemId, $request ); ``` -# Delete All Order Items +# Get Order Item ```php -function deleteAllOrderItems(string $orderId, ?string $idempotencyKey = null): GetOrderResponse +function getOrderItem(string $orderId, string $itemId): GetOrderItemResponse ``` ## Parameters @@ -283,18 +324,23 @@ function deleteAllOrderItems(string $orderId, ?string $idempotencyKey = null): G | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orderId` | `string` | Template, Required | Order Id | -| `idempotencyKey` | `?string` | Header, Optional | - | +| `itemId` | `string` | Template, Required | Item Id | ## Response Type -[`GetOrderResponse`](../../doc/models/get-order-response.md) +[`GetOrderItemResponse`](../../doc/models/get-order-item-response.md) ## Example Usage ```php $orderId = 'orderId2'; -$result = $ordersController->deleteAllOrderItems($orderId); +$itemId = 'itemId8'; + +$result = $ordersController->getOrderItem( + $orderId, + $itemId +); ``` @@ -340,75 +386,29 @@ $result = $ordersController->updateOrderMetadata( ``` -# Delete Order Item - -```php -function deleteOrderItem(string $orderId, string $itemId, ?string $idempotencyKey = null): GetOrderItemResponse -``` - -## Parameters - -| Parameter | Type | Tags | Description | -| --- | --- | --- | --- | -| `orderId` | `string` | Template, Required | Order Id | -| `itemId` | `string` | Template, Required | Item Id | -| `idempotencyKey` | `?string` | Header, Optional | - | - -## Response Type - -[`GetOrderItemResponse`](../../doc/models/get-order-item-response.md) - -## Example Usage - -```php -$orderId = 'orderId2'; - -$itemId = 'itemId8'; - -$result = $ordersController->deleteOrderItem( - $orderId, - $itemId -); -``` - +# Get Order -# Create Order Item +Gets an order ```php -function createOrderItem( - string $orderId, - CreateOrderItemRequest $request, - ?string $idempotencyKey = null -): GetOrderItemResponse +function getOrder(string $orderId): GetOrderResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `orderId` | `string` | Template, Required | Order Id | -| `request` | [`CreateOrderItemRequest`](../../doc/models/create-order-item-request.md) | Body, Required | Order Item Model | -| `idempotencyKey` | `?string` | Header, Optional | - | +| `orderId` | `string` | Template, Required | Order id | ## Response Type -[`GetOrderItemResponse`](../../doc/models/get-order-item-response.md) +[`GetOrderResponse`](../../doc/models/get-order-response.md) ## Example Usage ```php -$orderId = 'orderId2'; - -$request = CreateOrderItemRequestBuilder::init( - 242, - 'description6', - 100, - 'category4' -)->build(); +$orderId = 'order_id6'; -$result = $ordersController->createOrderItem( - $orderId, - $request -); +$result = $ordersController->getOrder($orderId); ``` diff --git a/doc/controllers/plans.md b/doc/controllers/plans.md index ac39fcc..f2be784 100644 --- a/doc/controllers/plans.md +++ b/doc/controllers/plans.md @@ -11,15 +11,15 @@ $plansController = $client->getPlansController(); ## Methods * [Get Plan](../../doc/controllers/plans.md#get-plan) -* [Update Plan](../../doc/controllers/plans.md#update-plan) -* [Update Plan Metadata](../../doc/controllers/plans.md#update-plan-metadata) -* [Delete Plan Item](../../doc/controllers/plans.md#delete-plan-item) -* [Get Plans](../../doc/controllers/plans.md#get-plans) -* [Get Plan Item](../../doc/controllers/plans.md#get-plan-item) * [Delete Plan](../../doc/controllers/plans.md#delete-plan) +* [Update Plan Metadata](../../doc/controllers/plans.md#update-plan-metadata) * [Update Plan Item](../../doc/controllers/plans.md#update-plan-item) * [Create Plan Item](../../doc/controllers/plans.md#create-plan-item) +* [Get Plan Item](../../doc/controllers/plans.md#get-plan-item) * [Create Plan](../../doc/controllers/plans.md#create-plan) +* [Delete Plan Item](../../doc/controllers/plans.md#delete-plan-item) +* [Get Plans](../../doc/controllers/plans.md#get-plans) +* [Update Plan](../../doc/controllers/plans.md#update-plan) # Get Plan @@ -49,12 +49,12 @@ $result = $plansController->getPlan($planId); ``` -# Update Plan +# Delete Plan -Updates a plan +Deletes a plan ```php -function updatePlan(string $planId, UpdatePlanRequest $request, ?string $idempotencyKey = null): GetPlanResponse +function deletePlan(string $planId, ?string $idempotencyKey = null): GetPlanResponse ``` ## Parameters @@ -62,7 +62,6 @@ 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 | - | ## Response Type @@ -74,37 +73,7 @@ function updatePlan(string $planId, UpdatePlanRequest $request, ?string $idempot ```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(); - -$result = $plansController->updatePlan( - $planId, - $request -); +$result = $plansController->deletePlan($planId); ``` @@ -150,12 +119,17 @@ $result = $plansController->updatePlanMetadata( ``` -# 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 @@ -164,6 +138,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 @@ -177,49 +152,71 @@ $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 +); ``` @@ -256,19 +253,19 @@ $result = $plansController->getPlanItem( ``` -# Delete Plan +# Create Plan -Deletes a plan +Creates a new plan ```php -function deletePlan(string $planId, ?string $idempotencyKey = null): GetPlanResponse +function createPlan(CreatePlanRequest $body, ?string $idempotencyKey = null): GetPlanResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `planId` | `string` | Template, Required | Plan id | +| `body` | [`CreatePlanRequest`](../../doc/models/create-plan-request.md) | Body, Required | Request for creating a plan | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -278,23 +275,54 @@ function deletePlan(string $planId, ?string $idempotencyKey = null): GetPlanResp ## Example Usage ```php -$planId = 'plan_id8'; +$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->deletePlan($planId); +$result = $plansController->createPlan($body); ``` -# Update Plan Item +# Delete Plan Item -Updates a plan item +Removes an item from a plan ```php -function updatePlanItem( - string $planId, - string $planItemId, - UpdatePlanItemRequest $body, - ?string $idempotencyKey = null -): GetPlanItemResponse +function deletePlanItem(string $planId, string $planItemId, ?string $idempotencyKey = null): GetPlanItemResponse ``` ## Parameters @@ -303,7 +331,6 @@ function updatePlanItem( | --- | --- | --- | --- | | `planId` | `string` | Template, Required | Plan id | | `planItemId` | `string` | Template, Required | Plan item id | -| `body` | [`UpdatePlanItemRequest`](../../doc/models/update-plan-item-request.md) | Body, Required | Request for updating the plan item | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -317,87 +344,66 @@ $planId = 'plan_id8'; $planItemId = 'plan_item_id0'; -$body = UpdatePlanItemRequestBuilder::init( - 'name6', - 'description4', - 'status2', - UpdatePricingSchemeRequestBuilder::init( - 'scheme_type8', - [ - UpdatePriceBracketRequestBuilder::init( - 144, - 174 - )->build() - ] - )->build() -)->build(); - -$result = $plansController->updatePlanItem( +$result = $plansController->deletePlanItem( $planId, - $planItemId, - $body + $planItemId ); ``` -# Create Plan Item +# Get Plans -Adds a new item to a plan +Gets all plans ```php -function createPlanItem( - string $planId, - CreatePlanItemRequest $request, - ?string $idempotencyKey = null -): GetPlanItemResponse +function getPlans( + ?int $page = null, + ?int $size = null, + ?string $name = null, + ?string $status = null, + ?string $billingType = null, + ?\DateTime $createdSince = null, + ?\DateTime $createdUntil = null +): ListPlansResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `planId` | `string` | Template, Required | Plan id | -| `request` | [`CreatePlanItemRequest`](../../doc/models/create-plan-item-request.md) | Body, Required | Request for creating a plan item | -| `idempotencyKey` | `?string` | Header, Optional | - | +| `page` | `?int` | Query, Optional | Page number | +| `size` | `?int` | Query, Optional | Page size | +| `name` | `?string` | Query, Optional | Filter for Plan's name | +| `status` | `?string` | Query, Optional | Filter for Plan's status | +| `billingType` | `?string` | Query, Optional | Filter for plan's billing type | +| `createdSince` | `?DateTime` | Query, Optional | Filter for plan's creation date start range | +| `createdUntil` | `?DateTime` | Query, Optional | Filter for plan's creation date end range | ## Response Type -[`GetPlanItemResponse`](../../doc/models/get-plan-item-response.md) +[`ListPlansResponse`](../../doc/models/list-plans-response.md) ## Example Usage ```php -$planId = 'plan_id8'; - -$request = CreatePlanItemRequestBuilder::init( - 'name6', - CreatePricingSchemeRequestBuilder::init( - 'scheme_type8' - )->build(), - 'id6', - 'description6' -)->build(); - -$result = $plansController->createPlanItem( - $planId, - $request -); +$result = $plansController->getPlans(); ``` -# Create Plan +# Update Plan -Creates a new plan +Updates a plan ```php -function createPlan(CreatePlanRequest $body, ?string $idempotencyKey = null): GetPlanResponse +function updatePlan(string $planId, UpdatePlanRequest $request, ?string $idempotencyKey = null): GetPlanResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `body` | [`CreatePlanRequest`](../../doc/models/create-plan-request.md) | Body, Required | Request for creating a plan | +| `planId` | `string` | Template, Required | Plan id | +| `request` | [`UpdatePlanRequest`](../../doc/models/update-plan-request.md) | Body, Required | Request for updating a plan | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -407,44 +413,38 @@ function createPlan(CreatePlanRequest $body, ?string $idempotencyKey = null): Ge ## Example Usage ```php -$body = CreatePlanRequestBuilder::init( +$planId = 'plan_id8'; + +$request = UpdatePlanRequestBuilder::init( 'name6', - 'description4', - 'statement_descriptor6', + 'description6', [ - CreatePlanItemRequestBuilder::init( - 'name8', - CreatePricingSchemeRequestBuilder::init( - 'scheme_type8' - )->build(), - 'id8', - 'description2' - )->build() + 151, + 152 ], - false, + 'statement_descriptor6', + 'currency6', + 'interval4', + 114, [ + 'payment_methods1', + 'payment_methods0', 'payment_methods9' ], + 'billing_type0', + 'status8', + false, [ - 207 - ], - 'currency6', - 'interval6', - 170, - [ - 201, - 200 + 115 ], - 'billing_type0', - CreatePricingSchemeRequestBuilder::init( - 'scheme_type8' - )->build(), [ - 'key0' => 'metadata7', - 'key1' => 'metadata8' + 'key0' => 'metadata3' ] )->build(); -$result = $plansController->createPlan($body); +$result = $plansController->updatePlan( + $planId, + $request +); ``` diff --git a/doc/controllers/recipients.md b/doc/controllers/recipients.md index 301562a..52891c5 100644 --- a/doc/controllers/recipients.md +++ b/doc/controllers/recipients.md @@ -14,21 +14,21 @@ $recipientsController = $client->getRecipientsController(); * [Create Anticipation](../../doc/controllers/recipients.md#create-anticipation) * [Get Anticipation Limits](../../doc/controllers/recipients.md#get-anticipation-limits) * [Get Recipients](../../doc/controllers/recipients.md#get-recipients) +* [Get Withdraw by Id](../../doc/controllers/recipients.md#get-withdraw-by-id) +* [Update Recipient Default Bank Account](../../doc/controllers/recipients.md#update-recipient-default-bank-account) * [Update Recipient Metadata](../../doc/controllers/recipients.md#update-recipient-metadata) +* [Get Transfers](../../doc/controllers/recipients.md#get-transfers) * [Get Transfer](../../doc/controllers/recipients.md#get-transfer) +* [Create Withdraw](../../doc/controllers/recipients.md#create-withdraw) +* [Update Automatic Anticipation Settings](../../doc/controllers/recipients.md#update-automatic-anticipation-settings) * [Get Anticipation](../../doc/controllers/recipients.md#get-anticipation) * [Update Recipient Transfer Settings](../../doc/controllers/recipients.md#update-recipient-transfer-settings) * [Get Anticipations](../../doc/controllers/recipients.md#get-anticipations) -* [Update Recipient Default Bank Account](../../doc/controllers/recipients.md#update-recipient-default-bank-account) -* [Create Withdraw](../../doc/controllers/recipients.md#create-withdraw) +* [Get Recipient](../../doc/controllers/recipients.md#get-recipient) * [Get Balance](../../doc/controllers/recipients.md#get-balance) +* [Get Withdrawals](../../doc/controllers/recipients.md#get-withdrawals) * [Create Transfer](../../doc/controllers/recipients.md#create-transfer) * [Create Recipient](../../doc/controllers/recipients.md#create-recipient) -* [Update Automatic Anticipation Settings](../../doc/controllers/recipients.md#update-automatic-anticipation-settings) -* [Get Recipient](../../doc/controllers/recipients.md#get-recipient) -* [Get Withdrawals](../../doc/controllers/recipients.md#get-withdrawals) -* [Get Withdraw by Id](../../doc/controllers/recipients.md#get-withdraw-by-id) -* [Get Transfers](../../doc/controllers/recipients.md#get-transfers) * [Get Recipient by Code](../../doc/controllers/recipients.md#get-recipient-by-code) * [Get Default Recipient](../../doc/controllers/recipients.md#get-default-recipient) @@ -189,54 +189,47 @@ $result = $recipientsController->getRecipients(); ``` -# Update Recipient Metadata - -Updates recipient metadata +# Get Withdraw by Id ```php -function updateRecipientMetadata( - string $recipientId, - UpdateMetadataRequest $request, - ?string $idempotencyKey = null -): GetRecipientResponse +function getWithdrawById(string $recipientId, string $withdrawalId): GetWithdrawResponse ``` ## 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 | - | +| `recipientId` | `string` | Template, Required | - | +| `withdrawalId` | `string` | Template, Required | - | ## Response Type -[`GetRecipientResponse`](../../doc/models/get-recipient-response.md) +[`GetWithdrawResponse`](../../doc/models/get-withdraw-response.md) ## Example Usage ```php $recipientId = 'recipient_id0'; -$request = UpdateMetadataRequestBuilder::init( - [ - 'key0' => 'metadata3' - ] -)->build(); +$withdrawalId = 'withdrawal_id2'; -$result = $recipientsController->updateRecipientMetadata( +$result = $recipientsController->getWithdrawById( $recipientId, - $request + $withdrawalId ); ``` -# Get Transfer +# Update Recipient Default Bank Account -Gets a transfer +Updates the default bank account from a recipient ```php -function getTransfer(string $recipientId, string $transferId): GetTransferResponse +function updateRecipientDefaultBankAccount( + string $recipientId, + UpdateRecipientBankAccountRequest $request, + ?string $idempotencyKey = null +): GetRecipientResponse ``` ## Parameters @@ -244,65 +237,51 @@ function getTransfer(string $recipientId, string $transferId): GetTransferRespon | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `recipientId` | `string` | Template, Required | Recipient id | -| `transferId` | `string` | Template, Required | Transfer id | +| `request` | [`UpdateRecipientBankAccountRequest`](../../doc/models/update-recipient-bank-account-request.md) | Body, Required | Bank account data | +| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`GetTransferResponse`](../../doc/models/get-transfer-response.md) +[`GetRecipientResponse`](../../doc/models/get-recipient-response.md) ## Example Usage ```php $recipientId = 'recipient_id0'; -$transferId = 'transfer_id6'; +$request = UpdateRecipientBankAccountRequestBuilder::init( + CreateBankAccountRequestBuilder::init( + 'holder_name0', + 'holder_type6', + 'holder_document8', + 'bank2', + 'branch_number0', + 'account_number4', + 'account_check_digit0', + 'type6', + [ + 'key0' => 'metadata1', + 'key1' => 'metadata0' + ] + )->build(), + 'bank_transfer' +)->build(); -$result = $recipientsController->getTransfer( +$result = $recipientsController->updateRecipientDefaultBankAccount( $recipientId, - $transferId + $request ); ``` -# Get Anticipation - -Gets an anticipation - -```php -function getAnticipation(string $recipientId, string $anticipationId): GetAnticipationResponse -``` - -## Parameters - -| Parameter | Type | Tags | Description | -| --- | --- | --- | --- | -| `recipientId` | `string` | Template, Required | Recipient id | -| `anticipationId` | `string` | Template, Required | Anticipation id | - -## Response Type - -[`GetAnticipationResponse`](../../doc/models/get-anticipation-response.md) - -## Example Usage - -```php -$recipientId = 'recipient_id0'; - -$anticipationId = 'anticipation_id0'; - -$result = $recipientsController->getAnticipation( - $recipientId, - $anticipationId -); -``` - +# Update Recipient Metadata -# Update Recipient Transfer Settings +Updates recipient metadata ```php -function updateRecipientTransferSettings( +function updateRecipientMetadata( string $recipientId, - UpdateTransferSettingsRequest $request, + UpdateMetadataRequest $request, ?string $idempotencyKey = null ): GetRecipientResponse ``` @@ -311,8 +290,8 @@ function updateRecipientTransferSettings( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `recipientId` | `string` | Template, Required | Recipient Identificator | -| `request` | [`UpdateTransferSettingsRequest`](../../doc/models/update-transfer-settings-request.md) | Body, Required | - | +| `recipientId` | `string` | Template, Required | Recipient id | +| `request` | [`UpdateMetadataRequest`](../../doc/models/update-metadata-request.md) | Body, Required | Metadata | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -324,35 +303,32 @@ function updateRecipientTransferSettings( ```php $recipientId = 'recipient_id0'; -$request = UpdateTransferSettingsRequestBuilder::init( - 'transfer_enabled2', - 'transfer_interval6', - 'transfer_day6' +$request = UpdateMetadataRequestBuilder::init( + [ + 'key0' => 'metadata3' + ] )->build(); -$result = $recipientsController->updateRecipientTransferSettings( +$result = $recipientsController->updateRecipientMetadata( $recipientId, $request ); ``` -# Get Anticipations +# Get Transfers -Retrieves a paginated list of anticipations from a recipient +Gets a paginated list of transfers for the recipient ```php -function getAnticipations( +function getTransfers( 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 +): ListTransferResponse ``` ## Parameters @@ -362,36 +338,29 @@ function getAnticipations( | `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 | +| `status` | `?string` | Query, Optional | Filter for transfer status | +| `createdSince` | `?DateTime` | Query, Optional | Filter for start range of transfer creation date | +| `createdUntil` | `?DateTime` | Query, Optional | Filter for end range of transfer creation date | ## Response Type -[`ListAnticipationResponse`](../../doc/models/list-anticipation-response.md) +[`ListTransferResponse`](../../doc/models/list-transfer-response.md) ## Example Usage ```php $recipientId = 'recipient_id0'; -$result = $recipientsController->getAnticipations($recipientId); +$result = $recipientsController->getTransfers($recipientId); ``` -# Update Recipient Default Bank Account +# Get Transfer -Updates the default bank account from a recipient +Gets a transfer ```php -function updateRecipientDefaultBankAccount( - string $recipientId, - UpdateRecipientBankAccountRequest $request, - ?string $idempotencyKey = null -): GetRecipientResponse +function getTransfer(string $recipientId, string $transferId): GetTransferResponse ``` ## Parameters @@ -399,39 +368,22 @@ function updateRecipientDefaultBankAccount( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `recipientId` | `string` | Template, Required | Recipient id | -| `request` | [`UpdateRecipientBankAccountRequest`](../../doc/models/update-recipient-bank-account-request.md) | Body, Required | Bank account data | -| `idempotencyKey` | `?string` | Header, Optional | - | +| `transferId` | `string` | Template, Required | Transfer id | ## Response Type -[`GetRecipientResponse`](../../doc/models/get-recipient-response.md) +[`GetTransferResponse`](../../doc/models/get-transfer-response.md) ## Example Usage ```php $recipientId = 'recipient_id0'; -$request = UpdateRecipientBankAccountRequestBuilder::init( - CreateBankAccountRequestBuilder::init( - 'holder_name0', - 'holder_type6', - 'holder_document8', - 'bank2', - 'branch_number0', - 'account_number4', - 'account_check_digit0', - 'type6', - [ - 'key0' => 'metadata1', - 'key1' => 'metadata0' - ] - )->build(), - 'bank_transfer' -)->build(); +$transferId = 'transfer_id6'; -$result = $recipientsController->updateRecipientDefaultBankAccount( +$result = $recipientsController->getTransfer( $recipientId, - $request + $transferId ); ``` @@ -469,12 +421,16 @@ $result = $recipientsController->createWithdraw( ``` -# 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 @@ -482,76 +438,76 @@ 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); +$request = UpdateAutomaticAnticipationSettingsRequestBuilder::init()->build(); + +$result = $recipientsController->updateAutomaticAnticipationSettings( + $recipientId, + $request +); ``` -# Create Transfer +# Get Anticipation -Creates a transfer for a recipient +Gets an anticipation ```php -function createTransfer( - string $recipientId, - CreateTransferRequest $request, - ?string $idempotencyKey = null -): GetTransferResponse +function getAnticipation(string $recipientId, string $anticipationId): GetAnticipationResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `recipientId` | `string` | Template, Required | Recipient Id | -| `request` | [`CreateTransferRequest`](../../doc/models/create-transfer-request.md) | Body, Required | Transfer data | -| `idempotencyKey` | `?string` | Header, Optional | - | +| `recipientId` | `string` | Template, Required | Recipient id | +| `anticipationId` | `string` | Template, Required | Anticipation id | ## Response Type -[`GetTransferResponse`](../../doc/models/get-transfer-response.md) +[`GetAnticipationResponse`](../../doc/models/get-anticipation-response.md) ## Example Usage ```php $recipientId = 'recipient_id0'; -$request = CreateTransferRequestBuilder::init( - 242, - [ - 'key0' => 'metadata3' - ] -)->build(); +$anticipationId = 'anticipation_id0'; -$result = $recipientsController->createTransfer( +$result = $recipientsController->getAnticipation( $recipientId, - $request + $anticipationId ); ``` -# Create Recipient - -Creates a new recipient +# Update Recipient Transfer Settings ```php -function createRecipient(CreateRecipientRequest $request, ?string $idempotencyKey = null): GetRecipientResponse +function updateRecipientTransferSettings( + string $recipientId, + UpdateTransferSettingsRequest $request, + ?string $idempotencyKey = null +): GetRecipientResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `request` | [`CreateRecipientRequest`](../../doc/models/create-recipient-request.md) | Body, Required | Recipient data | +| `recipientId` | `string` | Template, Required | Recipient Identificator | +| `request` | [`UpdateTransferSettingsRequest`](../../doc/models/update-transfer-settings-request.md) | Body, Required | - | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -561,43 +517,37 @@ function createRecipient(CreateRecipientRequest $request, ?string $idempotencyKe ## Example Usage ```php -$request = CreateRecipientRequestBuilder::init( - CreateBankAccountRequestBuilder::init( - 'holder_name4', - 'holder_type0', - 'holder_document2', - 'bank6', - 'branch_number4', - 'account_number8', - 'account_check_digit4', - 'type2', - [ - 'key0' => 'metadata5', - 'key1' => 'metadata4', - 'key2' => 'metadata3' - ] - )->build(), - [ - 'key0' => 'metadata3' - ], - 'code4', - 'bank_transfer' +$recipientId = 'recipient_id0'; + +$request = UpdateTransferSettingsRequestBuilder::init( + 'transfer_enabled2', + 'transfer_interval6', + 'transfer_day6' )->build(); -$result = $recipientsController->createRecipient($request); +$result = $recipientsController->updateRecipientTransferSettings( + $recipientId, + $request +); ``` -# Update Automatic Anticipation Settings +# Get Anticipations -Updates recipient metadata +Retrieves a paginated list of anticipations from a recipient ```php -function updateAutomaticAnticipationSettings( +function getAnticipations( string $recipientId, - UpdateAutomaticAnticipationSettingsRequest $request, - ?string $idempotencyKey = null -): GetRecipientResponse + ?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 @@ -605,24 +555,25 @@ function updateAutomaticAnticipationSettings( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `recipientId` | `string` | Template, Required | Recipient id | -| `request` | [`UpdateAutomaticAnticipationSettingsRequest`](../../doc/models/update-automatic-anticipation-settings-request.md) | Body, Required | Metadata | -| `idempotencyKey` | `?string` | Header, Optional | - | +| `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 -[`GetRecipientResponse`](../../doc/models/get-recipient-response.md) +[`ListAnticipationResponse`](../../doc/models/list-anticipation-response.md) ## Example Usage ```php $recipientId = 'recipient_id0'; -$request = UpdateAutomaticAnticipationSettingsRequestBuilder::init()->build(); - -$result = $recipientsController->updateAutomaticAnticipationSettings( - $recipientId, - $request -); +$result = $recipientsController->getAnticipations($recipientId); ``` @@ -653,6 +604,33 @@ $result = $recipientsController->getRecipient($recipientId); ``` +# Get Balance + +Get balance information for a recipient + +```php +function getBalance(string $recipientId): GetBalanceResponse +``` + +## Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `recipientId` | `string` | Template, Required | Recipient id | + +## Response Type + +[`GetBalanceResponse`](../../doc/models/get-balance-response.md) + +## Example Usage + +```php +$recipientId = 'recipient_id0'; + +$result = $recipientsController->getBalance($recipientId); +``` + + # Get Withdrawals Gets a paginated list of transfers for the recipient @@ -692,73 +670,95 @@ $result = $recipientsController->getWithdrawals($recipientId); ``` -# Get Withdraw by Id +# Create Transfer + +Creates a transfer for a recipient ```php -function getWithdrawById(string $recipientId, string $withdrawalId): GetWithdrawResponse +function createTransfer( + string $recipientId, + CreateTransferRequest $request, + ?string $idempotencyKey = null +): GetTransferResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `recipientId` | `string` | Template, Required | - | -| `withdrawalId` | `string` | Template, Required | - | +| `recipientId` | `string` | Template, Required | Recipient Id | +| `request` | [`CreateTransferRequest`](../../doc/models/create-transfer-request.md) | Body, Required | Transfer data | +| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`GetWithdrawResponse`](../../doc/models/get-withdraw-response.md) +[`GetTransferResponse`](../../doc/models/get-transfer-response.md) ## Example Usage ```php $recipientId = 'recipient_id0'; -$withdrawalId = 'withdrawal_id2'; +$request = CreateTransferRequestBuilder::init( + 242, + [ + 'key0' => 'metadata3' + ] +)->build(); -$result = $recipientsController->getWithdrawById( +$result = $recipientsController->createTransfer( $recipientId, - $withdrawalId + $request ); ``` -# Get Transfers +# Create Recipient -Gets a paginated list of transfers for the recipient +Creates a new recipient ```php -function getTransfers( - string $recipientId, - ?int $page = null, - ?int $size = null, - ?string $status = null, - ?\DateTime $createdSince = null, - ?\DateTime $createdUntil = null -): ListTransferResponse +function createRecipient(CreateRecipientRequest $request, ?string $idempotencyKey = null): GetRecipientResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `recipientId` | `string` | Template, Required | Recipient id | -| `page` | `?int` | Query, Optional | Page number | -| `size` | `?int` | Query, Optional | Page size | -| `status` | `?string` | Query, Optional | Filter for transfer status | -| `createdSince` | `?DateTime` | Query, Optional | Filter for start range of transfer creation date | -| `createdUntil` | `?DateTime` | Query, Optional | Filter for end range of transfer creation date | +| `request` | [`CreateRecipientRequest`](../../doc/models/create-recipient-request.md) | Body, Required | Recipient data | +| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`ListTransferResponse`](../../doc/models/list-transfer-response.md) +[`GetRecipientResponse`](../../doc/models/get-recipient-response.md) ## Example Usage ```php -$recipientId = 'recipient_id0'; +$request = CreateRecipientRequestBuilder::init( + CreateBankAccountRequestBuilder::init( + 'holder_name4', + 'holder_type0', + 'holder_document2', + 'bank6', + 'branch_number4', + 'account_number8', + 'account_check_digit4', + 'type2', + [ + 'key0' => 'metadata5', + 'key1' => 'metadata4', + 'key2' => 'metadata3' + ] + )->build(), + [ + 'key0' => 'metadata3' + ], + 'code4', + 'bank_transfer' +)->build(); -$result = $recipientsController->getTransfers($recipientId); +$result = $recipientsController->createRecipient($request); ``` diff --git a/doc/controllers/subscriptions.md b/doc/controllers/subscriptions.md index 2fa7d5d..c1883f8 100644 --- a/doc/controllers/subscriptions.md +++ b/doc/controllers/subscriptions.md @@ -11,39 +11,39 @@ $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) * [Delete Discount](../../doc/controllers/subscriptions.md#delete-discount) +* [Get Subscription Items](../../doc/controllers/subscriptions.md#get-subscription-items) +* [Update Subscription Payment Method](../../doc/controllers/subscriptions.md#update-subscription-payment-method) +* [Get Subscription Item](../../doc/controllers/subscriptions.md#get-subscription-item) * [Get Subscriptions](../../doc/controllers/subscriptions.md#get-subscriptions) +* [Cancel Subscription](../../doc/controllers/subscriptions.md#cancel-subscription) +* [Create Increment](../../doc/controllers/subscriptions.md#create-increment) +* [Create Usage](../../doc/controllers/subscriptions.md#create-usage) * [Get Discount by Id](../../doc/controllers/subscriptions.md#get-discount-by-id) * [Create Subscription](../../doc/controllers/subscriptions.md#create-subscription) * [Get Increment by Id](../../doc/controllers/subscriptions.md#get-increment-by-id) +* [Update Subscription Affiliation Id](../../doc/controllers/subscriptions.md#update-subscription-affiliation-id) * [Update Subscription Metadata](../../doc/controllers/subscriptions.md#update-subscription-metadata) * [Delete Increment](../../doc/controllers/subscriptions.md#delete-increment) -* [Get Subscription](../../doc/controllers/subscriptions.md#get-subscription) -* [Update Latest Period End At](../../doc/controllers/subscriptions.md#update-latest-period-end-at) -* [Update Current Cycle Status](../../doc/controllers/subscriptions.md#update-current-cycle-status) -* [Get Subscription Items](../../doc/controllers/subscriptions.md#get-subscription-items) -* [Get Subscription Item](../../doc/controllers/subscriptions.md#get-subscription-item) -* [Update Subscription Affiliation Id](../../doc/controllers/subscriptions.md#update-subscription-affiliation-id) +* [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) -* [Create an Usage](../../doc/controllers/subscriptions.md#create-an-usage) -* [Cancel Subscription](../../doc/controllers/subscriptions.md#cancel-subscription) -* [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 Card](../../doc/controllers/subscriptions.md#update-subscription-card) -* [Delete Usage](../../doc/controllers/subscriptions.md#delete-usage) -* [Create Discount](../../doc/controllers/subscriptions.md#create-discount) -* [Update Subscription Payment Method](../../doc/controllers/subscriptions.md#update-subscription-payment-method) -* [Create Increment](../../doc/controllers/subscriptions.md#create-increment) -* [Create Usage](../../doc/controllers/subscriptions.md#create-usage) -* [Get Subscription Cycles](../../doc/controllers/subscriptions.md#get-subscription-cycles) -* [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 Usage Report](../../doc/controllers/subscriptions.md#get-usage-report) * [Update Split Subscription](../../doc/controllers/subscriptions.md#update-split-subscription) @@ -74,16 +74,16 @@ $result = $subscriptionsController->renewSubscription($subscriptionId); ``` -# Delete Discount +# Update Subscription Card -Deletes a discount +Updates the credit card from a subscription ```php -function deleteDiscount( +function updateSubscriptionCard( string $subscriptionId, - string $discountId, + UpdateSubscriptionCardRequest $request, ?string $idempotencyKey = null -): GetDiscountResponse +): GetSubscriptionResponse ``` ## Parameters @@ -91,88 +91,94 @@ function deleteDiscount( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `subscriptionId` | `string` | Template, Required | Subscription id | -| `discountId` | `string` | Template, Required | Discount Id | +| `request` | [`UpdateSubscriptionCardRequest`](../../doc/models/update-subscription-card-request.md) | Body, Required | Request for updating a card | | `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'; +$request = UpdateSubscriptionCardRequestBuilder::init( + CreateCardRequestBuilder::init() + ->type('credit') + ->build(), + 'card_id2' +)->build(); -$result = $subscriptionsController->deleteDiscount( +$result = $subscriptionsController->updateSubscriptionCard( $subscriptionId, - $discountId + $request ); ``` -# Get Subscriptions +# Delete Usage -Gets all subscriptions +Deletes a usage ```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 +function deleteUsage( + string $subscriptionId, + string $itemId, + string $usageId, + ?string $idempotencyKey = null +): GetUsageResponse ``` ## 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 | +| `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 -[`ListSubscriptionsResponse`](../../doc/models/list-subscriptions-response.md) +[`GetUsageResponse`](../../doc/models/get-usage-response.md) ## Example Usage ```php -$result = $subscriptionsController->getSubscriptions(); +$subscriptionId = 'subscription_id0'; + +$itemId = 'item_id0'; + +$usageId = 'usage_id0'; + +$result = $subscriptionsController->deleteUsage( + $subscriptionId, + $itemId, + $usageId +); ``` -# Get Discount by Id +# Create Discount + +Creates a discount ```php -function getDiscountById(string $subscriptionId, string $discountId): GetDiscountResponse +function createDiscount( + string $subscriptionId, + CreateDiscountRequest $request, + ?string $idempotencyKey = null +): GetDiscountResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | The subscription id | -| `discountId` | `string` | Template, Required | - | +| `subscriptionId` | `string` | Template, Required | Subscription id | +| `request` | [`CreateDiscountRequest`](../../doc/models/create-discount-request.md) | Body, Required | Request for creating a discount | +| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -183,181 +189,182 @@ function getDiscountById(string $subscriptionId, string $discountId): GetDiscoun ```php $subscriptionId = 'subscription_id0'; -$discountId = 'discountId0'; +$request = CreateDiscountRequestBuilder::init( + 185.28, + 'discount_type4', + 'item_id6' +)->build(); -$result = $subscriptionsController->getDiscountById( +$result = $subscriptionsController->createDiscount( $subscriptionId, - $discountId + $request ); ``` -# Create Subscription +# Create an Usage -Creates a new subscription +Create Usage ```php -function createSubscription( - CreateSubscriptionRequest $body, +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, + UpdateCurrentCycleStatusRequest $request, ?string $idempotencyKey = null -): GetSubscriptionResponse +): void ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `body` | [`CreateSubscriptionRequest`](../../doc/models/create-subscription-request.md) | Body, Required | Request for creating a subscription | +| `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 -$body = CreateSubscriptionRequestBuilder::init( - CreateCustomerRequestBuilder::init( - '{ - "name": "Tony Stark" -}', - 'email6', - 'document6', - 'type0', - CreateAddressRequestBuilder::init( - 'street6', - 'number4', - 'zip_code0', - 'neighborhood2', - 'city6', - 'state2', - 'country0', - 'complement2', - 'line_10', - 'line_24' - )->build(), - [ - 'key0' => 'metadata3' - ], - CreatePhonesRequestBuilder::init()->build(), - 'code8' - )->build(), - CreateCardRequestBuilder::init() - ->type('credit') - ->build(), - 'code4', - 'payment_method4', - 'billing_type0', - 'statement_descriptor6', - 'description4', - 'currency6', - 'interval6', - 170, - CreatePricingSchemeRequestBuilder::init( - 'scheme_type8' - )->build(), - [ - CreateSubscriptionItemRequestBuilder::init( - 'description2', - CreatePricingSchemeRequestBuilder::init( - 'scheme_type8' - )->build(), - 'id8', - 'plan_item_id8', - [ - CreateDiscountRequestBuilder::init( - 90.66, - 'discount_type2', - 'item_id4' - )->build() - ], - 'name8' - )->build() - ], - CreateShippingRequestBuilder::init( - 52, - 'description6', - 'recipient_name2', - 'recipient_phone6', - 'address_id6', - CreateAddressRequestBuilder::init( - 'street6', - 'number4', - 'zip_code0', - 'neighborhood2', - 'city6', - 'state2', - 'country0', - 'complement2', - 'line_10', - 'line_24' - )->build(), - 'type6' - )->build(), - [ - CreateDiscountRequestBuilder::init( - 90.66, - 'discount_type2', - 'item_id4' - )->build() - ], - [ - 'key0' => 'metadata7', - 'key1' => 'metadata8' - ], - [ - CreateIncrementRequestBuilder::init( - 252.86, - 'increment_type6', - 'item_id6' - )->build() - ] +$subscriptionId = 'subscription_id0'; + +$request = UpdateCurrentCycleStatusRequestBuilder::init( + 'status8' )->build(); -$result = $subscriptionsController->createSubscription($body); +$subscriptionsController->updateCurrentCycleStatus( + $subscriptionId, + $request +); ``` -# Get Increment by Id +# Delete Discount + +Deletes a discount ```php -function getIncrementById(string $subscriptionId, string $incrementId): GetIncrementResponse +function deleteDiscount( + string $subscriptionId, + string $discountId, + ?string $idempotencyKey = null +): GetDiscountResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | The subscription Id | -| `incrementId` | `string` | Template, Required | The increment Id | +| `subscriptionId` | `string` | Template, Required | Subscription id | +| `discountId` | `string` | Template, Required | Discount Id | +| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`GetIncrementResponse`](../../doc/models/get-increment-response.md) +[`GetDiscountResponse`](../../doc/models/get-discount-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$incrementId = 'increment_id8'; +$discountId = 'discount_id8'; -$result = $subscriptionsController->getIncrementById( +$result = $subscriptionsController->deleteDiscount( $subscriptionId, - $incrementId + $discountId ); ``` -# Update Subscription Metadata +# Get Subscription Items -Updates the metadata from a subscription +Get Subscription Items ```php -function updateSubscriptionMetadata( +function getSubscriptionItems( string $subscriptionId, - UpdateMetadataRequest $request, + ?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 +``` + +## Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `subscriptionId` | `string` | Template, Required | The subscription id | +| `page` | `?int` | Query, Optional | Page number | +| `size` | `?int` | Query, Optional | Page size | +| `name` | `?string` | Query, Optional | The item name | +| `code` | `?string` | Query, Optional | Identification code in the client system | +| `status` | `?string` | Query, Optional | The item statis | +| `description` | `?string` | Query, Optional | The item description | +| `createdSince` | `?string` | Query, Optional | Filter for item's creation date start range | +| `createdUntil` | `?string` | Query, Optional | Filter for item's creation date end range | + +## Response Type + +[`ListSubscriptionItemsResponse`](../../doc/models/list-subscription-items-response.md) + +## Example Usage + +```php +$subscriptionId = 'subscription_id0'; + +$result = $subscriptionsController->getSubscriptionItems($subscriptionId); +``` + + +# Update Subscription Payment Method + +Updates the payment method from a subscription + +```php +function updateSubscriptionPaymentMethod( + string $subscriptionId, + UpdateSubscriptionPaymentMethodRequest $request, ?string $idempotencyKey = null ): GetSubscriptionResponse ``` @@ -366,8 +373,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` | [`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 @@ -379,90 +386,111 @@ function updateSubscriptionMetadata( ```php $subscriptionId = 'subscription_id0'; -$request = UpdateMetadataRequestBuilder::init( - [ - 'key0' => 'metadata3' - ] +$request = UpdateSubscriptionPaymentMethodRequestBuilder::init( + 'payment_method4', + 'card_id2', + CreateCardRequestBuilder::init() + ->type('credit') + ->build() )->build(); -$result = $subscriptionsController->updateSubscriptionMetadata( +$result = $subscriptionsController->updateSubscriptionPaymentMethod( $subscriptionId, $request ); ``` -# Delete Increment +# Get Subscription Item -Deletes a increment +Get Subscription Item ```php -function deleteIncrement( - string $subscriptionId, - string $incrementId, - ?string $idempotencyKey = null -): GetIncrementResponse +function getSubscriptionItem(string $subscriptionId, string $itemId): GetSubscriptionItemResponse ``` ## 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 | Subscription Id | +| `itemId` | `string` | Template, Required | Item id | ## Response Type -[`GetIncrementResponse`](../../doc/models/get-increment-response.md) +[`GetSubscriptionItemResponse`](../../doc/models/get-subscription-item-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$incrementId = 'increment_id8'; +$itemId = 'item_id0'; -$result = $subscriptionsController->deleteIncrement( +$result = $subscriptionsController->getSubscriptionItem( $subscriptionId, - $incrementId + $itemId ); ``` -# Get Subscription +# Get Subscriptions -Gets a subscription +Gets all subscriptions ```php -function getSubscription(string $subscriptionId): GetSubscriptionResponse +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 | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | Subscription id | +| `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 -[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) +[`ListSubscriptionsResponse`](../../doc/models/list-subscriptions-response.md) ## Example Usage ```php -$subscriptionId = 'subscription_id0'; - -$result = $subscriptionsController->getSubscription($subscriptionId); +$result = $subscriptionsController->getSubscriptions(); ``` -# Update Latest Period End At +# Cancel Subscription + +Cancels a subscription ```php -function updateLatestPeriodEndAt( +function cancelSubscription( string $subscriptionId, - UpdateCurrentCycleEndDateRequest $request, + ?CreateCancelSubscriptionRequest $request = null, ?string $idempotencyKey = null ): GetSubscriptionResponse ``` @@ -471,8 +499,8 @@ function updateLatestPeriodEndAt( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | - | -| `request` | [`UpdateCurrentCycleEndDateRequest`](../../doc/models/update-current-cycle-end-date-request.md) | Body, Required | Request for updating the end date of the current signature cycle | +| `subscriptionId` | `string` | Template, Required | Subscription id | +| `request` | [`?CreateCancelSubscriptionRequest`](../../doc/models/create-cancel-subscription-request.md) | Body, Optional | Request for cancelling a subscription | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -484,104 +512,70 @@ function updateLatestPeriodEndAt( ```php $subscriptionId = 'subscription_id0'; -$request = UpdateCurrentCycleEndDateRequestBuilder::init()->build(); +$request = CreateCancelSubscriptionRequestBuilder::init( + true +)->build(); -$result = $subscriptionsController->updateLatestPeriodEndAt( +$result = $subscriptionsController->cancelSubscription( $subscriptionId, $request ); ``` -# Update Current Cycle Status +# Create Increment + +Creates a increment ```php -function updateCurrentCycleStatus( +function createIncrement( string $subscriptionId, - UpdateCurrentCycleStatusRequest $request, + CreateIncrementRequest $request, ?string $idempotencyKey = null -): void +): GetIncrementResponse ``` ## 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 | Subscription id | +| `request` | [`CreateIncrementRequest`](../../doc/models/create-increment-request.md) | Body, Required | Request for creating a increment | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -`void` +[`GetIncrementResponse`](../../doc/models/get-increment-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$request = UpdateCurrentCycleStatusRequestBuilder::init( - 'status8' +$request = CreateIncrementRequestBuilder::init( + 185.28, + 'increment_type8', + 'item_id6' )->build(); -$subscriptionsController->updateCurrentCycleStatus( +$result = $subscriptionsController->createIncrement( $subscriptionId, $request ); ``` -# Get Subscription Items +# Create Usage -Get Subscription Items +Creates a usage ```php -function getSubscriptionItems( +function createUsage( 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 -``` - -## Parameters - -| Parameter | Type | Tags | Description | -| --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | The subscription id | -| `page` | `?int` | Query, Optional | Page number | -| `size` | `?int` | Query, Optional | Page size | -| `name` | `?string` | Query, Optional | The item name | -| `code` | `?string` | Query, Optional | Identification code in the client system | -| `status` | `?string` | Query, Optional | The item statis | -| `description` | `?string` | Query, Optional | The item description | -| `createdSince` | `?string` | Query, Optional | Filter for item's creation date start range | -| `createdUntil` | `?string` | Query, Optional | Filter for item's creation date end range | - -## Response Type - -[`ListSubscriptionItemsResponse`](../../doc/models/list-subscription-items-response.md) - -## Example Usage - -```php -$subscriptionId = 'subscription_id0'; - -$result = $subscriptionsController->getSubscriptionItems($subscriptionId); -``` - - -# Get Subscription Item - -Get Subscription Item - -```php -function getSubscriptionItem(string $subscriptionId, string $itemId): GetSubscriptionItemResponse + string $itemId, + CreateUsageRequest $body, + ?string $idempotencyKey = null +): GetUsageResponse ``` ## Parameters @@ -590,10 +584,12 @@ function getSubscriptionItem(string $subscriptionId, string $itemId): GetSubscri | --- | --- | --- | --- | | `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 -[`GetSubscriptionItemResponse`](../../doc/models/get-subscription-item-response.md) +[`GetUsageResponse`](../../doc/models/get-usage-response.md) ## Example Usage @@ -602,210 +598,257 @@ $subscriptionId = 'subscription_id0'; $itemId = 'item_id0'; -$result = $subscriptionsController->getSubscriptionItem( +$body = CreateUsageRequestBuilder::init( + 156, + 'description4', + DateTimeHelper::fromRfc3339DateTimeRequired('2016-03-13T12:52:32.123Z') +)->build(); + +$result = $subscriptionsController->createUsage( $subscriptionId, - $itemId + $itemId, + $body ); ``` -# Update Subscription Affiliation Id +# Get Discount by Id ```php -function updateSubscriptionAffiliationId( - string $subscriptionId, - UpdateSubscriptionAffiliationIdRequest $request, - ?string $idempotencyKey = null -): GetSubscriptionResponse +function getDiscountById(string $subscriptionId, string $discountId): GetDiscountResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | - | -| `request` | [`UpdateSubscriptionAffiliationIdRequest`](../../doc/models/update-subscription-affiliation-id-request.md) | Body, Required | Request for updating a subscription affiliation id | -| `idempotencyKey` | `?string` | Header, Optional | - | +| `subscriptionId` | `string` | Template, Required | The subscription id | +| `discountId` | `string` | Template, Required | - | ## Response Type -[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) +[`GetDiscountResponse`](../../doc/models/get-discount-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$request = UpdateSubscriptionAffiliationIdRequestBuilder::init( - 'gateway_affiliation_id2' -)->build(); +$discountId = 'discountId0'; -$result = $subscriptionsController->updateSubscriptionAffiliationId( +$result = $subscriptionsController->getDiscountById( $subscriptionId, - $request + $discountId ); ``` -# Get Discounts +# Create Subscription + +Creates a new subscription ```php -function getDiscounts(string $subscriptionId, int $page, int $size): ListDiscountsResponse +function createSubscription( + CreateSubscriptionRequest $body, + ?string $idempotencyKey = null +): GetSubscriptionResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | The subscription id | -| `page` | `int` | Query, Required | Page number | -| `size` | `int` | Query, Required | Page size | +| `body` | [`CreateSubscriptionRequest`](../../doc/models/create-subscription-request.md) | Body, Required | Request for creating a subscription | +| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`ListDiscountsResponse`](../../doc/models/list-discounts-response.md) +[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) ## Example Usage ```php -$subscriptionId = 'subscription_id0'; - -$page = 30; - -$size = 18; +$body = CreateSubscriptionRequestBuilder::init( + CreateCustomerRequestBuilder::init( + '{ + "name": "Tony Stark" +}', + 'email6', + 'document6', + 'type0', + CreateAddressRequestBuilder::init( + 'street6', + 'number4', + 'zip_code0', + 'neighborhood2', + 'city6', + 'state2', + 'country0', + 'complement2', + 'line_10', + 'line_24' + )->build(), + [ + 'key0' => 'metadata3' + ], + CreatePhonesRequestBuilder::init()->build(), + 'code8' + )->build(), + CreateCardRequestBuilder::init() + ->type('credit') + ->build(), + 'code4', + 'payment_method4', + 'billing_type0', + 'statement_descriptor6', + 'description4', + 'currency6', + 'interval6', + 170, + CreatePricingSchemeRequestBuilder::init( + 'scheme_type8' + )->build(), + [ + CreateSubscriptionItemRequestBuilder::init( + 'description2', + CreatePricingSchemeRequestBuilder::init( + 'scheme_type8' + )->build(), + 'id8', + 'plan_item_id8', + [ + CreateDiscountRequestBuilder::init( + 90.66, + 'discount_type2', + 'item_id4' + )->build() + ], + 'name8' + )->build() + ], + CreateShippingRequestBuilder::init( + 52, + 'description6', + 'recipient_name2', + 'recipient_phone6', + 'address_id6', + CreateAddressRequestBuilder::init( + 'street6', + 'number4', + 'zip_code0', + 'neighborhood2', + 'city6', + 'state2', + 'country0', + 'complement2', + 'line_10', + 'line_24' + )->build(), + 'type6' + )->build(), + [ + CreateDiscountRequestBuilder::init( + 90.66, + 'discount_type2', + 'item_id4' + )->build() + ], + [ + 'key0' => 'metadata7', + 'key1' => 'metadata8' + ], + [ + CreateIncrementRequestBuilder::init( + 252.86, + 'increment_type6', + 'item_id6' + )->build() + ] +)->build(); -$result = $subscriptionsController->getDiscounts( - $subscriptionId, - $page, - $size -); +$result = $subscriptionsController->createSubscription($body); ``` -# Update Subscription Item - -Updates a subscription item +# Get Increment by Id ```php -function updateSubscriptionItem( - string $subscriptionId, - string $itemId, - UpdateSubscriptionItemRequest $body, - ?string $idempotencyKey = null -): GetSubscriptionItemResponse +function getIncrementById(string $subscriptionId, string $incrementId): GetIncrementResponse ``` ## 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 | - | +| `subscriptionId` | `string` | Template, Required | The subscription Id | +| `incrementId` | `string` | Template, Required | The increment Id | ## Response Type -[`GetSubscriptionItemResponse`](../../doc/models/get-subscription-item-response.md) +[`GetIncrementResponse`](../../doc/models/get-increment-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(); +$incrementId = 'increment_id8'; -$result = $subscriptionsController->updateSubscriptionItem( +$result = $subscriptionsController->getIncrementById( $subscriptionId, - $itemId, - $body + $incrementId ); ``` -# Create Subscription Item - -Creates a new Subscription item +# Update Subscription Affiliation Id ```php -function createSubscriptionItem( +function updateSubscriptionAffiliationId( string $subscriptionId, - CreateSubscriptionItemRequest $request, + UpdateSubscriptionAffiliationIdRequest $request, ?string $idempotencyKey = null -): GetSubscriptionItemResponse +): GetSubscriptionResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | Subscription id | -| `request` | [`CreateSubscriptionItemRequest`](../../doc/models/create-subscription-item-request.md) | Body, Required | Request for creating a subscription item | +| `subscriptionId` | `string` | Template, Required | - | +| `request` | [`UpdateSubscriptionAffiliationIdRequest`](../../doc/models/update-subscription-affiliation-id-request.md) | Body, Required | Request for updating a subscription affiliation id | | `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'; -$request = CreateSubscriptionItemRequestBuilder::init( - 'description6', - CreatePricingSchemeRequestBuilder::init( - 'scheme_type8' - )->build(), - 'id6', - 'plan_item_id6', - [ - CreateDiscountRequestBuilder::init( - 90.66, - 'discount_type2', - 'item_id4' - )->build() - ], - 'name6' +$request = UpdateSubscriptionAffiliationIdRequestBuilder::init( + 'gateway_affiliation_id2' )->build(); -$result = $subscriptionsController->createSubscriptionItem( +$result = $subscriptionsController->updateSubscriptionAffiliationId( $subscriptionId, $request ); ``` -# Get Usages +# Update Subscription Metadata -Lists all usages from a subscription item +Updates the metadata from a subscription ```php -function getUsages( +function updateSubscriptionMetadata( string $subscriptionId, - string $itemId, - ?int $page = null, - ?int $size = null, - ?string $code = null, - ?string $group = null, - ?\DateTime $usedSince = null, - ?\DateTime $usedUntil = null -): ListUsagesResponse + UpdateMetadataRequest $request, + ?string $idempotencyKey = null +): GetSubscriptionResponse ``` ## Parameters @@ -813,143 +856,147 @@ 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 | -| `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 | - | +| `request` | [`UpdateMetadataRequest`](../../doc/models/update-metadata-request.md) | Body, Required | Request for updating the subscrption metadata | +| `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`ListUsagesResponse`](../../doc/models/list-usages-response.md) +[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$itemId = 'item_id0'; +$request = UpdateMetadataRequestBuilder::init( + [ + 'key0' => 'metadata3' + ] +)->build(); -$result = $subscriptionsController->getUsages( +$result = $subscriptionsController->updateSubscriptionMetadata( $subscriptionId, - $itemId + $request ); ``` -# Update Subscription Minium Price +# Delete Increment -Atualização do valor mínimo da assinatura +Deletes a increment ```php -function updateSubscriptionMiniumPrice( +function deleteIncrement( string $subscriptionId, - UpdateSubscriptionMinimumPriceRequest $request, + string $incrementId, ?string $idempotencyKey = null -): GetSubscriptionResponse +): GetIncrementResponse ``` ## Parameters | 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 | 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 = UpdateSubscriptionMinimumPriceRequestBuilder::init()->build(); +$incrementId = 'increment_id8'; -$result = $subscriptionsController->updateSubscriptionMiniumPrice( +$result = $subscriptionsController->deleteIncrement( $subscriptionId, - $request + $incrementId ); ``` -# 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 ); ``` -# Create an Usage - -Create Usage +# Get Discounts ```php -function createAnUsage(string $subscriptionId, string $itemId, ?string $idempotencyKey = null): GetUsageResponse +function getDiscounts(string $subscriptionId, int $page, int $size): ListDiscountsResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | Subscription id | -| `itemId` | `string` | Template, Required | Item id | -| `idempotencyKey` | `?string` | Header, Optional | - | +| `subscriptionId` | `string` | Template, Required | The subscription id | +| `page` | `int` | Query, Required | Page number | +| `size` | `int` | Query, Required | Page size | ## Response Type -[`GetUsageResponse`](../../doc/models/get-usage-response.md) +[`ListDiscountsResponse`](../../doc/models/list-discounts-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$itemId = 'item_id0'; +$page = 30; -$result = $subscriptionsController->createAnUsage( +$size = 18; + +$result = $subscriptionsController->getDiscounts( $subscriptionId, - $itemId + $page, + $size ); ``` -# Cancel Subscription +# Update Subscription Billing Date -Cancels a subscription +Updates the billing date from a subscription ```php -function cancelSubscription( +function updateSubscriptionBillingDate( string $subscriptionId, - ?CreateCancelSubscriptionRequest $request = null, + UpdateSubscriptionBillingDateRequest $request, ?string $idempotencyKey = null ): GetSubscriptionResponse ``` @@ -958,8 +1005,8 @@ 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 | +| `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 @@ -971,11 +1018,11 @@ function cancelSubscription( ```php $subscriptionId = 'subscription_id0'; -$request = CreateCancelSubscriptionRequestBuilder::init( - true +$request = UpdateSubscriptionBillingDateRequestBuilder::init( + DateTimeHelper::fromRfc3339DateTimeRequired('2016-03-13T12:52:32.123Z') )->build(); -$result = $subscriptionsController->cancelSubscription( +$result = $subscriptionsController->updateSubscriptionBillingDate( $subscriptionId, $request ); @@ -1049,52 +1096,12 @@ $result = $subscriptionsController->getIncrements($subscriptionId); # Update Subscription Due Days -Updates the boleto due days from a subscription - -```php -function updateSubscriptionDueDays( - string $subscriptionId, - UpdateSubscriptionDueDaysRequest $request, - ?string $idempotencyKey = null -): GetSubscriptionResponse -``` - -## Parameters - -| Parameter | Type | Tags | Description | -| --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | Subscription Id | -| `request` | [`UpdateSubscriptionDueDaysRequest`](../../doc/models/update-subscription-due-days-request.md) | Body, Required | - | -| `idempotencyKey` | `?string` | Header, Optional | - | - -## Response Type - -[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) - -## Example Usage - -```php -$subscriptionId = 'subscription_id0'; - -$request = UpdateSubscriptionDueDaysRequestBuilder::init( - 226 -)->build(); - -$result = $subscriptionsController->updateSubscriptionDueDays( - $subscriptionId, - $request -); -``` - - -# Update Subscription Card - -Updates the credit card from a subscription +Updates the boleto due days from a subscription ```php -function updateSubscriptionCard( +function updateSubscriptionDueDays( string $subscriptionId, - UpdateSubscriptionCardRequest $request, + UpdateSubscriptionDueDaysRequest $request, ?string $idempotencyKey = null ): GetSubscriptionResponse ``` @@ -1103,8 +1110,8 @@ function updateSubscriptionCard( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | Subscription id | -| `request` | [`UpdateSubscriptionCardRequest`](../../doc/models/update-subscription-card-request.md) | Body, Required | Request for updating a card | +| `subscriptionId` | `string` | Template, Required | Subscription Id | +| `request` | [`UpdateSubscriptionDueDaysRequest`](../../doc/models/update-subscription-due-days-request.md) | Body, Required | - | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type @@ -1116,31 +1123,27 @@ function updateSubscriptionCard( ```php $subscriptionId = 'subscription_id0'; -$request = UpdateSubscriptionCardRequestBuilder::init( - CreateCardRequestBuilder::init() - ->type('credit') - ->build(), - 'card_id2' +$request = UpdateSubscriptionDueDaysRequestBuilder::init( + 226 )->build(); -$result = $subscriptionsController->updateSubscriptionCard( +$result = $subscriptionsController->updateSubscriptionDueDays( $subscriptionId, $request ); ``` -# Delete Usage +# Update Subscription Start At -Deletes a usage +Updates the start at date from a subscription ```php -function deleteUsage( +function updateSubscriptionStartAt( string $subscriptionId, - string $itemId, - string $usageId, + UpdateSubscriptionStartAtRequest $request, ?string $idempotencyKey = null -): GetUsageResponse +): GetSubscriptionResponse ``` ## Parameters @@ -1148,83 +1151,95 @@ function deleteUsage( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `subscriptionId` | `string` | Template, Required | The subscription id | -| `itemId` | `string` | Template, Required | The subscription item id | -| `usageId` | `string` | Template, Required | The usage id | +| `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 -[`GetUsageResponse`](../../doc/models/get-usage-response.md) +[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$itemId = 'item_id0'; - -$usageId = 'usage_id0'; +$request = UpdateSubscriptionStartAtRequestBuilder::init( + DateTimeHelper::fromRfc3339DateTimeRequired('2016-03-13T12:52:32.123Z') +)->build(); -$result = $subscriptionsController->deleteUsage( +$result = $subscriptionsController->updateSubscriptionStartAt( $subscriptionId, - $itemId, - $usageId + $request ); ``` -# Create Discount +# Update Subscription Item -Creates a discount +Updates a subscription item ```php -function createDiscount( +function updateSubscriptionItem( string $subscriptionId, - CreateDiscountRequest $request, + string $itemId, + UpdateSubscriptionItemRequest $body, ?string $idempotencyKey = null -): GetDiscountResponse +): GetSubscriptionItemResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | Subscription id | -| `request` | [`CreateDiscountRequest`](../../doc/models/create-discount-request.md) | Body, Required | Request for creating a discount | +| `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 -[`GetDiscountResponse`](../../doc/models/get-discount-response.md) +[`GetSubscriptionItemResponse`](../../doc/models/get-subscription-item-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$request = CreateDiscountRequestBuilder::init( - 185.28, - 'discount_type4', - 'item_id6' +$itemId = 'item_id0'; + +$body = UpdateSubscriptionItemRequestBuilder::init( + 'description4', + 'status2', + UpdatePricingSchemeRequestBuilder::init( + 'scheme_type8', + [ + UpdatePriceBracketRequestBuilder::init( + 144, + 174 + )->build() + ] + )->build(), + 'name6' )->build(); -$result = $subscriptionsController->createDiscount( +$result = $subscriptionsController->updateSubscriptionItem( $subscriptionId, - $request + $itemId, + $body ); ``` -# Update Subscription Payment Method +# Create Subscription Item -Updates the payment method from a subscription +Creates a new Subscription item ```php -function updateSubscriptionPaymentMethod( +function createSubscriptionItem( string $subscriptionId, - UpdateSubscriptionPaymentMethodRequest $request, + CreateSubscriptionItemRequest $request, ?string $idempotencyKey = null -): GetSubscriptionResponse +): GetSubscriptionItemResponse ``` ## Parameters @@ -1232,43 +1247,48 @@ function updateSubscriptionPaymentMethod( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `subscriptionId` | `string` | Template, Required | Subscription id | -| `request` | [`UpdateSubscriptionPaymentMethodRequest`](../../doc/models/update-subscription-payment-method-request.md) | Body, Required | Request for updating the paymentmethod from a subscription | +| `request` | [`CreateSubscriptionItemRequest`](../../doc/models/create-subscription-item-request.md) | Body, Required | Request for creating a subscription item | | `idempotencyKey` | `?string` | Header, Optional | - | ## Response Type -[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) +[`GetSubscriptionItemResponse`](../../doc/models/get-subscription-item-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$request = UpdateSubscriptionPaymentMethodRequestBuilder::init( - 'payment_method4', - 'card_id2', - CreateCardRequestBuilder::init() - ->type('credit') - ->build() +$request = CreateSubscriptionItemRequestBuilder::init( + 'description6', + CreatePricingSchemeRequestBuilder::init( + 'scheme_type8' + )->build(), + 'id6', + 'plan_item_id6', + [ + CreateDiscountRequestBuilder::init( + 90.66, + 'discount_type2', + 'item_id4' + )->build() + ], + 'name6' )->build(); -$result = $subscriptionsController->updateSubscriptionPaymentMethod( +$result = $subscriptionsController->createSubscriptionItem( $subscriptionId, $request ); ``` -# Create Increment +# Get Subscription -Creates a increment +Gets a subscription ```php -function createIncrement( - string $subscriptionId, - CreateIncrementRequest $request, - ?string $idempotencyKey = null -): GetIncrementResponse +function getSubscription(string $subscriptionId): GetSubscriptionResponse ``` ## Parameters @@ -1276,56 +1296,53 @@ 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 | -| `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' -)->build(); - -$result = $subscriptionsController->createIncrement( - $subscriptionId, - $request -); +$result = $subscriptionsController->getSubscription($subscriptionId); ``` -# Create Usage +# Get Usages -Creates a usage +Lists all usages from a subscription item ```php -function createUsage( +function getUsages( string $subscriptionId, string $itemId, - CreateUsageRequest $body, - ?string $idempotencyKey = null -): GetUsageResponse + ?int $page = null, + ?int $size = null, + ?string $code = null, + ?string $group = null, + ?\DateTime $usedSince = null, + ?\DateTime $usedUntil = null +): ListUsagesResponse ``` ## 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 | - | +| `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 | +| `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 | - | ## Response Type -[`GetUsageResponse`](../../doc/models/get-usage-response.md) +[`ListUsagesResponse`](../../doc/models/list-usages-response.md) ## Example Usage @@ -1334,63 +1351,57 @@ $subscriptionId = 'subscription_id0'; $itemId = 'item_id0'; -$body = CreateUsageRequestBuilder::init( - 156, - 'description4', - DateTimeHelper::fromRfc3339DateTimeRequired('2016-03-13T12:52:32.123Z') -)->build(); - -$result = $subscriptionsController->createUsage( +$result = $subscriptionsController->getUsages( $subscriptionId, - $itemId, - $body + $itemId ); ``` -# Get Subscription Cycles +# Update Latest Period End At ```php -function getSubscriptionCycles(string $subscriptionId, string $page, string $size): ListCyclesResponse +function updateLatestPeriodEndAt( + string $subscriptionId, + UpdateCurrentCycleEndDateRequest $request, + ?string $idempotencyKey = null +): GetSubscriptionResponse ``` ## 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 | - | +| `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 -[`ListCyclesResponse`](../../doc/models/list-cycles-response.md) +[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$page = 'page8'; - -$size = 'size0'; +$request = UpdateCurrentCycleEndDateRequestBuilder::init()->build(); -$result = $subscriptionsController->getSubscriptionCycles( +$result = $subscriptionsController->updateLatestPeriodEndAt( $subscriptionId, - $page, - $size + $request ); ``` -# Update Subscription Billing Date +# Update Subscription Minium Price -Updates the billing date from a subscription +Atualização do valor mínimo da assinatura ```php -function updateSubscriptionBillingDate( +function updateSubscriptionMiniumPrice( string $subscriptionId, - UpdateSubscriptionBillingDateRequest $request, + UpdateSubscriptionMinimumPriceRequest $request, ?string $idempotencyKey = null ): GetSubscriptionResponse ``` @@ -1399,8 +1410,8 @@ function updateSubscriptionBillingDate( | 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` | [`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 @@ -1412,27 +1423,19 @@ function updateSubscriptionBillingDate( ```php $subscriptionId = 'subscription_id0'; -$request = UpdateSubscriptionBillingDateRequestBuilder::init( - DateTimeHelper::fromRfc3339DateTimeRequired('2016-03-13T12:52:32.123Z') -)->build(); +$request = UpdateSubscriptionMinimumPriceRequestBuilder::init()->build(); -$result = $subscriptionsController->updateSubscriptionBillingDate( +$result = $subscriptionsController->updateSubscriptionMiniumPrice( $subscriptionId, $request ); ``` -# Update Subscription Start At - -Updates the start at date from a subscription +# Get Subscription Cycle by Id ```php -function updateSubscriptionStartAt( - string $subscriptionId, - UpdateSubscriptionStartAtRequest $request, - ?string $idempotencyKey = null -): GetSubscriptionResponse +function getSubscriptionCycleById(string $subscriptionId, string $cycleId): GetPeriodResponse ``` ## Parameters @@ -1440,25 +1443,22 @@ 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 | - | +| `cycleId` | `string` | Template, Required | - | ## Response Type -[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) +[`GetPeriodResponse`](../../doc/models/get-period-response.md) ## Example Usage ```php $subscriptionId = 'subscription_id0'; -$request = UpdateSubscriptionStartAtRequestBuilder::init( - DateTimeHelper::fromRfc3339DateTimeRequired('2016-03-13T12:52:32.123Z') -)->build(); +$cycleId = 'cycleId0'; -$result = $subscriptionsController->updateSubscriptionStartAt( +$result = $subscriptionsController->getSubscriptionCycleById( $subscriptionId, - $request + $cycleId ); ``` diff --git a/doc/controllers/tokens.md b/doc/controllers/tokens.md index 732e7a7..ba3d3f3 100644 --- a/doc/controllers/tokens.md +++ b/doc/controllers/tokens.md @@ -16,8 +16,6 @@ $tokensController = $client->getTokensController(); # Create Token -:information_source: **Note** This endpoint does not require authentication. - ```php function createToken( string $publicKey, @@ -67,8 +65,6 @@ $result = $tokensController->createToken( Gets a token from its id -:information_source: **Note** This endpoint does not require authentication. - ```php function getToken(string $id, string $publicKey): GetTokenResponse ``` diff --git a/doc/controllers/transfers.md b/doc/controllers/transfers.md index 306c6bf..36eb1cb 100644 --- a/doc/controllers/transfers.md +++ b/doc/controllers/transfers.md @@ -10,28 +10,9 @@ $transfersController = $client->getTransfersController(); ## Methods -* [Get Transfers](../../doc/controllers/transfers.md#get-transfers) * [Get Transfer by Id](../../doc/controllers/transfers.md#get-transfer-by-id) * [Create Transfer](../../doc/controllers/transfers.md#create-transfer) - - -# Get Transfers - -Gets all transfers - -```php -function getTransfers(): ListTransfers -``` - -## Response Type - -[`ListTransfers`](../../doc/models/list-transfers.md) - -## Example Usage - -```php -$result = $transfersController->getTransfers(); -``` +* [Get Transfers](../../doc/controllers/transfers.md#get-transfers) # Get Transfer by Id @@ -87,3 +68,22 @@ $request = CreateTransferBuilder::init( $result = $transfersController->createTransfer($request); ``` + +# Get Transfers + +Gets all transfers + +```php +function getTransfers(): ListTransfers +``` + +## Response Type + +[`ListTransfers`](../../doc/models/list-transfers.md) + +## Example Usage + +```php +$result = $transfersController->getTransfers(); +``` + diff --git a/doc/models/create-managing-partner-request.md b/doc/models/create-managing-partner-request.md index 5c327a1..f836932 100644 --- a/doc/models/create-managing-partner-request.md +++ b/doc/models/create-managing-partner-request.md @@ -16,7 +16,7 @@ Managing Partner Request | `document` | `string` | Required | - | getDocument(): string | setDocument(string document): void | | `motherName` | `string` | Required | - | getMotherName(): string | setMotherName(string motherName): void | | `birthdate` | `string` | Required | - | getBirthdate(): string | setBirthdate(string birthdate): void | -| `monthlyIncome` | `string` | Required | - | getMonthlyIncome(): string | setMonthlyIncome(string monthlyIncome): void | +| `monthlyIncome` | `int` | Required | - | getMonthlyIncome(): int | setMonthlyIncome(int monthlyIncome): void | | `professionalOccupation` | `string` | Required | - | getProfessionalOccupation(): string | setProfessionalOccupation(string professionalOccupation): void | | `selfDeclaredLegalRepresentative` | `bool` | Required | - | getSelfDeclaredLegalRepresentative(): bool | setSelfDeclaredLegalRepresentative(bool selfDeclaredLegalRepresentative): void | | `address` | [`CreateRegisterInformationAddressRequest`](../../doc/models/create-register-information-address-request.md) | Required | - | getAddress(): CreateRegisterInformationAddressRequest | setAddress(CreateRegisterInformationAddressRequest address): void | @@ -31,7 +31,7 @@ Managing Partner Request "document": "document2", "mother_name": "mother_name0", "birthdate": "birthdate8", - "monthly_income": "monthly_income0", + "monthly_income": 70, "professional_occupation": "professional_occupation8", "self_declared_legal_representative": false, "address": { diff --git a/doc/models/create-register-information-corporation-request.md b/doc/models/create-register-information-corporation-request.md index 70d9cee..841f7fe 100644 --- a/doc/models/create-register-information-corporation-request.md +++ b/doc/models/create-register-information-corporation-request.md @@ -15,7 +15,7 @@ | --- | --- | --- | --- | --- | --- | | `companyName` | `string` | Required | - | getCompanyName(): string | setCompanyName(string companyName): void | | `tradingName` | `string` | Required | - | getTradingName(): string | setTradingName(string tradingName): void | -| `annualRevenue` | `string` | Required | - | getAnnualRevenue(): string | setAnnualRevenue(string annualRevenue): void | +| `annualRevenue` | `int` | Required | - | getAnnualRevenue(): int | setAnnualRevenue(int annualRevenue): void | | `corporationType` | `?string` | Optional | - | getCorporationType(): ?string | setCorporationType(?string corporationType): void | | `foundingDate` | `?string` | Optional | - | getFoundingDate(): ?string | setFoundingDate(?string foundingDate): void | | `cnae` | `?string` | Optional | - | getCnae(): ?string | setCnae(?string cnae): void | @@ -38,7 +38,7 @@ ], "company_name": "company_name8", "trading_name": "trading_name0", - "annual_revenue": "annual_revenue0", + "annual_revenue": 156, "managing_partners": [ { "name": "name4", @@ -46,7 +46,7 @@ "document": "document8", "mother_name": "mother_name0", "birthdate": "birthdate8", - "monthly_income": "monthly_income0", + "monthly_income": 202, "professional_occupation": "professional_occupation8", "self_declared_legal_representative": false, "address": { diff --git a/doc/models/create-register-information-individual-request.md b/doc/models/create-register-information-individual-request.md index 6c087bf..6134ea9 100644 --- a/doc/models/create-register-information-individual-request.md +++ b/doc/models/create-register-information-individual-request.md @@ -16,7 +16,7 @@ | `name` | `string` | Required | - | getName(): string | setName(string name): void | | `motherName` | `?string` | Optional | - | getMotherName(): ?string | setMotherName(?string motherName): void | | `birthdate` | `string` | Required | - | getBirthdate(): string | setBirthdate(string birthdate): void | -| `monthlyIncome` | `string` | Required | - | getMonthlyIncome(): string | setMonthlyIncome(string monthlyIncome): void | +| `monthlyIncome` | `int` | Required | - | getMonthlyIncome(): int | setMonthlyIncome(int monthlyIncome): void | | `professionalOccupation` | `string` | Required | - | getProfessionalOccupation(): string | setProfessionalOccupation(string professionalOccupation): void | | `address` | [`CreateRegisterInformationAddressRequest`](../../doc/models/create-register-information-address-request.md) | Required | - | getAddress(): CreateRegisterInformationAddressRequest | setAddress(CreateRegisterInformationAddressRequest address): void | @@ -43,7 +43,7 @@ "name": "name6", "mother_name": "mother_name2", "birthdate": "birthdate0", - "monthly_income": "monthly_income2", + "monthly_income": 206, "professional_occupation": "professional_occupation0", "address": { "street": "street6", diff --git a/doc/models/get-transaction-response.md b/doc/models/get-transaction-response.md index 50e6a51..54189f5 100644 --- a/doc/models/get-transaction-response.md +++ b/doc/models/get-transaction-response.md @@ -40,11 +40,20 @@ Generic response object for getting a transaction. "status": "status6", "success": false, "created_at": "2016-03-13T12:52:32.123Z", - "statement_descriptor": "statement_descriptor2", - "acquirer_name": "acquirer_name6", - "acquirer_affiliation_code": "acquirer_affiliation_code6", - "acquirer_tid": "acquirer_tid8", - "acquirer_nsu": "acquirer_nsu8" + "qr_code": "qr_code0", + "qr_code_url": "qr_code_url6", + "expires_at": "2016-03-13T12:52:32.123Z", + "additional_information": [ + { + "Name": "Name0", + "Value": "Value2" + }, + { + "Name": "Name0", + "Value": "Value2" + } + ], + "end_to_end_id": "end_to_end_id6" } ``` diff --git a/doc/models/list-charge-transactions-response.md b/doc/models/list-charge-transactions-response.md index cc5f56a..84f7b68 100644 --- a/doc/models/list-charge-transactions-response.md +++ b/doc/models/list-charge-transactions-response.md @@ -25,11 +25,20 @@ Response object for listing charge transactions "status": "status6", "success": false, "created_at": "2016-03-13T12:52:32.123Z", - "statement_descriptor": "statement_descriptor2", - "acquirer_name": "acquirer_name6", - "acquirer_affiliation_code": "acquirer_affiliation_code6", - "acquirer_tid": "acquirer_tid8", - "acquirer_nsu": "acquirer_nsu8" + "qr_code": "qr_code0", + "qr_code_url": "qr_code_url6", + "expires_at": "2016-03-13T12:52:32.123Z", + "additional_information": [ + { + "Name": "Name0", + "Value": "Value2" + }, + { + "Name": "Name0", + "Value": "Value2" + } + ], + "end_to_end_id": "end_to_end_id6" }, { "gateway_id": "gateway_id8", @@ -37,11 +46,20 @@ Response object for listing charge transactions "status": "status6", "success": false, "created_at": "2016-03-13T12:52:32.123Z", - "statement_descriptor": "statement_descriptor2", - "acquirer_name": "acquirer_name6", - "acquirer_affiliation_code": "acquirer_affiliation_code6", - "acquirer_tid": "acquirer_tid8", - "acquirer_nsu": "acquirer_nsu8" + "qr_code": "qr_code0", + "qr_code_url": "qr_code_url6", + "expires_at": "2016-03-13T12:52:32.123Z", + "additional_information": [ + { + "Name": "Name0", + "Value": "Value2" + }, + { + "Name": "Name0", + "Value": "Value2" + } + ], + "end_to_end_id": "end_to_end_id6" } ], "paging": { diff --git a/doc/models/list-transactions-response.md b/doc/models/list-transactions-response.md index 9898977..563a573 100644 --- a/doc/models/list-transactions-response.md +++ b/doc/models/list-transactions-response.md @@ -25,11 +25,20 @@ Response object for listing transactions "status": "status6", "success": false, "created_at": "2016-03-13T12:52:32.123Z", - "statement_descriptor": "statement_descriptor2", - "acquirer_name": "acquirer_name6", - "acquirer_affiliation_code": "acquirer_affiliation_code6", - "acquirer_tid": "acquirer_tid8", - "acquirer_nsu": "acquirer_nsu8" + "qr_code": "qr_code0", + "qr_code_url": "qr_code_url6", + "expires_at": "2016-03-13T12:52:32.123Z", + "additional_information": [ + { + "Name": "Name0", + "Value": "Value2" + }, + { + "Name": "Name0", + "Value": "Value2" + } + ], + "end_to_end_id": "end_to_end_id6" }, { "gateway_id": "gateway_id8", @@ -37,11 +46,20 @@ Response object for listing transactions "status": "status6", "success": false, "created_at": "2016-03-13T12:52:32.123Z", - "statement_descriptor": "statement_descriptor2", - "acquirer_name": "acquirer_name6", - "acquirer_affiliation_code": "acquirer_affiliation_code6", - "acquirer_tid": "acquirer_tid8", - "acquirer_nsu": "acquirer_nsu8" + "qr_code": "qr_code0", + "qr_code_url": "qr_code_url6", + "expires_at": "2016-03-13T12:52:32.123Z", + "additional_information": [ + { + "Name": "Name0", + "Value": "Value2" + }, + { + "Name": "Name0", + "Value": "Value2" + } + ], + "end_to_end_id": "end_to_end_id6" }, { "gateway_id": "gateway_id8", @@ -49,11 +67,20 @@ Response object for listing transactions "status": "status6", "success": false, "created_at": "2016-03-13T12:52:32.123Z", - "statement_descriptor": "statement_descriptor2", - "acquirer_name": "acquirer_name6", - "acquirer_affiliation_code": "acquirer_affiliation_code6", - "acquirer_tid": "acquirer_tid8", - "acquirer_nsu": "acquirer_nsu8" + "qr_code": "qr_code0", + "qr_code_url": "qr_code_url6", + "expires_at": "2016-03-13T12:52:32.123Z", + "additional_information": [ + { + "Name": "Name0", + "Value": "Value2" + }, + { + "Name": "Name0", + "Value": "Value2" + } + ], + "end_to_end_id": "end_to_end_id6" } ], "paging": { diff --git a/src/ApiHelper.php b/src/ApiHelper.php index e8b1374..6d67757 100644 --- a/src/ApiHelper.php +++ b/src/ApiHelper.php @@ -27,15 +27,15 @@ class ApiHelper */ private const INHERITED_MODELS_MAP = [ Models\GetTransactionResponse::class => [ - Models\GetVoucherTransactionResponse::class, Models\GetBankTransferTransactionResponse::class, Models\GetSafetyPayTransactionResponse::class, - Models\GetDebitCardTransactionResponse::class, + Models\GetVoucherTransactionResponse::class, Models\GetBoletoTransactionResponse::class, - Models\GetCashTransactionResponse::class, + Models\GetDebitCardTransactionResponse::class, Models\GetPrivateLabelTransactionResponse::class, - Models\GetPixTransactionResponse::class, - Models\GetCreditCardTransactionResponse::class + Models\GetCashTransactionResponse::class, + Models\GetCreditCardTransactionResponse::class, + Models\GetPixTransactionResponse::class ], Models\GetMovementObjectBaseResponse::class => [ Models\GetMovementObjectRefundResponse::class, diff --git a/src/BasicAuthCredentials.php b/src/BasicAuthCredentials.php deleted file mode 100644 index 23d88d8..0000000 --- a/src/BasicAuthCredentials.php +++ /dev/null @@ -1,35 +0,0 @@ -required() - ); - $this->basicAuthUserName = $basicAuthUserName; - $this->basicAuthPassword = $basicAuthPassword; - } - - /** - * String value for basicAuthUserName. - */ - public function getBasicAuthUserName(): string - { - return $this->basicAuthUserName; - } - - /** - * String value for basicAuthPassword. - */ - public function getBasicAuthPassword(): string - { - return $this->basicAuthPassword; - } - - /** - * Checks if provided credentials match with existing ones. - * - * @param string $basicAuthUserName The username to use with basic authentication - * @param string $basicAuthPassword The password to use with basic authentication - */ - public function equals(string $basicAuthUserName, string $basicAuthPassword): bool - { - return $basicAuthUserName == $this->basicAuthUserName && - $basicAuthPassword == $this->basicAuthPassword; - } -} diff --git a/src/ConfigurationDefaults.php b/src/ConfigurationDefaults.php index 148c547..2ad7fbc 100644 --- a/src/ConfigurationDefaults.php +++ b/src/ConfigurationDefaults.php @@ -37,10 +37,6 @@ class ConfigurationDefaults public const ENVIRONMENT = Environment::PRODUCTION; - public const BASIC_AUTH_USER_NAME = ''; - - public const BASIC_AUTH_PASSWORD = ''; - /** * @var array Associative list of all default configurations */ @@ -55,8 +51,6 @@ class ConfigurationDefaults 'httpStatusCodesToRetry' => self::HTTP_STATUS_CODES_TO_RETRY, 'httpMethodsToRetry' => self::HTTP_METHODS_TO_RETRY, 'serviceRefererName' => self::SERVICE_REFERER_NAME, - 'environment' => self::ENVIRONMENT, - 'basicAuthUserName' => self::BASIC_AUTH_USER_NAME, - 'basicAuthPassword' => self::BASIC_AUTH_PASSWORD + 'environment' => self::ENVIRONMENT ]; } diff --git a/src/ConfigurationInterface.php b/src/ConfigurationInterface.php index 7bad9c3..e89478a 100644 --- a/src/ConfigurationInterface.php +++ b/src/ConfigurationInterface.php @@ -27,11 +27,6 @@ public function getServiceRefererName(): string; */ public function getEnvironment(): string; - /** - * Get the credentials to use with BasicAuth - */ - public function getBasicAuthCredentials(): ?BasicAuthCredentials; - /** * Get the base uri for a given server in the current environment. * diff --git a/src/Controllers/BalanceOperationsController.php b/src/Controllers/BalanceOperationsController.php index 8d027f6..fb623cc 100644 --- a/src/Controllers/BalanceOperationsController.php +++ b/src/Controllers/BalanceOperationsController.php @@ -37,7 +37,6 @@ public function getBalanceOperations( ?string $recipientId = null ): ListBalanceOperationResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/balance/operations') - ->auth('global') ->parameters( QueryParam::init('status', $status), QueryParam::init('created_since', $createdSince) @@ -62,7 +61,6 @@ public function getBalanceOperations( public function getBalanceOperationById(int $id): GetBalanceOperationResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/balance/operations/{id}') - ->auth('global') ->parameters(TemplateParam::init('id', $id)); $_resHandler = $this->responseHandler()->type(GetBalanceOperationResponse::class); diff --git a/src/Controllers/ChargesController.php b/src/Controllers/ChargesController.php index 30230af..9048de7 100644 --- a/src/Controllers/ChargesController.php +++ b/src/Controllers/ChargesController.php @@ -49,7 +49,6 @@ public function updateChargeMetadata( ?string $idempotencyKey = null ): GetChargeResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/Charges/{charge_id}/metadata') - ->auth('global') ->parameters( TemplateParam::init('charge_id', $chargeId), BodyParam::init($request), @@ -79,7 +78,6 @@ public function updateChargePaymentMethod( ?string $idempotencyKey = null ): GetChargeResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/charges/{charge_id}/payment-method') - ->auth('global') ->parameters( TemplateParam::init('charge_id', $chargeId), BodyParam::init($request), @@ -92,78 +90,53 @@ public function updateChargePaymentMethod( } /** - * Updates the card from a charge - * - * @param string $chargeId Charge id - * @param UpdateChargeCardRequest $request Request for updating a charge's card - * @param string|null $idempotencyKey + * @param string $chargeId Charge Id + * @param int|null $page Page number + * @param int|null $size Page size * - * @return GetChargeResponse Response from the API call + * @return ListChargeTransactionsResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateChargeCard( + public function getChargeTransactions( string $chargeId, - UpdateChargeCardRequest $request, - ?string $idempotencyKey = null - ): GetChargeResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/charges/{charge_id}/card') - ->auth('global') + ?int $page = null, + ?int $size = null + ): ListChargeTransactionsResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/charges/{charge_id}/transactions') ->parameters( TemplateParam::init('charge_id', $chargeId), - BodyParam::init($request), - HeaderParam::init('idempotency-key', $idempotencyKey) - ); - - $_resHandler = $this->responseHandler()->type(GetChargeResponse::class); - - return $this->execute($_reqBuilder, $_resHandler); - } - - /** - * @param string $status - * @param \DateTime|null $createdSince - * @param \DateTime|null $createdUntil - * - * @return GetChargesSummaryResponse Response from the API call - * - * @throws ApiException Thrown if API call fails - */ - public function getChargesSummary( - string $status, - ?\DateTime $createdSince = null, - ?\DateTime $createdUntil = null - ): GetChargesSummaryResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/charges/summary') - ->auth('global') - ->parameters( - QueryParam::init('status', $status), - QueryParam::init('created_since', $createdSince) - ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), - QueryParam::init('created_until', $createdUntil) - ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']) + QueryParam::init('page', $page), + QueryParam::init('size', $size) ); - $_resHandler = $this->responseHandler()->type(GetChargesSummaryResponse::class); + $_resHandler = $this->responseHandler()->type(ListChargeTransactionsResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Creates a new charge + * Updates the due date from a charge * - * @param CreateChargeRequest $request Request for creating a charge + * @param string $chargeId Charge Id + * @param UpdateChargeDueDateRequest $request Request for updating the due date * @param string|null $idempotencyKey * * @return GetChargeResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function createCharge(CreateChargeRequest $request, ?string $idempotencyKey = null): GetChargeResponse - { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/Charges') - ->auth('global') - ->parameters(BodyParam::init($request), HeaderParam::init('idempotency-key', $idempotencyKey)); + public function updateChargeDueDate( + string $chargeId, + UpdateChargeDueDateRequest $request, + ?string $idempotencyKey = null + ): GetChargeResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/Charges/{charge_id}/due-date') + ->parameters( + TemplateParam::init('charge_id', $chargeId), + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) + ); $_resHandler = $this->responseHandler()->type(GetChargeResponse::class); @@ -171,28 +144,50 @@ public function createCharge(CreateChargeRequest $request, ?string $idempotencyK } /** - * @param string $chargeId Charge Id + * Lists all charges + * * @param int|null $page Page number * @param int|null $size Page size + * @param string|null $code Filter for charge's code + * @param string|null $status Filter for charge's status + * @param string|null $paymentMethod Filter for charge's payment method + * @param string|null $customerId Filter for charge's customer id + * @param string|null $orderId Filter for charge's order id + * @param \DateTime|null $createdSince Filter for the beginning of the range for charge's + * creation + * @param \DateTime|null $createdUntil Filter for the end of the range for charge's creation * - * @return ListChargeTransactionsResponse Response from the API call + * @return ListChargesResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getChargeTransactions( - string $chargeId, + public function getCharges( ?int $page = null, - ?int $size = null - ): ListChargeTransactionsResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/charges/{charge_id}/transactions') - ->auth('global') + ?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') ->parameters( - TemplateParam::init('charge_id', $chargeId), QueryParam::init('page', $page), - QueryParam::init('size', $size) + QueryParam::init('size', $size), + QueryParam::init('code', $code), + QueryParam::init('status', $status), + QueryParam::init('payment_method', $paymentMethod), + QueryParam::init('customer_id', $customerId), + QueryParam::init('order_id', $orderId), + QueryParam::init('created_since', $createdSince) + ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), + QueryParam::init('created_until', $createdUntil) + ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']) ); - $_resHandler = $this->responseHandler()->type(ListChargeTransactionsResponse::class); + $_resHandler = $this->responseHandler()->type(ListChargesResponse::class); return $this->execute($_reqBuilder, $_resHandler); } @@ -214,7 +209,6 @@ public function captureCharge( ?string $idempotencyKey = null ): GetChargeResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/charges/{charge_id}/capture') - ->auth('global') ->parameters( TemplateParam::init('charge_id', $chargeId), BodyParam::init($request), @@ -227,19 +221,27 @@ public function captureCharge( } /** - * Get a charge from its id + * Updates the card from a charge * * @param string $chargeId Charge id + * @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 getCharge(string $chargeId): GetChargeResponse - { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/charges/{charge_id}') - ->auth('global') - ->parameters(TemplateParam::init('charge_id', $chargeId)); + public function updateChargeCard( + string $chargeId, + UpdateChargeCardRequest $request, + ?string $idempotencyKey = null + ): GetChargeResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/charges/{charge_id}/card') + ->parameters( + TemplateParam::init('charge_id', $chargeId), + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) + ); $_resHandler = $this->responseHandler()->type(GetChargeResponse::class); @@ -247,28 +249,18 @@ public function getCharge(string $chargeId): GetChargeResponse } /** - * Cancel a charge + * Get a charge from its id * * @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 cancelCharge( - string $chargeId, - ?CreateCancelChargeRequest $request = null, - ?string $idempotencyKey = null - ): GetChargeResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/charges/{charge_id}') - ->auth('global') - ->parameters( - TemplateParam::init('charge_id', $chargeId), - BodyParam::init($request), - HeaderParam::init('idempotency-key', $idempotencyKey) - ); + public function getCharge(string $chargeId): GetChargeResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/charges/{charge_id}') + ->parameters(TemplateParam::init('charge_id', $chargeId)); $_resHandler = $this->responseHandler()->type(GetChargeResponse::class); @@ -276,74 +268,48 @@ public function cancelCharge( } /** - * Lists all charges - * - * @param int|null $page Page number - * @param int|null $size Page size - * @param string|null $code Filter for charge's code - * @param string|null $status Filter for charge's status - * @param string|null $paymentMethod Filter for charge's payment method - * @param string|null $customerId Filter for charge's customer id - * @param string|null $orderId Filter for charge's order id - * @param \DateTime|null $createdSince Filter for the beginning of the range for charge's - * creation - * @param \DateTime|null $createdUntil Filter for the end of the range for charge's creation + * @param string $status + * @param \DateTime|null $createdSince + * @param \DateTime|null $createdUntil * - * @return ListChargesResponse Response from the API call + * @return GetChargesSummaryResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getCharges( - ?int $page = null, - ?int $size = null, - ?string $code = null, - ?string $status = null, - ?string $paymentMethod = null, - ?string $customerId = null, - ?string $orderId = null, + public function getChargesSummary( + string $status, ?\DateTime $createdSince = null, ?\DateTime $createdUntil = null - ): ListChargesResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/charges') - ->auth('global') + ): GetChargesSummaryResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/charges/summary') ->parameters( - QueryParam::init('page', $page), - QueryParam::init('size', $size), - QueryParam::init('code', $code), QueryParam::init('status', $status), - QueryParam::init('payment_method', $paymentMethod), - QueryParam::init('customer_id', $customerId), - QueryParam::init('order_id', $orderId), QueryParam::init('created_since', $createdSince) ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), QueryParam::init('created_until', $createdUntil) ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']) ); - $_resHandler = $this->responseHandler()->type(ListChargesResponse::class); + $_resHandler = $this->responseHandler()->type(GetChargesSummaryResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * @param string $chargeId - * @param CreateConfirmPaymentRequest|null $request Request for confirm payment + * Retries a charge + * + * @param string $chargeId Charge id * @param string|null $idempotencyKey * * @return GetChargeResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function confirmPayment( - string $chargeId, - ?CreateConfirmPaymentRequest $request = null, - ?string $idempotencyKey = null - ): GetChargeResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/charges/{charge_id}/confirm-payment') - ->auth('global') + public function retryCharge(string $chargeId, ?string $idempotencyKey = null): GetChargeResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/charges/{charge_id}/retry') ->parameters( TemplateParam::init('charge_id', $chargeId), - BodyParam::init($request), HeaderParam::init('idempotency-key', $idempotencyKey) ); @@ -353,23 +319,22 @@ public function confirmPayment( } /** - * Updates the due date from a charge + * Cancel a charge * - * @param string $chargeId Charge Id - * @param UpdateChargeDueDateRequest $request Request for updating the due date + * @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 updateChargeDueDate( + public function cancelCharge( string $chargeId, - UpdateChargeDueDateRequest $request, + ?CreateCancelChargeRequest $request = null, ?string $idempotencyKey = null ): GetChargeResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/Charges/{charge_id}/due-date') - ->auth('global') + $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/charges/{charge_id}') ->parameters( TemplateParam::init('charge_id', $chargeId), BodyParam::init($request), @@ -382,21 +347,43 @@ public function updateChargeDueDate( } /** - * Retries a charge + * Creates a new charge * - * @param string $chargeId Charge id + * @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 retryCharge(string $chargeId, ?string $idempotencyKey = null): GetChargeResponse + public function createCharge(CreateChargeRequest $request, ?string $idempotencyKey = null): GetChargeResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/charges/{charge_id}/retry') - ->auth('global') + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/Charges') + ->parameters(BodyParam::init($request), HeaderParam::init('idempotency-key', $idempotencyKey)); + + $_resHandler = $this->responseHandler()->type(GetChargeResponse::class); + + return $this->execute($_reqBuilder, $_resHandler); + } + + /** + * @param string $chargeId + * @param CreateConfirmPaymentRequest|null $request Request for confirm payment + * @param string|null $idempotencyKey + * + * @return GetChargeResponse Response from the API call + * + * @throws ApiException Thrown if API call fails + */ + public function confirmPayment( + string $chargeId, + ?CreateConfirmPaymentRequest $request = null, + ?string $idempotencyKey = null + ): GetChargeResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/charges/{charge_id}/confirm-payment') ->parameters( TemplateParam::init('charge_id', $chargeId), + BodyParam::init($request), HeaderParam::init('idempotency-key', $idempotencyKey) ); diff --git a/src/Controllers/CustomersController.php b/src/Controllers/CustomersController.php index c9ad0e0..995fc1a 100644 --- a/src/Controllers/CustomersController.php +++ b/src/Controllers/CustomersController.php @@ -54,7 +54,6 @@ public function updateCard( ?string $idempotencyKey = null ): GetCardResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/customers/{customer_id}/cards/{card_id}') - ->auth('global') ->parameters( TemplateParam::init('customer_id', $customerId), TemplateParam::init('card_id', $cardId), @@ -86,7 +85,6 @@ public function updateAddress( ?string $idempotencyKey = null ): GetAddressResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/customers/{customer_id}/addresses/{address_id}') - ->auth('global') ->parameters( TemplateParam::init('customer_id', $customerId), TemplateParam::init('address_id', $addressId), @@ -119,7 +117,6 @@ public function deleteAccessToken( RequestMethod::DELETE, '/customers/{customer_id}/access-tokens/{token_id}' ) - ->auth('global') ->parameters( TemplateParam::init('customer_id', $customerId), TemplateParam::init('token_id', $tokenId), @@ -131,35 +128,6 @@ public function deleteAccessToken( return $this->execute($_reqBuilder, $_resHandler); } - /** - * Creates a new address for a customer - * - * @param string $customerId Customer Id - * @param CreateAddressRequest $request Request for creating an address - * @param string|null $idempotencyKey - * - * @return GetAddressResponse 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') - ->auth('global') - ->parameters( - TemplateParam::init('customer_id', $customerId), - BodyParam::init($request), - HeaderParam::init('idempotency-key', $idempotencyKey) - ); - - $_resHandler = $this->responseHandler()->type(GetAddressResponse::class); - - return $this->execute($_reqBuilder, $_resHandler); - } - /** * Creates a new customer * @@ -173,7 +141,6 @@ public function createAddress( public function createCustomer(CreateCustomerRequest $request, ?string $idempotencyKey = null): GetCustomerResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/customers') - ->auth('global') ->parameters(BodyParam::init($request), HeaderParam::init('idempotency-key', $idempotencyKey)); $_resHandler = $this->responseHandler()->type(GetCustomerResponse::class); @@ -182,82 +149,48 @@ public function createCustomer(CreateCustomerRequest $request, ?string $idempote } /** - * Creates a new card for a customer + * Creates a new address for a customer * - * @param string $customerId Customer id - * @param CreateCardRequest $request Request for creating a card + * @param string $customerId Customer Id + * @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 createCard( + public function createAddress( string $customerId, - CreateCardRequest $request, + CreateAddressRequest $request, ?string $idempotencyKey = null - ): GetCardResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/customers/{customer_id}/cards') - ->auth('global') + ): GetAddressResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/customers/{customer_id}/addresses') ->parameters( TemplateParam::init('customer_id', $customerId), 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); } /** - * Get all cards from a customer + * Delete a Customer's access tokens * * @param string $customerId Customer Id - * @param int|null $page Page number - * @param int|null $size Page size - * - * @return ListCardsResponse Response from the API call - * - * @throws ApiException Thrown if API call fails - */ - public function getCards(string $customerId, ?int $page = null, ?int $size = null): ListCardsResponse - { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/customers/{customer_id}/cards') - ->auth('global') - ->parameters( - TemplateParam::init('customer_id', $customerId), - QueryParam::init('page', $page), - QueryParam::init('size', $size) - ); - - $_resHandler = $this->responseHandler()->type(ListCardsResponse::class); - - return $this->execute($_reqBuilder, $_resHandler); - } - - /** - * Renew a card * - * @param string $customerId Customer id - * @param string $cardId Card Id - * @param string|null $idempotencyKey - * - * @return GetCardResponse Response from the API call + * @return ListAccessTokensResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function renewCard(string $customerId, string $cardId, ?string $idempotencyKey = null): GetCardResponse + public function deleteAccessTokens(string $customerId): ListAccessTokensResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/customers/{customer_id}/cards/{card_id}/renew') - ->auth('global') - ->parameters( - TemplateParam::init('customer_id', $customerId), - TemplateParam::init('card_id', $cardId), - HeaderParam::init('idempotency-key', $idempotencyKey) - ); + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/customers/{customer_id}/access-tokens/') + ->parameters(TemplateParam::init('customer_id', $customerId)); - $_resHandler = $this->responseHandler()->type(GetCardResponse::class); + $_resHandler = $this->responseHandler()->type(ListAccessTokensResponse::class); return $this->execute($_reqBuilder, $_resHandler); } @@ -275,7 +208,6 @@ public function renewCard(string $customerId, string $cardId, ?string $idempoten public function getAddress(string $customerId, string $addressId): GetAddressResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/customers/{customer_id}/addresses/{address_id}') - ->auth('global') ->parameters( TemplateParam::init('customer_id', $customerId), TemplateParam::init('address_id', $addressId) @@ -306,7 +238,6 @@ public function deleteAddress( RequestMethod::DELETE, '/customers/{customer_id}/addresses/{address_id}' ) - ->auth('global') ->parameters( TemplateParam::init('customer_id', $customerId), TemplateParam::init('address_id', $addressId), @@ -319,98 +250,94 @@ public function deleteAddress( } /** - * Get a Customer's access token - * - * @param string $customerId Customer Id - * @param string $tokenId Token Id - * - * @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}' - ) - ->auth('global') - ->parameters( - TemplateParam::init('customer_id', $customerId), - TemplateParam::init('token_id', $tokenId) - ); - - $_resHandler = $this->responseHandler()->type(GetAccessTokenResponse::class); - - return $this->execute($_reqBuilder, $_resHandler); - } - - /** - * Updates the metadata a customer + * Creates a new card for a customer * - * @param string $customerId The customer id - * @param UpdateMetadataRequest $request Request for updating the customer metadata + * @param string $customerId Customer id + * @param CreateCardRequest $request Request for creating a card * @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 updateCustomerMetadata( + public function createCard( string $customerId, - UpdateMetadataRequest $request, + CreateCardRequest $request, ?string $idempotencyKey = null - ): GetCustomerResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/Customers/{customer_id}/metadata') - ->auth('global') + ): GetCardResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/customers/{customer_id}/cards') ->parameters( TemplateParam::init('customer_id', $customerId), BodyParam::init($request), HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetCustomerResponse::class); + $_resHandler = $this->responseHandler()->type(GetCardResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Get a customer's card + * Get all Customers * - * @param string $customerId Customer id - * @param string $cardId Card id + * @param string|null $name Name of the Customer + * @param string|null $document Document of the Customer + * @param int|null $page Current page the the search + * @param int|null $size Quantity pages of the search + * @param string|null $email Customer's email + * @param string|null $code Customer's code * - * @return GetCardResponse Response from the API call + * @return ListCustomersResponse 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('global') - ->parameters(TemplateParam::init('customer_id', $customerId), TemplateParam::init('card_id', $cardId)); + public function getCustomers( + ?string $name = null, + ?string $document = null, + ?int $page = 1, + ?int $size = 10, + ?string $email = null, + ?string $code = null + ): ListCustomersResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/customers') + ->parameters( + QueryParam::init('name', $name), + QueryParam::init('document', $document), + QueryParam::init('page', $page), + QueryParam::init('size', $size), + QueryParam::init('email', $email), + QueryParam::init('Code', $code) + ); - $_resHandler = $this->responseHandler()->type(GetCardResponse::class); + $_resHandler = $this->responseHandler()->type(ListCustomersResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Delete a Customer's access tokens + * Updates a customer * - * @param string $customerId Customer Id + * @param string $customerId Customer id + * @param UpdateCustomerRequest $request Request for updating a customer + * @param string|null $idempotencyKey * - * @return ListAccessTokensResponse Response from the API call + * @return GetCustomerResponse 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/') - ->auth('global') - ->parameters(TemplateParam::init('customer_id', $customerId)); + public function updateCustomer( + string $customerId, + UpdateCustomerRequest $request, + ?string $idempotencyKey = null + ): GetCustomerResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/customers/{customer_id}') + ->parameters( + TemplateParam::init('customer_id', $customerId), + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) + ); - $_resHandler = $this->responseHandler()->type(ListAccessTokensResponse::class); + $_resHandler = $this->responseHandler()->type(GetCustomerResponse::class); return $this->execute($_reqBuilder, $_resHandler); } @@ -432,7 +359,6 @@ public function createAccessToken( ?string $idempotencyKey = null ): GetAccessTokenResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/customers/{customer_id}/access-tokens') - ->auth('global') ->parameters( TemplateParam::init('customer_id', $customerId), BodyParam::init($request), @@ -458,7 +384,6 @@ public function createAccessToken( public function getAccessTokens(string $customerId, ?int $page = null, ?int $size = null): ListAccessTokensResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/customers/{customer_id}/access-tokens') - ->auth('global') ->parameters( TemplateParam::init('customer_id', $customerId), QueryParam::init('page', $page), @@ -471,61 +396,94 @@ public function getAccessTokens(string $customerId, ?int $page = null, ?int $siz } /** - * Get all Customers + * Get all cards from a customer * - * @param string|null $name Name of the Customer - * @param string|null $document Document of the Customer - * @param int|null $page Current page the the search - * @param int|null $size Quantity pages of the search - * @param string|null $email Customer's email - * @param string|null $code Customer's code + * @param string $customerId Customer Id + * @param int|null $page Page number + * @param int|null $size Page size * - * @return ListCustomersResponse Response from the API call + * @return ListCardsResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getCustomers( - ?string $name = null, - ?string $document = null, - ?int $page = 1, - ?int $size = 10, - ?string $email = null, - ?string $code = null - ): ListCustomersResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/customers') - ->auth('global') + public function getCards(string $customerId, ?int $page = null, ?int $size = null): ListCardsResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/customers/{customer_id}/cards') ->parameters( - QueryParam::init('name', $name), - QueryParam::init('document', $document), + TemplateParam::init('customer_id', $customerId), QueryParam::init('page', $page), - QueryParam::init('size', $size), - QueryParam::init('email', $email), - QueryParam::init('Code', $code) + QueryParam::init('size', $size) ); - $_resHandler = $this->responseHandler()->type(ListCustomersResponse::class); + $_resHandler = $this->responseHandler()->type(ListCardsResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Updates a customer + * Renew a card * * @param string $customerId Customer id - * @param UpdateCustomerRequest $request Request for updating a customer + * @param string $cardId Card Id + * @param string|null $idempotencyKey + * + * @return GetCardResponse 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') + ->parameters( + TemplateParam::init('customer_id', $customerId), + TemplateParam::init('card_id', $cardId), + HeaderParam::init('idempotency-key', $idempotencyKey) + ); + + $_resHandler = $this->responseHandler()->type(GetCardResponse::class); + + return $this->execute($_reqBuilder, $_resHandler); + } + + /** + * Get a Customer's access token + * + * @param string $customerId Customer Id + * @param string $tokenId Token Id + * + * @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}' + )->parameters(TemplateParam::init('customer_id', $customerId), TemplateParam::init('token_id', $tokenId)); + + $_resHandler = $this->responseHandler()->type(GetAccessTokenResponse::class); + + return $this->execute($_reqBuilder, $_resHandler); + } + + /** + * Updates the metadata a customer + * + * @param string $customerId The customer id + * @param UpdateMetadataRequest $request Request for updating the customer metadata * @param string|null $idempotencyKey * * @return GetCustomerResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateCustomer( + public function updateCustomerMetadata( string $customerId, - UpdateCustomerRequest $request, + UpdateMetadataRequest $request, ?string $idempotencyKey = null ): GetCustomerResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/customers/{customer_id}') - ->auth('global') + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/Customers/{customer_id}/metadata') ->parameters( TemplateParam::init('customer_id', $customerId), BodyParam::init($request), @@ -551,7 +509,6 @@ public function updateCustomer( public function deleteCard(string $customerId, string $cardId, ?string $idempotencyKey = null): GetCardResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/customers/{customer_id}/cards/{card_id}') - ->auth('global') ->parameters( TemplateParam::init('customer_id', $customerId), TemplateParam::init('card_id', $cardId), @@ -577,7 +534,6 @@ public function deleteCard(string $customerId, string $cardId, ?string $idempote public function getAddresses(string $customerId, ?int $page = null, ?int $size = null): ListAddressesResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/customers/{customer_id}/addresses') - ->auth('global') ->parameters( TemplateParam::init('customer_id', $customerId), QueryParam::init('page', $page), @@ -601,11 +557,30 @@ public function getAddresses(string $customerId, ?int $page = null, ?int $size = public function getCustomer(string $customerId): GetCustomerResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/customers/{customer_id}') - ->auth('global') ->parameters(TemplateParam::init('customer_id', $customerId)); $_resHandler = $this->responseHandler()->type(GetCustomerResponse::class); return $this->execute($_reqBuilder, $_resHandler); } + + /** + * Get a customer's card + * + * @param string $customerId Customer id + * @param string $cardId Card id + * + * @return GetCardResponse Response from the API call + * + * @throws ApiException Thrown if API call fails + */ + public function getCard(string $customerId, string $cardId): GetCardResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/customers/{customer_id}/cards/{card_id}') + ->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 857a90a..375eaa6 100644 --- a/src/Controllers/InvoicesController.php +++ b/src/Controllers/InvoicesController.php @@ -25,6 +25,76 @@ class InvoicesController extends BaseController { + /** + * Updates the metadata from an invoice + * + * @param string $invoiceId The invoice id + * @param UpdateMetadataRequest $request Request for updating the invoice metadata + * @param string|null $idempotencyKey + * + * @return GetInvoiceResponse 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') + ->parameters( + TemplateParam::init('invoice_id', $invoiceId), + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) + ); + + $_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' + )->parameters(TemplateParam::init('subscription_id', $subscriptionId)); + + $_resHandler = $this->responseHandler()->type(GetInvoiceResponse::class); + + return $this->execute($_reqBuilder, $_resHandler); + } + + /** + * Cancels an invoice + * + * @param string $invoiceId Invoice id + * @param string|null $idempotencyKey + * + * @return GetInvoiceResponse Response from the API call + * + * @throws ApiException Thrown if API call fails + */ + public function cancelInvoice(string $invoiceId, ?string $idempotencyKey = null): GetInvoiceResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/invoices/{invoice_id}') + ->parameters( + TemplateParam::init('invoice_id', $invoiceId), + HeaderParam::init('idempotency-key', $idempotencyKey) + ); + + $_resHandler = $this->responseHandler()->type(GetInvoiceResponse::class); + + return $this->execute($_reqBuilder, $_resHandler); + } + /** * Create an Invoice * @@ -47,7 +117,6 @@ public function createInvoice( RequestMethod::POST, '/subscriptions/{subscription_id}/cycles/{cycle_id}/pay' ) - ->auth('global') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), TemplateParam::init('cycle_id', $cycleId), @@ -93,7 +162,6 @@ public function getInvoices( ?string $customerDocument = null ): ListInvoicesResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/invoices') - ->auth('global') ->parameters( QueryParam::init('page', $page), QueryParam::init('size', $size), @@ -116,71 +184,18 @@ public function getInvoices( } /** - * Cancels an invoice - * - * @param string $invoiceId Invoice id - * @param string|null $idempotencyKey - * - * @return GetInvoiceResponse Response from the API call - * - * @throws ApiException Thrown if API call fails - */ - public function cancelInvoice(string $invoiceId, ?string $idempotencyKey = null): GetInvoiceResponse - { - $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/invoices/{invoice_id}') - ->auth('global') - ->parameters( - TemplateParam::init('invoice_id', $invoiceId), - HeaderParam::init('idempotency-key', $idempotencyKey) - ); - - $_resHandler = $this->responseHandler()->type(GetInvoiceResponse::class); - - return $this->execute($_reqBuilder, $_resHandler); - } - - /** - * Updates the metadata from an invoice - * - * @param string $invoiceId The invoice id - * @param UpdateMetadataRequest $request Request for updating the invoice metadata - * @param string|null $idempotencyKey - * - * @return GetInvoiceResponse Response from the API call + * Gets an invoice * - * @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') - ->auth('global') - ->parameters( - TemplateParam::init('invoice_id', $invoiceId), - BodyParam::init($request), - HeaderParam::init('idempotency-key', $idempotencyKey) - ); - - $_resHandler = $this->responseHandler()->type(GetInvoiceResponse::class); - - return $this->execute($_reqBuilder, $_resHandler); - } - - /** - * @param string $subscriptionId Subscription Id + * @param string $invoiceId Invoice Id * * @return GetInvoiceResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getPartialInvoice(string $subscriptionId): GetInvoiceResponse + public function getInvoice(string $invoiceId): GetInvoiceResponse { - $_reqBuilder = $this->requestBuilder( - RequestMethod::GET, - '/subscriptions/{subscription_id}/partial-invoice' - )->auth('global')->parameters(TemplateParam::init('subscription_id', $subscriptionId)); + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/invoices/{invoice_id}') + ->parameters(TemplateParam::init('invoice_id', $invoiceId)); $_resHandler = $this->responseHandler()->type(GetInvoiceResponse::class); @@ -204,7 +219,6 @@ public function updateInvoiceStatus( ?string $idempotencyKey = null ): GetInvoiceResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/invoices/{invoice_id}/status') - ->auth('global') ->parameters( TemplateParam::init('invoice_id', $invoiceId), BodyParam::init($request), @@ -215,24 +229,4 @@ 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('global') - ->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 cabe654..fd63294 100644 --- a/src/Controllers/OrdersController.php +++ b/src/Controllers/OrdersController.php @@ -53,7 +53,6 @@ public function getOrders( ?string $customerId = null ): ListOrderResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/orders') - ->auth('global') ->parameters( QueryParam::init('page', $page), QueryParam::init('size', $size), @@ -74,16 +73,26 @@ 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 getOrderItem(string $orderId, string $itemId): GetOrderItemResponse - { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/orders/{orderId}/items/{itemId}') - ->auth('global') - ->parameters(TemplateParam::init('orderId', $orderId), TemplateParam::init('itemId', $itemId)); + public function updateOrderItem( + string $orderId, + string $itemId, + UpdateOrderItemRequest $request, + ?string $idempotencyKey = null + ): GetOrderItemResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/orders/{orderId}/items/{itemId}') + ->parameters( + TemplateParam::init('orderId', $orderId), + TemplateParam::init('itemId', $itemId), + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) + ); $_resHandler = $this->responseHandler()->type(GetOrderItemResponse::class); @@ -91,25 +100,52 @@ public function getOrderItem(string $orderId, string $itemId): GetOrderItemRespo } /** - * Gets an order - * - * @param string $orderId Order id + * @param string $orderId Order Id + * @param string|null $idempotencyKey * * @return GetOrderResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getOrder(string $orderId): GetOrderResponse + public function deleteAllOrderItems(string $orderId, ?string $idempotencyKey = null): GetOrderResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/orders/{order_id}') - ->auth('global') - ->parameters(TemplateParam::init('order_id', $orderId)); + $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/orders/{orderId}/items') + ->parameters( + TemplateParam::init('orderId', $orderId), + HeaderParam::init('idempotency-key', $idempotencyKey) + ); $_resHandler = $this->responseHandler()->type(GetOrderResponse::class); return $this->execute($_reqBuilder, $_resHandler); } + /** + * @param string $orderId Order Id + * @param string $itemId Item Id + * @param string|null $idempotencyKey + * + * @return GetOrderItemResponse Response from the API call + * + * @throws ApiException Thrown if API call fails + */ + public function deleteOrderItem( + string $orderId, + string $itemId, + ?string $idempotencyKey = null + ): GetOrderItemResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/orders/{orderId}/items/{itemId}') + ->parameters( + TemplateParam::init('orderId', $orderId), + TemplateParam::init('itemId', $itemId), + HeaderParam::init('idempotency-key', $idempotencyKey) + ); + + $_resHandler = $this->responseHandler()->type(GetOrderItemResponse::class); + + return $this->execute($_reqBuilder, $_resHandler); + } + /** * @param string $id Order Id * @param UpdateOrderStatusRequest $request Update Order Model @@ -125,7 +161,6 @@ public function closeOrder( ?string $idempotencyKey = null ): GetOrderResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/orders/{id}/closed') - ->auth('global') ->parameters( TemplateParam::init('id', $id), BodyParam::init($request), @@ -150,7 +185,6 @@ public function closeOrder( public function createOrder(CreateOrderRequest $body, ?string $idempotencyKey = null): GetOrderResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/orders') - ->auth('global') ->parameters(BodyParam::init($body), HeaderParam::init('idempotency-key', $idempotencyKey)); $_resHandler = $this->responseHandler()->type(GetOrderResponse::class); @@ -160,25 +194,21 @@ public function createOrder(CreateOrderRequest $body, ?string $idempotencyKey = /** * @param string $orderId Order Id - * @param string $itemId Item Id - * @param UpdateOrderItemRequest $request Item Model + * @param CreateOrderItemRequest $request Order Item Model * @param string|null $idempotencyKey * * @return GetOrderItemResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateOrderItem( + public function createOrderItem( string $orderId, - string $itemId, - UpdateOrderItemRequest $request, + CreateOrderItemRequest $request, ?string $idempotencyKey = null ): GetOrderItemResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/orders/{orderId}/items/{itemId}') - ->auth('global') + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/orders/{orderId}/items') ->parameters( TemplateParam::init('orderId', $orderId), - TemplateParam::init('itemId', $itemId), BodyParam::init($request), HeaderParam::init('idempotency-key', $idempotencyKey) ); @@ -190,22 +220,18 @@ public function updateOrderItem( /** * @param string $orderId Order Id - * @param string|null $idempotencyKey + * @param string $itemId Item Id * - * @return GetOrderResponse Response from the API call + * @return GetOrderItemResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function deleteAllOrderItems(string $orderId, ?string $idempotencyKey = null): GetOrderResponse + public function getOrderItem(string $orderId, string $itemId): GetOrderItemResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/orders/{orderId}/items') - ->auth('global') - ->parameters( - TemplateParam::init('orderId', $orderId), - HeaderParam::init('idempotency-key', $idempotencyKey) - ); + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/orders/{orderId}/items/{itemId}') + ->parameters(TemplateParam::init('orderId', $orderId), TemplateParam::init('itemId', $itemId)); - $_resHandler = $this->responseHandler()->type(GetOrderResponse::class); + $_resHandler = $this->responseHandler()->type(GetOrderItemResponse::class); return $this->execute($_reqBuilder, $_resHandler); } @@ -227,7 +253,6 @@ public function updateOrderMetadata( ?string $idempotencyKey = null ): GetOrderResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/Orders/{order_id}/metadata') - ->auth('global') ->parameters( TemplateParam::init('order_id', $orderId), BodyParam::init($request), @@ -240,55 +265,20 @@ public function updateOrderMetadata( } /** - * @param string $orderId Order Id - * @param string $itemId Item Id - * @param string|null $idempotencyKey - * - * @return GetOrderItemResponse Response from the API call + * Gets an order * - * @throws ApiException Thrown if API call fails - */ - public function deleteOrderItem( - string $orderId, - string $itemId, - ?string $idempotencyKey = null - ): GetOrderItemResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/orders/{orderId}/items/{itemId}') - ->auth('global') - ->parameters( - TemplateParam::init('orderId', $orderId), - TemplateParam::init('itemId', $itemId), - HeaderParam::init('idempotency-key', $idempotencyKey) - ); - - $_resHandler = $this->responseHandler()->type(GetOrderItemResponse::class); - - return $this->execute($_reqBuilder, $_resHandler); - } - - /** - * @param string $orderId Order Id - * @param CreateOrderItemRequest $request Order Item Model - * @param string|null $idempotencyKey + * @param string $orderId Order id * - * @return GetOrderItemResponse Response from the API call + * @return GetOrderResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function createOrderItem( - string $orderId, - CreateOrderItemRequest $request, - ?string $idempotencyKey = null - ): GetOrderItemResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/orders/{orderId}/items') - ->auth('global') - ->parameters( - TemplateParam::init('orderId', $orderId), - BodyParam::init($request), - HeaderParam::init('idempotency-key', $idempotencyKey) - ); + public function getOrder(string $orderId): GetOrderResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/orders/{order_id}') + ->parameters(TemplateParam::init('order_id', $orderId)); - $_resHandler = $this->responseHandler()->type(GetOrderItemResponse::class); + $_resHandler = $this->responseHandler()->type(GetOrderResponse::class); return $this->execute($_reqBuilder, $_resHandler); } diff --git a/src/Controllers/PayablesController.php b/src/Controllers/PayablesController.php index d71a668..1573c9b 100644 --- a/src/Controllers/PayablesController.php +++ b/src/Controllers/PayablesController.php @@ -65,7 +65,6 @@ public function getPayables( ?int $gatewayId = null ): ListPayablesResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/payables') - ->auth('global') ->parameters( QueryParam::init('type', $type), QueryParam::init('split_id', $splitId), @@ -107,7 +106,6 @@ public function getPayables( public function getPayableById(int $id): GetPayableResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/payables/{id}') - ->auth('global') ->parameters(TemplateParam::init('id', $id)); $_resHandler = $this->responseHandler()->type(GetPayableResponse::class); diff --git a/src/Controllers/PlansController.php b/src/Controllers/PlansController.php index e824b56..990bdd2 100644 --- a/src/Controllers/PlansController.php +++ b/src/Controllers/PlansController.php @@ -40,7 +40,6 @@ class PlansController extends BaseController public function getPlan(string $planId): GetPlanResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/plans/{plan_id}') - ->auth('global') ->parameters(TemplateParam::init('plan_id', $planId)); $_resHandler = $this->responseHandler()->type(GetPlanResponse::class); @@ -49,26 +48,20 @@ public function getPlan(string $planId): GetPlanResponse } /** - * Updates a plan + * Deletes a plan * * @param string $planId Plan id - * @param UpdatePlanRequest $request Request for updating a plan * @param string|null $idempotencyKey * * @return GetPlanResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updatePlan( - string $planId, - UpdatePlanRequest $request, - ?string $idempotencyKey = null - ): GetPlanResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/plans/{plan_id}') - ->auth('global') + public function deletePlan(string $planId, ?string $idempotencyKey = null): GetPlanResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/plans/{plan_id}') ->parameters( TemplateParam::init('plan_id', $planId), - BodyParam::init($request), HeaderParam::init('idempotency-key', $idempotencyKey) ); @@ -94,7 +87,6 @@ public function updatePlanMetadata( ?string $idempotencyKey = null ): GetPlanResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/Plans/{plan_id}/metadata') - ->auth('global') ->parameters( TemplateParam::init('plan_id', $planId), BodyParam::init($request), @@ -107,26 +99,28 @@ public function updatePlanMetadata( } /** - * Removes an item from a plan + * Updates a plan item * * @param string $planId Plan id * @param string $planItemId Plan item id + * @param UpdatePlanItemRequest $body Request for updating the plan item * @param string|null $idempotencyKey * * @return GetPlanItemResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function deletePlanItem( + public function updatePlanItem( string $planId, string $planItemId, + UpdatePlanItemRequest $body, ?string $idempotencyKey = null ): GetPlanItemResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/plans/{plan_id}/items/{plan_item_id}') - ->auth('global') + $_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/plans/{plan_id}/items/{plan_item_id}') ->parameters( TemplateParam::init('plan_id', $planId), TemplateParam::init('plan_item_id', $planItemId), + BodyParam::init($body), HeaderParam::init('idempotency-key', $idempotencyKey) ); @@ -136,44 +130,29 @@ public function deletePlanItem( } /** - * Gets all plans + * Adds a new item to a plan * - * @param int|null $page Page number - * @param int|null $size Page size - * @param string|null $name Filter for Plan's name - * @param string|null $status Filter for Plan's status - * @param string|null $billingType Filter for plan's billing type - * @param \DateTime|null $createdSince Filter for plan's creation date start range - * @param \DateTime|null $createdUntil Filter for plan's creation date end range + * @param string $planId Plan id + * @param CreatePlanItemRequest $request Request for creating a plan item + * @param string|null $idempotencyKey * - * @return ListPlansResponse Response from the API call + * @return GetPlanItemResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getPlans( - ?int $page = null, - ?int $size = null, - ?string $name = null, - ?string $status = null, - ?string $billingType = null, - ?\DateTime $createdSince = null, - ?\DateTime $createdUntil = null - ): ListPlansResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/plans') - ->auth('global') + public function createPlanItem( + string $planId, + CreatePlanItemRequest $request, + ?string $idempotencyKey = null + ): GetPlanItemResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/plans/{plan_id}/items') ->parameters( - QueryParam::init('page', $page), - QueryParam::init('size', $size), - QueryParam::init('name', $name), - QueryParam::init('status', $status), - QueryParam::init('billing_type', $billingType), - QueryParam::init('created_since', $createdSince) - ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), - QueryParam::init('created_until', $createdUntil) - ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']) + TemplateParam::init('plan_id', $planId), + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(ListPlansResponse::class); + $_resHandler = $this->responseHandler()->type(GetPlanItemResponse::class); return $this->execute($_reqBuilder, $_resHandler); } @@ -191,7 +170,6 @@ public function getPlans( public function getPlanItem(string $planId, string $planItemId): GetPlanItemResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/plans/{plan_id}/items/{plan_item_id}') - ->auth('global') ->parameters(TemplateParam::init('plan_id', $planId), TemplateParam::init('plan_item_id', $planItemId)); $_resHandler = $this->responseHandler()->type(GetPlanItemResponse::class); @@ -200,23 +178,19 @@ public function getPlanItem(string $planId, string $planItemId): GetPlanItemResp } /** - * Deletes a plan + * Creates a new plan * - * @param string $planId Plan id + * @param CreatePlanRequest $body Request for creating a plan * @param string|null $idempotencyKey * * @return GetPlanResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function deletePlan(string $planId, ?string $idempotencyKey = null): GetPlanResponse + public function createPlan(CreatePlanRequest $body, ?string $idempotencyKey = null): GetPlanResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/plans/{plan_id}') - ->auth('global') - ->parameters( - TemplateParam::init('plan_id', $planId), - HeaderParam::init('idempotency-key', $idempotencyKey) - ); + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/plans') + ->parameters(BodyParam::init($body), HeaderParam::init('idempotency-key', $idempotencyKey)); $_resHandler = $this->responseHandler()->type(GetPlanResponse::class); @@ -224,29 +198,25 @@ public function deletePlan(string $planId, ?string $idempotencyKey = null): GetP } /** - * Updates a plan item + * Removes an item from a plan * * @param string $planId Plan id * @param string $planItemId Plan item id - * @param UpdatePlanItemRequest $body Request for updating the plan item * @param string|null $idempotencyKey * * @return GetPlanItemResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updatePlanItem( + public function deletePlanItem( string $planId, string $planItemId, - UpdatePlanItemRequest $body, ?string $idempotencyKey = null ): GetPlanItemResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/plans/{plan_id}/items/{plan_item_id}') - ->auth('global') + $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/plans/{plan_id}/items/{plan_item_id}') ->parameters( TemplateParam::init('plan_id', $planId), TemplateParam::init('plan_item_id', $planItemId), - BodyParam::init($body), HeaderParam::init('idempotency-key', $idempotencyKey) ); @@ -256,49 +226,69 @@ public function updatePlanItem( } /** - * Adds a new item to a plan + * Gets all plans * - * @param string $planId Plan id - * @param CreatePlanItemRequest $request Request for creating a plan item - * @param string|null $idempotencyKey + * @param int|null $page Page number + * @param int|null $size Page size + * @param string|null $name Filter for Plan's name + * @param string|null $status Filter for Plan's status + * @param string|null $billingType Filter for plan's billing type + * @param \DateTime|null $createdSince Filter for plan's creation date start range + * @param \DateTime|null $createdUntil Filter for plan's creation date end range * - * @return GetPlanItemResponse Response from the API call + * @return ListPlansResponse 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('global') + public function getPlans( + ?int $page = null, + ?int $size = null, + ?string $name = null, + ?string $status = null, + ?string $billingType = null, + ?\DateTime $createdSince = null, + ?\DateTime $createdUntil = null + ): ListPlansResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/plans') ->parameters( - TemplateParam::init('plan_id', $planId), - BodyParam::init($request), - HeaderParam::init('idempotency-key', $idempotencyKey) + QueryParam::init('page', $page), + QueryParam::init('size', $size), + QueryParam::init('name', $name), + QueryParam::init('status', $status), + QueryParam::init('billing_type', $billingType), + QueryParam::init('created_since', $createdSince) + ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), + QueryParam::init('created_until', $createdUntil) + ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']) ); - $_resHandler = $this->responseHandler()->type(GetPlanItemResponse::class); + $_resHandler = $this->responseHandler()->type(ListPlansResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Creates a new plan + * Updates a plan * - * @param CreatePlanRequest $body Request for creating a plan + * @param string $planId Plan id + * @param UpdatePlanRequest $request Request for updating 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 - { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/plans') - ->auth('global') - ->parameters(BodyParam::init($body), HeaderParam::init('idempotency-key', $idempotencyKey)); + public function updatePlan( + string $planId, + UpdatePlanRequest $request, + ?string $idempotencyKey = null + ): GetPlanResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/plans/{plan_id}') + ->parameters( + TemplateParam::init('plan_id', $planId), + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) + ); $_resHandler = $this->responseHandler()->type(GetPlanResponse::class); diff --git a/src/Controllers/RecipientsController.php b/src/Controllers/RecipientsController.php index cdc2e90..0128c99 100644 --- a/src/Controllers/RecipientsController.php +++ b/src/Controllers/RecipientsController.php @@ -56,7 +56,6 @@ public function updateRecipient( ?string $idempotencyKey = null ): GetRecipientResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/recipients/{recipient_id}') - ->auth('global') ->parameters( TemplateParam::init('recipient_id', $recipientId), BodyParam::init($request), @@ -85,7 +84,6 @@ public function createAnticipation( ?string $idempotencyKey = null ): GetAnticipationResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/recipients/{recipient_id}/anticipations') - ->auth('global') ->parameters( TemplateParam::init('recipient_id', $recipientId), BodyParam::init($request), @@ -114,7 +112,6 @@ public function getAnticipationLimits( \DateTime $paymentDate ): GetAnticipationLimitResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/{recipient_id}/anticipation_limits') - ->auth('global') ->parameters( TemplateParam::init('recipient_id', $recipientId), QueryParam::init('timeframe', $timeframe), @@ -140,7 +137,6 @@ public function getAnticipationLimits( public function getRecipients(?int $page = null, ?int $size = null): ListRecipientResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients') - ->auth('global') ->parameters(QueryParam::init('page', $page), QueryParam::init('size', $size)); $_resHandler = $this->responseHandler()->type(ListRecipientResponse::class); @@ -149,104 +145,77 @@ public function getRecipients(?int $page = null, ?int $size = null): ListRecipie } /** - * 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('global') - ->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 transfer - * - * @param string $recipientId Recipient id - * @param string $transferId Transfer id + * @param string $recipientId + * @param string $withdrawalId * - * @return GetTransferResponse Response from the API call + * @return GetWithdrawResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getTransfer(string $recipientId, string $transferId): GetTransferResponse + public function getWithdrawById(string $recipientId, string $withdrawalId): GetWithdrawResponse { $_reqBuilder = $this->requestBuilder( RequestMethod::GET, - '/recipients/{recipient_id}/transfers/{transfer_id}' + '/recipients/{recipient_id}/withdrawals/{withdrawal_id}' ) - ->auth('global') ->parameters( TemplateParam::init('recipient_id', $recipientId), - TemplateParam::init('transfer_id', $transferId) + TemplateParam::init('withdrawal_id', $withdrawalId) ); - $_resHandler = $this->responseHandler()->type(GetTransferResponse::class); + $_resHandler = $this->responseHandler()->type(GetWithdrawResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Gets an anticipation + * Updates the default bank account from a recipient * * @param string $recipientId Recipient id - * @param string $anticipationId Anticipation id + * @param UpdateRecipientBankAccountRequest $request Bank account data + * @param string|null $idempotencyKey * - * @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 updateRecipientDefaultBankAccount( + string $recipientId, + UpdateRecipientBankAccountRequest $request, + ?string $idempotencyKey = null + ): GetRecipientResponse { $_reqBuilder = $this->requestBuilder( - RequestMethod::GET, - '/recipients/{recipient_id}/anticipations/{anticipation_id}' + RequestMethod::PATCH, + '/recipients/{recipient_id}/default-bank-account' ) - ->auth('global') ->parameters( TemplateParam::init('recipient_id', $recipientId), - TemplateParam::init('anticipation_id', $anticipationId) + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_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 UpdateMetadataRequest $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 updateRecipientMetadata( string $recipientId, - UpdateTransferSettingsRequest $request, + UpdateMetadataRequest $request, ?string $idempotencyKey = null ): GetRecipientResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/recipients/{recipient_id}/transfer-settings') - ->auth('global') + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/recipients/{recipient_id}/metadata') ->parameters( TemplateParam::init('recipient_id', $recipientId), BodyParam::init($request), @@ -259,84 +228,66 @@ public function updateRecipientTransferSettings( } /** - * Retrieves a paginated list of anticipations from a recipient + * Gets a paginated list of transfers for the 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|null $status Filter for transfer status + * @param \DateTime|null $createdSince Filter for start range of transfer creation date + * @param \DateTime|null $createdUntil Filter for end range of transfer creation date * - * @return ListAnticipationResponse Response from the API call + * @return ListTransferResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getAnticipations( + public function getTransfers( 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('global') + ): ListTransferResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/{recipient_id}/transfers') ->parameters( TemplateParam::init('recipient_id', $recipientId), QueryParam::init('page', $page), QueryParam::init('size', $size), QueryParam::init('status', $status), - QueryParam::init('timeframe', $timeframe), - QueryParam::init('payment_date_since', $paymentDateSince) - ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), - QueryParam::init('payment_date_until', $paymentDateUntil) - ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), QueryParam::init('created_since', $createdSince) ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), QueryParam::init('created_until', $createdUntil) ->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']) ); - $_resHandler = $this->responseHandler()->type(ListAnticipationResponse::class); + $_resHandler = $this->responseHandler()->type(ListTransferResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Updates the default bank account from a recipient + * Gets a transfer * * @param string $recipientId Recipient id - * @param UpdateRecipientBankAccountRequest $request Bank account data - * @param string|null $idempotencyKey + * @param string $transferId Transfer id * - * @return GetRecipientResponse Response from the API call + * @return GetTransferResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateRecipientDefaultBankAccount( - string $recipientId, - UpdateRecipientBankAccountRequest $request, - ?string $idempotencyKey = null - ): GetRecipientResponse { + public function getTransfer(string $recipientId, string $transferId): GetTransferResponse + { $_reqBuilder = $this->requestBuilder( - RequestMethod::PATCH, - '/recipients/{recipient_id}/default-bank-account' + RequestMethod::GET, + '/recipients/{recipient_id}/transfers/{transfer_id}' ) - ->auth('global') ->parameters( TemplateParam::init('recipient_id', $recipientId), - BodyParam::init($request), - HeaderParam::init('idempotency-key', $idempotencyKey) + TemplateParam::init('transfer_id', $transferId) ); - $_resHandler = $this->responseHandler()->type(GetRecipientResponse::class); + $_resHandler = $this->responseHandler()->type(GetTransferResponse::class); return $this->execute($_reqBuilder, $_resHandler); } @@ -352,7 +303,6 @@ public function updateRecipientDefaultBankAccount( public function createWithdraw(string $recipientId, CreateWithdrawRequest $request): GetWithdrawResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/recipients/{recipient_id}/withdrawals') - ->auth('global') ->parameters(TemplateParam::init('recipient_id', $recipientId), BodyParam::init($request)); $_resHandler = $this->responseHandler()->type(GetWithdrawResponse::class); @@ -361,71 +311,82 @@ public function createWithdraw(string $recipientId, CreateWithdrawRequest $reque } /** - * Get balance information for a recipient + * Updates recipient metadata * * @param string $recipientId Recipient id + * @param UpdateAutomaticAnticipationSettingsRequest $request Metadata + * @param string|null $idempotencyKey * - * @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 - { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/{recipient_id}/balance') - ->auth('global') - ->parameters(TemplateParam::init('recipient_id', $recipientId)); + public function updateAutomaticAnticipationSettings( + string $recipientId, + UpdateAutomaticAnticipationSettingsRequest $request, + ?string $idempotencyKey = null + ): GetRecipientResponse { + $_reqBuilder = $this->requestBuilder( + RequestMethod::PATCH, + '/recipients/{recipient_id}/automatic-anticipation-settings' + ) + ->parameters( + TemplateParam::init('recipient_id', $recipientId), + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) + ); - $_resHandler = $this->responseHandler()->type(GetBalanceResponse::class); + $_resHandler = $this->responseHandler()->type(GetRecipientResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Creates a transfer for a recipient + * Gets an anticipation * - * @param string $recipientId Recipient Id - * @param CreateTransferRequest $request Transfer data - * @param string|null $idempotencyKey + * @param string $recipientId Recipient id + * @param string $anticipationId Anticipation id * - * @return GetTransferResponse Response from the API call + * @return GetAnticipationResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function createTransfer( - string $recipientId, - CreateTransferRequest $request, - ?string $idempotencyKey = null - ): GetTransferResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/recipients/{recipient_id}/transfers') - ->auth('global') + public function getAnticipation(string $recipientId, string $anticipationId): GetAnticipationResponse + { + $_reqBuilder = $this->requestBuilder( + RequestMethod::GET, + '/recipients/{recipient_id}/anticipations/{anticipation_id}' + ) ->parameters( TemplateParam::init('recipient_id', $recipientId), - BodyParam::init($request), - HeaderParam::init('idempotency-key', $idempotencyKey) + TemplateParam::init('anticipation_id', $anticipationId) ); - $_resHandler = $this->responseHandler()->type(GetTransferResponse::class); + $_resHandler = $this->responseHandler()->type(GetAnticipationResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Creates a new recipient - * - * @param CreateRecipientRequest $request Recipient data + * @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 createRecipient( - CreateRecipientRequest $request, + public function updateRecipientTransferSettings( + string $recipientId, + UpdateTransferSettingsRequest $request, ?string $idempotencyKey = null ): GetRecipientResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/recipients') - ->auth('global') - ->parameters(BodyParam::init($request), HeaderParam::init('idempotency-key', $idempotencyKey)); + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/recipients/{recipient_id}/transfer-settings') + ->parameters( + TemplateParam::init('recipient_id', $recipientId), + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) + ); $_resHandler = $this->responseHandler()->type(GetRecipientResponse::class); @@ -433,33 +394,51 @@ public function createRecipient( } /** - * Updates recipient metadata + * Retrieves a paginated list of anticipations from a recipient * * @param string $recipientId Recipient id - * @param UpdateAutomaticAnticipationSettingsRequest $request Metadata - * @param string|null $idempotencyKey + * @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 updateAutomaticAnticipationSettings( + public function getAnticipations( string $recipientId, - UpdateAutomaticAnticipationSettingsRequest $request, - ?string $idempotencyKey = null - ): GetRecipientResponse { - $_reqBuilder = $this->requestBuilder( - RequestMethod::PATCH, - '/recipients/{recipient_id}/automatic-anticipation-settings' - ) - ->auth('global') + ?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') ->parameters( TemplateParam::init('recipient_id', $recipientId), - BodyParam::init($request), - HeaderParam::init('idempotency-key', $idempotencyKey) + QueryParam::init('page', $page), + QueryParam::init('size', $size), + QueryParam::init('status', $status), + QueryParam::init('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); } @@ -476,7 +455,6 @@ public function updateAutomaticAnticipationSettings( public function getRecipient(string $recipientId): GetRecipientResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/{recipient_id}') - ->auth('global') ->parameters(TemplateParam::init('recipient_id', $recipientId)); $_resHandler = $this->responseHandler()->type(GetRecipientResponse::class); @@ -484,6 +462,25 @@ public function getRecipient(string $recipientId): GetRecipientResponse return $this->execute($_reqBuilder, $_resHandler); } + /** + * Get balance information for a recipient + * + * @param string $recipientId Recipient id + * + * @return GetBalanceResponse Response from the API call + * + * @throws ApiException Thrown if API call fails + */ + public function getBalance(string $recipientId): GetBalanceResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/{recipient_id}/balance') + ->parameters(TemplateParam::init('recipient_id', $recipientId)); + + $_resHandler = $this->responseHandler()->type(GetBalanceResponse::class); + + return $this->execute($_reqBuilder, $_resHandler); + } + /** * Gets a paginated list of transfers for the recipient * @@ -507,7 +504,6 @@ public function getWithdrawals( ?\DateTime $createdUntil = null ): ListWithdrawals { $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/{recipient_id}/withdrawals') - ->auth('global') ->parameters( TemplateParam::init('recipient_id', $recipientId), QueryParam::init('page', $page), @@ -525,66 +521,51 @@ public function getWithdrawals( } /** - * @param string $recipientId - * @param string $withdrawalId + * Creates a transfer for a recipient * - * @return GetWithdrawResponse Response from the API call + * @param string $recipientId Recipient Id + * @param CreateTransferRequest $request Transfer data + * @param string|null $idempotencyKey + * + * @return GetTransferResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getWithdrawById(string $recipientId, string $withdrawalId): GetWithdrawResponse - { - $_reqBuilder = $this->requestBuilder( - RequestMethod::GET, - '/recipients/{recipient_id}/withdrawals/{withdrawal_id}' - ) - ->auth('global') + public function createTransfer( + string $recipientId, + CreateTransferRequest $request, + ?string $idempotencyKey = null + ): GetTransferResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/recipients/{recipient_id}/transfers') ->parameters( TemplateParam::init('recipient_id', $recipientId), - TemplateParam::init('withdrawal_id', $withdrawalId) + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetWithdrawResponse::class); + $_resHandler = $this->responseHandler()->type(GetTransferResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Gets a paginated list of transfers for the recipient + * Creates a new recipient * - * @param string $recipientId Recipient id - * @param int|null $page Page number - * @param int|null $size Page size - * @param string|null $status Filter for transfer status - * @param \DateTime|null $createdSince Filter for start range of transfer creation date - * @param \DateTime|null $createdUntil Filter for end range of transfer creation date + * @param CreateRecipientRequest $request Recipient data + * @param string|null $idempotencyKey * - * @return ListTransferResponse Response from the API call + * @return GetRecipientResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getTransfers( - string $recipientId, - ?int $page = null, - ?int $size = null, - ?string $status = null, - ?\DateTime $createdSince = null, - ?\DateTime $createdUntil = null - ): ListTransferResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/{recipient_id}/transfers') - ->auth('global') - ->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']) - ); + public function createRecipient( + CreateRecipientRequest $request, + ?string $idempotencyKey = null + ): GetRecipientResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/recipients') + ->parameters(BodyParam::init($request), HeaderParam::init('idempotency-key', $idempotencyKey)); - $_resHandler = $this->responseHandler()->type(ListTransferResponse::class); + $_resHandler = $this->responseHandler()->type(GetRecipientResponse::class); return $this->execute($_reqBuilder, $_resHandler); } @@ -601,7 +582,6 @@ public function getTransfers( public function getRecipientByCode(string $code): GetRecipientResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/{code}') - ->auth('global') ->parameters(TemplateParam::init('code', $code)); $_resHandler = $this->responseHandler()->type(GetRecipientResponse::class); @@ -616,7 +596,7 @@ public function getRecipientByCode(string $code): GetRecipientResponse */ public function getDefaultRecipient(): GetRecipientResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/default')->auth('global'); + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/default'); $_resHandler = $this->responseHandler()->type(GetRecipientResponse::class); diff --git a/src/Controllers/SubscriptionsController.php b/src/Controllers/SubscriptionsController.php index 53d83c3..a0641f7 100644 --- a/src/Controllers/SubscriptionsController.php +++ b/src/Controllers/SubscriptionsController.php @@ -62,7 +62,6 @@ class SubscriptionsController extends BaseController public function renewSubscription(string $subscriptionId, ?string $idempotencyKey = null): GetPeriodResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/subscriptions/{subscription_id}/cycles') - ->auth('global') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), HeaderParam::init('idempotency-key', $idempotencyKey) @@ -74,307 +73,180 @@ public function renewSubscription(string $subscriptionId, ?string $idempotencyKe } /** - * Deletes a discount + * Updates the credit card from a subscription * * @param string $subscriptionId Subscription id - * @param string $discountId Discount Id + * @param UpdateSubscriptionCardRequest $request Request for updating a card * @param string|null $idempotencyKey * - * @return GetDiscountResponse Response from the API call + * @return GetSubscriptionResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function deleteDiscount( + public function updateSubscriptionCard( string $subscriptionId, - string $discountId, + UpdateSubscriptionCardRequest $request, ?string $idempotencyKey = null - ): GetDiscountResponse { - $_reqBuilder = $this->requestBuilder( - RequestMethod::DELETE, - '/subscriptions/{subscription_id}/discounts/{discount_id}' - ) - ->auth('global') + ): GetSubscriptionResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/subscriptions/{subscription_id}/card') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), - TemplateParam::init('discount_id', $discountId), + BodyParam::init($request), HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetDiscountResponse::class); + $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Gets all subscriptions - * - * @param int|null $page Page number - * @param int|null $size Page size - * @param string|null $code Filter for subscription's code - * @param string|null $billingType Filter for subscription's billing type - * @param string|null $customerId Filter for subscription's customer id - * @param string|null $planId Filter for subscription's plan id - * @param string|null $cardId Filter for subscription's card id - * @param string|null $status Filter for subscription's status - * @param \DateTime|null $nextBillingSince Filter for subscription's next billing date start - * range - * @param \DateTime|null $nextBillingUntil Filter for subscription's next billing date end range - * @param \DateTime|null $createdSince Filter for subscription's creation date start range - * @param \DateTime|null $createdUntil Filter for subscriptions creation date end range - * - * @return ListSubscriptionsResponse Response from the API call + * Deletes a usage * - * @throws ApiException Thrown if API call fails - */ - public function getSubscriptions( - ?int $page = null, - ?int $size = null, - ?string $code = null, - ?string $billingType = null, - ?string $customerId = null, - ?string $planId = null, - ?string $cardId = null, - ?string $status = null, - ?\DateTime $nextBillingSince = null, - ?\DateTime $nextBillingUntil = null, - ?\DateTime $createdSince = null, - ?\DateTime $createdUntil = null - ): ListSubscriptionsResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/subscriptions') - ->auth('global') - ->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']) - ); - - $_resHandler = $this->responseHandler()->type(ListSubscriptionsResponse::class); - - return $this->execute($_reqBuilder, $_resHandler); - } - - /** * @param string $subscriptionId The subscription id - * @param string $discountId - * - * @return GetDiscountResponse Response from the API call - * - * @throws ApiException Thrown if API call fails - */ - public function getDiscountById(string $subscriptionId, string $discountId): GetDiscountResponse - { - $_reqBuilder = $this->requestBuilder( - RequestMethod::GET, - '/subscriptions/{subscription_id}/discounts/{discountId}' - ) - ->auth('global') - ->parameters( - TemplateParam::init('subscription_id', $subscriptionId), - TemplateParam::init('discountId', $discountId) - ); - - $_resHandler = $this->responseHandler()->type(GetDiscountResponse::class); - - return $this->execute($_reqBuilder, $_resHandler); - } - - /** - * Creates a new subscription - * - * @param CreateSubscriptionRequest $body Request for creating a subscription + * @param string $itemId The subscription item id + * @param string $usageId The usage id * @param string|null $idempotencyKey * - * @return GetSubscriptionResponse Response from the API call + * @return GetUsageResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function createSubscription( - CreateSubscriptionRequest $body, + public function deleteUsage( + string $subscriptionId, + string $itemId, + string $usageId, ?string $idempotencyKey = null - ): GetSubscriptionResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/subscriptions') - ->auth('global') - ->parameters(BodyParam::init($body), HeaderParam::init('idempotency-key', $idempotencyKey)); - - $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::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 - { + ): GetUsageResponse { $_reqBuilder = $this->requestBuilder( - RequestMethod::GET, - '/subscriptions/{subscription_id}/increments/{increment_id}' + RequestMethod::DELETE, + '/subscriptions/{subscription_id}/items/{item_id}/usages/{usage_id}' ) - ->auth('global') ->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); } /** - * Updates the metadata from a subscription + * Creates a discount * - * @param string $subscriptionId The subscription id - * @param UpdateMetadataRequest $request Request for updating the subscrption metadata + * @param string $subscriptionId Subscription id + * @param CreateDiscountRequest $request Request for creating a discount * @param string|null $idempotencyKey * - * @return GetSubscriptionResponse Response from the API call + * @return GetDiscountResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateSubscriptionMetadata( + public function createDiscount( string $subscriptionId, - UpdateMetadataRequest $request, + CreateDiscountRequest $request, ?string $idempotencyKey = null - ): GetSubscriptionResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/Subscriptions/{subscription_id}/metadata') - ->auth('global') + ): GetDiscountResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/subscriptions/{subscription_id}/discounts') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), BodyParam::init($request), HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); + $_resHandler = $this->responseHandler()->type(GetDiscountResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Deletes a increment + * Create Usage * * @param string $subscriptionId Subscription id - * @param string $incrementId Increment id + * @param string $itemId Item id * @param string|null $idempotencyKey * - * @return GetIncrementResponse Response from the API call + * @return GetUsageResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function deleteIncrement( + public function createAnUsage( string $subscriptionId, - string $incrementId, + string $itemId, ?string $idempotencyKey = null - ): GetIncrementResponse { + ): GetUsageResponse { $_reqBuilder = $this->requestBuilder( - RequestMethod::DELETE, - '/subscriptions/{subscription_id}/increments/{increment_id}' + RequestMethod::POST, + '/subscriptions/{subscription_id}/items/{item_id}/usages' ) - ->auth('global') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), - TemplateParam::init('increment_id', $incrementId), + TemplateParam::init('item_id', $itemId), HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetIncrementResponse::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('global') - ->parameters(TemplateParam::init('subscription_id', $subscriptionId)); - - $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); + $_resHandler = $this->responseHandler()->type(GetUsageResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * @param string $subscriptionId - * @param UpdateCurrentCycleEndDateRequest $request Request for updating the end date of the - * current signature cycle + * @param string $subscriptionId Subscription Id + * @param UpdateCurrentCycleStatusRequest $request Request for updating the end date of the + * subscription current status * @param string|null $idempotencyKey * - * @return GetSubscriptionResponse Response from the API call + * @return void Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateLatestPeriodEndAt( + public function updateCurrentCycleStatus( string $subscriptionId, - UpdateCurrentCycleEndDateRequest $request, + UpdateCurrentCycleStatusRequest $request, ?string $idempotencyKey = null - ): GetSubscriptionResponse { - $_reqBuilder = $this->requestBuilder( - RequestMethod::PATCH, - '/subscriptions/{subscription_id}/periods/latest/end-at' - ) - ->auth('global') + ): void { + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/subscriptions/{subscription_id}/cycle-status') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), BodyParam::init($request), HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); - - return $this->execute($_reqBuilder, $_resHandler); + $this->execute($_reqBuilder); } /** - * @param string $subscriptionId Subscription Id - * @param UpdateCurrentCycleStatusRequest $request Request for updating the end date of the - * subscription current status + * Deletes a discount + * + * @param string $subscriptionId Subscription id + * @param string $discountId Discount Id * @param string|null $idempotencyKey * - * @return void Response from the API call + * @return GetDiscountResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateCurrentCycleStatus( + public function deleteDiscount( string $subscriptionId, - UpdateCurrentCycleStatusRequest $request, + string $discountId, ?string $idempotencyKey = null - ): void { - $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/subscriptions/{subscription_id}/cycle-status') - ->auth('global') + ): GetDiscountResponse { + $_reqBuilder = $this->requestBuilder( + RequestMethod::DELETE, + '/subscriptions/{subscription_id}/discounts/{discount_id}' + ) ->parameters( TemplateParam::init('subscription_id', $subscriptionId), - BodyParam::init($request), + TemplateParam::init('discount_id', $discountId), HeaderParam::init('idempotency-key', $idempotencyKey) ); - $this->execute($_reqBuilder); + $_resHandler = $this->responseHandler()->type(GetDiscountResponse::class); + + return $this->execute($_reqBuilder, $_resHandler); } /** @@ -406,7 +278,6 @@ public function getSubscriptionItems( ?string $createdUntil = null ): ListSubscriptionItemsResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/subscriptions/{subscription_id}/items') - ->auth('global') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), QueryParam::init('page', $page), @@ -425,9 +296,41 @@ public function getSubscriptionItems( } /** - * Get Subscription Item + * Updates the payment method from a subscription * - * @param string $subscriptionId Subscription Id + * @param string $subscriptionId Subscription id + * @param UpdateSubscriptionPaymentMethodRequest $request Request for updating the paymentmethod + * from a subscription + * @param string|null $idempotencyKey + * + * @return GetSubscriptionResponse Response from the API call + * + * @throws ApiException Thrown if API call fails + */ + public function updateSubscriptionPaymentMethod( + string $subscriptionId, + UpdateSubscriptionPaymentMethodRequest $request, + ?string $idempotencyKey = null + ): GetSubscriptionResponse { + $_reqBuilder = $this->requestBuilder( + RequestMethod::PATCH, + '/subscriptions/{subscription_id}/payment-method' + ) + ->parameters( + TemplateParam::init('subscription_id', $subscriptionId), + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) + ); + + $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); + + return $this->execute($_reqBuilder, $_resHandler); + } + + /** + * Get Subscription Item + * + * @param string $subscriptionId Subscription Id * @param string $itemId Item id * * @return GetSubscriptionItemResponse Response from the API call @@ -440,7 +343,6 @@ public function getSubscriptionItem(string $subscriptionId, string $itemId): Get RequestMethod::GET, '/subscriptions/{subscription_id}/items/{item_id}' ) - ->auth('global') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), TemplateParam::init('item_id', $itemId) @@ -452,25 +354,82 @@ public function getSubscriptionItem(string $subscriptionId, string $itemId): Get } /** - * @param string $subscriptionId - * @param UpdateSubscriptionAffiliationIdRequest $request Request for updating a subscription - * affiliation id + * Gets all subscriptions + * + * @param int|null $page Page number + * @param int|null $size Page size + * @param string|null $code Filter for subscription's code + * @param string|null $billingType Filter for subscription's billing type + * @param string|null $customerId Filter for subscription's customer id + * @param string|null $planId Filter for subscription's plan id + * @param string|null $cardId Filter for subscription's card id + * @param string|null $status Filter for subscription's status + * @param \DateTime|null $nextBillingSince Filter for subscription's next billing date start + * range + * @param \DateTime|null $nextBillingUntil Filter for subscription's next billing date end range + * @param \DateTime|null $createdSince Filter for subscription's creation date start range + * @param \DateTime|null $createdUntil Filter for subscriptions creation date end range + * + * @return ListSubscriptionsResponse Response from the API call + * + * @throws ApiException Thrown if API call fails + */ + public function getSubscriptions( + ?int $page = null, + ?int $size = null, + ?string $code = null, + ?string $billingType = null, + ?string $customerId = null, + ?string $planId = null, + ?string $cardId = null, + ?string $status = null, + ?\DateTime $nextBillingSince = null, + ?\DateTime $nextBillingUntil = null, + ?\DateTime $createdSince = null, + ?\DateTime $createdUntil = null + ): ListSubscriptionsResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/subscriptions') + ->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']) + ); + + $_resHandler = $this->responseHandler()->type(ListSubscriptionsResponse::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|null $idempotencyKey * * @return GetSubscriptionResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateSubscriptionAffiliationId( + public function cancelSubscription( string $subscriptionId, - UpdateSubscriptionAffiliationIdRequest $request, + ?CreateCancelSubscriptionRequest $request = null, ?string $idempotencyKey = null ): GetSubscriptionResponse { - $_reqBuilder = $this->requestBuilder( - RequestMethod::PATCH, - '/subscriptions/{subscription_id}/gateway-affiliation-id' - ) - ->auth('global') + $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/subscriptions/{subscription_id}') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), BodyParam::init($request), @@ -483,52 +442,55 @@ public function updateSubscriptionAffiliationId( } /** - * @param string $subscriptionId The subscription id - * @param int $page Page number - * @param int $size Page size + * Creates a increment * - * @return ListDiscountsResponse Response from the API call + * @param string $subscriptionId Subscription id + * @param CreateIncrementRequest $request Request for creating a increment + * @param string|null $idempotencyKey + * + * @return GetIncrementResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getDiscounts(string $subscriptionId, int $page, int $size): ListDiscountsResponse - { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/subscriptions/{subscription_id}/discounts/') - ->auth('global') + public function createIncrement( + string $subscriptionId, + CreateIncrementRequest $request, + ?string $idempotencyKey = null + ): GetIncrementResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/subscriptions/{subscription_id}/increments') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), - QueryParam::init('page', $page), - QueryParam::init('size', $size) + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(ListDiscountsResponse::class); + $_resHandler = $this->responseHandler()->type(GetIncrementResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Updates a subscription item + * Creates a usage * * @param string $subscriptionId Subscription Id * @param string $itemId Item id - * @param UpdateSubscriptionItemRequest $body Request for updating a subscription item + * @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 updateSubscriptionItem( + public function createUsage( string $subscriptionId, string $itemId, - UpdateSubscriptionItemRequest $body, + CreateUsageRequest $body, ?string $idempotencyKey = null - ): GetSubscriptionItemResponse { + ): GetUsageResponse { $_reqBuilder = $this->requestBuilder( - RequestMethod::PUT, - '/subscriptions/{subscription_id}/items/{item_id}' + RequestMethod::POST, + '/subscriptions/{subscription_id}/items/{item_id}/usages' ) - ->auth('global') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), TemplateParam::init('item_id', $itemId), @@ -536,109 +498,100 @@ public function updateSubscriptionItem( HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetSubscriptionItemResponse::class); + $_resHandler = $this->responseHandler()->type(GetUsageResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Creates a new Subscription item - * - * @param string $subscriptionId Subscription id - * @param CreateSubscriptionItemRequest $request Request for creating a subscription item - * @param string|null $idempotencyKey + * @param string $subscriptionId The subscription id + * @param string $discountId * - * @return GetSubscriptionItemResponse Response from the API call + * @return GetDiscountResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function createSubscriptionItem( - string $subscriptionId, - CreateSubscriptionItemRequest $request, - ?string $idempotencyKey = null - ): GetSubscriptionItemResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/subscriptions/{subscription_id}/items') - ->auth('global') + public function getDiscountById(string $subscriptionId, string $discountId): GetDiscountResponse + { + $_reqBuilder = $this->requestBuilder( + RequestMethod::GET, + '/subscriptions/{subscription_id}/discounts/{discountId}' + ) ->parameters( TemplateParam::init('subscription_id', $subscriptionId), - BodyParam::init($request), - HeaderParam::init('idempotency-key', $idempotencyKey) + TemplateParam::init('discountId', $discountId) ); - $_resHandler = $this->responseHandler()->type(GetSubscriptionItemResponse::class); + $_resHandler = $this->responseHandler()->type(GetDiscountResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Lists all usages from a subscription item + * Creates a new subscription * - * @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 CreateSubscriptionRequest $body Request for creating a subscription + * @param string|null $idempotencyKey * - * @return ListUsagesResponse Response from the API call + * @return GetSubscriptionResponse 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 createSubscription( + CreateSubscriptionRequest $body, + ?string $idempotencyKey = null + ): GetSubscriptionResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/subscriptions') + ->parameters(BodyParam::init($body), HeaderParam::init('idempotency-key', $idempotencyKey)); + + $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::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}/items/{item_id}/usages' + '/subscriptions/{subscription_id}/increments/{increment_id}' ) - ->auth('global') ->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('increment_id', $incrementId) ); - $_resHandler = $this->responseHandler()->type(ListUsagesResponse::class); + $_resHandler = $this->responseHandler()->type(GetIncrementResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * 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 $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 updateSubscriptionMiniumPrice( + public function updateSubscriptionAffiliationId( string $subscriptionId, - UpdateSubscriptionMinimumPriceRequest $request, + UpdateSubscriptionAffiliationIdRequest $request, ?string $idempotencyKey = null ): GetSubscriptionResponse { $_reqBuilder = $this->requestBuilder( RequestMethod::PATCH, - '/subscriptions/{subscription_id}/minimum_price' + '/subscriptions/{subscription_id}/gateway-affiliation-id' ) - ->auth('global') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), BodyParam::init($request), @@ -651,80 +604,128 @@ public function updateSubscriptionMiniumPrice( } /** + * Updates the metadata from a subscription + * * @param string $subscriptionId The subscription id - * @param string $cycleId + * @param UpdateMetadataRequest $request Request for updating the subscrption metadata + * @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 getSubscriptionCycleById(string $subscriptionId, string $cycleId): GetPeriodResponse - { + public function updateSubscriptionMetadata( + string $subscriptionId, + UpdateMetadataRequest $request, + ?string $idempotencyKey = null + ): GetSubscriptionResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/Subscriptions/{subscription_id}/metadata') + ->parameters( + TemplateParam::init('subscription_id', $subscriptionId), + BodyParam::init($request), + HeaderParam::init('idempotency-key', $idempotencyKey) + ); + + $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); + + return $this->execute($_reqBuilder, $_resHandler); + } + + /** + * Deletes a increment + * + * @param string $subscriptionId Subscription id + * @param string $incrementId Increment id + * @param string|null $idempotencyKey + * + * @return GetIncrementResponse Response from the API call + * + * @throws ApiException Thrown if API call fails + */ + public function deleteIncrement( + string $subscriptionId, + string $incrementId, + ?string $idempotencyKey = null + ): GetIncrementResponse { $_reqBuilder = $this->requestBuilder( - RequestMethod::GET, - '/subscriptions/{subscription_id}/cycles/{cycleId}' + RequestMethod::DELETE, + '/subscriptions/{subscription_id}/increments/{increment_id}' ) - ->auth('global') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), - TemplateParam::init('cycleId', $cycleId) + TemplateParam::init('increment_id', $incrementId), + HeaderParam::init('idempotency-key', $idempotencyKey) + ); + + $_resHandler = $this->responseHandler()->type(GetIncrementResponse::class); + + 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') + ->parameters( + TemplateParam::init('subscription_id', $subscriptionId), + QueryParam::init('page', $page), + QueryParam::init('size', $size) ); - $_resHandler = $this->responseHandler()->type(GetPeriodResponse::class); + $_resHandler = $this->responseHandler()->type(ListCyclesResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Create Usage - * - * @param string $subscriptionId Subscription id - * @param string $itemId Item id - * @param string|null $idempotencyKey + * @param string $subscriptionId The subscription id + * @param int $page Page number + * @param int $size Page size * - * @return GetUsageResponse Response from the API call + * @return ListDiscountsResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function createAnUsage( - string $subscriptionId, - string $itemId, - ?string $idempotencyKey = null - ): GetUsageResponse { - $_reqBuilder = $this->requestBuilder( - RequestMethod::POST, - '/subscriptions/{subscription_id}/items/{item_id}/usages' - ) - ->auth('global') + public function getDiscounts(string $subscriptionId, int $page, int $size): ListDiscountsResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/subscriptions/{subscription_id}/discounts/') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), - TemplateParam::init('item_id', $itemId), - HeaderParam::init('idempotency-key', $idempotencyKey) + QueryParam::init('page', $page), + QueryParam::init('size', $size) ); - $_resHandler = $this->responseHandler()->type(GetUsageResponse::class); + $_resHandler = $this->responseHandler()->type(ListDiscountsResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Cancels a subscription + * Updates the billing date from a subscription * - * @param string $subscriptionId Subscription id - * @param CreateCancelSubscriptionRequest|null $request Request for cancelling a subscription + * @param string $subscriptionId The subscription id + * @param UpdateSubscriptionBillingDateRequest $request Request for updating the subscription + * billing date * @param string|null $idempotencyKey * * @return GetSubscriptionResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function cancelSubscription( + public function updateSubscriptionBillingDate( string $subscriptionId, - ?CreateCancelSubscriptionRequest $request = null, + UpdateSubscriptionBillingDateRequest $request, ?string $idempotencyKey = null ): GetSubscriptionResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/subscriptions/{subscription_id}') - ->auth('global') + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/subscriptions/{subscription_id}/billing-date') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), BodyParam::init($request), @@ -756,7 +757,6 @@ public function deleteSubscriptionItem( RequestMethod::DELETE, '/subscriptions/{subscription_id}/items/{subscription_item_id}' ) - ->auth('global') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), TemplateParam::init('subscription_item_id', $subscriptionItemId), @@ -780,7 +780,6 @@ public function deleteSubscriptionItem( public function getIncrements(string $subscriptionId, ?int $page = null, ?int $size = null): ListIncrementsResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/subscriptions/{subscription_id}/increments/') - ->auth('global') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), QueryParam::init('page', $page), @@ -812,7 +811,6 @@ public function updateSubscriptionDueDays( RequestMethod::PATCH, '/subscriptions/{subscription_id}/boleto-due-days' ) - ->auth('global') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), BodyParam::init($request), @@ -825,23 +823,23 @@ public function updateSubscriptionDueDays( } /** - * Updates the credit card from a subscription + * Updates the start at date from a subscription * - * @param string $subscriptionId Subscription id - * @param UpdateSubscriptionCardRequest $request Request for updating a card + * @param string $subscriptionId The subscription id + * @param UpdateSubscriptionStartAtRequest $request Request for updating the subscription start + * date * @param string|null $idempotencyKey * * @return GetSubscriptionResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateSubscriptionCard( + public function updateSubscriptionStartAt( string $subscriptionId, - UpdateSubscriptionCardRequest $request, + UpdateSubscriptionStartAtRequest $request, ?string $idempotencyKey = null ): GetSubscriptionResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/subscriptions/{subscription_id}/card') - ->auth('global') + $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/subscriptions/{subscription_id}/start-at') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), BodyParam::init($request), @@ -854,96 +852,80 @@ public function updateSubscriptionCard( } /** - * Deletes a usage + * Updates a subscription item * - * @param string $subscriptionId The subscription id - * @param string $itemId The subscription item id - * @param string $usageId The usage id + * @param string $subscriptionId Subscription Id + * @param string $itemId Item id + * @param UpdateSubscriptionItemRequest $body Request for updating a subscription item * @param string|null $idempotencyKey * - * @return GetUsageResponse Response from the API call + * @return GetSubscriptionItemResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function deleteUsage( + public function updateSubscriptionItem( string $subscriptionId, string $itemId, - string $usageId, + UpdateSubscriptionItemRequest $body, ?string $idempotencyKey = null - ): GetUsageResponse { + ): GetSubscriptionItemResponse { $_reqBuilder = $this->requestBuilder( - RequestMethod::DELETE, - '/subscriptions/{subscription_id}/items/{item_id}/usages/{usage_id}' + RequestMethod::PUT, + '/subscriptions/{subscription_id}/items/{item_id}' ) - ->auth('global') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), TemplateParam::init('item_id', $itemId), - TemplateParam::init('usage_id', $usageId), + BodyParam::init($body), HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetUsageResponse::class); + $_resHandler = $this->responseHandler()->type(GetSubscriptionItemResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Creates a discount + * Creates a new Subscription item * * @param string $subscriptionId Subscription id - * @param CreateDiscountRequest $request Request for creating a discount + * @param CreateSubscriptionItemRequest $request Request for creating a subscription item * @param string|null $idempotencyKey * - * @return GetDiscountResponse Response from the API call + * @return GetSubscriptionItemResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function createDiscount( + public function createSubscriptionItem( string $subscriptionId, - CreateDiscountRequest $request, + CreateSubscriptionItemRequest $request, ?string $idempotencyKey = null - ): GetDiscountResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/subscriptions/{subscription_id}/discounts') - ->auth('global') + ): GetSubscriptionItemResponse { + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/subscriptions/{subscription_id}/items') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), BodyParam::init($request), HeaderParam::init('idempotency-key', $idempotencyKey) ); - $_resHandler = $this->responseHandler()->type(GetDiscountResponse::class); + $_resHandler = $this->responseHandler()->type(GetSubscriptionItemResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Updates the payment method from a subscription + * Gets a subscription * * @param string $subscriptionId Subscription id - * @param UpdateSubscriptionPaymentMethodRequest $request Request for updating the paymentmethod - * from a subscription - * @param string|null $idempotencyKey * * @return GetSubscriptionResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateSubscriptionPaymentMethod( - string $subscriptionId, - UpdateSubscriptionPaymentMethodRequest $request, - ?string $idempotencyKey = null - ): GetSubscriptionResponse { - $_reqBuilder = $this->requestBuilder( - RequestMethod::PATCH, - '/subscriptions/{subscription_id}/payment-method' - ) - ->auth('global') - ->parameters( - TemplateParam::init('subscription_id', $subscriptionId), - BodyParam::init($request), - HeaderParam::init('idempotency-key', $idempotencyKey) - ); + public function getSubscription(string $subscriptionId): GetSubscriptionResponse + { + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/subscriptions/{subscription_id}') + ->parameters(TemplateParam::init('subscription_id', $subscriptionId)); $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); @@ -951,112 +933,102 @@ public function updateSubscriptionPaymentMethod( } /** - * Creates a increment + * Lists all usages from a subscription item * - * @param string $subscriptionId Subscription id - * @param CreateIncrementRequest $request Request for creating a increment - * @param string|null $idempotencyKey + * @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 GetIncrementResponse Response from the API call + * @return ListUsagesResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function createIncrement( + public function getUsages( string $subscriptionId, - CreateIncrementRequest $request, - ?string $idempotencyKey = null - ): GetIncrementResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/subscriptions/{subscription_id}/increments') - ->auth('global') + string $itemId, + ?int $page = null, + ?int $size = null, + ?string $code = null, + ?string $group = null, + ?\DateTime $usedSince = null, + ?\DateTime $usedUntil = null + ): ListUsagesResponse { + $_reqBuilder = $this->requestBuilder( + RequestMethod::GET, + '/subscriptions/{subscription_id}/items/{item_id}/usages' + ) ->parameters( TemplateParam::init('subscription_id', $subscriptionId), - BodyParam::init($request), - HeaderParam::init('idempotency-key', $idempotencyKey) + TemplateParam::init('item_id', $itemId), + QueryParam::init('page', $page), + QueryParam::init('size', $size), + QueryParam::init('code', $code), + QueryParam::init('group', $group), + QueryParam::init('used_since', $usedSince)->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']), + QueryParam::init('used_until', $usedUntil)->serializeBy([DateTimeHelper::class, 'toRfc3339DateTime']) ); - $_resHandler = $this->responseHandler()->type(GetIncrementResponse::class); + $_resHandler = $this->responseHandler()->type(ListUsagesResponse::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 $subscriptionId + * @param UpdateCurrentCycleEndDateRequest $request Request for updating the end date of the + * current signature cycle * @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 createUsage( + public function updateLatestPeriodEndAt( string $subscriptionId, - string $itemId, - CreateUsageRequest $body, + UpdateCurrentCycleEndDateRequest $request, ?string $idempotencyKey = null - ): GetUsageResponse { + ): GetSubscriptionResponse { $_reqBuilder = $this->requestBuilder( - RequestMethod::POST, - '/subscriptions/{subscription_id}/items/{item_id}/usages' + RequestMethod::PATCH, + '/subscriptions/{subscription_id}/periods/latest/end-at' ) - ->auth('global') ->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(GetUsageResponse::class); - - 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('global') - ->parameters( - TemplateParam::init('subscription_id', $subscriptionId), - QueryParam::init('page', $page), - QueryParam::init('size', $size) - ); - - $_resHandler = $this->responseHandler()->type(ListCyclesResponse::class); + $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * Updates the billing date from a subscription + * Atualização do valor mínimo da assinatura * - * @param string $subscriptionId The subscription id - * @param UpdateSubscriptionBillingDateRequest $request Request for updating the subscription - * billing date + * @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 GetSubscriptionResponse Response from the API call * * @throws ApiException Thrown if API call fails */ - public function updateSubscriptionBillingDate( + public function updateSubscriptionMiniumPrice( string $subscriptionId, - UpdateSubscriptionBillingDateRequest $request, + UpdateSubscriptionMinimumPriceRequest $request, ?string $idempotencyKey = null ): GetSubscriptionResponse { - $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/subscriptions/{subscription_id}/billing-date') - ->auth('global') + $_reqBuilder = $this->requestBuilder( + RequestMethod::PATCH, + '/subscriptions/{subscription_id}/minimum_price' + ) ->parameters( TemplateParam::init('subscription_id', $subscriptionId), BodyParam::init($request), @@ -1069,31 +1041,25 @@ public function updateSubscriptionBillingDate( } /** - * Updates the start at date from a subscription - * * @param string $subscriptionId The subscription id - * @param UpdateSubscriptionStartAtRequest $request Request for updating the subscription start - * date - * @param string|null $idempotencyKey + * @param string $cycleId * - * @return GetSubscriptionResponse Response from the API call + * @return GetPeriodResponse 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') - ->auth('global') + public function getSubscriptionCycleById(string $subscriptionId, string $cycleId): GetPeriodResponse + { + $_reqBuilder = $this->requestBuilder( + RequestMethod::GET, + '/subscriptions/{subscription_id}/cycles/{cycleId}' + ) ->parameters( TemplateParam::init('subscription_id', $subscriptionId), - BodyParam::init($request), - HeaderParam::init('idempotency-key', $idempotencyKey) + TemplateParam::init('cycleId', $cycleId) ); - $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); + $_resHandler = $this->responseHandler()->type(GetPeriodResponse::class); return $this->execute($_reqBuilder, $_resHandler); } @@ -1112,7 +1078,6 @@ public function getUsageReport(string $subscriptionId, string $periodId): GetUsa RequestMethod::GET, '/subscriptions/{subscription_id}/periods/{period_id}/usages/report' ) - ->auth('global') ->parameters( TemplateParam::init('subscription_id', $subscriptionId), TemplateParam::init('period_id', $periodId) @@ -1136,7 +1101,6 @@ public function updateSplitSubscription( UpdateSubscriptionSplitRequest $request ): GetSubscriptionResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/subscriptions/{id}/split') - ->auth('global') ->parameters(TemplateParam::init('id', $id), BodyParam::init($request)); $_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class); diff --git a/src/Controllers/TransactionsController.php b/src/Controllers/TransactionsController.php index a4574ff..152a9c6 100644 --- a/src/Controllers/TransactionsController.php +++ b/src/Controllers/TransactionsController.php @@ -27,7 +27,6 @@ class TransactionsController extends BaseController public function getTransaction(string $transactionId): GetTransactionResponse { $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/transactions/{transaction_id}') - ->auth('global') ->parameters(TemplateParam::init('transaction_id', $transactionId)); $_resHandler = $this->responseHandler()->type(GetTransactionResponse::class); diff --git a/src/Controllers/TransfersController.php b/src/Controllers/TransfersController.php index 779edf3..e465ebb 100644 --- a/src/Controllers/TransfersController.php +++ b/src/Controllers/TransfersController.php @@ -21,33 +21,33 @@ class TransfersController extends BaseController { /** - * Gets all transfers + * @param string $transferId * - * @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 getTransferById(string $transferId): GetTransfer { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/transfers')->auth('global'); + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/transfers/{transfer_id}') + ->parameters(TemplateParam::init('transfer_id', $transferId)); - $_resHandler = $this->responseHandler()->type(ListTransfers::class); + $_resHandler = $this->responseHandler()->type(GetTransfer::class); return $this->execute($_reqBuilder, $_resHandler); } /** - * @param string $transferId + * @param CreateTransfer $request * * @return GetTransfer Response from the API call * * @throws ApiException Thrown if API call fails */ - public function getTransferById(string $transferId): GetTransfer + public function createTransfer(CreateTransfer $request): GetTransfer { - $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/transfers/{transfer_id}') - ->auth('global') - ->parameters(TemplateParam::init('transfer_id', $transferId)); + $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/transfers/recipients') + ->parameters(BodyParam::init($request)); $_resHandler = $this->responseHandler()->type(GetTransfer::class); @@ -55,19 +55,17 @@ 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('global') - ->parameters(BodyParam::init($request)); + $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/transfers'); - $_resHandler = $this->responseHandler()->type(GetTransfer::class); + $_resHandler = $this->responseHandler()->type(ListTransfers::class); return $this->execute($_reqBuilder, $_resHandler); } diff --git a/src/Models/Builders/CreateManagingPartnerRequestBuilder.php b/src/Models/Builders/CreateManagingPartnerRequestBuilder.php index 7f56a57..e5f6104 100644 --- a/src/Models/Builders/CreateManagingPartnerRequestBuilder.php +++ b/src/Models/Builders/CreateManagingPartnerRequestBuilder.php @@ -40,7 +40,7 @@ public static function init( string $document, string $motherName, string $birthdate, - string $monthlyIncome, + int $monthlyIncome, string $professionalOccupation, bool $selfDeclaredLegalRepresentative, CreateRegisterInformationAddressRequest $address, diff --git a/src/Models/Builders/CreateRegisterInformationCorporationRequestBuilder.php b/src/Models/Builders/CreateRegisterInformationCorporationRequestBuilder.php index cce760f..6be19df 100644 --- a/src/Models/Builders/CreateRegisterInformationCorporationRequestBuilder.php +++ b/src/Models/Builders/CreateRegisterInformationCorporationRequestBuilder.php @@ -41,7 +41,7 @@ public static function init( array $phoneNumbers, string $companyName, string $tradingName, - string $annualRevenue, + int $annualRevenue, array $managingPartners, CreateRegisterInformationAddressRequest $mainAddress ): self { diff --git a/src/Models/Builders/CreateRegisterInformationIndividualRequestBuilder.php b/src/Models/Builders/CreateRegisterInformationIndividualRequestBuilder.php index 580e2e8..3a0fc9a 100644 --- a/src/Models/Builders/CreateRegisterInformationIndividualRequestBuilder.php +++ b/src/Models/Builders/CreateRegisterInformationIndividualRequestBuilder.php @@ -41,7 +41,7 @@ public static function init( array $phoneNumbers, string $name, string $birthdate, - string $monthlyIncome, + int $monthlyIncome, string $professionalOccupation, CreateRegisterInformationAddressRequest $address ): self { diff --git a/src/Models/CreateManagingPartnerRequest.php b/src/Models/CreateManagingPartnerRequest.php index da2bc60..74a8aca 100644 --- a/src/Models/CreateManagingPartnerRequest.php +++ b/src/Models/CreateManagingPartnerRequest.php @@ -43,7 +43,7 @@ class CreateManagingPartnerRequest implements \JsonSerializable private $birthdate; /** - * @var string + * @var int */ private $monthlyIncome; @@ -73,7 +73,7 @@ class CreateManagingPartnerRequest implements \JsonSerializable * @param string $document * @param string $motherName * @param string $birthdate - * @param string $monthlyIncome + * @param int $monthlyIncome * @param string $professionalOccupation * @param bool $selfDeclaredLegalRepresentative * @param CreateRegisterInformationAddressRequest $address @@ -85,7 +85,7 @@ public function __construct( string $document, string $motherName, string $birthdate, - string $monthlyIncome, + int $monthlyIncome, string $professionalOccupation, bool $selfDeclaredLegalRepresentative, CreateRegisterInformationAddressRequest $address, @@ -201,7 +201,7 @@ public function setBirthdate(string $birthdate): void /** * Returns Monthly Income. */ - public function getMonthlyIncome(): string + public function getMonthlyIncome(): int { return $this->monthlyIncome; } @@ -212,7 +212,7 @@ public function getMonthlyIncome(): string * @required * @maps monthly_income */ - public function setMonthlyIncome(string $monthlyIncome): void + public function setMonthlyIncome(int $monthlyIncome): void { $this->monthlyIncome = $monthlyIncome; } diff --git a/src/Models/CreateRegisterInformationCorporationRequest.php b/src/Models/CreateRegisterInformationCorporationRequest.php index 045150e..1183907 100644 --- a/src/Models/CreateRegisterInformationCorporationRequest.php +++ b/src/Models/CreateRegisterInformationCorporationRequest.php @@ -25,7 +25,7 @@ class CreateRegisterInformationCorporationRequest extends CreateRegisterInformat private $tradingName; /** - * @var string + * @var int */ private $annualRevenue; @@ -61,7 +61,7 @@ class CreateRegisterInformationCorporationRequest extends CreateRegisterInformat * @param CreateRegisterInformationPhoneRequest[] $phoneNumbers * @param string $companyName * @param string $tradingName - * @param string $annualRevenue + * @param int $annualRevenue * @param CreateManagingPartnerRequest[] $managingPartners * @param CreateRegisterInformationAddressRequest $mainAddress */ @@ -72,7 +72,7 @@ public function __construct( array $phoneNumbers, string $companyName, string $tradingName, - string $annualRevenue, + int $annualRevenue, array $managingPartners, CreateRegisterInformationAddressRequest $mainAddress ) { @@ -125,7 +125,7 @@ public function setTradingName(string $tradingName): void /** * Returns Annual Revenue. */ - public function getAnnualRevenue(): string + public function getAnnualRevenue(): int { return $this->annualRevenue; } @@ -136,7 +136,7 @@ public function getAnnualRevenue(): string * @required * @maps annual_revenue */ - public function setAnnualRevenue(string $annualRevenue): void + public function setAnnualRevenue(int $annualRevenue): void { $this->annualRevenue = $annualRevenue; } diff --git a/src/Models/CreateRegisterInformationIndividualRequest.php b/src/Models/CreateRegisterInformationIndividualRequest.php index 4388a93..c99b854 100644 --- a/src/Models/CreateRegisterInformationIndividualRequest.php +++ b/src/Models/CreateRegisterInformationIndividualRequest.php @@ -30,7 +30,7 @@ class CreateRegisterInformationIndividualRequest extends CreateRegisterInformati private $birthdate; /** - * @var string + * @var int */ private $monthlyIncome; @@ -51,7 +51,7 @@ class CreateRegisterInformationIndividualRequest extends CreateRegisterInformati * @param CreateRegisterInformationPhoneRequest[] $phoneNumbers * @param string $name * @param string $birthdate - * @param string $monthlyIncome + * @param int $monthlyIncome * @param string $professionalOccupation * @param CreateRegisterInformationAddressRequest $address */ @@ -62,7 +62,7 @@ public function __construct( array $phoneNumbers, string $name, string $birthdate, - string $monthlyIncome, + int $monthlyIncome, string $professionalOccupation, CreateRegisterInformationAddressRequest $address ) { @@ -144,7 +144,7 @@ public function setBirthdate(string $birthdate): void /** * Returns Monthly Income. */ - public function getMonthlyIncome(): string + public function getMonthlyIncome(): int { return $this->monthlyIncome; } @@ -155,7 +155,7 @@ public function getMonthlyIncome(): string * @required * @maps monthly_income */ - public function setMonthlyIncome(string $monthlyIncome): void + public function setMonthlyIncome(int $monthlyIncome): void { $this->monthlyIncome = $monthlyIncome; } diff --git a/src/PagarmeApiSDKClient.php b/src/PagarmeApiSDKClient.php index d341998..7fa5f1a 100644 --- a/src/PagarmeApiSDKClient.php +++ b/src/PagarmeApiSDKClient.php @@ -57,8 +57,6 @@ class PagarmeApiSDKClient implements ConfigurationInterface private $balanceOperations; - private $basicAuthManager; - private $config; private $client; @@ -72,19 +70,14 @@ 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->client = ClientBuilder::init(new HttpClient(Configuration::init($this))) ->converter(new CompatibilityConverter()) ->jsonHelper(ApiHelper::getJsonHelper()) ->apiCallback($this->config['httpCallback'] ?? null) - ->userAgent('PagarmeApiSDK - PHP 6.8.4') + ->userAgent('PagarmeApiSDK - PHP 6.8.5') ->globalConfig($this->getGlobalConfiguration()) ->globalErrors($this->getGlobalErrors()) ->serverUrls(self::ENVIRONMENT_MAP[$this->getEnvironment()], Server::DEFAULT_) - ->authManagers(['global' => $this->basicAuthManager]) ->build(); } @@ -107,8 +100,6 @@ public function toBuilder(): PagarmeApiSDKClientBuilder ->httpMethodsToRetry($this->getHttpMethodsToRetry()) ->serviceRefererName($this->getServiceRefererName()) ->environment($this->getEnvironment()) - ->basicAuthUserName($this->basicAuthManager->getBasicAuthUserName()) - ->basicAuthPassword($this->basicAuthManager->getBasicAuthPassword()) ->httpCallback($this->config['httpCallback'] ?? null); } @@ -167,11 +158,6 @@ public function getEnvironment(): string return $this->config['environment'] ?? ConfigurationDefaults::ENVIRONMENT; } - public function getBasicAuthCredentials(): ?BasicAuthCredentials - { - return $this->basicAuthManager; - } - /** * Get the client configuration as an associative array * diff --git a/src/PagarmeApiSDKClientBuilder.php b/src/PagarmeApiSDKClientBuilder.php index 4aecc55..2576358 100644 --- a/src/PagarmeApiSDKClientBuilder.php +++ b/src/PagarmeApiSDKClientBuilder.php @@ -113,18 +113,6 @@ public function environment(string $environment): self return $this; } - public function basicAuthUserName(string $basicAuthUserName): self - { - $this->config['basicAuthUserName'] = $basicAuthUserName; - return $this; - } - - public function basicAuthPassword(string $basicAuthPassword): self - { - $this->config['basicAuthPassword'] = $basicAuthPassword; - return $this; - } - public function httpCallback($httpCallback): self { if (!$httpCallback instanceof CoreCallback) {