export type CreateApiIdentitiesSaveWithTokenArgs = {body: {id?: string | undefined, orgId: string, userId?: string | undefined, type: 'linkedin' | 'google', firstName?: string | undefined, lastName?: string | undefined, profileUrl?: string | undefined, profileId: string, profilePictureUrl?: string | undefined, subscriptionTitles?: (Array | null) | undefined, headline?: string | undefined, token: string, activeCredentials?: (Array<{sessionCookie: string, userAgent?: string | undefined}>) | undefined, activeCredential?: ({sessionCookie: string, userAgent?: string | undefined}) | undefined}}; export type CreateApiIdentitiesSaveWithTokenOptions = {baseUrl?: string | undefined, apiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Save identity. * * POST /identities/save-with-token */ export const createApiIdentitiesSaveWithToken = async (args: CreateApiIdentitiesSaveWithTokenArgs, options?: CreateApiIdentitiesSaveWithTokenOptions) => { const {baseUrl = "https://api.phantombuster.com/api/v2", fetch: fetchFn = fetch, apiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (apiKeyAuth !== undefined) headers.set("X-Phantombuster-Key", apiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/identities/save-with-token${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 };