//native
type Clickup = {
token: string;
};
/**
* Get time entries within a date range
* View time entries filtered by start and end date. \
\
By default, this endpoint returns time entries from the last 30 days created by the authenticated user. \
\
To retrieve time entries for other users, you must include the `assignee` query parameter. \
\
Only one of the following location filters can be included at a time: `space_id`, `folder_id`, `list_id`, or `task_id`. \
\
***Note:** A time entry that has a negative duration means that timer is currently running for that user.*
*/
export async function main(
auth: Clickup,
team_Id: string,
start_date: string | undefined,
end_date: string | undefined,
assignee: string | undefined,
include_task_tags: string | undefined,
include_location_names: string | undefined,
include_approval_history: string | undefined,
include_approval_details: string | undefined,
space_id: string | undefined,
folder_id: string | undefined,
list_id: string | undefined,
task_id: string | undefined,
custom_task_ids: string | undefined,
team_id: string | undefined,
is_billable: string | undefined,
Content_Type: string,
) {
const url = new URL(
`https://api.clickup.com/api/v2/team/${team_Id}/time_entries`,
);
for (const [k, v] of [
["start_date", start_date],
["end_date", end_date],
["assignee", assignee],
["include_task_tags", include_task_tags],
["include_location_names", include_location_names],
["include_approval_history", include_approval_history],
["include_approval_details", include_approval_details],
["space_id", space_id],
["folder_id", folder_id],
["list_id", list_id],
["task_id", task_id],
["custom_task_ids", custom_task_ids],
["team_id", team_id],
["is_billable", is_billable],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
"Content-Type": Content_Type,
Authorization: auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago