Edits history of script submission #15395 for ' Create a parent worker relation with external id (deel)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Create a parent worker relation with external id
     * Create a parent worker relation with external id.
     **Token scopes**: `profile:write`
     */
    export async function main(auth: RT.Deel, hrisProfileExternalId: string, body: Body) {
    	const url = new URL(
    		`https://api.letsdeel.com/rest/v2/hris/worker_relations/profile/external/${hrisProfileExternalId}/parent`
    	)
    
    	const response = await fetch(url, {
    		method: 'PUT',
    		headers: {
    			'Content-Type': 'application/json',
    			Authorization: 'Bearer ' + auth.apiKey
    		},
    		body: JSON.stringify(body)
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.json()
    }
    
    /* eslint-disable */
    /**
     * This file was automatically generated by json-schema-to-typescript.
     * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
     * and run json-schema-to-typescript to regenerate this file.
     */
    
    export interface Body {
    	data?: {
    		edit_reason?: {
    			/**
    			 * The reason for the edit
    			 */
    			reason_oid: string
    			/**
    			 * Additional information about the edit
    			 */
    			additional_info?: string
    			[k: string]: unknown
    		}
    		/**
    		 * The external id of the relation
    		 */
    		relation_external_id?: string
    		/**
    		 * The external id of the parent profile
    		 */
    		parent_profile_external_id?: string
    		/**
    		 * The external id of the relationship type
    		 */
    		hris_relationship_type_external_id?: string
    		[k: string]: unknown
    	}
    	[k: string]: unknown
    }
    

    Submitted by hugo697 235 days ago