UNPKG

orb-billing

Version:

The official TypeScript library for the Orb API

90 lines 3.38 kB
"use strict"; // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. Object.defineProperty(exports, "__esModule", { value: true }); exports.CreditNotes = void 0; const resource_1 = require("../core/resource.js"); const pagination_1 = require("../core/pagination.js"); const path_1 = require("../internal/utils/path.js"); /** * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been applied to a * particular invoice. */ class CreditNotes extends resource_1.APIResource { /** * This endpoint is used to create a single * [`Credit Note`](/invoicing/credit-notes). * * The credit note service period configuration supports two explicit modes: * * 1. Global service periods: Specify start_date and end_date at the credit note * level. These dates will be applied to all line items uniformly. * * 2. Individual service periods: Specify start_date and end_date for each line * item. When using this mode, ALL line items must have individual periods * specified. * * 3. Default behavior: If no service periods are specified (neither global nor * individual), the original invoice line item service periods will be used. * * Note: Mixing global and individual service periods in the same request is not * allowed to prevent confusion. * * Service period dates are normalized to the start of the day in the customer's * timezone to ensure consistent handling across different timezones. * * Date Format: Use start_date and end_date with format "YYYY-MM-DD" (e.g., * "2023-09-22") to match other Orb APIs like /v1/invoice_line_items. * * Note: Both start_date and end_date are inclusive - the service period will cover * both the start date and end date completely (from start of start_date to end of * end_date). * * @example * ```ts * const creditNote = await client.creditNotes.create({ * line_items: [ * { * amount: 'amount', * invoice_line_item_id: '4khy3nwzktxv7', * }, * ], * reason: 'duplicate', * }); * ``` */ create(body, options) { return this._client.post('/credit_notes', { body, ...options }); } /** * Get a paginated list of CreditNotes. Users can also filter by customer_id, * subscription_id, or external_customer_id. The credit notes will be returned in * reverse chronological order by `creation_time`. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const creditNote of client.creditNotes.list()) { * // ... * } * ``` */ list(query = {}, options) { return this._client.getAPIList('/credit_notes', (pagination_1.Page), { query, ...options }); } /** * This endpoint is used to fetch a single [`Credit Note`](/invoicing/credit-notes) * given an identifier. * * @example * ```ts * const creditNote = await client.creditNotes.fetch( * 'credit_note_id', * ); * ``` */ fetch(creditNoteID, options) { return this._client.get((0, path_1.path) `/credit_notes/${creditNoteID}`, options); } } exports.CreditNotes = CreditNotes; //# sourceMappingURL=credit-notes.js.map