class FacebookAds::ServerSide::Content

Content object contains information about the products.

Attributes

brand[RW]
category[RW]
delivery_category[RW]
description[RW]
item_price[RW]
product_id[RW]
quantity[RW]
title[RW]

Public Class Methods

new(product_id: nil, quantity: nil, item_price: nil, title: nil, description: nil, brand: nil, category: nil, delivery_category: nil) click to toggle source

Initializes the object @param [String] product_id @param [Integer] quantity @param [Float] item_price @param [String] title @param [String] description @param [String] brand @param [String] category @param [String] delivery_category

# File lib/facebook_ads/ad_objects/server_side/content.rb, line 43
def initialize(product_id: nil, quantity: nil, item_price: nil, title: nil, description: nil, brand: nil, category: nil, delivery_category: nil)
  unless product_id.nil?
    self.product_id = String(product_id)
  end
  unless quantity.nil?
    self.quantity = Integer(quantity)
  end
  unless item_price.nil?
    self.item_price = Float(item_price)
  end
  unless title.nil?
    self.title = String(title)
  end
  unless description.nil?
    self.description = String(description)
  end
  unless brand.nil?
    self.brand = String(brand)
  end
  unless category.nil?
    self.category = String(category)
  end
  unless delivery_category.nil?
    self.delivery_category = String(delivery_category)
  end
end

Public Instance Methods

==(o) click to toggle source

Checks equality by comparing each attribute.

# File lib/facebook_ads/ad_objects/server_side/content.rb, line 112
def ==(o)
  return self.class == o.class &&
      product_id == o.product_id &&
      quantity == o.quantity &&
      item_price == o.item_price &&
      title == o.title &&
      description == o.description &&
      brand == o.brand &&
      category == o.category &&
      delivery_category == o.delivery_category
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/content.rb, line 72
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?(:'product_id')
    self.product_id = attributes[:'product_id']
  end

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

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

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

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

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

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

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

@see the `==` method

# File lib/facebook_ads/ad_objects/server_side/content.rb, line 125
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/content.rb, line 131
def hash
  [
      product_id,
      quantity,
      item_price,
      title,
      description,
      brand,
      category,
      delivery_category
  ].hash
end
normalize() click to toggle source

Normalize input fields to server request format.

# File lib/facebook_ads/ad_objects/server_side/content.rb, line 177
def normalize
  hash = {}
  unless product_id.nil?
    hash['id'] = product_id
  end
  unless quantity.nil?
    hash['quantity'] = quantity
  end
  unless item_price.nil?
    hash['item_price'] = item_price
  end
  unless title.nil?
    hash['title'] = title
  end
  unless description.nil?
    hash['description'] = description
  end
  unless brand.nil?
    hash['brand'] = brand
  end
  unless category.nil?
    hash['category'] = category
  end
  unless delivery_category.nil?
    hash['delivery_category'] = FacebookAds::ServerSide::Util.normalize_delivery_category(
      delivery_category
    )
  end
  hash
end
to_s() click to toggle source

Returns the string representation of the object @return [String] String presentation of the object

# File lib/facebook_ads/ad_objects/server_side/content.rb, line 147
def to_s
  hash = {}
  unless product_id.nil?
    hash['product_id'] = product_id
  end
  unless quantity.nil?
    hash['quantity'] = quantity
  end
  unless item_price.nil?
    hash['item_price'] = item_price
  end
  unless title.nil?
    hash['title'] = title
  end
  unless description.nil?
    hash['description'] = description
  end
  unless brand.nil?
    hash['brand'] = brand
  end
  unless category.nil?
    hash['category'] = category
  end
  unless delivery_category.nil?
    hash['delivery_category'] = delivery_category
  end
  hash.to_s
end