@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.
420 lines • 30.5 kB
JavaScript
"use strict";
/**
* AdvancedBilling
*
* This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ).
*/
exports.__esModule = true;
exports.ProductPricePointsController = void 0;
var tslib_1 = require("tslib");
var core_1 = require("../core");
var bulkCreateProductPricePointsRequest_1 = require("../models/bulkCreateProductPricePointsRequest");
var bulkCreateProductPricePointsResponse_1 = require("../models/bulkCreateProductPricePointsResponse");
var archiveProductPricePointPricePointId_1 = require("../models/containers/archiveProductPricePointPricePointId");
var archiveProductPricePointProductId_1 = require("../models/containers/archiveProductPricePointProductId");
var createProductPricePointProductId_1 = require("../models/containers/createProductPricePointProductId");
var listProductPricePointsInputProductId_1 = require("../models/containers/listProductPricePointsInputProductId");
var readProductPricePointPricePointId_1 = require("../models/containers/readProductPricePointPricePointId");
var readProductPricePointProductId_1 = require("../models/containers/readProductPricePointProductId");
var updateProductPricePointPricePointId_1 = require("../models/containers/updateProductPricePointPricePointId");
var updateProductPricePointProductId_1 = require("../models/containers/updateProductPricePointProductId");
var createProductCurrencyPricesRequest_1 = require("../models/createProductCurrencyPricesRequest");
var createProductPricePointRequest_1 = require("../models/createProductPricePointRequest");
var currencyPricesResponse_1 = require("../models/currencyPricesResponse");
var listPricePointsFilter_1 = require("../models/listPricePointsFilter");
var listProductPricePointsResponse_1 = require("../models/listProductPricePointsResponse");
var listProductsPricePointsInclude_1 = require("../models/listProductsPricePointsInclude");
var pricePointType_1 = require("../models/pricePointType");
var productPricePointResponse_1 = require("../models/productPricePointResponse");
var productResponse_1 = require("../models/productResponse");
var sortingDirection_1 = require("../models/sortingDirection");
var updateCurrencyPricesRequest_1 = require("../models/updateCurrencyPricesRequest");
var updateProductPricePointRequest_1 = require("../models/updateProductPricePointRequest");
var schema_1 = require("../schema");
var baseController_1 = require("./baseController");
var core_2 = require("@apimatic/core");
var errorArrayMapResponseError_1 = require("../errors/errorArrayMapResponseError");
var errorListResponseError_1 = require("../errors/errorListResponseError");
var productPricePointErrorResponseError_1 = require("../errors/productPricePointErrorResponseError");
var ProductPricePointsController = /** @class */ (function (_super) {
tslib_1.__extends(ProductPricePointsController, _super);
function ProductPricePointsController() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* [Product Price Point Documentation](https://maxio.zendesk.com/hc/en-us/articles/24261111947789-
* Product-Price-Points)
*
* @param productId The id or handle of the product. When using the
* handle, it must be prefixed with `handle:`
* @param body
* @return Response from the API call
*/
ProductPricePointsController.prototype.createProductPricePoint = function (productId, 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({
productId: [productId, createProductPricePointProductId_1.createProductPricePointProductIdSchema],
body: [body, (0, schema_1.optional)(createProductPricePointRequest_1.createProductPricePointRequestSchema)]
});
req.header('Content-Type', 'application/json');
req.json(mapped.body);
req.appendTemplatePath(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["/products/", "/price_points.json"], ["/products/", "/price_points.json"])), mapped.productId);
req.throwOn(422, productPricePointErrorResponseError_1.ProductPricePointErrorResponseError, true, "HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'.");
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(productPricePointResponse_1.productPricePointResponseSchema, requestOptions)];
});
});
};
/**
* Use this endpoint to retrieve a list of product price points.
*
* @param productId The id or handle of the product. When using the
* handle, it must be prefixed with `handle:`
* @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 10. The maximum
* allowed values is 200; any per_page value over 200
* will be changed to 200.
* @param currencyPrices When fetching a product'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 product 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 filterType Use in query: `filter[type]=catalog,default`.
* @param archived Set to include archived price points in the
* response.
* @return Response from the API call
*/
ProductPricePointsController.prototype.listProductPricePoints = function (_a, requestOptions) {
var productId = _a.productId, page = _a.page, perPage = _a.perPage, currencyPrices = _a.currencyPrices, filterType = _a.filterType, archived = _a.archived;
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({
productId: [productId, listProductPricePointsInputProductId_1.listProductPricePointsInputProductIdSchema],
page: [page, (0, schema_1.optional)((0, schema_1.number)())],
perPage: [perPage, (0, schema_1.optional)((0, schema_1.number)())],
currencyPrices: [currencyPrices, (0, schema_1.optional)((0, schema_1.boolean)())],
filterType: [filterType, (0, schema_1.optional)((0, schema_1.array)(pricePointType_1.pricePointTypeSchema))],
archived: [archived, (0, schema_1.optional)((0, schema_1.boolean)())]
});
req.query('page', mapped.page, core_1.commaPrefix);
req.query('per_page', mapped.perPage, core_1.commaPrefix);
req.query('currency_prices', mapped.currencyPrices, core_1.commaPrefix);
req.query('filter[type]', mapped.filterType, core_1.commaPrefix);
req.query('archived', mapped.archived, core_1.commaPrefix);
req.appendTemplatePath(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["/products/", "/price_points.json"], ["/products/", "/price_points.json"])), mapped.productId);
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(listProductPricePointsResponse_1.listProductPricePointsResponseSchema, requestOptions)];
});
});
};
/**
* Use this endpoint to update a product price point.
*
* Note: Custom product price points are not able to be updated.
*
* @param productId The id or handle of the product. 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-product-price-point-handle` for a string
* handle.
* @param body
* @return Response from the API call
*/
ProductPricePointsController.prototype.updateProductPricePoint = function (productId, 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({
productId: [productId, updateProductPricePointProductId_1.updateProductPricePointProductIdSchema],
pricePointId: [pricePointId, updateProductPricePointPricePointId_1.updateProductPricePointPricePointIdSchema],
body: [body, (0, schema_1.optional)(updateProductPricePointRequest_1.updateProductPricePointRequestSchema)]
});
req.header('Content-Type', 'application/json');
req.json(mapped.body);
req.appendTemplatePath(templateObject_3 || (templateObject_3 = tslib_1.__makeTemplateObject(["/products/", "/price_points/", ".json"], ["/products/", "/price_points/", ".json"])), mapped.productId, mapped.pricePointId);
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(productPricePointResponse_1.productPricePointResponseSchema, requestOptions)];
});
});
};
/**
* Use this endpoint to retrieve details for a specific product price point. You can achieve this by
* using either the product price point ID or handle.
*
* @param productId The id or handle of the product. 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-product-
* price-point-handle` for a string handle.
* @param currencyPrices When fetching a product'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 product 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.
* @return Response from the API call
*/
ProductPricePointsController.prototype.readProductPricePoint = function (productId, 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({
productId: [productId, readProductPricePointProductId_1.readProductPricePointProductIdSchema],
pricePointId: [pricePointId, readProductPricePointPricePointId_1.readProductPricePointPricePointIdSchema],
currencyPrices: [currencyPrices, (0, schema_1.optional)((0, schema_1.boolean)())]
});
req.query('currency_prices', mapped.currencyPrices, core_1.commaPrefix);
req.appendTemplatePath(templateObject_4 || (templateObject_4 = tslib_1.__makeTemplateObject(["/products/", "/price_points/", ".json"], ["/products/", "/price_points/", ".json"])), mapped.productId, mapped.pricePointId);
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(productPricePointResponse_1.productPricePointResponseSchema, requestOptions)];
});
});
};
/**
* Use this endpoint to archive a product price point.
*
* @param productId The id or handle of the product. 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-product-
* price-point-handle` for a string handle.
* @return Response from the API call
*/
ProductPricePointsController.prototype.archiveProductPricePoint = function (productId, 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({
productId: [productId, archiveProductPricePointProductId_1.archiveProductPricePointProductIdSchema],
pricePointId: [pricePointId, archiveProductPricePointPricePointId_1.archiveProductPricePointPricePointIdSchema]
});
req.appendTemplatePath(templateObject_5 || (templateObject_5 = tslib_1.__makeTemplateObject(["/products/", "/price_points/", ".json"], ["/products/", "/price_points/", ".json"])), mapped.productId, 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(productPricePointResponse_1.productPricePointResponseSchema, requestOptions)];
});
});
};
/**
* Use this endpoint to unarchive an archived product price point.
*
* @param productId The Advanced Billing id of the product to which the price point belongs
* @param pricePointId The Advanced Billing id of the product price point
* @return Response from the API call
*/
ProductPricePointsController.prototype.unarchiveProductPricePoint = function (productId, 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('PATCH');
mapped = req.prepareArgs({
productId: [productId, (0, schema_1.number)()],
pricePointId: [pricePointId, (0, schema_1.number)()]
});
req.appendTemplatePath(templateObject_6 || (templateObject_6 = tslib_1.__makeTemplateObject(["/products/", "/price_points/", "/unarchive.json"], ["/products/", "/price_points/", "/unarchive.json"])), mapped.productId, mapped.pricePointId);
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(productPricePointResponse_1.productPricePointResponseSchema, requestOptions)];
});
});
};
/**
* Use this endpoint to make a product price point the default for the product.
*
* Note: Custom product price points are not able to be set as the default for a product.
*
* @param productId The Advanced Billing id of the product to which the price point belongs
* @param pricePointId The Advanced Billing id of the product price point
* @return Response from the API call
*/
ProductPricePointsController.prototype.promoteProductPricePointToDefault = function (productId, 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('PATCH');
mapped = req.prepareArgs({
productId: [productId, (0, schema_1.number)()],
pricePointId: [pricePointId, (0, schema_1.number)()]
});
req.appendTemplatePath(templateObject_7 || (templateObject_7 = tslib_1.__makeTemplateObject(["/products/", "/price_points/", "/default.json"], ["/products/", "/price_points/", "/default.json"])), mapped.productId, mapped.pricePointId);
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(productResponse_1.productResponseSchema, requestOptions)];
});
});
};
/**
* Use this endpoint to create multiple product price points in one request.
*
* @param productId The Advanced Billing id of the product to which
* the price points belong
* @param body
* @return Response from the API call
*/
ProductPricePointsController.prototype.bulkCreateProductPricePoints = function (productId, 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({
productId: [productId, (0, schema_1.number)()],
body: [body, (0, schema_1.optional)(bulkCreateProductPricePointsRequest_1.bulkCreateProductPricePointsRequestSchema)]
});
req.header('Content-Type', 'application/json');
req.json(mapped.body);
req.appendTemplatePath(templateObject_8 || (templateObject_8 = tslib_1.__makeTemplateObject(["/products/", "/price_points/bulk.json"], ["/products/", "/price_points/bulk.json"])), mapped.productId);
req.throwOn(422, core_2.ApiError, true, "HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'.");
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(bulkCreateProductPricePointsResponse_1.bulkCreateProductPricePointsResponseSchema, 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. If the
* product price point defines a trial and/or setup fee, each currency must also define a trial and/or
* setup fee.
*
* Note: Currency Prices are not able to be created for custom product price points.
*
* @param productPricePointId The Advanced Billing id of the product
* price point
* @param body
* @return Response from the API call
*/
ProductPricePointsController.prototype.createProductCurrencyPrices = function (productPricePointId, 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({
productPricePointId: [productPricePointId, (0, schema_1.number)()],
body: [body, (0, schema_1.optional)(createProductCurrencyPricesRequest_1.createProductCurrencyPricesRequestSchema)]
});
req.header('Content-Type', 'application/json');
req.json(mapped.body);
req.appendTemplatePath(templateObject_9 || (templateObject_9 = tslib_1.__makeTemplateObject(["/product_price_points/", "/currency_prices.json"], ["/product_price_points/", "/currency_prices.json"])), mapped.productPricePointId);
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(currencyPricesResponse_1.currencyPricesResponseSchema, requestOptions)];
});
});
};
/**
* This endpoint allows you to update the `price`s of currency prices for a given currency that exists
* on the product price point.
*
* When updating the pricing, it needs to mirror the structure of your primary pricing. If the product
* price point defines a trial and/or setup fee, each currency must also define a trial and/or setup
* fee.
*
* Note: Currency Prices are not able to be updated for custom product price points.
*
* @param productPricePointId The Advanced Billing id of the product price
* point
* @param body
* @return Response from the API call
*/
ProductPricePointsController.prototype.updateProductCurrencyPrices = function (productPricePointId, 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({
productPricePointId: [productPricePointId, (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(["/product_price_points/", "/currency_prices.json"], ["/product_price_points/", "/currency_prices.json"])), mapped.productPricePointId);
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(currencyPricesResponse_1.currencyPricesResponseSchema, requestOptions)];
});
});
};
/**
* This method allows retrieval of a list of Products Price Points belonging to a Site.
*
* @param direction Controls the order in which results are returned. Use in query
* `direction=asc`.
* @param filter Filter to use for List PricePoints operations
* @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`.
* @return Response from the API call
*/
ProductPricePointsController.prototype.listAllProductPricePoints = function (_a, requestOptions) {
var direction = _a.direction, filter = _a.filter, include = _a.include, page = _a.page, perPage = _a.perPage;
return tslib_1.__awaiter(this, void 0, void 0, function () {
var req, mapped;
return tslib_1.__generator(this, function (_b) {
req = this.createRequest('GET', '/products_price_points.json');
mapped = req.prepareArgs({
direction: [direction, (0, schema_1.optional)(sortingDirection_1.sortingDirectionSchema)],
filter: [filter, (0, schema_1.optional)(listPricePointsFilter_1.listPricePointsFilterSchema)],
include: [include, (0, schema_1.optional)(listProductsPricePointsInclude_1.listProductsPricePointsIncludeSchema)],
page: [page, (0, schema_1.optional)((0, schema_1.number)())],
perPage: [perPage, (0, schema_1.optional)((0, schema_1.number)())]
});
req.query('direction', mapped.direction, core_1.commaPrefix);
req.query('filter', mapped.filter, core_1.commaPrefix);
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.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(listProductPricePointsResponse_1.listProductPricePointsResponseSchema, requestOptions)];
});
});
};
return ProductPricePointsController;
}(baseController_1.BaseController));
exports.ProductPricePointsController = ProductPricePointsController;
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10;
//# sourceMappingURL=productPricePointsController.js.map