UNPKG

orb-billing

Version:

The official TypeScript library for the Orb API

87 lines 3.82 kB
"use strict"; // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. Object.defineProperty(exports, "__esModule", { value: true }); exports.InvoicesPage = exports.Invoices = void 0; const resource_1 = require("../resource.js"); const core_1 = require("../core.js"); const shared_1 = require("./shared.js"); Object.defineProperty(exports, "InvoicesPage", { enumerable: true, get: function () { return shared_1.InvoicesPage; } }); class Invoices extends resource_1.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 ((0, core_1.isRequestOptions)(query)) { return this.list({}, query); } return this._client.getAPIList('/invoices', shared_1.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 ((0, core_1.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); } } exports.Invoices = Invoices; //# sourceMappingURL=invoices.js.map