class Nutrella::TaskBoard

Knows how to use the Trello API to create and lookup task boards.

Public Class Methods

new(configuration) click to toggle source
# File lib/nutrella/task_board.rb, line 10
def initialize(configuration)
  Trello.configure do |trello_client|
    trello_client.consumer_key = configuration.fetch(:key)
    trello_client.consumer_secret = configuration.fetch(:secret)
    trello_client.oauth_token = configuration.fetch(:token)
    trello_client.oauth_token_secret = configuration.fetch(:secret)
  end

  @organization = configuration.fetch(:organization)
end

Public Instance Methods

lookup_or_create(board_name) click to toggle source
# File lib/nutrella/task_board.rb, line 21
def lookup_or_create(board_name)
  lookup(board_name) || create(board_name)
end

Private Instance Methods

create(board_name) click to toggle source
# File lib/nutrella/task_board.rb, line 35
def create(board_name)
  Trello::Board.create(name: board_name, organization_id: @organization, visibility_level: "org")
end
lookup(board_name) click to toggle source
# File lib/nutrella/task_board.rb, line 27
def lookup(board_name)
  matching_boards(board_name).find { |board| board.name == board_name }
end
matching_boards(board_name) click to toggle source
# File lib/nutrella/task_board.rb, line 31
def matching_boards(board_name)
  Trello::Action.search(board_name, modelTypes: "boards", board_fields: "all").fetch("boards", [])
end