export type DocumentType = 'IDENTITY_CARD' | 'PASSPORT' | 'RESIDENCE_PERMIT'; export type CountryCode = string; export type UpdateIdentityDataRequestV1 = {bsnDocument?: string | undefined, base64DocumentBack: string, base64DocumentFront: string, documentType: DocumentType, documentNumber: string, documentExpiryDate: string, documentNationality: CountryCode}; export type CreateApiPublicWorkerV1UpdateIdentityDataArgs = {body: UpdateIdentityDataRequestV1}; export type CreateApiPublicWorkerV1UpdateIdentityDataOptions = {baseUrl: string, oauth2ClientCredentials?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update identity data of a worker * * * POST /public/worker/v1/update-identity-data */ export const createApiPublicWorkerV1UpdateIdentityData = async (args: CreateApiPublicWorkerV1UpdateIdentityDataArgs, options: CreateApiPublicWorkerV1UpdateIdentityDataOptions) => { const {baseUrl, fetch: fetchFn = fetch, oauth2ClientCredentials} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (oauth2ClientCredentials !== undefined) headers.set('authorization', `Bearer ${oauth2ClientCredentials}`) const url = `${baseUrl.replace(/\/+$/, '')}/public/worker/v1/update-identity-data${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 };