@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.2 kB
JavaScript
;
/**
* AdvancedBilling
*
* This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ).
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProductFamiliesController = void 0;
var tslib_1 = require("tslib");
var core_js_1 = require("../core.js");
var basicDateField_js_1 = require("../models/basicDateField.js");
var createProductFamilyRequest_js_1 = require("../models/createProductFamilyRequest.js");
var listProductsFilter_js_1 = require("../models/listProductsFilter.js");
var listProductsInclude_js_1 = require("../models/listProductsInclude.js");
var productFamilyResponse_js_1 = require("../models/productFamilyResponse.js");
var productResponse_js_1 = require("../models/productResponse.js");
var schema_js_1 = require("../schema.js");
var baseController_js_1 = require("./baseController.js");
var core_1 = require("@apimatic/core");
var errorListResponseError_js_1 = require("../errors/errorListResponseError.js");
var ProductFamiliesController = /** @class */ (function (_super) {
tslib_1.__extends(ProductFamiliesController, _super);
function ProductFamiliesController() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* Retrieves 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_1) {
return tslib_1.__awaiter(this, arguments, void 0, function (_b, requestOptions) {
var req, mapped;
var productFamilyId = _b.productFamilyId, page = _b.page, perPage = _b.perPage, dateField = _b.dateField, filter = _b.filter, startDate = _b.startDate, endDate = _b.endDate, startDatetime = _b.startDatetime, endDatetime = _b.endDatetime, includeArchived = _b.includeArchived, include = _b.include;
return tslib_1.__generator(this, function (_c) {
req = this.createRequest('GET');
mapped = req.prepareArgs({
productFamilyId: [productFamilyId, (0, schema_js_1.string)()],
page: [page, (0, schema_js_1.optional)((0, schema_js_1.number)())],
perPage: [perPage, (0, schema_js_1.optional)((0, schema_js_1.number)())],
dateField: [dateField, (0, schema_js_1.optional)(basicDateField_js_1.basicDateFieldSchema)],
filter: [filter, (0, schema_js_1.optional)(listProductsFilter_js_1.listProductsFilterSchema)],
startDate: [startDate, (0, schema_js_1.optional)((0, schema_js_1.string)())],
endDate: [endDate, (0, schema_js_1.optional)((0, schema_js_1.string)())],
startDatetime: [startDatetime, (0, schema_js_1.optional)((0, schema_js_1.string)())],
endDatetime: [endDatetime, (0, schema_js_1.optional)((0, schema_js_1.string)())],
includeArchived: [includeArchived, (0, schema_js_1.optional)((0, schema_js_1.boolean)())],
include: [include, (0, schema_js_1.optional)(listProductsInclude_js_1.listProductsIncludeSchema)],
});
req.query('page', mapped.page, core_js_1.commaPrefix);
req.query('per_page', mapped.perPage, core_js_1.commaPrefix);
req.query('date_field', mapped.dateField, core_js_1.commaPrefix);
req.query('filter', mapped.filter, core_js_1.commaPrefix);
req.query('start_date', mapped.startDate, core_js_1.commaPrefix);
req.query('end_date', mapped.endDate, core_js_1.commaPrefix);
req.query('start_datetime', mapped.startDatetime, core_js_1.commaPrefix);
req.query('end_datetime', mapped.endDatetime, core_js_1.commaPrefix);
req.query('include_archived', mapped.includeArchived, core_js_1.commaPrefix);
req.query('include', mapped.include, core_js_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_1.ApiError, true, "Not Found:'{$response.body}'");
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson((0, schema_js_1.array)(productResponse_js_1.productResponseSchema), requestOptions)];
});
});
};
/**
* Creates 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_js_1.optional)(createProductFamilyRequest_js_1.createProductFamilyRequestSchema)],
});
req.header('Content-Type', 'application/json');
req.json(mapped.body);
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(productFamilyResponse_js_1.productFamilyResponseSchema, requestOptions)];
});
});
};
/**
* 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_1) {
return tslib_1.__awaiter(this, arguments, void 0, function (_b, requestOptions) {
var req, mapped;
var dateField = _b.dateField, startDate = _b.startDate, endDate = _b.endDate, startDatetime = _b.startDatetime, endDatetime = _b.endDatetime;
return tslib_1.__generator(this, function (_c) {
req = this.createRequest('GET', '/product_families.json');
mapped = req.prepareArgs({
dateField: [dateField, (0, schema_js_1.optional)(basicDateField_js_1.basicDateFieldSchema)],
startDate: [startDate, (0, schema_js_1.optional)((0, schema_js_1.string)())],
endDate: [endDate, (0, schema_js_1.optional)((0, schema_js_1.string)())],
startDatetime: [startDatetime, (0, schema_js_1.optional)((0, schema_js_1.string)())],
endDatetime: [endDatetime, (0, schema_js_1.optional)((0, schema_js_1.string)())],
});
req.query('date_field', mapped.dateField, core_js_1.commaPrefix);
req.query('start_date', mapped.startDate, core_js_1.commaPrefix);
req.query('end_date', mapped.endDate, core_js_1.commaPrefix);
req.query('start_datetime', mapped.startDatetime, core_js_1.commaPrefix);
req.query('end_datetime', mapped.endDatetime, core_js_1.commaPrefix);
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson((0, schema_js_1.array)(productFamilyResponse_js_1.productFamilyResponseSchema), requestOptions)];
});
});
};
/**
* Retrieves 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_js_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_js_1.productFamilyResponseSchema, requestOptions)];
});
});
};
return ProductFamiliesController;
}(baseController_js_1.BaseController));
exports.ProductFamiliesController = ProductFamiliesController;
var templateObject_1, templateObject_2;
//# sourceMappingURL=productFamiliesController.js.map