@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.
195 lines • 11.7 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.InsightsController = void 0;
var tslib_1 = require("tslib");
var core_js_1 = require("../core.js");
var direction_js_1 = require("../models/direction.js");
var listMrrFilter_js_1 = require("../models/listMrrFilter.js");
var listMRRResponse_js_1 = require("../models/listMRRResponse.js");
var mRRResponse_js_1 = require("../models/mRRResponse.js");
var siteSummary_js_1 = require("../models/siteSummary.js");
var sortingDirection_js_1 = require("../models/sortingDirection.js");
var subscriptionMRRResponse_js_1 = require("../models/subscriptionMRRResponse.js");
var schema_js_1 = require("../schema.js");
var baseController_js_1 = require("./baseController.js");
var subscriptionsMrrErrorResponseError_js_1 = require("../errors/subscriptionsMrrErrorResponseError.js");
var InsightsController = /** @class */ (function (_super) {
tslib_1.__extends(InsightsController, _super);
function InsightsController() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* The Stats API is a very basic view of some Site-level stats. This API call only answers with JSON
* responses. An XML version is not provided.
*
* ## Stats Documentation
*
* There currently is not a complimentary matching set of documentation that compliments this endpoint.
* However, each Site's dashboard will reflect the summary of information provided in the Stats
* response.
*
* ```
* https://subdomain.chargify.com/dashboard
* ```
*
* @return Response from the API call
*/
InsightsController.prototype.readSiteStats = function (requestOptions) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var req;
return tslib_1.__generator(this, function (_a) {
req = this.createRequest('GET', '/stats.json');
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(siteSummary_js_1.siteSummarySchema, requestOptions)];
});
});
};
/**
* This endpoint returns your site's current MRR, including plan and usage breakouts.
*
* @param atTime submit a timestamp in ISO8601 format to request MRR for a historic time
* @param subscriptionId submit the id of a subscription in order to limit results
* @return Response from the API call
* @deprecated
*/
InsightsController.prototype.readMrr = function (atTime, subscriptionId, 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', '/mrr.json');
mapped = req.prepareArgs({
atTime: [atTime, (0, schema_js_1.optional)((0, schema_js_1.string)())],
subscriptionId: [subscriptionId, (0, schema_js_1.optional)((0, schema_js_1.number)())],
});
req.query('at_time', mapped.atTime, core_js_1.commaPrefix);
req.query('subscription_id', mapped.subscriptionId, core_js_1.commaPrefix);
req.deprecated('InsightsController.readMrr');
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(mRRResponse_js_1.mRRResponseSchema, requestOptions)];
});
});
};
/**
* This endpoint returns your site's MRR movements.
*
* ## Understanding MRR movements
*
* This endpoint will aid in accessing your site's [MRR Report](https://maxio.zendesk.com/hc/en-
* us/articles/24285894587021-MRR-Analytics) data.
*
* Whenever a subscription event occurs that causes your site's MRR to change (such as a signup or
* upgrade), we record an MRR movement. These records are accessible via the MRR Movements endpoint.
*
* Each MRR Movement belongs to a subscription and contains a timestamp, category, and an amount.
* `line_items` represent the subscription's product configuration at the time of the movement.
*
* ### Plan & Usage Breakouts
*
* In the MRR Report UI, we support a setting to [include or exclude](https://maxio.zendesk.com/hc/en-
* us/articles/24285894587021-MRR-Analytics#displaying-component-based-metered-usage-in-mrr) usage
* revenue. In the MRR APIs, responses include `plan` and `usage` breakouts.
*
* Plan includes revenue from:
* * Products
* * Quantity-Based Components
* * On/Off Components
*
* Usage includes revenue from:
* * Metered Components
* * Prepaid Usage Components
*
* @param subscriptionId optionally filter results by 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 10. The maximum allowed values is 50; any per_page
* value over 50 will be changed to 50. Use in query `per_page=20`.
* @param direction Controls the order in which results are returned. Use in query
* `direction=asc`.
* @return Response from the API call
* @deprecated
*/
InsightsController.prototype.listMrrMovements = function (_a, requestOptions_1) {
return tslib_1.__awaiter(this, arguments, void 0, function (_b, requestOptions) {
var req, mapped;
var subscriptionId = _b.subscriptionId, page = _b.page, perPage = _b.perPage, direction = _b.direction;
return tslib_1.__generator(this, function (_c) {
req = this.createRequest('GET', '/mrr_movements.json');
mapped = req.prepareArgs({
subscriptionId: [subscriptionId, (0, schema_js_1.optional)((0, schema_js_1.number)())],
page: [page, (0, schema_js_1.optional)((0, schema_js_1.number)())],
perPage: [perPage, (0, schema_js_1.optional)((0, schema_js_1.number)())],
direction: [direction, (0, schema_js_1.optional)(sortingDirection_js_1.sortingDirectionSchema)],
});
req.query('subscription_id', mapped.subscriptionId, core_js_1.commaPrefix);
req.query('page', mapped.page, core_js_1.commaPrefix);
req.query('per_page', mapped.perPage, core_js_1.commaPrefix);
req.query('direction', mapped.direction, core_js_1.commaPrefix);
req.deprecated('InsightsController.listMrrMovements');
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(listMRRResponse_js_1.listMRRResponseSchema, requestOptions)];
});
});
};
/**
* This endpoint returns your site's current MRR, including plan and usage breakouts split per
* subscription.
*
* @param filter Filter to use for List MRR per subscription operation
* @param atTime Submit a timestamp in ISO8601 format to request MRR for a historic time.
* Use in query: `at_time=2022-01-10T10:00:00-05:00`.
* @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 direction Controls the order in which results are returned. Records are ordered by
* subscription_id in ascending order by default. Use in query
* `direction=desc`.
* @return Response from the API call
* @deprecated
*/
InsightsController.prototype.listMrrPerSubscription = function (_a, requestOptions_1) {
return tslib_1.__awaiter(this, arguments, void 0, function (_b, requestOptions) {
var req, mapped;
var filter = _b.filter, atTime = _b.atTime, page = _b.page, perPage = _b.perPage, direction = _b.direction;
return tslib_1.__generator(this, function (_c) {
req = this.createRequest('GET', '/subscriptions_mrr.json');
mapped = req.prepareArgs({
filter: [filter, (0, schema_js_1.optional)(listMrrFilter_js_1.listMrrFilterSchema)],
atTime: [atTime, (0, schema_js_1.optional)((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)())],
direction: [direction, (0, schema_js_1.optional)(direction_js_1.directionSchema)],
});
req.query('filter', mapped.filter, core_js_1.commaPrefix);
req.query('at_time', mapped.atTime, core_js_1.commaPrefix);
req.query('page', mapped.page, core_js_1.commaPrefix);
req.query('per_page', mapped.perPage, core_js_1.commaPrefix);
req.query('direction', mapped.direction, core_js_1.commaPrefix);
req.deprecated('InsightsController.listMrrPerSubscription');
req.throwOn(400, subscriptionsMrrErrorResponseError_js_1.SubscriptionsMrrErrorResponseError, true, "HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'.");
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(subscriptionMRRResponse_js_1.subscriptionMRRResponseSchema, requestOptions)];
});
});
};
return InsightsController;
}(baseController_js_1.BaseController));
exports.InsightsController = InsightsController;
//# sourceMappingURL=insightsController.js.map