export type EmailsFilterDto = {page: number, limit: number, search?: string | undefined, categoryIds?: Array | undefined, sentiment?: ('Positive' | 'Negative' | 'Neutral' | 'Uncategorized') | undefined, sequenceIds?: Array | undefined, emailAccountIds?: Array | undefined, startDate?: string | undefined, endDate?: string | undefined, isRead?: number | undefined, owners: Array, clientIds?: Array | undefined, type?: ('system' | 'external') | undefined}; export type CreateApiV1UnifiedInboxEmailsArgs = {body: EmailsFilterDto}; export type CreateApiV1UnifiedInboxEmailsOptions = {baseUrl: string, xApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get all emails based on filters * * POST /v1/unified-inbox/emails */ export const createApiV1UnifiedInboxEmails = async (args: CreateApiV1UnifiedInboxEmailsArgs, options: CreateApiV1UnifiedInboxEmailsOptions) => { const {baseUrl, fetch: fetchFn = fetch, xApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (xApiKey !== undefined) headers.set("x-api-key", xApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/v1/unified-inbox/emails${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };