type Trello = {
key: string;
token: string;
};
/**
* Create a new Card
* Create a new card. Query parameters may also be replaced with a JSON request body instead.
*/
export async function main(
auth: Trello,
name: string | undefined,
desc: string | undefined,
pos: string | undefined,
due: string | undefined,
start: string | undefined,
dueComplete: string | undefined,
idList: string | undefined,
idMembers: string | undefined,
idLabels: string | undefined,
urlSource: string | undefined,
fileSource: string | undefined,
mimeType: string | undefined,
idCardSource: string | undefined,
keepFromSource:
| "all"
| "attachments"
| "checklists"
| "comments"
| "customFields"
| "due"
| "start"
| "labels"
| "members"
| "start"
| "stickers"
| undefined,
address: string | undefined,
locationName: string | undefined,
coordinates: string | undefined
) {
const url = new URL(`https://api.trello.com/1/cards`);
for (const [k, v] of [
["name", name],
["desc", desc],
["pos", pos],
["due", due],
["start", start],
["dueComplete", dueComplete],
["idList", idList],
["idMembers", idMembers],
["idLabels", idLabels],
["urlSource", urlSource],
["fileSource", fileSource],
["mimeType", mimeType],
["idCardSource", idCardSource],
["keepFromSource", keepFromSource],
["address", address],
["locationName", locationName],
["coordinates", coordinates],
["key", auth.key],
["token", auth.token],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "POST",
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;
};
/**
* Create a new Card
* Create a new card. Query parameters may also be replaced with a JSON request body instead.
*/
export async function main(
auth: Trello,
name: string | undefined,
desc: string | undefined,
pos: string | undefined,
due: string | undefined,
start: string | undefined,
dueComplete: string | undefined,
idList: string | undefined,
idMembers: string | undefined,
idLabels: string | undefined,
urlSource: string | undefined,
fileSource: string | undefined,
mimeType: string | undefined,
idCardSource: string | undefined,
keepFromSource:
| "all"
| "attachments"
| "checklists"
| "comments"
| "customFields"
| "due"
| "start"
| "labels"
| "members"
| "start"
| "stickers"
| undefined,
address: string | undefined,
locationName: string | undefined,
coordinates: string | undefined
) {
const url = new URL(`https://api.trello.com/1/cards`);
for (const [k, v] of [
["name", name],
["desc", desc],
["pos", pos],
["due", due],
["start", start],
["dueComplete", dueComplete],
["idList", idList],
["idMembers", idMembers],
["idLabels", idLabels],
["urlSource", urlSource],
["fileSource", fileSource],
["mimeType", mimeType],
["idCardSource", idCardSource],
["keepFromSource", keepFromSource],
["address", address],
["locationName", locationName],
["coordinates", coordinates],
["key", auth.key],
["token", auth.token],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "POST",
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