Skip to content

Latest commit

 

History

History
335 lines (258 loc) · 9.03 KB

invoices.md

File metadata and controls

335 lines (258 loc) · 9.03 KB

Invoices

const invoicesController = new InvoicesController(client);

Class Name

InvoicesController

Methods

Create Invoice

Create an Invoice

async createInvoice(
  subscriptionId: string,
  cycleId: string,
  request?: CreateInvoiceRequest,
  idempotencyKey?: string,
  requestOptions?: RequestOptions
): Promise<ApiResponse<GetInvoiceResponse>>

Parameters

Parameter Type Tags Description
subscriptionId string Template, Required Subscription Id
cycleId string Template, Required Cycle Id
request CreateInvoiceRequest | undefined Body, Optional -
idempotencyKey string | undefined Header, Optional -
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

GetInvoiceResponse

Example Usage

const subscriptionId = 'subscription_id0';
const cycleId = 'cycle_id6';
try {
  const { result, ...httpResponse } = await invoicesController.createInvoice(subscriptionId, cycleId);
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch(error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}

Get Invoices

Gets all invoices

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<ApiResponse<ListInvoicesResponse>>

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 -
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

ListInvoicesResponse

Example Usage

try {
  const { result, ...httpResponse } = await invoicesController.getInvoices();
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch(error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}

Cancel Invoice

Cancels an invoice

async cancelInvoice(
  invoiceId: string,
  idempotencyKey?: string,
  requestOptions?: RequestOptions
): Promise<ApiResponse<GetInvoiceResponse>>

Parameters

Parameter Type Tags Description
invoiceId string Template, Required Invoice id
idempotencyKey string | undefined Header, Optional -
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

GetInvoiceResponse

Example Usage

const invoiceId = 'invoice_id0';
try {
  const { result, ...httpResponse } = await invoicesController.cancelInvoice(invoiceId);
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch(error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}

Update Invoice Metadata

Updates the metadata from an invoice

async updateInvoiceMetadata(
  invoiceId: string,
  request: UpdateMetadataRequest,
  idempotencyKey?: string,
  requestOptions?: RequestOptions
): Promise<ApiResponse<GetInvoiceResponse>>

Parameters

Parameter Type Tags Description
invoiceId string Template, Required The invoice id
request UpdateMetadataRequest Body, Required Request for updating the invoice metadata
idempotencyKey string | undefined Header, Optional -
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

GetInvoiceResponse

Example Usage

const invoiceId = 'invoice_id0';
const requestMetadata: Record<string, string> = {'key0' : 'metadata3' } const request: UpdateMetadataRequest = {
  metadata: requestMetadata,
};

try {
  const { result, ...httpResponse } = await invoicesController.updateInvoiceMetadata(invoiceId, request);
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch(error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}

Get Partial Invoice

async getPartialInvoice(
  subscriptionId: string,
  requestOptions?: RequestOptions
): Promise<ApiResponse<GetInvoiceResponse>>

Parameters

Parameter Type Tags Description
subscriptionId string Template, Required Subscription Id
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

GetInvoiceResponse

Example Usage

const subscriptionId = 'subscription_id0';
try {
  const { result, ...httpResponse } = await invoicesController.getPartialInvoice(subscriptionId);
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch(error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}

Update Invoice Status

Updates the status from an invoice

async updateInvoiceStatus(
  invoiceId: string,
  request: UpdateInvoiceStatusRequest,
  idempotencyKey?: string,
  requestOptions?: RequestOptions
): Promise<ApiResponse<GetInvoiceResponse>>

Parameters

Parameter Type Tags Description
invoiceId string Template, Required Invoice Id
request UpdateInvoiceStatusRequest Body, Required Request for updating an invoice's status
idempotencyKey string | undefined Header, Optional -
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

GetInvoiceResponse

Example Usage

const invoiceId = 'invoice_id0';
const request: UpdateInvoiceStatusRequest = {
  status: 'status8',
};

try {
  const { result, ...httpResponse } = await invoicesController.updateInvoiceStatus(invoiceId, request);
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch(error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}

Get Invoice

Gets an invoice

async getInvoice(
  invoiceId: string,
  requestOptions?: RequestOptions
): Promise<ApiResponse<GetInvoiceResponse>>

Parameters

Parameter Type Tags Description
invoiceId string Template, Required Invoice Id
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

GetInvoiceResponse

Example Usage

const invoiceId = 'invoice_id0';
try {
  const { result, ...httpResponse } = await invoicesController.getInvoice(invoiceId);
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch(error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}