"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.IterableClient = void 0;
const axios_1 = __importDefault(require("axios"));
class IterableBaseAPI {
    constructor({ baseUrl, apiKey }) {
        this.post = async (url, { body }) => {
            return await axios_1.default.post(`${this._baseUrl}/${url}`, body, {
                headers: this._headers,
            });
        };
        this.put = async (url, { body }) => {
            return await axios_1.default.put(`${this._baseUrl}/${url}`, body, {
                headers: this._headers,
            });
        };
        this.patch = async (url, { body }) => {
            return await axios_1.default.patch(`${this._baseUrl}/${url}`, body, {
                headers: this._headers,
            });
        };
        this.get = async (url) => {
            return await axios_1.default.get(`${this._baseUrl}/${url}`, {
                headers: this._headers,
            });
        };
        this.delete = async (url) => {
            return await axios_1.default.delete(`${this._baseUrl}/${url}`, {
                headers: this._headers,
            });
        };
        this._baseUrl = baseUrl;
        this._apiKey = apiKey;
        this._headers = {
            'Content-Type': 'application/json; charset=utf8',
            'Api-Key': this._apiKey,
        };
    }
}
class IterableEmailAPI {
    constructor({ apiKey }) {
        this.sendEmail = async (body) => {
            return await this._baseApi.post('target', {
                body,
            });
        };
        this._baseApi = new IterableBaseAPI({
            baseUrl: `https://api.iterable.com/api/email`,
            apiKey,
        });
    }
}
class IterableEventsAPI {
    constructor({ apiKey }) {
        this.trackEvent = async (body) => {
            return await this._baseApi.post('track', {
                body,
            });
        };
        this._baseApi = new IterableBaseAPI({
            baseUrl: `https://api.iterable.com/api/events`,
            apiKey,
        });
    }
}
class IterableClient {
    constructor({ apiKey }) {
        this.emailApi = new IterableEmailAPI({ apiKey });
        this.eventsApi = new IterableEventsAPI({ apiKey });
    }
}
exports.IterableClient = IterableClient;
//# sourceMappingURL=client.js.map