type Trello = {
key: string;
token: string;
};
/**
* Update blocked notification keys of Member on a channel
* Update blocked notification keys of Member on a specific channel
*/
export async function main(
auth: Trello,
id: string,
channel: "email",
blockedKeys:
| "notification_comment_card"
| "notification_added_a_due_date"
| "notification_changed_due_date"
| "notification_card_due_soon"
| "notification_removed_from_card"
| "notification_added_attachment_to_card"
| "notification_created_card"
| "notification_moved_card"
| "notification_archived_card"
| "notification_unarchived_card"
) {
const url = new URL(
`https://api.trello.com/1/members/${id}/notificationsChannelSettings/${channel}/${blockedKeys}`
);
for (const [k, v] of [
["key", auth.key],
["token", auth.token],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "PUT",
headers: {
Authorization: undefined,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 398 days ago
type Trello = {
key: string;
token: string;
};
/**
* Update blocked notification keys of Member on a channel
* Update blocked notification keys of Member on a specific channel
*/
export async function main(
auth: Trello,
id: string,
channel: "email",
blockedKeys:
| "notification_comment_card"
| "notification_added_a_due_date"
| "notification_changed_due_date"
| "notification_card_due_soon"
| "notification_removed_from_card"
| "notification_added_attachment_to_card"
| "notification_created_card"
| "notification_moved_card"
| "notification_archived_card"
| "notification_unarchived_card"
) {
const url = new URL(
`https://api.trello.com/1/members/${id}/notificationsChannelSettings/${channel}/${blockedKeys}`
);
for (const [k, v] of [
["key", auth.key],
["token", auth.token],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "PUT",
headers: {
Authorization: undefined,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 953 days ago