Skip to content

Commit dba5e37

Browse files
committed
feat: fetch custom fields
1 parent 649ba84 commit dba5e37

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/trello/api.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,25 @@ export type Card = {
88
badges: {
99
attachments: number
1010
}
11+
customFieldItems?: CustomFieldItem[]
1112
attachments?: Attachment[]
1213
}
1314

15+
// https://developers.trello.com/docs/getting-started-custom-fields#section-custom-field-values-on-cards
16+
export type CustomFieldItem = {
17+
id: string
18+
value: {
19+
text?: string
20+
number?: string
21+
date?: string
22+
checked?: 'true'
23+
list?: string[]
24+
}
25+
idCustomField: string
26+
idModel: string
27+
modelType: 'card' | 'board'
28+
}
29+
1430
export type Attachment = {
1531
id: string
1632
bytes: number
@@ -59,7 +75,8 @@ export const trelloApi = ({
5975
options,
6076
)
6177

62-
const query = (args: { res: string }) => f(args).then(res => res.json())
78+
const query = (args: { res: string; query?: { [key: string]: any } }) =>
79+
f(args).then(res => res.json())
6380

6481
const del = (args: { res: string }) =>
6582
f({
@@ -75,7 +92,12 @@ export const trelloApi = ({
7592
return {
7693
lists: {
7794
cards: ({ list }: { list: string }) =>
78-
query({ res: `lists/${list}/cards` }) as Promise<Card[]>,
95+
query({
96+
res: `lists/${list}/cards`,
97+
query: {
98+
customFieldItems: true,
99+
},
100+
}) as Promise<Card[]>,
79101
},
80102
tokens: {
81103
token: ({ token }: { token: string }) => ({

0 commit comments

Comments
 (0)