@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.
191 lines • 10.5 kB
JavaScript
/**
* AdvancedBilling
*
* This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ).
*/
import { commaPrefix } from '../core.js';
import { batchJobResponseSchema, } from '../models/batchJobResponse.js';
import { invoiceSchema } from '../models/invoice.js';
import { proformaInvoiceSchema, } from '../models/proformaInvoice.js';
import { subscriptionSchema } from '../models/subscription.js';
import { array, number, optional, string } from '../schema.js';
import { BaseController } from './baseController.js';
import { ApiError } from '@apimatic/core';
import { SingleErrorResponseError } from '../errors/singleErrorResponseError.js';
export class APIExportsController extends BaseController {
/**
* This API returns an array of exported proforma invoices for a provided `batch_id`. Pay close
* attention to pagination in order to control responses from the server.
*
* Example: `GET https://{subdomain}.chargify.com/api_exports/proforma_invoices/123/rows?
* per_page=10000&page=1`.
*
* @param batchId Id of a Batch Job.
* @param perPage This parameter indicates how many records to fetch in each request. Default value is
* 100. The maximum allowed values is 10000; any per_page value over 10000 will be changed
* to 10000.
* @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`.
* @return Response from the API call
*/
async listExportedProformaInvoices({ batchId, perPage, page, }, requestOptions) {
const req = this.createRequest('GET');
const mapped = req.prepareArgs({
batchId: [batchId, string()],
perPage: [perPage, optional(number())],
page: [page, optional(number())],
});
req.query('per_page', mapped.perPage, commaPrefix);
req.query('page', mapped.page, commaPrefix);
req.appendTemplatePath `/api_exports/proforma_invoices/${mapped.batchId}/rows.json`;
req.throwOn(404, ApiError, true, "Not Found:'{$response.body}'");
req.authenticate([{ basicAuth: true }]);
return req.callAsJson(array(proformaInvoiceSchema), requestOptions);
}
/**
* This API returns an array of exported invoices for a provided `batch_id`. Pay close attention to
* pagination in order to control responses from the server.
*
* Example: `GET https://{subdomain}.chargify.com/api_exports/invoices/123/rows?per_page=10000&page=1`.
*
* @param batchId Id of a Batch Job.
* @param perPage This parameter indicates how many records to fetch in each request. Default value is
* 100. The maximum allowed values is 10000; any per_page value over 10000 will be changed
* to 10000.
* @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`.
* @return Response from the API call
*/
async listExportedInvoices({ batchId, perPage, page, }, requestOptions) {
const req = this.createRequest('GET');
const mapped = req.prepareArgs({
batchId: [batchId, string()],
perPage: [perPage, optional(number())],
page: [page, optional(number())],
});
req.query('per_page', mapped.perPage, commaPrefix);
req.query('page', mapped.page, commaPrefix);
req.appendTemplatePath `/api_exports/invoices/${mapped.batchId}/rows.json`;
req.throwOn(404, ApiError, true, "Not Found:'{$response.body}'");
req.authenticate([{ basicAuth: true }]);
return req.callAsJson(array(invoiceSchema), requestOptions);
}
/**
* This API returns an array of exported subscriptions for a provided `batch_id`. Pay close attention
* to pagination in order to control responses from the server.
*
* Example: `GET https://{subdomain}.chargify.com/api_exports/subscriptions/123/rows?
* per_page=200&page=1`.
*
* @param batchId Id of a Batch Job.
* @param perPage This parameter indicates how many records to fetch in each request. Default value is
* 100. The maximum allowed values is 10000; any per_page value over 10000 will be changed
* to 10000.
* @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`.
* @return Response from the API call
*/
async listExportedSubscriptions({ batchId, perPage, page, }, requestOptions) {
const req = this.createRequest('GET');
const mapped = req.prepareArgs({
batchId: [batchId, string()],
perPage: [perPage, optional(number())],
page: [page, optional(number())],
});
req.query('per_page', mapped.perPage, commaPrefix);
req.query('page', mapped.page, commaPrefix);
req.appendTemplatePath `/api_exports/subscriptions/${mapped.batchId}/rows.json`;
req.throwOn(404, ApiError, true, "Not Found:'{$response.body}'");
req.authenticate([{ basicAuth: true }]);
return req.callAsJson(array(subscriptionSchema), requestOptions);
}
/**
* This API creates a proforma invoices export and returns a batchjob object.
*
* It is only available for Relationship Invoicing architecture.
*
* @return Response from the API call
*/
async exportProformaInvoices(requestOptions) {
const req = this.createRequest('POST', '/api_exports/proforma_invoices.json');
req.throwOn(404, ApiError, true, "Not Found:'{$response.body}'");
req.throwOn(409, SingleErrorResponseError, true, "HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'.");
req.authenticate([{ basicAuth: true }]);
return req.callAsJson(batchJobResponseSchema, requestOptions);
}
/**
* This API creates an invoices export and returns a batchjob object.
*
* @return Response from the API call
*/
async exportInvoices(requestOptions) {
const req = this.createRequest('POST', '/api_exports/invoices.json');
req.throwOn(404, ApiError, true, "Not Found:'{$response.body}'");
req.throwOn(409, SingleErrorResponseError, true, "HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'.");
req.authenticate([{ basicAuth: true }]);
return req.callAsJson(batchJobResponseSchema, requestOptions);
}
/**
* This API creates a subscriptions export and returns a batchjob object.
*
* @return Response from the API call
*/
async exportSubscriptions(requestOptions) {
const req = this.createRequest('POST', '/api_exports/subscriptions.json');
req.throwOn(409, SingleErrorResponseError, true, "HTTP Response Not OK. Status code: {$statusCode}. Response: '{$response.body}'.");
req.authenticate([{ basicAuth: true }]);
return req.callAsJson(batchJobResponseSchema, requestOptions);
}
/**
* This API returns a batchjob object for proforma invoices export.
*
* @param batchId Id of a Batch Job.
* @return Response from the API call
*/
async readProformaInvoicesExport(batchId, requestOptions) {
const req = this.createRequest('GET');
const mapped = req.prepareArgs({ batchId: [batchId, string()] });
req.appendTemplatePath `/api_exports/proforma_invoices/${mapped.batchId}.json`;
req.throwOn(404, ApiError, true, "Not Found:'{$response.body}'");
req.authenticate([{ basicAuth: true }]);
return req.callAsJson(batchJobResponseSchema, requestOptions);
}
/**
* This API returns a batchjob object for invoices export.
*
* @param batchId Id of a Batch Job.
* @return Response from the API call
*/
async readInvoicesExport(batchId, requestOptions) {
const req = this.createRequest('GET');
const mapped = req.prepareArgs({ batchId: [batchId, string()] });
req.appendTemplatePath `/api_exports/invoices/${mapped.batchId}.json`;
req.throwOn(404, ApiError, true, "Not Found:'{$response.body}'");
req.authenticate([{ basicAuth: true }]);
return req.callAsJson(batchJobResponseSchema, requestOptions);
}
/**
* This API returns a batchjob object for subscriptions export.
*
* @param batchId Id of a Batch Job.
* @return Response from the API call
*/
async readSubscriptionsExport(batchId, requestOptions) {
const req = this.createRequest('GET');
const mapped = req.prepareArgs({ batchId: [batchId, string()] });
req.appendTemplatePath `/api_exports/subscriptions/${mapped.batchId}.json`;
req.throwOn(404, ApiError, true, "Not Found:'{$response.body}'");
req.authenticate([{ basicAuth: true }]);
return req.callAsJson(batchJobResponseSchema, requestOptions);
}
}
//# sourceMappingURL=aPIExportsController.js.map