Edits history of script submission #15669 for ' Update raw shift (deel)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Update raw shift
     * Update specific fields of an existing raw shift by its unique `external_id`. This includes shift meta details, description etc.
     **Token scopes**: `time-tracking:write`
     */
    export async function main(auth: RT.Deel, external_id: string, body: Body) {
    	const url = new URL(`https://api.letsdeel.com/rest/v2/time_tracking/shifts/raw/${external_id}`)
    
    	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.
     */
    
    export interface Body {
    	data: {
    		meta?: {
    			end?: {
    				/**
    				 * End date
    				 */
    				date?: string
    				/**
    				 * End time
    				 */
    				time?: string
    				/**
    				 * Is rest day
    				 */
    				is_rest_day?: boolean
    				/**
    				 * Is public holiday
    				 */
    				is_public_holiday?: boolean
    				[k: string]: unknown
    			}
    			start?: {
    				/**
    				 * Start date
    				 */
    				date?: string
    				/**
    				 * Start time
    				 */
    				time?: string
    				/**
    				 * Is rest day
    				 */
    				is_rest_day?: boolean
    				/**
    				 * Is public holiday
    				 */
    				is_public_holiday?: boolean
    				[k: string]: unknown
    			}
    			breaks?: {
    				end?: {
    					/**
    					 * Break end date
    					 */
    					date?: string
    					/**
    					 * Break end time
    					 */
    					time?: string
    					[k: string]: unknown
    				}
    				start?: {
    					/**
    					 * Break start date
    					 */
    					date?: string
    					/**
    					 * Break start time
    					 */
    					time?: string
    					[k: string]: unknown
    				}
    				/**
    				 * Is break paid
    				 */
    				is_paid?: boolean
    				[k: string]: unknown
    			}[]
    			/**
    			 * Approval date
    			 */
    			approval_date?: string
    			[k: string]: unknown
    		}
    		/**
    		 * Description of the shift.
    		 */
    		description?: string
    		/**
    		 * The date of the shift.
    		 */
    		date_of_work?: string
    		[k: string]: unknown
    	}
    	[k: string]: unknown
    }
    

    Submitted by hugo697 235 days ago