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

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

describe("FilesClient", () => {
    test("list", async () => {
        const server = mockServerPool.createServer();
        const client = new VapiClient({ maxRetries: 0, token: "test", environment: server.baseUrl });

        const rawResponseBody = [
            {
                object: "file",
                status: "processing",
                name: "name",
                originalName: "originalName",
                bytes: 1.1,
                purpose: "purpose",
                mimetype: "mimetype",
                key: "key",
                path: "path",
                bucket: "bucket",
                url: "url",
                parsedTextUrl: "parsedTextUrl",
                parsedTextBytes: 1.1,
                metadata: { key: "value" },
                id: "id",
                orgId: "orgId",
                createdAt: "2024-01-15T09:30:00Z",
                updatedAt: "2024-01-15T09:30:00Z",
            },
        ];

        server.mockEndpoint().get("/file").respondWith().statusCode(200).jsonBody(rawResponseBody).build();

        const response = await client.files.list();
        expect(response).toEqual([
            {
                object: "file",
                status: "processing",
                name: "name",
                originalName: "originalName",
                bytes: 1.1,
                purpose: "purpose",
                mimetype: "mimetype",
                key: "key",
                path: "path",
                bucket: "bucket",
                url: "url",
                parsedTextUrl: "parsedTextUrl",
                parsedTextBytes: 1.1,
                metadata: {
                    key: "value",
                },
                id: "id",
                orgId: "orgId",
                createdAt: "2024-01-15T09:30:00Z",
                updatedAt: "2024-01-15T09:30:00Z",
            },
        ]);
    });

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

        const rawResponseBody = {
            object: "file",
            status: "processing",
            name: "name",
            originalName: "originalName",
            bytes: 1.1,
            purpose: "purpose",
            mimetype: "mimetype",
            key: "key",
            path: "path",
            bucket: "bucket",
            url: "url",
            parsedTextUrl: "parsedTextUrl",
            parsedTextBytes: 1.1,
            metadata: { key: "value" },
            id: "id",
            orgId: "orgId",
            createdAt: "2024-01-15T09:30:00Z",
            updatedAt: "2024-01-15T09:30:00Z",
        };

        server.mockEndpoint().get("/file/id").respondWith().statusCode(200).jsonBody(rawResponseBody).build();

        const response = await client.files.get({
            id: "id",
        });
        expect(response).toEqual({
            object: "file",
            status: "processing",
            name: "name",
            originalName: "originalName",
            bytes: 1.1,
            purpose: "purpose",
            mimetype: "mimetype",
            key: "key",
            path: "path",
            bucket: "bucket",
            url: "url",
            parsedTextUrl: "parsedTextUrl",
            parsedTextBytes: 1.1,
            metadata: {
                key: "value",
            },
            id: "id",
            orgId: "orgId",
            createdAt: "2024-01-15T09:30:00Z",
            updatedAt: "2024-01-15T09:30:00Z",
        });
    });

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

        const rawResponseBody = {
            object: "file",
            status: "processing",
            name: "name",
            originalName: "originalName",
            bytes: 1.1,
            purpose: "purpose",
            mimetype: "mimetype",
            key: "key",
            path: "path",
            bucket: "bucket",
            url: "url",
            parsedTextUrl: "parsedTextUrl",
            parsedTextBytes: 1.1,
            metadata: { key: "value" },
            id: "id",
            orgId: "orgId",
            createdAt: "2024-01-15T09:30:00Z",
            updatedAt: "2024-01-15T09:30:00Z",
        };

        server.mockEndpoint().delete("/file/id").respondWith().statusCode(200).jsonBody(rawResponseBody).build();

        const response = await client.files.delete({
            id: "id",
        });
        expect(response).toEqual({
            object: "file",
            status: "processing",
            name: "name",
            originalName: "originalName",
            bytes: 1.1,
            purpose: "purpose",
            mimetype: "mimetype",
            key: "key",
            path: "path",
            bucket: "bucket",
            url: "url",
            parsedTextUrl: "parsedTextUrl",
            parsedTextBytes: 1.1,
            metadata: {
                key: "value",
            },
            id: "id",
            orgId: "orgId",
            createdAt: "2024-01-15T09:30:00Z",
            updatedAt: "2024-01-15T09:30:00Z",
        });
    });

    test("update", async () => {
        const server = mockServerPool.createServer();
        const client = new VapiClient({ maxRetries: 0, token: "test", environment: server.baseUrl });
        const rawRequestBody = {};
        const rawResponseBody = {
            object: "file",
            status: "processing",
            name: "name",
            originalName: "originalName",
            bytes: 1.1,
            purpose: "purpose",
            mimetype: "mimetype",
            key: "key",
            path: "path",
            bucket: "bucket",
            url: "url",
            parsedTextUrl: "parsedTextUrl",
            parsedTextBytes: 1.1,
            metadata: { key: "value" },
            id: "id",
            orgId: "orgId",
            createdAt: "2024-01-15T09:30:00Z",
            updatedAt: "2024-01-15T09:30:00Z",
        };

        server
            .mockEndpoint()
            .patch("/file/id")
            .jsonBody(rawRequestBody)
            .respondWith()
            .statusCode(200)
            .jsonBody(rawResponseBody)
            .build();

        const response = await client.files.update({
            id: "id",
        });
        expect(response).toEqual({
            object: "file",
            status: "processing",
            name: "name",
            originalName: "originalName",
            bytes: 1.1,
            purpose: "purpose",
            mimetype: "mimetype",
            key: "key",
            path: "path",
            bucket: "bucket",
            url: "url",
            parsedTextUrl: "parsedTextUrl",
            parsedTextBytes: 1.1,
            metadata: {
                key: "value",
            },
            id: "id",
            orgId: "orgId",
            createdAt: "2024-01-15T09:30:00Z",
            updatedAt: "2024-01-15T09:30:00Z",
        });
    });
});
