@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.
204 lines • 15 kB
JavaScript
;
/**
* AdvancedBilling
*
* This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ).
*/
exports.__esModule = true;
exports.ProductFamiliesController = void 0;
var tslib_1 = require("tslib");
var core_1 = require("../core");
var basicDateField_1 = require("../models/basicDateField");
var createProductFamilyRequest_1 = require("../models/createProductFamilyRequest");
var listProductsFilter_1 = require("../models/listProductsFilter");
var listProductsInclude_1 = require("../models/listProductsInclude");
var productFamilyResponse_1 = require("../models/productFamilyResponse");
var productResponse_1 = require("../models/productResponse");
var schema_1 = require("../schema");
var baseController_1 = require("./baseController");
var core_2 = require("@apimatic/core");
var errorListResponseError_1 = require("../errors/errorListResponseError");
var ProductFamiliesController = /** @class */ (function (_super) {
tslib_1.__extends(ProductFamiliesController, _super);
function ProductFamiliesController() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* This method allows to retrieve a list of Products belonging to a Product Family.
*
* @param productFamilyId Either the product family's id or its handle 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 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 dateField The type of filter you would like to apply to your search.
* Use in query: `date_field=created_at`.
* @param filter Filter to use for List Products operations
* @param startDate The start date (format YYYY-MM-DD) with which to filter the
* date_field. Returns products with a timestamp at or after
* midnight (12:00:00 AM) in your site’s time zone on the date
* specified.
* @param endDate The end date (format YYYY-MM-DD) with which to filter the
* date_field. Returns products with a timestamp up to and
* including 11:59:59PM in your site’s time zone on the date
* specified.
* @param startDatetime The start date and time (format YYYY-MM-DD HH:MM:SS) with
* which to filter the date_field. Returns products with a
* timestamp at or after exact time provided in query. You can
* specify timezone in query - otherwise your site's time zone
* will be used. If provided, this parameter will be used
* instead of start_date.
* @param endDatetime The end date and time (format YYYY-MM-DD HH:MM:SS) with
* which to filter the date_field. Returns products with a
* timestamp at or before exact time provided in query. You can
* specify timezone in query - otherwise your site's time zone
* will be used. If provided, this parameter will be used
* instead of end_date.
* @param includeArchived Include archived products
* @param include Allows including additional data in the response. Use in
* query `include=prepaid_product_price_point`.
* @return Response from the API call
*/
ProductFamiliesController.prototype.listProductsForProductFamily = function (_a, requestOptions) {
var productFamilyId = _a.productFamilyId, page = _a.page, perPage = _a.perPage, dateField = _a.dateField, filter = _a.filter, startDate = _a.startDate, endDate = _a.endDate, startDatetime = _a.startDatetime, endDatetime = _a.endDatetime, includeArchived = _a.includeArchived, include = _a.include;
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({
productFamilyId: [productFamilyId, (0, schema_1.string)()],
page: [page, (0, schema_1.optional)((0, schema_1.number)())],
perPage: [perPage, (0, schema_1.optional)((0, schema_1.number)())],
dateField: [dateField, (0, schema_1.optional)(basicDateField_1.basicDateFieldSchema)],
filter: [filter, (0, schema_1.optional)(listProductsFilter_1.listProductsFilterSchema)],
startDate: [startDate, (0, schema_1.optional)((0, schema_1.string)())],
endDate: [endDate, (0, schema_1.optional)((0, schema_1.string)())],
startDatetime: [startDatetime, (0, schema_1.optional)((0, schema_1.string)())],
endDatetime: [endDatetime, (0, schema_1.optional)((0, schema_1.string)())],
includeArchived: [includeArchived, (0, schema_1.optional)((0, schema_1.boolean)())],
include: [include, (0, schema_1.optional)(listProductsInclude_1.listProductsIncludeSchema)]
});
req.query('page', mapped.page, core_1.commaPrefix);
req.query('per_page', mapped.perPage, core_1.commaPrefix);
req.query('date_field', mapped.dateField, core_1.commaPrefix);
req.query('filter', mapped.filter, core_1.commaPrefix);
req.query('start_date', mapped.startDate, core_1.commaPrefix);
req.query('end_date', mapped.endDate, core_1.commaPrefix);
req.query('start_datetime', mapped.startDatetime, core_1.commaPrefix);
req.query('end_datetime', mapped.endDatetime, core_1.commaPrefix);
req.query('include_archived', mapped.includeArchived, core_1.commaPrefix);
req.query('include', mapped.include, core_1.commaPrefix);
req.appendTemplatePath(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["/product_families/", "/products.json"], ["/product_families/", "/products.json"])), mapped.productFamilyId);
req.throwOn(404, core_2.ApiError, true, "Not Found:'{$response.body}'");
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson((0, schema_1.array)(productResponse_1.productResponseSchema), requestOptions)];
});
});
};
/**
* This method will create a Product Family within your Advanced Billing site. Create a Product Family
* to act as a container for your products, components and coupons.
*
* Full documentation on how Product Families operate within the Advanced Billing UI can be located
* [here](https://maxio.zendesk.com/hc/en-us/articles/24261098936205-Product-Families).
*
* @param body
* @return Response from the API call
*/
ProductFamiliesController.prototype.createProductFamily = function (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', '/product_families.json');
mapped = req.prepareArgs({
body: [body, (0, schema_1.optional)(createProductFamilyRequest_1.createProductFamilyRequestSchema)]
});
req.header('Content-Type', 'application/json');
req.json(mapped.body);
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(productFamilyResponse_1.productFamilyResponseSchema, requestOptions)];
});
});
};
/**
* This method allows to retrieve a list of Product Families for a site.
*
* @param dateField The type of filter you would like to apply to your search. Use in query:
* `date_field=created_at`.
* @param startDate The start date (format YYYY-MM-DD) with which to filter the date_field.
* Returns products with a timestamp at or after midnight (12:00:00 AM) in
* your site’s time zone on the date specified.
* @param endDate The end date (format YYYY-MM-DD) with which to filter the date_field.
* Returns products with a timestamp up to and including 11:59:59PM in your
* site’s time zone on the date specified.
* @param startDatetime The start date and time (format YYYY-MM-DD HH:MM:SS) with which to filter
* the date_field. Returns products with a timestamp at or after exact time
* provided in query. You can specify timezone in query - otherwise your
* site's time zone will be used. If provided, this parameter will be used
* instead of start_date.
* @param endDatetime The end date and time (format YYYY-MM-DD HH:MM:SS) with which to filter
* the date_field. Returns products with a timestamp at or before exact time
* provided in query. You can specify timezone in query - otherwise your
* site's time zone will be used. If provided, this parameter will be used
* instead of end_date.
* @return Response from the API call
*/
ProductFamiliesController.prototype.listProductFamilies = function (_a, requestOptions) {
var dateField = _a.dateField, startDate = _a.startDate, endDate = _a.endDate, startDatetime = _a.startDatetime, endDatetime = _a.endDatetime;
return tslib_1.__awaiter(this, void 0, void 0, function () {
var req, mapped;
return tslib_1.__generator(this, function (_b) {
req = this.createRequest('GET', '/product_families.json');
mapped = req.prepareArgs({
dateField: [dateField, (0, schema_1.optional)(basicDateField_1.basicDateFieldSchema)],
startDate: [startDate, (0, schema_1.optional)((0, schema_1.string)())],
endDate: [endDate, (0, schema_1.optional)((0, schema_1.string)())],
startDatetime: [startDatetime, (0, schema_1.optional)((0, schema_1.string)())],
endDatetime: [endDatetime, (0, schema_1.optional)((0, schema_1.string)())]
});
req.query('date_field', mapped.dateField, core_1.commaPrefix);
req.query('start_date', mapped.startDate, core_1.commaPrefix);
req.query('end_date', mapped.endDate, core_1.commaPrefix);
req.query('start_datetime', mapped.startDatetime, core_1.commaPrefix);
req.query('end_datetime', mapped.endDatetime, core_1.commaPrefix);
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson((0, schema_1.array)(productFamilyResponse_1.productFamilyResponseSchema), requestOptions)];
});
});
};
/**
* This method allows to retrieve a Product Family via the `product_family_id`. The response will
* contain a Product Family object.
*
* The product family can be specified either with the id number, or with the `handle:my-family` format.
*
* @param id The Advanced Billing id of the product family
* @return Response from the API call
*/
ProductFamiliesController.prototype.readProductFamily = function (id, 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({ id: [id, (0, schema_1.number)()] });
req.appendTemplatePath(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["/product_families/", ".json"], ["/product_families/", ".json"])), mapped.id);
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(productFamilyResponse_1.productFamilyResponseSchema, requestOptions)];
});
});
};
return ProductFamiliesController;
}(baseController_1.BaseController));
exports.ProductFamiliesController = ProductFamiliesController;
var templateObject_1, templateObject_2;
//# sourceMappingURL=productFamiliesController.js.map