Class: Trellodon::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/trellodon/client.rb

Defined Under Namespace

Classes: DeletedMember

Instance Method Summary collapse

Constructor Details

#initialize(api_key:, api_token:, logger: Config.logger) ⇒ Client

Returns a new instance of Client.



15
16
17
18
19
20
21
22
# File 'lib/trellodon/client.rb', line 15

def initialize(api_key:, api_token:, logger: Config.logger)
  @logger = logger
  @client = Trello::Client.new(
    developer_public_key: api_key,
    member_token: api_token
  )
  @members = Concurrent::Map.new
end

Instance Method Details

#fetch_board(board_id) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/trellodon/client.rb', line 24

def fetch_board(board_id)
  retrying do
    board = @client.find(:boards, board_id)

    Board.new(
      id: board.id,
      name: board.name,
      lists: lists_from(board),
      card_ids: @client.find_many(Trello::Card, "/boards/#{board_id}/cards", fields: "id").map(&:id),
      last_activity_date: board.last_activity_date
    )
  end
end

#fetch_card(card_id) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/trellodon/client.rb', line 38

def fetch_card(card_id)
  retrying do
    card = @client.find(:cards, card_id)

    Card.new(
      id: card.id,
      name: card.name,
      desc: card.desc,
      labels: card.labels.map(&:name),
      list_id: card.list_id,
      comments: comments_from(card),
      attachments: attachments_from(card),
      checklists: checklists_from(card),
      last_activity_date: card.last_activity_date
    )
  end
end