/
trello_adapter.rb
52 lines (44 loc) · 1.09 KB
/
trello_adapter.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
require "trello"
=begin
* Created by PSU Beeminder Capstone Team on 3/12/2017.
* Copyright (c) 2017 PSU Beeminder Capstone Team
* This code is available under the "MIT License".
* Please see the file LICENSE in this distribution for license terms.
=end
class TrelloAdapter < BaseAdapter
class << self
def required_keys
%i(token secret)
end
def auth_type
:oauth
end
def website_link
"https://trello.com"
end
def title
"Trello"
end
end
def client
Trello::Client.new(
consumer_key: Rails.application.secrets.trello_provider_key,
consumer_secret: Rails.application.secrets.trello_provider_key,
oauth_token: access_token,
oauth_token_secret: access_secret
)
end
def cards(list_ids)
list_ids.flat_map do |list_id|
client.find(:list, list_id).cards.map(&:itself)
end
end
def list_options
client.find(:member, uid).boards(filter: :open).flat_map do |b|
b.lists.map do |list|
joined_name = [b.name, list.name].join("/")
[joined_name, list.id]
end
end
end
end