type Asana = {
token: string;
};
/**
* Create a story on a task
* Adds a story to a task. This endpoint currently only allows for comment
stories to be created. The comment will be authored by the currently
authenticated user, and timestamped when the server receives the request.
Returns the full record for the new story added to the task.
*/
export async function main(
auth: Asana,
task_gid: string,
opt_pretty: string | undefined,
opt_fields: string | undefined,
body: {
data?: { gid?: string; resource_type?: string; [k: string]: unknown } & {
created_at?: string;
html_text?: string;
is_pinned?: boolean;
resource_subtype?: string;
sticker_name?:
| "green_checkmark"
| "people_dancing"
| "dancing_unicorn"
| "heart"
| "party_popper"
| "people_waving_flags"
| "splashing_narwhal"
| "trophy"
| "yeti_riding_unicorn"
| "celebrating_people"
| "determined_climbers"
| "phoenix_spreading_love";
text?: string;
[k: string]: unknown;
};
[k: string]: unknown;
}
) {
const url = new URL(
`https://app.asana.com/api/1.0/tasks/${task_gid}/stories`
);
for (const [k, v] of [
["opt_pretty", opt_pretty],
["opt_fields", opt_fields],
]) {
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 story on a task
* Adds a story to a task. This endpoint currently only allows for comment
stories to be created. The comment will be authored by the currently
authenticated user, and timestamped when the server receives the request.
Returns the full record for the new story added to the task.
*/
export async function main(
auth: Asana,
task_gid: string,
opt_pretty: string | undefined,
opt_fields: string | undefined,
body: {
data?: { gid?: string; resource_type?: string; [k: string]: unknown } & {
created_at?: string;
html_text?: string;
is_pinned?: boolean;
resource_subtype?: string;
sticker_name?:
| "green_checkmark"
| "people_dancing"
| "dancing_unicorn"
| "heart"
| "party_popper"
| "people_waving_flags"
| "splashing_narwhal"
| "trophy"
| "yeti_riding_unicorn"
| "celebrating_people"
| "determined_climbers"
| "phoenix_spreading_love";
text?: string;
[k: string]: unknown;
};
[k: string]: unknown;
}
) {
const url = new URL(
`https://app.asana.com/api/1.0/tasks/${task_gid}/stories`
);
for (const [k, v] of [
["opt_pretty", opt_pretty],
["opt_fields", opt_fields],
]) {
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