Edits history of script submission #15512 for ' Get worker's KYC details (deel)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Get worker's KYC details
     * This endpoint allows organizations managing workers on Deel to retrieve detailed KYC verification data using the worker’s profile ID. It provides comprehensive information including verification status, document type, submission, approval, rejection, and expiry dates, supporting compliance monitoring and onboarding workflows
     **Token scopes**: `screenings:read`
     */
    export async function main(
    	auth: RT.Deel,
    	worker_profile_id?: string | undefined,
    	profile_id?: string | undefined
    ) {
    	const url = new URL(`https://api.letsdeel.com/rest/v2/screenings/kyc/details`)
    	for (const [k, v] of [
    		['worker_profile_id', worker_profile_id],
    		['profile_id', profile_id]
    	]) {
    		if (v !== undefined && v !== '') {
    			url.searchParams.append(k, v)
    		}
    	}
    	const response = await fetch(url, {
    		method: 'GET',
    		headers: {
    			Authorization: 'Bearer ' + auth.apiKey
    		},
    		body: undefined
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.json()
    }
    

    Submitted by hugo697 235 days ago