UNPKG

orb-billing

Version:

The official TypeScript library for the Orb API

100 lines 3.48 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../core/resource.mjs"; import * as ExternalLicensesAPI from "./external-licenses.mjs"; import { ExternalLicenses, } from "./external-licenses.mjs"; import * as UsageAPI from "./usage.mjs"; import { Usage, } from "./usage.mjs"; import { Page } from "../../core/pagination.mjs"; import { path } from "../../internal/utils/path.mjs"; export class Licenses extends APIResource { constructor() { super(...arguments); this.externalLicenses = new ExternalLicensesAPI.ExternalLicenses(this._client); this.usage = new UsageAPI.Usage(this._client); } /** * This endpoint is used to create a new license for a user. * * If a start date is provided, the license will be activated at the **start** of * the specified date in the customer's timezone. Otherwise, the activation time * will default to the **start** of the current day in the customer's timezone. * * @example * ```ts * const license = await client.licenses.create({ * external_license_id: 'external_license_id', * license_type_id: 'license_type_id', * subscription_id: 'subscription_id', * }); * ``` */ create(body, options) { return this._client.post('/licenses', { body, ...options }); } /** * This endpoint is used to fetch a license given an identifier. * * @example * ```ts * const license = await client.licenses.retrieve( * 'license_id', * ); * ``` */ retrieve(licenseID, options) { return this._client.get(path `/licenses/${licenseID}`, options); } /** * This endpoint returns a list of all licenses for a subscription. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const licenseListResponse of client.licenses.list( * { subscription_id: 'subscription_id' }, * )) { * // ... * } * ``` */ list(query, options) { return this._client.getAPIList('/licenses', (Page), { query, ...options }); } /** * This endpoint is used to deactivate an existing license. * * If an end date is provided, the license will be deactivated at the **start** of * the specified date in the customer's timezone. Otherwise, the deactivation time * will default to the **end** of the current day in the customer's timezone. * * @example * ```ts * const response = await client.licenses.deactivate( * 'license_id', * ); * ``` */ deactivate(licenseID, body, options) { return this._client.post(path `/licenses/${licenseID}/deactivate`, { body, ...options }); } /** * This endpoint is used to fetch a license given an external license identifier. * * @example * ```ts * const response = await client.licenses.retrieveByExternalID( * 'external_license_id', * { * license_type_id: 'license_type_id', * subscription_id: 'subscription_id', * }, * ); * ``` */ retrieveByExternalID(externalLicenseID, query, options) { return this._client.get(path `/licenses/external_license_id/${externalLicenseID}`, { query, ...options }); } } Licenses.ExternalLicenses = ExternalLicenses; Licenses.Usage = Usage; //# sourceMappingURL=licenses.mjs.map