Skip to content

Commit

Permalink
feat: fetch custom fields
Browse files Browse the repository at this point in the history
  • Loading branch information
coderbyheart committed Jun 24, 2019
1 parent 649ba84 commit dba5e37
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/trello/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,25 @@ export type Card = {
badges: {
attachments: number
}
customFieldItems?: CustomFieldItem[]
attachments?: Attachment[]
}

// https://developers.trello.com/docs/getting-started-custom-fields#section-custom-field-values-on-cards
export type CustomFieldItem = {
id: string
value: {
text?: string
number?: string
date?: string
checked?: 'true'
list?: string[]
}
idCustomField: string
idModel: string
modelType: 'card' | 'board'
}

export type Attachment = {
id: string
bytes: number
Expand Down Expand Up @@ -59,7 +75,8 @@ export const trelloApi = ({
options,
)

const query = (args: { res: string }) => f(args).then(res => res.json())
const query = (args: { res: string; query?: { [key: string]: any } }) =>
f(args).then(res => res.json())

const del = (args: { res: string }) =>
f({
Expand All @@ -75,7 +92,12 @@ export const trelloApi = ({
return {
lists: {
cards: ({ list }: { list: string }) =>
query({ res: `lists/${list}/cards` }) as Promise<Card[]>,
query({
res: `lists/${list}/cards`,
query: {
customFieldItems: true,
},
}) as Promise<Card[]>,
},
tokens: {
token: ({ token }: { token: string }) => ({
Expand Down

0 comments on commit dba5e37

Please sign in to comment.