Edits history of script submission #15404 for ' Create an immigration case (deel)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Create an immigration case
     * Create an immigration case.
     **Token scopes**: `immigration:write`
     */
    export async function main(auth: RT.Deel, body: Body) {
    	const url = new URL(`https://api.letsdeel.com/rest/v2/immigration/client/cases`)
    
    	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?:
    		| RightToWorkCase
    		| EORVisaCase
    		| SponsoredVisaCase
    		| PreHireEORVisaCase
    		| PreHireSponsorshipVisaCase
    	[k: string]: unknown
    }
    export interface RightToWorkCase {
    	/**
    	 * The type of immigration case to be created. Determines the workflow and requirements
    	 */
    	case_type: 'RIGHT_TO_WORK'
    	/**
    	 * The contract object identifier. Required for document reviews and visa applications
    	 */
    	contract_id: string
    	/**
    	 * ISO 3166-1 alpha-2 country code where the immigration case needs to be processed
    	 */
    	country_code: string
    	[k: string]: unknown
    }
    export interface EORVisaCase {
    	/**
    	 * The type of immigration case to be created. Determines the workflow and requirements
    	 */
    	case_type: 'EOR_VISA'
    	/**
    	 * The contract object identifier. Required for document reviews and visa applications
    	 */
    	contract_id: string
    	/**
    	 * ISO 3166-1 alpha-2 country code where the immigration case needs to be processed
    	 */
    	country_code: string
    	/**
    	 * The id of visa type that is being applied for. Identifies the type of the visa.
    	 */
    	visa_type_id?: string
    	[k: string]: unknown
    }
    export interface SponsoredVisaCase {
    	/**
    	 * The type of immigration case to be created. Determines the workflow and requirements
    	 */
    	case_type: 'SPONSORED_VISA'
    	/**
    	 * The unique identifier of the entity sponsoring the visa. Required for sponsored visa applications
    	 */
    	entity_id: string
    	/**
    	 * The contract object identifier. Required for document reviews and visa applications
    	 */
    	contract_id: string
    	/**
    	 * ISO 3166-1 alpha-2 country code where the immigration case needs to be processed
    	 */
    	country_code: string
    	/**
    	 * The id of visa type that is being applied for. Identifies the type of the visa.
    	 */
    	visa_type_id?: string
    	[k: string]: unknown
    }
    export interface PreHireEORVisaCase {
    	team_id: string
    	/**
    	 * The type of immigration case to be created. Determines the workflow and requirements
    	 */
    	case_type: 'PRE_HIRE_EOR_VISA'
    	/**
    	 * ISO 3166-1 alpha-2 country code where the immigration case needs to be processed
    	 */
    	country_code: string
    	/**
    	 * The id of visa type that is being applied for. Identifies the type of the visa.
    	 */
    	visa_type_id?: string
    	[k: string]: unknown
    }
    export interface PreHireSponsorshipVisaCase {
    	team_id: string
    	/**
    	 * The type of immigration case to be created. Determines the workflow and requirements
    	 */
    	case_type: 'PRE_HIRE_SPONSORSHIP_VISA'
    	/**
    	 * The unique identifier of the entity sponsoring the visa. Required for sponsored visa applications
    	 */
    	entity_id?: string
    	/**
    	 * ISO 3166-1 alpha-2 country code where the immigration case needs to be processed
    	 */
    	country_code: string
    	/**
    	 * The id of visa type that is being applied for. Identifies the type of the visa.
    	 */
    	visa_type_id?: string
    	[k: string]: unknown
    }
    

    Submitted by hugo697 235 days ago