@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.
120 lines • 6.93 kB
JavaScript
/**
* AdvancedBilling
*
* This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ).
*/
import { commaPrefix } from '../core.js';
import { deductServiceCreditRequestSchema, } from '../models/deductServiceCreditRequest.js';
import { issueServiceCreditRequestSchema, } from '../models/issueServiceCreditRequest.js';
import { listPrepaymentsFilterSchema, } from '../models/listPrepaymentsFilter.js';
import { listSubscriptionGroupPrepaymentResponseSchema, } from '../models/listSubscriptionGroupPrepaymentResponse.js';
import { serviceCreditSchema } from '../models/serviceCredit.js';
import { serviceCreditResponseSchema, } from '../models/serviceCreditResponse.js';
import { subscriptionGroupPrepaymentRequestSchema, } from '../models/subscriptionGroupPrepaymentRequest.js';
import { subscriptionGroupPrepaymentResponseSchema, } from '../models/subscriptionGroupPrepaymentResponse.js';
import { number, optional, string } from '../schema.js';
import { BaseController } from './baseController.js';
import { ApiError } from '@apimatic/core';
import { ErrorListResponseError } from '../errors/errorListResponseError.js';
export class SubscriptionGroupInvoiceAccountController extends BaseController {
/**
* A prepayment can be added for a subscription group identified by the group's `uid`. This endpoint
* requires a `amount`, `details`, `method`, and `memo`. On success, the prepayment will be added to
* the group's prepayment balance.
*
* @param uid The uid of the subscription group
* @param body
* @return Response from the API call
*/
async createSubscriptionGroupPrepayment(uid, body, requestOptions) {
const req = this.createRequest('POST');
const mapped = req.prepareArgs({
uid: [uid, string()],
body: [body, optional(subscriptionGroupPrepaymentRequestSchema)],
});
req.header('Content-Type', 'application/json');
req.json(mapped.body);
req.appendTemplatePath `/subscription_groups/${mapped.uid}/prepayments.json`;
req.throwOn(422, ErrorListResponseError, true, "HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'.");
req.authenticate([{ basicAuth: true }]);
return req.callAsJson(subscriptionGroupPrepaymentResponseSchema, requestOptions);
}
/**
* This request will list a subscription group's prepayments.
*
* @param uid The uid of the subscription group
* @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 filter Filter to use for List Prepayments operations
* @return Response from the API call
*/
async listPrepaymentsForSubscriptionGroup({ uid, page, perPage, filter, }, requestOptions) {
const req = this.createRequest('GET');
const mapped = req.prepareArgs({
uid: [uid, string()],
page: [page, optional(number())],
perPage: [perPage, optional(number())],
filter: [filter, optional(listPrepaymentsFilterSchema)],
});
req.query('page', mapped.page, commaPrefix);
req.query('per_page', mapped.perPage, commaPrefix);
req.query('filter', mapped.filter, commaPrefix);
req.appendTemplatePath `/subscription_groups/${mapped.uid}/prepayments.json`;
req.throwOn(404, ApiError, true, "Not Found:'{$response.body}'");
req.authenticate([{ basicAuth: true }]);
return req.callAsJson(listSubscriptionGroupPrepaymentResponseSchema, requestOptions);
}
/**
* Credit can be issued for a subscription group identified by the group's `uid`. Credit will be added
* to the group in the amount specified in the request body. The credit will be applied to group member
* invoices as they are generated.
*
* @param uid The uid of the subscription group
* @param body
* @return Response from the API call
*/
async issueSubscriptionGroupServiceCredit(uid, body, requestOptions) {
const req = this.createRequest('POST');
const mapped = req.prepareArgs({
uid: [uid, string()],
body: [body, optional(issueServiceCreditRequestSchema)],
});
req.header('Content-Type', 'application/json');
req.json(mapped.body);
req.appendTemplatePath `/subscription_groups/${mapped.uid}/service_credits.json`;
req.throwOn(422, ErrorListResponseError, true, "HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'.");
req.authenticate([{ basicAuth: true }]);
return req.callAsJson(serviceCreditResponseSchema, requestOptions);
}
/**
* Credit can be deducted for a subscription group identified by the group's `uid`. Credit will be
* deducted from the group in the amount specified in the request body.
*
* @param uid The uid of the subscription group
* @param body
* @return Response from the API call
*/
async deductSubscriptionGroupServiceCredit(uid, body, requestOptions) {
const req = this.createRequest('POST');
const mapped = req.prepareArgs({
uid: [uid, string()],
body: [body, optional(deductServiceCreditRequestSchema)],
});
req.header('Content-Type', 'application/json');
req.json(mapped.body);
req.appendTemplatePath `/subscription_groups/${mapped.uid}/service_credit_deductions.json`;
req.throwOn(422, ErrorListResponseError, true, "HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'.");
req.authenticate([{ basicAuth: true }]);
return req.callAsJson(serviceCreditSchema, requestOptions);
}
}
//# sourceMappingURL=subscriptionGroupInvoiceAccountController.js.map