Class: TrelloFlow::Api::Card

Inherits:
Base
  • Object
show all
Defined in:
lib/trello_flow/api/card.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

configure, #position

Class Method Details

.fieldsObject



6
7
8
# File 'lib/trello_flow/api/card.rb', line 6

def self.fields
  [:name]
end

.find_by_url(url) ⇒ Object



10
11
12
13
# File 'lib/trello_flow/api/card.rb', line 10

def self.find_by_url(url)
  card = Card.new(url: url)
  find(card.short_link)
end

Instance Method Details

#acceptObject



23
24
25
# File 'lib/trello_flow/api/card.rb', line 23

def accept
  move_to board.lists.accepted
end

#add_label(label) ⇒ Object



32
33
34
# File 'lib/trello_flow/api/card.rb', line 32

def add_label(label)
  self.class.request(:post, "cards/#{id}/idLabels", value: label.id)
end

#add_member(user) ⇒ Object



27
28
29
30
# File 'lib/trello_flow/api/card.rb', line 27

def add_member(user)
  return if member_ids.include?(user.id)
  self.class.request(:post, "cards/#{id}/members", value: user.id)
end

#attach(url:) ⇒ Object



36
37
38
# File 'lib/trello_flow/api/card.rb', line 36

def attach(url:)
  self.class.request(:post, "cards/#{id}/attachments", url: url)
end

#finishObject



19
20
21
# File 'lib/trello_flow/api/card.rb', line 19

def finish
  move_to board.lists.finished
end


40
41
42
# File 'lib/trello_flow/api/card.rb', line 40

def short_link
  url.scan(/\/c\/(.+)\//).flatten.first
end

#short_urlObject



44
45
46
# File 'lib/trello_flow/api/card.rb', line 44

def short_url
  attributes[:shortUrl]
end

#startObject



15
16
17
# File 'lib/trello_flow/api/card.rb', line 15

def start
  move_to board.lists.started
end

#to_paramObject



48
49
50
# File 'lib/trello_flow/api/card.rb', line 48

def to_param
  name.parameterize[0..50]
end