Edits history of script submission #15643 for ' Update EOR Contract (deel)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Update EOR Contract
     * This endpoint is used to modify mutable fields of an EOR contract, such as salary, job title, or benefits. It supports partial updates—only include fields that should be updated. Required fields must still be present for validation.
     **Token scopes**: `contracts:write`
     */
    export async function main(auth: RT.Deel, contract_id: string, body: Body) {
    	const url = new URL(`https://api.letsdeel.com/rest/v2/eor/contract/${contract_id}`)
    
    	const response = await fetch(url, {
    		method: 'PATCH',
    		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: {
    		scope?:
    			| string
    			| {
    					/**
    					 * Scope template UUID.
    					 */
    					scope_template_id?: string
    					/**
    					 * Scope validation UUID.
    					 */
    					scope_validation_id?: string
    					[k: string]: unknown
    			  }
    		/**
    		 * Annual salary amount
    		 */
    		salary: number
    		/**
    		 * Array of employee benefits
    		 */
    		benefits?: {
    			/**
    			 * Benefit plan ID
    			 */
    			plan_id?: string
    			/**
    			 * Indicates if benefit covers all
    			 */
    			cover_all?: boolean
    			/**
    			 * Benefit provider ID
    			 */
    			provider_id?: string
    			/**
    			 * Contribution amount
    			 */
    			contribution?: number
    			/**
    			 * Indicates if benefit covers dependents
    			 */
    			cover_dependents?: boolean
    			[k: string]: unknown
    		}[]
    		/**
    		 * Currency code for salary and benefits
    		 */
    		currency?: string
    		/**
    		 * Employment end date
    		 */
    		end_date?: string
    		/**
    		 * Number of holiday days per year
    		 */
    		holidays?: number
    		/**
    		 * Indicates if compensation is hourly
    		 */
    		is_hourly?: boolean
    		/**
    		 * Job title (cannot be C-level position)
    		 */
    		job_title: string
    		/**
    		 * Indicates if work visa is required
    		 */
    		work_visa?: boolean
    		/**
    		 * Employment start date
    		 */
    		start_date: string
    		/**
    		 * Employee's unique identifier
    		 */
    		employee_id?: string
    		/**
    		 * Hourly rate (required if is_hourly is true)
    		 */
    		hourly_rate?: number
    		/**
    		 * Indicates if this is a resubmission
    		 */
    		is_resubmit?: boolean
    		/**
    		 * Unique identifier for the employee's work schedule
    		 */
    		schedule_id?: string
    		/**
    		 * Seniority level identifier
    		 */
    		seniority_id?: number
    		/**
    		 * Indicates if work pension is included
    		 */
    		work_pension?: boolean
    		/**
    		 * Signing bonus amount
    		 */
    		signing_bonus?: number
    		/**
    		 * Type of time off
    		 */
    		time_off_type?: 'STANDARD' | 'SPECIFIC' | 'PRORATED'
    		/**
    		 * Employee's email address
    		 */
    		employee_email: string
    		/**
    		 * Employee seniority date
    		 */
    		seniority_date?: string
    		/**
    		 * Type of employment
    		 */
    		employment_type: 'Full-time' | 'Part-time'
    		/**
    		 * Number of sick leave days per year
    		 */
    		sick_leave_days?: number
    		/**
    		 * Employee's address information
    		 */
    		employee_address?: {
    			/**
    			 * ZIP/Postal code
    			 */
    			zip?: string
    			/**
    			 * City of residence
    			 */
    			city: string
    			/**
    			 * Phone number
    			 */
    			phone?: string
    			/**
    			 * State of residence
    			 */
    			state?: string
    			/**
    			 * Street address
    			 */
    			street: string
    			/**
    			 * Country of residence (can be country code or name)
    			 */
    			country: string
    			/**
    			 * Province of residence
    			 */
    			province?: string
    			/**
    			 * Country calling code
    			 */
    			calling_code?: string
    			[k: string]: unknown
    		}
    		/**
    		 * State/Province of employment
    		 */
    		employment_state?: string
    		/**
    		 * Objective for hiring
    		 */
    		hiring_objective?:
    			| 'EXPANDING_TO_NEW_COUNTRY'
    			| 'TEMP_EOR_OPENING_ENTITY'
    			| 'ONE_OFF_HIRE'
    			| 'CONVERTING_CONTRACTOR'
    			| 'OTHER'
    		/**
    		 * Probation period duration
    		 */
    		probation_period?: number
    		/**
    		 * Work arrangement type
    		 */
    		work_arrangement?: 'REMOTE' | 'ON_SITE_OR_HYBRID'
    		/**
    		 * Work eligibility documentation
    		 */
    		work_eligibility?: {
    			/**
    			 * Unique identifier for the work eligibility document
    			 */
    			key: string
    			/**
    			 * Name of the work eligibility document file
    			 */
    			file_name: string
    			[k: string]: unknown
    		}
    		/**
    		 * Medical insurance coverage
    		 */
    		medical_insurance?: boolean
    		/**
    		 * Type of contract term
    		 */
    		contract_term_type?: 'DEFINITE' | 'INDEFINITE'
    		/**
    		 * Employee's last name
    		 */
    		employee_last_name: string
    		/**
    		 * Country of employment
    		 */
    		employment_country: string
    		/**
    		 * Type of notice period
    		 */
    		notice_period_type?: 'STANDARD' | 'CUSTOM'
    		/**
    		 * Employee's first name
    		 */
    		employee_first_name: string
    		/**
    		 * Working hours per week
    		 */
    		work_hours_per_week?: number
    		/**
    		 * Employee's nationality
    		 */
    		employee_nationality?: string
    		/**
    		 * Reason for fixed-term contract
    		 */
    		reason_for_fixed_term?:
    			| 'SEASONAL_OR_TEMPORARY_WORK'
    			| 'PROJECT_BASED_EMPLOYMENT'
    			| 'REPLACEMENT_FOR_PERMANENT_STAFF'
    			| 'TRIAL_PERIODS_FOR_NEW_ROLES_OR_BUSINESSES'
    		/**
    		 * Additional quote-specific information
    		 */
    		quote_additional_fields?: {
    			/**
    			 * Type of employee
    			 */
    			employee_type?: 'Employee' | 'Manager'
    			/**
    			 * Required qualifications
    			 */
    			qualifications?: string
    			/**
    			 * German translation of scope
    			 */
    			scope_german_translation?: string
    			/**
    			 * German translation of qualifications
    			 */
    			qualifications_german_translation?: string
    			[k: string]: unknown
    		}
    		/**
    		 * Determines when the signing bonus will be paid out
    		 */
    		signing_bonus_payout_type?:
    			| 'FIRST_CYCLE'
    			| 'AFTER_PROBATION'
    			| 'AFTER_FIRST_CONTRACT_ANNIVERSARY'
    		/**
    		 * Additional information about hiring objective
    		 */
    		hiring_objective_extra_info?: string
    		/**
    		 * Notice period after probation (days)
    		 */
    		notice_period_after_probation?: number
    		/**
    		 * Notice period during probation (days)
    		 */
    		notice_period_during_probation?: number
    		/**
    		 * Auto quote validation status
    		 */
    		is_auto_quote_validation_passed?: boolean
    		/**
    		 * Unit of time for probation period
    		 */
    		probation_period_type_for_definite?: 'CUSTOM' | 'STANDARD'
    		/**
    		 * Allow equipment reimbursement for consultants
    		 */
    		allow_consultant_equipment_reimbursement?: boolean
    		[k: string]: unknown
    	}
    	[k: string]: unknown
    }
    

    Submitted by hugo697 235 days ago