@mozaic-io/mozaic-sdk-node
Version:
The Mozaic Node SDK enables you to pay your creators easily via the Mozaic API.
54 lines (53 loc) • 2.23 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Invoices = void 0;
const api_1 = require("../../api");
const BaseResource_1 = require("../BaseResource");
/**
* @group Resources
*/
class Invoices extends BaseResource_1.BaseResource {
/**
* @internal
* You should not call this constructor directly. Instead, use the Mozaic main
* entry point to get access to the SDK classes.
* @param configuration
*/
constructor(mozaic, configuration) {
super();
this._mozaic = mozaic;
this._invoicesApi = new api_1.InvoicesApi(configuration);
}
/**
* Get the underlying API for direct calls to the Mozaic API.
*/
get InvoicesApi() {
return this._invoicesApi;
}
/**
*
* @param invoiceId Downloads an invoice by it's invoiceId. The invoiceId can be found on a payment cycle that
* has been completed as well as other areas of the Mozaic SDK.
*
* @returns an ArrayBuffer containing the bytes of an Invoice PDF. It can be saved using:
*
* ```fs.writeFileSync(fileName, Buffer.from(arrayBuffer));```
*/
getInvoice(invoiceId) {
return __awaiter(this, void 0, void 0, function* () {
const result = yield this.execute(() => this._invoicesApi.downloadInvoice(invoiceId, { responseType: "arraybuffer" }));
// There is a signature error in the generated proxy, this is a work-around for it.
return result;
});
}
}
exports.Invoices = Invoices;