omnisend-node-sdk
Version:
🔹 Typesafe Omnisend API SDK for Node.js
36 lines (35 loc) • 1.05 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.OmnisendCore = void 0;
const http_client_1 = require("./http-client");
class OmnisendCore {
constructor(options) {
this.apiKey = options.apiKey;
this.debug = options.debug === true;
this.log("Debugging is enabled");
// Set up httpclient
this.httpClient = new http_client_1.HttpClient({
safeMode: options.safeMode,
headers: {
"X-API-KEY": this.apiKey,
"User-Agent": "ajmnz/omnisend-node-sdk",
},
});
if (this.debug) {
this.httpClient.instance.interceptors.request.use((c) => {
this.log(`${c.method} ${c.url}`);
return c;
});
}
}
/**
* Logger for debug mode
*/
log(message) {
if (this.debug) {
// eslint-disable-next-line no-console
console.log(`[Omnisend] ${message}`);
}
}
}
exports.OmnisendCore = OmnisendCore;