UNPKG

orb-billing

Version:

The official TypeScript library for the Orb API

105 lines 3.8 kB
"use strict"; // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. Object.defineProperty(exports, "__esModule", { value: true }); exports.Licenses = void 0; const tslib_1 = require("../../internal/tslib.js"); const resource_1 = require("../../core/resource.js"); const ExternalLicensesAPI = tslib_1.__importStar(require("./external-licenses.js")); const external_licenses_1 = require("./external-licenses.js"); const UsageAPI = tslib_1.__importStar(require("./usage.js")); const usage_1 = require("./usage.js"); const pagination_1 = require("../../core/pagination.js"); const path_1 = require("../../internal/utils/path.js"); class Licenses extends resource_1.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((0, path_1.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', (pagination_1.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((0, path_1.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((0, path_1.path) `/licenses/external_license_id/${externalLicenseID}`, { query, ...options }); } } exports.Licenses = Licenses; Licenses.ExternalLicenses = external_licenses_1.ExternalLicenses; Licenses.Usage = usage_1.Usage; //# sourceMappingURL=licenses.js.map