UNPKG

@squadco/js

Version:

Simplify the integration process with Squad's comprehensive payment solutions using the Squad JavaScript SDK.

46 lines (45 loc) 1.78 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const axios_1 = __importDefault(require("axios")); /** * @desc * Squad JavaScript SDK * Built with ❣️ by Adedoyin Emmanuel Adeniyi https://github.com/adedoyin-emmanuel/ */ class SquadBaseClient { /** * @desc This creates a new instance of Squad JS SDK * @arg {string} publicKey - Squad public key * @arg {string} privateKey - Squad private key * @arg {string} environment - The environment to use for the client. If not specified, defaults to "development". */ constructor(publicKey, privateKey, environment) { /** * @desc * The environment to use for the client. If not specified, defaults to "development". */ this.environment = "development"; if (!publicKey || !privateKey) throw new Error("Public or Private keys are required!"); if (!this.environment) console.warn("No environment specified. Defaulting to development."); this.pubilcKey = publicKey; this.privateKey = privateKey; this.environment = environment || "development"; this.baseUrl = this.environment == "development" || this.environment == "test" ? "https://sandbox-api-d.squadco.com" : "https://api-d.squadco.com"; this.Axios = axios_1.default.create({ baseURL: this.baseUrl, headers: { Authorization: `Bearer ${this.privateKey}`, "Content-Type": "application/json", }, }); } } exports.default = SquadBaseClient;