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
-
#item_price ⇒ Object
Item Price.
-
#product_id ⇒ Object
Product Id.
-
#quantity ⇒ Object
number of product.
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) ⇒ 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) ⇒ Content
Initializes the object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/facebook_ads/ad_objects/server_side/content.rb', line 38 def initialize(product_id: nil, quantity: nil, item_price: 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 end |
Instance Attribute Details
#item_price ⇒ Object
Item Price.
32 33 34 |
# File 'lib/facebook_ads/ad_objects/server_side/content.rb', line 32 def item_price @item_price end |
#product_id ⇒ Object
Product Id
26 27 28 |
# File 'lib/facebook_ads/ad_objects/server_side/content.rb', line 26 def product_id @product_id end |
#quantity ⇒ Object
number of product
29 30 31 |
# File 'lib/facebook_ads/ad_objects/server_side/content.rb', line 29 def quantity @quantity 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/content.rb', line 72 def ==(o) return true if self.equal?(o) self.class == o.class && product_id == o.product_id && quantity == o.quantity && item_price == o.item_price end |
#build(attributes = {}) ⇒ Object
build the object using the input hash
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/content.rb', line 52 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 end |
#eql?(o) ⇒ Boolean
81 82 83 |
# File 'lib/facebook_ads/ad_objects/server_side/content.rb', line 81 def eql?(o) self == o end |
#hash ⇒ Fixnum
Calculates hash code according to all attributes.
87 88 89 90 91 92 93 |
# File 'lib/facebook_ads/ad_objects/server_side/content.rb', line 87 def hash [ product_id, quantity, item_price ].hash end |
#normalize ⇒ Object
Normalize input fields to server request format.
113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/facebook_ads/ad_objects/server_side/content.rb', line 113 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 hash end |
#to_s ⇒ String
Returns the string representation of the object
98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/facebook_ads/ad_objects/server_side/content.rb', line 98 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 hash.to_s end |