@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.
322 lines • 20.6 kB
JavaScript
"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.SubscriptionRenewalsController = void 0;
var tslib_1 = require("tslib");
var core_js_1 = require("../core.js");
var scheduledRenewalConfigurationItemRequest_js_1 = require("../models/scheduledRenewalConfigurationItemRequest.js");
var scheduledRenewalConfigurationItemResponse_js_1 = require("../models/scheduledRenewalConfigurationItemResponse.js");
var scheduledRenewalConfigurationRequest_js_1 = require("../models/scheduledRenewalConfigurationRequest.js");
var scheduledRenewalConfigurationResponse_js_1 = require("../models/scheduledRenewalConfigurationResponse.js");
var scheduledRenewalConfigurationsResponse_js_1 = require("../models/scheduledRenewalConfigurationsResponse.js");
var scheduledRenewalLockInRequest_js_1 = require("../models/scheduledRenewalLockInRequest.js");
var scheduledRenewalUpdateRequest_js_1 = require("../models/scheduledRenewalUpdateRequest.js");
var status_js_1 = require("../models/status.js");
var schema_js_1 = require("../schema.js");
var baseController_js_1 = require("./baseController.js");
var errorListResponseError_js_1 = require("../errors/errorListResponseError.js");
var SubscriptionRenewalsController = /** @class */ (function (_super) {
tslib_1.__extends(SubscriptionRenewalsController, _super);
function SubscriptionRenewalsController() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* Creates a scheduled renewal configuration for a subscription. The scheduled renewal is based on the
* subscription’s current product and component setup.
*
* @param subscriptionId The Chargify id of the subscription.
* @param body
* @return Response from the API call
*/
SubscriptionRenewalsController.prototype.createScheduledRenewalConfiguration = function (subscriptionId, 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({
subscriptionId: [subscriptionId, (0, schema_js_1.number)()],
body: [body, (0, schema_js_1.optional)(scheduledRenewalConfigurationRequest_js_1.scheduledRenewalConfigurationRequestSchema)],
});
req.header('Content-Type', 'application/json');
req.json(mapped.body);
req.appendTemplatePath(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["/subscriptions/", "/scheduled_renewals.json"], ["/subscriptions/", "/scheduled_renewals.json"])), mapped.subscriptionId);
req.throwOn(422, errorListResponseError_js_1.ErrorListResponseError, 'Unprocessable Entity (WebDAV)');
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(scheduledRenewalConfigurationResponse_js_1.scheduledRenewalConfigurationResponseSchema, requestOptions)];
});
});
};
/**
* Lists scheduled renewal configurations for the subscription and permits an optional status query
* filter.
*
* @param subscriptionId The Chargify id of the subscription.
* @param status (Optional) Status filter for scheduled renewal configurations.
* @return Response from the API call
*/
SubscriptionRenewalsController.prototype.listScheduledRenewalConfigurations = function (subscriptionId, status, 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({
subscriptionId: [subscriptionId, (0, schema_js_1.number)()],
status: [status, (0, schema_js_1.optional)(status_js_1.statusSchema)],
});
req.query('status', mapped.status, core_js_1.commaPrefix);
req.appendTemplatePath(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["/subscriptions/", "/scheduled_renewals.json"], ["/subscriptions/", "/scheduled_renewals.json"])), mapped.subscriptionId);
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(scheduledRenewalConfigurationsResponse_js_1.scheduledRenewalConfigurationsResponseSchema, requestOptions)];
});
});
};
/**
* Retrieves the configuration settings for the scheduled renewal.
*
* @param subscriptionId The Chargify id of the subscription.
* @param id The renewal id.
* @return Response from the API call
*/
SubscriptionRenewalsController.prototype.readScheduledRenewalConfiguration = function (subscriptionId, 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({
subscriptionId: [subscriptionId, (0, schema_js_1.number)()],
id: [id, (0, schema_js_1.number)()],
});
req.appendTemplatePath(templateObject_3 || (templateObject_3 = tslib_1.__makeTemplateObject(["/subscriptions/", "/scheduled_renewals/", ".json"], ["/subscriptions/", "/scheduled_renewals/", ".json"])), mapped.subscriptionId, mapped.id);
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(scheduledRenewalConfigurationResponse_js_1.scheduledRenewalConfigurationResponseSchema, requestOptions)];
});
});
};
/**
* Updates an existing configuration.
*
* @param subscriptionId The Chargify id of the subscription.
* @param id The renewal id.
* @param body
* @return Response from the API call
*/
SubscriptionRenewalsController.prototype.updateScheduledRenewalConfiguration = function (subscriptionId, id, 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({
subscriptionId: [subscriptionId, (0, schema_js_1.number)()],
id: [id, (0, schema_js_1.number)()],
body: [body, (0, schema_js_1.optional)(scheduledRenewalConfigurationRequest_js_1.scheduledRenewalConfigurationRequestSchema)],
});
req.header('Content-Type', 'application/json');
req.json(mapped.body);
req.appendTemplatePath(templateObject_4 || (templateObject_4 = tslib_1.__makeTemplateObject(["/subscriptions/", "/scheduled_renewals/", ".json"], ["/subscriptions/", "/scheduled_renewals/", ".json"])), mapped.subscriptionId, mapped.id);
req.throwOn(422, errorListResponseError_js_1.ErrorListResponseError, 'Unprocessable Entity (WebDAV)');
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(scheduledRenewalConfigurationResponse_js_1.scheduledRenewalConfigurationResponseSchema, requestOptions)];
});
});
};
/**
* Schedules a future lock-in date for the renewal.
*
* @param subscriptionId The Chargify id of the subscription.
* @param id The renewal id.
* @param body
* @return Response from the API call
*/
SubscriptionRenewalsController.prototype.scheduleScheduledRenewalLockIn = function (subscriptionId, id, 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({
subscriptionId: [subscriptionId, (0, schema_js_1.number)()],
id: [id, (0, schema_js_1.number)()],
body: [body, (0, schema_js_1.optional)(scheduledRenewalLockInRequest_js_1.scheduledRenewalLockInRequestSchema)],
});
req.header('Content-Type', 'application/json');
req.json(mapped.body);
req.appendTemplatePath(templateObject_5 || (templateObject_5 = tslib_1.__makeTemplateObject(["/subscriptions/", "/scheduled_renewals/", "/schedule_lock_in.json"], ["/subscriptions/", "/scheduled_renewals/", "/schedule_lock_in.json"])), mapped.subscriptionId, mapped.id);
req.throwOn(422, errorListResponseError_js_1.ErrorListResponseError, 'Unprocessable Entity (WebDAV)');
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(scheduledRenewalConfigurationResponse_js_1.scheduledRenewalConfigurationResponseSchema, requestOptions)];
});
});
};
/**
* Locks in the renewal immediately.
*
* @param subscriptionId The Chargify id of the subscription.
* @param id The renewal id.
* @return Response from the API call
*/
SubscriptionRenewalsController.prototype.lockInScheduledRenewalImmediately = function (subscriptionId, 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('PUT');
mapped = req.prepareArgs({
subscriptionId: [subscriptionId, (0, schema_js_1.number)()],
id: [id, (0, schema_js_1.number)()],
});
req.appendTemplatePath(templateObject_6 || (templateObject_6 = tslib_1.__makeTemplateObject(["/subscriptions/", "/scheduled_renewals/", "/immediate_lock_in.json"], ["/subscriptions/", "/scheduled_renewals/", "/immediate_lock_in.json"])), mapped.subscriptionId, mapped.id);
req.throwOn(422, errorListResponseError_js_1.ErrorListResponseError, 'Unprocessable Entity (WebDAV)');
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(scheduledRenewalConfigurationResponse_js_1.scheduledRenewalConfigurationResponseSchema, requestOptions)];
});
});
};
/**
* Returns a scheduled renewal configuration to an editable state.
*
* @param subscriptionId The Chargify id of the subscription.
* @param id The renewal id.
* @return Response from the API call
*/
SubscriptionRenewalsController.prototype.unpublishScheduledRenewalConfiguration = function (subscriptionId, 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('PUT');
mapped = req.prepareArgs({
subscriptionId: [subscriptionId, (0, schema_js_1.number)()],
id: [id, (0, schema_js_1.number)()],
});
req.appendTemplatePath(templateObject_7 || (templateObject_7 = tslib_1.__makeTemplateObject(["/subscriptions/", "/scheduled_renewals/", "/unpublish.json"], ["/subscriptions/", "/scheduled_renewals/", "/unpublish.json"])), mapped.subscriptionId, mapped.id);
req.throwOn(422, errorListResponseError_js_1.ErrorListResponseError, 'Unprocessable Entity (WebDAV)');
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(scheduledRenewalConfigurationResponse_js_1.scheduledRenewalConfigurationResponseSchema, requestOptions)];
});
});
};
/**
* Cancels a scheduled renewal configuration.
*
* @param subscriptionId The Chargify id of the subscription.
* @param id The renewal id.
* @return Response from the API call
*/
SubscriptionRenewalsController.prototype.cancelScheduledRenewalConfiguration = function (subscriptionId, 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('PUT');
mapped = req.prepareArgs({
subscriptionId: [subscriptionId, (0, schema_js_1.number)()],
id: [id, (0, schema_js_1.number)()],
});
req.appendTemplatePath(templateObject_8 || (templateObject_8 = tslib_1.__makeTemplateObject(["/subscriptions/", "/scheduled_renewals/", "/cancel.json"], ["/subscriptions/", "/scheduled_renewals/", "/cancel.json"])), mapped.subscriptionId, mapped.id);
req.throwOn(422, errorListResponseError_js_1.ErrorListResponseError, 'Unprocessable Entity (WebDAV)');
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(scheduledRenewalConfigurationResponse_js_1.scheduledRenewalConfigurationResponseSchema, requestOptions)];
});
});
};
/**
* Adds product and component line items to the scheduled renewal.
*
* @param subscriptionId The Chargify id of
* the subscription.
* @param scheduledRenewalsConfigurationId The scheduled
* renewal
* configuration id.
* @param body
* @return Response from the API call
*/
SubscriptionRenewalsController.prototype.createScheduledRenewalConfigurationItem = function (subscriptionId, scheduledRenewalsConfigurationId, 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({
subscriptionId: [subscriptionId, (0, schema_js_1.number)()],
scheduledRenewalsConfigurationId: [
scheduledRenewalsConfigurationId,
(0, schema_js_1.number)(),
],
body: [body, (0, schema_js_1.optional)(scheduledRenewalConfigurationItemRequest_js_1.scheduledRenewalConfigurationItemRequestSchema)],
});
req.header('Content-Type', 'application/json');
req.json(mapped.body);
req.appendTemplatePath(templateObject_9 || (templateObject_9 = tslib_1.__makeTemplateObject(["/subscriptions/", "/scheduled_renewals/", "/configuration_items.json"], ["/subscriptions/", "/scheduled_renewals/", "/configuration_items.json"])), mapped.subscriptionId, mapped.scheduledRenewalsConfigurationId);
req.throwOn(422, errorListResponseError_js_1.ErrorListResponseError, 'Unprocessable Entity (WebDAV)');
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(scheduledRenewalConfigurationItemResponse_js_1.scheduledRenewalConfigurationItemResponseSchema, requestOptions)];
});
});
};
/**
* Updates an existing configuration item’s pricing and quantity.
*
* @param subscriptionId The Chargify id of the
* subscription.
* @param scheduledRenewalsConfigurationId The scheduled renewal
* configuration id.
* @param id The scheduled renewal
* configuration item id.
* @param body
* @return Response from the API call
*/
SubscriptionRenewalsController.prototype.updateScheduledRenewalConfigurationItem = function (subscriptionId, scheduledRenewalsConfigurationId, id, 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({
subscriptionId: [subscriptionId, (0, schema_js_1.number)()],
scheduledRenewalsConfigurationId: [
scheduledRenewalsConfigurationId,
(0, schema_js_1.number)(),
],
id: [id, (0, schema_js_1.number)()],
body: [body, (0, schema_js_1.optional)(scheduledRenewalUpdateRequest_js_1.scheduledRenewalUpdateRequestSchema)],
});
req.header('Content-Type', 'application/json');
req.json(mapped.body);
req.appendTemplatePath(templateObject_10 || (templateObject_10 = tslib_1.__makeTemplateObject(["/subscriptions/", "/scheduled_renewals/", "/configuration_items/", ".json"], ["/subscriptions/", "/scheduled_renewals/", "/configuration_items/", ".json"])), mapped.subscriptionId, mapped.scheduledRenewalsConfigurationId, mapped.id);
req.throwOn(422, errorListResponseError_js_1.ErrorListResponseError, 'Unprocessable Entity (WebDAV)');
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(scheduledRenewalConfigurationItemResponse_js_1.scheduledRenewalConfigurationItemResponseSchema, requestOptions)];
});
});
};
/**
* Removes an item from the pending renewal configuration.
*
* @param subscriptionId The Chargify id of the subscription.
* @param scheduledRenewalsConfigurationId The scheduled renewal configuration id.
* @param id The scheduled renewal configuration item id.
* @return Response from the API call
*/
SubscriptionRenewalsController.prototype.deleteScheduledRenewalConfigurationItem = function (subscriptionId, scheduledRenewalsConfigurationId, 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('DELETE');
mapped = req.prepareArgs({
subscriptionId: [subscriptionId, (0, schema_js_1.number)()],
scheduledRenewalsConfigurationId: [
scheduledRenewalsConfigurationId,
(0, schema_js_1.number)(),
],
id: [id, (0, schema_js_1.number)()],
});
req.appendTemplatePath(templateObject_11 || (templateObject_11 = tslib_1.__makeTemplateObject(["/subscriptions/", "/scheduled_renewals/", "/configuration_items/", ".json"], ["/subscriptions/", "/scheduled_renewals/", "/configuration_items/", ".json"])), mapped.subscriptionId, mapped.scheduledRenewalsConfigurationId, mapped.id);
req.throwOn(422, errorListResponseError_js_1.ErrorListResponseError, 'Unprocessable Entity (WebDAV)');
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.call(requestOptions)];
});
});
};
return SubscriptionRenewalsController;
}(baseController_js_1.BaseController));
exports.SubscriptionRenewalsController = SubscriptionRenewalsController;
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11;
//# sourceMappingURL=subscriptionRenewalsController.js.map