Edits history of script submission #15393 for ' Create a new worker (deel)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Create a new worker
     * Creates a new worker account with the specified profile type
     */
    export async function main(auth: RT.Deel, body: Body) {
    	const url = new URL(`https://api.letsdeel.com/rest/v2/worker`)
    
    	const response = await fetch(url, {
    		method: 'POST',
    		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: {
    		/**
    		 * Worker's email address
    		 */
    		email: string
    		company: {
    			/**
    			 * Type of company registration
    			 */
    			type: 'COMPANY' | 'INDIVIDUAL'
    			personal: {
    				/**
    				 * Zip/Postal code
    				 */
    				zip: number
    				/**
    				 * City
    				 */
    				city: string
    				/**
    				 * Phone number
    				 */
    				phone: number
    				/**
    				 * Street address
    				 */
    				street: string
    				/**
    				 * Citizenship country code
    				 */
    				citizen: string
    				/**
    				 * Country code
    				 */
    				country?: string
    				/**
    				 * Type of identification
    				 */
    				id_type?: string
    				/**
    				 * Province/State
    				 */
    				province?: string
    				/**
    				 * Personal timezone
    				 */
    				timezone?: string
    				/**
    				 * Personal identification number
    				 */
    				personal_id: number
    				/**
    				 * Legal status (required only when type is INDIVIDUAL)
    				 */
    				legal_status?: string
    				/**
    				 * Tax residence country code
    				 */
    				tax_residence?: string
    				/**
    				 * Entity tax residence (only applicable for company type)
    				 */
    				entity_tax_residence?: string
    				[k: string]: unknown
    			}
    			[k: string]: unknown
    		}
    		/**
    		 * Worker's timezone
    		 */
    		timezone: string
    		/**
    		 * Worker's last name
    		 */
    		last_name: string
    		/**
    		 * Worker's first name
    		 */
    		first_name: string
    		/**
    		 * Associated contract ID
    		 */
    		contract_id: string
    		/**
    		 * Worker's middle name
    		 */
    		middle_name?: string
    		/**
    		 * Type of worker profile
    		 */
    		profile_type: 'CONTRACTOR' | 'EOR'
    		/**
    		 * Worker's preferred name
    		 */
    		preferred_name?: string
    		/**
    		 * Worker's preferred last name
    		 */
    		preferred_lastName?: string
    		/**
    		 * Worker's preferred first name
    		 */
    		preferred_firstname?: string
    		[k: string]: unknown
    	}
    	[k: string]: unknown
    }
    

    Submitted by hugo697 235 days ago