UNPKG

@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.

419 lines 30.9 kB
"use strict"; /** * AdvancedBilling * * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). */ Object.defineProperty(exports, "__esModule", { value: true }); exports.ProductPricePointsController = void 0; var tslib_1 = require("tslib"); var core_js_1 = require("../core.js"); var bulkCreateProductPricePointsRequest_js_1 = require("../models/bulkCreateProductPricePointsRequest.js"); var bulkCreateProductPricePointsResponse_js_1 = require("../models/bulkCreateProductPricePointsResponse.js"); var archiveProductPricePointPricePointId_js_1 = require("../models/containers/archiveProductPricePointPricePointId.js"); var archiveProductPricePointProductId_js_1 = require("../models/containers/archiveProductPricePointProductId.js"); var createProductPricePointProductId_js_1 = require("../models/containers/createProductPricePointProductId.js"); var listProductPricePointsInputProductId_js_1 = require("../models/containers/listProductPricePointsInputProductId.js"); var readProductPricePointPricePointId_js_1 = require("../models/containers/readProductPricePointPricePointId.js"); var readProductPricePointProductId_js_1 = require("../models/containers/readProductPricePointProductId.js"); var updateProductPricePointPricePointId_js_1 = require("../models/containers/updateProductPricePointPricePointId.js"); var updateProductPricePointProductId_js_1 = require("../models/containers/updateProductPricePointProductId.js"); var createProductCurrencyPricesRequest_js_1 = require("../models/createProductCurrencyPricesRequest.js"); var createProductPricePointRequest_js_1 = require("../models/createProductPricePointRequest.js"); var currencyPricesResponse_js_1 = require("../models/currencyPricesResponse.js"); var listPricePointsFilter_js_1 = require("../models/listPricePointsFilter.js"); var listProductPricePointsResponse_js_1 = require("../models/listProductPricePointsResponse.js"); var listProductsPricePointsInclude_js_1 = require("../models/listProductsPricePointsInclude.js"); var pricePointType_js_1 = require("../models/pricePointType.js"); var productPricePointResponse_js_1 = require("../models/productPricePointResponse.js"); var productResponse_js_1 = require("../models/productResponse.js"); var sortingDirection_js_1 = require("../models/sortingDirection.js"); var updateCurrencyPricesRequest_js_1 = require("../models/updateCurrencyPricesRequest.js"); var updateProductPricePointRequest_js_1 = require("../models/updateProductPricePointRequest.js"); var schema_js_1 = require("../schema.js"); var baseController_js_1 = require("./baseController.js"); var core_1 = require("@apimatic/core"); var errorArrayMapResponseError_js_1 = require("../errors/errorArrayMapResponseError.js"); var errorListResponseError_js_1 = require("../errors/errorListResponseError.js"); var productPricePointErrorResponseError_js_1 = require("../errors/productPricePointErrorResponseError.js"); var ProductPricePointsController = /** @class */ (function (_super) { tslib_1.__extends(ProductPricePointsController, _super); function ProductPricePointsController() { return _super !== null && _super.apply(this, arguments) || this; } /** * Creates a Product Price Point. See the [Product Price Point](https://maxio.zendesk.com/hc/en- * us/articles/24261111947789-Product-Price-Points) documentation for details. * * @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_js_1.createProductPricePointProductIdSchema], body: [body, (0, schema_js_1.optional)(createProductPricePointRequest_js_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_js_1.ProductPricePointErrorResponseError, true, "HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'."); req.authenticate([{ basicAuth: true }]); return [2 /*return*/, req.callAsJson(productPricePointResponse_js_1.productPricePointResponseSchema, requestOptions)]; }); }); }; /** * Retrieves 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_1) { return tslib_1.__awaiter(this, arguments, void 0, function (_b, requestOptions) { var req, mapped; var productId = _b.productId, page = _b.page, perPage = _b.perPage, currencyPrices = _b.currencyPrices, filterType = _b.filterType, archived = _b.archived; return tslib_1.__generator(this, function (_c) { req = this.createRequest('GET'); mapped = req.prepareArgs({ productId: [productId, listProductPricePointsInputProductId_js_1.listProductPricePointsInputProductIdSchema], page: [page, (0, schema_js_1.optional)((0, schema_js_1.number)())], perPage: [perPage, (0, schema_js_1.optional)((0, schema_js_1.number)())], currencyPrices: [currencyPrices, (0, schema_js_1.optional)((0, schema_js_1.boolean)())], filterType: [filterType, (0, schema_js_1.optional)((0, schema_js_1.array)(pricePointType_js_1.pricePointTypeSchema))], archived: [archived, (0, schema_js_1.optional)((0, schema_js_1.boolean)())], }); req.query('page', mapped.page, core_js_1.commaPrefix); req.query('per_page', mapped.perPage, core_js_1.commaPrefix); req.query('currency_prices', mapped.currencyPrices, core_js_1.commaPrefix); req.query('filter[type]', mapped.filterType, core_js_1.commaPrefix); req.query('archived', mapped.archived, core_js_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_js_1.listProductPricePointsResponseSchema, requestOptions)]; }); }); }; /** * Updates a product price point. * * Note: Custom product price points cannot 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_js_1.updateProductPricePointProductIdSchema], pricePointId: [pricePointId, updateProductPricePointPricePointId_js_1.updateProductPricePointPricePointIdSchema], body: [body, (0, schema_js_1.optional)(updateProductPricePointRequest_js_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_js_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_js_1.readProductPricePointProductIdSchema], pricePointId: [pricePointId, readProductPricePointPricePointId_js_1.readProductPricePointPricePointIdSchema], currencyPrices: [currencyPrices, (0, schema_js_1.optional)((0, schema_js_1.boolean)())], }); req.query('currency_prices', mapped.currencyPrices, core_js_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_js_1.productPricePointResponseSchema, requestOptions)]; }); }); }; /** * Archives 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_js_1.archiveProductPricePointProductIdSchema], pricePointId: [pricePointId, archiveProductPricePointPricePointId_js_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_js_1.ErrorListResponseError, true, "HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'."); req.authenticate([{ basicAuth: true }]); return [2 /*return*/, req.callAsJson(productPricePointResponse_js_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_js_1.number)()], pricePointId: [pricePointId, (0, schema_js_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_js_1.productPricePointResponseSchema, requestOptions)]; }); }); }; /** * Sets a product price point as the default for the product. * * Note: Custom product price points cannot 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_js_1.number)()], pricePointId: [pricePointId, (0, schema_js_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_js_1.productResponseSchema, requestOptions)]; }); }); }; /** * Creates 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_js_1.number)()], body: [body, (0, schema_js_1.optional)(bulkCreateProductPricePointsRequest_js_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_1.ApiError, true, "HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'."); req.authenticate([{ basicAuth: true }]); return [2 /*return*/, req.callAsJson(bulkCreateProductPricePointsResponse_js_1.bulkCreateProductPricePointsResponseSchema, requestOptions)]; }); }); }; /** * Creates 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_js_1.number)()], body: [body, (0, schema_js_1.optional)(createProductCurrencyPricesRequest_js_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_js_1.ErrorArrayMapResponseError, true, "HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'."); req.authenticate([{ basicAuth: true }]); return [2 /*return*/, req.callAsJson(currencyPricesResponse_js_1.currencyPricesResponseSchema, requestOptions)]; }); }); }; /** * Updates 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 cannot 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_js_1.number)()], body: [body, (0, schema_js_1.optional)(updateCurrencyPricesRequest_js_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_js_1.ErrorArrayMapResponseError, true, "HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'."); req.authenticate([{ basicAuth: true }]); return [2 /*return*/, req.callAsJson(currencyPricesResponse_js_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_1) { return tslib_1.__awaiter(this, arguments, void 0, function (_b, requestOptions) { var req, mapped; var direction = _b.direction, filter = _b.filter, include = _b.include, page = _b.page, perPage = _b.perPage; return tslib_1.__generator(this, function (_c) { req = this.createRequest('GET', '/products_price_points.json'); mapped = req.prepareArgs({ direction: [direction, (0, schema_js_1.optional)(sortingDirection_js_1.sortingDirectionSchema)], filter: [filter, (0, schema_js_1.optional)(listPricePointsFilter_js_1.listPricePointsFilterSchema)], include: [include, (0, schema_js_1.optional)(listProductsPricePointsInclude_js_1.listProductsPricePointsIncludeSchema)], page: [page, (0, schema_js_1.optional)((0, schema_js_1.number)())], perPage: [perPage, (0, schema_js_1.optional)((0, schema_js_1.number)())], }); req.query('direction', mapped.direction, core_js_1.commaPrefix); req.query('filter', mapped.filter, core_js_1.commaPrefix); req.query('include', mapped.include, core_js_1.commaPrefix); req.query('page', mapped.page, core_js_1.commaPrefix); req.query('per_page', mapped.perPage, core_js_1.commaPrefix); req.throwOn(422, errorListResponseError_js_1.ErrorListResponseError, true, "HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'."); req.authenticate([{ basicAuth: true }]); return [2 /*return*/, req.callAsJson(listProductPricePointsResponse_js_1.listProductPricePointsResponseSchema, requestOptions)]; }); }); }; return ProductPricePointsController; }(baseController_js_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