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.

151 lines 9.98 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.SubscriptionGroupInvoiceAccountController = void 0; var tslib_1 = require("tslib"); var core_js_1 = require("../core.js"); var deductServiceCreditRequest_js_1 = require("../models/deductServiceCreditRequest.js"); var issueServiceCreditRequest_js_1 = require("../models/issueServiceCreditRequest.js"); var listPrepaymentsFilter_js_1 = require("../models/listPrepaymentsFilter.js"); var listSubscriptionGroupPrepaymentResponse_js_1 = require("../models/listSubscriptionGroupPrepaymentResponse.js"); var serviceCredit_js_1 = require("../models/serviceCredit.js"); var serviceCreditResponse_js_1 = require("../models/serviceCreditResponse.js"); var subscriptionGroupPrepaymentRequest_js_1 = require("../models/subscriptionGroupPrepaymentRequest.js"); var subscriptionGroupPrepaymentResponse_js_1 = require("../models/subscriptionGroupPrepaymentResponse.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 SubscriptionGroupInvoiceAccountController = /** @class */ (function (_super) { tslib_1.__extends(SubscriptionGroupInvoiceAccountController, _super); function SubscriptionGroupInvoiceAccountController() { return _super !== null && _super.apply(this, arguments) || this; } /** * Adds a prepayment for a subscription group. This endpoint requires an `amount`, `details`, `method`, * and `memo`. On success, the prepayment will be added to the group's prepayment balance. * * @param uid The uid of the subscription group * @param body * @return Response from the API call */ SubscriptionGroupInvoiceAccountController.prototype.createSubscriptionGroupPrepayment = function (uid, 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({ uid: [uid, (0, schema_js_1.string)()], body: [body, (0, schema_js_1.optional)(subscriptionGroupPrepaymentRequest_js_1.subscriptionGroupPrepaymentRequestSchema)], }); req.header('Content-Type', 'application/json'); req.json(mapped.body); req.appendTemplatePath(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["/subscription_groups/", "/prepayments.json"], ["/subscription_groups/", "/prepayments.json"])), mapped.uid); 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(subscriptionGroupPrepaymentResponse_js_1.subscriptionGroupPrepaymentResponseSchema, requestOptions)]; }); }); }; /** * Lists a subscription group's prepayments. * * @param uid The uid of the subscription group * @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 filter Filter to use for List Prepayments operations * @return Response from the API call */ SubscriptionGroupInvoiceAccountController.prototype.listPrepaymentsForSubscriptionGroup = function (_a, requestOptions_1) { return tslib_1.__awaiter(this, arguments, void 0, function (_b, requestOptions) { var req, mapped; var uid = _b.uid, page = _b.page, perPage = _b.perPage, filter = _b.filter; return tslib_1.__generator(this, function (_c) { req = this.createRequest('GET'); mapped = req.prepareArgs({ uid: [uid, (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)())], filter: [filter, (0, schema_js_1.optional)(listPrepaymentsFilter_js_1.listPrepaymentsFilterSchema)], }); req.query('page', mapped.page, core_js_1.commaPrefix); req.query('per_page', mapped.perPage, core_js_1.commaPrefix); req.query('filter', mapped.filter, core_js_1.commaPrefix); req.appendTemplatePath(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["/subscription_groups/", "/prepayments.json"], ["/subscription_groups/", "/prepayments.json"])), mapped.uid); req.throwOn(404, core_1.ApiError, true, "Not Found:'{$response.body}'"); req.authenticate([{ basicAuth: true }]); return [2 /*return*/, req.callAsJson(listSubscriptionGroupPrepaymentResponse_js_1.listSubscriptionGroupPrepaymentResponseSchema, requestOptions)]; }); }); }; /** * Issues service credit for a subscription group. Credit will be added to the group in the amount * specified in the request body. The credit will be applied to group member invoices as they are * generated. * * @param uid The uid of the subscription group * @param body * @return Response from the API call */ SubscriptionGroupInvoiceAccountController.prototype.issueSubscriptionGroupServiceCredit = function (uid, 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({ uid: [uid, (0, schema_js_1.string)()], body: [body, (0, schema_js_1.optional)(issueServiceCreditRequest_js_1.issueServiceCreditRequestSchema)], }); req.header('Content-Type', 'application/json'); req.json(mapped.body); req.appendTemplatePath(templateObject_3 || (templateObject_3 = tslib_1.__makeTemplateObject(["/subscription_groups/", "/service_credits.json"], ["/subscription_groups/", "/service_credits.json"])), mapped.uid); 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(serviceCreditResponse_js_1.serviceCreditResponseSchema, requestOptions)]; }); }); }; /** * Deducts service credit for a subscription group. Credit will be deducted from the group in the * amount specified in the request body. * * @param uid The uid of the subscription group * @param body * @return Response from the API call */ SubscriptionGroupInvoiceAccountController.prototype.deductSubscriptionGroupServiceCredit = function (uid, 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({ uid: [uid, (0, schema_js_1.string)()], body: [body, (0, schema_js_1.optional)(deductServiceCreditRequest_js_1.deductServiceCreditRequestSchema)], }); req.header('Content-Type', 'application/json'); req.json(mapped.body); req.appendTemplatePath(templateObject_4 || (templateObject_4 = tslib_1.__makeTemplateObject(["/subscription_groups/", "/service_credit_deductions.json"], ["/subscription_groups/", "/service_credit_deductions.json"])), mapped.uid); 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(serviceCredit_js_1.serviceCreditSchema, requestOptions)]; }); }); }; return SubscriptionGroupInvoiceAccountController; }(baseController_js_1.BaseController)); exports.SubscriptionGroupInvoiceAccountController = SubscriptionGroupInvoiceAccountController; var templateObject_1, templateObject_2, templateObject_3, templateObject_4; //# sourceMappingURL=subscriptionGroupInvoiceAccountController.js.map