type Trello = {
key: string;
token: string;
};
/**
* Create a new Custom Field on a Board
* Create a new Custom Field on a board.
*/
export async function main(
auth: Trello,
body: {
idModel: string;
modelType: "board";
name: string;
type: "checkbox" | "list" | "number" | "text" | "date";
options?: string;
pos: ("top" | "bottom") | number;
display_cardFront?: boolean;
[k: string]: unknown;
}
) {
const url = new URL(`https://api.trello.com/1/customFields`);
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: "POST",
headers: {
"Content-Type": "application/json",
Authorization: undefined,
},
body: JSON.stringify(body),
});
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 Custom Field on a Board
* Create a new Custom Field on a board.
*/
export async function main(
auth: Trello,
body: {
idModel: string;
modelType: "board";
name: string;
type: "checkbox" | "list" | "number" | "text" | "date";
options?: string;
pos: ("top" | "bottom") | number;
display_cardFront?: boolean;
[k: string]: unknown;
}
) {
const url = new URL(`https://api.trello.com/1/customFields`);
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: "POST",
headers: {
"Content-Type": "application/json",
Authorization: undefined,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 953 days ago