Edits history of script submission #15374 for ' Create 401k plan for legal entity (deel)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Create 401k plan for legal entity
     * Create a new 401k plan for existing provider to legal entity
     **Token scopes**: `benefits:write`
     */
    export async function main(auth: RT.Deel, id: string, body: Body) {
    	const url = new URL(`https://api.letsdeel.com/rest/v2/benefits/legal-entities/${id}/401k/plans`)
    
    	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.
     */
    
    /**
     * Schema for the 401K Guideline Plan request body.
     */
    export interface Body {
    	/**
    	 * Name of the 401K plan.
    	 */
    	name: string
    	/**
    	 * Object containing additional information about the 401K plan.
    	 */
    	details?: {
    		/**
    		 * A key-value pair providing additional details about the plan.
    		 */
    		key?: string
    		[k: string]: unknown
    	}
    	/**
    	 * Start date of the plan.
    	 */
    	start_date: string
    	/**
    	 * Type of contribution for the 401K plan.
    	 */
    	contribution_type: 'PERCENTAGE' | 'NEC_PERCENTAGE' | 'NEC_FIXED_AMOUNT' | 'FIXED_AMOUNT' | 'MATCH'
    	/**
    	 * Value of the contribution if type is percent or amount.
    	 */
    	contribution_value?: number
    	/**
    	 * Array of objects containing limits and rates for match rate contribution type.
    	 */
    	contribution_value_for_match_rate?: {
    		/**
    		 * Rate of matching contribution.
    		 */
    		rate: number
    		/**
    		 * Limit up to which the match rate is applicable.
    		 */
    		limit: number
    		[k: string]: unknown
    	}[]
    	[k: string]: unknown
    }
    

    Submitted by hugo697 235 days ago