diff --git a/README.md b/README.md index 38afd5a..d0a579b 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ npm install ## Initialize the API Client -**_Note:_** Documentation for the client can be found [here.](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.13/doc/client.md) +**_Note:_** Documentation for the client can be found [here.](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.14/doc/client.md) The following parameters are configurable for the API Client: @@ -81,7 +81,7 @@ The following parameters are configurable for the API Client: | `timeout` | `number` | Timeout for API calls.
*Default*: `0` | | `httpClientOptions` | `Partial` | Stable configurable http client options. | | `unstableHttpClientOptions` | `any` | Unstable configurable http client options. | -| `basicAuthCredentials` | [`BasicAuthCredentials`](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.13/doc/auth/basic-authentication.md) | The credential object for basicAuth | +| `basicAuthCredentials` | [`BasicAuthCredentials`](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.14/doc/auth/basic-authentication.md) | The credential object for basicAuth | ### HttpClientOptions @@ -121,7 +121,7 @@ const client = new Client({ This API uses the following authentication schemes. -* [`httpBasic (Basic Authentication)`](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.13/doc/auth/basic-authentication.md) +* [`httpBasic (Basic Authentication)`](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.14/doc/auth/basic-authentication.md) ## API Errors @@ -129,30 +129,30 @@ Here is the list of errors that the API might throw. | HTTP Status Code | Error Description | Exception Class | | --- | --- | --- | -| 400 | Invalid request | [`CustomError`](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.13/doc/models/custom-error.md) | -| 401 | Invalid API key | [`CustomError`](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.13/doc/models/custom-error.md) | -| 404 | An informed resource was not found | [`CustomError`](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.13/doc/models/custom-error.md) | -| 412 | Business validation error | [`CustomError`](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.13/doc/models/custom-error.md) | -| 422 | Contract validation error | [`CustomError`](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.13/doc/models/custom-error.md) | -| 500 | Internal server error | [`CustomError`](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.13/doc/models/custom-error.md) | +| 400 | Invalid request | [`CustomError`](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.14/doc/models/custom-error.md) | +| 401 | Invalid API key | [`CustomError`](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.14/doc/models/custom-error.md) | +| 404 | An informed resource was not found | [`CustomError`](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.14/doc/models/custom-error.md) | +| 412 | Business validation error | [`CustomError`](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.14/doc/models/custom-error.md) | +| 422 | Contract validation error | [`CustomError`](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.14/doc/models/custom-error.md) | +| 500 | Internal server error | [`CustomError`](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.14/doc/models/custom-error.md) | ## List of APIs -* [Subscriptions](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.13/doc/controllers/subscriptions.md) -* [Orders](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.13/doc/controllers/orders.md) -* [Plans](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.13/doc/controllers/plans.md) -* [Invoices](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.13/doc/controllers/invoices.md) -* [Customers](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.13/doc/controllers/customers.md) -* [Charges](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.13/doc/controllers/charges.md) -* [Recipients](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.13/doc/controllers/recipients.md) -* [Tokens](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.13/doc/controllers/tokens.md) -* [Transactions](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.13/doc/controllers/transactions.md) -* [Transfers](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.13/doc/controllers/transfers.md) -* [Payables](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.13/doc/controllers/payables.md) -* [Balance Operations](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.13/doc/controllers/balance-operations.md) +* [Subscriptions](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.14/doc/controllers/subscriptions.md) +* [Orders](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.14/doc/controllers/orders.md) +* [Plans](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.14/doc/controllers/plans.md) +* [Invoices](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.14/doc/controllers/invoices.md) +* [Customers](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.14/doc/controllers/customers.md) +* [Charges](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.14/doc/controllers/charges.md) +* [Recipients](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.14/doc/controllers/recipients.md) +* [Tokens](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.14/doc/controllers/tokens.md) +* [Transactions](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.14/doc/controllers/transactions.md) +* [Transfers](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.14/doc/controllers/transfers.md) +* [Payables](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.14/doc/controllers/payables.md) +* [Balance Operations](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.14/doc/controllers/balance-operations.md) ## Classes Documentation -* [ApiResponse](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.13/doc/api-response.md) -* [ApiError](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.13/doc/api-error.md) +* [ApiResponse](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.14/doc/api-response.md) +* [ApiError](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.14/doc/api-error.md) diff --git a/doc/controllers/balance-operations.md b/doc/controllers/balance-operations.md index 1cf12b7..b3d1a6f 100644 --- a/doc/controllers/balance-operations.md +++ b/doc/controllers/balance-operations.md @@ -10,39 +10,35 @@ const balanceOperationsController = new BalanceOperationsController(client); ## Methods -* [Get Balance Operations](../../doc/controllers/balance-operations.md#get-balance-operations) * [Get Balance Operation by Id](../../doc/controllers/balance-operations.md#get-balance-operation-by-id) +* [Get Balance Operations](../../doc/controllers/balance-operations.md#get-balance-operations) -# Get Balance Operations +# Get Balance Operation by Id ```ts -async getBalanceOperations( status?: string, - createdSince?: string, - createdUntil?: string, - recipientId?: string, -requestOptions?: RequestOptions): Promise> +async getBalanceOperationById( id: bigint, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `status` | `string \| undefined` | Query, Optional | - | -| `createdSince` | `string \| undefined` | Query, Optional | - | -| `createdUntil` | `string \| undefined` | Query, Optional | - | -| `recipientId` | `string \| undefined` | Query, Optional | - | +| `id` | `bigint` | Template, Required | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`ListBalanceOperationResponse`](../../doc/models/list-balance-operation-response.md) +[`GetBalanceOperationResponse`](../../doc/models/get-balance-operation-response.md) ## Example Usage ```ts +const id = BigInt(112); + try { - const { result, ...httpResponse } = await balanceOperationsController.getBalanceOperations(); + const { result, ...httpResponse } = await balanceOperationsController.getBalanceOperationById(id); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -54,31 +50,35 @@ try { ``` -# Get Balance Operation by Id +# Get Balance Operations ```ts -async getBalanceOperationById( id: bigint, -requestOptions?: RequestOptions): Promise> +async getBalanceOperations( status?: string, + createdSince?: string, + createdUntil?: string, + recipientId?: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `id` | `bigint` | Template, Required | - | +| `status` | `string \| undefined` | Query, Optional | - | +| `createdSince` | `string \| undefined` | Query, Optional | - | +| `createdUntil` | `string \| undefined` | Query, Optional | - | +| `recipientId` | `string \| undefined` | Query, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetBalanceOperationResponse`](../../doc/models/get-balance-operation-response.md) +[`ListBalanceOperationResponse`](../../doc/models/list-balance-operation-response.md) ## Example Usage ```ts -const id = BigInt(112); - try { - const { result, ...httpResponse } = await balanceOperationsController.getBalanceOperationById(id); + const { result, ...httpResponse } = await balanceOperationsController.getBalanceOperations(); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { diff --git a/doc/controllers/charges.md b/doc/controllers/charges.md index dbffb4d..a77a6be 100644 --- a/doc/controllers/charges.md +++ b/doc/controllers/charges.md @@ -11,18 +11,18 @@ const chargesController = new ChargesController(client); ## Methods * [Update Charge Metadata](../../doc/controllers/charges.md#update-charge-metadata) -* [Update Charge Payment Method](../../doc/controllers/charges.md#update-charge-payment-method) -* [Get Charge Transactions](../../doc/controllers/charges.md#get-charge-transactions) -* [Update Charge Due Date](../../doc/controllers/charges.md#update-charge-due-date) -* [Get Charges](../../doc/controllers/charges.md#get-charges) * [Capture Charge](../../doc/controllers/charges.md#capture-charge) -* [Update Charge Card](../../doc/controllers/charges.md#update-charge-card) * [Get Charge](../../doc/controllers/charges.md#get-charge) +* [Confirm Payment](../../doc/controllers/charges.md#confirm-payment) +* [Get Charge Transactions](../../doc/controllers/charges.md#get-charge-transactions) +* [Update Charge Card](../../doc/controllers/charges.md#update-charge-card) +* [Create Charge](../../doc/controllers/charges.md#create-charge) +* [Update Charge Payment Method](../../doc/controllers/charges.md#update-charge-payment-method) +* [Update Charge Due Date](../../doc/controllers/charges.md#update-charge-due-date) * [Get Charges Summary](../../doc/controllers/charges.md#get-charges-summary) * [Retry Charge](../../doc/controllers/charges.md#retry-charge) +* [Get Charges](../../doc/controllers/charges.md#get-charges) * [Cancel Charge](../../doc/controllers/charges.md#cancel-charge) -* [Create Charge](../../doc/controllers/charges.md#create-charge) -* [Confirm Payment](../../doc/controllers/charges.md#confirm-payment) # Update Charge Metadata @@ -76,13 +76,13 @@ try { ``` -# Update Charge Payment Method +# Capture Charge -Updates a charge's payment method +Captures a charge ```ts -async updateChargePaymentMethod( chargeId: string, - request: UpdateChargePaymentMethodRequest, +async captureCharge( chargeId: string, + request?: CreateCaptureChargeRequest, idempotencyKey?: string, requestOptions?: RequestOptions): Promise> ``` @@ -92,7 +92,7 @@ requestOptions?: RequestOptions): Promise> | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `chargeId` | `string` | Template, Required | Charge id | -| `request` | [`UpdateChargePaymentMethodRequest`](../../doc/models/update-charge-payment-method-request.md) | Body, Required | Request for updating the payment method from a charge | +| `request` | [`CreateCaptureChargeRequest \| undefined`](../../doc/models/create-capture-charge-request.md) | Body, Optional | Request for capturing a charge | | `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | @@ -105,56 +105,8 @@ requestOptions?: RequestOptions): Promise> ```ts const chargeId = 'charge_id8'; -const request: UpdateChargePaymentMethodRequest = { - updateSubscription: false, - paymentMethod: 'payment_method4', - creditCard: { - installments: 1, - capture: true, - recurrencyCycle: '"first" or "subsequent"', - }, - debitCard: {}, - boleto: { - retries: 226, - instructions: 'instructions2', - billingAddress: { - street: 'street8', - number: 'number4', - zipCode: 'zip_code2', - neighborhood: 'neighborhood4', - city: 'city2', - state: 'state6', - country: 'country2', - complement: 'complement6', - line1: 'line_18', - line2: 'line_26', - }, - documentNumber: 'document_number6', - statementDescriptor: 'statement_descriptor0', - }, - voucher: { - recurrencyCycle: '"first" or "subsequent"', - }, - cash: { - description: 'description0', - confirm: false, - }, - bankTransfer: { - bank: 'bank0', - retries: 236, - }, - privateLabel: { - installments: 1, - capture: true, - recurrencyCycle: '"first" or "subsequent"', - }, -}; - try { - const { result, ...httpResponse } = await chargesController.updateChargePaymentMethod( - chargeId, - request -); + const { result, ...httpResponse } = await chargesController.captureCharge(chargeId); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -166,27 +118,25 @@ try { ``` -# Get Charge Transactions +# Get Charge + +Get a charge from its id ```ts -async getChargeTransactions( chargeId: string, - page?: number, - size?: number, -requestOptions?: RequestOptions): Promise> +async getCharge( chargeId: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `chargeId` | `string` | Template, Required | Charge Id | -| `page` | `number \| undefined` | Query, Optional | Page number | -| `size` | `number \| undefined` | Query, Optional | Page size | +| `chargeId` | `string` | Template, Required | Charge id | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`ListChargeTransactionsResponse`](../../doc/models/list-charge-transactions-response.md) +[`GetChargeResponse`](../../doc/models/get-charge-response.md) ## Example Usage @@ -194,7 +144,7 @@ requestOptions?: RequestOptions): Promise> ``` @@ -221,8 +169,8 @@ requestOptions?: RequestOptions): Promise> | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `chargeId` | `string` | Template, Required | Charge Id | -| `request` | [`UpdateChargeDueDateRequest`](../../doc/models/update-charge-due-date-request.md) | Body, Required | Request for updating the due date | +| `chargeId` | `string` | Template, Required | - | +| `request` | [`CreateConfirmPaymentRequest \| undefined`](../../doc/models/create-confirm-payment-request.md) | Body, Optional | Request for confirm payment | | `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | @@ -235,13 +183,8 @@ requestOptions?: RequestOptions): Promise> ```ts const chargeId = 'charge_id8'; -const request: UpdateChargeDueDateRequest = {}; - try { - const { result, ...httpResponse } = await chargesController.updateChargeDueDate( - chargeId, - request -); + const { result, ...httpResponse } = await chargesController.confirmPayment(chargeId); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -253,47 +196,35 @@ try { ``` -# Get Charges - -Lists all charges +# Get Charge Transactions ```ts -async getCharges( page?: number, +async getChargeTransactions( chargeId: string, + page?: number, size?: number, - code?: string, - status?: string, - paymentMethod?: string, - customerId?: string, - orderId?: string, - createdSince?: string, - createdUntil?: string, -requestOptions?: RequestOptions): Promise> +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | +| `chargeId` | `string` | Template, Required | Charge Id | | `page` | `number \| undefined` | Query, Optional | Page number | | `size` | `number \| undefined` | Query, Optional | Page size | -| `code` | `string \| undefined` | Query, Optional | Filter for charge's code | -| `status` | `string \| undefined` | Query, Optional | Filter for charge's status | -| `paymentMethod` | `string \| undefined` | Query, Optional | Filter for charge's payment method | -| `customerId` | `string \| undefined` | Query, Optional | Filter for charge's customer id | -| `orderId` | `string \| undefined` | Query, Optional | Filter for charge's order id | -| `createdSince` | `string \| undefined` | Query, Optional | Filter for the beginning of the range for charge's creation | -| `createdUntil` | `string \| undefined` | Query, Optional | Filter for the end of the range for charge's creation | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`ListChargesResponse`](../../doc/models/list-charges-response.md) +[`ListChargeTransactionsResponse`](../../doc/models/list-charge-transactions-response.md) ## Example Usage ```ts +const chargeId = 'charge_id8'; + try { - const { result, ...httpResponse } = await chargesController.getCharges(); + const { result, ...httpResponse } = await chargesController.getChargeTransactions(chargeId); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -305,13 +236,13 @@ try { ``` -# Capture Charge +# Update Charge Card -Captures a charge +Updates the card from a charge ```ts -async captureCharge( chargeId: string, - request?: CreateCaptureChargeRequest, +async updateChargeCard( chargeId: string, + request: UpdateChargeCardRequest, idempotencyKey?: string, requestOptions?: RequestOptions): Promise> ``` @@ -321,7 +252,7 @@ requestOptions?: RequestOptions): Promise> | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `chargeId` | `string` | Template, Required | Charge id | -| `request` | [`CreateCaptureChargeRequest \| undefined`](../../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 \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | @@ -334,8 +265,20 @@ requestOptions?: RequestOptions): Promise> ```ts const chargeId = 'charge_id8'; +const request: UpdateChargeCardRequest = { + updateSubscription: false, + cardId: 'card_id2', + card: { + type: 'credit', + }, + recurrence: false, +}; + try { - const { result, ...httpResponse } = await chargesController.captureCharge(chargeId); + const { result, ...httpResponse } = await chargesController.updateChargeCard( + chargeId, + request +); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -347,13 +290,12 @@ try { ``` -# Update Charge Card +# Create Charge -Updates the card from a charge +Creates a new charge ```ts -async updateChargeCard( chargeId: string, - request: UpdateChargeCardRequest, +async createCharge( request: CreateChargeRequest, idempotencyKey?: string, requestOptions?: RequestOptions): Promise> ``` @@ -362,8 +304,7 @@ requestOptions?: RequestOptions): Promise> | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `chargeId` | `string` | Template, Required | Charge id | -| `request` | [`UpdateChargeCardRequest`](../../doc/models/update-charge-card-request.md) | Body, Required | Request for updating a charge's card | +| `request` | [`CreateChargeRequest`](../../doc/models/create-charge-request.md) | Body, Required | Request for creating a charge | | `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | @@ -374,22 +315,16 @@ requestOptions?: RequestOptions): Promise> ## Example Usage ```ts -const chargeId = 'charge_id8'; - -const request: UpdateChargeCardRequest = { - updateSubscription: false, - cardId: 'card_id2', - card: { - type: 'credit', +const request: CreateChargeRequest = { + amount: 242, + payment: { + paymentMethod: 'payment_method4', }, - recurrence: false, + orderId: 'order_id0', }; try { - const { result, ...httpResponse } = await chargesController.updateChargeCard( - chargeId, - request -); + const { result, ...httpResponse } = await chargesController.createCharge(request); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -401,12 +336,14 @@ try { ``` -# Get Charge +# Update Charge Payment Method -Get a charge from its id +Updates a charge's payment method ```ts -async getCharge( chargeId: string, +async updateChargePaymentMethod( chargeId: string, + request: UpdateChargePaymentMethodRequest, + idempotencyKey?: string, requestOptions?: RequestOptions): Promise> ``` @@ -415,6 +352,8 @@ requestOptions?: RequestOptions): Promise> | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `chargeId` | `string` | Template, Required | Charge id | +| `request` | [`UpdateChargePaymentMethodRequest`](../../doc/models/update-charge-payment-method-request.md) | Body, Required | Request for updating the payment method from a charge | +| `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type @@ -426,8 +365,56 @@ requestOptions?: RequestOptions): Promise> ```ts const chargeId = 'charge_id8'; +const request: UpdateChargePaymentMethodRequest = { + updateSubscription: false, + paymentMethod: 'payment_method4', + creditCard: { + installments: 1, + capture: true, + recurrencyCycle: '"first" or "subsequent"', + }, + debitCard: {}, + boleto: { + retries: 226, + instructions: 'instructions2', + billingAddress: { + street: 'street8', + number: 'number4', + zipCode: 'zip_code2', + neighborhood: 'neighborhood4', + city: 'city2', + state: 'state6', + country: 'country2', + complement: 'complement6', + line1: 'line_18', + line2: 'line_26', + }, + documentNumber: 'document_number6', + statementDescriptor: 'statement_descriptor0', + }, + voucher: { + recurrencyCycle: '"first" or "subsequent"', + }, + cash: { + description: 'description0', + confirm: false, + }, + bankTransfer: { + bank: 'bank0', + retries: 236, + }, + privateLabel: { + installments: 1, + capture: true, + recurrencyCycle: '"first" or "subsequent"', + }, +}; + try { - const { result, ...httpResponse } = await chargesController.getCharge(chargeId); + const { result, ...httpResponse } = await chargesController.updateChargePaymentMethod( + chargeId, + request +); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -439,35 +426,42 @@ try { ``` -# Get Charges Summary +# Update Charge Due Date + +Updates the due date from a charge ```ts -async getChargesSummary( status: string, - createdSince?: string, - createdUntil?: string, -requestOptions?: RequestOptions): Promise> +async updateChargeDueDate( chargeId: string, + request: UpdateChargeDueDateRequest, + idempotencyKey?: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `status` | `string` | Query, Required | - | -| `createdSince` | `string \| undefined` | Query, Optional | - | -| `createdUntil` | `string \| undefined` | 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 \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetChargesSummaryResponse`](../../doc/models/get-charges-summary-response.md) +[`GetChargeResponse`](../../doc/models/get-charge-response.md) ## Example Usage ```ts -const status = 'status8'; +const chargeId = 'charge_id8'; + +const request: UpdateChargeDueDateRequest = {}; try { - const { result, ...httpResponse } = await chargesController.getChargesSummary(status); + const { result, ...httpResponse } = await chargesController.updateChargeDueDate( + chargeId, + request +); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -479,35 +473,35 @@ try { ``` -# Retry Charge - -Retries a charge +# Get Charges Summary ```ts -async retryCharge( chargeId: string, - idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> +async getChargesSummary( status: string, + createdSince?: string, + createdUntil?: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `chargeId` | `string` | Template, Required | Charge id | -| `idempotencyKey` | `string \| undefined` | Header, Optional | - | +| `status` | `string` | Query, Required | - | +| `createdSince` | `string \| undefined` | Query, Optional | - | +| `createdUntil` | `string \| undefined` | Query, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetChargeResponse`](../../doc/models/get-charge-response.md) +[`GetChargesSummaryResponse`](../../doc/models/get-charges-summary-response.md) ## Example Usage ```ts -const chargeId = 'charge_id8'; +const status = 'status8'; try { - const { result, ...httpResponse } = await chargesController.retryCharge(chargeId); + const { result, ...httpResponse } = await chargesController.getChargesSummary(status); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -519,13 +513,12 @@ try { ``` -# Cancel Charge +# Retry Charge -Cancel a charge +Retries a charge ```ts -async cancelCharge( chargeId: string, - request?: CreateCancelChargeRequest, +async retryCharge( chargeId: string, idempotencyKey?: string, requestOptions?: RequestOptions): Promise> ``` @@ -535,7 +528,6 @@ requestOptions?: RequestOptions): Promise> | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `chargeId` | `string` | Template, Required | Charge id | -| `request` | [`CreateCancelChargeRequest \| undefined`](../../doc/models/create-cancel-charge-request.md) | Body, Optional | Request for cancelling a charge | | `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | @@ -549,7 +541,7 @@ requestOptions?: RequestOptions): Promise> const chargeId = 'charge_id8'; try { - const { result, ...httpResponse } = await chargesController.cancelCharge(chargeId); + const { result, ...httpResponse } = await chargesController.retryCharge(chargeId); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -561,41 +553,47 @@ try { ``` -# Create Charge +# Get Charges -Creates a new charge +Lists all charges ```ts -async createCharge( request: CreateChargeRequest, - idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> +async getCharges( page?: number, + size?: number, + code?: string, + status?: string, + paymentMethod?: string, + customerId?: string, + orderId?: string, + createdSince?: string, + createdUntil?: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `request` | [`CreateChargeRequest`](../../doc/models/create-charge-request.md) | Body, Required | Request for creating a charge | -| `idempotencyKey` | `string \| undefined` | Header, Optional | - | +| `page` | `number \| undefined` | Query, Optional | Page number | +| `size` | `number \| undefined` | Query, Optional | Page size | +| `code` | `string \| undefined` | Query, Optional | Filter for charge's code | +| `status` | `string \| undefined` | Query, Optional | Filter for charge's status | +| `paymentMethod` | `string \| undefined` | Query, Optional | Filter for charge's payment method | +| `customerId` | `string \| undefined` | Query, Optional | Filter for charge's customer id | +| `orderId` | `string \| undefined` | Query, Optional | Filter for charge's order id | +| `createdSince` | `string \| undefined` | Query, Optional | Filter for the beginning of the range for charge's creation | +| `createdUntil` | `string \| undefined` | Query, Optional | Filter for the end of the range for charge's creation | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetChargeResponse`](../../doc/models/get-charge-response.md) +[`ListChargesResponse`](../../doc/models/list-charges-response.md) ## Example Usage ```ts -const request: CreateChargeRequest = { - amount: 242, - payment: { - paymentMethod: 'payment_method4', - }, - orderId: 'order_id0', -}; - try { - const { result, ...httpResponse } = await chargesController.createCharge(request); + const { result, ...httpResponse } = await chargesController.getCharges(); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -607,11 +605,13 @@ try { ``` -# Confirm Payment +# Cancel Charge + +Cancel a charge ```ts -async confirmPayment( chargeId: string, - request?: CreateConfirmPaymentRequest, +async cancelCharge( chargeId: string, + request?: CreateCancelChargeRequest, idempotencyKey?: string, requestOptions?: RequestOptions): Promise> ``` @@ -620,8 +620,8 @@ requestOptions?: RequestOptions): Promise> | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `chargeId` | `string` | Template, Required | - | -| `request` | [`CreateConfirmPaymentRequest \| undefined`](../../doc/models/create-confirm-payment-request.md) | Body, Optional | Request for confirm payment | +| `chargeId` | `string` | Template, Required | Charge id | +| `request` | [`CreateCancelChargeRequest \| undefined`](../../doc/models/create-cancel-charge-request.md) | Body, Optional | Request for cancelling a charge | | `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | @@ -635,7 +635,7 @@ requestOptions?: RequestOptions): Promise> const chargeId = 'charge_id8'; try { - const { result, ...httpResponse } = await chargesController.confirmPayment(chargeId); + const { result, ...httpResponse } = await chargesController.cancelCharge(chargeId); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { diff --git a/doc/controllers/customers.md b/doc/controllers/customers.md index e1bbb14..0e21510 100644 --- a/doc/controllers/customers.md +++ b/doc/controllers/customers.md @@ -10,39 +10,38 @@ const customersController = new CustomersController(client); ## Methods +* [Create Address](../../doc/controllers/customers.md#create-address) * [Update Card](../../doc/controllers/customers.md#update-card) -* [Update Address](../../doc/controllers/customers.md#update-address) * [Delete Access Token](../../doc/controllers/customers.md#delete-access-token) * [Create Customer](../../doc/controllers/customers.md#create-customer) -* [Create Address](../../doc/controllers/customers.md#create-address) * [Delete Access Tokens](../../doc/controllers/customers.md#delete-access-tokens) +* [Update Address](../../doc/controllers/customers.md#update-address) * [Get Address](../../doc/controllers/customers.md#get-address) * [Delete Address](../../doc/controllers/customers.md#delete-address) -* [Create Card](../../doc/controllers/customers.md#create-card) * [Get Customers](../../doc/controllers/customers.md#get-customers) +* [Get Access Tokens](../../doc/controllers/customers.md#get-access-tokens) +* [Delete Card](../../doc/controllers/customers.md#delete-card) +* [Get Card](../../doc/controllers/customers.md#get-card) +* [Create Card](../../doc/controllers/customers.md#create-card) +* [Get Access Token](../../doc/controllers/customers.md#get-access-token) +* [Get Addresses](../../doc/controllers/customers.md#get-addresses) * [Update Customer](../../doc/controllers/customers.md#update-customer) * [Create Access Token](../../doc/controllers/customers.md#create-access-token) -* [Get Access Tokens](../../doc/controllers/customers.md#get-access-tokens) * [Get Cards](../../doc/controllers/customers.md#get-cards) * [Renew Card](../../doc/controllers/customers.md#renew-card) -* [Get Access Token](../../doc/controllers/customers.md#get-access-token) * [Update Customer Metadata](../../doc/controllers/customers.md#update-customer-metadata) -* [Delete Card](../../doc/controllers/customers.md#delete-card) -* [Get Addresses](../../doc/controllers/customers.md#get-addresses) * [Get Customer](../../doc/controllers/customers.md#get-customer) -* [Get Card](../../doc/controllers/customers.md#get-card) -# Update Card +# Create Address -Updates a card +Creates a new address for a customer ```ts -async updateCard( customerId: string, - cardId: string, - request: UpdateCardRequest, +async createAddress( customerId: string, + request: CreateAddressRequest, idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> +requestOptions?: RequestOptions): Promise> ``` ## Parameters @@ -50,48 +49,35 @@ requestOptions?: RequestOptions): Promise> | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `customerId` | `string` | Template, Required | Customer Id | -| `cardId` | `string` | Template, Required | Card id | -| `request` | [`UpdateCardRequest`](../../doc/models/update-card-request.md) | Body, Required | Request for updating a card | +| `request` | [`CreateAddressRequest`](../../doc/models/create-address-request.md) | Body, Required | Request for creating an address | | `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetCardResponse`](../../doc/models/get-card-response.md) +[`GetAddressResponse`](../../doc/models/get-address-response.md) ## Example Usage ```ts const customerId = 'customer_id8'; -const cardId = 'card_id4'; - -const request: UpdateCardRequest = { - holderName: 'holder_name2', - expMonth: 10, - expYear: 30, - billingAddress: { - street: 'street8', - number: 'number4', - zipCode: 'zip_code2', - neighborhood: 'neighborhood4', - city: 'city2', - state: 'state6', - country: 'country2', - complement: 'complement6', - line1: 'line_18', - line2: 'line_26', - }, - metadata: { - 'key0': 'metadata3' - }, - label: 'label6', +const request: CreateAddressRequest = { + street: 'street6', + number: 'number4', + zipCode: 'zip_code0', + neighborhood: 'neighborhood2', + city: 'city6', + state: 'state2', + country: 'country0', + complement: 'complement2', + line1: 'line_10', + line2: 'line_24', }; try { - const { result, ...httpResponse } = await customersController.updateCard( + const { result, ...httpResponse } = await customersController.createAddress( customerId, - cardId, request ); // Get more response info... @@ -105,16 +91,16 @@ try { ``` -# Update Address +# Update Card -Updates an address +Updates a card ```ts -async updateAddress( customerId: string, - addressId: string, - request: UpdateAddressRequest, +async updateCard( customerId: string, + cardId: string, + request: UpdateCardRequest, idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> +requestOptions?: RequestOptions): Promise> ``` ## Parameters @@ -122,35 +108,48 @@ requestOptions?: RequestOptions): Promise> | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `customerId` | `string` | Template, Required | Customer Id | -| `addressId` | `string` | Template, Required | Address Id | -| `request` | [`UpdateAddressRequest`](../../doc/models/update-address-request.md) | Body, Required | Request for updating an address | +| `cardId` | `string` | Template, Required | Card id | +| `request` | [`UpdateCardRequest`](../../doc/models/update-card-request.md) | Body, Required | Request for updating a card | | `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetAddressResponse`](../../doc/models/get-address-response.md) +[`GetCardResponse`](../../doc/models/get-card-response.md) ## Example Usage ```ts const customerId = 'customer_id8'; -const addressId = 'address_id0'; +const cardId = 'card_id4'; -const request: UpdateAddressRequest = { - number: 'number4', - complement: 'complement2', +const request: UpdateCardRequest = { + holderName: 'holder_name2', + expMonth: 10, + expYear: 30, + billingAddress: { + street: 'street8', + number: 'number4', + zipCode: 'zip_code2', + neighborhood: 'neighborhood4', + city: 'city2', + state: 'state6', + country: 'country2', + complement: 'complement6', + line1: 'line_18', + line2: 'line_26', + }, metadata: { 'key0': 'metadata3' }, - line2: 'line_24', + label: 'label6', }; try { - const { result, ...httpResponse } = await customersController.updateAddress( + const { result, ...httpResponse } = await customersController.updateCard( customerId, - addressId, + cardId, request ); // Get more response info... @@ -273,15 +272,13 @@ try { ``` -# Create Address +# Delete Access Tokens -Creates a new address for a customer +Delete a Customer's access tokens ```ts -async createAddress( customerId: string, - request: CreateAddressRequest, - idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> +async deleteAccessTokens( customerId: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters @@ -289,37 +286,19 @@ requestOptions?: RequestOptions): Promise> | 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 \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetAddressResponse`](../../doc/models/get-address-response.md) +[`ListAccessTokensResponse`](../../doc/models/list-access-tokens-response.md) ## Example Usage ```ts const customerId = 'customer_id8'; -const request: CreateAddressRequest = { - street: 'street6', - number: 'number4', - zipCode: 'zip_code0', - neighborhood: 'neighborhood2', - city: 'city6', - state: 'state2', - country: 'country0', - complement: 'complement2', - line1: 'line_10', - line2: 'line_24', -}; - try { - const { result, ...httpResponse } = await customersController.createAddress( - customerId, - request -); + const { result, ...httpResponse } = await customersController.deleteAccessTokens(customerId); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -331,13 +310,16 @@ try { ``` -# Delete Access Tokens +# Update Address -Delete a Customer's access tokens +Updates an address ```ts -async deleteAccessTokens( customerId: string, -requestOptions?: RequestOptions): Promise> +async updateAddress( customerId: string, + addressId: string, + request: UpdateAddressRequest, + idempotencyKey?: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters @@ -345,19 +327,37 @@ requestOptions?: RequestOptions): Promise> | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `customerId` | `string` | Template, Required | Customer Id | +| `addressId` | `string` | Template, Required | Address Id | +| `request` | [`UpdateAddressRequest`](../../doc/models/update-address-request.md) | Body, Required | Request for updating an address | +| `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`ListAccessTokensResponse`](../../doc/models/list-access-tokens-response.md) +[`GetAddressResponse`](../../doc/models/get-address-response.md) ## Example Usage ```ts const customerId = 'customer_id8'; +const addressId = 'address_id0'; + +const request: UpdateAddressRequest = { + number: 'number4', + complement: 'complement2', + metadata: { + 'key0': 'metadata3' + }, + line2: 'line_24', +}; + try { - const { result, ...httpResponse } = await customersController.deleteAccessTokens(customerId); + const { result, ...httpResponse } = await customersController.updateAddress( + customerId, + addressId, + request +); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -461,55 +461,6 @@ try { ``` -# Create Card - -Creates a new card for a customer - -```ts -async createCard( customerId: string, - request: CreateCardRequest, - idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> -``` - -## Parameters - -| Parameter | Type | Tags | Description | -| --- | --- | --- | --- | -| `customerId` | `string` | Template, Required | Customer id | -| `request` | [`CreateCardRequest`](../../doc/models/create-card-request.md) | Body, Required | Request for creating a card | -| `idempotencyKey` | `string \| undefined` | Header, Optional | - | -| `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | - -## Response Type - -[`GetCardResponse`](../../doc/models/get-card-response.md) - -## Example Usage - -```ts -const customerId = 'customer_id8'; - -const request: CreateCardRequest = { - type: 'credit', -}; - -try { - const { result, ...httpResponse } = await customersController.createCard( - customerId, - request -); - // Get more response info... - // const { statusCode, headers } = httpResponse; -} catch (error) { - if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; - } -} -``` - - # Get Customers Get all Customers @@ -565,42 +516,37 @@ try { ``` -# Update Customer +# Get Access Tokens -Updates a customer +Get all access tokens from a customer ```ts -async updateCustomer( customerId: string, - request: UpdateCustomerRequest, - idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> +async getAccessTokens( customerId: string, + page?: number, + size?: number, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `customerId` | `string` | Template, Required | Customer id | -| `request` | [`UpdateCustomerRequest`](../../doc/models/update-customer-request.md) | Body, Required | Request for updating a customer | -| `idempotencyKey` | `string \| undefined` | Header, Optional | - | +| `customerId` | `string` | Template, Required | Customer Id | +| `page` | `number \| undefined` | Query, Optional | Page number | +| `size` | `number \| undefined` | Query, Optional | Page size | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetCustomerResponse`](../../doc/models/get-customer-response.md) +[`ListAccessTokensResponse`](../../doc/models/list-access-tokens-response.md) ## Example Usage ```ts const customerId = 'customer_id8'; -const request: UpdateCustomerRequest = {}; - try { - const { result, ...httpResponse } = await customersController.updateCustomer( - customerId, - request -); + const { result, ...httpResponse } = await customersController.getAccessTokens(customerId); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -612,15 +558,15 @@ try { ``` -# Create Access Token +# Delete Card -Creates a access token for a customer +Delete a customer's card ```ts -async createAccessToken( customerId: string, - request: CreateAccessTokenRequest, +async deleteCard( customerId: string, + cardId: string, idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> +requestOptions?: RequestOptions): Promise> ``` ## Parameters @@ -628,25 +574,25 @@ requestOptions?: RequestOptions): Promise> | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `customerId` | `string` | Template, Required | Customer Id | -| `request` | [`CreateAccessTokenRequest`](../../doc/models/create-access-token-request.md) | Body, Required | Request for creating a access token | +| `cardId` | `string` | Template, Required | Card Id | | `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetAccessTokenResponse`](../../doc/models/get-access-token-response.md) +[`GetCardResponse`](../../doc/models/get-card-response.md) ## Example Usage ```ts const customerId = 'customer_id8'; -const request: CreateAccessTokenRequest = {}; +const cardId = 'card_id4'; try { - const { result, ...httpResponse } = await customersController.createAccessToken( + const { result, ...httpResponse } = await customersController.deleteCard( customerId, - request + cardId ); // Get more response info... // const { statusCode, headers } = httpResponse; @@ -659,37 +605,40 @@ try { ``` -# Get Access Tokens +# Get Card -Get all access tokens from a customer +Get a customer's card ```ts -async getAccessTokens( customerId: string, - page?: number, - size?: number, -requestOptions?: RequestOptions): Promise> +async getCard( customerId: string, + cardId: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `customerId` | `string` | Template, Required | Customer Id | -| `page` | `number \| undefined` | Query, Optional | Page number | -| `size` | `number \| undefined` | Query, Optional | Page size | +| `customerId` | `string` | Template, Required | Customer id | +| `cardId` | `string` | Template, Required | Card id | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`ListAccessTokensResponse`](../../doc/models/list-access-tokens-response.md) +[`GetCardResponse`](../../doc/models/get-card-response.md) ## Example Usage ```ts const customerId = 'customer_id8'; +const cardId = 'card_id4'; + try { - const { result, ...httpResponse } = await customersController.getAccessTokens(customerId); + const { result, ...httpResponse } = await customersController.getCard( + customerId, + cardId +); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -701,37 +650,44 @@ try { ``` -# Get Cards +# Create Card -Get all cards from a customer +Creates a new card for a customer ```ts -async getCards( customerId: string, - page?: number, - size?: number, -requestOptions?: RequestOptions): Promise> +async createCard( customerId: string, + request: CreateCardRequest, + idempotencyKey?: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `customerId` | `string` | Template, Required | Customer Id | -| `page` | `number \| undefined` | Query, Optional | Page number | -| `size` | `number \| undefined` | Query, Optional | Page size | +| `customerId` | `string` | Template, Required | Customer id | +| `request` | [`CreateCardRequest`](../../doc/models/create-card-request.md) | Body, Required | Request for creating a card | +| `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`ListCardsResponse`](../../doc/models/list-cards-response.md) +[`GetCardResponse`](../../doc/models/get-card-response.md) ## Example Usage ```ts const customerId = 'customer_id8'; +const request: CreateCardRequest = { + type: 'credit', +}; + try { - const { result, ...httpResponse } = await customersController.getCards(customerId); + const { result, ...httpResponse } = await customersController.createCard( + customerId, + request +); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -743,41 +699,39 @@ try { ``` -# Renew Card +# Get Access Token -Renew a card +Get a Customer's access token ```ts -async renewCard( customerId: string, - cardId: string, - idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> +async getAccessToken( customerId: string, + tokenId: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `customerId` | `string` | Template, Required | Customer id | -| `cardId` | `string` | Template, Required | Card Id | -| `idempotencyKey` | `string \| undefined` | Header, Optional | - | +| `customerId` | `string` | Template, Required | Customer Id | +| `tokenId` | `string` | Template, Required | Token Id | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetCardResponse`](../../doc/models/get-card-response.md) +[`GetAccessTokenResponse`](../../doc/models/get-access-token-response.md) ## Example Usage ```ts const customerId = 'customer_id8'; -const cardId = 'card_id4'; +const tokenId = 'token_id6'; try { - const { result, ...httpResponse } = await customersController.renewCard( + const { result, ...httpResponse } = await customersController.getAccessToken( customerId, - cardId + tokenId ); // Get more response info... // const { statusCode, headers } = httpResponse; @@ -790,40 +744,37 @@ try { ``` -# Get Access Token +# Get Addresses -Get a Customer's access token +Gets all adressess from a customer ```ts -async getAccessToken( customerId: string, - tokenId: string, -requestOptions?: RequestOptions): Promise> +async getAddresses( customerId: string, + page?: number, + size?: number, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `customerId` | `string` | Template, Required | Customer Id | -| `tokenId` | `string` | Template, Required | Token Id | +| `customerId` | `string` | Template, Required | Customer id | +| `page` | `number \| undefined` | Query, Optional | Page number | +| `size` | `number \| undefined` | Query, Optional | Page size | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetAccessTokenResponse`](../../doc/models/get-access-token-response.md) +[`ListAddressesResponse`](../../doc/models/list-addresses-response.md) ## Example Usage ```ts const customerId = 'customer_id8'; -const tokenId = 'token_id6'; - try { - const { result, ...httpResponse } = await customersController.getAccessToken( - customerId, - tokenId -); + const { result, ...httpResponse } = await customersController.getAddresses(customerId); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -835,13 +786,13 @@ try { ``` -# Update Customer Metadata +# Update Customer -Updates the metadata a customer +Updates a customer ```ts -async updateCustomerMetadata( customerId: string, - request: UpdateMetadataRequest, +async updateCustomer( customerId: string, + request: UpdateCustomerRequest, idempotencyKey?: string, requestOptions?: RequestOptions): Promise> ``` @@ -850,8 +801,8 @@ requestOptions?: RequestOptions): Promise> | 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 \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | @@ -864,14 +815,10 @@ requestOptions?: RequestOptions): Promise> ```ts const customerId = 'customer_id8'; -const request: UpdateMetadataRequest = { - metadata: { - 'key0': 'metadata3' - }, -}; +const request: UpdateCustomerRequest = {}; try { - const { result, ...httpResponse } = await customersController.updateCustomerMetadata( + const { result, ...httpResponse } = await customersController.updateCustomer( customerId, request ); @@ -886,15 +833,15 @@ try { ``` -# Delete Card +# Create Access Token -Delete a customer's card +Creates a access token for a customer ```ts -async deleteCard( customerId: string, - cardId: string, +async createAccessToken( customerId: string, + request: CreateAccessTokenRequest, idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> +requestOptions?: RequestOptions): Promise> ``` ## Parameters @@ -902,25 +849,25 @@ requestOptions?: RequestOptions): Promise> | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `customerId` | `string` | Template, Required | Customer Id | -| `cardId` | `string` | Template, Required | Card Id | +| `request` | [`CreateAccessTokenRequest`](../../doc/models/create-access-token-request.md) | Body, Required | Request for creating a access token | | `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetCardResponse`](../../doc/models/get-card-response.md) +[`GetAccessTokenResponse`](../../doc/models/get-access-token-response.md) ## Example Usage ```ts const customerId = 'customer_id8'; -const cardId = 'card_id4'; +const request: CreateAccessTokenRequest = {}; try { - const { result, ...httpResponse } = await customersController.deleteCard( + const { result, ...httpResponse } = await customersController.createAccessToken( customerId, - cardId + request ); // Get more response info... // const { statusCode, headers } = httpResponse; @@ -933,29 +880,29 @@ try { ``` -# Get Addresses +# Get Cards -Gets all adressess from a customer +Get all cards from a customer ```ts -async getAddresses( customerId: string, +async getCards( customerId: string, page?: number, size?: number, -requestOptions?: RequestOptions): Promise> +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `customerId` | `string` | Template, Required | Customer id | +| `customerId` | `string` | Template, Required | Customer Id | | `page` | `number \| undefined` | Query, Optional | Page number | | `size` | `number \| undefined` | Query, Optional | Page size | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`ListAddressesResponse`](../../doc/models/list-addresses-response.md) +[`ListCardsResponse`](../../doc/models/list-cards-response.md) ## Example Usage @@ -963,7 +910,7 @@ requestOptions?: RequestOptions): Promise> const customerId = 'customer_id8'; try { - const { result, ...httpResponse } = await customersController.getAddresses(customerId); + const { result, ...httpResponse } = await customersController.getCards(customerId); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -975,33 +922,42 @@ try { ``` -# Get Customer +# Renew Card -Get a customer +Renew a card ```ts -async getCustomer( customerId: string, -requestOptions?: RequestOptions): Promise> +async renewCard( customerId: string, + cardId: string, + idempotencyKey?: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `customerId` | `string` | Template, Required | Customer Id | +| `customerId` | `string` | Template, Required | Customer id | +| `cardId` | `string` | Template, Required | Card Id | +| `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetCustomerResponse`](../../doc/models/get-customer-response.md) +[`GetCardResponse`](../../doc/models/get-card-response.md) ## Example Usage ```ts const customerId = 'customer_id8'; +const cardId = 'card_id4'; + try { - const { result, ...httpResponse } = await customersController.getCustomer(customerId); + const { result, ...httpResponse } = await customersController.renewCard( + customerId, + cardId +); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -1013,39 +969,45 @@ try { ``` -# Get Card +# Update Customer Metadata -Get a customer's card +Updates the metadata a customer ```ts -async getCard( customerId: string, - cardId: string, -requestOptions?: RequestOptions): Promise> +async updateCustomerMetadata( customerId: string, + request: UpdateMetadataRequest, + idempotencyKey?: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `customerId` | `string` | Template, Required | Customer id | -| `cardId` | `string` | Template, Required | Card id | +| `customerId` | `string` | Template, Required | The customer id | +| `request` | [`UpdateMetadataRequest`](../../doc/models/update-metadata-request.md) | Body, Required | Request for updating the customer metadata | +| `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetCardResponse`](../../doc/models/get-card-response.md) +[`GetCustomerResponse`](../../doc/models/get-customer-response.md) ## Example Usage ```ts const customerId = 'customer_id8'; -const cardId = 'card_id4'; +const request: UpdateMetadataRequest = { + metadata: { + 'key0': 'metadata3' + }, +}; try { - const { result, ...httpResponse } = await customersController.getCard( + const { result, ...httpResponse } = await customersController.updateCustomerMetadata( customerId, - cardId + request ); // Get more response info... // const { statusCode, headers } = httpResponse; @@ -1057,3 +1019,41 @@ try { } ``` + +# Get Customer + +Get a customer + +```ts +async getCustomer( customerId: string, +requestOptions?: RequestOptions): Promise> +``` + +## Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `customerId` | `string` | Template, Required | Customer Id | +| `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | + +## Response Type + +[`GetCustomerResponse`](../../doc/models/get-customer-response.md) + +## Example Usage + +```ts +const customerId = 'customer_id8'; + +try { + const { result, ...httpResponse } = await customersController.getCustomer(customerId); + // Get more response info... + // const { statusCode, headers } = httpResponse; +} catch (error) { + if (error instanceof ApiError) { + const errors = error.result; + // const { statusCode, headers } = error; + } +} +``` + diff --git a/doc/controllers/invoices.md b/doc/controllers/invoices.md index 37339a5..f5b875f 100644 --- a/doc/controllers/invoices.md +++ b/doc/controllers/invoices.md @@ -10,55 +10,60 @@ const invoicesController = new InvoicesController(client); ## Methods +* [Get Invoices](../../doc/controllers/invoices.md#get-invoices) +* [Cancel Invoice](../../doc/controllers/invoices.md#cancel-invoice) +* [Update Invoice Status](../../doc/controllers/invoices.md#update-invoice-status) * [Update Invoice Metadata](../../doc/controllers/invoices.md#update-invoice-metadata) * [Get Partial Invoice](../../doc/controllers/invoices.md#get-partial-invoice) -* [Cancel Invoice](../../doc/controllers/invoices.md#cancel-invoice) * [Create Invoice](../../doc/controllers/invoices.md#create-invoice) -* [Get Invoices](../../doc/controllers/invoices.md#get-invoices) * [Get Invoice](../../doc/controllers/invoices.md#get-invoice) -* [Update Invoice Status](../../doc/controllers/invoices.md#update-invoice-status) -# Update Invoice Metadata +# Get Invoices -Updates the metadata from an invoice +Gets all invoices ```ts -async updateInvoiceMetadata( invoiceId: string, - request: UpdateMetadataRequest, - idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> +async getInvoices( page?: number, + size?: number, + code?: string, + customerId?: string, + subscriptionId?: string, + createdSince?: string, + createdUntil?: string, + status?: string, + dueSince?: string, + dueUntil?: string, + customerDocument?: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `invoiceId` | `string` | Template, Required | The invoice id | -| `request` | [`UpdateMetadataRequest`](../../doc/models/update-metadata-request.md) | Body, Required | Request for updating the invoice metadata | -| `idempotencyKey` | `string \| undefined` | Header, Optional | - | +| `page` | `number \| undefined` | Query, Optional | Page number | +| `size` | `number \| undefined` | Query, Optional | Page size | +| `code` | `string \| undefined` | Query, Optional | Filter for Invoice's code | +| `customerId` | `string \| undefined` | Query, Optional | Filter for Invoice's customer id | +| `subscriptionId` | `string \| undefined` | Query, Optional | Filter for Invoice's subscription id | +| `createdSince` | `string \| undefined` | Query, Optional | Filter for Invoice's creation date start range | +| `createdUntil` | `string \| undefined` | Query, Optional | Filter for Invoices creation date end range | +| `status` | `string \| undefined` | Query, Optional | Filter for Invoice's status | +| `dueSince` | `string \| undefined` | Query, Optional | Filter for Invoice's due date start range | +| `dueUntil` | `string \| undefined` | Query, Optional | Filter for Invoice's due date end range | +| `customerDocument` | `string \| undefined` | Query, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetInvoiceResponse`](../../doc/models/get-invoice-response.md) +[`ListInvoicesResponse`](../../doc/models/list-invoices-response.md) ## Example Usage ```ts -const invoiceId = 'invoice_id0'; - -const request: UpdateMetadataRequest = { - metadata: { - 'key0': 'metadata3' - }, -}; - try { - const { result, ...httpResponse } = await invoicesController.updateInvoiceMetadata( - invoiceId, - request -); + const { result, ...httpResponse } = await invoicesController.getInvoices(); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -70,10 +75,13 @@ try { ``` -# Get Partial Invoice +# Cancel Invoice + +Cancels an invoice ```ts -async getPartialInvoice( subscriptionId: string, +async cancelInvoice( invoiceId: string, + idempotencyKey?: string, requestOptions?: RequestOptions): Promise> ``` @@ -81,7 +89,8 @@ requestOptions?: RequestOptions): Promise> | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | Subscription Id | +| `invoiceId` | `string` | Template, Required | Invoice id | +| `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type @@ -91,10 +100,10 @@ requestOptions?: RequestOptions): Promise> ## Example Usage ```ts -const subscriptionId = 'subscription_id0'; +const invoiceId = 'invoice_id0'; try { - const { result, ...httpResponse } = await invoicesController.getPartialInvoice(subscriptionId); + const { result, ...httpResponse } = await invoicesController.cancelInvoice(invoiceId); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -106,12 +115,13 @@ try { ``` -# Cancel Invoice +# Update Invoice Status -Cancels an invoice +Updates the status from an invoice ```ts -async cancelInvoice( invoiceId: string, +async updateInvoiceStatus( invoiceId: string, + request: UpdateInvoiceStatusRequest, idempotencyKey?: string, requestOptions?: RequestOptions): Promise> ``` @@ -120,7 +130,8 @@ requestOptions?: RequestOptions): Promise> | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `invoiceId` | `string` | Template, Required | Invoice id | +| `invoiceId` | `string` | Template, Required | Invoice Id | +| `request` | [`UpdateInvoiceStatusRequest`](../../doc/models/update-invoice-status-request.md) | Body, Required | Request for updating an invoice's status | | `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | @@ -133,8 +144,15 @@ requestOptions?: RequestOptions): Promise> ```ts const invoiceId = 'invoice_id0'; +const request: UpdateInvoiceStatusRequest = { + status: 'status8', +}; + try { - const { result, ...httpResponse } = await invoicesController.cancelInvoice(invoiceId); + const { result, ...httpResponse } = await invoicesController.updateInvoiceStatus( + invoiceId, + request +); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -146,14 +164,13 @@ try { ``` -# Create Invoice +# Update Invoice Metadata -Create an Invoice +Updates the metadata from an invoice ```ts -async createInvoice( subscriptionId: string, - cycleId: string, - request?: CreateInvoiceRequest, +async updateInvoiceMetadata( invoiceId: string, + request: UpdateMetadataRequest, idempotencyKey?: string, requestOptions?: RequestOptions): Promise> ``` @@ -162,9 +179,8 @@ requestOptions?: RequestOptions): Promise> | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | Subscription Id | -| `cycleId` | `string` | Template, Required | Cycle Id | -| `request` | [`CreateInvoiceRequest \| undefined`](../../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 \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | @@ -175,14 +191,18 @@ requestOptions?: RequestOptions): Promise> ## Example Usage ```ts -const subscriptionId = 'subscription_id0'; +const invoiceId = 'invoice_id0'; -const cycleId = 'cycle_id6'; +const request: UpdateMetadataRequest = { + metadata: { + 'key0': 'metadata3' + }, +}; try { - const { result, ...httpResponse } = await invoicesController.createInvoice( - subscriptionId, - cycleId + const { result, ...httpResponse } = await invoicesController.updateInvoiceMetadata( + invoiceId, + request ); // Get more response info... // const { statusCode, headers } = httpResponse; @@ -195,51 +215,31 @@ try { ``` -# Get Invoices - -Gets all invoices +# Get Partial Invoice ```ts -async getInvoices( page?: number, - size?: number, - code?: string, - customerId?: string, - subscriptionId?: string, - createdSince?: string, - createdUntil?: string, - status?: string, - dueSince?: string, - dueUntil?: string, - customerDocument?: string, -requestOptions?: RequestOptions): Promise> +async getPartialInvoice( subscriptionId: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `page` | `number \| undefined` | Query, Optional | Page number | -| `size` | `number \| undefined` | Query, Optional | Page size | -| `code` | `string \| undefined` | Query, Optional | Filter for Invoice's code | -| `customerId` | `string \| undefined` | Query, Optional | Filter for Invoice's customer id | -| `subscriptionId` | `string \| undefined` | Query, Optional | Filter for Invoice's subscription id | -| `createdSince` | `string \| undefined` | Query, Optional | Filter for Invoice's creation date start range | -| `createdUntil` | `string \| undefined` | Query, Optional | Filter for Invoices creation date end range | -| `status` | `string \| undefined` | Query, Optional | Filter for Invoice's status | -| `dueSince` | `string \| undefined` | Query, Optional | Filter for Invoice's due date start range | -| `dueUntil` | `string \| undefined` | Query, Optional | Filter for Invoice's due date end range | -| `customerDocument` | `string \| undefined` | Query, Optional | - | +| `subscriptionId` | `string` | Template, Required | Subscription Id | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`ListInvoicesResponse`](../../doc/models/list-invoices-response.md) +[`GetInvoiceResponse`](../../doc/models/get-invoice-response.md) ## Example Usage ```ts +const subscriptionId = 'subscription_id0'; + try { - const { result, ...httpResponse } = await invoicesController.getInvoices(); + const { result, ...httpResponse } = await invoicesController.getPartialInvoice(subscriptionId); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -251,12 +251,15 @@ try { ``` -# Get Invoice +# Create Invoice -Gets an invoice +Create an Invoice ```ts -async getInvoice( invoiceId: string, +async createInvoice( subscriptionId: string, + cycleId: string, + request?: CreateInvoiceRequest, + idempotencyKey?: string, requestOptions?: RequestOptions): Promise> ``` @@ -264,7 +267,10 @@ requestOptions?: RequestOptions): Promise> | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `invoiceId` | `string` | Template, Required | Invoice Id | +| `subscriptionId` | `string` | Template, Required | Subscription Id | +| `cycleId` | `string` | Template, Required | Cycle Id | +| `request` | [`CreateInvoiceRequest \| undefined`](../../doc/models/create-invoice-request.md) | Body, Optional | - | +| `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type @@ -274,10 +280,15 @@ requestOptions?: RequestOptions): Promise> ## Example Usage ```ts -const invoiceId = 'invoice_id0'; +const subscriptionId = 'subscription_id0'; + +const cycleId = 'cycle_id6'; try { - const { result, ...httpResponse } = await invoicesController.getInvoice(invoiceId); + const { result, ...httpResponse } = await invoicesController.createInvoice( + subscriptionId, + cycleId +); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -289,14 +300,12 @@ try { ``` -# Update Invoice Status +# Get Invoice -Updates the status from an invoice +Gets an invoice ```ts -async updateInvoiceStatus( invoiceId: string, - request: UpdateInvoiceStatusRequest, - idempotencyKey?: string, +async getInvoice( invoiceId: string, requestOptions?: RequestOptions): Promise> ``` @@ -305,8 +314,6 @@ requestOptions?: RequestOptions): Promise> | 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 \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type @@ -318,15 +325,8 @@ requestOptions?: RequestOptions): Promise> ```ts const invoiceId = 'invoice_id0'; -const request: UpdateInvoiceStatusRequest = { - status: 'status8', -}; - try { - const { result, ...httpResponse } = await invoicesController.updateInvoiceStatus( - invoiceId, - request -); + const { result, ...httpResponse } = await invoicesController.getInvoice(invoiceId); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { diff --git a/doc/controllers/orders.md b/doc/controllers/orders.md index 4c04323..2e7912d 100644 --- a/doc/controllers/orders.md +++ b/doc/controllers/orders.md @@ -10,55 +10,45 @@ const ordersController = new OrdersController(client); ## Methods -* [Get Orders](../../doc/controllers/orders.md#get-orders) -* [Update Order Item](../../doc/controllers/orders.md#update-order-item) * [Delete All Order Items](../../doc/controllers/orders.md#delete-all-order-items) +* [Get Order Item](../../doc/controllers/orders.md#get-order-item) +* [Update Order Metadata](../../doc/controllers/orders.md#update-order-metadata) * [Delete Order Item](../../doc/controllers/orders.md#delete-order-item) +* [Get Order](../../doc/controllers/orders.md#get-order) +* [Get Orders](../../doc/controllers/orders.md#get-orders) +* [Update Order Item](../../doc/controllers/orders.md#update-order-item) * [Close Order](../../doc/controllers/orders.md#close-order) * [Create Order](../../doc/controllers/orders.md#create-order) * [Create Order Item](../../doc/controllers/orders.md#create-order-item) -* [Get Order Item](../../doc/controllers/orders.md#get-order-item) -* [Update Order Metadata](../../doc/controllers/orders.md#update-order-metadata) -* [Get Order](../../doc/controllers/orders.md#get-order) -# Get Orders - -Gets all orders +# Delete All Order Items ```ts -async getOrders( page?: number, - size?: number, - code?: string, - status?: string, - createdSince?: string, - createdUntil?: string, - customerId?: string, -requestOptions?: RequestOptions): Promise> +async deleteAllOrderItems( orderId: string, + idempotencyKey?: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `page` | `number \| undefined` | Query, Optional | Page number | -| `size` | `number \| undefined` | Query, Optional | Page size | -| `code` | `string \| undefined` | Query, Optional | Filter for order's code | -| `status` | `string \| undefined` | Query, Optional | Filter for order's status | -| `createdSince` | `string \| undefined` | Query, Optional | Filter for order's creation date start range | -| `createdUntil` | `string \| undefined` | Query, Optional | Filter for order's creation date end range | -| `customerId` | `string \| undefined` | Query, Optional | Filter for order's customer id | +| `orderId` | `string` | Template, Required | Order Id | +| `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`ListOrderResponse`](../../doc/models/list-order-response.md) +[`GetOrderResponse`](../../doc/models/get-order-response.md) ## Example Usage ```ts +const orderId = 'orderId2'; + try { - const { result, ...httpResponse } = await ordersController.getOrders(); + const { result, ...httpResponse } = await ordersController.deleteAllOrderItems(orderId); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -70,13 +60,11 @@ try { ``` -# Update Order Item +# Get Order Item ```ts -async updateOrderItem( orderId: string, +async getOrderItem( orderId: string, itemId: string, - request: UpdateOrderItemRequest, - idempotencyKey?: string, requestOptions?: RequestOptions): Promise> ``` @@ -86,8 +74,6 @@ requestOptions?: RequestOptions): Promise> | --- | --- | --- | --- | | `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 \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type @@ -101,18 +87,10 @@ const orderId = 'orderId2'; const itemId = 'itemId8'; -const request: UpdateOrderItemRequest = { - amount: 242, - description: 'description6', - quantity: 100, - category: 'category4', -}; - try { - const { result, ...httpResponse } = await ordersController.updateOrderItem( + const { result, ...httpResponse } = await ordersController.getOrderItem( orderId, - itemId, - request + itemId ); // Get more response info... // const { statusCode, headers } = httpResponse; @@ -125,10 +103,13 @@ try { ``` -# Delete All Order Items +# Update Order Metadata + +Updates the metadata from an order ```ts -async deleteAllOrderItems( orderId: string, +async updateOrderMetadata( orderId: string, + request: UpdateMetadataRequest, idempotencyKey?: string, requestOptions?: RequestOptions): Promise> ``` @@ -137,7 +118,8 @@ requestOptions?: RequestOptions): Promise> | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `orderId` | `string` | Template, Required | Order Id | +| `orderId` | `string` | Template, Required | The order id | +| `request` | [`UpdateMetadataRequest`](../../doc/models/update-metadata-request.md) | Body, Required | Request for updating the order metadata | | `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | @@ -148,10 +130,19 @@ requestOptions?: RequestOptions): Promise> ## Example Usage ```ts -const orderId = 'orderId2'; +const orderId = 'order_id6'; + +const request: UpdateMetadataRequest = { + metadata: { + 'key0': 'metadata3' + }, +}; try { - const { result, ...httpResponse } = await ordersController.deleteAllOrderItems(orderId); + const { result, ...httpResponse } = await ordersController.updateOrderMetadata( + orderId, + request +); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -208,12 +199,12 @@ try { ``` -# Close Order +# Get Order + +Gets an order ```ts -async closeOrder( id: string, - request: UpdateOrderStatusRequest, - idempotencyKey?: string, +async getOrder( orderId: string, requestOptions?: RequestOptions): Promise> ``` @@ -221,9 +212,7 @@ requestOptions?: RequestOptions): Promise> | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `id` | `string` | Template, Required | Order Id | -| `request` | [`UpdateOrderStatusRequest`](../../doc/models/update-order-status-request.md) | Body, Required | Update Order Model | -| `idempotencyKey` | `string \| undefined` | Header, Optional | - | +| `orderId` | `string` | Template, Required | Order id | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type @@ -233,17 +222,10 @@ requestOptions?: RequestOptions): Promise> ## Example Usage ```ts -const id = 'id0'; - -const request: UpdateOrderStatusRequest = { - status: 'status8', -}; +const orderId = 'order_id6'; try { - const { result, ...httpResponse } = await ordersController.closeOrder( - id, - request -); + const { result, ...httpResponse } = await ordersController.getOrder(orderId); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -255,74 +237,43 @@ try { ``` -# Create Order +# Get Orders -Creates a new Order +Gets all orders ```ts -async createOrder( body: CreateOrderRequest, - idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> +async getOrders( page?: number, + size?: number, + code?: string, + status?: string, + createdSince?: string, + createdUntil?: string, + customerId?: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `body` | [`CreateOrderRequest`](../../doc/models/create-order-request.md) | Body, Required | Request for creating an order | -| `idempotencyKey` | `string \| undefined` | Header, Optional | - | +| `page` | `number \| undefined` | Query, Optional | Page number | +| `size` | `number \| undefined` | Query, Optional | Page size | +| `code` | `string \| undefined` | Query, Optional | Filter for order's code | +| `status` | `string \| undefined` | Query, Optional | Filter for order's status | +| `createdSince` | `string \| undefined` | Query, Optional | Filter for order's creation date start range | +| `createdUntil` | `string \| undefined` | Query, Optional | Filter for order's creation date end range | +| `customerId` | `string \| undefined` | Query, Optional | Filter for order's customer id | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetOrderResponse`](../../doc/models/get-order-response.md) +[`ListOrderResponse`](../../doc/models/list-order-response.md) ## Example Usage ```ts -const body: CreateOrderRequest = { - items: [ - { - amount: 164, - description: 'description2', - quantity: 22, - category: 'category6', - } - ], - customer: { - name: 'Tony Stark', - email: 'email6', - document: 'document6', - type: 'type0', - address: { - street: 'street6', - number: 'number4', - zipCode: 'zip_code0', - neighborhood: 'neighborhood2', - city: 'city6', - state: 'state2', - country: 'country0', - complement: 'complement2', - line1: 'line_10', - line2: 'line_24', - }, - metadata: { - 'key0': 'metadata3' - }, - phones: {}, - code: 'code8', - }, - payments: [ - { - paymentMethod: 'payment_method8', - } - ], - code: 'code4', - closed: true, -}; - try { - const { result, ...httpResponse } = await ordersController.createOrder(body); + const { result, ...httpResponse } = await ordersController.getOrders(); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -334,11 +285,12 @@ try { ``` -# Create Order Item +# Update Order Item ```ts -async createOrderItem( orderId: string, - request: CreateOrderItemRequest, +async updateOrderItem( orderId: string, + itemId: string, + request: UpdateOrderItemRequest, idempotencyKey?: string, requestOptions?: RequestOptions): Promise> ``` @@ -348,7 +300,8 @@ requestOptions?: RequestOptions): Promise> | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orderId` | `string` | Template, Required | Order Id | -| `request` | [`CreateOrderItemRequest`](../../doc/models/create-order-item-request.md) | Body, Required | Order Item Model | +| `itemId` | `string` | Template, Required | Item Id | +| `request` | [`UpdateOrderItemRequest`](../../doc/models/update-order-item-request.md) | Body, Required | Item Model | | `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | @@ -361,7 +314,9 @@ requestOptions?: RequestOptions): Promise> ```ts const orderId = 'orderId2'; -const request: CreateOrderItemRequest = { +const itemId = 'itemId8'; + +const request: UpdateOrderItemRequest = { amount: 242, description: 'description6', quantity: 100, @@ -369,8 +324,9 @@ const request: CreateOrderItemRequest = { }; try { - const { result, ...httpResponse } = await ordersController.createOrderItem( + const { result, ...httpResponse } = await ordersController.updateOrderItem( orderId, + itemId, request ); // Get more response info... @@ -384,37 +340,41 @@ try { ``` -# Get Order Item +# Close Order ```ts -async getOrderItem( orderId: string, - itemId: string, -requestOptions?: RequestOptions): Promise> +async closeOrder( id: string, + request: UpdateOrderStatusRequest, + idempotencyKey?: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `orderId` | `string` | Template, Required | Order Id | -| `itemId` | `string` | Template, Required | Item Id | +| `id` | `string` | Template, Required | Order Id | +| `request` | [`UpdateOrderStatusRequest`](../../doc/models/update-order-status-request.md) | Body, Required | Update Order Model | +| `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetOrderItemResponse`](../../doc/models/get-order-item-response.md) +[`GetOrderResponse`](../../doc/models/get-order-response.md) ## Example Usage ```ts -const orderId = 'orderId2'; +const id = 'id0'; -const itemId = 'itemId8'; +const request: UpdateOrderStatusRequest = { + status: 'status8', +}; try { - const { result, ...httpResponse } = await ordersController.getOrderItem( - orderId, - itemId + const { result, ...httpResponse } = await ordersController.closeOrder( + id, + request ); // Get more response info... // const { statusCode, headers } = httpResponse; @@ -427,13 +387,12 @@ try { ``` -# Update Order Metadata +# Create Order -Updates the metadata from an order +Creates a new Order ```ts -async updateOrderMetadata( orderId: string, - request: UpdateMetadataRequest, +async createOrder( body: CreateOrderRequest, idempotencyKey?: string, requestOptions?: RequestOptions): Promise> ``` @@ -442,8 +401,7 @@ requestOptions?: RequestOptions): Promise> | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `orderId` | `string` | Template, Required | The order id | -| `request` | [`UpdateMetadataRequest`](../../doc/models/update-metadata-request.md) | Body, Required | Request for updating the order metadata | +| `body` | [`CreateOrderRequest`](../../doc/models/create-order-request.md) | Body, Required | Request for creating an order | | `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | @@ -454,19 +412,49 @@ requestOptions?: RequestOptions): Promise> ## Example Usage ```ts -const orderId = 'order_id6'; - -const request: UpdateMetadataRequest = { - metadata: { - 'key0': 'metadata3' +const body: CreateOrderRequest = { + items: [ + { + amount: 164, + description: 'description2', + quantity: 22, + category: 'category6', + } + ], + customer: { + name: 'Tony Stark', + email: 'email6', + document: 'document6', + type: 'type0', + address: { + street: 'street6', + number: 'number4', + zipCode: 'zip_code0', + neighborhood: 'neighborhood2', + city: 'city6', + state: 'state2', + country: 'country0', + complement: 'complement2', + line1: 'line_10', + line2: 'line_24', + }, + metadata: { + 'key0': 'metadata3' + }, + phones: {}, + code: 'code8', }, + payments: [ + { + paymentMethod: 'payment_method8', + } + ], + code: 'code4', + closed: true, }; try { - const { result, ...httpResponse } = await ordersController.updateOrderMetadata( - orderId, - request -); + const { result, ...httpResponse } = await ordersController.createOrder(body); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -478,33 +466,45 @@ try { ``` -# Get Order - -Gets an order +# Create Order Item ```ts -async getOrder( orderId: string, -requestOptions?: RequestOptions): Promise> +async createOrderItem( orderId: string, + request: CreateOrderItemRequest, + idempotencyKey?: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `orderId` | `string` | Template, Required | Order id | +| `orderId` | `string` | Template, Required | Order Id | +| `request` | [`CreateOrderItemRequest`](../../doc/models/create-order-item-request.md) | Body, Required | Order Item Model | +| `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetOrderResponse`](../../doc/models/get-order-response.md) +[`GetOrderItemResponse`](../../doc/models/get-order-item-response.md) ## Example Usage ```ts -const orderId = 'order_id6'; +const orderId = 'orderId2'; + +const request: CreateOrderItemRequest = { + amount: 242, + description: 'description6', + quantity: 100, + category: 'category4', +}; try { - const { result, ...httpResponse } = await ordersController.getOrder(orderId); + const { result, ...httpResponse } = await ordersController.createOrderItem( + orderId, + request +); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { diff --git a/doc/controllers/plans.md b/doc/controllers/plans.md index 7dfb444..da59bf7 100644 --- a/doc/controllers/plans.md +++ b/doc/controllers/plans.md @@ -11,15 +11,15 @@ const plansController = new PlansController(client); ## Methods * [Get Plan](../../doc/controllers/plans.md#get-plan) -* [Delete Plan](../../doc/controllers/plans.md#delete-plan) +* [Delete Plan Item](../../doc/controllers/plans.md#delete-plan-item) * [Update Plan Metadata](../../doc/controllers/plans.md#update-plan-metadata) +* [Create Plan](../../doc/controllers/plans.md#create-plan) +* [Update Plan](../../doc/controllers/plans.md#update-plan) +* [Delete Plan](../../doc/controllers/plans.md#delete-plan) +* [Get Plans](../../doc/controllers/plans.md#get-plans) * [Update Plan Item](../../doc/controllers/plans.md#update-plan-item) * [Create Plan Item](../../doc/controllers/plans.md#create-plan-item) * [Get Plan Item](../../doc/controllers/plans.md#get-plan-item) -* [Create Plan](../../doc/controllers/plans.md#create-plan) -* [Delete Plan Item](../../doc/controllers/plans.md#delete-plan-item) -* [Get Plans](../../doc/controllers/plans.md#get-plans) -* [Update Plan](../../doc/controllers/plans.md#update-plan) # Get Plan @@ -60,14 +60,15 @@ try { ``` -# Delete Plan +# Delete Plan Item -Deletes a plan +Removes an item from a plan ```ts -async deletePlan( planId: string, +async deletePlanItem( planId: string, + planItemId: string, idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> +requestOptions?: RequestOptions): Promise> ``` ## Parameters @@ -75,20 +76,26 @@ requestOptions?: RequestOptions): Promise> | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `planId` | `string` | Template, Required | Plan id | +| `planItemId` | `string` | Template, Required | Plan item id | | `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetPlanResponse`](../../doc/models/get-plan-response.md) +[`GetPlanItemResponse`](../../doc/models/get-plan-item-response.md) ## Example Usage ```ts const planId = 'plan_id8'; +const planItemId = 'plan_item_id0'; + try { - const { result, ...httpResponse } = await plansController.deletePlan(planId); + const { result, ...httpResponse } = await plansController.deletePlanItem( + planId, + planItemId +); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -151,60 +158,71 @@ try { ``` -# Update Plan Item +# Create Plan -Updates a plan item +Creates a new plan ```ts -async updatePlanItem( planId: string, - planItemId: string, - body: UpdatePlanItemRequest, +async createPlan( body: CreatePlanRequest, idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `planId` | `string` | Template, Required | Plan id | -| `planItemId` | `string` | Template, Required | Plan item id | -| `body` | [`UpdatePlanItemRequest`](../../doc/models/update-plan-item-request.md) | Body, Required | Request for updating the plan item | +| `body` | [`CreatePlanRequest`](../../doc/models/create-plan-request.md) | Body, Required | Request for creating a plan | | `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetPlanItemResponse`](../../doc/models/get-plan-item-response.md) +[`GetPlanResponse`](../../doc/models/get-plan-response.md) ## Example Usage ```ts -const planId = 'plan_id8'; - -const planItemId = 'plan_item_id0'; - -const body: UpdatePlanItemRequest = { +const body: CreatePlanRequest = { name: 'name6', description: 'description4', - status: 'status2', + statementDescriptor: 'statement_descriptor6', + items: [ + { + name: 'name8', + pricingScheme: { + schemeType: 'scheme_type8', + }, + id: 'id8', + description: 'description2', + } + ], + shippable: false, + paymentMethods: [ + 'payment_methods9' + ], + installments: [ + 207 + ], + currency: 'currency6', + interval: 'interval6', + intervalCount: 170, + billingDays: [ + 201, + 200 + ], + billingType: 'billing_type0', pricingScheme: { schemeType: 'scheme_type8', - priceBrackets: [ - { - startQuantity: 144, - price: 174, - } - ], + }, + metadata: { + 'key0': 'metadata7', + 'key1': 'metadata8' }, }; try { - const { result, ...httpResponse } = await plansController.updatePlanItem( - planId, - planItemId, - body -); + const { result, ...httpResponse } = await plansController.createPlan(body); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -216,15 +234,15 @@ try { ``` -# Create Plan Item +# Update Plan -Adds a new item to a plan +Updates a plan ```ts -async createPlanItem( planId: string, - request: CreatePlanItemRequest, +async updatePlan( planId: string, + request: UpdatePlanRequest, idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> +requestOptions?: RequestOptions): Promise> ``` ## Parameters @@ -232,30 +250,48 @@ requestOptions?: RequestOptions): Promise> | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `planId` | `string` | Template, Required | Plan id | -| `request` | [`CreatePlanItemRequest`](../../doc/models/create-plan-item-request.md) | Body, Required | Request for creating a plan item | +| `request` | [`UpdatePlanRequest`](../../doc/models/update-plan-request.md) | Body, Required | Request for updating a plan | | `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetPlanItemResponse`](../../doc/models/get-plan-item-response.md) +[`GetPlanResponse`](../../doc/models/get-plan-response.md) ## Example Usage ```ts const planId = 'plan_id8'; -const request: CreatePlanItemRequest = { +const request: UpdatePlanRequest = { name: 'name6', - pricingScheme: { - schemeType: 'scheme_type8', - }, - id: 'id6', description: 'description6', + installments: [ + 151, + 152 + ], + statementDescriptor: 'statement_descriptor6', + currency: 'currency6', + interval: 'interval4', + intervalCount: 114, + paymentMethods: [ + 'payment_methods1', + 'payment_methods0', + 'payment_methods9' + ], + billingType: 'billing_type0', + status: 'status8', + shippable: false, + billingDays: [ + 115 + ], + metadata: { + 'key0': 'metadata3' + }, }; try { - const { result, ...httpResponse } = await plansController.createPlanItem( + const { result, ...httpResponse } = await plansController.updatePlan( planId, request ); @@ -270,14 +306,14 @@ try { ``` -# Get Plan Item +# Delete Plan -Gets a plan item +Deletes a plan ```ts -async getPlanItem( planId: string, - planItemId: string, -requestOptions?: RequestOptions): Promise> +async deletePlan( planId: string, + idempotencyKey?: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters @@ -285,25 +321,20 @@ requestOptions?: RequestOptions): Promise> | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `planId` | `string` | Template, Required | Plan id | -| `planItemId` | `string` | Template, Required | Plan item id | +| `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetPlanItemResponse`](../../doc/models/get-plan-item-response.md) +[`GetPlanResponse`](../../doc/models/get-plan-response.md) ## Example Usage ```ts const planId = 'plan_id8'; -const planItemId = 'plan_item_id0'; - try { - const { result, ...httpResponse } = await plansController.getPlanItem( - planId, - planItemId -); + const { result, ...httpResponse } = await plansController.deletePlan(planId); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -315,71 +346,43 @@ try { ``` -# Create Plan +# Get Plans -Creates a new plan +Gets all plans ```ts -async createPlan( body: CreatePlanRequest, - idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> +async getPlans( page?: number, + size?: number, + name?: string, + status?: string, + billingType?: string, + createdSince?: string, + createdUntil?: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `body` | [`CreatePlanRequest`](../../doc/models/create-plan-request.md) | Body, Required | Request for creating a plan | -| `idempotencyKey` | `string \| undefined` | Header, Optional | - | +| `page` | `number \| undefined` | Query, Optional | Page number | +| `size` | `number \| undefined` | Query, Optional | Page size | +| `name` | `string \| undefined` | Query, Optional | Filter for Plan's name | +| `status` | `string \| undefined` | Query, Optional | Filter for Plan's status | +| `billingType` | `string \| undefined` | Query, Optional | Filter for plan's billing type | +| `createdSince` | `string \| undefined` | Query, Optional | Filter for plan's creation date start range | +| `createdUntil` | `string \| undefined` | Query, Optional | Filter for plan's creation date end range | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetPlanResponse`](../../doc/models/get-plan-response.md) +[`ListPlansResponse`](../../doc/models/list-plans-response.md) ## Example Usage ```ts -const body: CreatePlanRequest = { - name: 'name6', - description: 'description4', - statementDescriptor: 'statement_descriptor6', - items: [ - { - name: 'name8', - pricingScheme: { - schemeType: 'scheme_type8', - }, - id: 'id8', - description: 'description2', - } - ], - shippable: false, - paymentMethods: [ - 'payment_methods9' - ], - installments: [ - 207 - ], - currency: 'currency6', - interval: 'interval6', - intervalCount: 170, - billingDays: [ - 201, - 200 - ], - billingType: 'billing_type0', - pricingScheme: { - schemeType: 'scheme_type8', - }, - metadata: { - 'key0': 'metadata7', - 'key1': 'metadata8' - }, -}; - try { - const { result, ...httpResponse } = await plansController.createPlan(body); + const { result, ...httpResponse } = await plansController.getPlans(); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -391,13 +394,14 @@ try { ``` -# Delete Plan Item +# Update Plan Item -Removes an item from a plan +Updates a plan item ```ts -async deletePlanItem( planId: string, +async updatePlanItem( planId: string, planItemId: string, + body: UpdatePlanItemRequest, idempotencyKey?: string, requestOptions?: RequestOptions): Promise> ``` @@ -408,6 +412,7 @@ requestOptions?: RequestOptions): Promise> | --- | --- | --- | --- | | `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 \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | @@ -422,10 +427,26 @@ const planId = 'plan_id8'; const planItemId = 'plan_item_id0'; +const body: UpdatePlanItemRequest = { + name: 'name6', + description: 'description4', + status: 'status2', + pricingScheme: { + schemeType: 'scheme_type8', + priceBrackets: [ + { + startQuantity: 144, + price: 174, + } + ], + }, +}; + try { - const { result, ...httpResponse } = await plansController.deletePlanItem( + const { result, ...httpResponse } = await plansController.updatePlanItem( planId, - planItemId + planItemId, + body ); // Get more response info... // const { statusCode, headers } = httpResponse; @@ -438,43 +459,49 @@ try { ``` -# Get Plans +# Create Plan Item -Gets all plans +Adds a new item to a plan ```ts -async getPlans( page?: number, - size?: number, - name?: string, - status?: string, - billingType?: string, - createdSince?: string, - createdUntil?: string, -requestOptions?: RequestOptions): Promise> +async createPlanItem( planId: string, + request: CreatePlanItemRequest, + idempotencyKey?: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `page` | `number \| undefined` | Query, Optional | Page number | -| `size` | `number \| undefined` | Query, Optional | Page size | -| `name` | `string \| undefined` | Query, Optional | Filter for Plan's name | -| `status` | `string \| undefined` | Query, Optional | Filter for Plan's status | -| `billingType` | `string \| undefined` | Query, Optional | Filter for plan's billing type | -| `createdSince` | `string \| undefined` | Query, Optional | Filter for plan's creation date start range | -| `createdUntil` | `string \| undefined` | 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 \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`ListPlansResponse`](../../doc/models/list-plans-response.md) +[`GetPlanItemResponse`](../../doc/models/get-plan-item-response.md) ## Example Usage ```ts +const planId = 'plan_id8'; + +const request: CreatePlanItemRequest = { + name: 'name6', + pricingScheme: { + schemeType: 'scheme_type8', + }, + id: 'id6', + description: 'description6', +}; + try { - const { result, ...httpResponse } = await plansController.getPlans(); + const { result, ...httpResponse } = await plansController.createPlanItem( + planId, + request +); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -486,15 +513,14 @@ try { ``` -# Update Plan +# Get Plan Item -Updates a plan +Gets a plan item ```ts -async updatePlan( planId: string, - request: UpdatePlanRequest, - idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> +async getPlanItem( planId: string, + planItemId: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters @@ -502,50 +528,24 @@ requestOptions?: RequestOptions): Promise> | 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 \| undefined` | Header, Optional | - | +| `planItemId` | `string` | Template, Required | Plan item id | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetPlanResponse`](../../doc/models/get-plan-response.md) +[`GetPlanItemResponse`](../../doc/models/get-plan-item-response.md) ## Example Usage ```ts const planId = 'plan_id8'; -const request: UpdatePlanRequest = { - name: 'name6', - description: 'description6', - installments: [ - 151, - 152 - ], - statementDescriptor: 'statement_descriptor6', - currency: 'currency6', - interval: 'interval4', - intervalCount: 114, - paymentMethods: [ - 'payment_methods1', - 'payment_methods0', - 'payment_methods9' - ], - billingType: 'billing_type0', - status: 'status8', - shippable: false, - billingDays: [ - 115 - ], - metadata: { - 'key0': 'metadata3' - }, -}; +const planItemId = 'plan_item_id0'; try { - const { result, ...httpResponse } = await plansController.updatePlan( + const { result, ...httpResponse } = await plansController.getPlanItem( planId, - request + planItemId ); // Get more response info... // const { statusCode, headers } = httpResponse; diff --git a/doc/controllers/recipients.md b/doc/controllers/recipients.md index 1a0abb7..02f6845 100644 --- a/doc/controllers/recipients.md +++ b/doc/controllers/recipients.md @@ -11,27 +11,28 @@ const recipientsController = new RecipientsController(client); ## Methods * [Update Recipient](../../doc/controllers/recipients.md#update-recipient) -* [Create Anticipation](../../doc/controllers/recipients.md#create-anticipation) -* [Get Anticipation Limits](../../doc/controllers/recipients.md#get-anticipation-limits) -* [Get Recipients](../../doc/controllers/recipients.md#get-recipients) * [Get Withdraw by Id](../../doc/controllers/recipients.md#get-withdraw-by-id) +* [Get Recipient](../../doc/controllers/recipients.md#get-recipient) +* [Get Balance](../../doc/controllers/recipients.md#get-balance) +* [Get Recipients](../../doc/controllers/recipients.md#get-recipients) * [Update Recipient Default Bank Account](../../doc/controllers/recipients.md#update-recipient-default-bank-account) -* [Update Recipient Metadata](../../doc/controllers/recipients.md#update-recipient-metadata) * [Get Transfers](../../doc/controllers/recipients.md#get-transfers) * [Get Transfer](../../doc/controllers/recipients.md#get-transfer) * [Create Withdraw](../../doc/controllers/recipients.md#create-withdraw) -* [Update Automatic Anticipation Settings](../../doc/controllers/recipients.md#update-automatic-anticipation-settings) * [Get Anticipation](../../doc/controllers/recipients.md#get-anticipation) * [Update Recipient Transfer Settings](../../doc/controllers/recipients.md#update-recipient-transfer-settings) -* [Get Anticipations](../../doc/controllers/recipients.md#get-anticipations) -* [Get Recipient](../../doc/controllers/recipients.md#get-recipient) -* [Get Balance](../../doc/controllers/recipients.md#get-balance) -* [Get Withdrawals](../../doc/controllers/recipients.md#get-withdrawals) +* [Get Recipient by Code](../../doc/controllers/recipients.md#get-recipient-by-code) +* [Update Automatic Anticipation Settings](../../doc/controllers/recipients.md#update-automatic-anticipation-settings) * [Create Transfer](../../doc/controllers/recipients.md#create-transfer) * [Create Recipient](../../doc/controllers/recipients.md#create-recipient) -* [Get Recipient by Code](../../doc/controllers/recipients.md#get-recipient-by-code) * [Get Default Recipient](../../doc/controllers/recipients.md#get-default-recipient) +* [Create Anticipation](../../doc/controllers/recipients.md#create-anticipation) +* [Get Anticipation Limits](../../doc/controllers/recipients.md#get-anticipation-limits) +* [Update Recipient Metadata](../../doc/controllers/recipients.md#update-recipient-metadata) +* [Get Anticipations](../../doc/controllers/recipients.md#get-anticipations) +* [Get Withdrawals](../../doc/controllers/recipients.md#get-withdrawals) * [Create KYC Link](../../doc/controllers/recipients.md#create-kyc-link) +* [Update Recipient Code](../../doc/controllers/recipients.md#update-recipient-code) # Update Recipient @@ -90,45 +91,37 @@ try { ``` -# Create Anticipation - -Creates an anticipation +# Get Withdraw by Id ```ts -async createAnticipation( recipientId: string, - request: CreateAnticipationRequest, - idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> +async getWithdrawById( recipientId: string, + withdrawalId: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `recipientId` | `string` | Template, Required | Recipient id | -| `request` | [`CreateAnticipationRequest`](../../doc/models/create-anticipation-request.md) | Body, Required | Anticipation data | -| `idempotencyKey` | `string \| undefined` | Header, Optional | - | +| `recipientId` | `string` | Template, Required | - | +| `withdrawalId` | `string` | Template, Required | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetAnticipationResponse`](../../doc/models/get-anticipation-response.md) +[`GetWithdrawResponse`](../../doc/models/get-withdraw-response.md) ## Example Usage ```ts const recipientId = 'recipient_id0'; -const request: CreateAnticipationRequest = { - amount: 242, - timeframe: 'timeframe8', - paymentDate: '2016-03-13T12:52:32.123Z', -}; +const withdrawalId = 'withdrawal_id2'; try { - const { result, ...httpResponse } = await recipientsController.createAnticipation( + const { result, ...httpResponse } = await recipientsController.getWithdrawById( recipientId, - request + withdrawalId ); // Get more response info... // const { statusCode, headers } = httpResponse; @@ -141,45 +134,33 @@ try { ``` -# Get Anticipation Limits +# Get Recipient -Gets the anticipation limits for a recipient +Retrieves recipient information ```ts -async getAnticipationLimits( recipientId: string, - timeframe: string, - paymentDate: string, -requestOptions?: RequestOptions): Promise> +async getRecipient( recipientId: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `recipientId` | `string` | Template, Required | Recipient id | -| `timeframe` | `string` | Query, Required | Timeframe | -| `paymentDate` | `string` | Query, Required | Anticipation payment date | +| `recipientId` | `string` | Template, Required | Recipiend id | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetAnticipationLimitResponse`](../../doc/models/get-anticipation-limit-response.md) +[`GetRecipientResponse`](../../doc/models/get-recipient-response.md) ## Example Usage ```ts const recipientId = 'recipient_id0'; -const timeframe = 'timeframe2'; - -const paymentDate = '2016-03-13T12:52:32.123Z'; - try { - const { result, ...httpResponse } = await recipientsController.getAnticipationLimits( - recipientId, - timeframe, - paymentDate -); + const { result, ...httpResponse } = await recipientsController.getRecipient(recipientId); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -191,33 +172,33 @@ try { ``` -# Get Recipients +# Get Balance -Retrieves paginated recipients information +Get balance information for a recipient ```ts -async getRecipients( page?: number, - size?: number, -requestOptions?: RequestOptions): Promise> +async getBalance( recipientId: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `page` | `number \| undefined` | Query, Optional | Page number | -| `size` | `number \| undefined` | Query, Optional | Page size | +| `recipientId` | `string` | Template, Required | Recipient id | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`ListRecipientResponse`](../../doc/models/list-recipient-response.md) +[`GetBalanceResponse`](../../doc/models/get-balance-response.md) ## Example Usage ```ts +const recipientId = 'recipient_id0'; + try { - const { result, ...httpResponse } = await recipientsController.getRecipients(); + const { result, ...httpResponse } = await recipientsController.getBalance(recipientId); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -229,38 +210,33 @@ try { ``` -# Get Withdraw by Id +# Get Recipients + +Retrieves paginated recipients information ```ts -async getWithdrawById( recipientId: string, - withdrawalId: string, -requestOptions?: RequestOptions): Promise> +async getRecipients( page?: number, + size?: number, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `recipientId` | `string` | Template, Required | - | -| `withdrawalId` | `string` | Template, Required | - | +| `page` | `number \| undefined` | Query, Optional | Page number | +| `size` | `number \| undefined` | Query, Optional | Page size | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetWithdrawResponse`](../../doc/models/get-withdraw-response.md) +[`ListRecipientResponse`](../../doc/models/list-recipient-response.md) ## Example Usage ```ts -const recipientId = 'recipient_id0'; - -const withdrawalId = 'withdrawal_id2'; - try { - const { result, ...httpResponse } = await recipientsController.getWithdrawById( - recipientId, - withdrawalId -); + const { result, ...httpResponse } = await recipientsController.getRecipients(); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -335,57 +311,6 @@ try { ``` -# Update Recipient Metadata - -Updates recipient metadata - -```ts -async updateRecipientMetadata( recipientId: string, - request: UpdateMetadataRequest, - idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> -``` - -## Parameters - -| Parameter | Type | Tags | Description | -| --- | --- | --- | --- | -| `recipientId` | `string` | Template, Required | Recipient id | -| `request` | [`UpdateMetadataRequest`](../../doc/models/update-metadata-request.md) | Body, Required | Metadata | -| `idempotencyKey` | `string \| undefined` | Header, Optional | - | -| `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | - -## Response Type - -[`GetRecipientResponse`](../../doc/models/get-recipient-response.md) - -## Example Usage - -```ts -const recipientId = 'recipient_id0'; - -const request: UpdateMetadataRequest = { - metadata: { - 'key0': 'metadata3' - }, -}; - -try { - const { result, ...httpResponse } = await recipientsController.updateRecipientMetadata( - recipientId, - request -); - // Get more response info... - // const { statusCode, headers } = httpResponse; -} catch (error) { - if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; - } -} -``` - - # Get Transfers Gets a paginated list of transfers for the recipient @@ -524,53 +449,6 @@ try { ``` -# Update Automatic Anticipation Settings - -Updates recipient metadata - -```ts -async updateAutomaticAnticipationSettings( recipientId: string, - request: UpdateAutomaticAnticipationSettingsRequest, - idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> -``` - -## Parameters - -| Parameter | Type | Tags | Description | -| --- | --- | --- | --- | -| `recipientId` | `string` | Template, Required | Recipient id | -| `request` | [`UpdateAutomaticAnticipationSettingsRequest`](../../doc/models/update-automatic-anticipation-settings-request.md) | Body, Required | Metadata | -| `idempotencyKey` | `string \| undefined` | Header, Optional | - | -| `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | - -## Response Type - -[`GetRecipientResponse`](../../doc/models/get-recipient-response.md) - -## Example Usage - -```ts -const recipientId = 'recipient_id0'; - -const request: UpdateAutomaticAnticipationSettingsRequest = {}; - -try { - const { result, ...httpResponse } = await recipientsController.updateAutomaticAnticipationSettings( - recipientId, - request -); - // Get more response info... - // const { statusCode, headers } = httpResponse; -} catch (error) { - if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; - } -} -``` - - # Get Anticipation Gets an anticipation @@ -665,49 +543,33 @@ try { ``` -# Get Anticipations +# Get Recipient by Code -Retrieves a paginated list of anticipations from a recipient +Retrieves recipient information ```ts -async getAnticipations( recipientId: string, - page?: number, - size?: number, - status?: string, - timeframe?: string, - paymentDateSince?: string, - paymentDateUntil?: string, - createdSince?: string, - createdUntil?: string, -requestOptions?: RequestOptions): Promise> +async getRecipientByCode( code: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `recipientId` | `string` | Template, Required | Recipient id | -| `page` | `number \| undefined` | Query, Optional | Page number | -| `size` | `number \| undefined` | Query, Optional | Page size | -| `status` | `string \| undefined` | Query, Optional | Filter for anticipation status | -| `timeframe` | `string \| undefined` | Query, Optional | Filter for anticipation timeframe | -| `paymentDateSince` | `string \| undefined` | Query, Optional | Filter for start range for anticipation payment date | -| `paymentDateUntil` | `string \| undefined` | Query, Optional | Filter for end range for anticipation payment date | -| `createdSince` | `string \| undefined` | Query, Optional | Filter for start range for anticipation creation date | -| `createdUntil` | `string \| undefined` | Query, Optional | Filter for end range for anticipation creation date | +| `code` | `string` | Template, Required | Recipient code | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`ListAnticipationResponse`](../../doc/models/list-anticipation-response.md) +[`GetRecipientResponse`](../../doc/models/get-recipient-response.md) ## Example Usage ```ts -const recipientId = 'recipient_id0'; +const code = 'code8'; try { - const { result, ...httpResponse } = await recipientsController.getAnticipations(recipientId); + const { result, ...httpResponse } = await recipientsController.getRecipientByCode(code); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -719,12 +581,14 @@ try { ``` -# Get Recipient +# Update Automatic Anticipation Settings -Retrieves recipient information +Updates recipient metadata ```ts -async getRecipient( recipientId: string, +async updateAutomaticAnticipationSettings( recipientId: string, + request: UpdateAutomaticAnticipationSettingsRequest, + idempotencyKey?: string, requestOptions?: RequestOptions): Promise> ``` @@ -732,7 +596,9 @@ requestOptions?: RequestOptions): Promise> | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `recipientId` | `string` | Template, Required | Recipiend id | +| `recipientId` | `string` | Template, Required | Recipient id | +| `request` | [`UpdateAutomaticAnticipationSettingsRequest`](../../doc/models/update-automatic-anticipation-settings-request.md) | Body, Required | Metadata | +| `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type @@ -744,8 +610,13 @@ requestOptions?: RequestOptions): Promise> ```ts const recipientId = 'recipient_id0'; +const request: UpdateAutomaticAnticipationSettingsRequest = {}; + try { - const { result, ...httpResponse } = await recipientsController.getRecipient(recipientId); + const { result, ...httpResponse } = await recipientsController.updateAutomaticAnticipationSettings( + recipientId, + request +); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -757,33 +628,47 @@ try { ``` -# Get Balance +# Create Transfer -Get balance information for a recipient +Creates a transfer for a recipient ```ts -async getBalance( recipientId: string, -requestOptions?: RequestOptions): Promise> +async createTransfer( recipientId: string, + request: CreateTransferRequest, + idempotencyKey?: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `recipientId` | `string` | Template, Required | Recipient id | +| `recipientId` | `string` | Template, Required | Recipient Id | +| `request` | [`CreateTransferRequest`](../../doc/models/create-transfer-request.md) | Body, Required | Transfer data | +| `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetBalanceResponse`](../../doc/models/get-balance-response.md) +[`GetTransferResponse`](../../doc/models/get-transfer-response.md) ## Example Usage ```ts const recipientId = 'recipient_id0'; +const request: CreateTransferRequest = { + amount: 242, + metadata: { + 'key0': 'metadata3' + }, +}; + try { - const { result, ...httpResponse } = await recipientsController.getBalance(recipientId); + const { result, ...httpResponse } = await recipientsController.createTransfer( + recipientId, + request +); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -795,43 +680,56 @@ try { ``` -# Get Withdrawals +# Create Recipient -Gets a paginated list of transfers for the recipient +Creates a new recipient ```ts -async getWithdrawals( recipientId: string, - page?: number, - size?: number, - status?: string, - createdSince?: string, - createdUntil?: string, -requestOptions?: RequestOptions): Promise> +async createRecipient( request: CreateRecipientRequest, + idempotencyKey?: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `recipientId` | `string` | Template, Required | - | -| `page` | `number \| undefined` | Query, Optional | - | -| `size` | `number \| undefined` | Query, Optional | - | -| `status` | `string \| undefined` | Query, Optional | - | -| `createdSince` | `string \| undefined` | Query, Optional | - | -| `createdUntil` | `string \| undefined` | Query, Optional | - | +| `request` | [`CreateRecipientRequest`](../../doc/models/create-recipient-request.md) | Body, Required | Recipient data | +| `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`ListWithdrawals`](../../doc/models/list-withdrawals.md) +[`GetRecipientResponse`](../../doc/models/get-recipient-response.md) ## Example Usage ```ts -const recipientId = 'recipient_id0'; +const request: CreateRecipientRequest = { + defaultBankAccount: { + holderName: 'holder_name4', + holderType: 'holder_type0', + holderDocument: 'holder_document2', + bank: 'bank6', + branchNumber: 'branch_number4', + accountNumber: 'account_number8', + accountCheckDigit: 'account_check_digit4', + type: 'type2', + metadata: { + 'key0': 'metadata5', + 'key1': 'metadata4', + 'key2': 'metadata3' + }, + }, + metadata: { + 'key0': 'metadata3' + }, + code: 'code4', + paymentMode: 'bank_transfer', +}; try { - const { result, ...httpResponse } = await recipientsController.getWithdrawals(recipientId); + const { result, ...httpResponse } = await recipientsController.createRecipient(request); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -843,44 +741,75 @@ try { ``` -# Create Transfer +# Get Default Recipient -Creates a transfer for a recipient +```ts +async getDefaultRecipient(requestOptions?: RequestOptions): Promise> +``` + +## Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | + +## Response Type + +[`GetRecipientResponse`](../../doc/models/get-recipient-response.md) + +## Example Usage ```ts -async createTransfer( recipientId: string, - request: CreateTransferRequest, +try { + const { result, ...httpResponse } = await recipientsController.getDefaultRecipient(); + // Get more response info... + // const { statusCode, headers } = httpResponse; +} catch (error) { + if (error instanceof ApiError) { + const errors = error.result; + // const { statusCode, headers } = error; + } +} +``` + + +# Create Anticipation + +Creates an anticipation + +```ts +async createAnticipation( recipientId: string, + request: CreateAnticipationRequest, idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `recipientId` | `string` | Template, Required | Recipient Id | -| `request` | [`CreateTransferRequest`](../../doc/models/create-transfer-request.md) | Body, Required | Transfer data | +| `recipientId` | `string` | Template, Required | Recipient id | +| `request` | [`CreateAnticipationRequest`](../../doc/models/create-anticipation-request.md) | Body, Required | Anticipation data | | `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetTransferResponse`](../../doc/models/get-transfer-response.md) +[`GetAnticipationResponse`](../../doc/models/get-anticipation-response.md) ## Example Usage ```ts const recipientId = 'recipient_id0'; -const request: CreateTransferRequest = { +const request: CreateAnticipationRequest = { amount: 242, - metadata: { - 'key0': 'metadata3' - }, + timeframe: 'timeframe8', + paymentDate: '2016-03-13T12:52:32.123Z', }; try { - const { result, ...httpResponse } = await recipientsController.createTransfer( + const { result, ...httpResponse } = await recipientsController.createAnticipation( recipientId, request ); @@ -895,12 +824,63 @@ try { ``` -# Create Recipient +# Get Anticipation Limits -Creates a new recipient +Gets the anticipation limits for a recipient ```ts -async createRecipient( request: CreateRecipientRequest, +async getAnticipationLimits( recipientId: string, + timeframe: string, + paymentDate: string, +requestOptions?: RequestOptions): Promise> +``` + +## Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `recipientId` | `string` | Template, Required | Recipient id | +| `timeframe` | `string` | Query, Required | Timeframe | +| `paymentDate` | `string` | Query, Required | Anticipation payment date | +| `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | + +## Response Type + +[`GetAnticipationLimitResponse`](../../doc/models/get-anticipation-limit-response.md) + +## Example Usage + +```ts +const recipientId = 'recipient_id0'; + +const timeframe = 'timeframe2'; + +const paymentDate = '2016-03-13T12:52:32.123Z'; + +try { + const { result, ...httpResponse } = await recipientsController.getAnticipationLimits( + recipientId, + timeframe, + paymentDate +); + // Get more response info... + // const { statusCode, headers } = httpResponse; +} catch (error) { + if (error instanceof ApiError) { + const errors = error.result; + // const { statusCode, headers } = error; + } +} +``` + + +# Update Recipient Metadata + +Updates recipient metadata + +```ts +async updateRecipientMetadata( recipientId: string, + request: UpdateMetadataRequest, idempotencyKey?: string, requestOptions?: RequestOptions): Promise> ``` @@ -909,7 +889,8 @@ requestOptions?: RequestOptions): Promise> | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `request` | [`CreateRecipientRequest`](../../doc/models/create-recipient-request.md) | Body, Required | Recipient data | +| `recipientId` | `string` | Template, Required | Recipient id | +| `request` | [`UpdateMetadataRequest`](../../doc/models/update-metadata-request.md) | Body, Required | Metadata | | `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | @@ -920,31 +901,19 @@ requestOptions?: RequestOptions): Promise> ## Example Usage ```ts -const request: CreateRecipientRequest = { - defaultBankAccount: { - holderName: 'holder_name4', - holderType: 'holder_type0', - holderDocument: 'holder_document2', - bank: 'bank6', - branchNumber: 'branch_number4', - accountNumber: 'account_number8', - accountCheckDigit: 'account_check_digit4', - type: 'type2', - metadata: { - 'key0': 'metadata5', - 'key1': 'metadata4', - 'key2': 'metadata3' - }, - }, +const recipientId = 'recipient_id0'; + +const request: UpdateMetadataRequest = { metadata: { 'key0': 'metadata3' }, - code: 'code4', - paymentMode: 'bank_transfer', }; try { - const { result, ...httpResponse } = await recipientsController.createRecipient(request); + const { result, ...httpResponse } = await recipientsController.updateRecipientMetadata( + recipientId, + request +); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -956,33 +925,49 @@ try { ``` -# Get Recipient by Code +# Get Anticipations -Retrieves recipient information +Retrieves a paginated list of anticipations from a recipient ```ts -async getRecipientByCode( code: string, -requestOptions?: RequestOptions): Promise> +async getAnticipations( recipientId: string, + page?: number, + size?: number, + status?: string, + timeframe?: string, + paymentDateSince?: string, + paymentDateUntil?: string, + createdSince?: string, + createdUntil?: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `code` | `string` | Template, Required | Recipient code | +| `recipientId` | `string` | Template, Required | Recipient id | +| `page` | `number \| undefined` | Query, Optional | Page number | +| `size` | `number \| undefined` | Query, Optional | Page size | +| `status` | `string \| undefined` | Query, Optional | Filter for anticipation status | +| `timeframe` | `string \| undefined` | Query, Optional | Filter for anticipation timeframe | +| `paymentDateSince` | `string \| undefined` | Query, Optional | Filter for start range for anticipation payment date | +| `paymentDateUntil` | `string \| undefined` | Query, Optional | Filter for end range for anticipation payment date | +| `createdSince` | `string \| undefined` | Query, Optional | Filter for start range for anticipation creation date | +| `createdUntil` | `string \| undefined` | Query, Optional | Filter for end range for anticipation creation date | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetRecipientResponse`](../../doc/models/get-recipient-response.md) +[`ListAnticipationResponse`](../../doc/models/list-anticipation-response.md) ## Example Usage ```ts -const code = 'code8'; +const recipientId = 'recipient_id0'; try { - const { result, ...httpResponse } = await recipientsController.getRecipientByCode(code); + const { result, ...httpResponse } = await recipientsController.getAnticipations(recipientId); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -994,27 +979,43 @@ try { ``` -# Get Default Recipient +# Get Withdrawals + +Gets a paginated list of transfers for the recipient ```ts -async getDefaultRecipient(requestOptions?: RequestOptions): Promise> +async getWithdrawals( recipientId: string, + page?: number, + size?: number, + status?: string, + createdSince?: string, + createdUntil?: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | +| `recipientId` | `string` | Template, Required | - | +| `page` | `number \| undefined` | Query, Optional | - | +| `size` | `number \| undefined` | Query, Optional | - | +| `status` | `string \| undefined` | Query, Optional | - | +| `createdSince` | `string \| undefined` | Query, Optional | - | +| `createdUntil` | `string \| undefined` | Query, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetRecipientResponse`](../../doc/models/get-recipient-response.md) +[`ListWithdrawals`](../../doc/models/list-withdrawals.md) ## Example Usage ```ts +const recipientId = 'recipient_id0'; + try { - const { result, ...httpResponse } = await recipientsController.getDefaultRecipient(); + const { result, ...httpResponse } = await recipientsController.getWithdrawals(recipientId); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -1063,3 +1064,52 @@ try { } ``` + +# Update Recipient Code + +Updates recipient code + +```ts +async updateRecipientCode( recipientId: string, + request: UpdateRecipientCodeRequest, + idempotencyKey?: string, +requestOptions?: RequestOptions): Promise> +``` + +## Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `recipientId` | `string` | Template, Required | Recipient id | +| `request` | [`UpdateRecipientCodeRequest`](../../doc/models/update-recipient-code-request.md) | Body, Required | UpdateRecipientCodeRequest | +| `idempotencyKey` | `string \| undefined` | Header, Optional | - | +| `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | + +## Response Type + +[`GetRecipientResponse`](../../doc/models/get-recipient-response.md) + +## Example Usage + +```ts +const recipientId = 'recipient_id0'; + +const request: UpdateRecipientCodeRequest = { + code: 'code4', +}; + +try { + const { result, ...httpResponse } = await recipientsController.updateRecipientCode( + recipientId, + request +); + // Get more response info... + // const { statusCode, headers } = httpResponse; +} catch (error) { + if (error instanceof ApiError) { + const errors = error.result; + // const { statusCode, headers } = error; + } +} +``` + diff --git a/doc/controllers/subscriptions.md b/doc/controllers/subscriptions.md index 8d9036e..6fc8cf6 100644 --- a/doc/controllers/subscriptions.md +++ b/doc/controllers/subscriptions.md @@ -10,71 +10,85 @@ const subscriptionsController = new SubscriptionsController(client); ## Methods -* [Renew Subscription](../../doc/controllers/subscriptions.md#renew-subscription) * [Update Subscription Card](../../doc/controllers/subscriptions.md#update-subscription-card) -* [Delete Usage](../../doc/controllers/subscriptions.md#delete-usage) * [Create Discount](../../doc/controllers/subscriptions.md#create-discount) -* [Create an Usage](../../doc/controllers/subscriptions.md#create-an-usage) -* [Update Current Cycle Status](../../doc/controllers/subscriptions.md#update-current-cycle-status) +* [Update Subscription Billing Date](../../doc/controllers/subscriptions.md#update-subscription-billing-date) +* [Update Subscription Start At](../../doc/controllers/subscriptions.md#update-subscription-start-at) +* [Get Subscription](../../doc/controllers/subscriptions.md#get-subscription) +* [Get Usages](../../doc/controllers/subscriptions.md#get-usages) +* [Update Latest Period End At](../../doc/controllers/subscriptions.md#update-latest-period-end-at) * [Delete Discount](../../doc/controllers/subscriptions.md#delete-discount) -* [Get Subscription Items](../../doc/controllers/subscriptions.md#get-subscription-items) * [Update Subscription Payment Method](../../doc/controllers/subscriptions.md#update-subscription-payment-method) +* [Cancel Subscription](../../doc/controllers/subscriptions.md#cancel-subscription) +* [Create Subscription](../../doc/controllers/subscriptions.md#create-subscription) +* [Update Subscription Affiliation Id](../../doc/controllers/subscriptions.md#update-subscription-affiliation-id) +* [Update Subscription Minium Price](../../doc/controllers/subscriptions.md#update-subscription-minium-price) +* [Get Subscription Cycle by Id](../../doc/controllers/subscriptions.md#get-subscription-cycle-by-id) +* [Get Usage Report](../../doc/controllers/subscriptions.md#get-usage-report) +* [Renew Subscription](../../doc/controllers/subscriptions.md#renew-subscription) +* [Delete Usage](../../doc/controllers/subscriptions.md#delete-usage) +* [Create an Usage](../../doc/controllers/subscriptions.md#create-an-usage) +* [Update Current Cycle Status](../../doc/controllers/subscriptions.md#update-current-cycle-status) * [Get Subscription Item](../../doc/controllers/subscriptions.md#get-subscription-item) +* [Get Increment by Id](../../doc/controllers/subscriptions.md#get-increment-by-id) +* [Delete Increment](../../doc/controllers/subscriptions.md#delete-increment) +* [Get Discounts](../../doc/controllers/subscriptions.md#get-discounts) +* [Update Subscription Due Days](../../doc/controllers/subscriptions.md#update-subscription-due-days) +* [Create Subscription Item](../../doc/controllers/subscriptions.md#create-subscription-item) +* [Update Split Subscription](../../doc/controllers/subscriptions.md#update-split-subscription) +* [Get Subscription Items](../../doc/controllers/subscriptions.md#get-subscription-items) * [Get Subscriptions](../../doc/controllers/subscriptions.md#get-subscriptions) -* [Cancel Subscription](../../doc/controllers/subscriptions.md#cancel-subscription) * [Create Increment](../../doc/controllers/subscriptions.md#create-increment) * [Create Usage](../../doc/controllers/subscriptions.md#create-usage) * [Get Discount by Id](../../doc/controllers/subscriptions.md#get-discount-by-id) -* [Create Subscription](../../doc/controllers/subscriptions.md#create-subscription) -* [Get Increment by Id](../../doc/controllers/subscriptions.md#get-increment-by-id) -* [Update Subscription Affiliation Id](../../doc/controllers/subscriptions.md#update-subscription-affiliation-id) * [Update Subscription Metadata](../../doc/controllers/subscriptions.md#update-subscription-metadata) -* [Delete Increment](../../doc/controllers/subscriptions.md#delete-increment) * [Get Subscription Cycles](../../doc/controllers/subscriptions.md#get-subscription-cycles) -* [Get Discounts](../../doc/controllers/subscriptions.md#get-discounts) -* [Update Subscription Billing Date](../../doc/controllers/subscriptions.md#update-subscription-billing-date) * [Delete Subscription Item](../../doc/controllers/subscriptions.md#delete-subscription-item) * [Get Increments](../../doc/controllers/subscriptions.md#get-increments) -* [Update Subscription Due Days](../../doc/controllers/subscriptions.md#update-subscription-due-days) -* [Update Subscription Start At](../../doc/controllers/subscriptions.md#update-subscription-start-at) * [Update Subscription Item](../../doc/controllers/subscriptions.md#update-subscription-item) -* [Create Subscription Item](../../doc/controllers/subscriptions.md#create-subscription-item) -* [Get Subscription](../../doc/controllers/subscriptions.md#get-subscription) -* [Get Usages](../../doc/controllers/subscriptions.md#get-usages) -* [Update Latest Period End At](../../doc/controllers/subscriptions.md#update-latest-period-end-at) -* [Update Subscription Minium Price](../../doc/controllers/subscriptions.md#update-subscription-minium-price) -* [Get Subscription Cycle by Id](../../doc/controllers/subscriptions.md#get-subscription-cycle-by-id) -* [Get Usage Report](../../doc/controllers/subscriptions.md#get-usage-report) -* [Update Split Subscription](../../doc/controllers/subscriptions.md#update-split-subscription) -# Renew Subscription +# Update Subscription Card + +Updates the credit card from a subscription ```ts -async renewSubscription( subscriptionId: string, +async updateSubscriptionCard( subscriptionId: string, + request: UpdateSubscriptionCardRequest, idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | - | +| `subscriptionId` | `string` | Template, Required | Subscription id | +| `request` | [`UpdateSubscriptionCardRequest`](../../doc/models/update-subscription-card-request.md) | Body, Required | Request for updating a card | | `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetPeriodResponse`](../../doc/models/get-period-response.md) +[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) ## Example Usage ```ts const subscriptionId = 'subscription_id0'; +const request: UpdateSubscriptionCardRequest = { + card: { + type: 'credit', + }, + cardId: 'card_id2', +}; + try { - const { result, ...httpResponse } = await subscriptionsController.renewSubscription(subscriptionId); + const { result, ...httpResponse } = await subscriptionsController.updateSubscriptionCard( + subscriptionId, + request +); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -86,15 +100,15 @@ try { ``` -# Update Subscription Card +# Create Discount -Updates the credit card from a subscription +Creates a discount ```ts -async updateSubscriptionCard( subscriptionId: string, - request: UpdateSubscriptionCardRequest, +async createDiscount( subscriptionId: string, + request: CreateDiscountRequest, idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> +requestOptions?: RequestOptions): Promise> ``` ## Parameters @@ -102,28 +116,27 @@ requestOptions?: RequestOptions): Promise> | 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 | +| `request` | [`CreateDiscountRequest`](../../doc/models/create-discount-request.md) | Body, Required | Request for creating a discount | | `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) +[`GetDiscountResponse`](../../doc/models/get-discount-response.md) ## Example Usage ```ts const subscriptionId = 'subscription_id0'; -const request: UpdateSubscriptionCardRequest = { - card: { - type: 'credit', - }, - cardId: 'card_id2', +const request: CreateDiscountRequest = { + value: 185.28, + discountType: 'discount_type4', + itemId: 'item_id6', }; try { - const { result, ...httpResponse } = await subscriptionsController.updateSubscriptionCard( + const { result, ...httpResponse } = await subscriptionsController.createDiscount( subscriptionId, request ); @@ -138,16 +151,15 @@ try { ``` -# Delete Usage +# Update Subscription Billing Date -Deletes a usage +Updates the billing date from a subscription ```ts -async deleteUsage( subscriptionId: string, - itemId: string, - usageId: string, +async updateSubscriptionBillingDate( subscriptionId: string, + request: UpdateSubscriptionBillingDateRequest, idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> +requestOptions?: RequestOptions): Promise> ``` ## Parameters @@ -155,29 +167,27 @@ requestOptions?: RequestOptions): Promise> | 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` | [`UpdateSubscriptionBillingDateRequest`](../../doc/models/update-subscription-billing-date-request.md) | Body, Required | Request for updating the subscription billing date | | `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetUsageResponse`](../../doc/models/get-usage-response.md) +[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) ## Example Usage ```ts const subscriptionId = 'subscription_id0'; -const itemId = 'item_id0'; - -const usageId = 'usage_id0'; +const request: UpdateSubscriptionBillingDateRequest = { + nextBillingAt: '2016-03-13T12:52:32.123Z', +}; try { - const { result, ...httpResponse } = await subscriptionsController.deleteUsage( + const { result, ...httpResponse } = await subscriptionsController.updateSubscriptionBillingDate( subscriptionId, - itemId, - usageId + request ); // Get more response info... // const { statusCode, headers } = httpResponse; @@ -190,43 +200,41 @@ try { ``` -# Create Discount +# Update Subscription Start At -Creates a discount +Updates the start at date from a subscription ```ts -async createDiscount( subscriptionId: string, - request: CreateDiscountRequest, +async updateSubscriptionStartAt( subscriptionId: string, + request: UpdateSubscriptionStartAtRequest, idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> +requestOptions?: RequestOptions): Promise> ``` ## 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 | The subscription id | +| `request` | [`UpdateSubscriptionStartAtRequest`](../../doc/models/update-subscription-start-at-request.md) | Body, Required | Request for updating the subscription start date | | `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetDiscountResponse`](../../doc/models/get-discount-response.md) +[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) ## Example Usage ```ts const subscriptionId = 'subscription_id0'; -const request: CreateDiscountRequest = { - value: 185.28, - discountType: 'discount_type4', - itemId: 'item_id6', +const request: UpdateSubscriptionStartAtRequest = { + startAt: '2016-03-13T12:52:32.123Z', }; try { - const { result, ...httpResponse } = await subscriptionsController.createDiscount( + const { result, ...httpResponse } = await subscriptionsController.updateSubscriptionStartAt( subscriptionId, request ); @@ -241,15 +249,13 @@ try { ``` -# Create an Usage +# Get Subscription -Create Usage +Gets a subscription ```ts -async createAnUsage( subscriptionId: string, - itemId: string, - idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> +async getSubscription( subscriptionId: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters @@ -257,13 +263,63 @@ requestOptions?: RequestOptions): Promise> | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `subscriptionId` | `string` | Template, Required | Subscription id | -| `itemId` | `string` | Template, Required | Item id | -| `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetUsageResponse`](../../doc/models/get-usage-response.md) +[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) + +## Example Usage + +```ts +const subscriptionId = 'subscription_id0'; + +try { + const { result, ...httpResponse } = await subscriptionsController.getSubscription(subscriptionId); + // Get more response info... + // const { statusCode, headers } = httpResponse; +} catch (error) { + if (error instanceof ApiError) { + const errors = error.result; + // const { statusCode, headers } = error; + } +} +``` + + +# Get Usages + +Lists all usages from a subscription item + +```ts +async getUsages( subscriptionId: string, + itemId: string, + page?: number, + size?: number, + code?: string, + group?: string, + usedSince?: string, + usedUntil?: string, +requestOptions?: RequestOptions): Promise> +``` + +## Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `subscriptionId` | `string` | Template, Required | The subscription id | +| `itemId` | `string` | Template, Required | The subscription item id | +| `page` | `number \| undefined` | Query, Optional | Page number | +| `size` | `number \| undefined` | Query, Optional | Page size | +| `code` | `string \| undefined` | Query, Optional | Identification code in the client system | +| `group` | `string \| undefined` | Query, Optional | Identification group in the client system | +| `usedSince` | `string \| undefined` | Query, Optional | - | +| `usedUntil` | `string \| undefined` | Query, Optional | - | +| `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | + +## Response Type + +[`ListUsagesResponse`](../../doc/models/list-usages-response.md) ## Example Usage @@ -273,7 +329,7 @@ const subscriptionId = 'subscription_id0'; const itemId = 'item_id0'; try { - const { result, ...httpResponse } = await subscriptionsController.createAnUsage( + const { result, ...httpResponse } = await subscriptionsController.getUsages( subscriptionId, itemId ); @@ -288,39 +344,37 @@ try { ``` -# Update Current Cycle Status +# Update Latest Period End At ```ts -async updateCurrentCycleStatus( subscriptionId: string, - request: UpdateCurrentCycleStatusRequest, +async updateLatestPeriodEndAt( subscriptionId: string, + request: UpdateCurrentCycleEndDateRequest, idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> +requestOptions?: RequestOptions): Promise> ``` ## 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 | - | +| `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 \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -`void` +[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) ## Example Usage ```ts const subscriptionId = 'subscription_id0'; -const request: UpdateCurrentCycleStatusRequest = { - status: 'status8', -}; +const request: UpdateCurrentCycleEndDateRequest = {}; try { - const { result, ...httpResponse } = await subscriptionsController.updateCurrentCycleStatus( + const { result, ...httpResponse } = await subscriptionsController.updateLatestPeriodEndAt( subscriptionId, request ); @@ -382,49 +436,48 @@ try { ``` -# Get Subscription Items +# Update Subscription Payment Method -Get Subscription Items +Updates the payment method from a subscription ```ts -async getSubscriptionItems( subscriptionId: string, - page?: number, - size?: number, - name?: string, - code?: string, - status?: string, - description?: string, - createdSince?: string, - createdUntil?: string, -requestOptions?: RequestOptions): Promise> +async updateSubscriptionPaymentMethod( subscriptionId: string, + request: UpdateSubscriptionPaymentMethodRequest, + idempotencyKey?: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | The subscription id | -| `page` | `number \| undefined` | Query, Optional | Page number | -| `size` | `number \| undefined` | Query, Optional | Page size | -| `name` | `string \| undefined` | Query, Optional | The item name | -| `code` | `string \| undefined` | Query, Optional | Identification code in the client system | -| `status` | `string \| undefined` | Query, Optional | The item statis | -| `description` | `string \| undefined` | Query, Optional | The item description | -| `createdSince` | `string \| undefined` | Query, Optional | Filter for item's creation date start range | -| `createdUntil` | `string \| undefined` | Query, Optional | Filter for item's creation date end range | +| `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 \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`ListSubscriptionItemsResponse`](../../doc/models/list-subscription-items-response.md) +[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) ## Example Usage ```ts const subscriptionId = 'subscription_id0'; +const request: UpdateSubscriptionPaymentMethodRequest = { + paymentMethod: 'payment_method4', + cardId: 'card_id2', + card: { + type: 'credit', + }, +}; + try { - const { result, ...httpResponse } = await subscriptionsController.getSubscriptionItems(subscriptionId); + const { result, ...httpResponse } = await subscriptionsController.updateSubscriptionPaymentMethod( + subscriptionId, + request +); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -436,13 +489,13 @@ try { ``` -# Update Subscription Payment Method +# Cancel Subscription -Updates the payment method from a subscription +Cancels a subscription ```ts -async updateSubscriptionPaymentMethod( subscriptionId: string, - request: UpdateSubscriptionPaymentMethodRequest, +async cancelSubscription( subscriptionId: string, + request?: CreateCancelSubscriptionRequest, idempotencyKey?: string, requestOptions?: RequestOptions): Promise> ``` @@ -452,7 +505,7 @@ requestOptions?: RequestOptions): Promise> | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `subscriptionId` | `string` | Template, Required | Subscription id | -| `request` | [`UpdateSubscriptionPaymentMethodRequest`](../../doc/models/update-subscription-payment-method-request.md) | Body, Required | Request for updating the paymentmethod from a subscription | +| `request` | [`CreateCancelSubscriptionRequest \| undefined`](../../doc/models/create-cancel-subscription-request.md) | Body, Optional | Request for cancelling a subscription | | `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | @@ -465,16 +518,12 @@ requestOptions?: RequestOptions): Promise> ```ts const subscriptionId = 'subscription_id0'; -const request: UpdateSubscriptionPaymentMethodRequest = { - paymentMethod: 'payment_method4', - cardId: 'card_id2', - card: { - type: 'credit', - }, +const request: CreateCancelSubscriptionRequest = { + cancelPendingInvoices: true, }; try { - const { result, ...httpResponse } = await subscriptionsController.updateSubscriptionPaymentMethod( + const { result, ...httpResponse } = await subscriptionsController.cancelSubscription( subscriptionId, request ); @@ -489,40 +538,129 @@ try { ``` -# Get Subscription Item +# Create Subscription -Get Subscription Item +Creates a new subscription ```ts -async getSubscriptionItem( subscriptionId: string, - itemId: string, -requestOptions?: RequestOptions): Promise> +async createSubscription( body: CreateSubscriptionRequest, + idempotencyKey?: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | Subscription Id | -| `itemId` | `string` | Template, Required | Item id | +| `body` | [`CreateSubscriptionRequest`](../../doc/models/create-subscription-request.md) | Body, Required | Request for creating a subscription | +| `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetSubscriptionItemResponse`](../../doc/models/get-subscription-item-response.md) +[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) ## Example Usage ```ts -const subscriptionId = 'subscription_id0'; - -const itemId = 'item_id0'; +const body: CreateSubscriptionRequest = { + customer: { + name: 'Tony Stark', + email: 'email6', + document: 'document6', + type: 'type0', + address: { + street: 'street6', + number: 'number4', + zipCode: 'zip_code0', + neighborhood: 'neighborhood2', + city: 'city6', + state: 'state2', + country: 'country0', + complement: 'complement2', + line1: 'line_10', + line2: 'line_24', + }, + metadata: { + 'key0': 'metadata3' + }, + phones: {}, + code: 'code8', + }, + card: { + type: 'credit', + }, + code: 'code4', + paymentMethod: 'payment_method4', + billingType: 'billing_type0', + statementDescriptor: 'statement_descriptor6', + description: 'description4', + currency: 'currency6', + interval: 'interval6', + intervalCount: 170, + pricingScheme: { + schemeType: 'scheme_type8', + }, + items: [ + { + description: 'description2', + pricingScheme: { + schemeType: 'scheme_type8', + }, + id: 'id8', + planItemId: 'plan_item_id8', + discounts: [ + { + value: 90.66, + discountType: 'discount_type2', + itemId: 'item_id4', + } + ], + name: 'name8', + } + ], + shipping: { + amount: 52, + description: 'description6', + recipientName: 'recipient_name2', + recipientPhone: 'recipient_phone6', + addressId: 'address_id6', + address: { + street: 'street6', + number: 'number4', + zipCode: 'zip_code0', + neighborhood: 'neighborhood2', + city: 'city6', + state: 'state2', + country: 'country0', + complement: 'complement2', + line1: 'line_10', + line2: 'line_24', + }, + type: 'type6', + }, + discounts: [ + { + value: 90.66, + discountType: 'discount_type2', + itemId: 'item_id4', + } + ], + metadata: { + 'key0': 'metadata7', + 'key1': 'metadata8' + }, + increments: [ + { + value: 252.86, + incrementType: 'increment_type6', + itemId: 'item_id6', + } + ], +}; try { - const { result, ...httpResponse } = await subscriptionsController.getSubscriptionItem( - subscriptionId, - itemId -); + const { result, ...httpResponse } = await subscriptionsController.createSubscription(body); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -534,53 +672,42 @@ try { ``` -# Get Subscriptions - -Gets all subscriptions +# Update Subscription Affiliation Id ```ts -async getSubscriptions( page?: number, - size?: number, - code?: string, - billingType?: string, - customerId?: string, - planId?: string, - cardId?: string, - status?: string, - nextBillingSince?: string, - nextBillingUntil?: string, - createdSince?: string, - createdUntil?: string, -requestOptions?: RequestOptions): Promise> +async updateSubscriptionAffiliationId( subscriptionId: string, + request: UpdateSubscriptionAffiliationIdRequest, + idempotencyKey?: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `page` | `number \| undefined` | Query, Optional | Page number | -| `size` | `number \| undefined` | Query, Optional | Page size | -| `code` | `string \| undefined` | Query, Optional | Filter for subscription's code | -| `billingType` | `string \| undefined` | Query, Optional | Filter for subscription's billing type | -| `customerId` | `string \| undefined` | Query, Optional | Filter for subscription's customer id | -| `planId` | `string \| undefined` | Query, Optional | Filter for subscription's plan id | -| `cardId` | `string \| undefined` | Query, Optional | Filter for subscription's card id | -| `status` | `string \| undefined` | Query, Optional | Filter for subscription's status | -| `nextBillingSince` | `string \| undefined` | Query, Optional | Filter for subscription's next billing date start range | -| `nextBillingUntil` | `string \| undefined` | Query, Optional | Filter for subscription's next billing date end range | -| `createdSince` | `string \| undefined` | Query, Optional | Filter for subscription's creation date start range | -| `createdUntil` | `string \| undefined` | Query, Optional | Filter for subscriptions creation date end range | +| `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 \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`ListSubscriptionsResponse`](../../doc/models/list-subscriptions-response.md) +[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) ## Example Usage ```ts +const subscriptionId = 'subscription_id0'; + +const request: UpdateSubscriptionAffiliationIdRequest = { + gatewayAffiliationId: 'gateway_affiliation_id2', +}; + try { - const { result, ...httpResponse } = await subscriptionsController.getSubscriptions(); + const { result, ...httpResponse } = await subscriptionsController.updateSubscriptionAffiliationId( + subscriptionId, + request +); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -592,13 +719,13 @@ try { ``` -# Cancel Subscription +# Update Subscription Minium Price -Cancels a subscription +Atualização do valor mínimo da assinatura ```ts -async cancelSubscription( subscriptionId: string, - request?: CreateCancelSubscriptionRequest, +async updateSubscriptionMiniumPrice( subscriptionId: string, + request: UpdateSubscriptionMinimumPriceRequest, idempotencyKey?: string, requestOptions?: RequestOptions): Promise> ``` @@ -607,8 +734,8 @@ requestOptions?: RequestOptions): Promise> | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | Subscription id | -| `request` | [`CreateCancelSubscriptionRequest \| undefined`](../../doc/models/create-cancel-subscription-request.md) | Body, Optional | Request for cancelling a subscription | +| `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 \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | @@ -621,12 +748,10 @@ requestOptions?: RequestOptions): Promise> ```ts const subscriptionId = 'subscription_id0'; -const request: CreateCancelSubscriptionRequest = { - cancelPendingInvoices: true, -}; +const request: UpdateSubscriptionMinimumPriceRequest = {}; try { - const { result, ...httpResponse } = await subscriptionsController.cancelSubscription( + const { result, ...httpResponse } = await subscriptionsController.updateSubscriptionMiniumPrice( subscriptionId, request ); @@ -641,45 +766,37 @@ try { ``` -# Create Increment - -Creates a increment +# Get Subscription Cycle by Id ```ts -async createIncrement( subscriptionId: string, - request: CreateIncrementRequest, - idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> +async getSubscriptionCycleById( subscriptionId: string, + cycleId: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | Subscription id | -| `request` | [`CreateIncrementRequest`](../../doc/models/create-increment-request.md) | Body, Required | Request for creating a increment | -| `idempotencyKey` | `string \| undefined` | Header, Optional | - | +| `subscriptionId` | `string` | Template, Required | The subscription id | +| `cycleId` | `string` | Template, Required | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetIncrementResponse`](../../doc/models/get-increment-response.md) +[`GetPeriodResponse`](../../doc/models/get-period-response.md) ## Example Usage ```ts const subscriptionId = 'subscription_id0'; -const request: CreateIncrementRequest = { - value: 185.28, - incrementType: 'increment_type8', - itemId: 'item_id6', -}; +const cycleId = 'cycleId0'; try { - const { result, ...httpResponse } = await subscriptionsController.createIncrement( + const { result, ...httpResponse } = await subscriptionsController.getSubscriptionCycleById( subscriptionId, - request + cycleId ); // Get more response info... // const { statusCode, headers } = httpResponse; @@ -692,50 +809,37 @@ try { ``` -# Create Usage - -Creates a usage +# Get Usage Report ```ts -async createUsage( subscriptionId: string, - itemId: string, - body: CreateUsageRequest, - idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> +async getUsageReport( subscriptionId: string, + periodId: string, +requestOptions?: RequestOptions): Promise> ``` ## 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 \| undefined` | Header, Optional | - | +| `subscriptionId` | `string` | Template, Required | The subscription Id | +| `periodId` | `string` | Template, Required | The period Id | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetUsageResponse`](../../doc/models/get-usage-response.md) +[`GetUsageReportResponse`](../../doc/models/get-usage-report-response.md) ## Example Usage ```ts const subscriptionId = 'subscription_id0'; -const itemId = 'item_id0'; - -const body: CreateUsageRequest = { - quantity: 156, - description: 'description4', - usedAt: '2016-03-13T12:52:32.123Z', -}; +const periodId = 'period_id0'; try { - const { result, ...httpResponse } = await subscriptionsController.createUsage( + const { result, ...httpResponse } = await subscriptionsController.getUsageReport( subscriptionId, - itemId, - body + periodId ); // Get more response info... // const { statusCode, headers } = httpResponse; @@ -748,38 +852,33 @@ try { ``` -# Get Discount by Id +# Renew Subscription ```ts -async getDiscountById( subscriptionId: string, - discountId: string, -requestOptions?: RequestOptions): Promise> +async renewSubscription( subscriptionId: string, + idempotencyKey?: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | The subscription id | -| `discountId` | `string` | Template, Required | - | +| `subscriptionId` | `string` | Template, Required | - | +| `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetDiscountResponse`](../../doc/models/get-discount-response.md) +[`GetPeriodResponse`](../../doc/models/get-period-response.md) ## Example Usage ```ts const subscriptionId = 'subscription_id0'; -const discountId = 'discountId0'; - try { - const { result, ...httpResponse } = await subscriptionsController.getDiscountById( - subscriptionId, - discountId -); + const { result, ...httpResponse } = await subscriptionsController.renewSubscription(subscriptionId); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -791,129 +890,47 @@ try { ``` -# Create Subscription +# Delete Usage -Creates a new subscription +Deletes a usage ```ts -async createSubscription( body: CreateSubscriptionRequest, +async deleteUsage( subscriptionId: string, + itemId: string, + usageId: string, idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `body` | [`CreateSubscriptionRequest`](../../doc/models/create-subscription-request.md) | Body, Required | Request for creating a subscription | +| `subscriptionId` | `string` | Template, Required | The subscription id | +| `itemId` | `string` | Template, Required | The subscription item id | +| `usageId` | `string` | Template, Required | The usage id | | `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) +[`GetUsageResponse`](../../doc/models/get-usage-response.md) ## Example Usage ```ts -const body: CreateSubscriptionRequest = { - customer: { - name: 'Tony Stark', - email: 'email6', - document: 'document6', - type: 'type0', - address: { - street: 'street6', - number: 'number4', - zipCode: 'zip_code0', - neighborhood: 'neighborhood2', - city: 'city6', - state: 'state2', - country: 'country0', - complement: 'complement2', - line1: 'line_10', - line2: 'line_24', - }, - metadata: { - 'key0': 'metadata3' - }, - phones: {}, - code: 'code8', - }, - card: { - type: 'credit', - }, - code: 'code4', - paymentMethod: 'payment_method4', - billingType: 'billing_type0', - statementDescriptor: 'statement_descriptor6', - description: 'description4', - currency: 'currency6', - interval: 'interval6', - intervalCount: 170, - pricingScheme: { - schemeType: 'scheme_type8', - }, - items: [ - { - description: 'description2', - pricingScheme: { - schemeType: 'scheme_type8', - }, - id: 'id8', - planItemId: 'plan_item_id8', - discounts: [ - { - value: 90.66, - discountType: 'discount_type2', - itemId: 'item_id4', - } - ], - name: 'name8', - } - ], - shipping: { - amount: 52, - description: 'description6', - recipientName: 'recipient_name2', - recipientPhone: 'recipient_phone6', - addressId: 'address_id6', - address: { - street: 'street6', - number: 'number4', - zipCode: 'zip_code0', - neighborhood: 'neighborhood2', - city: 'city6', - state: 'state2', - country: 'country0', - complement: 'complement2', - line1: 'line_10', - line2: 'line_24', - }, - type: 'type6', - }, - discounts: [ - { - value: 90.66, - discountType: 'discount_type2', - itemId: 'item_id4', - } - ], - metadata: { - 'key0': 'metadata7', - 'key1': 'metadata8' - }, - increments: [ - { - value: 252.86, - incrementType: 'increment_type6', - itemId: 'item_id6', - } - ], -}; +const subscriptionId = 'subscription_id0'; + +const itemId = 'item_id0'; + +const usageId = 'usage_id0'; try { - const { result, ...httpResponse } = await subscriptionsController.createSubscription(body); + const { result, ...httpResponse } = await subscriptionsController.deleteUsage( + subscriptionId, + itemId, + usageId +); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -925,37 +942,41 @@ try { ``` -# Get Increment by Id +# Create an Usage + +Create Usage ```ts -async getIncrementById( subscriptionId: string, - incrementId: string, -requestOptions?: RequestOptions): Promise> +async createAnUsage( subscriptionId: string, + itemId: string, + idempotencyKey?: string, +requestOptions?: RequestOptions): Promise> ``` ## 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 | +| `itemId` | `string` | Template, Required | Item id | +| `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetIncrementResponse`](../../doc/models/get-increment-response.md) +[`GetUsageResponse`](../../doc/models/get-usage-response.md) ## Example Usage ```ts const subscriptionId = 'subscription_id0'; -const incrementId = 'increment_id8'; +const itemId = 'item_id0'; try { - const { result, ...httpResponse } = await subscriptionsController.getIncrementById( + const { result, ...httpResponse } = await subscriptionsController.createAnUsage( subscriptionId, - incrementId + itemId ); // Get more response info... // const { statusCode, headers } = httpResponse; @@ -968,39 +989,39 @@ try { ``` -# Update Subscription Affiliation Id +# Update Current Cycle Status ```ts -async updateSubscriptionAffiliationId( subscriptionId: string, - request: UpdateSubscriptionAffiliationIdRequest, +async updateCurrentCycleStatus( subscriptionId: string, + request: UpdateCurrentCycleStatusRequest, idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> +requestOptions?: RequestOptions): Promise> ``` ## 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 | +| `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 \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) +`void` ## Example Usage ```ts const subscriptionId = 'subscription_id0'; -const request: UpdateSubscriptionAffiliationIdRequest = { - gatewayAffiliationId: 'gateway_affiliation_id2', +const request: UpdateCurrentCycleStatusRequest = { + status: 'status8', }; try { - const { result, ...httpResponse } = await subscriptionsController.updateSubscriptionAffiliationId( + const { result, ...httpResponse } = await subscriptionsController.updateCurrentCycleStatus( subscriptionId, request ); @@ -1015,45 +1036,39 @@ try { ``` -# Update Subscription Metadata +# Get Subscription Item -Updates the metadata from a subscription +Get Subscription Item ```ts -async updateSubscriptionMetadata( subscriptionId: string, - request: UpdateMetadataRequest, - idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> +async getSubscriptionItem( subscriptionId: string, + itemId: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | 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 | -| `idempotencyKey` | `string \| undefined` | Header, Optional | - | +| `subscriptionId` | `string` | Template, Required | Subscription Id | +| `itemId` | `string` | Template, Required | Item id | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) +[`GetSubscriptionItemResponse`](../../doc/models/get-subscription-item-response.md) ## Example Usage ```ts const subscriptionId = 'subscription_id0'; -const request: UpdateMetadataRequest = { - metadata: { - 'key0': 'metadata3' - }, -}; +const itemId = 'item_id0'; try { - const { result, ...httpResponse } = await subscriptionsController.updateSubscriptionMetadata( + const { result, ...httpResponse } = await subscriptionsController.getSubscriptionItem( subscriptionId, - request + itemId ); // Get more response info... // const { statusCode, headers } = httpResponse; @@ -1066,14 +1081,11 @@ try { ``` -# Delete Increment - -Deletes a increment +# Get Increment by Id ```ts -async deleteIncrement( subscriptionId: string, +async getIncrementById( subscriptionId: string, incrementId: string, - idempotencyKey?: string, requestOptions?: RequestOptions): Promise> ``` @@ -1081,9 +1093,8 @@ requestOptions?: RequestOptions): Promise> | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | Subscription id | -| `incrementId` | `string` | Template, Required | Increment id | -| `idempotencyKey` | `string \| undefined` | Header, Optional | - | +| `subscriptionId` | `string` | Template, Required | The subscription Id | +| `incrementId` | `string` | Template, Required | The increment Id | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type @@ -1098,7 +1109,7 @@ const subscriptionId = 'subscription_id0'; const incrementId = 'increment_id8'; try { - const { result, ...httpResponse } = await subscriptionsController.deleteIncrement( + const { result, ...httpResponse } = await subscriptionsController.getIncrementById( subscriptionId, incrementId ); @@ -1113,42 +1124,41 @@ try { ``` -# Get Subscription Cycles +# Delete Increment + +Deletes a increment ```ts -async getSubscriptionCycles( subscriptionId: string, - page: string, - size: string, -requestOptions?: RequestOptions): Promise> +async deleteIncrement( subscriptionId: string, + incrementId: string, + idempotencyKey?: string, +requestOptions?: RequestOptions): Promise> ``` ## 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 | Subscription id | +| `incrementId` | `string` | Template, Required | Increment id | +| `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`ListCyclesResponse`](../../doc/models/list-cycles-response.md) +[`GetIncrementResponse`](../../doc/models/get-increment-response.md) ## Example Usage ```ts const subscriptionId = 'subscription_id0'; -const page = 'page8'; - -const size = 'size0'; +const incrementId = 'increment_id8'; try { - const { result, ...httpResponse } = await subscriptionsController.getSubscriptionCycles( + const { result, ...httpResponse } = await subscriptionsController.deleteIncrement( subscriptionId, - page, - size + incrementId ); // Get more response info... // const { statusCode, headers } = httpResponse; @@ -1209,13 +1219,13 @@ try { ``` -# Update Subscription Billing Date +# Update Subscription Due Days -Updates the billing date from a subscription +Updates the boleto due days from a subscription ```ts -async updateSubscriptionBillingDate( subscriptionId: string, - request: UpdateSubscriptionBillingDateRequest, +async updateSubscriptionDueDays( subscriptionId: string, + request: UpdateSubscriptionDueDaysRequest, idempotencyKey?: string, requestOptions?: RequestOptions): Promise> ``` @@ -1224,8 +1234,8 @@ requestOptions?: RequestOptions): Promise> | 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` | [`UpdateSubscriptionDueDaysRequest`](../../doc/models/update-subscription-due-days-request.md) | Body, Required | - | | `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | @@ -1238,12 +1248,12 @@ requestOptions?: RequestOptions): Promise> ```ts const subscriptionId = 'subscription_id0'; -const request: UpdateSubscriptionBillingDateRequest = { - nextBillingAt: '2016-03-13T12:52:32.123Z', +const request: UpdateSubscriptionDueDaysRequest = { + boletoDueDays: 226, }; try { - const { result, ...httpResponse } = await subscriptionsController.updateSubscriptionBillingDate( + const { result, ...httpResponse } = await subscriptionsController.updateSubscriptionDueDays( subscriptionId, request ); @@ -1258,13 +1268,13 @@ try { ``` -# Delete Subscription Item +# Create Subscription Item -Deletes a subscription item +Creates a new Subscription item ```ts -async deleteSubscriptionItem( subscriptionId: string, - subscriptionItemId: string, +async createSubscriptionItem( subscriptionId: string, + request: CreateSubscriptionItemRequest, idempotencyKey?: string, requestOptions?: RequestOptions): Promise> ``` @@ -1274,7 +1284,7 @@ requestOptions?: RequestOptions): Promise> -``` - -## Parameters - -| Parameter | Type | Tags | Description | -| --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | The subscription id | -| `page` | `number \| undefined` | Query, Optional | Page number | -| `size` | `number \| undefined` | Query, Optional | Page size | -| `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | - -## Response Type - -[`ListIncrementsResponse`](../../doc/models/list-increments-response.md) - -## Example Usage - -```ts -const subscriptionId = 'subscription_id0'; - -try { - const { result, ...httpResponse } = await subscriptionsController.getIncrements(subscriptionId); - // Get more response info... - // const { statusCode, headers } = httpResponse; -} catch (error) { - if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; - } -} -``` - - -# Update Subscription Due Days - -Updates the boleto due days from a subscription +# Update Split Subscription ```ts -async updateSubscriptionDueDays( subscriptionId: string, - request: UpdateSubscriptionDueDaysRequest, - idempotencyKey?: string, +async updateSplitSubscription( id: string, + request: UpdateSubscriptionSplitRequest, requestOptions?: RequestOptions): Promise> ``` @@ -1360,9 +1342,8 @@ requestOptions?: RequestOptions): Promise> | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | Subscription Id | -| `request` | [`UpdateSubscriptionDueDaysRequest`](../../doc/models/update-subscription-due-days-request.md) | Body, Required | - | -| `idempotencyKey` | `string \| undefined` | Header, Optional | - | +| `id` | `string` | Template, Required | Subscription's id | +| `request` | [`UpdateSubscriptionSplitRequest`](../../doc/models/update-subscription-split-request.md) | Body, Required | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type @@ -1372,15 +1353,22 @@ requestOptions?: RequestOptions): Promise> ## Example Usage ```ts -const subscriptionId = 'subscription_id0'; +const id = 'id0'; -const request: UpdateSubscriptionDueDaysRequest = { - boletoDueDays: 226, +const request: UpdateSubscriptionSplitRequest = { + enabled: false, + rules: [ + { + type: 'type2', + amount: 118, + recipientId: 'recipient_id2', + } + ], }; try { - const { result, ...httpResponse } = await subscriptionsController.updateSubscriptionDueDays( - subscriptionId, + const { result, ...httpResponse } = await subscriptionsController.updateSplitSubscription( + id, request ); // Get more response info... @@ -1394,15 +1382,21 @@ try { ``` -# Update Subscription Start At +# Get Subscription Items -Updates the start at date from a subscription +Get Subscription Items ```ts -async updateSubscriptionStartAt( subscriptionId: string, - request: UpdateSubscriptionStartAtRequest, - idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> +async getSubscriptionItems( subscriptionId: string, + page?: number, + size?: number, + name?: string, + code?: string, + status?: string, + description?: string, + createdSince?: string, + createdUntil?: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters @@ -1410,28 +1404,27 @@ requestOptions?: RequestOptions): Promise> | 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 \| undefined` | Header, Optional | - | +| `page` | `number \| undefined` | Query, Optional | Page number | +| `size` | `number \| undefined` | Query, Optional | Page size | +| `name` | `string \| undefined` | Query, Optional | The item name | +| `code` | `string \| undefined` | Query, Optional | Identification code in the client system | +| `status` | `string \| undefined` | Query, Optional | The item statis | +| `description` | `string \| undefined` | Query, Optional | The item description | +| `createdSince` | `string \| undefined` | Query, Optional | Filter for item's creation date start range | +| `createdUntil` | `string \| undefined` | Query, Optional | Filter for item's creation date end range | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) +[`ListSubscriptionItemsResponse`](../../doc/models/list-subscription-items-response.md) ## Example Usage ```ts const subscriptionId = 'subscription_id0'; -const request: UpdateSubscriptionStartAtRequest = { - startAt: '2016-03-13T12:52:32.123Z', -}; - try { - const { result, ...httpResponse } = await subscriptionsController.updateSubscriptionStartAt( - subscriptionId, - request -); + const { result, ...httpResponse } = await subscriptionsController.getSubscriptionItems(subscriptionId); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -1443,60 +1436,53 @@ try { ``` -# Update Subscription Item +# Get Subscriptions -Updates a subscription item +Gets all subscriptions ```ts -async updateSubscriptionItem( subscriptionId: string, - itemId: string, - body: UpdateSubscriptionItemRequest, - idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> +async getSubscriptions( page?: number, + size?: number, + code?: string, + billingType?: string, + customerId?: string, + planId?: string, + cardId?: string, + status?: string, + nextBillingSince?: string, + nextBillingUntil?: string, + createdSince?: string, + createdUntil?: string, +requestOptions?: RequestOptions): Promise> ``` ## 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 \| undefined` | Header, Optional | - | +| `page` | `number \| undefined` | Query, Optional | Page number | +| `size` | `number \| undefined` | Query, Optional | Page size | +| `code` | `string \| undefined` | Query, Optional | Filter for subscription's code | +| `billingType` | `string \| undefined` | Query, Optional | Filter for subscription's billing type | +| `customerId` | `string \| undefined` | Query, Optional | Filter for subscription's customer id | +| `planId` | `string \| undefined` | Query, Optional | Filter for subscription's plan id | +| `cardId` | `string \| undefined` | Query, Optional | Filter for subscription's card id | +| `status` | `string \| undefined` | Query, Optional | Filter for subscription's status | +| `nextBillingSince` | `string \| undefined` | Query, Optional | Filter for subscription's next billing date start range | +| `nextBillingUntil` | `string \| undefined` | Query, Optional | Filter for subscription's next billing date end range | +| `createdSince` | `string \| undefined` | Query, Optional | Filter for subscription's creation date start range | +| `createdUntil` | `string \| undefined` | Query, Optional | Filter for subscriptions creation date end range | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetSubscriptionItemResponse`](../../doc/models/get-subscription-item-response.md) - -## Example Usage - -```ts -const subscriptionId = 'subscription_id0'; - -const itemId = 'item_id0'; - -const body: UpdateSubscriptionItemRequest = { - description: 'description4', - status: 'status2', - pricingScheme: { - schemeType: 'scheme_type8', - priceBrackets: [ - { - startQuantity: 144, - price: 174, - } - ], - }, - name: 'name6', -}; +[`ListSubscriptionsResponse`](../../doc/models/list-subscriptions-response.md) + +## Example Usage +```ts try { - const { result, ...httpResponse } = await subscriptionsController.updateSubscriptionItem( - subscriptionId, - itemId, - body -); + const { result, ...httpResponse } = await subscriptionsController.getSubscriptions(); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -1508,15 +1494,15 @@ try { ``` -# Create Subscription Item +# Create Increment -Creates a new Subscription item +Creates a increment ```ts -async createSubscriptionItem( subscriptionId: string, - request: CreateSubscriptionItemRequest, +async createIncrement( subscriptionId: string, + request: CreateIncrementRequest, idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> +requestOptions?: RequestOptions): Promise> ``` ## Parameters @@ -1524,38 +1510,27 @@ requestOptions?: RequestOptions): Promise> +async createUsage( subscriptionId: string, + itemId: string, + body: CreateUsageRequest, + idempotencyKey?: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | Subscription id | +| `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 \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) +[`GetUsageResponse`](../../doc/models/get-usage-response.md) ## Example Usage ```ts const subscriptionId = 'subscription_id0'; +const itemId = 'item_id0'; + +const body: CreateUsageRequest = { + quantity: 156, + description: 'description4', + usedAt: '2016-03-13T12:52:32.123Z', +}; + try { - const { result, ...httpResponse } = await subscriptionsController.getSubscription(subscriptionId); + const { result, ...httpResponse } = await subscriptionsController.createUsage( + subscriptionId, + itemId, + body +); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -1608,20 +1601,12 @@ try { ``` -# Get Usages - -Lists all usages from a subscription item +# Get Discount by Id ```ts -async getUsages( subscriptionId: string, - itemId: string, - page?: number, - size?: number, - code?: string, - group?: string, - usedSince?: string, - usedUntil?: string, -requestOptions?: RequestOptions): Promise> +async getDiscountById( subscriptionId: string, + discountId: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters @@ -1629,30 +1614,24 @@ requestOptions?: RequestOptions): Promise> | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `subscriptionId` | `string` | Template, Required | The subscription id | -| `itemId` | `string` | Template, Required | The subscription item id | -| `page` | `number \| undefined` | Query, Optional | Page number | -| `size` | `number \| undefined` | Query, Optional | Page size | -| `code` | `string \| undefined` | Query, Optional | Identification code in the client system | -| `group` | `string \| undefined` | Query, Optional | Identification group in the client system | -| `usedSince` | `string \| undefined` | Query, Optional | - | -| `usedUntil` | `string \| undefined` | Query, Optional | - | +| `discountId` | `string` | Template, Required | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`ListUsagesResponse`](../../doc/models/list-usages-response.md) +[`GetDiscountResponse`](../../doc/models/get-discount-response.md) ## Example Usage ```ts const subscriptionId = 'subscription_id0'; -const itemId = 'item_id0'; +const discountId = 'discountId0'; try { - const { result, ...httpResponse } = await subscriptionsController.getUsages( + const { result, ...httpResponse } = await subscriptionsController.getDiscountById( subscriptionId, - itemId + discountId ); // Get more response info... // const { statusCode, headers } = httpResponse; @@ -1665,11 +1644,13 @@ try { ``` -# Update Latest Period End At +# Update Subscription Metadata + +Updates the metadata from a subscription ```ts -async updateLatestPeriodEndAt( subscriptionId: string, - request: UpdateCurrentCycleEndDateRequest, +async updateSubscriptionMetadata( subscriptionId: string, + request: UpdateMetadataRequest, idempotencyKey?: string, requestOptions?: RequestOptions): Promise> ``` @@ -1678,8 +1659,8 @@ requestOptions?: RequestOptions): Promise> | 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 | The subscription id | +| `request` | [`UpdateMetadataRequest`](../../doc/models/update-metadata-request.md) | Body, Required | Request for updating the subscrption metadata | | `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | @@ -1692,10 +1673,14 @@ requestOptions?: RequestOptions): Promise> ```ts const subscriptionId = 'subscription_id0'; -const request: UpdateCurrentCycleEndDateRequest = {}; +const request: UpdateMetadataRequest = { + metadata: { + 'key0': 'metadata3' + }, +}; try { - const { result, ...httpResponse } = await subscriptionsController.updateLatestPeriodEndAt( + const { result, ...httpResponse } = await subscriptionsController.updateSubscriptionMetadata( subscriptionId, request ); @@ -1710,15 +1695,13 @@ try { ``` -# Update Subscription Minium Price - -Atualização do valor mínimo da assinatura +# Get Subscription Cycles ```ts -async updateSubscriptionMiniumPrice( subscriptionId: string, - request: UpdateSubscriptionMinimumPriceRequest, - idempotencyKey?: string, -requestOptions?: RequestOptions): Promise> +async getSubscriptionCycles( subscriptionId: string, + page: string, + size: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters @@ -1726,25 +1709,28 @@ requestOptions?: RequestOptions): Promise> | 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 | -| `idempotencyKey` | `string \| undefined` | Header, Optional | - | +| `page` | `string` | Query, Required | Page number | +| `size` | `string` | Query, Required | Page size | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) +[`ListCyclesResponse`](../../doc/models/list-cycles-response.md) ## Example Usage ```ts const subscriptionId = 'subscription_id0'; -const request: UpdateSubscriptionMinimumPriceRequest = {}; +const page = 'page8'; + +const size = 'size0'; try { - const { result, ...httpResponse } = await subscriptionsController.updateSubscriptionMiniumPrice( + const { result, ...httpResponse } = await subscriptionsController.getSubscriptionCycles( subscriptionId, - request + page, + size ); // Get more response info... // const { statusCode, headers } = httpResponse; @@ -1757,37 +1743,41 @@ try { ``` -# Get Subscription Cycle by Id +# Delete Subscription Item + +Deletes a subscription item ```ts -async getSubscriptionCycleById( subscriptionId: string, - cycleId: string, -requestOptions?: RequestOptions): Promise> +async deleteSubscriptionItem( subscriptionId: string, + subscriptionItemId: string, + idempotencyKey?: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | The subscription id | -| `cycleId` | `string` | Template, Required | - | +| `subscriptionId` | `string` | Template, Required | Subscription id | +| `subscriptionItemId` | `string` | Template, Required | Subscription item id | +| `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetPeriodResponse`](../../doc/models/get-period-response.md) +[`GetSubscriptionItemResponse`](../../doc/models/get-subscription-item-response.md) ## Example Usage ```ts const subscriptionId = 'subscription_id0'; -const cycleId = 'cycleId0'; +const subscriptionItemId = 'subscription_item_id4'; try { - const { result, ...httpResponse } = await subscriptionsController.getSubscriptionCycleById( + const { result, ...httpResponse } = await subscriptionsController.deleteSubscriptionItem( subscriptionId, - cycleId + subscriptionItemId ); // Get more response info... // const { statusCode, headers } = httpResponse; @@ -1800,38 +1790,35 @@ try { ``` -# Get Usage Report +# Get Increments ```ts -async getUsageReport( subscriptionId: string, - periodId: string, -requestOptions?: RequestOptions): Promise> +async getIncrements( subscriptionId: string, + page?: number, + size?: number, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `subscriptionId` | `string` | Template, Required | The subscription Id | -| `periodId` | `string` | Template, Required | The period Id | +| `subscriptionId` | `string` | Template, Required | The subscription id | +| `page` | `number \| undefined` | Query, Optional | Page number | +| `size` | `number \| undefined` | Query, Optional | Page size | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetUsageReportResponse`](../../doc/models/get-usage-report-response.md) +[`ListIncrementsResponse`](../../doc/models/list-increments-response.md) ## Example Usage ```ts const subscriptionId = 'subscription_id0'; -const periodId = 'period_id0'; - try { - const { result, ...httpResponse } = await subscriptionsController.getUsageReport( - subscriptionId, - periodId -); + const { result, ...httpResponse } = await subscriptionsController.getIncrements(subscriptionId); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -1843,46 +1830,59 @@ try { ``` -# Update Split Subscription +# Update Subscription Item + +Updates a subscription item ```ts -async updateSplitSubscription( id: string, - request: UpdateSubscriptionSplitRequest, -requestOptions?: RequestOptions): Promise> +async updateSubscriptionItem( subscriptionId: string, + itemId: string, + body: UpdateSubscriptionItemRequest, + idempotencyKey?: string, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `id` | `string` | Template, Required | Subscription's id | -| `request` | [`UpdateSubscriptionSplitRequest`](../../doc/models/update-subscription-split-request.md) | Body, Required | - | +| `subscriptionId` | `string` | Template, Required | Subscription Id | +| `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 \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetSubscriptionResponse`](../../doc/models/get-subscription-response.md) +[`GetSubscriptionItemResponse`](../../doc/models/get-subscription-item-response.md) ## Example Usage ```ts -const id = 'id0'; +const subscriptionId = 'subscription_id0'; -const request: UpdateSubscriptionSplitRequest = { - enabled: false, - rules: [ - { - type: 'type2', - amount: 118, - recipientId: 'recipient_id2', - } - ], +const itemId = 'item_id0'; + +const body: UpdateSubscriptionItemRequest = { + description: 'description4', + status: 'status2', + pricingScheme: { + schemeType: 'scheme_type8', + priceBrackets: [ + { + startQuantity: 144, + price: 174, + } + ], + }, + name: 'name6', }; try { - const { result, ...httpResponse } = await subscriptionsController.updateSplitSubscription( - id, - request + const { result, ...httpResponse } = await subscriptionsController.updateSubscriptionItem( + subscriptionId, + itemId, + body ); // Get more response info... // const { statusCode, headers } = httpResponse; diff --git a/doc/controllers/tokens.md b/doc/controllers/tokens.md index 2dbf625..c69e86e 100644 --- a/doc/controllers/tokens.md +++ b/doc/controllers/tokens.md @@ -10,18 +10,19 @@ const tokensController = new TokensController(client); ## Methods -* [Create Token](../../doc/controllers/tokens.md#create-token) * [Get Token](../../doc/controllers/tokens.md#get-token) +* [Create Token](../../doc/controllers/tokens.md#create-token) -# Create Token +# Get Token + +Gets a token from its id :information_source: **Note** This endpoint does not require authentication. ```ts -async createToken( publicKey: string, - request: CreateTokenRequest, - idempotencyKey?: string, +async getToken( id: string, + publicKey: string, requestOptions?: RequestOptions): Promise> ``` @@ -29,9 +30,8 @@ requestOptions?: RequestOptions): Promise> | Parameter | Type | Tags | Description | | --- | --- | --- | --- | +| `id` | `string` | Template, Required | Token id | | `publicKey` | `string` | Template, Required | Public key | -| `request` | [`CreateTokenRequest`](../../doc/models/create-token-request.md) | Body, Required | Request for creating a token | -| `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type @@ -41,25 +41,14 @@ requestOptions?: RequestOptions): Promise> ## Example Usage ```ts -const publicKey = 'public_key6'; +const id = 'id0'; -const request: CreateTokenRequest = { - type: 'card', - card: { - number: 'number6', - holderName: 'holder_name2', - expMonth: 228, - expYear: 68, - cvv: 'cvv4', - brand: 'brand0', - label: 'label6', - }, -}; +const publicKey = 'public_key6'; try { - const { result, ...httpResponse } = await tokensController.createToken( - publicKey, - request + const { result, ...httpResponse } = await tokensController.getToken( + id, + publicKey ); // Get more response info... // const { statusCode, headers } = httpResponse; @@ -72,15 +61,14 @@ try { ``` -# Get Token - -Gets a token from its id +# Create Token :information_source: **Note** This endpoint does not require authentication. ```ts -async getToken( id: string, - publicKey: string, +async createToken( publicKey: string, + request: CreateTokenRequest, + idempotencyKey?: string, requestOptions?: RequestOptions): Promise> ``` @@ -88,8 +76,9 @@ requestOptions?: RequestOptions): Promise> | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `id` | `string` | Template, Required | Token id | | `publicKey` | `string` | Template, Required | Public key | +| `request` | [`CreateTokenRequest`](../../doc/models/create-token-request.md) | Body, Required | Request for creating a token | +| `idempotencyKey` | `string \| undefined` | Header, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type @@ -99,14 +88,25 @@ requestOptions?: RequestOptions): Promise> ## Example Usage ```ts -const id = 'id0'; - const publicKey = 'public_key6'; +const request: CreateTokenRequest = { + type: 'card', + card: { + number: 'number6', + holderName: 'holder_name2', + expMonth: 228, + expYear: 68, + cvv: 'cvv4', + brand: 'brand0', + label: 'label6', + }, +}; + try { - const { result, ...httpResponse } = await tokensController.getToken( - id, - publicKey + const { result, ...httpResponse } = await tokensController.createToken( + publicKey, + request ); // Get more response info... // const { statusCode, headers } = httpResponse; diff --git a/doc/controllers/transfers.md b/doc/controllers/transfers.md index 9a4a522..faf4867 100644 --- a/doc/controllers/transfers.md +++ b/doc/controllers/transfers.md @@ -11,8 +11,8 @@ const transfersController = new TransfersController(client); ## Methods * [Get Transfer by Id](../../doc/controllers/transfers.md#get-transfer-by-id) -* [Create Transfer](../../doc/controllers/transfers.md#create-transfer) * [Get Transfers](../../doc/controllers/transfers.md#get-transfers) +* [Create Transfer](../../doc/controllers/transfers.md#create-transfer) # Get Transfer by Id @@ -51,35 +51,29 @@ try { ``` -# Create Transfer +# Get Transfers + +Gets all transfers ```ts -async createTransfer( request: CreateTransfer, -requestOptions?: RequestOptions): Promise> +async getTransfers(requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `request` | [`CreateTransfer`](../../doc/models/create-transfer.md) | Body, Required | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`GetTransfer`](../../doc/models/get-transfer.md) +[`ListTransfers`](../../doc/models/list-transfers.md) ## Example Usage ```ts -const request: CreateTransfer = { - amount: 242, - sourceId: 'source_id0', - targetId: 'target_id6', -}; - try { - const { result, ...httpResponse } = await transfersController.createTransfer(request); + const { result, ...httpResponse } = await transfersController.getTransfers(); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { @@ -91,29 +85,35 @@ try { ``` -# Get Transfers - -Gets all transfers +# Create Transfer ```ts -async getTransfers(requestOptions?: RequestOptions): Promise> +async createTransfer( request: CreateTransfer, +requestOptions?: RequestOptions): Promise> ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | +| `request` | [`CreateTransfer`](../../doc/models/create-transfer.md) | Body, Required | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type -[`ListTransfers`](../../doc/models/list-transfers.md) +[`GetTransfer`](../../doc/models/get-transfer.md) ## Example Usage ```ts +const request: CreateTransfer = { + amount: 242, + sourceId: 'source_id0', + targetId: 'target_id6', +}; + try { - const { result, ...httpResponse } = await transfersController.getTransfers(); + const { result, ...httpResponse } = await transfersController.createTransfer(request); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { diff --git a/doc/models/create-credit-card-payment-request.md b/doc/models/create-credit-card-payment-request.md index d77c146..f96e212 100644 --- a/doc/models/create-credit-card-payment-request.md +++ b/doc/models/create-credit-card-payment-request.md @@ -30,6 +30,7 @@ The settings for creating a credit card payment | `initiatedType` | `string \| undefined` | Optional | - | | `recurrenceModel` | `string \| undefined` | Optional | - | | `paymentOrigin` | [`CreatePaymentOriginRequest \| undefined`](../../doc/models/create-payment-origin-request.md) | Optional | - | +| `indirectAcceptor` | `string \| undefined` | Optional | Business model identifier | ## Example (as JSON) diff --git a/doc/models/create-subscription-request.md b/doc/models/create-subscription-request.md index a55dc68..c798e09 100644 --- a/doc/models/create-subscription-request.md +++ b/doc/models/create-subscription-request.md @@ -44,6 +44,7 @@ Request for creating a subcription | `submerchant` | [`CreateSubMerchantRequest \| undefined`](../../doc/models/create-sub-merchant-request.md) | Optional | SubMerchant | | `split` | [`CreateSubscriptionSplitRequest \| undefined`](../../doc/models/create-subscription-split-request.md) | Optional | Subscription's split | | `boleto` | [`CreateSubscriptionBoletoRequest \| undefined`](../../doc/models/create-subscription-boleto-request.md) | Optional | Information about fines and interest on the "boleto" used from payment | +| `indirectAcceptor` | `string \| undefined` | Optional | Business model identifier | ## Example (as JSON) diff --git a/doc/models/get-credit-card-transaction-response.md b/doc/models/get-credit-card-transaction-response.md index d14ca35..6eff951 100644 --- a/doc/models/get-credit-card-transaction-response.md +++ b/doc/models/get-credit-card-transaction-response.md @@ -30,6 +30,7 @@ Response object for getting a credit card transaction | `fundingSource` | `string \| null \| undefined` | Optional | Identify when a card is prepaid, credit or debit. | | `retryInfo` | [`GetRetryTransactionInformationResponse \| null \| undefined`](../../doc/models/get-retry-transaction-information-response.md) | Optional | Retry transaction information | | `brandId` | `string \| null \| undefined` | Optional | - | +| `indirectAcceptor` | `string \| null \| undefined` | Optional | Business model identifier | ## Example (as JSON) diff --git a/doc/models/get-subscription-response.md b/doc/models/get-subscription-response.md index f4ea2f7..a16e17b 100644 --- a/doc/models/get-subscription-response.md +++ b/doc/models/get-subscription-response.md @@ -39,6 +39,7 @@ | `split` | [`GetSubscriptionSplitResponse \| null \| undefined`](../../doc/models/get-subscription-split-response.md) | Optional | Subscription's split response | | `boleto` | [`GetSubscriptionBoletoResponse \| null \| undefined`](../../doc/models/get-subscription-boleto-response.md) | Optional | - | | `manualBilling` | `boolean \| null \| undefined` | Optional | - | +| `indirectAcceptor` | `string \| null \| undefined` | Optional | Business model identifier | ## Example (as JSON) diff --git a/doc/models/update-charge-card-request.md b/doc/models/update-charge-card-request.md index 7ec44fd..c571c3e 100644 --- a/doc/models/update-charge-card-request.md +++ b/doc/models/update-charge-card-request.md @@ -18,6 +18,7 @@ Request for updating card data | `initiatedType` | `string \| undefined` | Optional | - | | `recurrenceModel` | `string \| undefined` | Optional | - | | `paymentOrigin` | [`CreatePaymentOriginRequest \| undefined`](../../doc/models/create-payment-origin-request.md) | Optional | - | +| `indirectAcceptor` | `string \| undefined` | Optional | Business model identifier | ## Example (as JSON) @@ -39,7 +40,8 @@ Request for updating card data "payment_origin": { "brand_id": "brand_id8", "charge_id": "charge_id2" - } + }, + "indirect_acceptor": "indirect_acceptor2" } ``` diff --git a/doc/models/update-recipient-code-request.md b/doc/models/update-recipient-code-request.md new file mode 100644 index 0000000..1815f4a --- /dev/null +++ b/doc/models/update-recipient-code-request.md @@ -0,0 +1,23 @@ + +# Update Recipient Code Request + +Update code for a recipient + +## Structure + +`UpdateRecipientCodeRequest` + +## Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `code` | `string` | Required | Code | + +## Example (as JSON) + +```json +{ + "code": "code6" +} +``` + diff --git a/doc/models/update-subscription-card-request.md b/doc/models/update-subscription-card-request.md index 6d21fbd..4bc07a4 100644 --- a/doc/models/update-subscription-card-request.md +++ b/doc/models/update-subscription-card-request.md @@ -13,6 +13,7 @@ Request for updating the card from a subscription | --- | --- | --- | --- | | `card` | [`CreateCardRequest`](../../doc/models/create-card-request.md) | Required | Credit card data | | `cardId` | `string` | Required | Credit card id | +| `indirectAcceptor` | `string \| undefined` | Optional | Business model identifier | ## Example (as JSON) @@ -26,7 +27,8 @@ Request for updating the card from a subscription "exp_year": 68, "cvv": "cvv4" }, - "card_id": "card_id0" + "card_id": "card_id0", + "indirect_acceptor": "indirect_acceptor0" } ``` diff --git a/package.json b/package.json index 820490c..51740a9 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "6.8.13", + "version": "6.8.14", "license": "MIT", "sideEffects": false, "main": "dist/cjs/index.js", diff --git a/src/client.ts b/src/client.ts index e2f0bff..5584301 100644 --- a/src/client.ts +++ b/src/client.ts @@ -58,7 +58,7 @@ export class Client implements ClientInterface { }, }; - this._userAgent = updateUserAgent('PagarmeApiSDK - TypeScript 6.8.13'); + this._userAgent = updateUserAgent('PagarmeApiSDK - TypeScript 6.8.14'); this._requestBuilderFactory = createRequestHandlerFactory( (server) => getBaseUri(server, this._config), createAuthProviderFromConfig(clonedConfig), diff --git a/src/controllers/balanceOperationsController.ts b/src/controllers/balanceOperationsController.ts index d3c2ab8..fad2482 100644 --- a/src/controllers/balanceOperationsController.ts +++ b/src/controllers/balanceOperationsController.ts @@ -17,6 +17,21 @@ import { bigint, optional, string } from '../schema'; import { BaseController } from './baseController'; export class BalanceOperationsController extends BaseController { + /** + * @param id + * @return Response from the API call + */ + async getBalanceOperationById( + id: bigint, + requestOptions?: RequestOptions + ): Promise> { + const req = this.createRequest('GET'); + const mapped = req.prepareArgs({ id: [id, bigint()] }); + req.appendTemplatePath`/balance/operations/${mapped.id}`; + req.authenticate([{ httpBasic: true }]); + return req.callAsJson(getBalanceOperationResponseSchema, requestOptions); + } + /** * @param status * @param createdSince @@ -45,19 +60,4 @@ export class BalanceOperationsController extends BaseController { req.authenticate([{ httpBasic: true }]); return req.callAsJson(listBalanceOperationResponseSchema, requestOptions); } - - /** - * @param id - * @return Response from the API call - */ - async getBalanceOperationById( - id: bigint, - requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('GET'); - const mapped = req.prepareArgs({ id: [id, bigint()] }); - req.appendTemplatePath`/balance/operations/${mapped.id}`; - req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getBalanceOperationResponseSchema, requestOptions); - } } diff --git a/src/controllers/chargesController.ts b/src/controllers/chargesController.ts index 49ab900..f8c1c88 100644 --- a/src/controllers/chargesController.ts +++ b/src/controllers/chargesController.ts @@ -85,29 +85,70 @@ export class ChargesController extends BaseController { } /** - * Updates a charge's payment method + * Captures a charge * * @param chargeId Charge id - * @param request Request for updating the payment method from a - * charge + * @param request Request for capturing a charge * @param idempotencyKey * @return Response from the API call */ - async updateChargePaymentMethod( + async captureCharge( chargeId: string, - request: UpdateChargePaymentMethodRequest, + request?: CreateCaptureChargeRequest, idempotencyKey?: string, requestOptions?: RequestOptions ): Promise> { - const req = this.createRequest('PATCH'); + const req = this.createRequest('POST'); const mapped = req.prepareArgs({ chargeId: [chargeId, string()], - request: [request, updateChargePaymentMethodRequestSchema], + request: [request, optional(createCaptureChargeRequestSchema)], idempotencyKey: [idempotencyKey, optional(string())], }); req.header('idempotency-key', mapped.idempotencyKey); req.json(mapped.request); - req.appendTemplatePath`/charges/${mapped.chargeId}/payment-method`; + req.appendTemplatePath`/charges/${mapped.chargeId}/capture`; + req.authenticate([{ httpBasic: true }]); + return req.callAsJson(getChargeResponseSchema, requestOptions); + } + + /** + * Get a charge from its id + * + * @param chargeId Charge id + * @return Response from the API call + */ + async getCharge( + chargeId: string, + requestOptions?: RequestOptions + ): Promise> { + const req = this.createRequest('GET'); + const mapped = req.prepareArgs({ chargeId: [chargeId, string()] }); + req.appendTemplatePath`/charges/${mapped.chargeId}`; + req.authenticate([{ httpBasic: true }]); + return req.callAsJson(getChargeResponseSchema, requestOptions); + } + + /** + * @param chargeId + * @param request Request for confirm payment + * @param idempotencyKey + * @return Response from the API call + */ + async confirmPayment( + chargeId: string, + request?: CreateConfirmPaymentRequest, + idempotencyKey?: string, + requestOptions?: RequestOptions + ): Promise> { + const req = this.createRequest('POST'); + const mapped = req.prepareArgs({ + chargeId: [chargeId, string()], + request: [request, optional(createConfirmPaymentRequestSchema)], + idempotencyKey: [idempotencyKey, optional(string())], + }); + req.header('idempotency-key', mapped.idempotencyKey); + req.json(mapped.request); + req.appendTemplatePath`/charges/${mapped.chargeId}/confirm-payment`; req.authenticate([{ httpBasic: true }]); return req.callAsJson(getChargeResponseSchema, requestOptions); } @@ -138,150 +179,106 @@ export class ChargesController extends BaseController { } /** - * Updates the due date from a charge + * Updates the card from a charge * - * @param chargeId Charge Id - * @param request Request for updating the due date + * @param chargeId Charge id + * @param request Request for updating a charge's card * @param idempotencyKey * @return Response from the API call */ - async updateChargeDueDate( + async updateChargeCard( chargeId: string, - request: UpdateChargeDueDateRequest, + request: UpdateChargeCardRequest, idempotencyKey?: string, requestOptions?: RequestOptions ): Promise> { const req = this.createRequest('PATCH'); const mapped = req.prepareArgs({ chargeId: [chargeId, string()], - request: [request, updateChargeDueDateRequestSchema], + request: [request, updateChargeCardRequestSchema], idempotencyKey: [idempotencyKey, optional(string())], }); req.header('idempotency-key', mapped.idempotencyKey); req.json(mapped.request); - req.appendTemplatePath`/Charges/${mapped.chargeId}/due-date`; + req.appendTemplatePath`/charges/${mapped.chargeId}/card`; req.authenticate([{ httpBasic: true }]); return req.callAsJson(getChargeResponseSchema, requestOptions); } /** - * Lists all charges + * Creates a new charge * - * @param page Page number - * @param size Page size - * @param code Filter for charge's code - * @param status Filter for charge's status - * @param paymentMethod Filter for charge's payment method - * @param customerId Filter for charge's customer id - * @param orderId Filter for charge's order id - * @param createdSince Filter for the beginning of the range for charge's creation - * @param createdUntil Filter for the end of the range for charge's creation + * @param request Request for creating a charge + * @param idempotencyKey * @return Response from the API call */ - async getCharges( - page?: number, - size?: number, - code?: string, - status?: string, - paymentMethod?: string, - customerId?: string, - orderId?: string, - createdSince?: string, - createdUntil?: string, + async createCharge( + request: CreateChargeRequest, + idempotencyKey?: string, requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('GET', '/charges'); + ): Promise> { + const req = this.createRequest('POST', '/Charges'); const mapped = req.prepareArgs({ - page: [page, optional(number())], - size: [size, optional(number())], - code: [code, optional(string())], - status: [status, optional(string())], - paymentMethod: [paymentMethod, optional(string())], - customerId: [customerId, optional(string())], - orderId: [orderId, optional(string())], - createdSince: [createdSince, optional(string())], - createdUntil: [createdUntil, optional(string())], + request: [request, createChargeRequestSchema], + idempotencyKey: [idempotencyKey, optional(string())], }); - req.query('page', mapped.page); - req.query('size', mapped.size); - req.query('code', mapped.code); - req.query('status', mapped.status); - req.query('payment_method', mapped.paymentMethod); - req.query('customer_id', mapped.customerId); - req.query('order_id', mapped.orderId); - req.query('created_since', mapped.createdSince); - req.query('created_until', mapped.createdUntil); + req.header('idempotency-key', mapped.idempotencyKey); + req.json(mapped.request); req.authenticate([{ httpBasic: true }]); - return req.callAsJson(listChargesResponseSchema, requestOptions); + return req.callAsJson(getChargeResponseSchema, requestOptions); } /** - * Captures a charge + * Updates a charge's payment method * * @param chargeId Charge id - * @param request Request for capturing a charge + * @param request Request for updating the payment method from a + * charge * @param idempotencyKey * @return Response from the API call */ - async captureCharge( + async updateChargePaymentMethod( chargeId: string, - request?: CreateCaptureChargeRequest, + request: UpdateChargePaymentMethodRequest, idempotencyKey?: string, requestOptions?: RequestOptions ): Promise> { - const req = this.createRequest('POST'); + const req = this.createRequest('PATCH'); const mapped = req.prepareArgs({ chargeId: [chargeId, string()], - request: [request, optional(createCaptureChargeRequestSchema)], + request: [request, updateChargePaymentMethodRequestSchema], idempotencyKey: [idempotencyKey, optional(string())], }); req.header('idempotency-key', mapped.idempotencyKey); req.json(mapped.request); - req.appendTemplatePath`/charges/${mapped.chargeId}/capture`; + req.appendTemplatePath`/charges/${mapped.chargeId}/payment-method`; req.authenticate([{ httpBasic: true }]); return req.callAsJson(getChargeResponseSchema, requestOptions); } /** - * Updates the card from a charge + * Updates the due date from a charge * - * @param chargeId Charge id - * @param request Request for updating a charge's card + * @param chargeId Charge Id + * @param request Request for updating the due date * @param idempotencyKey * @return Response from the API call */ - async updateChargeCard( + async updateChargeDueDate( chargeId: string, - request: UpdateChargeCardRequest, + request: UpdateChargeDueDateRequest, idempotencyKey?: string, requestOptions?: RequestOptions ): Promise> { const req = this.createRequest('PATCH'); const mapped = req.prepareArgs({ chargeId: [chargeId, string()], - request: [request, updateChargeCardRequestSchema], + request: [request, updateChargeDueDateRequestSchema], idempotencyKey: [idempotencyKey, optional(string())], }); req.header('idempotency-key', mapped.idempotencyKey); req.json(mapped.request); - req.appendTemplatePath`/charges/${mapped.chargeId}/card`; - req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getChargeResponseSchema, requestOptions); - } - - /** - * Get a charge from its id - * - * @param chargeId Charge id - * @return Response from the API call - */ - async getCharge( - chargeId: string, - requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('GET'); - const mapped = req.prepareArgs({ chargeId: [chargeId, string()] }); - req.appendTemplatePath`/charges/${mapped.chargeId}`; + req.appendTemplatePath`/Charges/${mapped.chargeId}/due-date`; req.authenticate([{ httpBasic: true }]); return req.callAsJson(getChargeResponseSchema, requestOptions); } @@ -335,76 +332,79 @@ export class ChargesController extends BaseController { } /** - * Cancel a charge + * Lists all charges * - * @param chargeId Charge id - * @param request Request for cancelling a charge - * @param idempotencyKey + * @param page Page number + * @param size Page size + * @param code Filter for charge's code + * @param status Filter for charge's status + * @param paymentMethod Filter for charge's payment method + * @param customerId Filter for charge's customer id + * @param orderId Filter for charge's order id + * @param createdSince Filter for the beginning of the range for charge's creation + * @param createdUntil Filter for the end of the range for charge's creation * @return Response from the API call */ - async cancelCharge( - chargeId: string, - request?: CreateCancelChargeRequest, - idempotencyKey?: string, + async getCharges( + page?: number, + size?: number, + code?: string, + status?: string, + paymentMethod?: string, + customerId?: string, + orderId?: string, + createdSince?: string, + createdUntil?: string, requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('DELETE'); + ): Promise> { + const req = this.createRequest('GET', '/charges'); const mapped = req.prepareArgs({ - chargeId: [chargeId, string()], - request: [request, optional(createCancelChargeRequestSchema)], - idempotencyKey: [idempotencyKey, optional(string())], + page: [page, optional(number())], + size: [size, optional(number())], + code: [code, optional(string())], + status: [status, optional(string())], + paymentMethod: [paymentMethod, optional(string())], + customerId: [customerId, optional(string())], + orderId: [orderId, optional(string())], + createdSince: [createdSince, optional(string())], + createdUntil: [createdUntil, optional(string())], }); - req.header('idempotency-key', mapped.idempotencyKey); - req.json(mapped.request); - req.appendTemplatePath`/charges/${mapped.chargeId}`; + req.query('page', mapped.page); + req.query('size', mapped.size); + req.query('code', mapped.code); + req.query('status', mapped.status); + req.query('payment_method', mapped.paymentMethod); + req.query('customer_id', mapped.customerId); + req.query('order_id', mapped.orderId); + req.query('created_since', mapped.createdSince); + req.query('created_until', mapped.createdUntil); req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getChargeResponseSchema, requestOptions); + return req.callAsJson(listChargesResponseSchema, requestOptions); } /** - * Creates a new charge + * Cancel a charge * - * @param request Request for creating a charge - * @param idempotencyKey - * @return Response from the API call - */ - async createCharge( - request: CreateChargeRequest, - idempotencyKey?: string, - requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('POST', '/Charges'); - const mapped = req.prepareArgs({ - request: [request, createChargeRequestSchema], - idempotencyKey: [idempotencyKey, optional(string())], - }); - req.header('idempotency-key', mapped.idempotencyKey); - req.json(mapped.request); - req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getChargeResponseSchema, requestOptions); - } - - /** - * @param chargeId - * @param request Request for confirm payment + * @param chargeId Charge id + * @param request Request for cancelling a charge * @param idempotencyKey * @return Response from the API call */ - async confirmPayment( + async cancelCharge( chargeId: string, - request?: CreateConfirmPaymentRequest, + request?: CreateCancelChargeRequest, idempotencyKey?: string, requestOptions?: RequestOptions ): Promise> { - const req = this.createRequest('POST'); + const req = this.createRequest('DELETE'); const mapped = req.prepareArgs({ chargeId: [chargeId, string()], - request: [request, optional(createConfirmPaymentRequestSchema)], + request: [request, optional(createCancelChargeRequestSchema)], idempotencyKey: [idempotencyKey, optional(string())], }); req.header('idempotency-key', mapped.idempotencyKey); req.json(mapped.request); - req.appendTemplatePath`/charges/${mapped.chargeId}/confirm-payment`; + req.appendTemplatePath`/charges/${mapped.chargeId}`; req.authenticate([{ httpBasic: true }]); return req.callAsJson(getChargeResponseSchema, requestOptions); } diff --git a/src/controllers/customersController.ts b/src/controllers/customersController.ts index 9116f5e..664d960 100644 --- a/src/controllers/customersController.ts +++ b/src/controllers/customersController.ts @@ -74,63 +74,60 @@ import { BaseController } from './baseController'; export class CustomersController extends BaseController { /** - * Updates a card + * Creates a new address for a customer * * @param customerId Customer Id - * @param cardId Card id - * @param request Request for updating a card + * @param request Request for creating an address * @param idempotencyKey * @return Response from the API call */ - async updateCard( + async createAddress( customerId: string, - cardId: string, - request: UpdateCardRequest, + request: CreateAddressRequest, idempotencyKey?: string, requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('PUT'); + ): Promise> { + const req = this.createRequest('POST'); const mapped = req.prepareArgs({ customerId: [customerId, string()], - cardId: [cardId, string()], - request: [request, updateCardRequestSchema], + request: [request, createAddressRequestSchema], idempotencyKey: [idempotencyKey, optional(string())], }); req.header('idempotency-key', mapped.idempotencyKey); req.json(mapped.request); - req.appendTemplatePath`/customers/${mapped.customerId}/cards/${mapped.cardId}`; + req.appendTemplatePath`/customers/${mapped.customerId}/addresses`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getCardResponseSchema, requestOptions); + return req.callAsJson(getAddressResponseSchema, requestOptions); } /** - * Updates an address + * Updates a card * * @param customerId Customer Id - * @param addressId Address Id - * @param request Request for updating an address + * @param cardId Card id + * @param request Request for updating a card * @param idempotencyKey * @return Response from the API call */ - async updateAddress( + async updateCard( customerId: string, - addressId: string, - request: UpdateAddressRequest, + cardId: string, + request: UpdateCardRequest, idempotencyKey?: string, requestOptions?: RequestOptions - ): Promise> { + ): Promise> { const req = this.createRequest('PUT'); const mapped = req.prepareArgs({ customerId: [customerId, string()], - addressId: [addressId, string()], - request: [request, updateAddressRequestSchema], + cardId: [cardId, string()], + request: [request, updateCardRequestSchema], idempotencyKey: [idempotencyKey, optional(string())], }); req.header('idempotency-key', mapped.idempotencyKey); req.json(mapped.request); - req.appendTemplatePath`/customers/${mapped.customerId}/addresses/${mapped.addressId}`; + req.appendTemplatePath`/customers/${mapped.customerId}/cards/${mapped.cardId}`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getAddressResponseSchema, requestOptions); + return req.callAsJson(getCardResponseSchema, requestOptions); } /** @@ -183,49 +180,52 @@ export class CustomersController extends BaseController { } /** - * Creates a new address for a customer + * Delete a Customer's access tokens + * + * @param customerId Customer Id + * @return Response from the API call + */ + async deleteAccessTokens( + customerId: string, + requestOptions?: RequestOptions + ): Promise> { + const req = this.createRequest('GET'); + const mapped = req.prepareArgs({ customerId: [customerId, string()] }); + req.appendTemplatePath`/customers/${mapped.customerId}/access-tokens/`; + req.authenticate([{ httpBasic: true }]); + return req.callAsJson(listAccessTokensResponseSchema, requestOptions); + } + + /** + * Updates an address * * @param customerId Customer Id - * @param request Request for creating an address + * @param addressId Address Id + * @param request Request for updating an address * @param idempotencyKey * @return Response from the API call */ - async createAddress( + async updateAddress( customerId: string, - request: CreateAddressRequest, + addressId: string, + request: UpdateAddressRequest, idempotencyKey?: string, requestOptions?: RequestOptions ): Promise> { - const req = this.createRequest('POST'); + const req = this.createRequest('PUT'); const mapped = req.prepareArgs({ customerId: [customerId, string()], - request: [request, createAddressRequestSchema], + addressId: [addressId, string()], + request: [request, updateAddressRequestSchema], idempotencyKey: [idempotencyKey, optional(string())], }); req.header('idempotency-key', mapped.idempotencyKey); req.json(mapped.request); - req.appendTemplatePath`/customers/${mapped.customerId}/addresses`; + req.appendTemplatePath`/customers/${mapped.customerId}/addresses/${mapped.addressId}`; req.authenticate([{ httpBasic: true }]); return req.callAsJson(getAddressResponseSchema, requestOptions); } - /** - * Delete a Customer's access tokens - * - * @param customerId Customer Id - * @return Response from the API call - */ - async deleteAccessTokens( - customerId: string, - requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('GET'); - const mapped = req.prepareArgs({ customerId: [customerId, string()] }); - req.appendTemplatePath`/customers/${mapped.customerId}/access-tokens/`; - req.authenticate([{ httpBasic: true }]); - return req.callAsJson(listAccessTokensResponseSchema, requestOptions); - } - /** * Get a customer's address * @@ -274,33 +274,6 @@ export class CustomersController extends BaseController { return req.callAsJson(getAddressResponseSchema, requestOptions); } - /** - * Creates a new card for a customer - * - * @param customerId Customer id - * @param request Request for creating a card - * @param idempotencyKey - * @return Response from the API call - */ - async createCard( - customerId: string, - request: CreateCardRequest, - idempotencyKey?: string, - requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('POST'); - const mapped = req.prepareArgs({ - customerId: [customerId, string()], - request: [request, createCardRequestSchema], - idempotencyKey: [idempotencyKey, optional(string())], - }); - req.header('idempotency-key', mapped.idempotencyKey); - req.json(mapped.request); - req.appendTemplatePath`/customers/${mapped.customerId}/cards`; - req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getCardResponseSchema, requestOptions); - } - /** * Get all Customers * @@ -341,135 +314,103 @@ export class CustomersController extends BaseController { } /** - * Updates a customer + * Get all access tokens from a customer * - * @param customerId Customer id - * @param request Request for updating a customer - * @param idempotencyKey + * @param customerId Customer Id + * @param page Page number + * @param size Page size * @return Response from the API call */ - async updateCustomer( + async getAccessTokens( customerId: string, - request: UpdateCustomerRequest, - idempotencyKey?: string, + page?: number, + size?: number, requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('PUT'); + ): Promise> { + const req = this.createRequest('GET'); const mapped = req.prepareArgs({ customerId: [customerId, string()], - request: [request, updateCustomerRequestSchema], - idempotencyKey: [idempotencyKey, optional(string())], + page: [page, optional(number())], + size: [size, optional(number())], }); - req.header('idempotency-key', mapped.idempotencyKey); - req.json(mapped.request); - req.appendTemplatePath`/customers/${mapped.customerId}`; + req.query('page', mapped.page); + req.query('size', mapped.size); + req.appendTemplatePath`/customers/${mapped.customerId}/access-tokens`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getCustomerResponseSchema, requestOptions); + return req.callAsJson(listAccessTokensResponseSchema, requestOptions); } /** - * Creates a access token for a customer + * Delete a customer's card * * @param customerId Customer Id - * @param request Request for creating a access token + * @param cardId Card Id * @param idempotencyKey * @return Response from the API call */ - async createAccessToken( + async deleteCard( customerId: string, - request: CreateAccessTokenRequest, + cardId: string, idempotencyKey?: string, requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('POST'); + ): Promise> { + const req = this.createRequest('DELETE'); const mapped = req.prepareArgs({ customerId: [customerId, string()], - request: [request, createAccessTokenRequestSchema], + cardId: [cardId, string()], idempotencyKey: [idempotencyKey, optional(string())], }); req.header('idempotency-key', mapped.idempotencyKey); - req.json(mapped.request); - req.appendTemplatePath`/customers/${mapped.customerId}/access-tokens`; - req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getAccessTokenResponseSchema, requestOptions); - } - - /** - * Get all access tokens from a customer - * - * @param customerId Customer Id - * @param page Page number - * @param size Page size - * @return Response from the API call - */ - async getAccessTokens( - customerId: string, - page?: number, - size?: number, - requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('GET'); - const mapped = req.prepareArgs({ - customerId: [customerId, string()], - page: [page, optional(number())], - size: [size, optional(number())], - }); - req.query('page', mapped.page); - req.query('size', mapped.size); - req.appendTemplatePath`/customers/${mapped.customerId}/access-tokens`; + req.appendTemplatePath`/customers/${mapped.customerId}/cards/${mapped.cardId}`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(listAccessTokensResponseSchema, requestOptions); + return req.callAsJson(getCardResponseSchema, requestOptions); } /** - * Get all cards from a customer + * Get a customer's card * - * @param customerId Customer Id - * @param page Page number - * @param size Page size + * @param customerId Customer id + * @param cardId Card id * @return Response from the API call */ - async getCards( + async getCard( customerId: string, - page?: number, - size?: number, + cardId: string, requestOptions?: RequestOptions - ): Promise> { + ): Promise> { const req = this.createRequest('GET'); const mapped = req.prepareArgs({ customerId: [customerId, string()], - page: [page, optional(number())], - size: [size, optional(number())], + cardId: [cardId, string()], }); - req.query('page', mapped.page); - req.query('size', mapped.size); - req.appendTemplatePath`/customers/${mapped.customerId}/cards`; + req.appendTemplatePath`/customers/${mapped.customerId}/cards/${mapped.cardId}`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(listCardsResponseSchema, requestOptions); + return req.callAsJson(getCardResponseSchema, requestOptions); } /** - * Renew a card + * Creates a new card for a customer * * @param customerId Customer id - * @param cardId Card Id + * @param request Request for creating a card * @param idempotencyKey * @return Response from the API call */ - async renewCard( + async createCard( customerId: string, - cardId: string, + request: CreateCardRequest, idempotencyKey?: string, requestOptions?: RequestOptions ): Promise> { const req = this.createRequest('POST'); const mapped = req.prepareArgs({ customerId: [customerId, string()], - cardId: [cardId, string()], + request: [request, createCardRequestSchema], idempotencyKey: [idempotencyKey, optional(string())], }); req.header('idempotency-key', mapped.idempotencyKey); - req.appendTemplatePath`/customers/${mapped.customerId}/cards/${mapped.cardId}/renew`; + req.json(mapped.request); + req.appendTemplatePath`/customers/${mapped.customerId}/cards`; req.authenticate([{ httpBasic: true }]); return req.callAsJson(getCardResponseSchema, requestOptions); } @@ -497,72 +438,100 @@ export class CustomersController extends BaseController { } /** - * Updates the metadata a customer + * Gets all adressess from a customer * - * @param customerId The customer id - * @param request Request for updating the customer metadata + * @param customerId Customer id + * @param page Page number + * @param size Page size + * @return Response from the API call + */ + async getAddresses( + customerId: string, + page?: number, + size?: number, + requestOptions?: RequestOptions + ): Promise> { + const req = this.createRequest('GET'); + const mapped = req.prepareArgs({ + customerId: [customerId, string()], + page: [page, optional(number())], + size: [size, optional(number())], + }); + req.query('page', mapped.page); + req.query('size', mapped.size); + req.appendTemplatePath`/customers/${mapped.customerId}/addresses`; + req.authenticate([{ httpBasic: true }]); + return req.callAsJson(listAddressesResponseSchema, requestOptions); + } + + /** + * Updates a customer + * + * @param customerId Customer id + * @param request Request for updating a customer * @param idempotencyKey * @return Response from the API call */ - async updateCustomerMetadata( + async updateCustomer( customerId: string, - request: UpdateMetadataRequest, + request: UpdateCustomerRequest, idempotencyKey?: string, requestOptions?: RequestOptions ): Promise> { - const req = this.createRequest('PATCH'); + const req = this.createRequest('PUT'); const mapped = req.prepareArgs({ customerId: [customerId, string()], - request: [request, updateMetadataRequestSchema], + request: [request, updateCustomerRequestSchema], idempotencyKey: [idempotencyKey, optional(string())], }); req.header('idempotency-key', mapped.idempotencyKey); req.json(mapped.request); - req.appendTemplatePath`/Customers/${mapped.customerId}/metadata`; + req.appendTemplatePath`/customers/${mapped.customerId}`; req.authenticate([{ httpBasic: true }]); return req.callAsJson(getCustomerResponseSchema, requestOptions); } /** - * Delete a customer's card + * Creates a access token for a customer * * @param customerId Customer Id - * @param cardId Card Id + * @param request Request for creating a access token * @param idempotencyKey * @return Response from the API call */ - async deleteCard( + async createAccessToken( customerId: string, - cardId: string, + request: CreateAccessTokenRequest, idempotencyKey?: string, requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('DELETE'); + ): Promise> { + const req = this.createRequest('POST'); const mapped = req.prepareArgs({ customerId: [customerId, string()], - cardId: [cardId, string()], + request: [request, createAccessTokenRequestSchema], idempotencyKey: [idempotencyKey, optional(string())], }); req.header('idempotency-key', mapped.idempotencyKey); - req.appendTemplatePath`/customers/${mapped.customerId}/cards/${mapped.cardId}`; + req.json(mapped.request); + req.appendTemplatePath`/customers/${mapped.customerId}/access-tokens`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getCardResponseSchema, requestOptions); + return req.callAsJson(getAccessTokenResponseSchema, requestOptions); } /** - * Gets all adressess from a customer + * Get all cards from a customer * - * @param customerId Customer id + * @param customerId Customer Id * @param page Page number * @param size Page size * @return Response from the API call */ - async getAddresses( + async getCards( customerId: string, page?: number, size?: number, requestOptions?: RequestOptions - ): Promise> { + ): Promise> { const req = this.createRequest('GET'); const mapped = req.prepareArgs({ customerId: [customerId, string()], @@ -571,47 +540,78 @@ export class CustomersController extends BaseController { }); req.query('page', mapped.page); req.query('size', mapped.size); - req.appendTemplatePath`/customers/${mapped.customerId}/addresses`; + req.appendTemplatePath`/customers/${mapped.customerId}/cards`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(listAddressesResponseSchema, requestOptions); + return req.callAsJson(listCardsResponseSchema, requestOptions); } /** - * Get a customer + * Renew a card * - * @param customerId Customer Id + * @param customerId Customer id + * @param cardId Card Id + * @param idempotencyKey * @return Response from the API call */ - async getCustomer( + async renewCard( customerId: string, + cardId: string, + idempotencyKey?: string, requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('GET'); - const mapped = req.prepareArgs({ customerId: [customerId, string()] }); - req.appendTemplatePath`/customers/${mapped.customerId}`; + ): Promise> { + const req = this.createRequest('POST'); + const mapped = req.prepareArgs({ + customerId: [customerId, string()], + cardId: [cardId, string()], + idempotencyKey: [idempotencyKey, optional(string())], + }); + req.header('idempotency-key', mapped.idempotencyKey); + req.appendTemplatePath`/customers/${mapped.customerId}/cards/${mapped.cardId}/renew`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getCustomerResponseSchema, requestOptions); + return req.callAsJson(getCardResponseSchema, requestOptions); } /** - * Get a customer's card + * Updates the metadata a customer * - * @param customerId Customer id - * @param cardId Card id + * @param customerId The customer id + * @param request Request for updating the customer metadata + * @param idempotencyKey * @return Response from the API call */ - async getCard( + async updateCustomerMetadata( customerId: string, - cardId: string, + request: UpdateMetadataRequest, + idempotencyKey?: string, requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('GET'); + ): Promise> { + const req = this.createRequest('PATCH'); const mapped = req.prepareArgs({ customerId: [customerId, string()], - cardId: [cardId, string()], + request: [request, updateMetadataRequestSchema], + idempotencyKey: [idempotencyKey, optional(string())], }); - req.appendTemplatePath`/customers/${mapped.customerId}/cards/${mapped.cardId}`; + req.header('idempotency-key', mapped.idempotencyKey); + req.json(mapped.request); + req.appendTemplatePath`/Customers/${mapped.customerId}/metadata`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getCardResponseSchema, requestOptions); + return req.callAsJson(getCustomerResponseSchema, requestOptions); + } + + /** + * Get a customer + * + * @param customerId Customer Id + * @return Response from the API call + */ + async getCustomer( + customerId: string, + requestOptions?: RequestOptions + ): Promise> { + const req = this.createRequest('GET'); + const mapped = req.prepareArgs({ customerId: [customerId, string()] }); + req.appendTemplatePath`/customers/${mapped.customerId}`; + req.authenticate([{ httpBasic: true }]); + return req.callAsJson(getCustomerResponseSchema, requestOptions); } } diff --git a/src/controllers/invoicesController.ts b/src/controllers/invoicesController.ts index 11a99c4..41e5ba4 100644 --- a/src/controllers/invoicesController.ts +++ b/src/controllers/invoicesController.ts @@ -29,103 +29,6 @@ import { number, optional, string } from '../schema'; import { BaseController } from './baseController'; export class InvoicesController extends BaseController { - /** - * Updates the metadata from an invoice - * - * @param invoiceId The invoice id - * @param request Request for updating the invoice metadata - * @param idempotencyKey - * @return Response from the API call - */ - async updateInvoiceMetadata( - invoiceId: string, - request: UpdateMetadataRequest, - idempotencyKey?: string, - requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('PATCH'); - const mapped = req.prepareArgs({ - invoiceId: [invoiceId, string()], - request: [request, updateMetadataRequestSchema], - idempotencyKey: [idempotencyKey, optional(string())], - }); - req.header('idempotency-key', mapped.idempotencyKey); - req.json(mapped.request); - req.appendTemplatePath`/invoices/${mapped.invoiceId}/metadata`; - req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getInvoiceResponseSchema, requestOptions); - } - - /** - * @param subscriptionId Subscription Id - * @return Response from the API call - */ - async getPartialInvoice( - subscriptionId: string, - requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('GET'); - const mapped = req.prepareArgs({ - subscriptionId: [subscriptionId, string()], - }); - req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/partial-invoice`; - req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getInvoiceResponseSchema, requestOptions); - } - - /** - * Cancels an invoice - * - * @param invoiceId Invoice id - * @param idempotencyKey - * @return Response from the API call - */ - async cancelInvoice( - invoiceId: string, - idempotencyKey?: string, - requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('DELETE'); - const mapped = req.prepareArgs({ - invoiceId: [invoiceId, string()], - idempotencyKey: [idempotencyKey, optional(string())], - }); - req.header('idempotency-key', mapped.idempotencyKey); - req.appendTemplatePath`/invoices/${mapped.invoiceId}`; - req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getInvoiceResponseSchema, requestOptions); - } - - /** - * Create an Invoice - * - * @param subscriptionId Subscription Id - * @param cycleId Cycle Id - * @param request - * @param idempotencyKey - * @return Response from the API call - */ - async createInvoice( - subscriptionId: string, - cycleId: string, - request?: CreateInvoiceRequest, - idempotencyKey?: string, - requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('POST'); - const mapped = req.prepareArgs({ - subscriptionId: [subscriptionId, string()], - cycleId: [cycleId, string()], - request: [request, optional(createInvoiceRequestSchema)], - idempotencyKey: [idempotencyKey, optional(string())], - }); - req.header('idempotency-key', mapped.idempotencyKey); - req.json(mapped.request); - req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/cycles/${mapped.cycleId}/pay`; - req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getInvoiceResponseSchema, requestOptions); - } - /** * Gets all invoices * @@ -186,17 +89,23 @@ export class InvoicesController extends BaseController { } /** - * Gets an invoice + * Cancels an invoice * - * @param invoiceId Invoice Id + * @param invoiceId Invoice id + * @param idempotencyKey * @return Response from the API call */ - async getInvoice( + async cancelInvoice( invoiceId: string, + idempotencyKey?: string, requestOptions?: RequestOptions ): Promise> { - const req = this.createRequest('GET'); - const mapped = req.prepareArgs({ invoiceId: [invoiceId, string()] }); + const req = this.createRequest('DELETE'); + const mapped = req.prepareArgs({ + invoiceId: [invoiceId, string()], + idempotencyKey: [idempotencyKey, optional(string())], + }); + req.header('idempotency-key', mapped.idempotencyKey); req.appendTemplatePath`/invoices/${mapped.invoiceId}`; req.authenticate([{ httpBasic: true }]); return req.callAsJson(getInvoiceResponseSchema, requestOptions); @@ -228,4 +137,95 @@ export class InvoicesController extends BaseController { req.authenticate([{ httpBasic: true }]); return req.callAsJson(getInvoiceResponseSchema, requestOptions); } + + /** + * Updates the metadata from an invoice + * + * @param invoiceId The invoice id + * @param request Request for updating the invoice metadata + * @param idempotencyKey + * @return Response from the API call + */ + async updateInvoiceMetadata( + invoiceId: string, + request: UpdateMetadataRequest, + idempotencyKey?: string, + requestOptions?: RequestOptions + ): Promise> { + const req = this.createRequest('PATCH'); + const mapped = req.prepareArgs({ + invoiceId: [invoiceId, string()], + request: [request, updateMetadataRequestSchema], + idempotencyKey: [idempotencyKey, optional(string())], + }); + req.header('idempotency-key', mapped.idempotencyKey); + req.json(mapped.request); + req.appendTemplatePath`/invoices/${mapped.invoiceId}/metadata`; + req.authenticate([{ httpBasic: true }]); + return req.callAsJson(getInvoiceResponseSchema, requestOptions); + } + + /** + * @param subscriptionId Subscription Id + * @return Response from the API call + */ + async getPartialInvoice( + subscriptionId: string, + requestOptions?: RequestOptions + ): Promise> { + const req = this.createRequest('GET'); + const mapped = req.prepareArgs({ + subscriptionId: [subscriptionId, string()], + }); + req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/partial-invoice`; + req.authenticate([{ httpBasic: true }]); + return req.callAsJson(getInvoiceResponseSchema, requestOptions); + } + + /** + * Create an Invoice + * + * @param subscriptionId Subscription Id + * @param cycleId Cycle Id + * @param request + * @param idempotencyKey + * @return Response from the API call + */ + async createInvoice( + subscriptionId: string, + cycleId: string, + request?: CreateInvoiceRequest, + idempotencyKey?: string, + requestOptions?: RequestOptions + ): Promise> { + const req = this.createRequest('POST'); + const mapped = req.prepareArgs({ + subscriptionId: [subscriptionId, string()], + cycleId: [cycleId, string()], + request: [request, optional(createInvoiceRequestSchema)], + idempotencyKey: [idempotencyKey, optional(string())], + }); + req.header('idempotency-key', mapped.idempotencyKey); + req.json(mapped.request); + req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/cycles/${mapped.cycleId}/pay`; + req.authenticate([{ httpBasic: true }]); + return req.callAsJson(getInvoiceResponseSchema, requestOptions); + } + + /** + * Gets an invoice + * + * @param invoiceId Invoice Id + * @return Response from the API call + */ + async getInvoice( + invoiceId: string, + requestOptions?: RequestOptions + ): Promise> { + const req = this.createRequest('GET'); + const mapped = req.prepareArgs({ invoiceId: [invoiceId, string()] }); + req.appendTemplatePath`/invoices/${mapped.invoiceId}`; + req.authenticate([{ httpBasic: true }]); + return req.callAsJson(getInvoiceResponseSchema, requestOptions); + } } diff --git a/src/controllers/ordersController.ts b/src/controllers/ordersController.ts index ad3cafe..638c862 100644 --- a/src/controllers/ordersController.ts +++ b/src/controllers/ordersController.ts @@ -41,6 +41,115 @@ import { number, optional, string } from '../schema'; import { BaseController } from './baseController'; export class OrdersController extends BaseController { + /** + * @param orderId Order Id + * @param idempotencyKey + * @return Response from the API call + */ + async deleteAllOrderItems( + orderId: string, + idempotencyKey?: string, + requestOptions?: RequestOptions + ): Promise> { + const req = this.createRequest('DELETE'); + const mapped = req.prepareArgs({ + orderId: [orderId, string()], + idempotencyKey: [idempotencyKey, optional(string())], + }); + req.header('idempotency-key', mapped.idempotencyKey); + req.appendTemplatePath`/orders/${mapped.orderId}/items`; + req.authenticate([{ httpBasic: true }]); + return req.callAsJson(getOrderResponseSchema, requestOptions); + } + + /** + * @param orderId Order Id + * @param itemId Item Id + * @return Response from the API call + */ + async getOrderItem( + orderId: string, + itemId: string, + requestOptions?: RequestOptions + ): Promise> { + const req = this.createRequest('GET'); + const mapped = req.prepareArgs({ + orderId: [orderId, string()], + itemId: [itemId, string()], + }); + req.appendTemplatePath`/orders/${mapped.orderId}/items/${mapped.itemId}`; + req.authenticate([{ httpBasic: true }]); + return req.callAsJson(getOrderItemResponseSchema, requestOptions); + } + + /** + * Updates the metadata from an order + * + * @param orderId The order id + * @param request Request for updating the order metadata + * @param idempotencyKey + * @return Response from the API call + */ + async updateOrderMetadata( + orderId: string, + request: UpdateMetadataRequest, + idempotencyKey?: string, + requestOptions?: RequestOptions + ): Promise> { + const req = this.createRequest('PATCH'); + const mapped = req.prepareArgs({ + orderId: [orderId, string()], + request: [request, updateMetadataRequestSchema], + idempotencyKey: [idempotencyKey, optional(string())], + }); + req.header('idempotency-key', mapped.idempotencyKey); + req.json(mapped.request); + req.appendTemplatePath`/Orders/${mapped.orderId}/metadata`; + req.authenticate([{ httpBasic: true }]); + return req.callAsJson(getOrderResponseSchema, requestOptions); + } + + /** + * @param orderId Order Id + * @param itemId Item Id + * @param idempotencyKey + * @return Response from the API call + */ + async deleteOrderItem( + orderId: string, + itemId: string, + idempotencyKey?: string, + requestOptions?: RequestOptions + ): Promise> { + const req = this.createRequest('DELETE'); + const mapped = req.prepareArgs({ + orderId: [orderId, string()], + itemId: [itemId, string()], + idempotencyKey: [idempotencyKey, optional(string())], + }); + req.header('idempotency-key', mapped.idempotencyKey); + req.appendTemplatePath`/orders/${mapped.orderId}/items/${mapped.itemId}`; + req.authenticate([{ httpBasic: true }]); + return req.callAsJson(getOrderItemResponseSchema, requestOptions); + } + + /** + * Gets an order + * + * @param orderId Order id + * @return Response from the API call + */ + async getOrder( + orderId: string, + requestOptions?: RequestOptions + ): Promise> { + const req = this.createRequest('GET'); + const mapped = req.prepareArgs({ orderId: [orderId, string()] }); + req.appendTemplatePath`/orders/${mapped.orderId}`; + req.authenticate([{ httpBasic: true }]); + return req.callAsJson(getOrderResponseSchema, requestOptions); + } + /** * Gets all orders * @@ -112,51 +221,6 @@ export class OrdersController extends BaseController { return req.callAsJson(getOrderItemResponseSchema, requestOptions); } - /** - * @param orderId Order Id - * @param idempotencyKey - * @return Response from the API call - */ - async deleteAllOrderItems( - orderId: string, - idempotencyKey?: string, - requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('DELETE'); - const mapped = req.prepareArgs({ - orderId: [orderId, string()], - idempotencyKey: [idempotencyKey, optional(string())], - }); - req.header('idempotency-key', mapped.idempotencyKey); - req.appendTemplatePath`/orders/${mapped.orderId}/items`; - req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getOrderResponseSchema, requestOptions); - } - - /** - * @param orderId Order Id - * @param itemId Item Id - * @param idempotencyKey - * @return Response from the API call - */ - async deleteOrderItem( - orderId: string, - itemId: string, - idempotencyKey?: string, - requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('DELETE'); - const mapped = req.prepareArgs({ - orderId: [orderId, string()], - itemId: [itemId, string()], - idempotencyKey: [idempotencyKey, optional(string())], - }); - req.header('idempotency-key', mapped.idempotencyKey); - req.appendTemplatePath`/orders/${mapped.orderId}/items/${mapped.itemId}`; - req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getOrderItemResponseSchema, requestOptions); - } - /** * @param id Order Id * @param request Update Order Model @@ -229,68 +293,4 @@ export class OrdersController extends BaseController { req.authenticate([{ httpBasic: true }]); return req.callAsJson(getOrderItemResponseSchema, requestOptions); } - - /** - * @param orderId Order Id - * @param itemId Item Id - * @return Response from the API call - */ - async getOrderItem( - orderId: string, - itemId: string, - requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('GET'); - const mapped = req.prepareArgs({ - orderId: [orderId, string()], - itemId: [itemId, string()], - }); - req.appendTemplatePath`/orders/${mapped.orderId}/items/${mapped.itemId}`; - req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getOrderItemResponseSchema, requestOptions); - } - - /** - * Updates the metadata from an order - * - * @param orderId The order id - * @param request Request for updating the order metadata - * @param idempotencyKey - * @return Response from the API call - */ - async updateOrderMetadata( - orderId: string, - request: UpdateMetadataRequest, - idempotencyKey?: string, - requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('PATCH'); - const mapped = req.prepareArgs({ - orderId: [orderId, string()], - request: [request, updateMetadataRequestSchema], - idempotencyKey: [idempotencyKey, optional(string())], - }); - req.header('idempotency-key', mapped.idempotencyKey); - req.json(mapped.request); - req.appendTemplatePath`/Orders/${mapped.orderId}/metadata`; - req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getOrderResponseSchema, requestOptions); - } - - /** - * Gets an order - * - * @param orderId Order id - * @return Response from the API call - */ - async getOrder( - orderId: string, - requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('GET'); - const mapped = req.prepareArgs({ orderId: [orderId, string()] }); - req.appendTemplatePath`/orders/${mapped.orderId}`; - req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getOrderResponseSchema, requestOptions); - } } diff --git a/src/controllers/plansController.ts b/src/controllers/plansController.ts index 6163f4d..92a8f4a 100644 --- a/src/controllers/plansController.ts +++ b/src/controllers/plansController.ts @@ -59,26 +59,29 @@ export class PlansController extends BaseController { } /** - * Deletes a plan + * Removes an item from a plan * * @param planId Plan id + * @param planItemId Plan item id * @param idempotencyKey * @return Response from the API call */ - async deletePlan( + async deletePlanItem( planId: string, + planItemId: string, idempotencyKey?: string, requestOptions?: RequestOptions - ): Promise> { + ): Promise> { const req = this.createRequest('DELETE'); const mapped = req.prepareArgs({ planId: [planId, string()], + planItemId: [planItemId, string()], idempotencyKey: [idempotencyKey, optional(string())], }); req.header('idempotency-key', mapped.idempotencyKey); - req.appendTemplatePath`/plans/${mapped.planId}`; + req.appendTemplatePath`/plans/${mapped.planId}/items/${mapped.planItemId}`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getPlanResponseSchema, requestOptions); + return req.callAsJson(getPlanItemResponseSchema, requestOptions); } /** @@ -109,131 +112,76 @@ export class PlansController extends BaseController { } /** - * Updates a plan item + * Creates a new plan * - * @param planId Plan id - * @param planItemId Plan item id - * @param body Request for updating the plan item + * @param body Request for creating a plan * @param idempotencyKey * @return Response from the API call */ - async updatePlanItem( - planId: string, - planItemId: string, - body: UpdatePlanItemRequest, + async createPlan( + body: CreatePlanRequest, idempotencyKey?: string, requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('PUT'); + ): Promise> { + const req = this.createRequest('POST', '/plans'); const mapped = req.prepareArgs({ - planId: [planId, string()], - planItemId: [planItemId, string()], - body: [body, updatePlanItemRequestSchema], + body: [body, createPlanRequestSchema], idempotencyKey: [idempotencyKey, optional(string())], }); req.header('idempotency-key', mapped.idempotencyKey); req.json(mapped.body); - req.appendTemplatePath`/plans/${mapped.planId}/items/${mapped.planItemId}`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getPlanItemResponseSchema, requestOptions); + return req.callAsJson(getPlanResponseSchema, requestOptions); } /** - * Adds a new item to a plan + * Updates a plan * * @param planId Plan id - * @param request Request for creating a plan item + * @param request Request for updating a plan * @param idempotencyKey * @return Response from the API call */ - async createPlanItem( + async updatePlan( planId: string, - request: CreatePlanItemRequest, + request: UpdatePlanRequest, idempotencyKey?: string, requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('POST'); + ): Promise> { + const req = this.createRequest('PUT'); const mapped = req.prepareArgs({ planId: [planId, string()], - request: [request, createPlanItemRequestSchema], + request: [request, updatePlanRequestSchema], idempotencyKey: [idempotencyKey, optional(string())], }); req.header('idempotency-key', mapped.idempotencyKey); req.json(mapped.request); - req.appendTemplatePath`/plans/${mapped.planId}/items`; - req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getPlanItemResponseSchema, requestOptions); - } - - /** - * Gets a plan item - * - * @param planId Plan id - * @param planItemId Plan item id - * @return Response from the API call - */ - async getPlanItem( - planId: string, - planItemId: string, - requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('GET'); - const mapped = req.prepareArgs({ - planId: [planId, string()], - planItemId: [planItemId, string()], - }); - req.appendTemplatePath`/plans/${mapped.planId}/items/${mapped.planItemId}`; - req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getPlanItemResponseSchema, requestOptions); - } - - /** - * Creates a new plan - * - * @param body Request for creating a plan - * @param idempotencyKey - * @return Response from the API call - */ - async createPlan( - body: CreatePlanRequest, - idempotencyKey?: string, - requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('POST', '/plans'); - const mapped = req.prepareArgs({ - body: [body, createPlanRequestSchema], - idempotencyKey: [idempotencyKey, optional(string())], - }); - req.header('idempotency-key', mapped.idempotencyKey); - req.json(mapped.body); + req.appendTemplatePath`/plans/${mapped.planId}`; req.authenticate([{ httpBasic: true }]); return req.callAsJson(getPlanResponseSchema, requestOptions); } /** - * Removes an item from a plan + * Deletes a plan * * @param planId Plan id - * @param planItemId Plan item id * @param idempotencyKey * @return Response from the API call */ - async deletePlanItem( + async deletePlan( planId: string, - planItemId: string, idempotencyKey?: string, requestOptions?: RequestOptions - ): Promise> { + ): Promise> { const req = this.createRequest('DELETE'); const mapped = req.prepareArgs({ planId: [planId, string()], - planItemId: [planItemId, string()], idempotencyKey: [idempotencyKey, optional(string())], }); req.header('idempotency-key', mapped.idempotencyKey); - req.appendTemplatePath`/plans/${mapped.planId}/items/${mapped.planItemId}`; + req.appendTemplatePath`/plans/${mapped.planId}`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getPlanItemResponseSchema, requestOptions); + return req.callAsJson(getPlanResponseSchema, requestOptions); } /** @@ -280,29 +228,81 @@ export class PlansController extends BaseController { } /** - * Updates a plan + * Updates a plan item * * @param planId Plan id - * @param request Request for updating a plan + * @param planItemId Plan item id + * @param body Request for updating the plan item * @param idempotencyKey * @return Response from the API call */ - async updatePlan( + async updatePlanItem( planId: string, - request: UpdatePlanRequest, + planItemId: string, + body: UpdatePlanItemRequest, idempotencyKey?: string, requestOptions?: RequestOptions - ): Promise> { + ): Promise> { const req = this.createRequest('PUT'); const mapped = req.prepareArgs({ planId: [planId, string()], - request: [request, updatePlanRequestSchema], + planItemId: [planItemId, string()], + body: [body, updatePlanItemRequestSchema], + idempotencyKey: [idempotencyKey, optional(string())], + }); + req.header('idempotency-key', mapped.idempotencyKey); + req.json(mapped.body); + req.appendTemplatePath`/plans/${mapped.planId}/items/${mapped.planItemId}`; + req.authenticate([{ httpBasic: true }]); + return req.callAsJson(getPlanItemResponseSchema, requestOptions); + } + + /** + * Adds a new item to a plan + * + * @param planId Plan id + * @param request Request for creating a plan item + * @param idempotencyKey + * @return Response from the API call + */ + async createPlanItem( + planId: string, + request: CreatePlanItemRequest, + idempotencyKey?: string, + requestOptions?: RequestOptions + ): Promise> { + const req = this.createRequest('POST'); + const mapped = req.prepareArgs({ + planId: [planId, string()], + request: [request, createPlanItemRequestSchema], idempotencyKey: [idempotencyKey, optional(string())], }); req.header('idempotency-key', mapped.idempotencyKey); req.json(mapped.request); - req.appendTemplatePath`/plans/${mapped.planId}`; + req.appendTemplatePath`/plans/${mapped.planId}/items`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getPlanResponseSchema, requestOptions); + return req.callAsJson(getPlanItemResponseSchema, requestOptions); + } + + /** + * Gets a plan item + * + * @param planId Plan id + * @param planItemId Plan item id + * @return Response from the API call + */ + async getPlanItem( + planId: string, + planItemId: string, + requestOptions?: RequestOptions + ): Promise> { + const req = this.createRequest('GET'); + const mapped = req.prepareArgs({ + planId: [planId, string()], + planItemId: [planItemId, string()], + }); + req.appendTemplatePath`/plans/${mapped.planId}/items/${mapped.planItemId}`; + req.authenticate([{ httpBasic: true }]); + return req.callAsJson(getPlanItemResponseSchema, requestOptions); } } diff --git a/src/controllers/recipientsController.ts b/src/controllers/recipientsController.ts index e4021c5..31f46eb 100644 --- a/src/controllers/recipientsController.ts +++ b/src/controllers/recipientsController.ts @@ -77,6 +77,10 @@ import { UpdateRecipientBankAccountRequest, updateRecipientBankAccountRequestSchema, } from '../models/updateRecipientBankAccountRequest'; +import { + UpdateRecipientCodeRequest, + updateRecipientCodeRequestSchema, +} from '../models/updateRecipientCodeRequest'; import { UpdateRecipientRequest, updateRecipientRequestSchema, @@ -117,57 +121,57 @@ export class RecipientsController extends BaseController { } /** - * Creates an anticipation - * - * @param recipientId Recipient id - * @param request Anticipation data - * @param idempotencyKey + * @param recipientId + * @param withdrawalId * @return Response from the API call */ - async createAnticipation( + async getWithdrawById( recipientId: string, - request: CreateAnticipationRequest, - idempotencyKey?: string, + withdrawalId: string, requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('POST'); + ): Promise> { + const req = this.createRequest('GET'); const mapped = req.prepareArgs({ recipientId: [recipientId, string()], - request: [request, createAnticipationRequestSchema], - idempotencyKey: [idempotencyKey, optional(string())], + withdrawalId: [withdrawalId, string()], }); - req.header('idempotency-key', mapped.idempotencyKey); - req.json(mapped.request); - req.appendTemplatePath`/recipients/${mapped.recipientId}/anticipations`; + req.appendTemplatePath`/recipients/${mapped.recipientId}/withdrawals/${mapped.withdrawalId}`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getAnticipationResponseSchema, requestOptions); + return req.callAsJson(getWithdrawResponseSchema, requestOptions); } /** - * Gets the anticipation limits for a recipient + * Retrieves recipient information + * + * @param recipientId Recipiend id + * @return Response from the API call + */ + async getRecipient( + recipientId: string, + requestOptions?: RequestOptions + ): Promise> { + const req = this.createRequest('GET'); + const mapped = req.prepareArgs({ recipientId: [recipientId, string()] }); + req.appendTemplatePath`/recipients/${mapped.recipientId}`; + req.authenticate([{ httpBasic: true }]); + return req.callAsJson(getRecipientResponseSchema, requestOptions); + } + + /** + * Get balance information for a recipient * * @param recipientId Recipient id - * @param timeframe Timeframe - * @param paymentDate Anticipation payment date * @return Response from the API call */ - async getAnticipationLimits( + async getBalance( recipientId: string, - timeframe: string, - paymentDate: string, requestOptions?: RequestOptions - ): Promise> { + ): Promise> { const req = this.createRequest('GET'); - const mapped = req.prepareArgs({ - recipientId: [recipientId, string()], - timeframe: [timeframe, string()], - paymentDate: [paymentDate, string()], - }); - req.query('timeframe', mapped.timeframe); - req.query('payment_date', mapped.paymentDate); - req.appendTemplatePath`/recipients/${mapped.recipientId}/anticipation_limits`; + const mapped = req.prepareArgs({ recipientId: [recipientId, string()] }); + req.appendTemplatePath`/recipients/${mapped.recipientId}/balance`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getAnticipationLimitResponseSchema, requestOptions); + return req.callAsJson(getBalanceResponseSchema, requestOptions); } /** @@ -193,26 +197,6 @@ export class RecipientsController extends BaseController { return req.callAsJson(listRecipientResponseSchema, requestOptions); } - /** - * @param recipientId - * @param withdrawalId - * @return Response from the API call - */ - async getWithdrawById( - recipientId: string, - withdrawalId: string, - requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('GET'); - const mapped = req.prepareArgs({ - recipientId: [recipientId, string()], - withdrawalId: [withdrawalId, string()], - }); - req.appendTemplatePath`/recipients/${mapped.recipientId}/withdrawals/${mapped.withdrawalId}`; - req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getWithdrawResponseSchema, requestOptions); - } - /** * Updates the default bank account from a recipient * @@ -240,33 +224,6 @@ export class RecipientsController extends BaseController { return req.callAsJson(getRecipientResponseSchema, requestOptions); } - /** - * Updates recipient metadata - * - * @param recipientId Recipient id - * @param request Metadata - * @param idempotencyKey - * @return Response from the API call - */ - async updateRecipientMetadata( - recipientId: string, - request: UpdateMetadataRequest, - idempotencyKey?: string, - requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('PATCH'); - const mapped = req.prepareArgs({ - recipientId: [recipientId, string()], - request: [request, updateMetadataRequestSchema], - idempotencyKey: [idempotencyKey, optional(string())], - }); - req.header('idempotency-key', mapped.idempotencyKey); - req.json(mapped.request); - req.appendTemplatePath`/recipients/${mapped.recipientId}/metadata`; - req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getRecipientResponseSchema, requestOptions); - } - /** * Gets a paginated list of transfers for the recipient * @@ -349,6 +306,70 @@ export class RecipientsController extends BaseController { return req.callAsJson(getWithdrawResponseSchema, requestOptions); } + /** + * Gets an anticipation + * + * @param recipientId Recipient id + * @param anticipationId Anticipation id + * @return Response from the API call + */ + async getAnticipation( + recipientId: string, + anticipationId: string, + requestOptions?: RequestOptions + ): Promise> { + const req = this.createRequest('GET'); + const mapped = req.prepareArgs({ + recipientId: [recipientId, string()], + anticipationId: [anticipationId, string()], + }); + req.appendTemplatePath`/recipients/${mapped.recipientId}/anticipations/${mapped.anticipationId}`; + req.authenticate([{ httpBasic: true }]); + return req.callAsJson(getAnticipationResponseSchema, requestOptions); + } + + /** + * @param recipientId Recipient Identificator + * @param request + * @param idempotencyKey + * @return Response from the API call + */ + async updateRecipientTransferSettings( + recipientId: string, + request: UpdateTransferSettingsRequest, + idempotencyKey?: string, + requestOptions?: RequestOptions + ): Promise> { + const req = this.createRequest('PATCH'); + const mapped = req.prepareArgs({ + recipientId: [recipientId, string()], + request: [request, updateTransferSettingsRequestSchema], + idempotencyKey: [idempotencyKey, optional(string())], + }); + req.header('idempotency-key', mapped.idempotencyKey); + req.json(mapped.request); + req.appendTemplatePath`/recipients/${mapped.recipientId}/transfer-settings`; + req.authenticate([{ httpBasic: true }]); + return req.callAsJson(getRecipientResponseSchema, requestOptions); + } + + /** + * Retrieves recipient information + * + * @param code Recipient code + * @return Response from the API call + */ + async getRecipientByCode( + code: string, + requestOptions?: RequestOptions + ): Promise> { + const req = this.createRequest('GET'); + const mapped = req.prepareArgs({ code: [code, string()] }); + req.appendTemplatePath`/recipients/${mapped.code}`; + req.authenticate([{ httpBasic: true }]); + return req.callAsJson(getRecipientResponseSchema, requestOptions); + } + /** * Updates recipient metadata * @@ -377,48 +398,143 @@ export class RecipientsController extends BaseController { } /** - * Gets an anticipation + * Creates a transfer for a recipient + * + * @param recipientId Recipient Id + * @param request Transfer data + * @param idempotencyKey + * @return Response from the API call + */ + async createTransfer( + recipientId: string, + request: CreateTransferRequest, + idempotencyKey?: string, + requestOptions?: RequestOptions + ): Promise> { + const req = this.createRequest('POST'); + const mapped = req.prepareArgs({ + recipientId: [recipientId, string()], + request: [request, createTransferRequestSchema], + idempotencyKey: [idempotencyKey, optional(string())], + }); + req.header('idempotency-key', mapped.idempotencyKey); + req.json(mapped.request); + req.appendTemplatePath`/recipients/${mapped.recipientId}/transfers`; + req.authenticate([{ httpBasic: true }]); + return req.callAsJson(getTransferResponseSchema, requestOptions); + } + + /** + * Creates a new recipient + * + * @param request Recipient data + * @param idempotencyKey + * @return Response from the API call + */ + async createRecipient( + request: CreateRecipientRequest, + idempotencyKey?: string, + requestOptions?: RequestOptions + ): Promise> { + const req = this.createRequest('POST', '/recipients'); + const mapped = req.prepareArgs({ + request: [request, createRecipientRequestSchema], + idempotencyKey: [idempotencyKey, optional(string())], + }); + req.header('idempotency-key', mapped.idempotencyKey); + req.json(mapped.request); + req.authenticate([{ httpBasic: true }]); + return req.callAsJson(getRecipientResponseSchema, requestOptions); + } + + /** + * @return Response from the API call + */ + async getDefaultRecipient( + requestOptions?: RequestOptions + ): Promise> { + const req = this.createRequest('GET', '/recipients/default'); + req.authenticate([{ httpBasic: true }]); + return req.callAsJson(getRecipientResponseSchema, requestOptions); + } + + /** + * Creates an anticipation * * @param recipientId Recipient id - * @param anticipationId Anticipation id + * @param request Anticipation data + * @param idempotencyKey * @return Response from the API call */ - async getAnticipation( + async createAnticipation( recipientId: string, - anticipationId: string, + request: CreateAnticipationRequest, + idempotencyKey?: string, requestOptions?: RequestOptions ): Promise> { - const req = this.createRequest('GET'); + const req = this.createRequest('POST'); const mapped = req.prepareArgs({ recipientId: [recipientId, string()], - anticipationId: [anticipationId, string()], + request: [request, createAnticipationRequestSchema], + idempotencyKey: [idempotencyKey, optional(string())], }); - req.appendTemplatePath`/recipients/${mapped.recipientId}/anticipations/${mapped.anticipationId}`; + req.header('idempotency-key', mapped.idempotencyKey); + req.json(mapped.request); + req.appendTemplatePath`/recipients/${mapped.recipientId}/anticipations`; req.authenticate([{ httpBasic: true }]); return req.callAsJson(getAnticipationResponseSchema, requestOptions); } /** - * @param recipientId Recipient Identificator - * @param request + * Gets the anticipation limits for a recipient + * + * @param recipientId Recipient id + * @param timeframe Timeframe + * @param paymentDate Anticipation payment date + * @return Response from the API call + */ + async getAnticipationLimits( + recipientId: string, + timeframe: string, + paymentDate: string, + requestOptions?: RequestOptions + ): Promise> { + const req = this.createRequest('GET'); + const mapped = req.prepareArgs({ + recipientId: [recipientId, string()], + timeframe: [timeframe, string()], + paymentDate: [paymentDate, string()], + }); + req.query('timeframe', mapped.timeframe); + req.query('payment_date', mapped.paymentDate); + req.appendTemplatePath`/recipients/${mapped.recipientId}/anticipation_limits`; + req.authenticate([{ httpBasic: true }]); + return req.callAsJson(getAnticipationLimitResponseSchema, requestOptions); + } + + /** + * Updates recipient metadata + * + * @param recipientId Recipient id + * @param request Metadata * @param idempotencyKey * @return Response from the API call */ - async updateRecipientTransferSettings( + async updateRecipientMetadata( recipientId: string, - request: UpdateTransferSettingsRequest, + request: UpdateMetadataRequest, idempotencyKey?: string, requestOptions?: RequestOptions ): Promise> { const req = this.createRequest('PATCH'); const mapped = req.prepareArgs({ recipientId: [recipientId, string()], - request: [request, updateTransferSettingsRequestSchema], + request: [request, updateMetadataRequestSchema], idempotencyKey: [idempotencyKey, optional(string())], }); req.header('idempotency-key', mapped.idempotencyKey); req.json(mapped.request); - req.appendTemplatePath`/recipients/${mapped.recipientId}/transfer-settings`; + req.appendTemplatePath`/recipients/${mapped.recipientId}/metadata`; req.authenticate([{ httpBasic: true }]); return req.callAsJson(getRecipientResponseSchema, requestOptions); } @@ -474,40 +590,6 @@ export class RecipientsController extends BaseController { return req.callAsJson(listAnticipationResponseSchema, requestOptions); } - /** - * Retrieves recipient information - * - * @param recipientId Recipiend id - * @return Response from the API call - */ - async getRecipient( - recipientId: string, - requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('GET'); - const mapped = req.prepareArgs({ recipientId: [recipientId, string()] }); - req.appendTemplatePath`/recipients/${mapped.recipientId}`; - req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getRecipientResponseSchema, requestOptions); - } - - /** - * Get balance information for a recipient - * - * @param recipientId Recipient id - * @return Response from the API call - */ - async getBalance( - recipientId: string, - requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('GET'); - const mapped = req.prepareArgs({ recipientId: [recipientId, string()] }); - req.appendTemplatePath`/recipients/${mapped.recipientId}/balance`; - req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getBalanceResponseSchema, requestOptions); - } - /** * Gets a paginated list of transfers for the recipient * @@ -548,97 +630,46 @@ export class RecipientsController extends BaseController { } /** - * Creates a transfer for a recipient + * Create a KYC link * - * @param recipientId Recipient Id - * @param request Transfer data - * @param idempotencyKey + * @param recipientId Recipient id * @return Response from the API call */ - async createTransfer( + async createKYCLink( recipientId: string, - request: CreateTransferRequest, - idempotencyKey?: string, requestOptions?: RequestOptions - ): Promise> { + ): Promise> { const req = this.createRequest('POST'); - const mapped = req.prepareArgs({ - recipientId: [recipientId, string()], - request: [request, createTransferRequestSchema], - idempotencyKey: [idempotencyKey, optional(string())], - }); - req.header('idempotency-key', mapped.idempotencyKey); - req.json(mapped.request); - req.appendTemplatePath`/recipients/${mapped.recipientId}/transfers`; + const mapped = req.prepareArgs({ recipientId: [recipientId, string()] }); + req.appendTemplatePath`/recipients/${mapped.recipientId}/kyc_link`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getTransferResponseSchema, requestOptions); + return req.callAsJson(createKYCLinkResponseSchema, requestOptions); } /** - * Creates a new recipient + * Updates recipient code * - * @param request Recipient data + * @param recipientId Recipient id + * @param request UpdateRecipientCodeRequest * @param idempotencyKey * @return Response from the API call */ - async createRecipient( - request: CreateRecipientRequest, + async updateRecipientCode( + recipientId: string, + request: UpdateRecipientCodeRequest, idempotencyKey?: string, requestOptions?: RequestOptions ): Promise> { - const req = this.createRequest('POST', '/recipients'); + const req = this.createRequest('PATCH'); const mapped = req.prepareArgs({ - request: [request, createRecipientRequestSchema], + recipientId: [recipientId, string()], + request: [request, updateRecipientCodeRequestSchema], idempotencyKey: [idempotencyKey, optional(string())], }); req.header('idempotency-key', mapped.idempotencyKey); req.json(mapped.request); + req.appendTemplatePath`/recipients/${mapped.recipientId}/code`; req.authenticate([{ httpBasic: true }]); return req.callAsJson(getRecipientResponseSchema, requestOptions); } - - /** - * Retrieves recipient information - * - * @param code Recipient code - * @return Response from the API call - */ - async getRecipientByCode( - code: string, - requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('GET'); - const mapped = req.prepareArgs({ code: [code, string()] }); - req.appendTemplatePath`/recipients/${mapped.code}`; - req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getRecipientResponseSchema, requestOptions); - } - - /** - * @return Response from the API call - */ - async getDefaultRecipient( - requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('GET', '/recipients/default'); - req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getRecipientResponseSchema, requestOptions); - } - - /** - * Create a KYC link - * - * @param recipientId Recipient id - * @return Response from the API call - */ - async createKYCLink( - recipientId: string, - requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('POST'); - const mapped = req.prepareArgs({ recipientId: [recipientId, string()] }); - req.appendTemplatePath`/recipients/${mapped.recipientId}/kyc_link`; - req.authenticate([{ httpBasic: true }]); - return req.callAsJson(createKYCLinkResponseSchema, requestOptions); - } } diff --git a/src/controllers/subscriptionsController.ts b/src/controllers/subscriptionsController.ts index e633d27..77198ad 100644 --- a/src/controllers/subscriptionsController.ts +++ b/src/controllers/subscriptionsController.ts @@ -134,159 +134,204 @@ import { BaseController } from './baseController'; export class SubscriptionsController extends BaseController { /** - * @param subscriptionId + * Updates the credit card from a subscription + * + * @param subscriptionId Subscription id + * @param request Request for updating a card * @param idempotencyKey * @return Response from the API call */ - async renewSubscription( + async updateSubscriptionCard( subscriptionId: string, + request: UpdateSubscriptionCardRequest, idempotencyKey?: string, requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('POST'); + ): Promise> { + const req = this.createRequest('PATCH'); const mapped = req.prepareArgs({ subscriptionId: [subscriptionId, string()], + request: [request, updateSubscriptionCardRequestSchema], idempotencyKey: [idempotencyKey, optional(string())], }); req.header('idempotency-key', mapped.idempotencyKey); - req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/cycles`; + req.json(mapped.request); + req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/card`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getPeriodResponseSchema, requestOptions); + return req.callAsJson(getSubscriptionResponseSchema, requestOptions); } /** - * Updates the credit card from a subscription + * Creates a discount * * @param subscriptionId Subscription id - * @param request Request for updating a card + * @param request Request for creating a discount * @param idempotencyKey * @return Response from the API call */ - async updateSubscriptionCard( + async createDiscount( subscriptionId: string, - request: UpdateSubscriptionCardRequest, + request: CreateDiscountRequest, idempotencyKey?: string, requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('PATCH'); + ): Promise> { + const req = this.createRequest('POST'); const mapped = req.prepareArgs({ subscriptionId: [subscriptionId, string()], - request: [request, updateSubscriptionCardRequestSchema], + request: [request, createDiscountRequestSchema], idempotencyKey: [idempotencyKey, optional(string())], }); req.header('idempotency-key', mapped.idempotencyKey); req.json(mapped.request); - req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/card`; + req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/discounts`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getSubscriptionResponseSchema, requestOptions); + return req.callAsJson(getDiscountResponseSchema, requestOptions); } /** - * Deletes a usage + * Updates the billing date from a subscription * * @param subscriptionId The subscription id - * @param itemId The subscription item id - * @param usageId The usage id + * @param request Request for updating the subscription + * billing date * @param idempotencyKey * @return Response from the API call */ - async deleteUsage( + async updateSubscriptionBillingDate( subscriptionId: string, - itemId: string, - usageId: string, + request: UpdateSubscriptionBillingDateRequest, idempotencyKey?: string, requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('DELETE'); + ): Promise> { + const req = this.createRequest('PATCH'); const mapped = req.prepareArgs({ subscriptionId: [subscriptionId, string()], - itemId: [itemId, string()], - usageId: [usageId, string()], + request: [request, updateSubscriptionBillingDateRequestSchema], idempotencyKey: [idempotencyKey, optional(string())], }); req.header('idempotency-key', mapped.idempotencyKey); - req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/items/${mapped.itemId}/usages/${mapped.usageId}`; + req.json(mapped.request); + req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/billing-date`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getUsageResponseSchema, requestOptions); + return req.callAsJson(getSubscriptionResponseSchema, requestOptions); } /** - * Creates a discount + * Updates the start at date from a subscription * - * @param subscriptionId Subscription id - * @param request Request for creating a discount + * @param subscriptionId The subscription id + * @param request Request for updating the subscription start + * date * @param idempotencyKey * @return Response from the API call */ - async createDiscount( + async updateSubscriptionStartAt( subscriptionId: string, - request: CreateDiscountRequest, + request: UpdateSubscriptionStartAtRequest, idempotencyKey?: string, requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('POST'); + ): Promise> { + const req = this.createRequest('PATCH'); const mapped = req.prepareArgs({ subscriptionId: [subscriptionId, string()], - request: [request, createDiscountRequestSchema], + request: [request, updateSubscriptionStartAtRequestSchema], idempotencyKey: [idempotencyKey, optional(string())], }); req.header('idempotency-key', mapped.idempotencyKey); req.json(mapped.request); - req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/discounts`; + req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/start-at`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getDiscountResponseSchema, requestOptions); + return req.callAsJson(getSubscriptionResponseSchema, requestOptions); } /** - * Create Usage + * Gets a subscription * * @param subscriptionId Subscription id - * @param itemId Item id - * @param idempotencyKey * @return Response from the API call */ - async createAnUsage( + async getSubscription( + subscriptionId: string, + requestOptions?: RequestOptions + ): Promise> { + const req = this.createRequest('GET'); + const mapped = req.prepareArgs({ + subscriptionId: [subscriptionId, string()], + }); + req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}`; + req.authenticate([{ httpBasic: true }]); + return req.callAsJson(getSubscriptionResponseSchema, requestOptions); + } + + /** + * Lists all usages from a subscription item + * + * @param subscriptionId The subscription id + * @param itemId The subscription item id + * @param page Page number + * @param size Page size + * @param code Identification code in the client system + * @param group Identification group in the client system + * @param usedSince + * @param usedUntil + * @return Response from the API call + */ + async getUsages( subscriptionId: string, itemId: string, - idempotencyKey?: string, + page?: number, + size?: number, + code?: string, + group?: string, + usedSince?: string, + usedUntil?: string, requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('POST'); + ): Promise> { + const req = this.createRequest('GET'); const mapped = req.prepareArgs({ subscriptionId: [subscriptionId, string()], itemId: [itemId, string()], - idempotencyKey: [idempotencyKey, optional(string())], + page: [page, optional(number())], + size: [size, optional(number())], + code: [code, optional(string())], + group: [group, optional(string())], + usedSince: [usedSince, optional(string())], + usedUntil: [usedUntil, optional(string())], }); - req.header('idempotency-key', mapped.idempotencyKey); + req.query('page', mapped.page); + req.query('size', mapped.size); + req.query('code', mapped.code); + req.query('group', mapped.group); + req.query('used_since', mapped.usedSince); + req.query('used_until', mapped.usedUntil); req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/items/${mapped.itemId}/usages`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getUsageResponseSchema, requestOptions); + return req.callAsJson(listUsagesResponseSchema, requestOptions); } /** - * @param subscriptionId Subscription Id + * @param subscriptionId * @param request Request for updating the end date of the - * subscription current status + * current signature cycle * @param idempotencyKey * @return Response from the API call */ - async updateCurrentCycleStatus( + async updateLatestPeriodEndAt( subscriptionId: string, - request: UpdateCurrentCycleStatusRequest, + request: UpdateCurrentCycleEndDateRequest, idempotencyKey?: string, requestOptions?: RequestOptions - ): Promise> { + ): Promise> { const req = this.createRequest('PATCH'); const mapped = req.prepareArgs({ subscriptionId: [subscriptionId, string()], - request: [request, updateCurrentCycleStatusRequestSchema], + request: [request, updateCurrentCycleEndDateRequestSchema], idempotencyKey: [idempotencyKey, optional(string())], }); req.header('idempotency-key', mapped.idempotencyKey); req.json(mapped.request); - req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/cycle-status`; + req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/periods/latest/end-at`; req.authenticate([{ httpBasic: true }]); - return req.call(requestOptions); + return req.callAsJson(getSubscriptionResponseSchema, requestOptions); } /** @@ -315,57 +360,6 @@ export class SubscriptionsController extends BaseController { return req.callAsJson(getDiscountResponseSchema, requestOptions); } - /** - * Get Subscription Items - * - * @param subscriptionId The subscription id - * @param page Page number - * @param size Page size - * @param name The item name - * @param code Identification code in the client system - * @param status The item statis - * @param description The item description - * @param createdSince Filter for item's creation date start range - * @param createdUntil Filter for item's creation date end range - * @return Response from the API call - */ - async getSubscriptionItems( - subscriptionId: string, - page?: number, - size?: number, - name?: string, - code?: string, - status?: string, - description?: string, - createdSince?: string, - createdUntil?: string, - requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('GET'); - const mapped = req.prepareArgs({ - subscriptionId: [subscriptionId, string()], - page: [page, optional(number())], - size: [size, optional(number())], - name: [name, optional(string())], - code: [code, optional(string())], - status: [status, optional(string())], - description: [description, optional(string())], - createdSince: [createdSince, optional(string())], - createdUntil: [createdUntil, optional(string())], - }); - req.query('page', mapped.page); - req.query('size', mapped.size); - req.query('name', mapped.name); - req.query('code', mapped.code); - req.query('status', mapped.status); - req.query('description', mapped.description); - req.query('created_since', mapped.createdSince); - req.query('created_until', mapped.createdUntil); - req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/items`; - req.authenticate([{ httpBasic: true }]); - return req.callAsJson(listSubscriptionItemsResponseSchema, requestOptions); - } - /** * Updates the payment method from a subscription * @@ -395,288 +389,291 @@ export class SubscriptionsController extends BaseController { } /** - * Get Subscription Item + * Cancels a subscription * - * @param subscriptionId Subscription Id - * @param itemId Item id + * @param subscriptionId Subscription id + * @param request Request for cancelling a subscription + * @param idempotencyKey * @return Response from the API call */ - async getSubscriptionItem( + async cancelSubscription( subscriptionId: string, - itemId: string, + request?: CreateCancelSubscriptionRequest, + idempotencyKey?: string, requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('GET'); + ): Promise> { + const req = this.createRequest('DELETE'); const mapped = req.prepareArgs({ subscriptionId: [subscriptionId, string()], - itemId: [itemId, string()], + request: [request, optional(createCancelSubscriptionRequestSchema)], + idempotencyKey: [idempotencyKey, optional(string())], }); - req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/items/${mapped.itemId}`; + req.header('idempotency-key', mapped.idempotencyKey); + req.json(mapped.request); + req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getSubscriptionItemResponseSchema, requestOptions); + return req.callAsJson(getSubscriptionResponseSchema, requestOptions); } /** - * Gets all subscriptions + * Creates a new subscription * - * @param page Page number - * @param size Page size - * @param code Filter for subscription's code - * @param billingType Filter for subscription's billing type - * @param customerId Filter for subscription's customer id - * @param planId Filter for subscription's plan id - * @param cardId Filter for subscription's card id - * @param status Filter for subscription's status - * @param nextBillingSince Filter for subscription's next billing date start range - * @param nextBillingUntil Filter for subscription's next billing date end range - * @param createdSince Filter for subscription's creation date start range - * @param createdUntil Filter for subscriptions creation date end range + * @param body Request for creating a subscription + * @param idempotencyKey * @return Response from the API call */ - async getSubscriptions( - page?: number, - size?: number, - code?: string, - billingType?: string, - customerId?: string, - planId?: string, - cardId?: string, - status?: string, - nextBillingSince?: string, - nextBillingUntil?: string, - createdSince?: string, - createdUntil?: string, + async createSubscription( + body: CreateSubscriptionRequest, + idempotencyKey?: string, requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('GET', '/subscriptions'); + ): Promise> { + const req = this.createRequest('POST', '/subscriptions'); const mapped = req.prepareArgs({ - page: [page, optional(number())], - size: [size, optional(number())], - code: [code, optional(string())], - billingType: [billingType, optional(string())], - customerId: [customerId, optional(string())], - planId: [planId, optional(string())], - cardId: [cardId, optional(string())], - status: [status, optional(string())], - nextBillingSince: [nextBillingSince, optional(string())], - nextBillingUntil: [nextBillingUntil, optional(string())], - createdSince: [createdSince, optional(string())], - createdUntil: [createdUntil, optional(string())], + body: [body, createSubscriptionRequestSchema], + idempotencyKey: [idempotencyKey, optional(string())], }); - req.query('page', mapped.page); - req.query('size', mapped.size); - req.query('code', mapped.code); - req.query('billing_type', mapped.billingType); - req.query('customer_id', mapped.customerId); - req.query('plan_id', mapped.planId); - req.query('card_id', mapped.cardId); - req.query('status', mapped.status); - req.query('next_billing_since', mapped.nextBillingSince); - req.query('next_billing_until', mapped.nextBillingUntil); - req.query('created_since', mapped.createdSince); - req.query('created_until', mapped.createdUntil); + req.header('idempotency-key', mapped.idempotencyKey); + req.json(mapped.body); req.authenticate([{ httpBasic: true }]); - return req.callAsJson(listSubscriptionsResponseSchema, requestOptions); + return req.callAsJson(getSubscriptionResponseSchema, requestOptions); } /** - * Cancels a subscription - * - * @param subscriptionId Subscription id - * @param request Request for cancelling a subscription + * @param subscriptionId + * @param request Request for updating a subscription + * affiliation id * @param idempotencyKey * @return Response from the API call */ - async cancelSubscription( + async updateSubscriptionAffiliationId( subscriptionId: string, - request?: CreateCancelSubscriptionRequest, + request: UpdateSubscriptionAffiliationIdRequest, idempotencyKey?: string, requestOptions?: RequestOptions ): Promise> { - const req = this.createRequest('DELETE'); + const req = this.createRequest('PATCH'); const mapped = req.prepareArgs({ subscriptionId: [subscriptionId, string()], - request: [request, optional(createCancelSubscriptionRequestSchema)], + request: [request, updateSubscriptionAffiliationIdRequestSchema], idempotencyKey: [idempotencyKey, optional(string())], }); req.header('idempotency-key', mapped.idempotencyKey); req.json(mapped.request); - req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}`; + req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/gateway-affiliation-id`; req.authenticate([{ httpBasic: true }]); return req.callAsJson(getSubscriptionResponseSchema, requestOptions); } /** - * Creates a increment + * Atualização do valor mínimo da assinatura * - * @param subscriptionId Subscription id - * @param request Request for creating a increment + * @param subscriptionId Subscription Id + * @param request Request da requisição com o valor mínimo + * que será configurado * @param idempotencyKey * @return Response from the API call */ - async createIncrement( + async updateSubscriptionMiniumPrice( subscriptionId: string, - request: CreateIncrementRequest, + request: UpdateSubscriptionMinimumPriceRequest, idempotencyKey?: string, requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('POST'); + ): Promise> { + const req = this.createRequest('PATCH'); const mapped = req.prepareArgs({ subscriptionId: [subscriptionId, string()], - request: [request, createIncrementRequestSchema], + request: [request, updateSubscriptionMinimumPriceRequestSchema], idempotencyKey: [idempotencyKey, optional(string())], }); req.header('idempotency-key', mapped.idempotencyKey); req.json(mapped.request); - req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/increments`; + req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/minimum_price`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getIncrementResponseSchema, requestOptions); + return req.callAsJson(getSubscriptionResponseSchema, requestOptions); } /** - * Creates a usage - * - * @param subscriptionId Subscription Id - * @param itemId Item id - * @param body Request for creating a usage - * @param idempotencyKey + * @param subscriptionId The subscription id + * @param cycleId * @return Response from the API call */ - async createUsage( + async getSubscriptionCycleById( subscriptionId: string, - itemId: string, - body: CreateUsageRequest, - idempotencyKey?: string, + cycleId: string, requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('POST'); + ): Promise> { + const req = this.createRequest('GET'); const mapped = req.prepareArgs({ subscriptionId: [subscriptionId, string()], - itemId: [itemId, string()], - body: [body, createUsageRequestSchema], - idempotencyKey: [idempotencyKey, optional(string())], + cycleId: [cycleId, string()], }); - req.header('idempotency-key', mapped.idempotencyKey); - req.json(mapped.body); - req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/items/${mapped.itemId}/usages`; + req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/cycles/${mapped.cycleId}`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getUsageResponseSchema, requestOptions); + return req.callAsJson(getPeriodResponseSchema, requestOptions); } /** - * @param subscriptionId The subscription id - * @param discountId + * @param subscriptionId The subscription Id + * @param periodId The period Id * @return Response from the API call */ - async getDiscountById( + async getUsageReport( subscriptionId: string, - discountId: string, + periodId: string, requestOptions?: RequestOptions - ): Promise> { + ): Promise> { const req = this.createRequest('GET'); const mapped = req.prepareArgs({ subscriptionId: [subscriptionId, string()], - discountId: [discountId, string()], + periodId: [periodId, string()], }); - req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/discounts/${mapped.discountId}`; + req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/periods/${mapped.periodId}/usages/report`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getDiscountResponseSchema, requestOptions); + return req.callAsJson(getUsageReportResponseSchema, requestOptions); } /** - * Creates a new subscription - * - * @param body Request for creating a subscription + * @param subscriptionId * @param idempotencyKey * @return Response from the API call */ - async createSubscription( - body: CreateSubscriptionRequest, + async renewSubscription( + subscriptionId: string, idempotencyKey?: string, requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('POST', '/subscriptions'); + ): Promise> { + const req = this.createRequest('POST'); const mapped = req.prepareArgs({ - body: [body, createSubscriptionRequestSchema], + subscriptionId: [subscriptionId, string()], idempotencyKey: [idempotencyKey, optional(string())], }); req.header('idempotency-key', mapped.idempotencyKey); - req.json(mapped.body); + req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/cycles`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getSubscriptionResponseSchema, requestOptions); + return req.callAsJson(getPeriodResponseSchema, requestOptions); } /** - * @param subscriptionId The subscription Id - * @param incrementId The increment Id + * Deletes a usage + * + * @param subscriptionId The subscription id + * @param itemId The subscription item id + * @param usageId The usage id + * @param idempotencyKey * @return Response from the API call */ - async getIncrementById( + async deleteUsage( subscriptionId: string, - incrementId: string, + itemId: string, + usageId: string, + idempotencyKey?: string, requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('GET'); + ): Promise> { + const req = this.createRequest('DELETE'); const mapped = req.prepareArgs({ subscriptionId: [subscriptionId, string()], - incrementId: [incrementId, string()], + itemId: [itemId, string()], + usageId: [usageId, string()], + idempotencyKey: [idempotencyKey, optional(string())], }); - req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/increments/${mapped.incrementId}`; + req.header('idempotency-key', mapped.idempotencyKey); + req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/items/${mapped.itemId}/usages/${mapped.usageId}`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getIncrementResponseSchema, requestOptions); + return req.callAsJson(getUsageResponseSchema, requestOptions); } /** - * @param subscriptionId - * @param request Request for updating a subscription - * affiliation id + * Create Usage + * + * @param subscriptionId Subscription id + * @param itemId Item id * @param idempotencyKey * @return Response from the API call */ - async updateSubscriptionAffiliationId( + async createAnUsage( subscriptionId: string, - request: UpdateSubscriptionAffiliationIdRequest, + itemId: string, idempotencyKey?: string, requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('PATCH'); + ): Promise> { + const req = this.createRequest('POST'); const mapped = req.prepareArgs({ subscriptionId: [subscriptionId, string()], - request: [request, updateSubscriptionAffiliationIdRequestSchema], + itemId: [itemId, string()], idempotencyKey: [idempotencyKey, optional(string())], }); req.header('idempotency-key', mapped.idempotencyKey); - req.json(mapped.request); - req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/gateway-affiliation-id`; + req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/items/${mapped.itemId}/usages`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getSubscriptionResponseSchema, requestOptions); + return req.callAsJson(getUsageResponseSchema, requestOptions); } /** - * Updates the metadata from a subscription - * - * @param subscriptionId The subscription id - * @param request Request for updating the subscrption metadata + * @param subscriptionId Subscription Id + * @param request Request for updating the end date of the + * subscription current status * @param idempotencyKey * @return Response from the API call */ - async updateSubscriptionMetadata( + async updateCurrentCycleStatus( subscriptionId: string, - request: UpdateMetadataRequest, + request: UpdateCurrentCycleStatusRequest, idempotencyKey?: string, requestOptions?: RequestOptions - ): Promise> { + ): Promise> { const req = this.createRequest('PATCH'); const mapped = req.prepareArgs({ subscriptionId: [subscriptionId, string()], - request: [request, updateMetadataRequestSchema], + request: [request, updateCurrentCycleStatusRequestSchema], idempotencyKey: [idempotencyKey, optional(string())], }); req.header('idempotency-key', mapped.idempotencyKey); req.json(mapped.request); - req.appendTemplatePath`/Subscriptions/${mapped.subscriptionId}/metadata`; + req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/cycle-status`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getSubscriptionResponseSchema, requestOptions); + return req.call(requestOptions); + } + + /** + * Get Subscription Item + * + * @param subscriptionId Subscription Id + * @param itemId Item id + * @return Response from the API call + */ + async getSubscriptionItem( + subscriptionId: string, + itemId: string, + requestOptions?: RequestOptions + ): Promise> { + const req = this.createRequest('GET'); + const mapped = req.prepareArgs({ + subscriptionId: [subscriptionId, string()], + itemId: [itemId, string()], + }); + req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/items/${mapped.itemId}`; + req.authenticate([{ httpBasic: true }]); + return req.callAsJson(getSubscriptionItemResponseSchema, requestOptions); + } + + /** + * @param subscriptionId The subscription Id + * @param incrementId The increment Id + * @return Response from the API call + */ + async getIncrementById( + subscriptionId: string, + incrementId: string, + requestOptions?: RequestOptions + ): Promise> { + const req = this.createRequest('GET'); + const mapped = req.prepareArgs({ + subscriptionId: [subscriptionId, string()], + incrementId: [incrementId, string()], + }); + req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/increments/${mapped.incrementId}`; + req.authenticate([{ httpBasic: true }]); + return req.callAsJson(getIncrementResponseSchema, requestOptions); } /** @@ -706,37 +703,12 @@ export class SubscriptionsController extends BaseController { } /** - * @param subscriptionId Subscription Id + * @param subscriptionId The subscription id * @param page Page number * @param size Page size * @return Response from the API call */ - async getSubscriptionCycles( - subscriptionId: string, - page: string, - size: string, - requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('GET'); - const mapped = req.prepareArgs({ - subscriptionId: [subscriptionId, string()], - page: [page, string()], - size: [size, string()], - }); - req.query('page', mapped.page); - req.query('size', mapped.size); - req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/cycles`; - req.authenticate([{ httpBasic: true }]); - return req.callAsJson(listCyclesResponseSchema, requestOptions); - } - - /** - * @param subscriptionId The subscription id - * @param page Page number - * @param size Page size - * @return Response from the API call - */ - async getDiscounts( + async getDiscounts( subscriptionId: string, page: number, size: number, @@ -756,373 +728,401 @@ export class SubscriptionsController extends BaseController { } /** - * Updates the billing date from a subscription + * Updates the boleto due days from a subscription * - * @param subscriptionId The subscription id - * @param request Request for updating the subscription - * billing date + * @param subscriptionId Subscription Id + * @param request * @param idempotencyKey * @return Response from the API call */ - async updateSubscriptionBillingDate( + async updateSubscriptionDueDays( subscriptionId: string, - request: UpdateSubscriptionBillingDateRequest, + request: UpdateSubscriptionDueDaysRequest, idempotencyKey?: string, requestOptions?: RequestOptions ): Promise> { const req = this.createRequest('PATCH'); const mapped = req.prepareArgs({ subscriptionId: [subscriptionId, string()], - request: [request, updateSubscriptionBillingDateRequestSchema], + request: [request, updateSubscriptionDueDaysRequestSchema], idempotencyKey: [idempotencyKey, optional(string())], }); req.header('idempotency-key', mapped.idempotencyKey); req.json(mapped.request); - req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/billing-date`; + req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/boleto-due-days`; req.authenticate([{ httpBasic: true }]); return req.callAsJson(getSubscriptionResponseSchema, requestOptions); } /** - * Deletes a subscription item + * Creates a new Subscription item * - * @param subscriptionId Subscription id - * @param subscriptionItemId Subscription item id + * @param subscriptionId Subscription id + * @param request Request for creating a subscription item * @param idempotencyKey * @return Response from the API call */ - async deleteSubscriptionItem( + async createSubscriptionItem( subscriptionId: string, - subscriptionItemId: string, + request: CreateSubscriptionItemRequest, idempotencyKey?: string, requestOptions?: RequestOptions ): Promise> { - const req = this.createRequest('DELETE'); + const req = this.createRequest('POST'); const mapped = req.prepareArgs({ subscriptionId: [subscriptionId, string()], - subscriptionItemId: [subscriptionItemId, string()], + request: [request, createSubscriptionItemRequestSchema], idempotencyKey: [idempotencyKey, optional(string())], }); req.header('idempotency-key', mapped.idempotencyKey); - req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/items/${mapped.subscriptionItemId}`; + req.json(mapped.request); + req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/items`; req.authenticate([{ httpBasic: true }]); return req.callAsJson(getSubscriptionItemResponseSchema, requestOptions); } /** + * @param id Subscription's id + * @param request + * @return Response from the API call + */ + async updateSplitSubscription( + id: string, + request: UpdateSubscriptionSplitRequest, + requestOptions?: RequestOptions + ): Promise> { + const req = this.createRequest('PATCH'); + const mapped = req.prepareArgs({ + id: [id, string()], + request: [request, updateSubscriptionSplitRequestSchema], + }); + req.json(mapped.request); + req.appendTemplatePath`/subscriptions/${mapped.id}/split`; + req.authenticate([{ httpBasic: true }]); + return req.callAsJson(getSubscriptionResponseSchema, requestOptions); + } + + /** + * Get Subscription Items + * * @param subscriptionId The subscription id * @param page Page number * @param size Page size + * @param name The item name + * @param code Identification code in the client system + * @param status The item statis + * @param description The item description + * @param createdSince Filter for item's creation date start range + * @param createdUntil Filter for item's creation date end range * @return Response from the API call */ - async getIncrements( + async getSubscriptionItems( subscriptionId: string, page?: number, size?: number, + name?: string, + code?: string, + status?: string, + description?: string, + createdSince?: string, + createdUntil?: string, requestOptions?: RequestOptions - ): Promise> { + ): Promise> { const req = this.createRequest('GET'); const mapped = req.prepareArgs({ subscriptionId: [subscriptionId, string()], page: [page, optional(number())], size: [size, optional(number())], + name: [name, optional(string())], + code: [code, optional(string())], + status: [status, optional(string())], + description: [description, optional(string())], + createdSince: [createdSince, optional(string())], + createdUntil: [createdUntil, optional(string())], }); req.query('page', mapped.page); req.query('size', mapped.size); - req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/increments/`; + req.query('name', mapped.name); + req.query('code', mapped.code); + req.query('status', mapped.status); + req.query('description', mapped.description); + req.query('created_since', mapped.createdSince); + req.query('created_until', mapped.createdUntil); + req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/items`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(listIncrementsResponseSchema, requestOptions); + return req.callAsJson(listSubscriptionItemsResponseSchema, requestOptions); } /** - * Updates the boleto due days from a subscription + * Gets all subscriptions * - * @param subscriptionId Subscription Id - * @param request - * @param idempotencyKey + * @param page Page number + * @param size Page size + * @param code Filter for subscription's code + * @param billingType Filter for subscription's billing type + * @param customerId Filter for subscription's customer id + * @param planId Filter for subscription's plan id + * @param cardId Filter for subscription's card id + * @param status Filter for subscription's status + * @param nextBillingSince Filter for subscription's next billing date start range + * @param nextBillingUntil Filter for subscription's next billing date end range + * @param createdSince Filter for subscription's creation date start range + * @param createdUntil Filter for subscriptions creation date end range * @return Response from the API call */ - async updateSubscriptionDueDays( - subscriptionId: string, - request: UpdateSubscriptionDueDaysRequest, - idempotencyKey?: string, + async getSubscriptions( + page?: number, + size?: number, + code?: string, + billingType?: string, + customerId?: string, + planId?: string, + cardId?: string, + status?: string, + nextBillingSince?: string, + nextBillingUntil?: string, + createdSince?: string, + createdUntil?: string, requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('PATCH'); + ): Promise> { + const req = this.createRequest('GET', '/subscriptions'); const mapped = req.prepareArgs({ - subscriptionId: [subscriptionId, string()], - request: [request, updateSubscriptionDueDaysRequestSchema], - idempotencyKey: [idempotencyKey, optional(string())], + page: [page, optional(number())], + size: [size, optional(number())], + code: [code, optional(string())], + billingType: [billingType, optional(string())], + customerId: [customerId, optional(string())], + planId: [planId, optional(string())], + cardId: [cardId, optional(string())], + status: [status, optional(string())], + nextBillingSince: [nextBillingSince, optional(string())], + nextBillingUntil: [nextBillingUntil, optional(string())], + createdSince: [createdSince, optional(string())], + createdUntil: [createdUntil, optional(string())], }); - req.header('idempotency-key', mapped.idempotencyKey); - req.json(mapped.request); - req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/boleto-due-days`; + req.query('page', mapped.page); + req.query('size', mapped.size); + req.query('code', mapped.code); + req.query('billing_type', mapped.billingType); + req.query('customer_id', mapped.customerId); + req.query('plan_id', mapped.planId); + req.query('card_id', mapped.cardId); + req.query('status', mapped.status); + req.query('next_billing_since', mapped.nextBillingSince); + req.query('next_billing_until', mapped.nextBillingUntil); + req.query('created_since', mapped.createdSince); + req.query('created_until', mapped.createdUntil); req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getSubscriptionResponseSchema, requestOptions); + return req.callAsJson(listSubscriptionsResponseSchema, requestOptions); } /** - * Updates the start at date from a subscription + * Creates a increment * - * @param subscriptionId The subscription id - * @param request Request for updating the subscription start - * date + * @param subscriptionId Subscription id + * @param request Request for creating a increment * @param idempotencyKey * @return Response from the API call */ - async updateSubscriptionStartAt( + async createIncrement( subscriptionId: string, - request: UpdateSubscriptionStartAtRequest, + request: CreateIncrementRequest, idempotencyKey?: string, requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('PATCH'); + ): Promise> { + const req = this.createRequest('POST'); const mapped = req.prepareArgs({ subscriptionId: [subscriptionId, string()], - request: [request, updateSubscriptionStartAtRequestSchema], + request: [request, createIncrementRequestSchema], idempotencyKey: [idempotencyKey, optional(string())], }); req.header('idempotency-key', mapped.idempotencyKey); req.json(mapped.request); - req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/start-at`; + req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/increments`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getSubscriptionResponseSchema, requestOptions); + return req.callAsJson(getIncrementResponseSchema, requestOptions); } /** - * Updates a subscription item + * Creates a usage * * @param subscriptionId Subscription Id * @param itemId Item id - * @param body Request for updating a subscription item + * @param body Request for creating a usage * @param idempotencyKey * @return Response from the API call */ - async updateSubscriptionItem( + async createUsage( subscriptionId: string, itemId: string, - body: UpdateSubscriptionItemRequest, + body: CreateUsageRequest, idempotencyKey?: string, requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('PUT'); + ): Promise> { + const req = this.createRequest('POST'); const mapped = req.prepareArgs({ subscriptionId: [subscriptionId, string()], itemId: [itemId, string()], - body: [body, updateSubscriptionItemRequestSchema], + body: [body, createUsageRequestSchema], idempotencyKey: [idempotencyKey, optional(string())], }); req.header('idempotency-key', mapped.idempotencyKey); req.json(mapped.body); - req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/items/${mapped.itemId}`; + req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/items/${mapped.itemId}/usages`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getSubscriptionItemResponseSchema, requestOptions); + return req.callAsJson(getUsageResponseSchema, requestOptions); } /** - * Creates a new Subscription item - * - * @param subscriptionId Subscription id - * @param request Request for creating a subscription item - * @param idempotencyKey + * @param subscriptionId The subscription id + * @param discountId * @return Response from the API call */ - async createSubscriptionItem( + async getDiscountById( subscriptionId: string, - request: CreateSubscriptionItemRequest, - idempotencyKey?: string, + discountId: string, requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('POST'); + ): Promise> { + const req = this.createRequest('GET'); const mapped = req.prepareArgs({ subscriptionId: [subscriptionId, string()], - request: [request, createSubscriptionItemRequestSchema], - idempotencyKey: [idempotencyKey, optional(string())], + discountId: [discountId, string()], }); - req.header('idempotency-key', mapped.idempotencyKey); - req.json(mapped.request); - req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/items`; + req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/discounts/${mapped.discountId}`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getSubscriptionItemResponseSchema, requestOptions); + return req.callAsJson(getDiscountResponseSchema, requestOptions); } /** - * Gets a subscription + * Updates the metadata from a subscription * - * @param subscriptionId Subscription id + * @param subscriptionId The subscription id + * @param request Request for updating the subscrption metadata + * @param idempotencyKey * @return Response from the API call */ - async getSubscription( + async updateSubscriptionMetadata( subscriptionId: string, + request: UpdateMetadataRequest, + idempotencyKey?: string, requestOptions?: RequestOptions ): Promise> { - const req = this.createRequest('GET'); + const req = this.createRequest('PATCH'); const mapped = req.prepareArgs({ subscriptionId: [subscriptionId, string()], + request: [request, updateMetadataRequestSchema], + idempotencyKey: [idempotencyKey, optional(string())], }); - req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}`; + req.header('idempotency-key', mapped.idempotencyKey); + req.json(mapped.request); + req.appendTemplatePath`/Subscriptions/${mapped.subscriptionId}/metadata`; req.authenticate([{ httpBasic: true }]); return req.callAsJson(getSubscriptionResponseSchema, requestOptions); } /** - * Lists all usages from a subscription item - * - * @param subscriptionId The subscription id - * @param itemId The subscription item id + * @param subscriptionId Subscription Id * @param page Page number * @param size Page size - * @param code Identification code in the client system - * @param group Identification group in the client system - * @param usedSince - * @param usedUntil * @return Response from the API call */ - async getUsages( + async getSubscriptionCycles( subscriptionId: string, - itemId: string, - page?: number, - size?: number, - code?: string, - group?: string, - usedSince?: string, - usedUntil?: string, + page: string, + size: string, requestOptions?: RequestOptions - ): Promise> { + ): Promise> { const req = this.createRequest('GET'); const mapped = req.prepareArgs({ subscriptionId: [subscriptionId, string()], - itemId: [itemId, string()], - page: [page, optional(number())], - size: [size, optional(number())], - code: [code, optional(string())], - group: [group, optional(string())], - usedSince: [usedSince, optional(string())], - usedUntil: [usedUntil, optional(string())], + page: [page, string()], + size: [size, string()], }); req.query('page', mapped.page); req.query('size', mapped.size); - req.query('code', mapped.code); - req.query('group', mapped.group); - req.query('used_since', mapped.usedSince); - req.query('used_until', mapped.usedUntil); - req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/items/${mapped.itemId}/usages`; - req.authenticate([{ httpBasic: true }]); - return req.callAsJson(listUsagesResponseSchema, requestOptions); - } - - /** - * @param subscriptionId - * @param request Request for updating the end date of the - * current signature cycle - * @param idempotencyKey - * @return Response from the API call - */ - async updateLatestPeriodEndAt( - subscriptionId: string, - request: UpdateCurrentCycleEndDateRequest, - idempotencyKey?: string, - requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('PATCH'); - const mapped = req.prepareArgs({ - subscriptionId: [subscriptionId, string()], - request: [request, updateCurrentCycleEndDateRequestSchema], - idempotencyKey: [idempotencyKey, optional(string())], - }); - req.header('idempotency-key', mapped.idempotencyKey); - req.json(mapped.request); - req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/periods/latest/end-at`; + req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/cycles`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getSubscriptionResponseSchema, requestOptions); + return req.callAsJson(listCyclesResponseSchema, requestOptions); } /** - * Atualização do valor mínimo da assinatura + * Deletes a subscription item * - * @param subscriptionId Subscription Id - * @param request Request da requisição com o valor mínimo - * que será configurado + * @param subscriptionId Subscription id + * @param subscriptionItemId Subscription item id * @param idempotencyKey * @return Response from the API call */ - async updateSubscriptionMiniumPrice( + async deleteSubscriptionItem( subscriptionId: string, - request: UpdateSubscriptionMinimumPriceRequest, + subscriptionItemId: string, idempotencyKey?: string, requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('PATCH'); + ): Promise> { + const req = this.createRequest('DELETE'); const mapped = req.prepareArgs({ subscriptionId: [subscriptionId, string()], - request: [request, updateSubscriptionMinimumPriceRequestSchema], + subscriptionItemId: [subscriptionItemId, string()], idempotencyKey: [idempotencyKey, optional(string())], }); req.header('idempotency-key', mapped.idempotencyKey); - req.json(mapped.request); - req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/minimum_price`; + req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/items/${mapped.subscriptionItemId}`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getSubscriptionResponseSchema, requestOptions); + return req.callAsJson(getSubscriptionItemResponseSchema, requestOptions); } /** * @param subscriptionId The subscription id - * @param cycleId + * @param page Page number + * @param size Page size * @return Response from the API call */ - async getSubscriptionCycleById( + async getIncrements( subscriptionId: string, - cycleId: string, + page?: number, + size?: number, requestOptions?: RequestOptions - ): Promise> { + ): Promise> { const req = this.createRequest('GET'); const mapped = req.prepareArgs({ subscriptionId: [subscriptionId, string()], - cycleId: [cycleId, string()], + page: [page, optional(number())], + size: [size, optional(number())], }); - req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/cycles/${mapped.cycleId}`; + req.query('page', mapped.page); + req.query('size', mapped.size); + req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/increments/`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getPeriodResponseSchema, requestOptions); + return req.callAsJson(listIncrementsResponseSchema, requestOptions); } /** - * @param subscriptionId The subscription Id - * @param periodId The period Id + * Updates a subscription item + * + * @param subscriptionId Subscription Id + * @param itemId Item id + * @param body Request for updating a subscription item + * @param idempotencyKey * @return Response from the API call */ - async getUsageReport( + async updateSubscriptionItem( subscriptionId: string, - periodId: string, + itemId: string, + body: UpdateSubscriptionItemRequest, + idempotencyKey?: string, requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('GET'); + ): Promise> { + const req = this.createRequest('PUT'); const mapped = req.prepareArgs({ subscriptionId: [subscriptionId, string()], - periodId: [periodId, string()], - }); - req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/periods/${mapped.periodId}/usages/report`; - req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getUsageReportResponseSchema, requestOptions); - } - - /** - * @param id Subscription's id - * @param request - * @return Response from the API call - */ - async updateSplitSubscription( - id: string, - request: UpdateSubscriptionSplitRequest, - requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('PATCH'); - const mapped = req.prepareArgs({ - id: [id, string()], - request: [request, updateSubscriptionSplitRequestSchema], + itemId: [itemId, string()], + body: [body, updateSubscriptionItemRequestSchema], + idempotencyKey: [idempotencyKey, optional(string())], }); - req.json(mapped.request); - req.appendTemplatePath`/subscriptions/${mapped.id}/split`; + req.header('idempotency-key', mapped.idempotencyKey); + req.json(mapped.body); + req.appendTemplatePath`/subscriptions/${mapped.subscriptionId}/items/${mapped.itemId}`; req.authenticate([{ httpBasic: true }]); - return req.callAsJson(getSubscriptionResponseSchema, requestOptions); + return req.callAsJson(getSubscriptionItemResponseSchema, requestOptions); } } diff --git a/src/controllers/tokensController.ts b/src/controllers/tokensController.ts index c9fe418..7f2cff1 100644 --- a/src/controllers/tokensController.ts +++ b/src/controllers/tokensController.ts @@ -18,48 +18,48 @@ import { BaseController } from './baseController'; export class TokensController extends BaseController { /** - * @param publicKey Public key - * @param request Request for creating a token - * @param idempotencyKey + * Gets a token from its id + * + * @param id Token id + * @param publicKey Public key * @return Response from the API call */ - async createToken( + async getToken( + id: string, publicKey: string, - request: CreateTokenRequest, - idempotencyKey?: string, requestOptions?: RequestOptions ): Promise> { - const req = this.createRequest('POST'); + const req = this.createRequest('GET'); const mapped = req.prepareArgs({ + id: [id, string()], publicKey: [publicKey, string()], - request: [request, createTokenRequestSchema], - idempotencyKey: [idempotencyKey, optional(string())], }); - req.header('idempotency-key', mapped.idempotencyKey); - req.json(mapped.request); - req.appendTemplatePath`/tokens?appId=${mapped.publicKey}`; + req.appendTemplatePath`/tokens/${mapped.id}?appId=${mapped.publicKey}`; req.authenticate(false); return req.callAsJson(getTokenResponseSchema, requestOptions); } /** - * Gets a token from its id - * - * @param id Token id - * @param publicKey Public key + * @param publicKey Public key + * @param request Request for creating a token + * @param idempotencyKey * @return Response from the API call */ - async getToken( - id: string, + async createToken( publicKey: string, + request: CreateTokenRequest, + idempotencyKey?: string, requestOptions?: RequestOptions ): Promise> { - const req = this.createRequest('GET'); + const req = this.createRequest('POST'); const mapped = req.prepareArgs({ - id: [id, string()], publicKey: [publicKey, string()], + request: [request, createTokenRequestSchema], + idempotencyKey: [idempotencyKey, optional(string())], }); - req.appendTemplatePath`/tokens/${mapped.id}?appId=${mapped.publicKey}`; + req.header('idempotency-key', mapped.idempotencyKey); + req.json(mapped.request); + req.appendTemplatePath`/tokens?appId=${mapped.publicKey}`; req.authenticate(false); return req.callAsJson(getTokenResponseSchema, requestOptions); } diff --git a/src/controllers/transfersController.ts b/src/controllers/transfersController.ts index afde4ce..1d467ab 100644 --- a/src/controllers/transfersController.ts +++ b/src/controllers/transfersController.ts @@ -27,6 +27,19 @@ export class TransfersController extends BaseController { return req.callAsJson(getTransferSchema, requestOptions); } + /** + * Gets all transfers + * + * @return Response from the API call + */ + async getTransfers( + requestOptions?: RequestOptions + ): Promise> { + const req = this.createRequest('GET', '/transfers'); + req.authenticate([{ httpBasic: true }]); + return req.callAsJson(listTransfersSchema, requestOptions); + } + /** * @param request * @return Response from the API call @@ -43,17 +56,4 @@ export class TransfersController extends BaseController { req.authenticate([{ httpBasic: true }]); return req.callAsJson(getTransferSchema, requestOptions); } - - /** - * Gets all transfers - * - * @return Response from the API call - */ - async getTransfers( - requestOptions?: RequestOptions - ): Promise> { - const req = this.createRequest('GET', '/transfers'); - req.authenticate([{ httpBasic: true }]); - return req.callAsJson(listTransfersSchema, requestOptions); - } } diff --git a/src/index.ts b/src/index.ts index ae60f69..e08bf70 100644 --- a/src/index.ts +++ b/src/index.ts @@ -256,6 +256,7 @@ export type { UpdatePlanRequest } from './models/updatePlanRequest'; export type { UpdatePriceBracketRequest } from './models/updatePriceBracketRequest'; export type { UpdatePricingSchemeRequest } from './models/updatePricingSchemeRequest'; export type { UpdateRecipientBankAccountRequest } from './models/updateRecipientBankAccountRequest'; +export type { UpdateRecipientCodeRequest } from './models/updateRecipientCodeRequest'; export type { UpdateRecipientRequest } from './models/updateRecipientRequest'; export type { UpdateSubscriptionAffiliationIdRequest } from './models/updateSubscriptionAffiliationIdRequest'; export type { UpdateSubscriptionBillingDateRequest } from './models/updateSubscriptionBillingDateRequest'; diff --git a/src/models/createCreditCardPaymentRequest.ts b/src/models/createCreditCardPaymentRequest.ts index 5332d7d..ef39dee 100644 --- a/src/models/createCreditCardPaymentRequest.ts +++ b/src/models/createCreditCardPaymentRequest.ts @@ -70,6 +70,8 @@ export interface CreateCreditCardPaymentRequest { initiatedType?: string; recurrenceModel?: string; paymentOrigin?: CreatePaymentOriginRequest; + /** Business model identifier */ + indirectAcceptor?: string; } export const createCreditCardPaymentRequestSchema: Schema = object( @@ -102,5 +104,6 @@ export const createCreditCardPaymentRequestSchema: Schema createPaymentOriginRequestSchema)), ], + indirectAcceptor: ['indirect_acceptor', optional(string())], } ); diff --git a/src/models/createSubscriptionRequest.ts b/src/models/createSubscriptionRequest.ts index d519b59..2f46751 100644 --- a/src/models/createSubscriptionRequest.ts +++ b/src/models/createSubscriptionRequest.ts @@ -130,6 +130,8 @@ export interface CreateSubscriptionRequest { split?: CreateSubscriptionSplitRequest; /** Information about fines and interest on the "boleto" used from payment */ boleto?: CreateSubscriptionBoletoRequest; + /** Business model identifier */ + indirectAcceptor?: string; } export const createSubscriptionRequestSchema: Schema = object( @@ -179,5 +181,6 @@ export const createSubscriptionRequestSchema: Schema 'boleto', optional(lazy(() => createSubscriptionBoletoRequestSchema)), ], + indirectAcceptor: ['indirect_acceptor', optional(string())], } ); diff --git a/src/models/discriminatedSchemas.ts b/src/models/discriminatedSchemas.ts index 24c72ff..8a034b7 100644 --- a/src/models/discriminatedSchemas.ts +++ b/src/models/discriminatedSchemas.ts @@ -72,13 +72,13 @@ import { export const discriminatedGetTransactionResponseSchema: Schema< | GetTransactionResponse - | GetBankTransferTransactionResponse | GetSafetyPayTransactionResponse | GetVoucherTransactionResponse + | GetBankTransferTransactionResponse | GetBoletoTransactionResponse | GetDebitCardTransactionResponse - | GetPrivateLabelTransactionResponse | GetCashTransactionResponse + | GetPrivateLabelTransactionResponse | GetCreditCardTransactionResponse | GetPixTransactionResponse > = discriminatedObject( @@ -86,13 +86,13 @@ export const discriminatedGetTransactionResponseSchema: Schema< 'transaction_type', { 'transaction': getTransactionResponseSchema, - 'bank_transfer': getBankTransferTransactionResponseSchema, 'safetypay': getSafetyPayTransactionResponseSchema, 'voucher': getVoucherTransactionResponseSchema, + 'bank_transfer': getBankTransferTransactionResponseSchema, 'boleto': getBoletoTransactionResponseSchema, 'debit_card': getDebitCardTransactionResponseSchema, - 'private_label': getPrivateLabelTransactionResponseSchema, 'cash': getCashTransactionResponseSchema, + 'private_label': getPrivateLabelTransactionResponseSchema, 'credit_card': getCreditCardTransactionResponseSchema, 'pix': getPixTransactionResponseSchema, }, @@ -100,9 +100,9 @@ export const discriminatedGetTransactionResponseSchema: Schema< ); export const discriminatedGetMovementObjectBaseResponseSchema: Schema< | GetMovementObjectBaseResponse - | GetMovementObjectRefundResponse | GetMovementObjectFeeCollectionResponse | GetMovementObjectPayableResponse + | GetMovementObjectRefundResponse | GetMovementObjectTransferResponse | GetMovementObjectSettlementResponse > = discriminatedObject( @@ -110,9 +110,9 @@ export const discriminatedGetMovementObjectBaseResponseSchema: Schema< 'object', { 'MovementObject': getMovementObjectBaseResponseSchema, - 'refund': getMovementObjectRefundResponseSchema, 'feeCollection': getMovementObjectFeeCollectionResponseSchema, 'payable': getMovementObjectPayableResponseSchema, + 'refund': getMovementObjectRefundResponseSchema, 'transfer': getMovementObjectTransferResponseSchema, 'settlement': getMovementObjectSettlementResponseSchema, }, diff --git a/src/models/getCreditCardTransactionResponse.ts b/src/models/getCreditCardTransactionResponse.ts index 80dd62a..98ae576 100644 --- a/src/models/getCreditCardTransactionResponse.ts +++ b/src/models/getCreditCardTransactionResponse.ts @@ -59,6 +59,8 @@ export interface GetCreditCardTransactionResponse extends GetTransactionResponse /** Retry transaction information */ retryInfo?: GetRetryTransactionInformationResponse | null; brandId?: string | null; + /** Business model identifier */ + indirectAcceptor?: string | null; } export const getCreditCardTransactionResponseSchema: Schema = object( @@ -89,6 +91,7 @@ export const getCreditCardTransactionResponseSchema: Schema = object( @@ -141,5 +143,6 @@ export const getSubscriptionResponseSchema: Schema = ob optional(nullable(lazy(() => getSubscriptionBoletoResponseSchema))), ], manualBilling: ['manual_billing', optional(nullable(boolean()))], + indirectAcceptor: ['indirect_acceptor', optional(nullable(string()))], } ); diff --git a/src/models/updateChargeCardRequest.ts b/src/models/updateChargeCardRequest.ts index b56b794..656fe7a 100644 --- a/src/models/updateChargeCardRequest.ts +++ b/src/models/updateChargeCardRequest.ts @@ -27,6 +27,8 @@ export interface UpdateChargeCardRequest { initiatedType?: string; recurrenceModel?: string; paymentOrigin?: CreatePaymentOriginRequest; + /** Business model identifier */ + indirectAcceptor?: string; } export const updateChargeCardRequestSchema: Schema = object( @@ -41,5 +43,6 @@ export const updateChargeCardRequestSchema: Schema = ob 'payment_origin', optional(lazy(() => createPaymentOriginRequestSchema)), ], + indirectAcceptor: ['indirect_acceptor', optional(string())], } ); diff --git a/src/models/updateRecipientCodeRequest.ts b/src/models/updateRecipientCodeRequest.ts new file mode 100644 index 0000000..f7f5036 --- /dev/null +++ b/src/models/updateRecipientCodeRequest.ts @@ -0,0 +1,17 @@ +/** + * PagarmeApiSDKLib + * + * This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ). + */ + +import { object, Schema, string } from '../schema'; + +/** Update code for a recipient */ +export interface UpdateRecipientCodeRequest { + /** Code */ + code: string; +} + +export const updateRecipientCodeRequestSchema: Schema = object( + { code: ['code', string()] } +); diff --git a/src/models/updateSubscriptionCardRequest.ts b/src/models/updateSubscriptionCardRequest.ts index e20f1bd..c1afd78 100644 --- a/src/models/updateSubscriptionCardRequest.ts +++ b/src/models/updateSubscriptionCardRequest.ts @@ -4,7 +4,7 @@ * This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ). */ -import { lazy, object, Schema, string } from '../schema'; +import { lazy, object, optional, Schema, string } from '../schema'; import { CreateCardRequest, createCardRequestSchema, @@ -16,11 +16,14 @@ export interface UpdateSubscriptionCardRequest { card: CreateCardRequest; /** Credit card id */ cardId: string; + /** Business model identifier */ + indirectAcceptor?: string; } export const updateSubscriptionCardRequestSchema: Schema = object( { card: ['card', lazy(() => createCardRequestSchema)], cardId: ['card_id', string()], + indirectAcceptor: ['indirect_acceptor', optional(string())], } );