class FacebookAds::ServerSide::Event

Server Side Event object.

Attributes

action_source[RW]

Where the conversion occurred.

custom_data[RW]

An Object that includes additional business data about the event.

data_processing_options[RW]

Processing options you would like to enable for a specific event. For more details see developers.facebook.com/docs/marketing-apis/data-processing-options

data_processing_options_country[RW]

A country that you want to associate to this data processing option For more details see developers.facebook.com/docs/marketing-apis/data-processing-options

data_processing_options_state[RW]

A state that you want to associate with this data processing option. For more details see developers.facebook.com/docs/marketing-apis/data-processing-options

event_id[RW]

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.

event_name[RW]

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

event_source_url[RW]

The browser URL where the event happened.

event_time[RW]

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

opt_out[RW]

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.

user_data[RW]

An Object that contains user data.

Public Class Methods

new(event_name: nil, event_time: nil, event_source_url: nil, opt_out: nil, event_id: nil, user_data: nil, custom_data: nil, data_processing_options: nil, data_processing_options_country: nil, data_processing_options_state: nil, action_source: nil) click to toggle source

@param [String] event_name @param [int] event_time @param [String] event_source_url @param [Boolean] opt_out @param [String] event_id @param [FacebookAds::ServerSide::UserData] user_data @param [FacebookAds::ServerSide::CustomData] custom_data @param [Array<String>] data_processing_options @param [int] data_processing_options_country @param [int] data_processing_options_state @param String action_source

# File lib/facebook_ads/ad_objects/server_side/event.rb, line 81
def initialize(event_name: nil,
               event_time: nil,
               event_source_url: nil,
               opt_out: nil,
               event_id: nil,
               user_data: nil,
               custom_data: nil,
               data_processing_options: nil,
               data_processing_options_country: nil,
               data_processing_options_state: nil,
               action_source: 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
  unless data_processing_options.nil?
    self.data_processing_options = data_processing_options
  end
  unless data_processing_options_country.nil?
    self.data_processing_options_country = data_processing_options_country
  end
  unless data_processing_options_state.nil?
    self.data_processing_options_state = data_processing_options_state
  end
  unless action_source.nil?
    self.action_source = action_source
  end
end

Public Instance Methods

==(o) click to toggle source

Checks equality by comparing each attribute.

# File lib/facebook_ads/ad_objects/server_side/event.rb, line 210
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 &&
      data_processing_options == o.data_processing_options &&
      data_processing_options_country == o.data_processing_options_country &&
      data_processing_options_state == o.data_processing_options_state &&
      action_source == o.action_source
end
build(attributes = {}) click to toggle source

build the object using the input hash @param [Hash] attributes attributes in the form of hash

# File lib/facebook_ads/ad_objects/server_side/event.rb, line 130
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

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

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

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

  if attributes.has_key?(:'action_source')
    self.action_source = attributes[:'action_source']
  end
end
eql?(o) click to toggle source

@see the `==` method

# File lib/facebook_ads/ad_objects/server_side/event.rb, line 227
def eql?(o)
  self == o
end
hash() click to toggle source

Calculates hash code according to all attributes. @return [Fixnum] Hash code

# File lib/facebook_ads/ad_objects/server_side/event.rb, line 233
def hash
  [
    event_name, event_time, event_source_url, opt_out, event_id, user_data, custom_data,
    data_processing_options, data_processing_options_country, data_processing_options_state,
    action_source,
  ].hash
end
list_invalid_properties() click to toggle source

Show invalid properties with the reasons. Usually used together with valid? @return Array for valid properties with the reasons

# File lib/facebook_ads/ad_objects/server_side/event.rb, line 183
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() click to toggle source

Normalize input fields to server request format.

# File lib/facebook_ads/ad_objects/server_side/event.rb, line 281
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
  unless data_processing_options.nil?
    hash['data_processing_options'] = data_processing_options
  end
  unless data_processing_options_country.nil?
    hash['data_processing_options_country'] = data_processing_options_country
  end
  unless data_processing_options_state.nil?
    hash['data_processing_options_state'] = data_processing_options_state
  end
  unless action_source.nil?
    hash['action_source'] = FacebookAds::ServerSide::Util.normalize(
      action_source,
      'action_source'
    )
  end
  hash
end
to_s() click to toggle source
# File lib/facebook_ads/ad_objects/server_side/event.rb, line 241
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
  unless data_processing_options.nil?
    hash['data_processing_options'] = data_processing_options.to_s
  end
  unless data_processing_options_country.nil?
    hash['data_processing_options_country'] = data_processing_options_country.to_s
  end
  unless data_processing_options_state.nil?
    hash['data_processing_options_state'] = data_processing_options_state.to_s
  end
  unless action_source.nil?
    hash['action_source'] = action_source
  end
  hash.to_s
end
valid?() click to toggle source

Check to see if the all the properties in the model are valid @return true if the model is valid

# File lib/facebook_ads/ad_objects/server_side/event.rb, line 202
def valid?
  return false if @event_name.nil?
  return false if @event_time.nil?
  return false if @user_data.nil?
  true
end