type Asana = {
token: string;
};
/**
* Get goals
* Returns compact goal records.
*/
export async function main(
auth: Asana,
opt_pretty: string | undefined,
opt_fields: string | undefined,
limit: string | undefined,
offset: string | undefined,
portfolio: string | undefined,
project: string | undefined,
is_workspace_level: string | undefined,
team: string | undefined,
workspace: string | undefined,
time_periods: string | undefined
) {
const url = new URL(`https://app.asana.com/api/1.0/goals`);
for (const [k, v] of [
["opt_pretty", opt_pretty],
["opt_fields", opt_fields],
["limit", limit],
["offset", offset],
["portfolio", portfolio],
["project", project],
["is_workspace_level", is_workspace_level],
["team", team],
["workspace", workspace],
["time_periods", time_periods],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + 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 383 days ago
type Asana = {
token: string;
};
/**
* Get goals
* Returns compact goal records.
*/
export async function main(
auth: Asana,
opt_pretty: string | undefined,
opt_fields: string | undefined,
limit: string | undefined,
offset: string | undefined,
portfolio: string | undefined,
project: string | undefined,
is_workspace_level: string | undefined,
team: string | undefined,
workspace: string | undefined,
time_periods: string | undefined
) {
const url = new URL(`https://app.asana.com/api/1.0/goals`);
for (const [k, v] of [
["opt_pretty", opt_pretty],
["opt_fields", opt_fields],
["limit", limit],
["offset", offset],
["portfolio", portfolio],
["project", project],
["is_workspace_level", is_workspace_level],
["team", team],
["workspace", workspace],
["time_periods", time_periods],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + 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 937 days ago