import { parseAuth } from './auth.ts' import { intercomRequest } from './client.ts' import { mapMe } from './models.ts' import type { IntercomAuthInput, IntercomMe } from './types.ts' import { requireRecord } from './types.ts' /** * Return the connected Intercom admin without email or workspace name. * @example * import getMe from 'kody:@kody/intercom/me' * const me = await getMe() */ export async function getMe(input: IntercomAuthInput = {}): Promise { const result = await intercomRequest({ ...input, operation: 'me.read', path: '/me', }) if ('dryRun' in result) { throw new Error('GET /me does not support dryRun.') } return mapMe(result.data) } /** * Return the connected Intercom admin without email or workspace name. * @example * import getMe from 'kody:@kody/intercom/me' * const me = await getMe({ integrationName: 'intercom-work' }) */ export default async function meEntrypoint( params: IntercomAuthInput & Record = {}, ) { return getMe(parseAuth(requireRecord(params, 'me'))) }