type Trello = {
key: string;
token: string;
};
/**
* Update a Label
* Update a label by ID.
*/
export async function main(
auth: Trello,
id: string,
name: string | undefined,
color:
| "yellow"
| "purple"
| "blue"
| "red"
| "green"
| "orange"
| "black"
| "sky"
| "pink"
| "lime"
| undefined
) {
const url = new URL(`https://api.trello.com/1/labels/${id}`);
for (const [k, v] of [
["name", name],
["color", color],
["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.text();
}
Submitted by hugo697 399 days ago
type Trello = {
key: string;
token: string;
};
/**
* Update a Label
* Update a label by ID.
*/
export async function main(
auth: Trello,
id: string,
name: string | undefined,
color:
| "yellow"
| "purple"
| "blue"
| "red"
| "green"
| "orange"
| "black"
| "sky"
| "pink"
| "lime"
| undefined
) {
const url = new URL(`https://api.trello.com/1/labels/${id}`);
for (const [k, v] of [
["name", name],
["color", color],
["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.text();
}
Submitted by hugo697 953 days ago