type Trello = {
key: string;
token: string;
};
/**
* Update a checkItem on a Card
* Update an item in a checklist on a card.
*/
export async function main(
auth: Trello,
id: string,
idCheckItem: string,
name: string | undefined,
state: "complete" | "incomplete" | undefined,
idChecklist: string | undefined,
pos: string | undefined,
due: string | undefined,
dueReminder: string | undefined,
idMember: string | undefined
) {
const url = new URL(
`https://api.trello.com/1/cards/${id}/checkItem/${idCheckItem}`
);
for (const [k, v] of [
["name", name],
["state", state],
["idChecklist", idChecklist],
["pos", pos],
["due", due],
["dueReminder", dueReminder],
["idMember", idMember],
["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 398 days ago
type Trello = {
key: string;
token: string;
};
/**
* Update a checkItem on a Card
* Update an item in a checklist on a card.
*/
export async function main(
auth: Trello,
id: string,
idCheckItem: string,
name: string | undefined,
state: "complete" | "incomplete" | undefined,
idChecklist: string | undefined,
pos: string | undefined,
due: string | undefined,
dueReminder: string | undefined,
idMember: string | undefined
) {
const url = new URL(
`https://api.trello.com/1/cards/${id}/checkItem/${idCheckItem}`
);
for (const [k, v] of [
["name", name],
["state", state],
["idChecklist", idChecklist],
["pos", pos],
["due", due],
["dueReminder", dueReminder],
["idMember", idMember],
["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