Class: FacebookAds::ServerSide::CustomData
- Inherits:
-
Object
- Object
- FacebookAds::ServerSide::CustomData
- Defined in:
- lib/facebook_ads/ad_objects/server_side/custom_data.rb
Overview
CustomData includes additional business data about the event which is used for ads delivery optimization.
Instance Attribute Summary collapse
-
#content_category ⇒ Object
The category of the content associated with the event.
-
#content_ids ⇒ Object
The content IDs associated with the event, such as product SKUs for items in an AddToCart event: [‘ABC123’, ‘XYZ789’].
-
#content_name ⇒ Object
The name of the page or product associated with the event.
-
#content_type ⇒ Object
A String equal to either ‘product’ or ‘product_group’.
-
#contents ⇒ Object
An array of Content objects that contain the product IDs associated with the event plus information about the products.
-
#currency ⇒ Object
The currency for the value specified, if applicable.
-
#custom_properties ⇒ Object
Custom Properties bag for storing other custom fields.
-
#delivery_category ⇒ Object
Type of delivery for a purchase event Example: ‘home_delivery’.
-
#item_number ⇒ Object
The item number.
-
#net_revenue ⇒ Object
A numeric net_revenue associated with this event.
-
#num_items ⇒ Object
Use only with InitiateCheckout events.
-
#order_id ⇒ Object
The order ID for this transaction as a String.
-
#predicted_ltv ⇒ Object
The predicted lifetime value of a conversion event.
-
#search_string ⇒ Object
Use only with Search events.
-
#status ⇒ Object
Use only with CompleteRegistration events.
-
#value ⇒ Object
A numeric value associated with this event.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
-
#add_custom_property(key, value) ⇒ Object
Add other custom fields to custom properties.
-
#build(attributes = {}) ⇒ Object
build the object using the input hash.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Fixnum
Calculates hash code according to all attributes.
-
#initialize(value: nil, net_revenue: nil, currency: nil, content_name: nil, content_category: nil, content_ids: nil, contents: nil, content_type: nil, order_id: nil, predicted_ltv: nil, num_items: nil, status: nil, search_string: nil, delivery_category: nil, item_number: nil, custom_properties: {}) ⇒ CustomData
constructor
A new instance of CustomData.
-
#normalize ⇒ Object
Normalize input fields to server request format.
-
#to_s ⇒ String
Returns the string representation of the object.
Constructor Details
#initialize(value: nil, net_revenue: nil, currency: nil, content_name: nil, content_category: nil, content_ids: nil, contents: nil, content_type: nil, order_id: nil, predicted_ltv: nil, num_items: nil, status: nil, search_string: nil, delivery_category: nil, item_number: nil, custom_properties: {}) ⇒ CustomData
Returns a new instance of CustomData.
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 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/facebook_ads/ad_objects/server_side/custom_data.rb', line 105 def initialize(value: nil, net_revenue: nil, currency: nil, content_name: nil, content_category: nil, content_ids: nil, contents: nil, content_type: nil, order_id: nil, predicted_ltv: nil, num_items: nil, status: nil, search_string: nil, delivery_category: nil, item_number: nil, custom_properties: {}) unless value.nil? self.value = value end unless net_revenue.nil? self.net_revenue = net_revenue end unless currency.nil? self.currency = currency end unless content_name.nil? self.content_name = content_name end unless content_category.nil? self.content_category = content_category end unless content_ids.nil? self.content_ids = content_ids end unless contents.nil? self.contents = contents end unless content_type.nil? self.content_type = content_type end unless order_id.nil? self.order_id = order_id end unless predicted_ltv.nil? self.predicted_ltv = predicted_ltv end unless num_items.nil? self.num_items = num_items end unless status.nil? self.status = status end unless search_string.nil? self.search_string = search_string end unless delivery_category.nil? self.delivery_category = delivery_category end unless item_number.nil? self.item_number = item_number end unless custom_properties.nil? self.custom_properties = custom_properties end end |
Instance Attribute Details
#content_category ⇒ Object
The category of the content associated with the event. Example: ‘grocery’
42 43 44 |
# File 'lib/facebook_ads/ad_objects/server_side/custom_data.rb', line 42 def content_category @content_category end |
#content_ids ⇒ Object
The content IDs associated with the event, such as product SKUs for items in an AddToCart event: [‘ABC123’, ‘XYZ789’]. If content_type is a product, then your content IDs must be an array with a single string value. Otherwise, this array can contain any number of string values.
47 48 49 |
# File 'lib/facebook_ads/ad_objects/server_side/custom_data.rb', line 47 def content_ids @content_ids end |
#content_name ⇒ Object
The name of the page or product associated with the event. Example: ‘lettuce’.
38 39 40 |
# File 'lib/facebook_ads/ad_objects/server_side/custom_data.rb', line 38 def content_name @content_name end |
#content_type ⇒ Object
A String equal to either ‘product’ or ‘product_group’. Set to product if the keys you send content_ids or contents represent products. Set to product_group if the keys you send in content_ids represent product groups.
55 56 57 |
# File 'lib/facebook_ads/ad_objects/server_side/custom_data.rb', line 55 def content_type @content_type end |
#contents ⇒ Object
An array of Content objects that contain the product IDs associated with the event plus information about the products. id, quantity, and item_price are available fields.
51 52 53 |
# File 'lib/facebook_ads/ad_objects/server_side/custom_data.rb', line 51 def contents @contents end |
#currency ⇒ Object
The currency for the value specified, if applicable. Currency must be a valid ISO 4217 three digit currency code. Example: ‘usd’.
34 35 36 |
# File 'lib/facebook_ads/ad_objects/server_side/custom_data.rb', line 34 def currency @currency end |
#custom_properties ⇒ Object
Custom Properties bag for storing other custom fields
86 87 88 |
# File 'lib/facebook_ads/ad_objects/server_side/custom_data.rb', line 86 def custom_properties @custom_properties end |
#delivery_category ⇒ Object
Type of delivery for a purchase event Example: ‘home_delivery’.
79 80 81 |
# File 'lib/facebook_ads/ad_objects/server_side/custom_data.rb', line 79 def delivery_category @delivery_category end |
#item_number ⇒ Object
The item number. Example: ‘item1234’.
83 84 85 |
# File 'lib/facebook_ads/ad_objects/server_side/custom_data.rb', line 83 def item_number @item_number end |
#net_revenue ⇒ Object
A numeric net_revenue associated with this event. This could be a monetary net_revenue or a net_revenue in some other metric. Example: 30.54.
30 31 32 |
# File 'lib/facebook_ads/ad_objects/server_side/custom_data.rb', line 30 def net_revenue @net_revenue end |
#num_items ⇒ Object
Use only with InitiateCheckout events. The number of items that a user tries to buy during checkout. Example: 4
67 68 69 |
# File 'lib/facebook_ads/ad_objects/server_side/custom_data.rb', line 67 def num_items @num_items end |
#order_id ⇒ Object
The order ID for this transaction as a String. Example: ‘order1234’.
59 60 61 |
# File 'lib/facebook_ads/ad_objects/server_side/custom_data.rb', line 59 def order_id @order_id end |
#predicted_ltv ⇒ Object
The predicted lifetime value of a conversion event. Example: 432.12.
63 64 65 |
# File 'lib/facebook_ads/ad_objects/server_side/custom_data.rb', line 63 def predicted_ltv @predicted_ltv end |
#search_string ⇒ Object
Use only with Search events. A search query made by a user. Example: ‘lettuce’.
75 76 77 |
# File 'lib/facebook_ads/ad_objects/server_side/custom_data.rb', line 75 def search_string @search_string end |
#status ⇒ Object
Use only with CompleteRegistration events. The status of the registration event, as a String. Example: ‘registered’.
71 72 73 |
# File 'lib/facebook_ads/ad_objects/server_side/custom_data.rb', line 71 def status @status end |
#value ⇒ Object
A numeric value associated with this event. This could be a monetary value or a value in some other metric. Example: 142.54.
26 27 28 |
# File 'lib/facebook_ads/ad_objects/server_side/custom_data.rb', line 26 def value @value end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
# File 'lib/facebook_ads/ad_objects/server_side/custom_data.rb', line 251 def ==(o) return true if self.equal?(o) self.class == o.class && value == o.value && net_revenue == o.net_revenue && currency == o.currency && content_name == o.content_name && content_category == o.content_category && content_ids == o.content_ids && contents == o.contents && content_type == o.content_type && order_id == o.order_id && predicted_ltv == o.predicted_ltv && num_items == o.num_items && status == o.status && search_string == o.search_string && delivery_category == o.delivery_category && item_number == o.item_number && custom_properties == o.custom_properties end |
#add_custom_property(key, value) ⇒ Object
Add other custom fields to custom properties.
353 354 355 |
# File 'lib/facebook_ads/ad_objects/server_side/custom_data.rb', line 353 def add_custom_property(key, value) custom_properties[key] = value; end |
#build(attributes = {}) ⇒ Object
build the object using the input hash
175 176 177 178 179 180 181 182 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 208 209 210 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 236 237 238 239 240 241 242 243 244 245 246 247 248 |
# File 'lib/facebook_ads/ad_objects/server_side/custom_data.rb', line 175 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?(:'value') self.value = attributes[:'value'] end if attributes.has_key?(:'net_revenue') self.net_revenue = attributes[:'net_revenue'] end if attributes.has_key?(:'currency') self.currency = attributes[:'currency'] end if attributes.has_key?(:'content_name') self.content_name = attributes[:'content_name'] end if attributes.has_key?(:'content_category') self.content_category = attributes[:'content_category'] end if attributes.has_key?(:'content_ids') if (value = attributes[:'content_ids']).is_a?(Array) self.content_ids = value end end if attributes.has_key?(:'contents') if (value = attributes[:'contents']).is_a?(Array) self.contents = value end end if attributes.has_key?(:'content_type') self.content_type = attributes[:'content_type'] end if attributes.has_key?(:'order_id') self.order_id = attributes[:'order_id'] end if attributes.has_key?(:'predicted_ltv') self.predicted_ltv = attributes[:'predicted_ltv'] end if attributes.has_key?(:'num_items') self.num_items = attributes[:'num_items'] end if attributes.has_key?(:'status') self.status = attributes[:'status'] end if attributes.has_key?(:'search_string') self.search_string = attributes[:'search_string'] end if attributes.has_key?(:'delivery_category') self.delivery_category = attributes[:'delivery_category'] end if attributes.has_key?(:'item_number') self.item_number = attributes[:'item_number'] end if attributes.has_key?(:'custom_properties') self.custom_properties = attributes[:'custom_properties'] end end |
#eql?(o) ⇒ Boolean
273 274 275 |
# File 'lib/facebook_ads/ad_objects/server_side/custom_data.rb', line 273 def eql?(o) self == o end |
#hash ⇒ Fixnum
Calculates hash code according to all attributes.
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/facebook_ads/ad_objects/server_side/custom_data.rb', line 279 def hash [ value, net_revenue, currency, content_name, content_category, content_ids, contents, content_type, order_id, predicted_ltv, num_items, status, search_string, delivery_category, item_number, custom_properties ].hash end |
#normalize ⇒ Object
Normalize input fields to server request format.
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 |
# File 'lib/facebook_ads/ad_objects/server_side/custom_data.rb', line 358 def normalize hash = {} unless value.nil? hash['value'] = value end unless net_revenue.nil? hash['net_revenue'] = net_revenue end unless currency.nil? hash['currency'] = FacebookAds::ServerSide::Util.normalize(currency, 'currency') end unless content_name.nil? hash['content_name'] = content_name end unless content_category.nil? hash['content_category'] = content_category end unless content_ids.nil? hash['content_ids'] = content_ids end unless content_type.nil? hash['content_type'] = content_type end unless order_id.nil? hash['order_id'] = order_id end unless predicted_ltv.nil? hash['predicted_ltv'] = predicted_ltv end unless num_items.nil? hash['num_items'] = num_items end unless status.nil? hash['status'] = status end unless search_string.nil? hash['search_string'] = search_string end unless delivery_category.nil? hash['delivery_category'] = FacebookAds::ServerSide::Util.normalize(delivery_category, 'delivery_category') end unless item_number.nil? hash['item_number'] = item_number end unless contents.nil? content_array = [] contents.each do |content| content_array.push(content.normalize) end hash['contents'] = content_array end hash.merge!(custom_properties) unless custom_properties.nil? hash end |
#to_s ⇒ String
Returns the string representation of the object
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 |
# File 'lib/facebook_ads/ad_objects/server_side/custom_data.rb', line 302 def to_s hash = {} unless value.nil? hash['value'] = value end unless net_revenue.nil? hash['net_revenue'] = net_revenue end unless currency.nil? hash['currency'] = currency end unless content_name.nil? hash['content_name'] = content_name end unless content_category.nil? hash['content_category'] = content_category end unless content_ids.nil? hash['content_ids'] = content_ids end unless contents.nil? hash['contents'] = contents.to_s end unless content_type.nil? hash['content_type'] = content_type end unless order_id.nil? hash['order_id'] = order_id end unless predicted_ltv.nil? hash['predicted_ltv'] = predicted_ltv end unless num_items.nil? hash['num_items'] = num_items end unless status.nil? hash['status'] = status end unless search_string.nil? hash['search_string'] = search_string end unless delivery_category.nil? hash['delivery_category'] = delivery_category end unless custom_properties.nil? hash['custom_properties'] = custom_properties end hash.to_s end |