//native
type Holded = {
apiKey: string;
};
/**
* List times
* List time trackings in projects not archived from 18 months on
*/
export async function main(
auth: Holded,
start: string | undefined,
end: string | undefined,
archived: string | undefined,
) {
const url = new URL(`https://api.holded.com/api/projects/v1/projects/times`);
for (const [k, v] of [
["start", start],
["end", end],
["archived", archived],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
key: auth.apiKey,
},
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