export type ConsentFramework = 'GDPR' | 'PDPO'; export type ConsentLegalBasis = 'CONSENT' | 'CONTRACT' | 'LEGAL_OBLIGATION' | 'VITAL_INTEREST' | 'PUBLIC_TASK' | 'LEGITIMATE_INTEREST'; export type SystemConsentPurpose = 'RECRUITING' | 'MARKETING_EMAIL' | 'MARKETING_SMS' | 'WHATSAPP_BUSINESS_UTILITY' | 'WHATSAPP_BUSINESS_MARKETING'; export type ConsentPurposeRequestDto = {type: 'system', name: SystemConsentPurpose} | {type: 'custom', id: string}; export type DateISO = string; export type ConsentStatus = 'GRANTED' | 'REVOKED'; export type UpdateConsentDto = {framework?: (ConsentFramework | null) | undefined, legalBasis?: ConsentLegalBasis | undefined, purpose?: ConsentPurposeRequestDto | undefined, comments?: (string | null) | undefined, receivedAt?: DateISO | undefined, validUntil?: DateISO | undefined, status?: ConsentStatus | undefined}; export type PatchApiConsentsConsentIdArgs = {consentId: string, body: UpdateConsentDto}; export type PatchApiConsentsConsentIdOptions = {baseUrl: string, xApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update consent * * PATCH /consents/{consentId} */ export const patchApiConsentsConsentId = async (args: PatchApiConsentsConsentIdArgs, options: PatchApiConsentsConsentIdOptions) => { 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(/\/+$/, '')}/consents/${encodeURIComponent(String(args.consentId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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 };