orb-billing
Version:
The official TypeScript library for the Orb API
89 lines • 3.58 kB
JavaScript
;
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DimensionalPriceGroups = void 0;
const tslib_1 = require("../../internal/tslib.js");
const resource_1 = require("../../core/resource.js");
const ExternalDimensionalPriceGroupIDAPI = tslib_1.__importStar(require("./external-dimensional-price-group-id.js"));
const external_dimensional_price_group_id_1 = require("./external-dimensional-price-group-id.js");
const pagination_1 = require("../../core/pagination.js");
const path_1 = require("../../internal/utils/path.js");
class DimensionalPriceGroups extends resource_1.APIResource {
constructor() {
super(...arguments);
this.externalDimensionalPriceGroupID = new ExternalDimensionalPriceGroupIDAPI.ExternalDimensionalPriceGroupID(this._client);
}
/**
* A dimensional price group is used to partition the result of a billable metric
* by a set of dimensions. Prices in a price group must specify the partition used
* to derive their usage.
*
* For example, suppose we have a billable metric that measures the number of
* widgets used and we want to charge differently depending on the color of the
* widget. We can create a price group with a dimension "color" and two prices: one
* that charges \$10 per red widget and one that charges \$20 per blue widget.
*
* @example
* ```ts
* const dimensionalPriceGroup =
* await client.dimensionalPriceGroups.create({
* billable_metric_id: 'billable_metric_id',
* dimensions: ['region', 'instance_type'],
* name: 'name',
* });
* ```
*/
create(body, options) {
return this._client.post('/dimensional_price_groups', { body, ...options });
}
/**
* Fetch dimensional price group
*
* @example
* ```ts
* const dimensionalPriceGroup =
* await client.dimensionalPriceGroups.retrieve(
* 'dimensional_price_group_id',
* );
* ```
*/
retrieve(dimensionalPriceGroupID, options) {
return this._client.get((0, path_1.path) `/dimensional_price_groups/${dimensionalPriceGroupID}`, options);
}
/**
* This endpoint can be used to update the `external_dimensional_price_group_id`
* and `metadata` of an existing dimensional price group. Other fields on a
* dimensional price group are currently immutable.
*
* @example
* ```ts
* const dimensionalPriceGroup =
* await client.dimensionalPriceGroups.update(
* 'dimensional_price_group_id',
* );
* ```
*/
update(dimensionalPriceGroupID, body, options) {
return this._client.put((0, path_1.path) `/dimensional_price_groups/${dimensionalPriceGroupID}`, { body, ...options });
}
/**
* List dimensional price groups
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const dimensionalPriceGroup of client.dimensionalPriceGroups.list()) {
* // ...
* }
* ```
*/
list(query = {}, options) {
return this._client.getAPIList('/dimensional_price_groups', (pagination_1.Page), {
query,
...options,
});
}
}
exports.DimensionalPriceGroups = DimensionalPriceGroups;
DimensionalPriceGroups.ExternalDimensionalPriceGroupID = external_dimensional_price_group_id_1.ExternalDimensionalPriceGroupID;
//# sourceMappingURL=dimensional-price-groups.js.map