lib/trello_wrapper.rb in trollolo-0.0.9 vs lib/trello_wrapper.rb in trollolo-0.0.10
- old
+ new
@@ -14,38 +14,28 @@
#
# 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
+class TrelloWrapper < TrelloService
+ def board(board_id)
+ @board ||= ScrumBoard.new(retrieve_board_data(board_id), @settings)
end
def client
- Trello::Client.new(
+ @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"))
+ JSON.parse(get_board(board_id))
end
def backup(board_id)
- client.get("/boards/#{board_id}?lists=open&cards=open&card_checklists=all")
+ get_board(board_id)
end
def organization(org_id)
Trello::Organization.find(org_id)
end
@@ -86,15 +76,11 @@
def set_name(card_id, name)
client.put("/cards/#{card_id}/name?value=#{name}")
end
- private
+ def get_board(board_id)
+ raise TrolloloError.new("Board id cannot be blank") if board_id.blank?
- def init_trello
- Trello.configure do |config|
- config.developer_public_key = @settings.developer_public_key
- config.member_token = @settings.member_token
- end
+ client.get("/boards/#{board_id}?lists=open&cards=open&card_checklists=all")
end
-
end