@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.
160 lines • 9.87 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.SubscriptionGroupStatusController = void 0;
var tslib_1 = require("tslib");
var cancelGroupedSubscriptionsRequest_js_1 = require("../models/cancelGroupedSubscriptionsRequest.js");
var reactivateSubscriptionGroupRequest_js_1 = require("../models/reactivateSubscriptionGroupRequest.js");
var reactivateSubscriptionGroupResponse_js_1 = require("../models/reactivateSubscriptionGroupResponse.js");
var schema_js_1 = require("../schema.js");
var baseController_js_1 = require("./baseController.js");
var errorListResponseError_js_1 = require("../errors/errorListResponseError.js");
var SubscriptionGroupStatusController = /** @class */ (function (_super) {
tslib_1.__extends(SubscriptionGroupStatusController, _super);
function SubscriptionGroupStatusController() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* Cancels all subscriptions within the specified group immediately. The group is identified by the
* `uid` that is passed in the URL. To successfully cancel the group, the primary subscription must be
* on automatic billing. The group members must be on automatic billing or prepaid.
*
* To cancel a subscription group while also charging for any unbilled usage on metered or prepaid
* components, the `charge_unbilled_usage=true` parameter must be included in the request.
*
* @param uid The uid of the subscription group
* @param body
* @return Response from the API call
*/
SubscriptionGroupStatusController.prototype.cancelSubscriptionsInGroup = 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)(cancelGroupedSubscriptionsRequest_js_1.cancelGroupedSubscriptionsRequestSchema)],
});
req.header('Content-Type', 'application/json');
req.json(mapped.body);
req.appendTemplatePath(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["/subscription_groups/", "/cancel.json"], ["/subscription_groups/", "/cancel.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.call(requestOptions)];
});
});
};
/**
* This endpoint will schedule all subscriptions within the specified group to be canceled at the end
* of their billing period. The group is identified by its uid passed in the URL.
*
* All subscriptions in the group must be on automatic billing in order to successfully cancel them,
* and the group must not be in a "past_due" state.
*
* @param uid The uid of the subscription group
* @return Response from the API call
*/
SubscriptionGroupStatusController.prototype.initiateDelayedCancellationForGroup = function (uid, 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)()] });
req.appendTemplatePath(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["/subscription_groups/", "/delayed_cancel.json"], ["/subscription_groups/", "/delayed_cancel.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.call(requestOptions)];
});
});
};
/**
* Removing the delayed cancellation on a subscription group will ensure that the subscriptions do not
* get canceled at the end of the period. The request will reset the `cancel_at_end_of_period` flag to
* false on each member in the group.
*
* @param uid The uid of the subscription group
* @return Response from the API call
*/
SubscriptionGroupStatusController.prototype.cancelDelayedCancellationForGroup = function (uid, 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({ uid: [uid, (0, schema_js_1.string)()] });
req.appendTemplatePath(templateObject_3 || (templateObject_3 = tslib_1.__makeTemplateObject(["/subscription_groups/", "/delayed_cancel.json"], ["/subscription_groups/", "/delayed_cancel.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.call(requestOptions)];
});
});
};
/**
* This endpoint will attempt to reactivate or resume a cancelled subscription group. Upon reactivation,
* any canceled invoices created after the beginning of the primary subscription's billing period will
* be reopened and payment will be attempted on them. If the subscription group is being reactivated
* (as opposed to resumed), new charges will also be assessed for the new billing period.
*
* Whether a subscription group is reactivated (a new billing period is created) or resumed (the
* current billing period is respected) will depend on the parameters that are sent with the request as
* well as the date of the request relative to the primary subscription's period.
*
* ## Reactivating within the current period
*
* If a subscription group is cancelled and reactivated within the primary subscription's current
* period, we can choose to either start a new billing period or maintain the existing one. If we want
* to maintain the existing billing period the `resume=true` option must be passed in request
* parameters.
*
* An exception to the above are subscriptions that are on calendar billing. These subscriptions cannot
* be reactivated within the current period. If the `resume=true` option is not passed the request will
* return an error.
*
* The `resume_members` option is ignored in this case. All eligible group members will be
* automatically resumed.
*
*
* ## Reactivating beyond the current period
*
* In this case, a subscription group can only be reactivated with a new billing period. If the
* `resume=true` option is passed it will be ignored.
*
* Member subscriptions can have billing periods that are longer than the primary (e.g. a monthly
* primary with annual group members). If the primary subscription in a group cannot be reactivated
* within the current period, but other group members can be, passing `resume_members=true` will resume
* the existing billing period for eligible group members. The primary subscription will begin a new
* billing period.
*
* For calendar billing subscriptions, the new billing period created will be a partial one, spanning
* from the date of reactivation to the next corresponding calendar renewal date.
*
* @param uid The uid of the subscription group
* @param body
* @return Response from the API call
*/
SubscriptionGroupStatusController.prototype.reactivateSubscriptionGroup = 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)(reactivateSubscriptionGroupRequest_js_1.reactivateSubscriptionGroupRequestSchema)],
});
req.header('Content-Type', 'application/json');
req.json(mapped.body);
req.appendTemplatePath(templateObject_4 || (templateObject_4 = tslib_1.__makeTemplateObject(["/subscription_groups/", "/reactivate.json"], ["/subscription_groups/", "/reactivate.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(reactivateSubscriptionGroupResponse_js_1.reactivateSubscriptionGroupResponseSchema, requestOptions)];
});
});
};
return SubscriptionGroupStatusController;
}(baseController_js_1.BaseController));
exports.SubscriptionGroupStatusController = SubscriptionGroupStatusController;
var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
//# sourceMappingURL=subscriptionGroupStatusController.js.map