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

Constructor Details

This class inherits a constructor from Trello::BasicData

Instance Attribute Details

#dataHash (readonly)

Returns:



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
# 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))
      JSON.parse(response).except("options").inject({}) do |res, key|
        res.merge({ key.first => key.last.jsoned_into("Trello::#{key.first.singularize.capitalize}".constantize) })
      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
    client.get("/actions/#{id}/board").json_into(Board)
  end

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

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

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

#dateDatetime (readonly)

Returns:

  • (Datetime)


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
# 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))
      JSON.parse(response).except("options").inject({}) do |res, key|
        res.merge({ key.first => key.last.jsoned_into("Trello::#{key.first.singularize.capitalize}".constantize) })
      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
    client.get("/actions/#{id}/board").json_into(Board)
  end

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

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

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

#idString (readonly)

Returns:



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
# 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))
      JSON.parse(response).except("options").inject({}) do |res, key|
        res.merge({ key.first => key.last.jsoned_into("Trello::#{key.first.singularize.capitalize}".constantize) })
      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
    client.get("/actions/#{id}/board").json_into(Board)
  end

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

  # Returns the list the action occurred on.
  def list
    client.get("/actions/#{id}/list").json_into(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)

Returns:



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
# 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))
      JSON.parse(response).except("options").inject({}) do |res, key|
        res.merge({ key.first => key.last.jsoned_into("Trello::#{key.first.singularize.capitalize}".constantize) })
      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
    client.get("/actions/#{id}/board").json_into(Board)
  end

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

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

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

#member_participantObject (readonly)

Returns:

  • (Object)


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
# 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))
      JSON.parse(response).except("options").inject({}) do |res, key|
        res.merge({ key.first => key.last.jsoned_into("Trello::#{key.first.singularize.capitalize}".constantize) })
      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
    client.get("/actions/#{id}/board").json_into(Board)
  end

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

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

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

#typeString (readonly)

Returns:



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
# 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))
      JSON.parse(response).except("options").inject({}) do |res, key|
        res.merge({ key.first => key.last.jsoned_into("Trello::#{key.first.singularize.capitalize}".constantize) })
      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
    client.get("/actions/#{id}/board").json_into(Board)
  end

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

  # Returns the list the action occurred on.
  def list
    client.get("/actions/#{id}/list").json_into(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
# File 'lib/trello/action.rb', line 27

def search(query, opts={})
  response = client.get("/search/", { query: query }.merge(opts))
  JSON.parse(response).except("options").inject({}) do |res, key|
    res.merge({ key.first => key.last.jsoned_into("Trello::#{key.first.singularize.capitalize}".constantize) })
  end
end

Instance Method Details

#boardObject

Returns the board this action occurred on.



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

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

#cardObject

Returns the card the action occurred on.



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

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

#listObject

Returns the list the action occurred on.



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

def list
  client.get("/actions/#{id}/list").json_into(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.



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

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