Sha256: 6df95c3ed14750805dccb2a51a4ba33d5a10335cc511a9e5f1f67b3a4e131124

Contents?: true

Size: 1.63 KB

Versions: 2

Compression:

Stored size: 1.63 KB

Contents

#  Copyright (c) 2013-2014 SUSE LLC
#
#  This program is free software; you can redistribute it and/or
#  modify it under the terms of version 3 of the GNU General Public License as
#  published by the Free Software Foundation.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.   See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, contact SUSE LLC.
#
#  To contact SUSE about this file by physical or electronic mail,
#  you may find current contact information at www.suse.com
require 'trello'

class TrelloWrapper

  attr_accessor :board

  def initialize(settings)
    @settings = settings
    init_trello
  end

  def client
    Trello::Client.new(
      developer_public_key: @settings.developer_public_key,
      member_token: @settings.member_token
    )
  end

  def board(board_id)
    return @board if @board

    @board = ScrumBoard.new(retrieve_board_data(board_id), @settings)
  end

  def retrieve_board_data(board_id)
    JSON.parse(client.get("/boards/#{board_id}?lists=open&cards=open&card_checklists=all"))
  end

  def backup(board_id)
    client.get("/boards/#{board_id}?lists=open&cards=open&card_checklists=all")
  end

  def organization(org_id)
    Trello::Organization.find(org_id)
  end

  private

  def init_trello
    Trello.configure do |config|
      config.developer_public_key = @settings.developer_public_key
      config.member_token         = @settings.member_token
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
trollolo-0.0.5 lib/trello_wrapper.rb
trollolo-0.0.4 lib/trello_wrapper.rb