type Trello = {
key: string;
token: string;
};
/**
* Update Multiple Custom Field items on Card
* Setting, updating, and removing the values for multiple Custom Fields on a card. For more details on updating custom fields check out the Getting Started With Custom Fields
*/
export async function main(
auth: Trello,
body: {
customFieldItems?: {
idCustomField?: { [k: string]: unknown };
value?: {
text?: string;
checked?: boolean;
date?: string;
number?: number;
[k: string]: unknown;
};
idValue?: { [k: string]: unknown };
[k: string]: unknown;
}[];
[k: string]: unknown;
}
) {
const url = new URL(`https://api.trello.com/1/cards/${idCard}/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: "PUT",
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.text();
}
Submitted by hugo697 398 days ago
type Trello = {
key: string;
token: string;
};
/**
* Update Multiple Custom Field items on Card
* Setting, updating, and removing the values for multiple Custom Fields on a card. For more details on updating custom fields check out the Getting Started With Custom Fields
*/
export async function main(
auth: Trello,
body: {
customFieldItems?: {
idCustomField?: { [k: string]: unknown };
value?: {
text?: string;
checked?: boolean;
date?: string;
number?: number;
[k: string]: unknown;
};
idValue?: { [k: string]: unknown };
[k: string]: unknown;
}[];
[k: string]: unknown;
}
) {
const url = new URL(`https://api.trello.com/1/cards/${idCard}/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: "PUT",
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.text();
}
Submitted by hugo697 826 days ago
type Trello = {
key: string;
token: string;
};
/**
* Update Multiple Custom Field items on Card
* Setting, updating, and removing the values for multiple Custom Fields on a card. For more details on updating custom fields check out the [Getting Started With Custom Fields](/cloud/trello/guides/rest-api/getting-started-with-custom-fields/)
*/
export async function main(
auth: Trello,
body: {
customFieldItems?: {
idCustomField?: { [k: string]: unknown };
value?: {
text?: string;
checked?: boolean;
date?: string;
number?: number;
[k: string]: unknown;
};
idValue?: { [k: string]: unknown };
[k: string]: unknown;
}[];
[k: string]: unknown;
}
) {
const url = new URL(`https://api.trello.com/1/cards/${idCard}/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: "PUT",
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.text();
}
Submitted by hugo697 953 days ago