UNPKG

@mozaic-io/mozaic-sdk-node

Version:

The Mozaic Node SDK enables you to pay your creators easily via the Mozaic API.

148 lines (147 loc) 5.94 kB
"use strict"; /** * This module provides access to the rest of the Mozaic SDK. * Proceed to the main SDK in the {@link Mozaic} class for more information. * @module Mozaic SDK */ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Mozaic = exports.MozaicError = void 0; const packageInfo = __importStar(require("../package.json")); const https_1 = __importDefault(require("https")); const configuration_1 = require("./api/configuration"); const Invoices_1 = require("./resources/Invoices/Invoices"); const PaymentCycles_1 = require("./resources/PaymentCycles/PaymentCycles"); const Permissions_1 = require("./resources/Permissions/Permissions"); const Wallets_1 = require("./resources/Wallets/Wallets"); const Contacts_1 = require("./resources/Contacts/Contacts"); const Payments_1 = require("./resources/Payments/Payments"); var MozaicError_1 = require("./resources/MozaicError"); Object.defineProperty(exports, "MozaicError", { enumerable: true, get: function () { return MozaicError_1.MozaicError; } }); // export { Invoices } from "./resources/Invoices/Invoices"; // export { PaymentCycles } from "./resources/PaymentCycles/PaymentCycles"; // export { Permissions } from "./resources/Permissions/Permissions"; // export { Wallets } from "./resources/Wallets/Wallets"; /** * This is the main entry point for the Mozaic SDK. You will need to obtain an API Key and * and endpoint to use this SDK. Please reach out to your Mozaic account representative to * get set up with system access. * * More information: [SDK Documentation](../documents/index.md) * * @category Mozaic SDK * @throws ApiException */ class Mozaic { /** * Creates an instance of the Mozaic SDK. * @param basePath - The base URL for the Mozaic API. */ constructor(basePath, apiKey) { this._sdks = {}; this._basePath = basePath; this._apiKey = apiKey; const httpsAgent = new https_1.default.Agent({ rejectUnauthorized: false, }); this._configuration = new configuration_1.Configuration({ basePath: basePath, apiKey: apiKey, baseOptions: { headers: { "x-sdk-version": packageInfo.version, }, httpsAgent: httpsAgent } }); } /** * Root resources are treated as singletons and should not keep state. * @param ctor The constructor pattern that each resource must implement. * @returns The one and only instance of the resource. */ getResource(ctor) { var _a; var _b, _c; return ((_a = (_b = this._sdks)[_c = ctor.name]) !== null && _a !== void 0 ? _a : (_b[_c] = new ctor(this, this._configuration))); } /** * The Contacts resource gives you access to the Contacts API so that you can create and manage contacts. * Contacts are used to represent the recipients of payments and senders of payments that you have received. * @group Resources */ get Contacts() { return this.getResource(Contacts_1.Contacts); } /** * The Invoices resource gives you access to the Invoices API so that you can download invoices related to * payments you have made, including payments for Payment Cycles. * @group Resources */ get Invoices() { return this.getResource(Invoices_1.Invoices); } /** * The Payments resource gives you access to the Payments API so that you can view payments. * * @group Resources */ get Payments() { return this.getResource(Payments_1.Payments); } /** * The PaymentCycles resource gives you access to the PaymentCycles API to create new payment cycles, * add entries to a payment cycle and finalize a payment cycle. You can also use this to retrieve and manage * payment cycles, invoices and payment cycle entries. * * @group Resources */ get PaymentCycles() { return this.getResource(PaymentCycles_1.PaymentCycles); } /** * The Permissions resource gives you access to the Permissions API to get UI visibility permissions for the * current Personal Access Token in use. * * @group Resources */ get Permissions() { return this.getResource(Permissions_1.Permissions); } /** * The Wallets resource gives you access to the Wallets API so that you can get payment and payout methods * from your wallets stored at Mozaic partners. Mozaic can then instruct a partner to move money using your * Wallet's tokens on your behalf. * * @group Resources */ get Wallets() { return this.getResource(Wallets_1.Wallets); } } exports.Mozaic = Mozaic;