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

import * as Vapi from "../../src/api/index";
import { VapiClient } from "../../src/Client";
import { mockServerPool } from "../mock-server/MockServerPool";

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

        const rawResponseBody = {
            results: [
                {
                    id: "id",
                    orgId: "orgId",
                    createdAt: "2024-01-15T09:30:00Z",
                    updatedAt: "2024-01-15T09:30:00Z",
                    provider: "cartesia",
                    resourceName: "pronunciation-dictionary",
                    resourceId: "resourceId",
                    resource: { key: "value" },
                },
            ],
            metadata: {
                itemsPerPage: 1.1,
                totalItems: 1.1,
                currentPage: 1.1,
                itemsBeyondRetention: true,
                createdAtLe: "2024-01-15T09:30:00Z",
                createdAtGe: "2024-01-15T09:30:00Z",
            },
        };

        server
            .mockEndpoint()
            .get("/provider/cartesia/pronunciation-dictionary")
            .respondWith()
            .statusCode(200)
            .jsonBody(rawResponseBody)
            .build();

        const response = await client.providerResources.providerResourceControllerGetProviderResourcesPaginated({
            provider: "cartesia",
            resourceName: "pronunciation-dictionary",
        });
        expect(response).toEqual({
            results: [
                {
                    id: "id",
                    orgId: "orgId",
                    createdAt: "2024-01-15T09:30:00Z",
                    updatedAt: "2024-01-15T09:30:00Z",
                    provider: "cartesia",
                    resourceName: "pronunciation-dictionary",
                    resourceId: "resourceId",
                    resource: {
                        key: "value",
                    },
                },
            ],
            metadata: {
                itemsPerPage: 1.1,
                totalItems: 1.1,
                currentPage: 1.1,
                itemsBeyondRetention: true,
                createdAtLe: "2024-01-15T09:30:00Z",
                createdAtGe: "2024-01-15T09:30:00Z",
            },
        });
    });

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

        const rawResponseBody = {
            id: "id",
            orgId: "orgId",
            createdAt: "2024-01-15T09:30:00Z",
            updatedAt: "2024-01-15T09:30:00Z",
            provider: "cartesia",
            resourceName: "pronunciation-dictionary",
            resourceId: "resourceId",
            resource: { key: "value" },
        };

        server
            .mockEndpoint()
            .post("/provider/cartesia/pronunciation-dictionary")
            .respondWith()
            .statusCode(200)
            .jsonBody(rawResponseBody)
            .build();

        const response = await client.providerResources.providerResourceControllerCreateProviderResource({
            provider: "cartesia",
            resourceName: "pronunciation-dictionary",
        });
        expect(response).toEqual({
            id: "id",
            orgId: "orgId",
            createdAt: "2024-01-15T09:30:00Z",
            updatedAt: "2024-01-15T09:30:00Z",
            provider: "cartesia",
            resourceName: "pronunciation-dictionary",
            resourceId: "resourceId",
            resource: {
                key: "value",
            },
        });
    });

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

        const rawResponseBody = {
            id: "id",
            orgId: "orgId",
            createdAt: "2024-01-15T09:30:00Z",
            updatedAt: "2024-01-15T09:30:00Z",
            provider: "cartesia",
            resourceName: "pronunciation-dictionary",
            resourceId: "resourceId",
            resource: { key: "value" },
        };

        server
            .mockEndpoint()
            .get("/provider/cartesia/pronunciation-dictionary/id")
            .respondWith()
            .statusCode(200)
            .jsonBody(rawResponseBody)
            .build();

        const response = await client.providerResources.providerResourceControllerGetProviderResource({
            provider: "cartesia",
            resourceName: "pronunciation-dictionary",
            id: "id",
        });
        expect(response).toEqual({
            id: "id",
            orgId: "orgId",
            createdAt: "2024-01-15T09:30:00Z",
            updatedAt: "2024-01-15T09:30:00Z",
            provider: "cartesia",
            resourceName: "pronunciation-dictionary",
            resourceId: "resourceId",
            resource: {
                key: "value",
            },
        });
    });

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

        const rawResponseBody = { key: "value" };

        server
            .mockEndpoint()
            .get("/provider/cartesia/pronunciation-dictionary/id")
            .respondWith()
            .statusCode(404)
            .jsonBody(rawResponseBody)
            .build();

        await expect(async () => {
            return await client.providerResources.providerResourceControllerGetProviderResource({
                provider: "cartesia",
                resourceName: "pronunciation-dictionary",
                id: "id",
            });
        }).rejects.toThrow(Vapi.NotFoundError);
    });

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

        const rawResponseBody = {
            id: "id",
            orgId: "orgId",
            createdAt: "2024-01-15T09:30:00Z",
            updatedAt: "2024-01-15T09:30:00Z",
            provider: "cartesia",
            resourceName: "pronunciation-dictionary",
            resourceId: "resourceId",
            resource: { key: "value" },
        };

        server
            .mockEndpoint()
            .delete("/provider/cartesia/pronunciation-dictionary/id")
            .respondWith()
            .statusCode(200)
            .jsonBody(rawResponseBody)
            .build();

        const response = await client.providerResources.providerResourceControllerDeleteProviderResource({
            provider: "cartesia",
            resourceName: "pronunciation-dictionary",
            id: "id",
        });
        expect(response).toEqual({
            id: "id",
            orgId: "orgId",
            createdAt: "2024-01-15T09:30:00Z",
            updatedAt: "2024-01-15T09:30:00Z",
            provider: "cartesia",
            resourceName: "pronunciation-dictionary",
            resourceId: "resourceId",
            resource: {
                key: "value",
            },
        });
    });

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

        const rawResponseBody = { key: "value" };

        server
            .mockEndpoint()
            .delete("/provider/cartesia/pronunciation-dictionary/id")
            .respondWith()
            .statusCode(404)
            .jsonBody(rawResponseBody)
            .build();

        await expect(async () => {
            return await client.providerResources.providerResourceControllerDeleteProviderResource({
                provider: "cartesia",
                resourceName: "pronunciation-dictionary",
                id: "id",
            });
        }).rejects.toThrow(Vapi.NotFoundError);
    });

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

        const rawResponseBody = {
            id: "id",
            orgId: "orgId",
            createdAt: "2024-01-15T09:30:00Z",
            updatedAt: "2024-01-15T09:30:00Z",
            provider: "cartesia",
            resourceName: "pronunciation-dictionary",
            resourceId: "resourceId",
            resource: { key: "value" },
        };

        server
            .mockEndpoint()
            .patch("/provider/cartesia/pronunciation-dictionary/id")
            .respondWith()
            .statusCode(200)
            .jsonBody(rawResponseBody)
            .build();

        const response = await client.providerResources.providerResourceControllerUpdateProviderResource({
            provider: "cartesia",
            resourceName: "pronunciation-dictionary",
            id: "id",
        });
        expect(response).toEqual({
            id: "id",
            orgId: "orgId",
            createdAt: "2024-01-15T09:30:00Z",
            updatedAt: "2024-01-15T09:30:00Z",
            provider: "cartesia",
            resourceName: "pronunciation-dictionary",
            resourceId: "resourceId",
            resource: {
                key: "value",
            },
        });
    });

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

        const rawResponseBody = { key: "value" };

        server
            .mockEndpoint()
            .patch("/provider/cartesia/pronunciation-dictionary/id")
            .respondWith()
            .statusCode(404)
            .jsonBody(rawResponseBody)
            .build();

        await expect(async () => {
            return await client.providerResources.providerResourceControllerUpdateProviderResource({
                provider: "cartesia",
                resourceName: "pronunciation-dictionary",
                id: "id",
            });
        }).rejects.toThrow(Vapi.NotFoundError);
    });
});
