Class: FacebookAds::ServerSide::AttributionSetting

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

Overview

AttributionSetting contains attribution window settings used for attribution.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(inactivity_window_hours: nil, reattribution_window_hours: nil) ⇒ AttributionSetting

Returns a new instance of AttributionSetting.

Parameters:

  • inactivity_window_hours (Integer) (defaults to: nil)
  • reattribution_window_hours (Integer) (defaults to: nil)


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

def initialize(inactivity_window_hours: nil, reattribution_window_hours: nil)
  unless inactivity_window_hours.nil?
    self.inactivity_window_hours = inactivity_window_hours
  end
  unless reattribution_window_hours.nil?
    self.reattribution_window_hours = reattribution_window_hours
  end
end

Instance Attribute Details

#inactivity_window_hoursObject

Inactivity window in hours.



26
27
28
# File 'lib/facebook_ads/ad_objects/server_side/attribution_setting.rb', line 26

def inactivity_window_hours
  @inactivity_window_hours
end

#reattribution_window_hoursObject

Reattribution window in hours.



29
30
31
# File 'lib/facebook_ads/ad_objects/server_side/attribution_setting.rb', line 29

def reattribution_window_hours
  @reattribution_window_hours
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/attribution_setting.rb', line 61

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      inactivity_window_hours == o.inactivity_window_hours &&
      reattribution_window_hours == o.reattribution_window_hours
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/attribution_setting.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?(:'inactivity_window_hours')
    self.inactivity_window_hours = attributes[:'inactivity_window_hours']
  end

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

#eql?(o) ⇒ Boolean

Returns:

  • (Boolean)

See Also:

  • `==` method


69
70
71
# File 'lib/facebook_ads/ad_objects/server_side/attribution_setting.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/attribution_setting.rb', line 75

def hash
  [
    inactivity_window_hours, reattribution_window_hours
  ].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/attribution_setting.rb', line 94

def normalize
  hash = {}
  unless inactivity_window_hours.nil?
    hash['inactivity_window_hours'] = inactivity_window_hours
  end
  unless reattribution_window_hours.nil?
    hash['reattribution_window_hours'] = reattribution_window_hours
  end
  hash
end

#to_sObject



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

def to_s
  hash = {}
  unless inactivity_window_hours.nil?
    hash['inactivity_window_hours'] = inactivity_window_hours
  end
  unless reattribution_window_hours.nil?
    hash['reattribution_window_hours'] = reattribution_window_hours
  end
  hash.to_s
end