@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.
167 lines • 10 kB
JavaScript
;
/**
* AdvancedBilling
*
* This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ).
*/
exports.__esModule = true;
exports.SubscriptionNotesController = void 0;
var tslib_1 = require("tslib");
var core_1 = require("../core");
var subscriptionNoteResponse_1 = require("../models/subscriptionNoteResponse");
var updateSubscriptionNoteRequest_1 = require("../models/updateSubscriptionNoteRequest");
var schema_1 = require("../schema");
var baseController_1 = require("./baseController");
var errorListResponseError_1 = require("../errors/errorListResponseError");
var SubscriptionNotesController = /** @class */ (function (_super) {
tslib_1.__extends(SubscriptionNotesController, _super);
function SubscriptionNotesController() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* Use the following method to create a note for a subscription.
*
* ## How to Use Subscription Notes
*
* Notes allow you to record information about a particular Subscription in a free text format.
*
* If you have structured data such as birth date, color, etc., consider using Metadata instead.
*
* Full documentation on how to use Notes in the Advanced Billing UI can be located [here](https:
* //maxio.zendesk.com/hc/en-us/articles/24251712214413-Subscription-Summary-Overview).
*
* @param subscriptionId The Chargify id of the subscription
* @param body
* @return Response from the API call
*/
SubscriptionNotesController.prototype.createSubscriptionNote = 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_1.number)()],
body: [body, (0, schema_1.optional)(updateSubscriptionNoteRequest_1.updateSubscriptionNoteRequestSchema)]
});
req.header('Content-Type', 'application/json');
req.json(mapped.body);
req.appendTemplatePath(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["/subscriptions/", "/notes.json"], ["/subscriptions/", "/notes.json"])), mapped.subscriptionId);
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(subscriptionNoteResponse_1.subscriptionNoteResponseSchema, requestOptions)];
});
});
};
/**
* Use this method to retrieve a list of Notes associated with a Subscription. The response will be an
* array of Notes.
*
* @param subscriptionId The Chargify id of the subscription
* @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`.
* @return Response from the API call
*/
SubscriptionNotesController.prototype.listSubscriptionNotes = function (_a, requestOptions) {
var subscriptionId = _a.subscriptionId, page = _a.page, perPage = _a.perPage;
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({
subscriptionId: [subscriptionId, (0, schema_1.number)()],
page: [page, (0, schema_1.optional)((0, schema_1.number)())],
perPage: [perPage, (0, schema_1.optional)((0, schema_1.number)())]
});
req.query('page', mapped.page, core_1.commaPrefix);
req.query('per_page', mapped.perPage, core_1.commaPrefix);
req.appendTemplatePath(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["/subscriptions/", "/notes.json"], ["/subscriptions/", "/notes.json"])), mapped.subscriptionId);
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((0, schema_1.array)(subscriptionNoteResponse_1.subscriptionNoteResponseSchema), requestOptions)];
});
});
};
/**
* Once you have obtained the ID of the note you wish to read, use this method to show a particular
* note attached to a subscription.
*
* @param subscriptionId The Chargify id of the subscription
* @param noteId The Advanced Billing id of the note
* @return Response from the API call
*/
SubscriptionNotesController.prototype.readSubscriptionNote = function (subscriptionId, noteId, 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_1.number)()],
noteId: [noteId, (0, schema_1.number)()]
});
req.appendTemplatePath(templateObject_3 || (templateObject_3 = tslib_1.__makeTemplateObject(["/subscriptions/", "/notes/", ".json"], ["/subscriptions/", "/notes/", ".json"])), mapped.subscriptionId, mapped.noteId);
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(subscriptionNoteResponse_1.subscriptionNoteResponseSchema, requestOptions)];
});
});
};
/**
* Use the following method to update a note for a Subscription.
*
* @param subscriptionId The Chargify id of the subscription
* @param noteId The Advanced Billing id of the note
* @param body
* @return Response from the API call
*/
SubscriptionNotesController.prototype.updateSubscriptionNote = function (subscriptionId, noteId, 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_1.number)()],
noteId: [noteId, (0, schema_1.number)()],
body: [body, (0, schema_1.optional)(updateSubscriptionNoteRequest_1.updateSubscriptionNoteRequestSchema)]
});
req.header('Content-Type', 'application/json');
req.json(mapped.body);
req.appendTemplatePath(templateObject_4 || (templateObject_4 = tslib_1.__makeTemplateObject(["/subscriptions/", "/notes/", ".json"], ["/subscriptions/", "/notes/", ".json"])), mapped.subscriptionId, mapped.noteId);
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(subscriptionNoteResponse_1.subscriptionNoteResponseSchema, requestOptions)];
});
});
};
/**
* Use the following method to delete a note for a Subscription.
*
* @param subscriptionId The Chargify id of the subscription
* @param noteId The Advanced Billing id of the note
* @return Response from the API call
*/
SubscriptionNotesController.prototype.deleteSubscriptionNote = function (subscriptionId, noteId, 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_1.number)()],
noteId: [noteId, (0, schema_1.number)()]
});
req.appendTemplatePath(templateObject_5 || (templateObject_5 = tslib_1.__makeTemplateObject(["/subscriptions/", "/notes/", ".json"], ["/subscriptions/", "/notes/", ".json"])), mapped.subscriptionId, mapped.noteId);
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.call(requestOptions)];
});
});
};
return SubscriptionNotesController;
}(baseController_1.BaseController));
exports.SubscriptionNotesController = SubscriptionNotesController;
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
//# sourceMappingURL=subscriptionNotesController.js.map