type Asana = {
token: string;
};
/**
* Update a goal
* An existing goal can be updated by making a PUT request on the URL for
that goal. Only the fields provided in the `data` block will be updated;
any unspecified fields will remain unchanged.
Returns the complete updated goal record.
*/
export async function main(
auth: Asana,
goal_gid: string,
opt_pretty: string | undefined,
opt_fields: string | undefined,
body: {
data?: ({ gid?: string; resource_type?: string; [k: string]: unknown } & {
due_on?: string;
html_notes?: string;
is_workspace_level?: boolean;
liked?: boolean;
name?: string;
notes?: string;
start_on?: string;
status?: string;
[k: string]: unknown;
}) & {
followers?: string[];
owner?: string;
team?: string;
time_period?: string;
workspace?: string;
[k: string]: unknown;
};
[k: string]: unknown;
}
) {
const url = new URL(`https://app.asana.com/api/1.0/goals/${goal_gid}`);
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: "PUT",
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;
};
/**
* Update a goal
* An existing goal can be updated by making a PUT request on the URL for
that goal. Only the fields provided in the `data` block will be updated;
any unspecified fields will remain unchanged.
Returns the complete updated goal record.
*/
export async function main(
auth: Asana,
goal_gid: string,
opt_pretty: string | undefined,
opt_fields: string | undefined,
body: {
data?: ({ gid?: string; resource_type?: string; [k: string]: unknown } & {
due_on?: string;
html_notes?: string;
is_workspace_level?: boolean;
liked?: boolean;
name?: string;
notes?: string;
start_on?: string;
status?: string;
[k: string]: unknown;
}) & {
followers?: string[];
owner?: string;
team?: string;
time_period?: string;
workspace?: string;
[k: string]: unknown;
};
[k: string]: unknown;
}
) {
const url = new URL(`https://app.asana.com/api/1.0/goals/${goal_gid}`);
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: "PUT",
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