orb-billing
Version:
The official TypeScript library for the Orb API
83 lines • 3.54 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../resource.mjs";
import { isRequestOptions } from "../core.mjs";
import { InvoicesPage } from "./shared.mjs";
export class Invoices extends APIResource {
/**
* This endpoint is used to create a one-off invoice for a customer.
*/
create(body, options) {
return this._client.post('/invoices', { body, ...options });
}
/**
* This endpoint allows you to update the `metadata`, `net_terms`, `due_date`, and
* `invoice_date` properties on an invoice. If you pass null for the metadata
* value, it will clear any existing metadata for that invoice.
*
* `metadata` can be modified regardless of invoice state. `net_terms`, `due_date`,
* and `invoice_date` can only be modified if the invoice is in a `draft` state.
* `invoice_date` can only be modified for non-subscription invoices.
*/
update(invoiceId, body, options) {
return this._client.put(`/invoices/${invoiceId}`, { body, ...options });
}
list(query = {}, options) {
if (isRequestOptions(query)) {
return this.list({}, query);
}
return this._client.getAPIList('/invoices', InvoicesPage, { query, ...options });
}
/**
* This endpoint is used to fetch an [`Invoice`](/core-concepts#invoice) given an
* identifier.
*/
fetch(invoiceId, options) {
return this._client.get(`/invoices/${invoiceId}`, options);
}
/**
* This endpoint can be used to fetch the upcoming
* [invoice](/core-concepts#invoice) for the current billing period given a
* subscription.
*/
fetchUpcoming(query, options) {
return this._client.get('/invoices/upcoming', { query, ...options });
}
issue(invoiceId, body = {}, options) {
if (isRequestOptions(body)) {
return this.issue(invoiceId, {}, body);
}
return this._client.post(`/invoices/${invoiceId}/issue`, { body, ...options });
}
/**
* This endpoint allows an invoice's status to be set to the `paid` status. This
* can only be done to invoices that are in the `issued` or `synced` status.
*/
markPaid(invoiceId, body, options) {
return this._client.post(`/invoices/${invoiceId}/mark_paid`, { body, ...options });
}
/**
* This endpoint collects payment for an invoice using the customer's default
* payment method. This action can only be taken on invoices with status "issued".
*/
pay(invoiceId, options) {
return this._client.post(`/invoices/${invoiceId}/pay`, options);
}
/**
* This endpoint allows an invoice's status to be set to the `void` status. This
* can only be done to invoices that are in the `issued` status.
*
* If the associated invoice has used the customer balance to change the amount
* due, the customer balance operation will be reverted. For example, if the
* invoice used \$10 of customer balance, that amount will be added back to the
* customer balance upon voiding.
*
* If the invoice was used to purchase a credit block, but the invoice is not yet
* paid, the credit block will be voided. If the invoice was created due to a
* top-up, the top-up will be disabled.
*/
void(invoiceId, options) {
return this._client.post(`/invoices/${invoiceId}/void`, options);
}
}
export { InvoicesPage };
//# sourceMappingURL=invoices.mjs.map