type Asana = {
token: string;
};
/**
* Get multiple portfolio memberships
* Returns a list of portfolio memberships in compact representation. You must specify `portfolio`, `portfolio` and `user`, or `workspace` and `user`.
*/
export async function main(
auth: Asana,
portfolio: string | undefined,
workspace: string | undefined,
user: string | undefined,
opt_pretty: string | undefined,
opt_fields: string | undefined,
limit: string | undefined,
offset: string | undefined
) {
const url = new URL(`https://app.asana.com/api/1.0/portfolio_memberships`);
for (const [k, v] of [
["portfolio", portfolio],
["workspace", workspace],
["user", user],
["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: "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 388 days ago