import { definePlugin } from "../../utils/plugin-utils";
import { createPluginMethod } from "../../utils/plugin-utils";
import { GetProfileSchema } from "./schemas";
import { UserProfileItemSchema } from "../../schemas/UserProfile";
export const getProfilePlugin = definePlugin((sdk) => createPluginMethod(sdk, {
    name: "getProfile",
    categories: ["account"],
    type: "item",
    itemType: "Profile",
    inputSchema: GetProfileSchema,
    outputSchema: UserProfileItemSchema,
    handler: async ({ sdk }) => {
        const profile = await sdk.context.api.get("/zapier/api/v4/profile/", { authRequired: true });
        return {
            data: {
                id: String(profile.public_id ?? profile.id),
                first_name: profile.first_name,
                last_name: profile.last_name,
                full_name: `${profile.first_name} ${profile.last_name}`,
                email: profile.email,
                email_confirmed: profile.email_confirmed,
                timezone: profile.timezone,
            },
        };
    },
}));
