Class: FacebookAds::ServerSide::EventResponse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(events_received: nil, messages: nil, fbtrace_id: nil) ⇒ EventResponse

Returns a new instance of EventResponse.

Parameters:

  • events_received (String) (defaults to: nil)
  • ] (Array()String)

    messages

  • fbtrace_id (String) (defaults to: nil)


36
37
38
39
40
41
42
43
44
45
46
# File 'lib/facebook_ads/ad_objects/server_side/event_response.rb', line 36

def initialize(events_received: nil, messages: nil, fbtrace_id: nil)
  unless events_received.nil?
    self.events_received = events_received
  end
  unless messages.nil?
    self.messages = messages
  end
  unless fbtrace_id.nil?
    self.fbtrace_id = fbtrace_id
  end
end

Instance Attribute Details

#events_receivedObject

number of events received.



25
26
27
# File 'lib/facebook_ads/ad_objects/server_side/event_response.rb', line 25

def events_received
  @events_received
end

#fbtrace_idObject

Facebook API trace id



31
32
33
# File 'lib/facebook_ads/ad_objects/server_side/event_response.rb', line 31

def fbtrace_id
  @fbtrace_id
end

#messagesObject

Response message



28
29
30
# File 'lib/facebook_ads/ad_objects/server_side/event_response.rb', line 28

def messages
  @messages
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.



72
73
74
75
76
77
78
# File 'lib/facebook_ads/ad_objects/server_side/event_response.rb', line 72

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      events_received == o.events_received &&
      messages == o.messages &&
      fbtrace_id == o.fbtrace_id
end

#build(attributes = {}) ⇒ Object

build the object using the input hash

Parameters:

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

    attributes in the form of hash



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/facebook_ads/ad_objects/server_side/event_response.rb', line 50

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?(:'events_received')
    self.events_received = attributes[:'events_received']
  end

  if attributes.has_key?(:'messages')
    if (value = attributes[:'messages']).is_a?(Array)
      self.messages = value
    end
  end

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

#eql?(o) ⇒ Boolean

Returns:

  • (Boolean)

See Also:

  • `==` method


81
82
83
# File 'lib/facebook_ads/ad_objects/server_side/event_response.rb', line 81

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



87
88
89
# File 'lib/facebook_ads/ad_objects/server_side/event_response.rb', line 87

def hash
  [events_received, messages, fbtrace_id].hash
end

#to_sObject



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

def to_s
  hash = {}
  unless events_received.nil?
    hash['events_received'] = events_received
  end
  unless messages.nil?
    hash['messages'] = messages
  end
  unless fbtrace_id.nil?
    hash['fbtrace_id'] = fbtrace_id
  end
  hash.to_s
end