@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.
53 lines • 2.59 kB
JavaScript
;
/**
* AdvancedBilling
*
* This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ).
*/
exports.__esModule = true;
exports.ReferralCodesController = void 0;
var tslib_1 = require("tslib");
var core_1 = require("../core");
var referralValidationResponse_1 = require("../models/referralValidationResponse");
var schema_1 = require("../schema");
var baseController_1 = require("./baseController");
var singleStringErrorResponseError_1 = require("../errors/singleStringErrorResponseError");
var ReferralCodesController = /** @class */ (function (_super) {
tslib_1.__extends(ReferralCodesController, _super);
function ReferralCodesController() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* Use this method to determine if the referral code is valid and applicable within your Site. This
* method is useful for validating referral codes that are entered by a customer.
*
* ## Referrals Documentation
*
* Full documentation on how to use the referrals feature in the Advanced Billing UI can be located
* [here](https://maxio.zendesk.com/hc/en-us/sections/24286965611405-Referrals).
*
* ## Server Response
*
* If the referral code is valid the status code will be `200` and the referral code will be returned.
* If the referral code is invalid, a `404` response will be returned.
*
* @param code The referral code you are trying to validate
* @return Response from the API call
*/
ReferralCodesController.prototype.validateReferralCode = function (code, 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', '/referral_codes/validate.json');
mapped = req.prepareArgs({ code: [code, (0, schema_1.string)()] });
req.query('code', mapped.code, core_1.commaPrefix);
req.throwOn(404, singleStringErrorResponseError_1.SingleStringErrorResponseError, true, 'Invalid referral code.');
req.authenticate([{ basicAuth: true }]);
return [2 /*return*/, req.callAsJson(referralValidationResponse_1.referralValidationResponseSchema, requestOptions)];
});
});
};
return ReferralCodesController;
}(baseController_1.BaseController));
exports.ReferralCodesController = ReferralCodesController;
//# sourceMappingURL=referralCodesController.js.map