Edits history of script submission #15385 for ' Create a contract (deel)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Create a contract
     * Create a Global Payroll contract.
     **Token scopes**: `contracts:write`
     */
    export async function main(auth: RT.Deel, body: Body) {
    	const url = new URL(`https://api.letsdeel.com/rest/v2/contracts/gp`)
    
    	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: {
    		client: {
    			team: {
    				/**
    				 * Refers to Groups in the platform. Working groups that reflect the organization's structure.
    				 */
    				id: string
    				[k: string]: unknown
    			}
    			legal_entity: {
    				/**
    				 * Unique identifier of this resource.
    				 */
    				id: string
    				[k: string]: unknown
    			}
    			[k: string]: unknown
    		}
    		employee: {
    			/**
    			 * Worker's email address.
    			 */
    			email: string
    			address: {
    				/**
    				 * Zip code.
    				 */
    				zip: string
    				/**
    				 * City name.
    				 */
    				city: string
    				/**
    				 * State code.
    				 */
    				state?: string
    				/**
    				 * Street and number.
    				 */
    				street: string
    				/**
    				 * Country code.
    				 */
    				country: string
    				[k: string]: unknown
    			}
    			/**
    			 * Employee's last name.
    			 */
    			last_name: string
    			/**
    			 * Employee's first name.
    			 */
    			first_name: string
    			/**
    			 * Worker's email address.
    			 */
    			work_email: string
    			/**
    			 * Employee's nationality.
    			 */
    			nationality?: string
    			/**
    			 * Employee's number.
    			 */
    			employee_number?: string
    			[k: string]: unknown
    		}
    		/**
    		 * Employee's job title.
    		 */
    		job_title: string
    		employment: {
    			/**
    			 * Is it a full-time contract or a part-time contract?
    			 */
    			type: 'Full-time' | 'Part-time'
    			holidays: {
    				/**
    				 * Enter the number of holidays.
    				 */
    				allowance: number
    				/**
    				 * Short date in format ISO-8601 (YYYY-MM-DD). For example: 2022-12-31.
    				 */
    				start_date: string
    				[k: string]: unknown
    			}
    			/**
    			 * Short date in format ISO-8601 (YYYY-MM-DD). For example: 2022-12-31.
    			 */
    			start_date: string
    			[k: string]: unknown
    		}
    		compensation_details: {
    			/**
    			 * Defines the scale at which the salary is paid.
    			 */
    			scale: 'YEAR' | 'MONTH'
    			/**
    			 * Employee's gross annual/month salary.
    			 */
    			salary: number
    			currency?: string
    			[k: string]: unknown
    		}
    		/**
    		 * Defines whether the employee should be invited to join the platform. When set to true, and if the employee app is enabled, an invitation will be sent to the employee to onboard them into the platform.
    		 */
    		invite_employee_to_app?: boolean
    		[k: string]: unknown
    	}
    	[k: string]: unknown
    }
    

    Submitted by hugo697 235 days ago