Class: FacebookAds::ServerSide::OriginalEventData

Inherits:
Object
  • Object
show all
Defined in:
lib/facebook_ads/ad_objects/server_side/original_event_data.rb

Overview

OriginalEventData contains original event info used for attribution passback event or generalized value optimization(GVO).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event_name: nil, event_time: nil) ⇒ OriginalEventData

Returns a new instance of OriginalEventData.

Parameters:

  • event_name (String) (defaults to: nil)
  • event_time (int) (defaults to: nil)


34
35
36
37
38
39
40
41
# File 'lib/facebook_ads/ad_objects/server_side/original_event_data.rb', line 34

def initialize(event_name: nil, event_time: nil)
  unless event_name.nil?
    self.event_name = event_name
  end
  unless event_time.nil?
    self.event_time = event_time
  end
end

Instance Attribute Details

#event_nameObject

A Facebook pixel Standard Event or Custom Event name. This is used with event_id to determine if events are identical.



27
28
29
# File 'lib/facebook_ads/ad_objects/server_side/original_event_data.rb', line 27

def event_name
  @event_name
end

#event_timeObject

A Unix timestamp in seconds indicating when the original event occurred.



30
31
32
# File 'lib/facebook_ads/ad_objects/server_side/original_event_data.rb', line 30

def event_time
  @event_time
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.



61
62
63
64
65
66
# File 'lib/facebook_ads/ad_objects/server_side/original_event_data.rb', line 61

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      event_name == o.event_name &&
      event_time == o.event_time
end

#build(attributes = {}) ⇒ Object

build the object using the input hash

Parameters:

  • attributes (Hash) (defaults to: {})

    attributes in the form of hash



45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/facebook_ads/ad_objects/server_side/original_event_data.rb', line 45

def build(attributes = {})
  return unless attributes.is_a?(Hash)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }

  if attributes.has_key?(:'event_name')
    self.event_name = attributes[:'event_name']
  end

  if attributes.has_key?(:'event_time')
    self.event_time = attributes[:'event_time']
  end
end

#eql?(o) ⇒ Boolean

Returns:

  • (Boolean)

See Also:

  • `==` method


69
70
71
# File 'lib/facebook_ads/ad_objects/server_side/original_event_data.rb', line 69

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



75
76
77
78
79
# File 'lib/facebook_ads/ad_objects/server_side/original_event_data.rb', line 75

def hash
  [
    event_name, event_time,
  ].hash
end

#normalizeObject

Normalize input fields to server request format.



94
95
96
97
98
99
100
101
102
103
# File 'lib/facebook_ads/ad_objects/server_side/original_event_data.rb', line 94

def normalize
  hash = {}
  unless event_name.nil?
    hash['event_name'] = event_name
  end
  unless event_time.nil?
    hash['event_time'] = event_time
  end
  hash
end

#to_sObject



81
82
83
84
85
86
87
88
89
90
# File 'lib/facebook_ads/ad_objects/server_side/original_event_data.rb', line 81

def to_s
  hash = {}
  unless event_name.nil?
    hash['event_name'] = event_name
  end
  unless event_time.nil?
    hash['event_time'] = event_time
  end
  hash.to_s
end