Skip to content

Commit

Permalink
Merge pull request #12 from hidetak/develop
Browse files Browse the repository at this point in the history
Modify for keeping data from trello
  • Loading branch information
hidetak authored Jun 28, 2020
2 parents 997a616 + 9061935 commit d889fc1
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 14 deletions.
68 changes: 55 additions & 13 deletions lib/trello-csv.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,33 @@ class TrelloCSV {
this.LISTS_URL = `https://trello.com/1/boards/$$BOARD_ID$$/lists?fields=name,url&key=${config.KEY}&token=${config.TOKEN}`
this.CARDS_URL = `https://trello.com/1/lists/$$LIST_ID$$/cards?key=${config.KEY}&token=${config.TOKEN}&fields=name,labels,idMembers,desc,shortUrl`
this.ACTIONS_URL = `https://trello.com/1/cards/$$CARD_ID$$/actions?key=${config.KEY}&token=${config.TOKEN}&filter=all`
this.clearRawData()
}

getRawData() {
return {
_boards: this._boards,
_members: this._members,
_lists: this._lists,
_cards: this._cards,
_actions: this._actions,
}
}

setRawData(datas) {
this._boards = datas._boards
this._members = datas._members
this._lists = datas._lists
this._cards = datas._cards
this._actions = datas._actions
}

clearRawData() {
this._boards = null
this._members = {}
this._lists = {}
this._cards = {}
this._actions = {}
}

async _getDataFromTrello(url) {
Expand All @@ -28,31 +55,46 @@ class TrelloCSV {
}

async loadBoards() {
return this._getDataFromTrello(this.BOARDS_URL)
if (!this._boards) {
this._boards = await this._getDataFromTrello(this.BOARDS_URL)
}
return this._boards
}

async loadMember(memberId) {
return this._getDataFromTrello(
this.MEMBERS_URL.replace('$$MEMBER_ID$$', memberId)
)
if (!this._members[memberId]) {
this._members[memberId] = await this._getDataFromTrello(
this.MEMBERS_URL.replace('$$MEMBER_ID$$', memberId)
)
}
return this._members[memberId]
}

async loadLists(boardId) {
return this._getDataFromTrello(
this.LISTS_URL.replace('$$BOARD_ID$$', boardId)
)
if (!this._lists[boardId]) {
this._lists[boardId] = await this._getDataFromTrello(
this.LISTS_URL.replace('$$BOARD_ID$$', boardId)
)
}
return this._lists[boardId]
}

async loadCards(listId) {
return this._getDataFromTrello(
this.CARDS_URL.replace('$$LIST_ID$$', listId)
)
if (!this._cards[listId]) {
this._cards[listId] = await this._getDataFromTrello(
this.CARDS_URL.replace('$$LIST_ID$$', listId)
)
}
return this._cards[listId]
}

async loadActions(cardId) {
return this._getDataFromTrello(
this.ACTIONS_URL.replace('$$CARD_ID$$', cardId)
)
if (!this._actions[cardId]) {
this._actions[cardId] = await this._getDataFromTrello(
this.ACTIONS_URL.replace('$$CARD_ID$$', cardId)
)
}
return this._actions[cardId]
}

async parseBoard(board) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "trello-csv",
"version": "1.1.0",
"version": "1.2.3",
"description": "",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit d889fc1

Please sign in to comment.