type Asana = {
token: string;
};
/**
* Create a status update
* Creates a new status update on an object.
Returns the full record of the newly created status update.
*/
export async function main(
auth: Asana,
opt_pretty: string | undefined,
opt_fields: string | undefined,
limit: string | undefined,
offset: string | undefined,
body: {
data?: (({ gid?: string; resource_type?: string; [k: string]: unknown } & {
resource_subtype?:
| "project_status_update"
| "portfolio_status_update"
| "goal_status_update";
title?: string;
[k: string]: unknown;
}) & {
html_text?: string;
status_type:
| "on_track"
| "at_risk"
| "off_track"
| "on_hold"
| "complete"
| "achieved"
| "partial"
| "missed"
| "dropped";
text: string;
[k: string]: unknown;
}) & { parent: string; [k: string]: unknown };
[k: string]: unknown;
}
) {
const url = new URL(`https://app.asana.com/api/1.0/status_updates`);
for (const [k, v] of [
["opt_pretty", opt_pretty],
["opt_fields", opt_fields],
["limit", limit],
["offset", offset],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
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;
};
/**
* Create a status update
* Creates a new status update on an object.
Returns the full record of the newly created status update.
*/
export async function main(
auth: Asana,
opt_pretty: string | undefined,
opt_fields: string | undefined,
limit: string | undefined,
offset: string | undefined,
body: {
data?: (({ gid?: string; resource_type?: string; [k: string]: unknown } & {
resource_subtype?:
| "project_status_update"
| "portfolio_status_update"
| "goal_status_update";
title?: string;
[k: string]: unknown;
}) & {
html_text?: string;
status_type:
| "on_track"
| "at_risk"
| "off_track"
| "on_hold"
| "complete"
| "achieved"
| "partial"
| "missed"
| "dropped";
text: string;
[k: string]: unknown;
}) & { parent: string; [k: string]: unknown };
[k: string]: unknown;
}
) {
const url = new URL(`https://app.asana.com/api/1.0/status_updates`);
for (const [k, v] of [
["opt_pretty", opt_pretty],
["opt_fields", opt_fields],
["limit", limit],
["offset", offset],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 937 days ago