//native
/**
* Update time-off request
* Update time-off request
**Token scopes**: `time-off:write`
*/
export async function main(auth: RT.Deel, time_off_id: string, body: Body) {
const url = new URL(`https://api.letsdeel.com/rest/v2/time_offs/${time_off_id}`)
const formData = new FormData()
for (const [k, v] of Object.entries(body)) {
if (v !== undefined && v !== '') {
formData.append(k, String(v))
}
}
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.
*/
/**
* Time off update request data
*/
export interface Body {
/**
* Time off update request data
*/
data?: {
/**
* The dates breakdown for the time off request.
*/
dates?: {
date: string | string
/**
* The amount taken in hours during this specific date. It can not exceed the maximum allowed hours for the date.
*/
hours?: number
/**
* The amount of time off requested for the date. It must be in the same time unit as in the total amount for the time off request.
*/
amount?: number
/**
* The type of day for the time off request. All dates must follow the same type.
*/
day_type?: 'HALF_DAY' | 'FULL_DAY' | 'PERCENTAGE' | 'HOURLY'
[k: string]: unknown
}[]
/**
* Reason for taking time off. This is complementary information for the time-off description. Useful to provide sub categories for the same policy.
*/
reason?: string
/**
* Whether the time off is paid or unpaid. By default it follows the policy configuration.
*/
is_paid?: boolean
end_date: string
/**
* The time off policy id. Can be used in place of time_off_type_id
*/
policy_id?: string
start_date: string
/**
* Description of the time off request. Some policies require that a description is provided.
*/
description?: string
/**
* Contract id. This is the id of the contract associated with the time off request.
*/
contract_oid?: string
/**
* Details of the event associated with the time off request. Required for event based policies such as parental leave.
*/
event_details?: {
/**
* The birth date of the child. This is used for parental leave requests.
*/
birth_date: string
/**
* The date of adoption. This is used for parental leave requests.
*/
adoption_date?: string
/**
* Whether the event date are a confirmed or not. This is used for parental leave requests when either the birth date or adoption date are not estimated anymore but actually confirmed.
*/
is_confirmation?: boolean
/**
* Whether the birth was premature or not. This is used for parental leave requests.
*/
was_premature_birth: boolean
/**
* Whether the birth was multiple or not. This is used for parental leave requests.
*/
had_multiple_children: boolean
[k: string]: unknown
}
/**
* Deduction amount. Available for independent contractor's policies
*/
deduction_amount?: number
/**
* The time off type id. Required when policy_id is not provided
*/
time_off_type_id?: string
/**
* The time off event id. This is used to link the time off request to an event.
*/
time_off_event_id?: string
/**
* This is the percentage of time off taken. This is used when the time off request is a percentage.
*/
time_off_percentage?: number
/**
* The hris profile id of the recipient
*/
recipient_profile_id: string
/**
* Description of the time off type. This is used when the policy is OTHER.
*/
other_type_description?: string
[k: string]: unknown
}
[k: string]: unknown
}
Submitted by hugo697 235 days ago