Class: FacebookAds::ServerSide::Content
- Inherits:
-
Object
- Object
- FacebookAds::ServerSide::Content
- Defined in:
- lib/facebook_ads/ad_objects/server_side/content.rb
Overview
Content object contains information about the products.
Instance Attribute Summary collapse
-
#brand ⇒ Object
Returns the value of attribute brand.
-
#category ⇒ Object
Returns the value of attribute category.
-
#description ⇒ Object
Returns the value of attribute description.
-
#item_price ⇒ Object
Returns the value of attribute item_price.
-
#product_id ⇒ Object
Returns the value of attribute product_id.
-
#quantity ⇒ Object
Returns the value of attribute quantity.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
-
#build(attributes = {}) ⇒ Object
build the object using the input hash.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Fixnum
Calculates hash code according to all attributes.
-
#initialize(product_id: nil, quantity: nil, item_price: nil, title: nil, description: nil, brand: nil, category: nil) ⇒ Content
constructor
Initializes the object.
-
#normalize ⇒ Object
Normalize input fields to server request format.
-
#to_s ⇒ String
Returns the string representation of the object.
Constructor Details
#initialize(product_id: nil, quantity: nil, item_price: nil, title: nil, description: nil, brand: nil, category: nil) ⇒ Content
Initializes the object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/facebook_ads/ad_objects/server_side/content.rb', line 41 def initialize(product_id: nil, quantity: nil, item_price: nil, title: nil, description: nil, brand: nil, 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 end |
Instance Attribute Details
#brand ⇒ Object
Returns the value of attribute brand.
25 26 27 |
# File 'lib/facebook_ads/ad_objects/server_side/content.rb', line 25 def brand @brand end |
#category ⇒ Object
Returns the value of attribute category.
25 26 27 |
# File 'lib/facebook_ads/ad_objects/server_side/content.rb', line 25 def category @category end |
#description ⇒ Object
Returns the value of attribute description.
25 26 27 |
# File 'lib/facebook_ads/ad_objects/server_side/content.rb', line 25 def description @description end |
#item_price ⇒ Object
Returns the value of attribute item_price.
25 26 27 |
# File 'lib/facebook_ads/ad_objects/server_side/content.rb', line 25 def item_price @item_price end |
#product_id ⇒ Object
Returns the value of attribute product_id.
25 26 27 |
# File 'lib/facebook_ads/ad_objects/server_side/content.rb', line 25 def product_id @product_id end |
#quantity ⇒ Object
Returns the value of attribute quantity.
25 26 27 |
# File 'lib/facebook_ads/ad_objects/server_side/content.rb', line 25 def quantity @quantity end |
#title ⇒ Object
Returns the value of attribute title.
25 26 27 |
# File 'lib/facebook_ads/ad_objects/server_side/content.rb', line 25 def title @title end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
103 104 105 106 107 108 109 110 111 112 |
# File 'lib/facebook_ads/ad_objects/server_side/content.rb', line 103 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 end |
#build(attributes = {}) ⇒ Object
build the object using the input hash
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/facebook_ads/ad_objects/server_side/content.rb', line 67 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 end |
#eql?(o) ⇒ Boolean
115 116 117 |
# File 'lib/facebook_ads/ad_objects/server_side/content.rb', line 115 def eql?(o) self == o end |
#hash ⇒ Fixnum
Calculates hash code according to all attributes.
121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/facebook_ads/ad_objects/server_side/content.rb', line 121 def hash [ product_id, quantity, item_price, title, description, brand, category ].hash end |
#normalize ⇒ Object
Normalize input fields to server request format.
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/facebook_ads/ad_objects/server_side/content.rb', line 163 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 hash end |
#to_s ⇒ String
Returns the string representation of the object
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 |
# File 'lib/facebook_ads/ad_objects/server_side/content.rb', line 136 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 hash.to_s end |