@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.
152 lines • 9.89 kB
JavaScript
;
/**
* AdvancedBilling
*
* This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ).
*/
exports.__esModule = true;
exports.SubscriptionGroupInvoiceAccountController = void 0;
var tslib_1 = require("tslib");
var core_1 = require("../core");
var deductServiceCreditRequest_1 = require("../models/deductServiceCreditRequest");
var issueServiceCreditRequest_1 = require("../models/issueServiceCreditRequest");
var listPrepaymentsFilter_1 = require("../models/listPrepaymentsFilter");
var listSubscriptionGroupPrepaymentResponse_1 = require("../models/listSubscriptionGroupPrepaymentResponse");
var serviceCredit_1 = require("../models/serviceCredit");
var serviceCreditResponse_1 = require("../models/serviceCreditResponse");
var subscriptionGroupPrepaymentRequest_1 = require("../models/subscriptionGroupPrepaymentRequest");
var subscriptionGroupPrepaymentResponse_1 = require("../models/subscriptionGroupPrepaymentResponse");
var schema_1 = require("../schema");
var baseController_1 = require("./baseController");
var core_2 = require("@apimatic/core");
var errorListResponseError_1 = require("../errors/errorListResponseError");
var SubscriptionGroupInvoiceAccountController = /** @class */ (function (_super) {
tslib_1.__extends(SubscriptionGroupInvoiceAccountController, _super);
function SubscriptionGroupInvoiceAccountController() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* A prepayment can be added for a subscription group identified by the group's `uid`. This endpoint
* requires a `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_1.string)()],
body: [body, (0, schema_1.optional)(subscriptionGroupPrepaymentRequest_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_1.ErrorListResponseError, true, "HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'.");
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(subscriptionGroupPrepaymentResponse_1.subscriptionGroupPrepaymentResponseSchema, requestOptions)];
});
});
};
/**
* This request will list 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) {
var uid = _a.uid, page = _a.page, perPage = _a.perPage, filter = _a.filter;
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({
uid: [uid, (0, schema_1.string)()],
page: [page, (0, schema_1.optional)((0, schema_1.number)())],
perPage: [perPage, (0, schema_1.optional)((0, schema_1.number)())],
filter: [filter, (0, schema_1.optional)(listPrepaymentsFilter_1.listPrepaymentsFilterSchema)]
});
req.query('page', mapped.page, core_1.commaPrefix);
req.query('per_page', mapped.perPage, core_1.commaPrefix);
req.query('filter', mapped.filter, core_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_2.ApiError, true, "Not Found:'{$response.body}'");
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(listSubscriptionGroupPrepaymentResponse_1.listSubscriptionGroupPrepaymentResponseSchema, requestOptions)];
});
});
};
/**
* Credit can be issued for a subscription group identified by the group's `uid`. 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_1.string)()],
body: [body, (0, schema_1.optional)(issueServiceCreditRequest_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_1.ErrorListResponseError, true, "HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'.");
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(serviceCreditResponse_1.serviceCreditResponseSchema, requestOptions)];
});
});
};
/**
* Credit can be deducted for a subscription group identified by the group's `uid`. 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_1.string)()],
body: [body, (0, schema_1.optional)(deductServiceCreditRequest_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_1.ErrorListResponseError, true, "HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'.");
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(serviceCredit_1.serviceCreditSchema, requestOptions)];
});
});
};
return SubscriptionGroupInvoiceAccountController;
}(baseController_1.BaseController));
exports.SubscriptionGroupInvoiceAccountController = SubscriptionGroupInvoiceAccountController;
var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
//# sourceMappingURL=subscriptionGroupInvoiceAccountController.js.map