type Trello = {
key: string;
token: string;
};
/**
* Update a Card
* Update a card. Query parameters may also be replaced with a JSON request body instead.
*/
export async function main(
auth: Trello,
id: string,
name: string | undefined,
desc: string | undefined,
closed: string | undefined,
idMembers: string | undefined,
idAttachmentCover: string | undefined,
idList: string | undefined,
idLabels: string | undefined,
idBoard: string | undefined,
pos: string | undefined,
due: string | undefined,
start: string | undefined,
dueComplete: string | undefined,
subscribed: string | undefined,
address: string | undefined,
locationName: string | undefined,
coordinates: string | undefined,
cover: string | undefined
) {
const url = new URL(`https://api.trello.com/1/cards/${id}`);
for (const [k, v] of [
["name", name],
["desc", desc],
["closed", closed],
["idMembers", idMembers],
["idAttachmentCover", idAttachmentCover],
["idList", idList],
["idLabels", idLabels],
["idBoard", idBoard],
["pos", pos],
["due", due],
["start", start],
["dueComplete", dueComplete],
["subscribed", subscribed],
["address", address],
["locationName", locationName],
["coordinates", coordinates],
["cover", cover],
["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 399 days ago
type Trello = {
key: string;
token: string;
};
/**
* Update a Card
* Update a card. Query parameters may also be replaced with a JSON request body instead.
*/
export async function main(
auth: Trello,
id: string,
name: string | undefined,
desc: string | undefined,
closed: string | undefined,
idMembers: string | undefined,
idAttachmentCover: string | undefined,
idList: string | undefined,
idLabels: string | undefined,
idBoard: string | undefined,
pos: string | undefined,
due: string | undefined,
start: string | undefined,
dueComplete: string | undefined,
subscribed: string | undefined,
address: string | undefined,
locationName: string | undefined,
coordinates: string | undefined,
cover: string | undefined
) {
const url = new URL(`https://api.trello.com/1/cards/${id}`);
for (const [k, v] of [
["name", name],
["desc", desc],
["closed", closed],
["idMembers", idMembers],
["idAttachmentCover", idAttachmentCover],
["idList", idList],
["idLabels", idLabels],
["idBoard", idBoard],
["pos", pos],
["due", due],
["start", start],
["dueComplete", dueComplete],
["subscribed", subscribed],
["address", address],
["locationName", locationName],
["coordinates", coordinates],
["cover", cover],
["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