Class: Trello::Action

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

Overview

Action represents some event that occurred. For instance, when a card is created.

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

#dataHash (readonly)



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
62
63
64
65
66
67
# File 'lib/trello/action.rb', line 16

class Action < BasicData
  register_attributes :id, :type, :data, :date, :member_creator_id, :member_participant,
    readonly: [ :id, :type, :data, :date, :member_creator_id, :member_participant ]
  validates_presence_of :id, :type, :date, :member_creator_id

  class << self
    # Locate a specific action and return a new Action object.
    def find(id, params = {})
      client.find(:action, id, params)
    end

    def search(query, opts={})
      response = client.get("/search/", { query: query }.merge(opts))
      parse_json(response).except("options").each_with_object({}) do |(key, data), result|
        klass = "Trello::#{key.singularize.capitalize}".constantize
        result[key] = klass.from_json(data)
      end
    end
  end

  # Update the attributes of an action
  #
  # Supply a hash of string keyed data retrieved from the Trello API representing
  # an Action.
  def update_fields(fields)
    attributes[:id]                 = fields['id']
    attributes[:type]               = fields['type']
    attributes[:data]               = fields['data']
    attributes[:date]               = Time.iso8601(fields['date'])
    attributes[:member_creator_id]  = fields['idMemberCreator']
    attributes[:member_participant] = fields['member']
    self
  end

  # Returns the board this action occurred on.
  def board
    Board.from_response client.get("/actions/#{id}/board")
  end

  # Returns the card the action occurred on.
  def card
    Card.from_response client.get("/actions/#{id}/card")
  end

  # Returns the list the action occurred on.
  def list
    List.from_response client.get("/actions/#{id}/list")
  end

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

#dateDatetime (readonly)



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
62
63
64
65
66
67
# File 'lib/trello/action.rb', line 16

class Action < BasicData
  register_attributes :id, :type, :data, :date, :member_creator_id, :member_participant,
    readonly: [ :id, :type, :data, :date, :member_creator_id, :member_participant ]
  validates_presence_of :id, :type, :date, :member_creator_id

  class << self
    # Locate a specific action and return a new Action object.
    def find(id, params = {})
      client.find(:action, id, params)
    end

    def search(query, opts={})
      response = client.get("/search/", { query: query }.merge(opts))
      parse_json(response).except("options").each_with_object({}) do |(key, data), result|
        klass = "Trello::#{key.singularize.capitalize}".constantize
        result[key] = klass.from_json(data)
      end
    end
  end

  # Update the attributes of an action
  #
  # Supply a hash of string keyed data retrieved from the Trello API representing
  # an Action.
  def update_fields(fields)
    attributes[:id]                 = fields['id']
    attributes[:type]               = fields['type']
    attributes[:data]               = fields['data']
    attributes[:date]               = Time.iso8601(fields['date'])
    attributes[:member_creator_id]  = fields['idMemberCreator']
    attributes[:member_participant] = fields['member']
    self
  end

  # Returns the board this action occurred on.
  def board
    Board.from_response client.get("/actions/#{id}/board")
  end

  # Returns the card the action occurred on.
  def card
    Card.from_response client.get("/actions/#{id}/card")
  end

  # Returns the list the action occurred on.
  def list
    List.from_response client.get("/actions/#{id}/list")
  end

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

#idString (readonly)



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
62
63
64
65
66
67
# File 'lib/trello/action.rb', line 16

class Action < BasicData
  register_attributes :id, :type, :data, :date, :member_creator_id, :member_participant,
    readonly: [ :id, :type, :data, :date, :member_creator_id, :member_participant ]
  validates_presence_of :id, :type, :date, :member_creator_id

  class << self
    # Locate a specific action and return a new Action object.
    def find(id, params = {})
      client.find(:action, id, params)
    end

    def search(query, opts={})
      response = client.get("/search/", { query: query }.merge(opts))
      parse_json(response).except("options").each_with_object({}) do |(key, data), result|
        klass = "Trello::#{key.singularize.capitalize}".constantize
        result[key] = klass.from_json(data)
      end
    end
  end

  # Update the attributes of an action
  #
  # Supply a hash of string keyed data retrieved from the Trello API representing
  # an Action.
  def update_fields(fields)
    attributes[:id]                 = fields['id']
    attributes[:type]               = fields['type']
    attributes[:data]               = fields['data']
    attributes[:date]               = Time.iso8601(fields['date'])
    attributes[:member_creator_id]  = fields['idMemberCreator']
    attributes[:member_participant] = fields['member']
    self
  end

  # Returns the board this action occurred on.
  def board
    Board.from_response client.get("/actions/#{id}/board")
  end

  # Returns the card the action occurred on.
  def card
    Card.from_response client.get("/actions/#{id}/card")
  end

  # Returns the list the action occurred on.
  def list
    List.from_response client.get("/actions/#{id}/list")
  end

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

#member_creator_idString (readonly)



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
62
63
64
65
66
67
# File 'lib/trello/action.rb', line 16

class Action < BasicData
  register_attributes :id, :type, :data, :date, :member_creator_id, :member_participant,
    readonly: [ :id, :type, :data, :date, :member_creator_id, :member_participant ]
  validates_presence_of :id, :type, :date, :member_creator_id

  class << self
    # Locate a specific action and return a new Action object.
    def find(id, params = {})
      client.find(:action, id, params)
    end

    def search(query, opts={})
      response = client.get("/search/", { query: query }.merge(opts))
      parse_json(response).except("options").each_with_object({}) do |(key, data), result|
        klass = "Trello::#{key.singularize.capitalize}".constantize
        result[key] = klass.from_json(data)
      end
    end
  end

  # Update the attributes of an action
  #
  # Supply a hash of string keyed data retrieved from the Trello API representing
  # an Action.
  def update_fields(fields)
    attributes[:id]                 = fields['id']
    attributes[:type]               = fields['type']
    attributes[:data]               = fields['data']
    attributes[:date]               = Time.iso8601(fields['date'])
    attributes[:member_creator_id]  = fields['idMemberCreator']
    attributes[:member_participant] = fields['member']
    self
  end

  # Returns the board this action occurred on.
  def board
    Board.from_response client.get("/actions/#{id}/board")
  end

  # Returns the card the action occurred on.
  def card
    Card.from_response client.get("/actions/#{id}/card")
  end

  # Returns the list the action occurred on.
  def list
    List.from_response client.get("/actions/#{id}/list")
  end

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

#member_participantObject (readonly)



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
62
63
64
65
66
67
# File 'lib/trello/action.rb', line 16

class Action < BasicData
  register_attributes :id, :type, :data, :date, :member_creator_id, :member_participant,
    readonly: [ :id, :type, :data, :date, :member_creator_id, :member_participant ]
  validates_presence_of :id, :type, :date, :member_creator_id

  class << self
    # Locate a specific action and return a new Action object.
    def find(id, params = {})
      client.find(:action, id, params)
    end

    def search(query, opts={})
      response = client.get("/search/", { query: query }.merge(opts))
      parse_json(response).except("options").each_with_object({}) do |(key, data), result|
        klass = "Trello::#{key.singularize.capitalize}".constantize
        result[key] = klass.from_json(data)
      end
    end
  end

  # Update the attributes of an action
  #
  # Supply a hash of string keyed data retrieved from the Trello API representing
  # an Action.
  def update_fields(fields)
    attributes[:id]                 = fields['id']
    attributes[:type]               = fields['type']
    attributes[:data]               = fields['data']
    attributes[:date]               = Time.iso8601(fields['date'])
    attributes[:member_creator_id]  = fields['idMemberCreator']
    attributes[:member_participant] = fields['member']
    self
  end

  # Returns the board this action occurred on.
  def board
    Board.from_response client.get("/actions/#{id}/board")
  end

  # Returns the card the action occurred on.
  def card
    Card.from_response client.get("/actions/#{id}/card")
  end

  # Returns the list the action occurred on.
  def list
    List.from_response client.get("/actions/#{id}/list")
  end

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

#typeString (readonly)



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
62
63
64
65
66
67
# File 'lib/trello/action.rb', line 16

class Action < BasicData
  register_attributes :id, :type, :data, :date, :member_creator_id, :member_participant,
    readonly: [ :id, :type, :data, :date, :member_creator_id, :member_participant ]
  validates_presence_of :id, :type, :date, :member_creator_id

  class << self
    # Locate a specific action and return a new Action object.
    def find(id, params = {})
      client.find(:action, id, params)
    end

    def search(query, opts={})
      response = client.get("/search/", { query: query }.merge(opts))
      parse_json(response).except("options").each_with_object({}) do |(key, data), result|
        klass = "Trello::#{key.singularize.capitalize}".constantize
        result[key] = klass.from_json(data)
      end
    end
  end

  # Update the attributes of an action
  #
  # Supply a hash of string keyed data retrieved from the Trello API representing
  # an Action.
  def update_fields(fields)
    attributes[:id]                 = fields['id']
    attributes[:type]               = fields['type']
    attributes[:data]               = fields['data']
    attributes[:date]               = Time.iso8601(fields['date'])
    attributes[:member_creator_id]  = fields['idMemberCreator']
    attributes[:member_participant] = fields['member']
    self
  end

  # Returns the board this action occurred on.
  def board
    Board.from_response client.get("/actions/#{id}/board")
  end

  # Returns the card the action occurred on.
  def card
    Card.from_response client.get("/actions/#{id}/card")
  end

  # Returns the list the action occurred on.
  def list
    List.from_response client.get("/actions/#{id}/list")
  end

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

Class Method Details

.find(id, params = {}) ⇒ Object

Locate a specific action and return a new Action object.



23
24
25
# File 'lib/trello/action.rb', line 23

def find(id, params = {})
  client.find(:action, id, params)
end

.search(query, opts = {}) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/trello/action.rb', line 27

def search(query, opts={})
  response = client.get("/search/", { query: query }.merge(opts))
  parse_json(response).except("options").each_with_object({}) do |(key, data), result|
    klass = "Trello::#{key.singularize.capitalize}".constantize
    result[key] = klass.from_json(data)
  end
end

Instance Method Details

#boardObject

Returns the board this action occurred on.



51
52
53
# File 'lib/trello/action.rb', line 51

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

#cardObject

Returns the card the action occurred on.



56
57
58
# File 'lib/trello/action.rb', line 56

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

#listObject

Returns the list the action occurred on.



61
62
63
# File 'lib/trello/action.rb', line 61

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

#update_fields(fields) ⇒ Object

Update the attributes of an action

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



40
41
42
43
44
45
46
47
48
# File 'lib/trello/action.rb', line 40

def update_fields(fields)
  attributes[:id]                 = fields['id']
  attributes[:type]               = fields['type']
  attributes[:data]               = fields['data']
  attributes[:date]               = Time.iso8601(fields['date'])
  attributes[:member_creator_id]  = fields['idMemberCreator']
  attributes[:member_participant] = fields['member']
  self
end