//native
/**
* Enroll an employee in a 401k plan
* Enroll an employee in a 401k plan
**Token scopes**: `benefits:write`
*/
export async function main(
auth: RT.Deel,
id: string,
contract_id: string,
plan_id: string,
body: Body
) {
const url = new URL(
`https://api.letsdeel.com/rest/v2/benefits/legal-entities/${id}/contracts/${contract_id}/plans/${plan_id}`
)
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 {
/**
* Type of the contribution for 401k.
*/
type: 'ROTH' | 'TRAD' | 'LOAN' | 'NEC'
/**
* Object containing additional information about the enrollment.
*/
details?: {
/**
* A key-value pair providing additional details about the enrollment.
*/
key?: string
[k: string]: unknown
}
/**
* Type of contribution.
*/
contribution_type?: 'PERCENTAGE' | 'FIXED_AMOUNT'
/**
* Maximum limit of contribution.
*/
contribution_limit: number
/**
* Value of the contribution.
*/
contribution_value?: number
[k: string]: unknown
}
Submitted by hugo697 235 days ago