Created
October 19, 2020 23:46
-
-
Save jorgeatorres/854fe02d03cefbca72301246f581160c to your computer and use it in GitHub Desktop.
Read Trello cards using Ruby (based on my "Videogames" board)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'trello' | |
require 'json' | |
require 'base64' | |
require 'open-uri' | |
Trello.configure do |config| | |
config.developer_public_key = 'KEY' | |
config.member_token = 'TOKEN' | |
end | |
board = Trello::Board.find('BOARD_ID') | |
videogames = [] | |
board.lists.each do |list| | |
list.cards.each do |card| | |
result = {} | |
result['title'] = card.name | |
result['description'] = card.desc | |
result['list'] = list.name | |
result['image'] = Base64.encode64(URI.open(card.cover_image.url).read()) | |
result['tags'] = [] | |
# Labels. | |
card.labels.each do |label| | |
result['tags'].push(label.name) | |
end | |
# Custom Fields. | |
card.custom_field_items.each do |custom_field_item| | |
result[custom_field_item.custom_field.name] = custom_field_item.option_value | |
end | |
# URL. | |
card.attachments.each do |attachment| | |
if attachment.mime_type.empty? | |
result['url'] = attachment.url | |
end | |
end | |
puts result['title'] | |
videogames.push(result) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment