Class: Preact::Event

Inherits:
ApiObject show all
Defined in:
lib/preact/objects/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ApiObject

#initialize

Constructor Details

This class inherits a constructor from Preact::ApiObject

Instance Attribute Details

#accountObject

Returns the value of attribute account.



3
4
5
# File 'lib/preact/objects/event.rb', line 3

def 
  @account
end

#external_identifierObject

Returns the value of attribute external_identifier.



5
6
7
# File 'lib/preact/objects/event.rb', line 5

def external_identifier
  @external_identifier
end

#extrasObject

Returns the value of attribute extras.



5
6
7
# File 'lib/preact/objects/event.rb', line 5

def extras
  @extras
end

Returns the value of attribute link_url.



6
7
8
# File 'lib/preact/objects/event.rb', line 6

def link_url
  @link_url
end

Returns the value of attribute links.



5
6
7
# File 'lib/preact/objects/event.rb', line 5

def links
  @links
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/preact/objects/event.rb', line 3

def name
  @name
end

#noteObject

Returns the value of attribute note.



5
6
7
# File 'lib/preact/objects/event.rb', line 5

def note
  @note
end

#revenueObject

Returns the value of attribute revenue.



5
6
7
# File 'lib/preact/objects/event.rb', line 5

def revenue
  @revenue
end

#target_idObject

Returns the value of attribute target_id.



5
6
7
# File 'lib/preact/objects/event.rb', line 5

def target_id
  @target_id
end

#thumb_urlObject

Returns the value of attribute thumb_url.



6
7
8
# File 'lib/preact/objects/event.rb', line 6

def thumb_url
  @thumb_url
end

#timestampObject

Returns the value of attribute timestamp.



3
4
5
# File 'lib/preact/objects/event.rb', line 3

def timestamp
  @timestamp
end

Instance Method Details



8
9
10
11
# File 'lib/preact/objects/event.rb', line 8

def add_link(name, href)
  self.links ||= []
  self.links << ActionLink.new({ :name => name, :href => href })
end

#as_json(options = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/preact/objects/event.rb', line 13

def as_json(options={})
  {
    :klass     => "actionevent",
    :name      => self.name,
    :timestamp => self.timestamp,
    :account   => self.,
    :revenue   => self.revenue,
    :source    => Preact.configuration.user_agent, # version of this logging library

    :note      => self.note,
    :external_identifier => self.target_id || self.external_identifier,
    :extras    => self.extras,
    :links     => self.links.nil? ? nil : self.links.as_json,
    :thumb_url => self.thumb_url,
    :link_url  => self.link_url
  }
end