export type PostV2UsersUserIdTimeEntries = {billable?: boolean | undefined, note?: string | undefined, project_id: number, start_time: string, tracked: number, task_id?: number | undefined}; export type CreateApiV2UsersUserIdTimeEntriesArgs = {user_id: number, body: PostV2UsersUserIdTimeEntries}; export type CreateApiV2UsersUserIdTimeEntriesOptions = {baseUrl?: string | undefined, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create time entry * * POST /v2/users/{user_id}/time_entries */ export const createApiV2UsersUserIdTimeEntries = async (args: CreateApiV2UsersUserIdTimeEntriesArgs, options?: CreateApiV2UsersUserIdTimeEntriesOptions) => { const {baseUrl = "https://api.hubstaff.com", fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/v2/users/${encodeURIComponent(String(args.user_id))}/time_entries${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };