"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.WestFaxApiClient = void 0;
const axios_1 = __importDefault(require("axios"));
const schema_1 = require("./schema");
class WestFaxApiClient {
    constructor({ baseUrl, username, password, productId, }) {
        this.credentials = {
            Username: username,
            Password: password,
            ProductId: productId,
        };
        this.client = axios_1.default.create({
            baseURL: baseUrl,
            headers: {},
        });
    }
    async testConnection() {
        const allData = {
            ...this.credentials,
            Cookies: false,
        };
        const formData = new URLSearchParams();
        Object.entries(allData).forEach(([key, value]) => {
            formData.append(key, String(value));
        });
        const response = await this.client.post(`/Security_Authenticate/JSON`, formData);
        return response;
    }
    async getFaxDocument(input) {
        const allData = schema_1.GetFaxDocumentInputSchema.parse({
            ...this.credentials,
            ...input,
        });
        const formData = new URLSearchParams();
        Object.entries(allData).forEach(([key, value]) => {
            if (typeof value === 'object') {
                formData.append(key, JSON.stringify(value));
            }
            else {
                formData.append(key, String(value));
            }
        });
        const response = await this.client.post(`/Fax_GetFaxDocuments/JSON`, formData);
        return response;
    }
}
exports.WestFaxApiClient = WestFaxApiClient;
//# sourceMappingURL=client.js.map