//native
/**
* Create shifts
* Creates multiple time tracking shifts for a contract, supporting both regular shift submissions and corrections that adjust hours for previously processed shifts.
**Token scopes**: `time-tracking:write`
*/
export async function main(auth: RT.Deel, body: Body) {
const url = new URL(`https://api.letsdeel.com/rest/v2/time_tracking/shifts`)
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: {
shifts: (
| RegularShiftRECOMMENDED
| CorrectionAbsoluteShiftRECOMMENDED
| CorrectionDeltaShiftRECOMMENDED
| RegularShiftNOTRECOMMENDEDLEGACY
| CorrectionAbsoluteShiftNOTRECOMMENDEDLEGACY
| CorrectionDeltaShiftNOTRECOMMENDEDLEGACY
)[]
/**
* The unique identifier of the employee contract.
*/
contract_id: string
[k: string]: unknown
}
[k: string]: unknown
}
export interface RegularShiftRECOMMENDED {
summary: {
/**
* Time unit
*/
time_unit: 'HOUR' | 'MONTH' | 'DAY' | 'WEEK'
/**
* Time amount
*/
time_amount: number
/**
* Shift Rate external ID
*/
shift_rate_external_id: string
[k: string]: unknown
}
/**
* Type of the shift
*/
shift_type?: 'REGULAR'
/**
* Description of the shift.
*/
description: string
/**
* External ID of the shift.
*/
external_id: string
/**
* Date of shift work
*/
date_of_work: string
payroll_cycle_ref?: {
/**
* Date in ISO 8601 format that helps referencing a payroll cycle
*/
date: string
[k: string]: unknown
}
[k: string]: unknown
}
export interface CorrectionAbsoluteShiftRECOMMENDED {
summary: {
/**
* Time amount
*/
time_amount: number
[k: string]: unknown
}
/**
* Type of the shift
*/
shift_type: 'CORRECTION_ABSOLUTE'
/**
* Description of the correction shift.
*/
description: string
/**
* External ID of the correction shift.
*/
external_id: string
payroll_cycle_ref?: {
/**
* Date in ISO 8601 format that helps referencing a payroll cycle
*/
date: string
[k: string]: unknown
}
/**
* External ID of the original shift being corrected
*/
shift_reference_id: string
[k: string]: unknown
}
export interface CorrectionDeltaShiftRECOMMENDED {
/**
* Type of the shift
*/
shift_type: 'CORRECTION_DELTA'
corrections: {
/**
* Type of correction
*/
type: 'SUBTRACTION' | 'ADDITION'
/**
* Time amount
*/
time_amount: number
[k: string]: unknown
}[]
/**
* Description of the correction shift.
*/
description: string
/**
* External ID of the correction shift.
*/
external_id: string
payroll_cycle_ref?: {
/**
* Date in ISO 8601 format that helps referencing a payroll cycle
*/
date: string
[k: string]: unknown
}
/**
* External ID of the original shift being corrected
*/
shift_reference_id: string
[k: string]: unknown
}
export interface RegularShiftNOTRECOMMENDEDLEGACY {
summary: {
/**
* Total break hours
*/
total_break_hours?: number
/**
* Payable break hours
*/
payable_break_hours?: number
/**
* Total payable hours
*/
total_payable_hours: number
/**
* Shift duration hours
*/
shift_duration_hours?: number
/**
* Shift Rate external ID
*/
shift_rate_external_id: string
[k: string]: unknown
}
/**
* Type of the shift
*/
shift_type?: 'REGULAR'
/**
* Description of the shift.
*/
description: string
/**
* External ID of the shift.
*/
external_id: string
/**
* Date of shift work
*/
date_of_work: string
payroll_cycle_ref?: {
/**
* Date in ISO 8601 format that helps referencing a payroll cycle
*/
date: string
[k: string]: unknown
}
[k: string]: unknown
}
export interface CorrectionAbsoluteShiftNOTRECOMMENDEDLEGACY {
summary: {
/**
* Absolute total break hours
*/
total_break_hours?: number
/**
* Absolute payable break hours
*/
payable_break_hours?: number
/**
* Absolute total payable hours
*/
total_payable_hours: number
/**
* Absolute shift duration hours
*/
shift_duration_hours?: number
[k: string]: unknown
}
/**
* Type of the shift
*/
shift_type: 'CORRECTION_ABSOLUTE'
/**
* Description of the correction shift.
*/
description: string
/**
* External ID of the correction shift.
*/
external_id: string
payroll_cycle_ref?: {
/**
* Date in ISO 8601 format that helps referencing a payroll cycle
*/
date: string
[k: string]: unknown
}
/**
* External ID of the original shift being corrected
*/
shift_reference_id: string
[k: string]: unknown
}
export interface CorrectionDeltaShiftNOTRECOMMENDEDLEGACY {
/**
* Type of the shift
*/
shift_type: 'CORRECTION_DELTA'
corrections: {
/**
* Type of correction
*/
type: string
/**
* Break hours to add or subtract
*/
total_break_hours?: number
/**
* Payable break hours to add or subtract
*/
payable_break_hours?: number
/**
* Payable hours to add or subtract
*/
total_payable_hours?: number
/**
* Shift duration hours to add or subtract
*/
shift_duration_hours?: number
}[]
/**
* Description of the correction shift.
*/
description: string
/**
* External ID of the correction shift.
*/
external_id: string
payroll_cycle_ref?: {
/**
* Date in ISO 8601 format that helps referencing a payroll cycle
*/
date: string
[k: string]: unknown
}
/**
* External ID of the original shift being corrected
*/
shift_reference_id: string
[k: string]: unknown
}
Submitted by hugo697 235 days ago