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, order_id: nil, event_id: nil) ⇒ OriginalEventData

Returns a new instance of OriginalEventData.

Parameters:

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


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

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

Instance Attribute Details

#event_idObject

A unique string chosen by the advertiser.



36
37
38
# File 'lib/facebook_ads/ad_objects/server_side/original_event_data.rb', line 36

def event_id
  @event_id
end

#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

#order_idObject

The order ID for this transaction as a string.



33
34
35
# File 'lib/facebook_ads/ad_objects/server_side/original_event_data.rb', line 33

def order_id
  @order_id
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.



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

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

#build(attributes = {}) ⇒ Object

build the object using the input hash

Parameters:

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

    attributes in the form of hash



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/facebook_ads/ad_objects/server_side/original_event_data.rb', line 59

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

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

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

#eql?(o) ⇒ Boolean

Returns:

  • (Boolean)

See Also:

  • `==` method


93
94
95
# File 'lib/facebook_ads/ad_objects/server_side/original_event_data.rb', line 93

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



99
100
101
102
103
# File 'lib/facebook_ads/ad_objects/server_side/original_event_data.rb', line 99

def hash
  [
    event_name, event_time, order_id, event_id,
  ].hash
end

#normalizeObject

Normalize input fields to server request format.



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/facebook_ads/ad_objects/server_side/original_event_data.rb', line 124

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

#to_sObject



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/facebook_ads/ad_objects/server_side/original_event_data.rb', line 105

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