class StartlingTrello::Api

Public Class Methods

new(developer_public_key:, member_token:) click to toggle source
# File lib/startling_trello/api.rb, line 5
def initialize(developer_public_key:, member_token:)
  @member_token = member_token
  @client = Trello::Client.new(
    developer_public_key: developer_public_key,
    member_token: member_token
  )
end

Public Instance Methods

add_member_to_card(card) click to toggle source
# File lib/startling_trello/api.rb, line 41
def add_member_to_card(card)
  begin
    card.add_member(get_member_from_token)
  rescue Trello::Error
    # Member is already on card
  end
end
find_board(board_id) click to toggle source
# File lib/startling_trello/api.rb, line 29
def find_board(board_id)
  begin
    @client.find(:board, board_id)
  rescue Trello::Error
    abort 'Invalid board id: Board could not be found'
  end
end
find_card(card_id) click to toggle source
# File lib/startling_trello/api.rb, line 13
def find_card(card_id)
  begin
    @client.find(:card, card_id)
  rescue Trello::Error
    abort 'Invalid card id: Card could not be found'
  end
end
find_list(list_id) click to toggle source
# File lib/startling_trello/api.rb, line 21
def find_list(list_id)
  begin
    @client.find(:list, list_id)
  rescue Trello::Error
    abort 'Invalid list id: List could not be found'
  end
end
get_member_from_token() click to toggle source
# File lib/startling_trello/api.rb, line 49
def get_member_from_token
  token = @client.find(:token, @member_token)
  @client.find(:member, token.member_id)
end
move_card_to_list(card:, list:) click to toggle source
# File lib/startling_trello/api.rb, line 37
def move_card_to_list(card:, list:)
  card.move_to_list(list)
end