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

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

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

        const rawResponseBody = {
            type: "list",
            data: [
                {
                    type: "ticket_state",
                    id: "8269",
                    category: "submitted",
                    internal_label: "Submitted",
                    external_label: "Submitted",
                    archived: false,
                    ticket_types: {
                        type: "list",
                        data: [
                            {
                                type: "ticket_type",
                                id: "55",
                                category: "Back-office",
                                name: "my-ticket-type-3",
                                description: "my ticket type description is awesome.",
                                icon: "🦁",
                                workspace_id: "ecahpwf5",
                                archived: false,
                            },
                            {
                                type: "ticket_type",
                                id: "56",
                                category: "Back-office",
                                name: "my-ticket-type-4",
                                description: "my ticket type description is awesome.",
                                icon: "🦁",
                                workspace_id: "ecahpwf5",
                                archived: false,
                            },
                            {
                                type: "ticket_type",
                                id: "58",
                                category: "Back-office",
                                name: "my-ticket-type-6",
                                description: "my ticket type description is awesome.",
                                icon: "🦁",
                                workspace_id: "ecahpwf5",
                                archived: false,
                            },
                        ],
                    },
                },
                {
                    type: "ticket_state",
                    id: "8270",
                    category: "in_progress",
                    internal_label: "In progress",
                    external_label: "In progress",
                    archived: false,
                    ticket_types: {
                        type: "list",
                        data: [
                            {
                                type: "ticket_type",
                                id: "55",
                                category: "Back-office",
                                name: "my-ticket-type-3",
                                description: "my ticket type description is awesome.",
                                icon: "🦁",
                                workspace_id: "ecahpwf5",
                                archived: false,
                            },
                            {
                                type: "ticket_type",
                                id: "56",
                                category: "Back-office",
                                name: "my-ticket-type-4",
                                description: "my ticket type description is awesome.",
                                icon: "🦁",
                                workspace_id: "ecahpwf5",
                                archived: false,
                            },
                            {
                                type: "ticket_type",
                                id: "58",
                                category: "Back-office",
                                name: "my-ticket-type-6",
                                description: "my ticket type description is awesome.",
                                icon: "🦁",
                                workspace_id: "ecahpwf5",
                                archived: false,
                            },
                        ],
                    },
                },
                {
                    type: "ticket_state",
                    id: "8271",
                    category: "waiting_on_customer",
                    internal_label: "Waiting on customer",
                    external_label: "Waiting on you",
                    archived: false,
                    ticket_types: {
                        type: "list",
                        data: [
                            {
                                type: "ticket_type",
                                id: "55",
                                category: "Back-office",
                                name: "my-ticket-type-3",
                                description: "my ticket type description is awesome.",
                                icon: "🦁",
                                workspace_id: "ecahpwf5",
                                archived: false,
                            },
                            {
                                type: "ticket_type",
                                id: "56",
                                category: "Back-office",
                                name: "my-ticket-type-4",
                                description: "my ticket type description is awesome.",
                                icon: "🦁",
                                workspace_id: "ecahpwf5",
                                archived: false,
                            },
                            {
                                type: "ticket_type",
                                id: "58",
                                category: "Back-office",
                                name: "my-ticket-type-6",
                                description: "my ticket type description is awesome.",
                                icon: "🦁",
                                workspace_id: "ecahpwf5",
                                archived: false,
                            },
                        ],
                    },
                },
                {
                    type: "ticket_state",
                    id: "8272",
                    category: "resolved",
                    internal_label: "Resolved",
                    external_label: "Resolved",
                    archived: false,
                    ticket_types: {
                        type: "list",
                        data: [
                            {
                                type: "ticket_type",
                                id: "55",
                                category: "Back-office",
                                name: "my-ticket-type-3",
                                description: "my ticket type description is awesome.",
                                icon: "🦁",
                                workspace_id: "ecahpwf5",
                                archived: false,
                            },
                            {
                                type: "ticket_type",
                                id: "56",
                                category: "Back-office",
                                name: "my-ticket-type-4",
                                description: "my ticket type description is awesome.",
                                icon: "🦁",
                                workspace_id: "ecahpwf5",
                                archived: false,
                            },
                            {
                                type: "ticket_type",
                                id: "58",
                                category: "Back-office",
                                name: "my-ticket-type-6",
                                description: "my ticket type description is awesome.",
                                icon: "🦁",
                                workspace_id: "ecahpwf5",
                                archived: false,
                            },
                        ],
                    },
                },
                {
                    type: "ticket_state",
                    id: "8273",
                    category: "submitted",
                    internal_label: "Admin label 1",
                    external_label: "User label",
                    archived: false,
                    ticket_types: {
                        type: "list",
                        data: [
                            {
                                type: "ticket_type",
                                id: "55",
                                category: "Back-office",
                                name: "my-ticket-type-3",
                                description: "my ticket type description is awesome.",
                                icon: "🦁",
                                workspace_id: "ecahpwf5",
                                archived: false,
                            },
                            {
                                type: "ticket_type",
                                id: "56",
                                category: "Back-office",
                                name: "my-ticket-type-4",
                                description: "my ticket type description is awesome.",
                                icon: "🦁",
                                workspace_id: "ecahpwf5",
                                archived: false,
                            },
                        ],
                    },
                },
                {
                    type: "ticket_state",
                    id: "8274",
                    category: "submitted",
                    internal_label: "Admin label 2",
                    external_label: "User label",
                    archived: false,
                    ticket_types: {
                        type: "list",
                        data: [
                            {
                                type: "ticket_type",
                                id: "58",
                                category: "Back-office",
                                name: "my-ticket-type-6",
                                description: "my ticket type description is awesome.",
                                icon: "🦁",
                                workspace_id: "ecahpwf5",
                                archived: false,
                            },
                        ],
                    },
                },
            ],
        };
        server.mockEndpoint().get("/ticket_states").respondWith().statusCode(200).jsonBody(rawResponseBody).build();

        const response = await client.ticketStates.listTicketStates();
        expect(response).toEqual({
            type: "list",
            data: [
                {
                    type: "ticket_state",
                    id: "8269",
                    category: "submitted",
                    internal_label: "Submitted",
                    external_label: "Submitted",
                    archived: false,
                    ticket_types: {
                        type: "list",
                        data: [
                            {
                                type: "ticket_type",
                                id: "55",
                                category: "Back-office",
                                name: "my-ticket-type-3",
                                description: "my ticket type description is awesome.",
                                icon: "\uD83E\uDD81",
                                workspace_id: "ecahpwf5",
                                archived: false,
                            },
                            {
                                type: "ticket_type",
                                id: "56",
                                category: "Back-office",
                                name: "my-ticket-type-4",
                                description: "my ticket type description is awesome.",
                                icon: "\uD83E\uDD81",
                                workspace_id: "ecahpwf5",
                                archived: false,
                            },
                            {
                                type: "ticket_type",
                                id: "58",
                                category: "Back-office",
                                name: "my-ticket-type-6",
                                description: "my ticket type description is awesome.",
                                icon: "\uD83E\uDD81",
                                workspace_id: "ecahpwf5",
                                archived: false,
                            },
                        ],
                    },
                },
                {
                    type: "ticket_state",
                    id: "8270",
                    category: "in_progress",
                    internal_label: "In progress",
                    external_label: "In progress",
                    archived: false,
                    ticket_types: {
                        type: "list",
                        data: [
                            {
                                type: "ticket_type",
                                id: "55",
                                category: "Back-office",
                                name: "my-ticket-type-3",
                                description: "my ticket type description is awesome.",
                                icon: "\uD83E\uDD81",
                                workspace_id: "ecahpwf5",
                                archived: false,
                            },
                            {
                                type: "ticket_type",
                                id: "56",
                                category: "Back-office",
                                name: "my-ticket-type-4",
                                description: "my ticket type description is awesome.",
                                icon: "\uD83E\uDD81",
                                workspace_id: "ecahpwf5",
                                archived: false,
                            },
                            {
                                type: "ticket_type",
                                id: "58",
                                category: "Back-office",
                                name: "my-ticket-type-6",
                                description: "my ticket type description is awesome.",
                                icon: "\uD83E\uDD81",
                                workspace_id: "ecahpwf5",
                                archived: false,
                            },
                        ],
                    },
                },
                {
                    type: "ticket_state",
                    id: "8271",
                    category: "waiting_on_customer",
                    internal_label: "Waiting on customer",
                    external_label: "Waiting on you",
                    archived: false,
                    ticket_types: {
                        type: "list",
                        data: [
                            {
                                type: "ticket_type",
                                id: "55",
                                category: "Back-office",
                                name: "my-ticket-type-3",
                                description: "my ticket type description is awesome.",
                                icon: "\uD83E\uDD81",
                                workspace_id: "ecahpwf5",
                                archived: false,
                            },
                            {
                                type: "ticket_type",
                                id: "56",
                                category: "Back-office",
                                name: "my-ticket-type-4",
                                description: "my ticket type description is awesome.",
                                icon: "\uD83E\uDD81",
                                workspace_id: "ecahpwf5",
                                archived: false,
                            },
                            {
                                type: "ticket_type",
                                id: "58",
                                category: "Back-office",
                                name: "my-ticket-type-6",
                                description: "my ticket type description is awesome.",
                                icon: "\uD83E\uDD81",
                                workspace_id: "ecahpwf5",
                                archived: false,
                            },
                        ],
                    },
                },
                {
                    type: "ticket_state",
                    id: "8272",
                    category: "resolved",
                    internal_label: "Resolved",
                    external_label: "Resolved",
                    archived: false,
                    ticket_types: {
                        type: "list",
                        data: [
                            {
                                type: "ticket_type",
                                id: "55",
                                category: "Back-office",
                                name: "my-ticket-type-3",
                                description: "my ticket type description is awesome.",
                                icon: "\uD83E\uDD81",
                                workspace_id: "ecahpwf5",
                                archived: false,
                            },
                            {
                                type: "ticket_type",
                                id: "56",
                                category: "Back-office",
                                name: "my-ticket-type-4",
                                description: "my ticket type description is awesome.",
                                icon: "\uD83E\uDD81",
                                workspace_id: "ecahpwf5",
                                archived: false,
                            },
                            {
                                type: "ticket_type",
                                id: "58",
                                category: "Back-office",
                                name: "my-ticket-type-6",
                                description: "my ticket type description is awesome.",
                                icon: "\uD83E\uDD81",
                                workspace_id: "ecahpwf5",
                                archived: false,
                            },
                        ],
                    },
                },
                {
                    type: "ticket_state",
                    id: "8273",
                    category: "submitted",
                    internal_label: "Admin label 1",
                    external_label: "User label",
                    archived: false,
                    ticket_types: {
                        type: "list",
                        data: [
                            {
                                type: "ticket_type",
                                id: "55",
                                category: "Back-office",
                                name: "my-ticket-type-3",
                                description: "my ticket type description is awesome.",
                                icon: "\uD83E\uDD81",
                                workspace_id: "ecahpwf5",
                                archived: false,
                            },
                            {
                                type: "ticket_type",
                                id: "56",
                                category: "Back-office",
                                name: "my-ticket-type-4",
                                description: "my ticket type description is awesome.",
                                icon: "\uD83E\uDD81",
                                workspace_id: "ecahpwf5",
                                archived: false,
                            },
                        ],
                    },
                },
                {
                    type: "ticket_state",
                    id: "8274",
                    category: "submitted",
                    internal_label: "Admin label 2",
                    external_label: "User label",
                    archived: false,
                    ticket_types: {
                        type: "list",
                        data: [
                            {
                                type: "ticket_type",
                                id: "58",
                                category: "Back-office",
                                name: "my-ticket-type-6",
                                description: "my ticket type description is awesome.",
                                icon: "\uD83E\uDD81",
                                workspace_id: "ecahpwf5",
                                archived: false,
                            },
                        ],
                    },
                },
            ],
        });
    });

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

        const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] };
        server.mockEndpoint().get("/ticket_states").respondWith().statusCode(401).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.ticketStates.listTicketStates();
        }).rejects.toThrow(Intercom.UnauthorizedError);
    });
});
