// 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("MacrosClient", () => {
    test("listMacros (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: "macro",
                    id: "123",
                    name: "Order Status Update",
                    body: '<p>Hi <attribute key="user.name" default="there"/>, your order #<attribute key="order.number"/> is ready for pickup!</p>',
                    body_text: 'Hi {{user.name|fallback:"there"}}, your order #{{order.number}} is ready for pickup!',
                    created_at: "2025-07-17T11:18:08Z",
                    updated_at: "2025-07-17T15:30:24Z",
                    visible_to: "everyone",
                    visible_to_team_ids: ["456", "789"],
                    available_on: ["inbox", "messenger"],
                },
                {
                    type: "macro",
                    id: "456",
                    name: "Welcome Message",
                    body: '<p>Welcome to our support! I\'m <attribute key="teammate.name"/>. How can I help you today?</p>',
                    body_text: "Welcome to our support! I'm {{teammate.name}}. How can I help you today?",
                    created_at: "2025-07-21T14:44:35Z",
                    updated_at: "2025-07-21T14:44:35Z",
                    visible_to: "specific_teams",
                    visible_to_team_ids: ["789", "101"],
                    available_on: ["inbox"],
                },
            ],
            pages: { type: "pages", per_page: 50, next: { starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd" } },
        };
        server.mockEndpoint().get("/macros").respondWith().statusCode(200).jsonBody(rawResponseBody).build();

        const response = await client.unstable.macros.listMacros({
            per_page: 1,
            starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd",
            updated_since: 1000000,
        });
        expect(response).toEqual({
            type: "list",
            data: [
                {
                    type: "macro",
                    id: "123",
                    name: "Order Status Update",
                    body: '<p>Hi <attribute key="user.name" default="there"/>, your order #<attribute key="order.number"/> is ready for pickup!</p>',
                    body_text: 'Hi {{user.name|fallback:"there"}}, your order #{{order.number}} is ready for pickup!',
                    created_at: "2025-07-17T11:18:08Z",
                    updated_at: "2025-07-17T15:30:24Z",
                    visible_to: "everyone",
                    visible_to_team_ids: ["456", "789"],
                    available_on: ["inbox", "messenger"],
                },
                {
                    type: "macro",
                    id: "456",
                    name: "Welcome Message",
                    body: '<p>Welcome to our support! I\'m <attribute key="teammate.name"/>. How can I help you today?</p>',
                    body_text: "Welcome to our support! I'm {{teammate.name}}. How can I help you today?",
                    created_at: "2025-07-21T14:44:35Z",
                    updated_at: "2025-07-21T14:44:35Z",
                    visible_to: "specific_teams",
                    visible_to_team_ids: ["789", "101"],
                    available_on: ["inbox"],
                },
            ],
            pages: {
                type: "pages",
                per_page: 50,
                next: {
                    starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd",
                },
            },
        });
    });

    test("listMacros (2)", 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: "macro",
                    id: "789",
                    name: "Refund Process",
                    body: '<p>I understand you\'d like a refund for order #<attribute key="conversation.custom_attributes.order_number"/>. The refund will be processed within 3-5 business days.</p>',
                    body_text:
                        "I understand you'd like a refund for order #{{conversation.custom_attributes.order_number}}. The refund will be processed within 3-5 business days.",
                    created_at: "2025-07-21T07:15:34Z",
                    updated_at: "2025-07-21T07:15:34Z",
                    visible_to: "everyone",
                    visible_to_team_ids: ["456", "789"],
                    available_on: ["inbox", "messenger"],
                },
                {
                    type: "macro",
                    id: "101",
                    name: "Product Inquiry Response",
                    body: '<p>Thank you for your interest in <attribute key="product.name" default="our products"/>. I\'d be happy to provide more information!</p>',
                    body_text:
                        'Thank you for your interest in {{product.name|fallback:"our products"}}. I\'d be happy to provide more information!',
                    created_at: "2025-07-20T05:33:20Z",
                    updated_at: "2025-07-21T10:00:00Z",
                    visible_to: "everyone",
                    visible_to_team_ids: ["456", "789"],
                    available_on: ["inbox", "messenger"],
                },
            ],
            pages: { type: "pages", per_page: 50, next: { starting_after: "WzE3MTk0MDAwMDAuMCwgIjEwMSJd" } },
        };
        server.mockEndpoint().get("/macros").respondWith().statusCode(200).jsonBody(rawResponseBody).build();

        const response = await client.unstable.macros.listMacros({
            per_page: 1,
            starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd",
            updated_since: 1000000,
        });
        expect(response).toEqual({
            type: "list",
            data: [
                {
                    type: "macro",
                    id: "789",
                    name: "Refund Process",
                    body: '<p>I understand you\'d like a refund for order #<attribute key="conversation.custom_attributes.order_number"/>. The refund will be processed within 3-5 business days.</p>',
                    body_text:
                        "I understand you'd like a refund for order #{{conversation.custom_attributes.order_number}}. The refund will be processed within 3-5 business days.",
                    created_at: "2025-07-21T07:15:34Z",
                    updated_at: "2025-07-21T07:15:34Z",
                    visible_to: "everyone",
                    visible_to_team_ids: ["456", "789"],
                    available_on: ["inbox", "messenger"],
                },
                {
                    type: "macro",
                    id: "101",
                    name: "Product Inquiry Response",
                    body: '<p>Thank you for your interest in <attribute key="product.name" default="our products"/>. I\'d be happy to provide more information!</p>',
                    body_text:
                        'Thank you for your interest in {{product.name|fallback:"our products"}}. I\'d be happy to provide more information!',
                    created_at: "2025-07-20T05:33:20Z",
                    updated_at: "2025-07-21T10:00:00Z",
                    visible_to: "everyone",
                    visible_to_team_ids: ["456", "789"],
                    available_on: ["inbox", "messenger"],
                },
            ],
            pages: {
                type: "pages",
                per_page: 50,
                next: {
                    starting_after: "WzE3MTk0MDAwMDAuMCwgIjEwMSJd",
                },
            },
        });
    });

    test("listMacros (3)", 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: "macro",
                    id: "234",
                    name: "Shipping Update Template",
                    body: '<p>Your order has been shipped via <attribute key="shipping.carrier" default="our shipping partner"/>. Tracking number: <attribute key="shipping.tracking_number"/></p>',
                    body_text:
                        'Your order has been shipped via {{shipping.carrier|fallback:"our shipping partner"}}. Tracking number: {{shipping.tracking_number}}',
                    created_at: "2025-07-22T05:31:01Z",
                    updated_at: "2025-07-22T18:45:12Z",
                    visible_to: "everyone",
                    visible_to_team_ids: ["456", "789"],
                    available_on: ["inbox"],
                },
            ],
            pages: { type: "pages", per_page: 50, next: { starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd" } },
        };
        server.mockEndpoint().get("/macros").respondWith().statusCode(200).jsonBody(rawResponseBody).build();

        const response = await client.unstable.macros.listMacros({
            per_page: 1,
            starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd",
            updated_since: 1000000,
        });
        expect(response).toEqual({
            type: "list",
            data: [
                {
                    type: "macro",
                    id: "234",
                    name: "Shipping Update Template",
                    body: '<p>Your order has been shipped via <attribute key="shipping.carrier" default="our shipping partner"/>. Tracking number: <attribute key="shipping.tracking_number"/></p>',
                    body_text:
                        'Your order has been shipped via {{shipping.carrier|fallback:"our shipping partner"}}. Tracking number: {{shipping.tracking_number}}',
                    created_at: "2025-07-22T05:31:01Z",
                    updated_at: "2025-07-22T18:45:12Z",
                    visible_to: "everyone",
                    visible_to_team_ids: ["456", "789"],
                    available_on: ["inbox"],
                },
            ],
            pages: {
                type: "pages",
                per_page: 50,
                next: {
                    starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd",
                },
            },
        });
    });

    test("listMacros (4)", 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: "macro",
                    id: "567",
                    name: "Account Status Review",
                    body: '<p>Hi <attribute key="user.first_name" default="there"/>,</p><p>Your account status: <attribute key="user.custom_attributes.account_status" default="pending review"/></p><p>Last activity: <attribute key="user.last_seen_at"/></p>',
                    body_text:
                        'Hi {{user.first_name|fallback:"there"}},\n\nYour account status: {{user.custom_attributes.account_status|fallback:"pending review"}}\n\nLast activity: {{user.last_seen_at}}',
                    created_at: "2025-07-21T09:00:00Z",
                    updated_at: "2025-07-21T09:00:00Z",
                    visible_to: "specific_teams",
                    visible_to_team_ids: ["security_team"],
                    available_on: ["inbox"],
                },
            ],
            pages: { type: "pages", per_page: 50, next: { starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd" } },
        };
        server.mockEndpoint().get("/macros").respondWith().statusCode(200).jsonBody(rawResponseBody).build();

        const response = await client.unstable.macros.listMacros({
            per_page: 1,
            starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd",
            updated_since: 1000000,
        });
        expect(response).toEqual({
            type: "list",
            data: [
                {
                    type: "macro",
                    id: "567",
                    name: "Account Status Review",
                    body: '<p>Hi <attribute key="user.first_name" default="there"/>,</p><p>Your account status: <attribute key="user.custom_attributes.account_status" default="pending review"/></p><p>Last activity: <attribute key="user.last_seen_at"/></p>',
                    body_text:
                        'Hi {{user.first_name|fallback:"there"}},\n\nYour account status: {{user.custom_attributes.account_status|fallback:"pending review"}}\n\nLast activity: {{user.last_seen_at}}',
                    created_at: "2025-07-21T09:00:00Z",
                    updated_at: "2025-07-21T09:00:00Z",
                    visible_to: "specific_teams",
                    visible_to_team_ids: ["security_team"],
                    available_on: ["inbox"],
                },
            ],
            pages: {
                type: "pages",
                per_page: 50,
                next: {
                    starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd",
                },
            },
        });
    });

    test("listMacros (5)", 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: "macro",
                    id: "123",
                    name: "Order Status Update",
                    body: '<p>Hi <attribute key="user.name" default="there"/>, your order is ready!</p>',
                    body_text: 'Hi {{user.name|fallback:"there"}}, your order is ready!',
                    created_at: "2025-07-17T11:18:08Z",
                    updated_at: "2025-07-17T15:30:24Z",
                    visible_to: "everyone",
                    visible_to_team_ids: ["456", "789"],
                    available_on: ["inbox", "messenger"],
                },
            ],
            pages: { type: "pages", per_page: 50, next: { starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd" } },
        };
        server.mockEndpoint().get("/macros").respondWith().statusCode(200).jsonBody(rawResponseBody).build();

        const response = await client.unstable.macros.listMacros({
            per_page: 1,
            starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd",
            updated_since: 1000000,
        });
        expect(response).toEqual({
            type: "list",
            data: [
                {
                    type: "macro",
                    id: "123",
                    name: "Order Status Update",
                    body: '<p>Hi <attribute key="user.name" default="there"/>, your order is ready!</p>',
                    body_text: 'Hi {{user.name|fallback:"there"}}, your order is ready!',
                    created_at: "2025-07-17T11:18:08Z",
                    updated_at: "2025-07-17T15:30:24Z",
                    visible_to: "everyone",
                    visible_to_team_ids: ["456", "789"],
                    available_on: ["inbox", "messenger"],
                },
            ],
            pages: {
                type: "pages",
                per_page: 50,
                next: {
                    starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd",
                },
            },
        });
    });

    test("listMacros (6)", 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: "macro",
                    id: "1001",
                    name: "Quick Response 1",
                    body: '<p>Hi <attribute key="user.name" default="there"/>, your order is ready!</p>',
                    body_text: 'Hi {{user.name|fallback:"there"}}, your order is ready!',
                    created_at: "2025-07-22T11:08:20Z",
                    updated_at: "2025-07-23T11:08:20Z",
                    visible_to: "everyone",
                    visible_to_team_ids: ["456", "789"],
                    available_on: ["inbox"],
                },
            ],
            pages: { type: "pages", per_page: 50, next: { starting_after: "WzE3MTk0OTAxMDAuMCwgIjEwMDIiXQ==" } },
        };
        server.mockEndpoint().get("/macros").respondWith().statusCode(200).jsonBody(rawResponseBody).build();

        const response = await client.unstable.macros.listMacros({
            per_page: 1,
            starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd",
            updated_since: 1000000,
        });
        expect(response).toEqual({
            type: "list",
            data: [
                {
                    type: "macro",
                    id: "1001",
                    name: "Quick Response 1",
                    body: '<p>Hi <attribute key="user.name" default="there"/>, your order is ready!</p>',
                    body_text: 'Hi {{user.name|fallback:"there"}}, your order is ready!',
                    created_at: "2025-07-22T11:08:20Z",
                    updated_at: "2025-07-23T11:08:20Z",
                    visible_to: "everyone",
                    visible_to_team_ids: ["456", "789"],
                    available_on: ["inbox"],
                },
            ],
            pages: {
                type: "pages",
                per_page: 50,
                next: {
                    starting_after: "WzE3MTk0OTAxMDAuMCwgIjEwMDIiXQ==",
                },
            },
        });
    });

    test("listMacros (7)", 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("/macros").respondWith().statusCode(400).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.unstable.macros.listMacros();
        }).rejects.toThrow(Intercom.unstable.BadRequestError);
    });

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

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

        await expect(async () => {
            return await client.unstable.macros.listMacros();
        }).rejects.toThrow(Intercom.unstable.UnauthorizedError);
    });

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

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

        await expect(async () => {
            return await client.unstable.macros.listMacros();
        }).rejects.toThrow(Intercom.unstable.ForbiddenError);
    });

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

        const rawResponseBody = {
            type: "macro",
            id: "789",
            name: "Refund Process Explanation",
            body: '<p>Hi <attribute key="user.first_name" default="there"/>,</p><p>I understand you\'d like a refund for order #<attribute key="conversation.custom_attributes.order_number"/>. The refund will be processed within 3-5 business days to your <attribute key="user.custom_attributes.payment_method" default="original payment method"/>.</p><p>Is there anything else I can help you with?</p>',
            body_text:
                'Hi {{user.first_name|fallback:"there"}},\n\nI understand you\'d like a refund for order #{{conversation.custom_attributes.order_number}}. The refund will be processed within 3-5 business days to your {{user.custom_attributes.payment_method|fallback:"original payment method"}}.\n\nIs there anything else I can help you with?',
            created_at: "2025-07-21T14:44:35Z",
            updated_at: "2025-07-21T14:44:35Z",
            visible_to: "specific_teams",
            visible_to_team_ids: ["support_team_1", "support_team_2"],
            available_on: ["inbox", "messenger"],
        };
        server.mockEndpoint().get("/macros/123").respondWith().statusCode(200).jsonBody(rawResponseBody).build();

        const response = await client.unstable.macros.getMacro({
            id: "123",
        });
        expect(response).toEqual({
            type: "macro",
            id: "789",
            name: "Refund Process Explanation",
            body: '<p>Hi <attribute key="user.first_name" default="there"/>,</p><p>I understand you\'d like a refund for order #<attribute key="conversation.custom_attributes.order_number"/>. The refund will be processed within 3-5 business days to your <attribute key="user.custom_attributes.payment_method" default="original payment method"/>.</p><p>Is there anything else I can help you with?</p>',
            body_text:
                'Hi {{user.first_name|fallback:"there"}},\n\nI understand you\'d like a refund for order #{{conversation.custom_attributes.order_number}}. The refund will be processed within 3-5 business days to your {{user.custom_attributes.payment_method|fallback:"original payment method"}}.\n\nIs there anything else I can help you with?',
            created_at: "2025-07-21T14:44:35Z",
            updated_at: "2025-07-21T14:44:35Z",
            visible_to: "specific_teams",
            visible_to_team_ids: ["support_team_1", "support_team_2"],
            available_on: ["inbox", "messenger"],
        });
    });

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

        const rawResponseBody = {
            type: "macro",
            id: "456",
            name: "Product Demo Request",
            body: '<p>Hello <attribute key="user.name" default="valued customer"/>,</p><p>Thank you for your interest in <attribute key="product.name" default="our products"/>! I\'d love to schedule a personalized demo for your team at <attribute key="company.name" default="your company"/>.</p><p>Would <attribute key="suggested_time" default="next Tuesday at 2 PM EST"/> work for you?</p>',
            body_text:
                'Hello {{user.name|fallback:"valued customer"}},\n\nThank you for your interest in {{product.name|fallback:"our products"}}! I\'d love to schedule a personalized demo for your team at {{company.name|fallback:"your company"}}.\n\nWould {{suggested_time|fallback:"next Tuesday at 2 PM EST"}} work for you?',
            created_at: "2025-07-22T11:06:40Z",
            updated_at: "2025-07-23T00:00:00Z",
            visible_to: "specific_teams",
            visible_to_team_ids: ["sales_team_us", "sales_team_eu"],
            available_on: ["messenger"],
        };
        server.mockEndpoint().get("/macros/123").respondWith().statusCode(200).jsonBody(rawResponseBody).build();

        const response = await client.unstable.macros.getMacro({
            id: "123",
        });
        expect(response).toEqual({
            type: "macro",
            id: "456",
            name: "Product Demo Request",
            body: '<p>Hello <attribute key="user.name" default="valued customer"/>,</p><p>Thank you for your interest in <attribute key="product.name" default="our products"/>! I\'d love to schedule a personalized demo for your team at <attribute key="company.name" default="your company"/>.</p><p>Would <attribute key="suggested_time" default="next Tuesday at 2 PM EST"/> work for you?</p>',
            body_text:
                'Hello {{user.name|fallback:"valued customer"}},\n\nThank you for your interest in {{product.name|fallback:"our products"}}! I\'d love to schedule a personalized demo for your team at {{company.name|fallback:"your company"}}.\n\nWould {{suggested_time|fallback:"next Tuesday at 2 PM EST"}} work for you?',
            created_at: "2025-07-22T11:06:40Z",
            updated_at: "2025-07-23T00:00:00Z",
            visible_to: "specific_teams",
            visible_to_team_ids: ["sales_team_us", "sales_team_eu"],
            available_on: ["messenger"],
        });
    });

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

        const rawResponseBody = {
            type: "macro",
            id: "890",
            name: "API Integration Help",
            body: '<p>Hi <attribute key="user.name"/>,</p><p>I see you\'re having trouble with the <attribute key="conversation.custom_attributes.api_endpoint" default="API"/> integration. Your API key for app <attribute key="app.id"/> is configured correctly.</p><p>Error code: <attribute key="conversation.custom_attributes.error_code" default="unknown"/></p><p>Let me help you resolve this issue.</p>',
            body_text:
                'Hi {{user.name}},\n\nI see you\'re having trouble with the {{conversation.custom_attributes.api_endpoint|fallback:"API"}} integration. Your API key for app {{app.id}} is configured correctly.\n\nError code: {{conversation.custom_attributes.error_code|fallback:"unknown"}}\n\nLet me help you resolve this issue.',
            created_at: "2025-07-18T09:15:00Z",
            updated_at: "2025-07-18T09:15:00Z",
            visible_to: "everyone",
            visible_to_team_ids: ["456", "789"],
            available_on: ["inbox"],
        };
        server.mockEndpoint().get("/macros/123").respondWith().statusCode(200).jsonBody(rawResponseBody).build();

        const response = await client.unstable.macros.getMacro({
            id: "123",
        });
        expect(response).toEqual({
            type: "macro",
            id: "890",
            name: "API Integration Help",
            body: '<p>Hi <attribute key="user.name"/>,</p><p>I see you\'re having trouble with the <attribute key="conversation.custom_attributes.api_endpoint" default="API"/> integration. Your API key for app <attribute key="app.id"/> is configured correctly.</p><p>Error code: <attribute key="conversation.custom_attributes.error_code" default="unknown"/></p><p>Let me help you resolve this issue.</p>',
            body_text:
                'Hi {{user.name}},\n\nI see you\'re having trouble with the {{conversation.custom_attributes.api_endpoint|fallback:"API"}} integration. Your API key for app {{app.id}} is configured correctly.\n\nError code: {{conversation.custom_attributes.error_code|fallback:"unknown"}}\n\nLet me help you resolve this issue.',
            created_at: "2025-07-18T09:15:00Z",
            updated_at: "2025-07-18T09:15:00Z",
            visible_to: "everyone",
            visible_to_team_ids: ["456", "789"],
            available_on: ["inbox"],
        });
    });

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

        const rawResponseBody = {
            type: "macro",
            id: "123",
            name: "Thank You Response",
            body: "<p>Thank you for reaching out! We appreciate your message and will get back to you as soon as possible.</p>",
            body_text:
                "Thank you for reaching out! We appreciate your message and will get back to you as soon as possible.",
            created_at: "2025-07-17T11:18:08Z",
            updated_at: "2025-07-17T15:30:24Z",
            visible_to: "everyone",
            visible_to_team_ids: ["456", "789"],
            available_on: ["inbox", "messenger"],
        };
        server.mockEndpoint().get("/macros/123").respondWith().statusCode(200).jsonBody(rawResponseBody).build();

        const response = await client.unstable.macros.getMacro({
            id: "123",
        });
        expect(response).toEqual({
            type: "macro",
            id: "123",
            name: "Thank You Response",
            body: "<p>Thank you for reaching out! We appreciate your message and will get back to you as soon as possible.</p>",
            body_text:
                "Thank you for reaching out! We appreciate your message and will get back to you as soon as possible.",
            created_at: "2025-07-17T11:18:08Z",
            updated_at: "2025-07-17T15:30:24Z",
            visible_to: "everyone",
            visible_to_team_ids: ["456", "789"],
            available_on: ["inbox", "messenger"],
        });
    });

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

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

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

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

        const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] };
        server.mockEndpoint().get("/macros/id").respondWith().statusCode(403).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.unstable.macros.getMacro({
                id: "id",
            });
        }).rejects.toThrow(Intercom.unstable.ForbiddenError);
    });

    test("getMacro (7)", 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("/macros/id").respondWith().statusCode(404).jsonBody(rawResponseBody).build();

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