@maxio-com/advanced-billing-sdk
Version:
Ultimate billing and pricing flexibility for B2B SaaS. Maxio integrates directly into your product, so you can seamlessly manage your product catalog, bill customers, and collect payments.
409 lines • 28.6 kB
JavaScript
"use strict";
/**
* AdvancedBilling
*
* This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ).
*/
exports.__esModule = true;
exports.ComponentPricePointsController = void 0;
var tslib_1 = require("tslib");
var core_1 = require("../core");
var componentCurrencyPricesResponse_1 = require("../models/componentCurrencyPricesResponse");
var componentPricePointResponse_1 = require("../models/componentPricePointResponse");
var componentPricePointsResponse_1 = require("../models/componentPricePointsResponse");
var componentResponse_1 = require("../models/componentResponse");
var archiveComponentPricePointComponentId_1 = require("../models/containers/archiveComponentPricePointComponentId");
var archiveComponentPricePointPricePointId_1 = require("../models/containers/archiveComponentPricePointPricePointId");
var readComponentPricePointComponentId_1 = require("../models/containers/readComponentPricePointComponentId");
var readComponentPricePointPricePointId_1 = require("../models/containers/readComponentPricePointPricePointId");
var updateComponentPricePointComponentId_1 = require("../models/containers/updateComponentPricePointComponentId");
var updateComponentPricePointPricePointId_1 = require("../models/containers/updateComponentPricePointPricePointId");
var createComponentPricePointRequest_1 = require("../models/createComponentPricePointRequest");
var createComponentPricePointsRequest_1 = require("../models/createComponentPricePointsRequest");
var createCurrencyPricesRequest_1 = require("../models/createCurrencyPricesRequest");
var listComponentsPricePointsInclude_1 = require("../models/listComponentsPricePointsInclude");
var listComponentsPricePointsResponse_1 = require("../models/listComponentsPricePointsResponse");
var listPricePointsFilter_1 = require("../models/listPricePointsFilter");
var pricePointType_1 = require("../models/pricePointType");
var sortingDirection_1 = require("../models/sortingDirection");
var updateComponentPricePointRequest_1 = require("../models/updateComponentPricePointRequest");
var updateCurrencyPricesRequest_1 = require("../models/updateCurrencyPricesRequest");
var schema_1 = require("../schema");
var baseController_1 = require("./baseController");
var errorArrayMapResponseError_1 = require("../errors/errorArrayMapResponseError");
var errorListResponseError_1 = require("../errors/errorListResponseError");
var ComponentPricePointsController = /** @class */ (function (_super) {
tslib_1.__extends(ComponentPricePointsController, _super);
function ComponentPricePointsController() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* Sets a new default price point for the component. This new default will apply to all new
* subscriptions going forward - existing subscriptions will remain on their current price point.
*
* See [Price Points Documentation](https://maxio.zendesk.com/hc/en-us/articles/24261191737101-Price-
* Points-Components) for more information on price points and moving subscriptions between price
* points.
*
* Note: Custom price points are not able to be set as the default for a component.
*
* @param componentId The Advanced Billing id of the component to which the price point belongs
* @param pricePointId The Advanced Billing id of the price point
* @return Response from the API call
*/
ComponentPricePointsController.prototype.promoteComponentPricePointToDefault = function (componentId, pricePointId, requestOptions) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var req, mapped;
return tslib_1.__generator(this, function (_a) {
req = this.createRequest('PUT');
mapped = req.prepareArgs({
componentId: [componentId, (0, schema_1.number)()],
pricePointId: [pricePointId, (0, schema_1.number)()]
});
req.appendTemplatePath(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["/components/", "/price_points/", "/default.json"], ["/components/", "/price_points/", "/default.json"])), mapped.componentId, mapped.pricePointId);
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(componentResponse_1.componentResponseSchema, requestOptions)];
});
});
};
/**
* This endpoint can be used to create a new price point for an existing component.
*
* @param componentId The Advanced Billing id of the component
* @param body
* @return Response from the API call
*/
ComponentPricePointsController.prototype.createComponentPricePoint = function (componentId, body, requestOptions) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var req, mapped;
return tslib_1.__generator(this, function (_a) {
req = this.createRequest('POST');
mapped = req.prepareArgs({
componentId: [componentId, (0, schema_1.number)()],
body: [body, (0, schema_1.optional)(createComponentPricePointRequest_1.createComponentPricePointRequestSchema)]
});
req.header('Content-Type', 'application/json');
req.json(mapped.body);
req.appendTemplatePath(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["/components/", "/price_points.json"], ["/components/", "/price_points.json"])), mapped.componentId);
req.throwOn(422, errorArrayMapResponseError_1.ErrorArrayMapResponseError, true, "HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'.");
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(componentPricePointResponse_1.componentPricePointResponseSchema, requestOptions)];
});
});
};
/**
* Use this endpoint to read current price points that are associated with a component.
*
* You may specify the component by using either the numeric id or the `handle:gold` syntax.
*
* When fetching a component's price points, if you have defined multiple currencies at the site level,
* you can optionally pass the `?currency_prices=true` query param to include an array of currency
* price data in the response.
*
* If the price point is set to `use_site_exchange_rate: true`, it will return pricing based on the
* current exchange rate. If the flag is set to false, it will return all of the defined prices for
* each currency.
*
* @param componentId The Advanced Billing id of the component
* @param currencyPrices Include an array of currency price data
* @param page Result records are organized in pages. By default, the first page of
* results is displayed. The page parameter specifies a page number of
* results to fetch. You can start navigating through the pages to consume
* the results. You do this by passing in a page parameter. Retrieve the
* next page by adding ?page=2 to the query string. If there are no
* results to return, then an empty result set will be returned. Use in
* query `page=1`.
* @param perPage This parameter indicates how many records to fetch in each request.
* Default value is 20. The maximum allowed values is 200; any per_page
* value over 200 will be changed to 200. Use in query `per_page=200`.
* @param filterType Use in query: `filter[type]=catalog,default`.
* @return Response from the API call
*/
ComponentPricePointsController.prototype.listComponentPricePoints = function (_a, requestOptions) {
var componentId = _a.componentId, currencyPrices = _a.currencyPrices, page = _a.page, perPage = _a.perPage, filterType = _a.filterType;
return tslib_1.__awaiter(this, void 0, void 0, function () {
var req, mapped;
return tslib_1.__generator(this, function (_b) {
req = this.createRequest('GET');
mapped = req.prepareArgs({
componentId: [componentId, (0, schema_1.number)()],
currencyPrices: [currencyPrices, (0, schema_1.optional)((0, schema_1.boolean)())],
page: [page, (0, schema_1.optional)((0, schema_1.number)())],
perPage: [perPage, (0, schema_1.optional)((0, schema_1.number)())],
filterType: [filterType, (0, schema_1.optional)((0, schema_1.array)(pricePointType_1.pricePointTypeSchema))]
});
req.query('currency_prices', mapped.currencyPrices, core_1.commaPrefix);
req.query('page', mapped.page, core_1.commaPrefix);
req.query('per_page', mapped.perPage, core_1.commaPrefix);
req.query('filter[type]', mapped.filterType, core_1.commaPrefix);
req.appendTemplatePath(templateObject_3 || (templateObject_3 = tslib_1.__makeTemplateObject(["/components/", "/price_points.json"], ["/components/", "/price_points.json"])), mapped.componentId);
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(componentPricePointsResponse_1.componentPricePointsResponseSchema, requestOptions)];
});
});
};
/**
* Use this endpoint to create multiple component price points in one request.
*
* @param componentId The Advanced Billing id of the component for
* which you want to fetch price points.
* @param body
* @return Response from the API call
*/
ComponentPricePointsController.prototype.bulkCreateComponentPricePoints = function (componentId, body, requestOptions) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var req, mapped;
return tslib_1.__generator(this, function (_a) {
req = this.createRequest('POST');
mapped = req.prepareArgs({
componentId: [componentId, (0, schema_1.string)()],
body: [body, (0, schema_1.optional)(createComponentPricePointsRequest_1.createComponentPricePointsRequestSchema)]
});
req.header('Content-Type', 'application/json');
req.json(mapped.body);
req.appendTemplatePath(templateObject_4 || (templateObject_4 = tslib_1.__makeTemplateObject(["/components/", "/price_points/bulk.json"], ["/components/", "/price_points/bulk.json"])), mapped.componentId);
req.throwOn(422, errorListResponseError_1.ErrorListResponseError, true, "HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'.");
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(componentPricePointsResponse_1.componentPricePointsResponseSchema, requestOptions)];
});
});
};
/**
* When updating a price point, it's prices can be updated as well by creating new prices or editing /
* removing existing ones.
*
* Passing in a price bracket without an `id` will attempt to create a new price.
*
* Including an `id` will update the corresponding price, and including the `_destroy` flag set to true
* along with the `id` will remove that price.
*
* Note: Custom price points cannot be updated directly. They must be edited through the Subscription.
*
* @param componentId The id or handle of the component. When using
* the handle, it must be prefixed with `handle:`.
* Example: `123` for an integer ID, or `handle:
* example-product-handle` for a string handle.
* @param pricePointId The id or handle of the price point. When using
* the handle, it must be prefixed with `handle:`.
* Example: `123` for an integer ID, or `handle:
* example-price_point-handle` for a string handle.
* @param body
* @return Response from the API call
*/
ComponentPricePointsController.prototype.updateComponentPricePoint = function (componentId, pricePointId, body, requestOptions) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var req, mapped;
return tslib_1.__generator(this, function (_a) {
req = this.createRequest('PUT');
mapped = req.prepareArgs({
componentId: [componentId, updateComponentPricePointComponentId_1.updateComponentPricePointComponentIdSchema],
pricePointId: [pricePointId, updateComponentPricePointPricePointId_1.updateComponentPricePointPricePointIdSchema],
body: [body, (0, schema_1.optional)(updateComponentPricePointRequest_1.updateComponentPricePointRequestSchema)]
});
req.header('Content-Type', 'application/json');
req.json(mapped.body);
req.appendTemplatePath(templateObject_5 || (templateObject_5 = tslib_1.__makeTemplateObject(["/components/", "/price_points/", ".json"], ["/components/", "/price_points/", ".json"])), mapped.componentId, mapped.pricePointId);
req.throwOn(422, errorArrayMapResponseError_1.ErrorArrayMapResponseError, true, "HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'.");
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(componentPricePointResponse_1.componentPricePointResponseSchema, requestOptions)];
});
});
};
/**
* Use this endpoint to retrieve details for a specific component price point. You can achieve this by
* using either the component price point ID or handle.
*
* @param componentId The id or handle of the component. When using the
* handle, it must be prefixed with `handle:`. Example:
* `123` for an integer ID, or `handle:example-product-
* handle` for a string handle.
* @param pricePointId The id or handle of the price point. When using the
* handle, it must be prefixed with `handle:`. Example:
* `123` for an integer ID, or `handle:example-
* price_point-handle` for a string handle.
* @param currencyPrices Include an array of currency price data
* @return Response from the API call
*/
ComponentPricePointsController.prototype.readComponentPricePoint = function (componentId, pricePointId, currencyPrices, requestOptions) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var req, mapped;
return tslib_1.__generator(this, function (_a) {
req = this.createRequest('GET');
mapped = req.prepareArgs({
componentId: [componentId, readComponentPricePointComponentId_1.readComponentPricePointComponentIdSchema],
pricePointId: [pricePointId, readComponentPricePointPricePointId_1.readComponentPricePointPricePointIdSchema],
currencyPrices: [currencyPrices, (0, schema_1.optional)((0, schema_1.boolean)())]
});
req.query('currency_prices', mapped.currencyPrices, core_1.commaPrefix);
req.appendTemplatePath(templateObject_6 || (templateObject_6 = tslib_1.__makeTemplateObject(["/components/", "/price_points/", ".json"], ["/components/", "/price_points/", ".json"])), mapped.componentId, mapped.pricePointId);
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(componentPricePointResponse_1.componentPricePointResponseSchema, requestOptions)];
});
});
};
/**
* A price point can be archived at any time. Subscriptions using a price point that has been archived
* will continue using it until they're moved to another price point.
*
* @param componentId The id or handle of the component. When using the
* handle, it must be prefixed with `handle:`.
* Example: `123` for an integer ID, or `handle:
* example-product-handle` for a string handle.
* @param pricePointId The id or handle of the price point. When using
* the handle, it must be prefixed with `handle:`.
* Example: `123` for an integer ID, or `handle:
* example-price_point-handle` for a string handle.
* @return Response from the API call
*/
ComponentPricePointsController.prototype.archiveComponentPricePoint = function (componentId, pricePointId, requestOptions) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var req, mapped;
return tslib_1.__generator(this, function (_a) {
req = this.createRequest('DELETE');
mapped = req.prepareArgs({
componentId: [componentId, archiveComponentPricePointComponentId_1.archiveComponentPricePointComponentIdSchema],
pricePointId: [
pricePointId,
archiveComponentPricePointPricePointId_1.archiveComponentPricePointPricePointIdSchema,
]
});
req.appendTemplatePath(templateObject_7 || (templateObject_7 = tslib_1.__makeTemplateObject(["/components/", "/price_points/", ".json"], ["/components/", "/price_points/", ".json"])), mapped.componentId, mapped.pricePointId);
req.throwOn(422, errorListResponseError_1.ErrorListResponseError, true, "HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'.");
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(componentPricePointResponse_1.componentPricePointResponseSchema, requestOptions)];
});
});
};
/**
* Use this endpoint to unarchive a component price point.
*
* @param componentId The Advanced Billing id of the component to which the price point belongs
* @param pricePointId The Advanced Billing id of the price point
* @return Response from the API call
*/
ComponentPricePointsController.prototype.unarchiveComponentPricePoint = function (componentId, pricePointId, requestOptions) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var req, mapped;
return tslib_1.__generator(this, function (_a) {
req = this.createRequest('PUT');
mapped = req.prepareArgs({
componentId: [componentId, (0, schema_1.number)()],
pricePointId: [pricePointId, (0, schema_1.number)()]
});
req.appendTemplatePath(templateObject_8 || (templateObject_8 = tslib_1.__makeTemplateObject(["/components/", "/price_points/", "/unarchive.json"], ["/components/", "/price_points/", "/unarchive.json"])), mapped.componentId, mapped.pricePointId);
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(componentPricePointResponse_1.componentPricePointResponseSchema, requestOptions)];
});
});
};
/**
* This endpoint allows you to create currency prices for a given currency that has been defined on the
* site level in your settings.
*
* When creating currency prices, they need to mirror the structure of your primary pricing. For each
* price level defined on the component price point, there should be a matching price level created in
* the given currency.
*
* Note: Currency Prices are not able to be created for custom price points.
*
* @param pricePointId The Advanced Billing id of the price point
* @param body
* @return Response from the API call
*/
ComponentPricePointsController.prototype.createCurrencyPrices = function (pricePointId, body, requestOptions) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var req, mapped;
return tslib_1.__generator(this, function (_a) {
req = this.createRequest('POST');
mapped = req.prepareArgs({
pricePointId: [pricePointId, (0, schema_1.number)()],
body: [body, (0, schema_1.optional)(createCurrencyPricesRequest_1.createCurrencyPricesRequestSchema)]
});
req.header('Content-Type', 'application/json');
req.json(mapped.body);
req.appendTemplatePath(templateObject_9 || (templateObject_9 = tslib_1.__makeTemplateObject(["/price_points/", "/currency_prices.json"], ["/price_points/", "/currency_prices.json"])), mapped.pricePointId);
req.throwOn(422, errorArrayMapResponseError_1.ErrorArrayMapResponseError, true, "HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'.");
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(componentCurrencyPricesResponse_1.componentCurrencyPricesResponseSchema, requestOptions)];
});
});
};
/**
* This endpoint allows you to update currency prices for a given currency that has been defined on the
* site level in your settings.
*
* Note: Currency Prices are not able to be updated for custom price points.
*
* @param pricePointId The Advanced Billing id of the price point
* @param body
* @return Response from the API call
*/
ComponentPricePointsController.prototype.updateCurrencyPrices = function (pricePointId, body, requestOptions) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var req, mapped;
return tslib_1.__generator(this, function (_a) {
req = this.createRequest('PUT');
mapped = req.prepareArgs({
pricePointId: [pricePointId, (0, schema_1.number)()],
body: [body, (0, schema_1.optional)(updateCurrencyPricesRequest_1.updateCurrencyPricesRequestSchema)]
});
req.header('Content-Type', 'application/json');
req.json(mapped.body);
req.appendTemplatePath(templateObject_10 || (templateObject_10 = tslib_1.__makeTemplateObject(["/price_points/", "/currency_prices.json"], ["/price_points/", "/currency_prices.json"])), mapped.pricePointId);
req.throwOn(422, errorArrayMapResponseError_1.ErrorArrayMapResponseError, true, "HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'.");
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(componentCurrencyPricesResponse_1.componentCurrencyPricesResponseSchema, requestOptions)];
});
});
};
/**
* This method allows to retrieve a list of Components Price Points belonging to a Site.
*
* @param include Allows including additional data in the response. Use in
* query: `include=currency_prices`.
* @param page Result records are organized in pages. By default, the first
* page of results is displayed. The page parameter specifies a
* page number of results to fetch. You can start navigating
* through the pages to consume the results. You do this by
* passing in a page parameter. Retrieve the next page by adding
* ?page=2 to the query string. If there are no results to
* return, then an empty result set will be returned. Use in
* query `page=1`.
* @param perPage This parameter indicates how many records to fetch in each
* request. Default value is 20. The maximum allowed values is
* 200; any per_page value over 200 will be changed to 200. Use
* in query `per_page=200`.
* @param direction Controls the order in which results are returned. Use in
* query `direction=asc`.
* @param filter Filter to use for List PricePoints operations
* @return Response from the API call
*/
ComponentPricePointsController.prototype.listAllComponentPricePoints = function (_a, requestOptions) {
var include = _a.include, page = _a.page, perPage = _a.perPage, direction = _a.direction, filter = _a.filter;
return tslib_1.__awaiter(this, void 0, void 0, function () {
var req, mapped;
return tslib_1.__generator(this, function (_b) {
req = this.createRequest('GET', '/components_price_points.json');
mapped = req.prepareArgs({
include: [include, (0, schema_1.optional)(listComponentsPricePointsInclude_1.listComponentsPricePointsIncludeSchema)],
page: [page, (0, schema_1.optional)((0, schema_1.number)())],
perPage: [perPage, (0, schema_1.optional)((0, schema_1.number)())],
direction: [direction, (0, schema_1.optional)(sortingDirection_1.sortingDirectionSchema)],
filter: [filter, (0, schema_1.optional)(listPricePointsFilter_1.listPricePointsFilterSchema)]
});
req.query('include', mapped.include, core_1.commaPrefix);
req.query('page', mapped.page, core_1.commaPrefix);
req.query('per_page', mapped.perPage, core_1.commaPrefix);
req.query('direction', mapped.direction, core_1.commaPrefix);
req.query('filter', mapped.filter, core_1.commaPrefix);
req.throwOn(422, errorListResponseError_1.ErrorListResponseError, true, "HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'.");
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(listComponentsPricePointsResponse_1.listComponentsPricePointsResponseSchema, requestOptions)];
});
});
};
return ComponentPricePointsController;
}(baseController_1.BaseController));
exports.ComponentPricePointsController = ComponentPricePointsController;
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10;
//# sourceMappingURL=componentPricePointsController.js.map