Class: Trello::Comment

Inherits:
BasicData show all
Defined in:
lib/trello/comment.rb

Overview

A Comment is a string with a creation date; it resides inside a Card and belongs to a User.

Instance Attribute Summary collapse

Attributes inherited from BasicData

#client

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BasicData

#==, client, create, #initialize, many, one, parse, parse_many, path_name, #refresh!, register_attributes, save

Methods included from JsonUtils

included

Constructor Details

This class inherits a constructor from Trello::BasicData

Instance Attribute Details

#action_idString (readonly)



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
53
54
55
56
57
58
59
60
61
# File 'lib/trello/comment.rb', line 12

class Comment < BasicData
  register_attributes :action_id, :text, :date, :member_creator_id,
    readonly: [ :action_id, :text, :date, :member_creator_id ]
  validates_presence_of :action_id, :text, :date, :member_creator_id
  validates_length_of   :text,        in: 1..16384

  class << self
    # Locate a specific action and return a new Comment object.
    def find(action_id)
      client.find(:action, action_id, filter: commentCard)
    end
  end

  # Update the attributes of a Comment
  #
  # Supply a hash of string keyed data retrieved from the Trello API representing
  # a Comment.
  def update_fields(fields)
    attributes[:action_id]          = fields['id'] || attributes[:action_id]
    attributes[:text]               = fields['data']['text'] || attributes[:text]
    attributes[:date]               = Time.iso8601(fields['date']) if fields.has_key?('date')
    attributes[:member_creator_id]  = fields['idMemberCreator'] || attributes[:member_creator_id]
    self
  end

  # Returns the board this comment is located
  def board
    Board.from_response client.get("/actions/#{action_id}/board")
  end

  # Returns the card the comment is located
  def card
    Card.from_response client.get("/actions/#{action_id}/card")
  end

  # Returns the list the comment is located
  def list
    List.from_response client.get("/actions/#{action_id}/list")
  end

  # Deletes the comment from the card
  def delete
    ruta = "/actions/#{action_id}"
    client.delete(ruta)
  end


  # Returns the member who created the comment.
  one :member_creator, via: Member, path: :members, using: :member_creator_id
end

#dateDatetime (readonly)



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
53
54
55
56
57
58
59
60
61
# File 'lib/trello/comment.rb', line 12

class Comment < BasicData
  register_attributes :action_id, :text, :date, :member_creator_id,
    readonly: [ :action_id, :text, :date, :member_creator_id ]
  validates_presence_of :action_id, :text, :date, :member_creator_id
  validates_length_of   :text,        in: 1..16384

  class << self
    # Locate a specific action and return a new Comment object.
    def find(action_id)
      client.find(:action, action_id, filter: commentCard)
    end
  end

  # Update the attributes of a Comment
  #
  # Supply a hash of string keyed data retrieved from the Trello API representing
  # a Comment.
  def update_fields(fields)
    attributes[:action_id]          = fields['id'] || attributes[:action_id]
    attributes[:text]               = fields['data']['text'] || attributes[:text]
    attributes[:date]               = Time.iso8601(fields['date']) if fields.has_key?('date')
    attributes[:member_creator_id]  = fields['idMemberCreator'] || attributes[:member_creator_id]
    self
  end

  # Returns the board this comment is located
  def board
    Board.from_response client.get("/actions/#{action_id}/board")
  end

  # Returns the card the comment is located
  def card
    Card.from_response client.get("/actions/#{action_id}/card")
  end

  # Returns the list the comment is located
  def list
    List.from_response client.get("/actions/#{action_id}/list")
  end

  # Deletes the comment from the card
  def delete
    ruta = "/actions/#{action_id}"
    client.delete(ruta)
  end


  # Returns the member who created the comment.
  one :member_creator, via: Member, path: :members, using: :member_creator_id
end

#member_creator_idString (readonly)



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
53
54
55
56
57
58
59
60
61
# File 'lib/trello/comment.rb', line 12

class Comment < BasicData
  register_attributes :action_id, :text, :date, :member_creator_id,
    readonly: [ :action_id, :text, :date, :member_creator_id ]
  validates_presence_of :action_id, :text, :date, :member_creator_id
  validates_length_of   :text,        in: 1..16384

  class << self
    # Locate a specific action and return a new Comment object.
    def find(action_id)
      client.find(:action, action_id, filter: commentCard)
    end
  end

  # Update the attributes of a Comment
  #
  # Supply a hash of string keyed data retrieved from the Trello API representing
  # a Comment.
  def update_fields(fields)
    attributes[:action_id]          = fields['id'] || attributes[:action_id]
    attributes[:text]               = fields['data']['text'] || attributes[:text]
    attributes[:date]               = Time.iso8601(fields['date']) if fields.has_key?('date')
    attributes[:member_creator_id]  = fields['idMemberCreator'] || attributes[:member_creator_id]
    self
  end

  # Returns the board this comment is located
  def board
    Board.from_response client.get("/actions/#{action_id}/board")
  end

  # Returns the card the comment is located
  def card
    Card.from_response client.get("/actions/#{action_id}/card")
  end

  # Returns the list the comment is located
  def list
    List.from_response client.get("/actions/#{action_id}/list")
  end

  # Deletes the comment from the card
  def delete
    ruta = "/actions/#{action_id}"
    client.delete(ruta)
  end


  # Returns the member who created the comment.
  one :member_creator, via: Member, path: :members, using: :member_creator_id
end

#textString (readonly)



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
53
54
55
56
57
58
59
60
61
# File 'lib/trello/comment.rb', line 12

class Comment < BasicData
  register_attributes :action_id, :text, :date, :member_creator_id,
    readonly: [ :action_id, :text, :date, :member_creator_id ]
  validates_presence_of :action_id, :text, :date, :member_creator_id
  validates_length_of   :text,        in: 1..16384

  class << self
    # Locate a specific action and return a new Comment object.
    def find(action_id)
      client.find(:action, action_id, filter: commentCard)
    end
  end

  # Update the attributes of a Comment
  #
  # Supply a hash of string keyed data retrieved from the Trello API representing
  # a Comment.
  def update_fields(fields)
    attributes[:action_id]          = fields['id'] || attributes[:action_id]
    attributes[:text]               = fields['data']['text'] || attributes[:text]
    attributes[:date]               = Time.iso8601(fields['date']) if fields.has_key?('date')
    attributes[:member_creator_id]  = fields['idMemberCreator'] || attributes[:member_creator_id]
    self
  end

  # Returns the board this comment is located
  def board
    Board.from_response client.get("/actions/#{action_id}/board")
  end

  # Returns the card the comment is located
  def card
    Card.from_response client.get("/actions/#{action_id}/card")
  end

  # Returns the list the comment is located
  def list
    List.from_response client.get("/actions/#{action_id}/list")
  end

  # Deletes the comment from the card
  def delete
    ruta = "/actions/#{action_id}"
    client.delete(ruta)
  end


  # Returns the member who created the comment.
  one :member_creator, via: Member, path: :members, using: :member_creator_id
end

Class Method Details

.find(action_id) ⇒ Object

Locate a specific action and return a new Comment object.



20
21
22
# File 'lib/trello/comment.rb', line 20

def find(action_id)
  client.find(:action, action_id, filter: commentCard)
end

Instance Method Details

#boardObject

Returns the board this comment is located



38
39
40
# File 'lib/trello/comment.rb', line 38

def board
  Board.from_response client.get("/actions/#{action_id}/board")
end

#cardObject

Returns the card the comment is located



43
44
45
# File 'lib/trello/comment.rb', line 43

def card
  Card.from_response client.get("/actions/#{action_id}/card")
end

#deleteObject

Deletes the comment from the card



53
54
55
56
# File 'lib/trello/comment.rb', line 53

def delete
  ruta = "/actions/#{action_id}"
  client.delete(ruta)
end

#listObject

Returns the list the comment is located



48
49
50
# File 'lib/trello/comment.rb', line 48

def list
  List.from_response client.get("/actions/#{action_id}/list")
end

#update_fields(fields) ⇒ Object

Update the attributes of a Comment

Supply a hash of string keyed data retrieved from the Trello API representing a Comment.



29
30
31
32
33
34
35
# File 'lib/trello/comment.rb', line 29

def update_fields(fields)
  attributes[:action_id]          = fields['id'] || attributes[:action_id]
  attributes[:text]               = fields['data']['text'] || attributes[:text]
  attributes[:date]               = Time.iso8601(fields['date']) if fields.has_key?('date')
  attributes[:member_creator_id]  = fields['idMemberCreator'] || attributes[:member_creator_id]
  self
end