Class: FacebookAds::ServerSide::Event
- Inherits:
-
Object
- Object
- FacebookAds::ServerSide::Event
- Defined in:
- lib/facebook_ads/ad_objects/server_side/event.rb
Overview
Server Side Event object.
Instance Attribute Summary collapse
-
#custom_data ⇒ Object
An Object that includes additional business data about the event.
-
#event_id ⇒ Object
This ID can be any unique string chosen by the advertiser.
-
#event_name ⇒ Object
A Facebook pixel Standard Event or Custom Event name.
-
#event_source_url ⇒ Object
The browser URL where the event happened.
-
#event_time ⇒ Object
A Unix timestamp in seconds indicating when the actual event occurred.
-
#opt_out ⇒ Object
A flag that indicates we should not use this event for ads delivery optimization.
-
#user_data ⇒ Object
An Object that contains user data.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
-
#build(attributes = {}) ⇒ Object
build the object using the input hash.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Fixnum
Calculates hash code according to all attributes.
-
#initialize(event_name: nil, event_time: nil, event_source_url: nil, opt_out: nil, event_id: nil, user_data: nil, custom_data: nil) ⇒ Event
constructor
A new instance of Event.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#normalize ⇒ Object
Normalize input fields to server request format.
- #to_s ⇒ Object
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Constructor Details
#initialize(event_name: nil, event_time: nil, event_source_url: nil, opt_out: nil, event_id: nil, user_data: nil, custom_data: nil) ⇒ Event
Returns a new instance of Event.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/facebook_ads/ad_objects/server_side/event.rb', line 63 def initialize(event_name: nil, event_time: nil, event_source_url: nil, opt_out: nil, event_id: nil, user_data: nil, custom_data: nil) unless event_name.nil? self.event_name = event_name end unless event_time.nil? self.event_time = event_time end unless event_source_url.nil? self.event_source_url = event_source_url end unless opt_out.nil? self.opt_out = opt_out end unless event_id.nil? self.event_id = event_id end unless user_data.nil? self.user_data = user_data end unless custom_data.nil? self.custom_data = custom_data end end |
Instance Attribute Details
#custom_data ⇒ Object
An Object that includes additional business data about the event.
53 54 55 |
# File 'lib/facebook_ads/ad_objects/server_side/event.rb', line 53 def custom_data @custom_data end |
#event_id ⇒ Object
This ID can be any unique string chosen by the advertiser. event_id is used to deduplicate events sent by both Facebook Pixel and Server-Side API. event_name is also used in the deduplication process. For deduplication, the eventID from Facebook pixel must match the event_id in the corresponding Server-Side API event.
47 48 49 |
# File 'lib/facebook_ads/ad_objects/server_side/event.rb', line 47 def event_id @event_id end |
#event_name ⇒ Object
A Facebook pixel Standard Event or Custom Event name. This is used with event_id to determine if events are identical.
30 31 32 |
# File 'lib/facebook_ads/ad_objects/server_side/event.rb', line 30 def event_name @event_name end |
#event_source_url ⇒ Object
The browser URL where the event happened.
36 37 38 |
# File 'lib/facebook_ads/ad_objects/server_side/event.rb', line 36 def event_source_url @event_source_url end |
#event_time ⇒ Object
A Unix timestamp in seconds indicating when the actual event occurred.
33 34 35 |
# File 'lib/facebook_ads/ad_objects/server_side/event.rb', line 33 def event_time @event_time end |
#opt_out ⇒ Object
A flag that indicates we should not use this event for ads delivery optimization. If set to true, we only use the event for attribution.
40 41 42 |
# File 'lib/facebook_ads/ad_objects/server_side/event.rb', line 40 def opt_out @opt_out end |
#user_data ⇒ Object
An Object that contains user data.
50 51 52 |
# File 'lib/facebook_ads/ad_objects/server_side/event.rb', line 50 def user_data @user_data end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/facebook_ads/ad_objects/server_side/event.rb', line 160 def ==(o) return true if self.equal?(o) self.class == o.class && event_name == o.event_name && event_time == o.event_time && event_source_url == o.event_source_url && opt_out == o.opt_out && event_id == o.event_id && user_data == o.user_data && custom_data == o.custom_data end |
#build(attributes = {}) ⇒ Object
build the object using the input hash
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/facebook_ads/ad_objects/server_side/event.rb', line 96 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?(:'event_source_url') self.event_source_url = attributes[:'event_source_url'] end if attributes.has_key?(:'opt_out') self.opt_out = attributes[:'opt_out'] end if attributes.has_key?(:'event_id') self.event_id = attributes[:'event_id'] end if attributes.has_key?(:'user_data') self.user_data = attributes[:'user_data'] end if attributes.has_key?(:'custom_data') self.custom_data = attributes[:'custom_data'] end end |
#eql?(o) ⇒ Boolean
173 174 175 |
# File 'lib/facebook_ads/ad_objects/server_side/event.rb', line 173 def eql?(o) self == o end |
#hash ⇒ Fixnum
Calculates hash code according to all attributes.
179 180 181 |
# File 'lib/facebook_ads/ad_objects/server_side/event.rb', line 179 def hash [event_name, event_time, event_source_url, opt_out, event_id, user_data, custom_data].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/facebook_ads/ad_objects/server_side/event.rb', line 133 def list_invalid_properties invalid_properties = Array.new if @event_name.nil? invalid_properties.push('invalid value for "event_name", event_name cannot be nil.') end if @event_time.nil? invalid_properties.push('invalid value for "event_time", event_time cannot be nil.') end if @user_data.nil? invalid_properties.push('invalid value for "user_data", user_data cannot be nil.') end invalid_properties end |
#normalize ⇒ Object
Normalize input fields to server request format.
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'lib/facebook_ads/ad_objects/server_side/event.rb', line 211 def normalize hash = {} unless event_name.nil? hash['event_name'] = event_name end unless event_time.nil? hash['event_time'] = event_time end unless event_source_url.nil? hash['event_source_url'] = event_source_url end unless opt_out.nil? hash['opt_out'] = opt_out end unless event_id.nil? hash['event_id'] = event_id end unless user_data.nil? hash['user_data'] = user_data.normalize end unless custom_data.nil? hash['custom_data'] = custom_data.normalize end hash end |
#to_s ⇒ Object
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/facebook_ads/ad_objects/server_side/event.rb', line 183 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 event_source_url.nil? hash['event_source_url'] = event_source_url end unless opt_out.nil? hash['opt_out'] = opt_out end unless event_id.nil? hash['event_id'] = event_id end unless user_data.nil? hash['user_data'] = user_data.to_s end unless custom_data.nil? hash['custom_data'] = custom_data.to_s end hash.to_s end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
152 153 154 155 156 157 |
# File 'lib/facebook_ads/ad_objects/server_side/event.rb', line 152 def valid? return false if @event_name.nil? return false if @event_time.nil? return false if @user_data.nil? true end |