Edits history of script submission #15402 for ' Create an EOR contract (deel)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Create an EOR contract
     * Creates an Employee of Record (EOR) contract quote. This endpoint allows to submit details for an EOR contract. Deel will process the information and return a quote for the requested contract.
     **Token scopes**: `contracts:write`
     */
    export async function main(auth: RT.Deel, body: Body) {
    	const url = new URL(`https://api.letsdeel.com/rest/v2/eor`)
    
    	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: {
    				id: string | number
    				[k: string]: unknown
    			}
    			legal_entity?: {
    				id?: string | number
    				[k: string]: unknown
    			}
    			[k: string]: unknown
    		}
    		/**
    		 * Some countries required a pension benefit.
    		 */
    		pension?: {
    			/**
    			 * Pension provider id. You can see available pension providers in the country guide endpoint.
    			 */
    			id?: string
    			/**
    			 * Enter the value of pension contribution. You should send this value only if the contribution object is available in the country guide endpoint and the value should be there between minimum and maximum values indicated.
    			 */
    			contribution?: string
    			[k: string]: unknown
    		}
    		benefits?: {
    			/**
    			 * The ID of a benefits plan to include in the calculation.
    			 */
    			plan_id?: string
    			/**
    			 * Flag indicating if benefit will fully cover the employee.
    			 */
    			cover_all?: boolean
    			/**
    			 * The ID of a benefits provider to include in the calculation.
    			 */
    			provider_id?: string
    			/**
    			 * The amount the client will contribute for the benefit in the currency of the contract. Only taken into account if cover_all is set to false. For Unisure provider contribution is always in USD.
    			 */
    			contribution?: number
    			/**
    			 * Flag indicating if benefit will cover dependents. Only needed if cover_all is set to true.
    			 */
    			cover_dependents?: boolean
    			[k: string]: unknown
    		}[]
    		employee: {
    			/**
    			 * Employee'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
    			/**
    			 * External identifier of the employee.
    			 */
    			external_id?: string
    			/**
    			 * Employee's nationality.
    			 */
    			nationality: string
    			/**
    			 * Employee's PF deductions. Required only for India contracts.
    			 */
    			pf_deductions?: '12% of Basic' | '12% of Rs 15,000 (Rs 1,800)'
    			[k: string]: unknown
    		}
    		/**
    		 * Employee's job title.
    		 */
    		job_title: string
    		seniority: {
    			id?: string | number
    			[k: string]: unknown
    		}
    		employment: {
    			/**
    			 * Is it a full-time contract or a part-time contract?
    			 */
    			type?: 'Full-time' | 'Part-time'
    			/**
    			 * State code of the state/province where the this person will be employed.
    			 */
    			state?: string
    			/**
    			 * Country code of employment.
    			 */
    			country: string
    			/**
    			 * End date in ISO-8601 format (YYYY-MM-DD).
    			 */
    			end_date?: string
    			/**
    			 * Enter the number of holidays. Leave this field blank if you are chooseing "STANDARD" time_off_type.
    			 */
    			holidays?: number
    			/**
    			 * Is the employee contract hourly instead of salaried?
    			 */
    			is_hourly?: boolean
    			/**
    			 * Start date in ISO-8601 format (YYYY-MM-DD).
    			 */
    			start_date: string
    			scope_of_work:
    				| string
    				| {
    						/**
    						 * Scope template UUID.
    						 */
    						scope_template_id?: string
    						[k: string]: unknown
    				  }
    				| {
    						/**
    						 * Scope validation UUID.
    						 */
    						scope_validation_id?: string
    						[k: string]: unknown
    				  }
    			/**
    			 * If you want to use standard number of holidays for this employee, choose "STANDARD". If you want to enter a specific number of holidays, choose "SPECIFIC" and enter the number of days in the holidays field.
    			 */
    			time_off_type?: 'STANDARD' | 'SPECIFIC'
    			/**
    			 * Seniority date
    			 */
    			seniority_date?: string
    			/**
    			 * Number of sick leave days
    			 */
    			sick_leave_days?: number
    			/**
    			 * Number of probation days.
    			 */
    			probation_period?: number
    			/**
    			 * Type of notice period.
    			 */
    			notice_period_type?: 'STANDARD' | 'CUSTOM'
    			/**
    			 * Do you require Deel to apply for work visa for this person?
    			 */
    			work_visa_required: boolean
    			/**
    			 * Employee's work hours per week. Required only if contract is set as hourly.
    			 */
    			work_hours_per_week?: number
    			/**
    			 * Notice period after probation required when type is CUSTOM.
    			 */
    			notice_period_after_probation?: number
    			/**
    			 * Notice period during probation required when type is CUSTOM.
    			 */
    			notice_period_during_probation?: number
    			/**
    			 * Whether the employee has previously passed the probation period.
    			 */
    			employee_completed_past_probation?: boolean
    			/**
    			 * Type of probation period for definite contracts.
    			 */
    			probation_period_type_for_definite?: 'STANDARD' | 'CUSTOM'
    			[k: string]: unknown
    		}
    		/**
    		 * Healthcare plan id. You can see available healthcare plans in the country guide endpoint.
    		 */
    		health_plan_id?: string
    		compensation_details: {
    			/**
    			 * Employee's gross annual salary. Required only if contract is salaried.
    			 */
    			salary?: number
    			/**
    			 * Salary currency.
    			 */
    			currency: string
    			/**
    			 * Employee's hourly rate. Required only if contract is set as hourly.
    			 */
    			hourly_rate?: number
    			/**
    			 * Signing bonus amount.
    			 */
    			signing_bonus?: number
    			fixed_adjustments?: {
    				/**
    				 * Adjustment name.
    				 */
    				name?: string
    				/**
    				 * Adjustment value.
    				 */
    				value?: number
    				/**
    				 * Whether the adjustment is being opted out of.
    				 */
    				opt_out?: boolean
    				/**
    				 * Whether the adjustment is optional.
    				 */
    				optional?: boolean
    				/**
    				 * Adjustment description.
    				 */
    				description?: string
    				/**
    				 * Whether the adjustment is paid recurring monthly or one-time on employee's first payroll.
    				 */
    				is_recurring?: boolean
    				/**
    				 * Identifier of the rule cost associated with the adjustment.
    				 */
    				rule_cost_id?: string
    				/**
    				 * Whether this adjustment is country-specific.
    				 */
    				is_country_specific?: boolean
    				/**
    				 * Optional skipping confirmation text shown to the user.
    				 */
    				skipping_confirmation_text?: string
    				[k: string]: unknown
    			}[]
    			/**
    			 * Variable compensation. For example, if the person will earn 5% of the gross annual salary as the variable compensation, enter 5.
    			 */
    			variable_compensation?: number
    			/**
    			 * Should be set only if signing_bonus is set. It defines when the bonus is paid.
    			 */
    			signing_bonus_payout_type?:
    				| 'FIRST_CYCLE'
    				| 'AFTER_PROBATION'
    				| 'AFTER_FIRST_CONTRACT_ANNIVERSARY'
    			/**
    			 * Should be set only if variable_compensation is set. It can be PERCENTAGE or FIXED.
    			 */
    			variable_compensation_type?: 'PERCENTAGE' | 'FIXED' | null
    			/**
    			 * Variable compensation title.
    			 */
    			variable_compensation_title?: string
    			/**
    			 * Variable compensation timeline.
    			 */
    			variable_compensation_timeline?: 'ANNUALLY' | 'BIANNUALLY' | 'QUARTERLY' | 'MONTHLY'
    			/**
    			 * Variable compensation effective date.
    			 */
    			variable_compensation_effective_date?: string
    			[k: string]: unknown
    		}
    		/**
    		 * Some countries require additional employee information for employment contracts.
    		 */
    		quote_additional_fields?: {
    			/**
    			 * Employee's date of birth.
    			 */
    			dob?: string
    			/**
    			 * Employee's gender.
    			 */
    			gender?: string
    			/**
    			 * Type of worker.
    			 */
    			worker_type?: 'Skilled' | 'Unskilled'
    			[k: string]: unknown
    		}
    		[k: string]: unknown
    	}
    	[k: string]: unknown
    }
    

    Submitted by hugo697 235 days ago