"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FreshdeskApiClient = void 0;
const axios_1 = __importDefault(require("axios"));
class FreshdeskApiClient {
    constructor({ baseUrl, apiKey }) {
        /**
         * Freshdesk uses Basic Auth with the API key as the username and a placeholder as the password.
         */
        const passwordPlaceholder = 'X';
        const token = Buffer.from(`${apiKey}:${passwordPlaceholder}`).toString('base64');
        this.client = axios_1.default.create({
            baseURL: baseUrl,
            headers: {
                Authorization: `Basic ${token}`,
                'Content-Type': 'application/json',
            },
        });
    }
    async getContact(contactId) {
        const response = await this.client.get(`/contacts/${contactId}`);
        return response;
    }
    async getTicket(ticketId) {
        const response = await this.client.get(`/tickets/${ticketId}`);
        return response;
    }
    async updateTicket({ ticketId, input, }) {
        const response = await this.client.put(`/tickets/${ticketId}`, input);
        return response;
    }
    async addNote({ ticketId, input, }) {
        const response = await this.client.post(`/tickets/${ticketId}/notes`, input);
        return response;
    }
}
exports.FreshdeskApiClient = FreshdeskApiClient;
//# sourceMappingURL=client.js.map