// This file was auto-generated by Fern from our API Definition.

import { IntercomClient } from "../../../src/Client";
import { mockServerPool } from "../../mock-server/MockServerPool";

describe("DataExportClient", () => {
    test("createDataExport", async () => {
        const server = mockServerPool.createServer();
        const client = new IntercomClient({
            maxRetries: 0,
            token: "test",
            version: "2.14",
            environment: server.baseUrl,
        });
        const rawRequestBody = { created_at_after: 1734519776, created_at_before: 1734537776 };
        const rawResponseBody = {
            job_identfier: "orzzsbd7hk67xyu",
            status: "pending",
            download_expires_at: "",
            download_url: "",
        };
        server
            .mockEndpoint()
            .post("/export/content/data")
            .jsonBody(rawRequestBody)
            .respondWith()
            .statusCode(200)
            .jsonBody(rawResponseBody)
            .build();

        const response = await client.unstable.dataExport.createDataExport({
            created_at_after: 1734519776,
            created_at_before: 1734537776,
        });
        expect(response).toEqual({
            job_identfier: "orzzsbd7hk67xyu",
            status: "pending",
            download_expires_at: "",
            download_url: "",
        });
    });

    test("getDataExport", async () => {
        const server = mockServerPool.createServer();
        const client = new IntercomClient({
            maxRetries: 0,
            token: "test",
            version: "2.14",
            environment: server.baseUrl,
        });

        const rawResponseBody = {
            job_identfier: "orzzsbd7hk67xyu",
            status: "pending",
            download_expires_at: "",
            download_url: "",
        };
        server
            .mockEndpoint()
            .get("/export/content/data/job_identifier")
            .respondWith()
            .statusCode(200)
            .jsonBody(rawResponseBody)
            .build();

        const response = await client.unstable.dataExport.getDataExport({
            job_identifier: "job_identifier",
        });
        expect(response).toEqual({
            job_identfier: "orzzsbd7hk67xyu",
            status: "pending",
            download_expires_at: "",
            download_url: "",
        });
    });

    test("cancelDataExport", async () => {
        const server = mockServerPool.createServer();
        const client = new IntercomClient({
            maxRetries: 0,
            token: "test",
            version: "2.14",
            environment: server.baseUrl,
        });

        const rawResponseBody = {
            job_identfier: "orzzsbd7hk67xyu",
            status: "canceled",
            download_expires_at: "",
            download_url: "",
        };
        server
            .mockEndpoint()
            .post("/export/cancel/job_identifier")
            .respondWith()
            .statusCode(200)
            .jsonBody(rawResponseBody)
            .build();

        const response = await client.unstable.dataExport.cancelDataExport({
            job_identifier: "job_identifier",
        });
        expect(response).toEqual({
            job_identfier: "orzzsbd7hk67xyu",
            status: "canceled",
            download_expires_at: "",
            download_url: "",
        });
    });

    test("downloadDataExport", async () => {
        const server = mockServerPool.createServer();
        const client = new IntercomClient({
            maxRetries: 0,
            token: "test",
            version: "2.14",
            environment: server.baseUrl,
        });

        server.mockEndpoint().get("/download/content/data/job_identifier").respondWith().statusCode(200).build();

        const response = await client.unstable.dataExport.downloadDataExport({
            job_identifier: "job_identifier",
        });
        expect(response).toEqual(undefined);
    });
});
