// 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("VisitorsClient", () => {
    test("find (1)", async () => {
        const server = mockServerPool.createServer();
        const client = new IntercomClient({
            maxRetries: 0,
            token: "test",
            version: "2.14",
            environment: server.baseUrl,
        });

        const rawResponseBody = {
            type: "visitor",
            id: "6762f3101bb69f9f2193bc64",
            user_id: "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3",
            anonymous: true,
            email: "",
            phone: "555-555-5555",
            name: "Jane Doe",
            pseudonym: "Red Duck from Dublin",
            avatar: { type: "avatar", image_url: "https://example.com/avatar.png" },
            app_id: "this_is_an_id722_that_should_be_at_least_",
            companies: {
                type: "company.list",
                companies: [
                    {
                        id: "531ee472cce572a6ec000006",
                        name: "Blue Sun",
                        app_id: "ecahpwf5",
                        company_id: "6",
                        remote_created_at: 1663597223,
                        created_at: 1663597223,
                        updated_at: 1663597223,
                        last_request_at: 1663597223,
                        size: 100,
                        website: "https://www.intercom.com",
                        industry: "Software",
                        monthly_spend: 100,
                        session_count: 100,
                        user_count: 100,
                        custom_attributes: { paid_subscriber: true, monthly_spend: 155.5, team_mates: 9 },
                    },
                ],
            },
            location_data: {
                type: "location_data",
                city_name: "Dublin",
                continent_code: "EU",
                country_code: "IRL",
                country_name: "Ireland",
                postal_code: "D02 N960",
                region_name: "Leinster",
                timezone: "Europe/Dublin",
            },
            las_request_at: 1663597260,
            created_at: 1734538000,
            remote_created_at: 1734538000,
            signed_up_at: 1734538000,
            updated_at: 1734538000,
            session_count: 0,
            social_profiles: { type: "social_profile.list", social_profiles: ["social_profiles"] },
            owner_id: "5169261",
            unsubscribed_from_emails: false,
            marked_email_as_spam: false,
            has_hard_bounced: false,
            tags: { type: "tag.list", tags: [{ id: "8482", name: "tag_name" }] },
            segments: { type: "segment.list", segments: ["segments"] },
            custom_attributes: { key: "value" },
            referrer: "https://www.google.com/",
            utm_campaign: "intercom-link",
            utm_content: "banner",
            utm_medium: "email",
            utm_source: "Intercom",
            utm_term: "messenger",
            do_not_track: false,
        };
        server.mockEndpoint().get("/visitors").respondWith().statusCode(200).jsonBody(rawResponseBody).build();

        const response = await client.visitors.find({
            user_id: "user_id",
        });
        expect(response).toEqual({
            type: "visitor",
            id: "6762f3101bb69f9f2193bc64",
            user_id: "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3",
            anonymous: true,
            email: "",
            phone: "555-555-5555",
            name: "Jane Doe",
            pseudonym: "Red Duck from Dublin",
            avatar: {
                type: "avatar",
                image_url: "https://example.com/avatar.png",
            },
            app_id: "this_is_an_id722_that_should_be_at_least_",
            companies: {
                type: "company.list",
                companies: [
                    {
                        id: "531ee472cce572a6ec000006",
                        name: "Blue Sun",
                        app_id: "ecahpwf5",
                        company_id: "6",
                        remote_created_at: 1663597223,
                        created_at: 1663597223,
                        updated_at: 1663597223,
                        last_request_at: 1663597223,
                        size: 100,
                        website: "https://www.intercom.com",
                        industry: "Software",
                        monthly_spend: 100,
                        session_count: 100,
                        user_count: 100,
                        custom_attributes: {
                            paid_subscriber: true,
                            monthly_spend: 155.5,
                            team_mates: 9,
                        },
                    },
                ],
            },
            location_data: {
                type: "location_data",
                city_name: "Dublin",
                continent_code: "EU",
                country_code: "IRL",
                country_name: "Ireland",
                postal_code: "D02 N960",
                region_name: "Leinster",
                timezone: "Europe/Dublin",
            },
            las_request_at: 1663597260,
            created_at: 1734538000,
            remote_created_at: 1734538000,
            signed_up_at: 1734538000,
            updated_at: 1734538000,
            session_count: 0,
            social_profiles: {
                type: "social_profile.list",
                social_profiles: ["social_profiles"],
            },
            owner_id: "5169261",
            unsubscribed_from_emails: false,
            marked_email_as_spam: false,
            has_hard_bounced: false,
            tags: {
                type: "tag.list",
                tags: [
                    {
                        id: "8482",
                        name: "tag_name",
                    },
                ],
            },
            segments: {
                type: "segment.list",
                segments: ["segments"],
            },
            custom_attributes: {
                key: "value",
            },
            referrer: "https://www.google.com/",
            utm_campaign: "intercom-link",
            utm_content: "banner",
            utm_medium: "email",
            utm_source: "Intercom",
            utm_term: "messenger",
            do_not_track: false,
        });
    });

    test("find (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("/visitors").respondWith().statusCode(401).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.visitors.find({
                user_id: "user_id",
            });
        }).rejects.toThrow(Intercom.UnauthorizedError);
    });

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

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/visitors").respondWith().statusCode(404).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.visitors.find({
                user_id: "user_id",
            });
        }).rejects.toThrow(Intercom.NotFoundError);
    });

    test("update (1)", async () => {
        const server = mockServerPool.createServer();
        const client = new IntercomClient({
            maxRetries: 0,
            token: "test",
            version: "2.14",
            environment: server.baseUrl,
        });
        const rawRequestBody = { id: "6762f30c1bb69f9f2193bc5e", name: "Gareth Bale" };
        const rawResponseBody = {
            type: "visitor",
            id: "6762f30c1bb69f9f2193bc5e",
            user_id: "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3",
            anonymous: true,
            email: "",
            phone: "555-555-5555",
            name: "Gareth Bale",
            pseudonym: "Violet Suitcase",
            avatar: {
                type: "avatar",
                image_url: "https://static.intercomassets.com/app/pseudonym_avatars_2019/violet-suitcase.png",
            },
            app_id: "this_is_an_id716_that_should_be_at_least_",
            companies: {
                type: "company.list",
                companies: [
                    {
                        id: "531ee472cce572a6ec000006",
                        name: "Blue Sun",
                        app_id: "ecahpwf5",
                        company_id: "6",
                        remote_created_at: 1663597223,
                        created_at: 1663597223,
                        updated_at: 1663597223,
                        last_request_at: 1663597223,
                        size: 100,
                        website: "https://www.intercom.com",
                        industry: "Software",
                        monthly_spend: 100,
                        session_count: 100,
                        user_count: 100,
                        custom_attributes: { paid_subscriber: true, monthly_spend: 155.5, team_mates: 9 },
                    },
                ],
            },
            location_data: {
                type: "location_data",
                city_name: "Dublin",
                continent_code: "EU",
                country_code: "IRL",
                country_name: "Ireland",
                postal_code: "D02 N960",
                region_name: "Leinster",
                timezone: "Europe/Dublin",
            },
            las_request_at: 1663597260,
            created_at: 1734537996,
            remote_created_at: 1734537996,
            signed_up_at: 1734537996,
            updated_at: 1734537997,
            session_count: 0,
            social_profiles: { type: "social_profile.list", social_profiles: ["social_profiles"] },
            owner_id: "5169261",
            unsubscribed_from_emails: false,
            marked_email_as_spam: false,
            has_hard_bounced: false,
            tags: { type: "tag.list", tags: [{ id: "8482", name: "tag_name" }] },
            segments: { type: "segment.list", segments: ["segments"] },
            custom_attributes: { key: "value" },
            referrer: "https://www.google.com/",
            utm_campaign: "intercom-link",
            utm_content: "banner",
            utm_medium: "email",
            utm_source: "Intercom",
            utm_term: "messenger",
            do_not_track: false,
        };
        server
            .mockEndpoint()
            .put("/visitors")
            .jsonBody(rawRequestBody)
            .respondWith()
            .statusCode(200)
            .jsonBody(rawResponseBody)
            .build();

        const response = await client.visitors.update({
            id: "6762f30c1bb69f9f2193bc5e",
            name: "Gareth Bale",
        });
        expect(response).toEqual({
            type: "visitor",
            id: "6762f30c1bb69f9f2193bc5e",
            user_id: "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3",
            anonymous: true,
            email: "",
            phone: "555-555-5555",
            name: "Gareth Bale",
            pseudonym: "Violet Suitcase",
            avatar: {
                type: "avatar",
                image_url: "https://static.intercomassets.com/app/pseudonym_avatars_2019/violet-suitcase.png",
            },
            app_id: "this_is_an_id716_that_should_be_at_least_",
            companies: {
                type: "company.list",
                companies: [
                    {
                        id: "531ee472cce572a6ec000006",
                        name: "Blue Sun",
                        app_id: "ecahpwf5",
                        company_id: "6",
                        remote_created_at: 1663597223,
                        created_at: 1663597223,
                        updated_at: 1663597223,
                        last_request_at: 1663597223,
                        size: 100,
                        website: "https://www.intercom.com",
                        industry: "Software",
                        monthly_spend: 100,
                        session_count: 100,
                        user_count: 100,
                        custom_attributes: {
                            paid_subscriber: true,
                            monthly_spend: 155.5,
                            team_mates: 9,
                        },
                    },
                ],
            },
            location_data: {
                type: "location_data",
                city_name: "Dublin",
                continent_code: "EU",
                country_code: "IRL",
                country_name: "Ireland",
                postal_code: "D02 N960",
                region_name: "Leinster",
                timezone: "Europe/Dublin",
            },
            las_request_at: 1663597260,
            created_at: 1734537996,
            remote_created_at: 1734537996,
            signed_up_at: 1734537996,
            updated_at: 1734537997,
            session_count: 0,
            social_profiles: {
                type: "social_profile.list",
                social_profiles: ["social_profiles"],
            },
            owner_id: "5169261",
            unsubscribed_from_emails: false,
            marked_email_as_spam: false,
            has_hard_bounced: false,
            tags: {
                type: "tag.list",
                tags: [
                    {
                        id: "8482",
                        name: "tag_name",
                    },
                ],
            },
            segments: {
                type: "segment.list",
                segments: ["segments"],
            },
            custom_attributes: {
                key: "value",
            },
            referrer: "https://www.google.com/",
            utm_campaign: "intercom-link",
            utm_content: "banner",
            utm_medium: "email",
            utm_source: "Intercom",
            utm_term: "messenger",
            do_not_track: false,
        });
    });

    test("update (2)", async () => {
        const server = mockServerPool.createServer();
        const client = new IntercomClient({
            maxRetries: 0,
            token: "test",
            version: "2.14",
            environment: server.baseUrl,
        });
        const rawRequestBody = { user_id: "fail", name: "Christian Fail" };
        const rawResponseBody = {
            type: "visitor",
            id: "6762f30c1bb69f9f2193bc5e",
            user_id: "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3",
            anonymous: true,
            email: "",
            phone: "555-555-5555",
            name: "Gareth Bale",
            pseudonym: "Violet Suitcase",
            avatar: {
                type: "avatar",
                image_url: "https://static.intercomassets.com/app/pseudonym_avatars_2019/violet-suitcase.png",
            },
            app_id: "this_is_an_id716_that_should_be_at_least_",
            companies: {
                type: "company.list",
                companies: [
                    {
                        id: "531ee472cce572a6ec000006",
                        name: "Blue Sun",
                        app_id: "ecahpwf5",
                        company_id: "6",
                        remote_created_at: 1663597223,
                        created_at: 1663597223,
                        updated_at: 1663597223,
                        last_request_at: 1663597223,
                        size: 100,
                        website: "https://www.intercom.com",
                        industry: "Software",
                        monthly_spend: 100,
                        session_count: 100,
                        user_count: 100,
                        custom_attributes: { paid_subscriber: true, monthly_spend: 155.5, team_mates: 9 },
                    },
                ],
            },
            location_data: {
                type: "location_data",
                city_name: "Dublin",
                continent_code: "EU",
                country_code: "IRL",
                country_name: "Ireland",
                postal_code: "D02 N960",
                region_name: "Leinster",
                timezone: "Europe/Dublin",
            },
            las_request_at: 1663597260,
            created_at: 1734537996,
            remote_created_at: 1734537996,
            signed_up_at: 1734537996,
            updated_at: 1734537997,
            session_count: 0,
            social_profiles: { type: "social_profile.list", social_profiles: ["social_profiles"] },
            owner_id: "5169261",
            unsubscribed_from_emails: false,
            marked_email_as_spam: false,
            has_hard_bounced: false,
            tags: { type: "tag.list", tags: [{ id: "8482", name: "tag_name" }] },
            segments: { type: "segment.list", segments: ["segments"] },
            custom_attributes: { key: "value" },
            referrer: "https://www.google.com/",
            utm_campaign: "intercom-link",
            utm_content: "banner",
            utm_medium: "email",
            utm_source: "Intercom",
            utm_term: "messenger",
            do_not_track: false,
        };
        server
            .mockEndpoint()
            .put("/visitors")
            .jsonBody(rawRequestBody)
            .respondWith()
            .statusCode(200)
            .jsonBody(rawResponseBody)
            .build();

        const response = await client.visitors.update({
            user_id: "fail",
            name: "Christian Fail",
        });
        expect(response).toEqual({
            type: "visitor",
            id: "6762f30c1bb69f9f2193bc5e",
            user_id: "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3",
            anonymous: true,
            email: "",
            phone: "555-555-5555",
            name: "Gareth Bale",
            pseudonym: "Violet Suitcase",
            avatar: {
                type: "avatar",
                image_url: "https://static.intercomassets.com/app/pseudonym_avatars_2019/violet-suitcase.png",
            },
            app_id: "this_is_an_id716_that_should_be_at_least_",
            companies: {
                type: "company.list",
                companies: [
                    {
                        id: "531ee472cce572a6ec000006",
                        name: "Blue Sun",
                        app_id: "ecahpwf5",
                        company_id: "6",
                        remote_created_at: 1663597223,
                        created_at: 1663597223,
                        updated_at: 1663597223,
                        last_request_at: 1663597223,
                        size: 100,
                        website: "https://www.intercom.com",
                        industry: "Software",
                        monthly_spend: 100,
                        session_count: 100,
                        user_count: 100,
                        custom_attributes: {
                            paid_subscriber: true,
                            monthly_spend: 155.5,
                            team_mates: 9,
                        },
                    },
                ],
            },
            location_data: {
                type: "location_data",
                city_name: "Dublin",
                continent_code: "EU",
                country_code: "IRL",
                country_name: "Ireland",
                postal_code: "D02 N960",
                region_name: "Leinster",
                timezone: "Europe/Dublin",
            },
            las_request_at: 1663597260,
            created_at: 1734537996,
            remote_created_at: 1734537996,
            signed_up_at: 1734537996,
            updated_at: 1734537997,
            session_count: 0,
            social_profiles: {
                type: "social_profile.list",
                social_profiles: ["social_profiles"],
            },
            owner_id: "5169261",
            unsubscribed_from_emails: false,
            marked_email_as_spam: false,
            has_hard_bounced: false,
            tags: {
                type: "tag.list",
                tags: [
                    {
                        id: "8482",
                        name: "tag_name",
                    },
                ],
            },
            segments: {
                type: "segment.list",
                segments: ["segments"],
            },
            custom_attributes: {
                key: "value",
            },
            referrer: "https://www.google.com/",
            utm_campaign: "intercom-link",
            utm_content: "banner",
            utm_medium: "email",
            utm_source: "Intercom",
            utm_term: "messenger",
            do_not_track: false,
        });
    });

    test("update (3)", async () => {
        const server = mockServerPool.createServer();
        const client = new IntercomClient({
            maxRetries: 0,
            token: "test",
            version: "2.14",
            environment: server.baseUrl,
        });
        const rawRequestBody = { id: "id" };
        const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] };
        server
            .mockEndpoint()
            .put("/visitors")
            .jsonBody(rawRequestBody)
            .respondWith()
            .statusCode(401)
            .jsonBody(rawResponseBody)
            .build();

        await expect(async () => {
            return await client.visitors.update({
                id: "id",
            });
        }).rejects.toThrow(Intercom.UnauthorizedError);
    });

    test("update (4)", async () => {
        const server = mockServerPool.createServer();
        const client = new IntercomClient({
            maxRetries: 0,
            token: "test",
            version: "2.14",
            environment: server.baseUrl,
        });
        const rawRequestBody = { id: "id" };
        const rawResponseBody = { key: "value" };
        server
            .mockEndpoint()
            .put("/visitors")
            .jsonBody(rawRequestBody)
            .respondWith()
            .statusCode(404)
            .jsonBody(rawResponseBody)
            .build();

        await expect(async () => {
            return await client.visitors.update({
                id: "id",
            });
        }).rejects.toThrow(Intercom.NotFoundError);
    });

    test("mergeToContact (1)", async () => {
        const server = mockServerPool.createServer();
        const client = new IntercomClient({
            maxRetries: 0,
            token: "test",
            version: "2.14",
            environment: server.baseUrl,
        });
        const rawRequestBody = {
            type: "user",
            user: { id: "8a88a590-e1c3-41e2-a502-e0649dbf721c", email: "foo@bar.com" },
            visitor: { user_id: "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3" },
        };
        const rawResponseBody = {
            type: "contact",
            id: "6762f3141bb69f9f2193bc6b",
            external_id: "f3b87a2e09d514c6c2e79b9a",
            workspace_id: "this_is_an_id728_that_should_be_at_least_",
            role: "user",
            email: "foo@bar.com",
            email_domain: "example.com",
            phone: "+1123456789",
            name: "John Doe",
            owner_id: 123,
            has_hard_bounced: false,
            marked_email_as_spam: false,
            unsubscribed_from_emails: false,
            created_at: 1734538004,
            updated_at: 1734538005,
            signed_up_at: 1734538004,
            last_seen_at: 1571672154,
            last_replied_at: 1571672154,
            last_contacted_at: 1571672154,
            last_email_opened_at: 1571672154,
            last_email_clicked_at: 1571672154,
            language_override: "en",
            browser: "Chrome",
            browser_version: "80.0.3987.132",
            browser_language: "en-US",
            os: "Mac OS X",
            android_app_name: "Intercom",
            android_app_version: "5.0.0",
            android_device: "Pixel 3",
            android_os_version: "10",
            android_sdk_version: "28",
            android_last_seen_at: 1571672154,
            ios_app_name: "Intercom",
            ios_app_version: "5.0.0",
            ios_device: "iPhone 11",
            ios_os_version: "13.3.1",
            ios_sdk_version: "13.3.1",
            ios_last_seen_at: 1571672154,
            custom_attributes: { key: "value" },
            avatar: "https://example.org/128Wash.jpg",
            tags: {
                data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }],
                url: "/contacts/6762f3141bb69f9f2193bc6b/tags",
                total_count: 0,
                has_more: false,
            },
            notes: {
                data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }],
                url: "/contacts/6762f3141bb69f9f2193bc6b/notes",
                total_count: 0,
                has_more: false,
            },
            companies: {
                data: [{ id: "5ba682d23d7cf92bef87bfd4", url: "/companies/5ba682d23d7cf92bef87bfd4" }],
                url: "/contacts/6762f3141bb69f9f2193bc6b/companies",
                total_count: 0,
                has_more: false,
            },
            location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" },
            social_profiles: { data: [{ name: "Facebook", url: "http://twitter.com/th1sland" }] },
        };
        server
            .mockEndpoint()
            .post("/visitors/convert")
            .jsonBody(rawRequestBody)
            .respondWith()
            .statusCode(200)
            .jsonBody(rawResponseBody)
            .build();

        const response = await client.visitors.mergeToContact({
            type: "user",
            user: {
                id: "8a88a590-e1c3-41e2-a502-e0649dbf721c",
                email: "foo@bar.com",
            },
            visitor: {
                user_id: "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3",
            },
        });
        expect(response).toEqual({
            type: "contact",
            id: "6762f3141bb69f9f2193bc6b",
            external_id: "f3b87a2e09d514c6c2e79b9a",
            workspace_id: "this_is_an_id728_that_should_be_at_least_",
            role: "user",
            email: "foo@bar.com",
            email_domain: "example.com",
            phone: "+1123456789",
            name: "John Doe",
            owner_id: 123,
            has_hard_bounced: false,
            marked_email_as_spam: false,
            unsubscribed_from_emails: false,
            created_at: 1734538004,
            updated_at: 1734538005,
            signed_up_at: 1734538004,
            last_seen_at: 1571672154,
            last_replied_at: 1571672154,
            last_contacted_at: 1571672154,
            last_email_opened_at: 1571672154,
            last_email_clicked_at: 1571672154,
            language_override: "en",
            browser: "Chrome",
            browser_version: "80.0.3987.132",
            browser_language: "en-US",
            os: "Mac OS X",
            android_app_name: "Intercom",
            android_app_version: "5.0.0",
            android_device: "Pixel 3",
            android_os_version: "10",
            android_sdk_version: "28",
            android_last_seen_at: 1571672154,
            ios_app_name: "Intercom",
            ios_app_version: "5.0.0",
            ios_device: "iPhone 11",
            ios_os_version: "13.3.1",
            ios_sdk_version: "13.3.1",
            ios_last_seen_at: 1571672154,
            custom_attributes: {
                key: "value",
            },
            avatar: "https://example.org/128Wash.jpg",
            tags: {
                data: [
                    {
                        type: "note",
                        id: "123",
                        url: "/contacts/5ba682d23d7cf92bef87bfd4/notes",
                    },
                ],
                url: "/contacts/6762f3141bb69f9f2193bc6b/tags",
                total_count: 0,
                has_more: false,
            },
            notes: {
                data: [
                    {
                        type: "note",
                        id: "123",
                        url: "/contacts/5ba682d23d7cf92bef87bfd4/notes",
                    },
                ],
                url: "/contacts/6762f3141bb69f9f2193bc6b/notes",
                total_count: 0,
                has_more: false,
            },
            companies: {
                data: [
                    {
                        id: "5ba682d23d7cf92bef87bfd4",
                        url: "/companies/5ba682d23d7cf92bef87bfd4",
                    },
                ],
                url: "/contacts/6762f3141bb69f9f2193bc6b/companies",
                total_count: 0,
                has_more: false,
            },
            location: {
                type: "location",
                country: "Ireland",
                region: "Dublin",
                city: "Dublin",
            },
            social_profiles: {
                data: [
                    {
                        name: "Facebook",
                        url: "http://twitter.com/th1sland",
                    },
                ],
            },
        });
    });

    test("mergeToContact (2)", async () => {
        const server = mockServerPool.createServer();
        const client = new IntercomClient({
            maxRetries: 0,
            token: "test",
            version: "2.14",
            environment: server.baseUrl,
        });
        const rawRequestBody = { type: "type", user: { id: "id" }, visitor: { id: "id" } };
        const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] };
        server
            .mockEndpoint()
            .post("/visitors/convert")
            .jsonBody(rawRequestBody)
            .respondWith()
            .statusCode(401)
            .jsonBody(rawResponseBody)
            .build();

        await expect(async () => {
            return await client.visitors.mergeToContact({
                type: "type",
                user: {
                    id: "id",
                },
                visitor: {
                    id: "id",
                },
            });
        }).rejects.toThrow(Intercom.UnauthorizedError);
    });
});
