"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SrfaxApiClient = void 0;
const axios_1 = __importDefault(require("axios"));
class SrfaxApiClient {
    constructor({ baseUrl, accountId, password, }) {
        this.baseUrl = baseUrl;
        this.accountId = accountId;
        this.password = password;
        this.client = axios_1.default.create({
            baseURL: this.baseUrl,
            headers: {
                Accept: 'application/json',
                'Content-Type': 'application/x-www-form-urlencoded',
            },
            timeout: 30000,
        });
    }
    async retrieveFax({ faxDetailsId, direction, }) {
        const params = new URLSearchParams({
            action: 'Retrieve_Fax',
            access_id: this.accountId,
            access_pwd: this.password,
            sFaxDetailsID: faxDetailsId,
            sDirection: direction,
            sFaxFormat: 'PDF',
            sResponseFormat: 'JSON',
        });
        const { data } = await this.client.post('', params.toString());
        return { status: data === null || data === void 0 ? void 0 : data.Status, result: data === null || data === void 0 ? void 0 : data.Result, raw: data };
    }
    async getFaxInboxAll() {
        const params = new URLSearchParams({
            action: 'Get_Fax_Inbox',
            access_id: this.accountId,
            access_pwd: this.password,
            sPeriod: 'ALL',
            sResponseFormat: 'JSON',
        });
        const { data } = await this.client.post('', params.toString());
        return { status: data === null || data === void 0 ? void 0 : data.Status, result: data === null || data === void 0 ? void 0 : data.Result, raw: data };
    }
}
exports.SrfaxApiClient = SrfaxApiClient;
//# sourceMappingURL=client.js.map