Class: PinterestSdkClient::PromotionCommon
- Inherits:
-
ApiModelBase
- Object
- ApiModelBase
- PinterestSdkClient::PromotionCommon
- Defined in:
- lib/pinterest_sdk/models/promotion_common.rb
Defined Under Namespace
Classes: EnumAttributeValidator
Instance Attribute Summary collapse
-
#discount_status ⇒ Object
Discount status based on the current time and start and end time of discount.
-
#end_time ⇒ Object
Promotion end time.
-
#external_id ⇒ Object
Platform-specific ID for this promotion.
-
#platform_type ⇒ Object
The source integration platform used when creating the promotion.
-
#promotion_code ⇒ Object
Code that can be used to redeem a promotion.
-
#promotion_custom_id ⇒ Object
An optional field for user defined promotion ID for this promotion.
-
#promotion_title ⇒ Object
Internal name for the promotion.
-
#promotion_type ⇒ Object
Returns the value of attribute promotion_type.
-
#start_time ⇒ Object
Promotion start time.
-
#template_values ⇒ Object
List of values to be inserted in the promotion type-specific template.
Class Method Summary collapse
-
.acceptable_attribute_map ⇒ Object
Returns attribute mapping this model knows about.
-
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about.
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.build_from_hash(attributes) ⇒ Object
Builds the object from hash.
-
.openapi_nullable ⇒ Object
List of attributes with nullable: true.
-
.openapi_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Integer
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ PromotionCommon
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Methods inherited from ApiModelBase
_deserialize, #_to_hash, #to_body, #to_s
Constructor Details
#initialize(attributes = {}) ⇒ PromotionCommon
Initializes the object
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 171 172 173 174 |
# File 'lib/pinterest_sdk/models/promotion_common.rb', line 119 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `PinterestSdkClient::PromotionCommon` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key acceptable_attribute_map = self.class.acceptable_attribute_map attributes = attributes.each_with_object({}) { |(k, v), h| if (!acceptable_attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `PinterestSdkClient::PromotionCommon`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect end h[k.to_sym] = v } if attributes.key?(:'discount_status') self.discount_status = attributes[:'discount_status'] end if attributes.key?(:'end_time') self.end_time = attributes[:'end_time'] end if attributes.key?(:'external_id') self.external_id = attributes[:'external_id'] end if attributes.key?(:'platform_type') self.platform_type = attributes[:'platform_type'] end if attributes.key?(:'promotion_code') self.promotion_code = attributes[:'promotion_code'] end if attributes.key?(:'promotion_custom_id') self.promotion_custom_id = attributes[:'promotion_custom_id'] end if attributes.key?(:'promotion_title') self.promotion_title = attributes[:'promotion_title'] end if attributes.key?(:'promotion_type') self.promotion_type = attributes[:'promotion_type'] end if attributes.key?(:'start_time') self.start_time = attributes[:'start_time'] end if attributes.key?(:'template_values') if (value = attributes[:'template_values']).is_a?(Array) self.template_values = value end end end |
Instance Attribute Details
#discount_status ⇒ Object
Discount status based on the current time and start and end time of discount
19 20 21 |
# File 'lib/pinterest_sdk/models/promotion_common.rb', line 19 def discount_status @discount_status end |
#end_time ⇒ Object
Promotion end time. Unix timestamp in seconds. Independent of campaign end time.
22 23 24 |
# File 'lib/pinterest_sdk/models/promotion_common.rb', line 22 def end_time @end_time end |
#external_id ⇒ Object
Platform-specific ID for this promotion. Will be null for promotions first created within Pinterest.
25 26 27 |
# File 'lib/pinterest_sdk/models/promotion_common.rb', line 25 def external_id @external_id end |
#platform_type ⇒ Object
The source integration platform used when creating the promotion. Currently supported values are ‘DEFAULT’ and ‘SHOPIFY’.
28 29 30 |
# File 'lib/pinterest_sdk/models/promotion_common.rb', line 28 def platform_type @platform_type end |
#promotion_code ⇒ Object
Code that can be used to redeem a promotion.
31 32 33 |
# File 'lib/pinterest_sdk/models/promotion_common.rb', line 31 def promotion_code @promotion_code end |
#promotion_custom_id ⇒ Object
An optional field for user defined promotion ID for this promotion. Will copy from Pinterest system generated ID if user did not provide one.
34 35 36 |
# File 'lib/pinterest_sdk/models/promotion_common.rb', line 34 def promotion_custom_id @promotion_custom_id end |
#promotion_title ⇒ Object
Internal name for the promotion.
37 38 39 |
# File 'lib/pinterest_sdk/models/promotion_common.rb', line 37 def promotion_title @promotion_title end |
#promotion_type ⇒ Object
Returns the value of attribute promotion_type.
39 40 41 |
# File 'lib/pinterest_sdk/models/promotion_common.rb', line 39 def promotion_type @promotion_type end |
#start_time ⇒ Object
Promotion start time. Unix timestamp in seconds. Independent of campaign start time.
42 43 44 |
# File 'lib/pinterest_sdk/models/promotion_common.rb', line 42 def start_time @start_time end |
#template_values ⇒ Object
List of values to be inserted in the promotion type-specific template.
45 46 47 |
# File 'lib/pinterest_sdk/models/promotion_common.rb', line 45 def template_values @template_values end |
Class Method Details
.acceptable_attribute_map ⇒ Object
Returns attribute mapping this model knows about
86 87 88 |
# File 'lib/pinterest_sdk/models/promotion_common.rb', line 86 def self.acceptable_attribute_map attribute_map end |
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
91 92 93 |
# File 'lib/pinterest_sdk/models/promotion_common.rb', line 91 def self.acceptable_attributes acceptable_attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/pinterest_sdk/models/promotion_common.rb', line 70 def self.attribute_map { :'discount_status' => :'discount_status', :'end_time' => :'end_time', :'external_id' => :'external_id', :'platform_type' => :'platform_type', :'promotion_code' => :'promotion_code', :'promotion_custom_id' => :'promotion_custom_id', :'promotion_title' => :'promotion_title', :'promotion_type' => :'promotion_type', :'start_time' => :'start_time', :'template_values' => :'template_values' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
# File 'lib/pinterest_sdk/models/promotion_common.rb', line 301 def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) transformed_hash = {} openapi_types.each_pair do |key, type| if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[attribute_map[key]].is_a?(Array) transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } end elsif !attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) end end new(transformed_hash) end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
112 113 114 115 |
# File 'lib/pinterest_sdk/models/promotion_common.rb', line 112 def self.openapi_nullable Set.new([ ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/pinterest_sdk/models/promotion_common.rb', line 96 def self.openapi_types { :'discount_status' => :'String', :'end_time' => :'Integer', :'external_id' => :'String', :'platform_type' => :'String', :'promotion_code' => :'String', :'promotion_custom_id' => :'String', :'promotion_title' => :'String', :'promotion_type' => :'PromotionType', :'start_time' => :'Integer', :'template_values' => :'Array<PromotionTemplateValue>' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
# File 'lib/pinterest_sdk/models/promotion_common.rb', line 271 def ==(o) return true if self.equal?(o) self.class == o.class && discount_status == o.discount_status && end_time == o.end_time && external_id == o.external_id && platform_type == o.platform_type && promotion_code == o.promotion_code && promotion_custom_id == o.promotion_custom_id && promotion_title == o.promotion_title && promotion_type == o.promotion_type && start_time == o.start_time && template_values == o.template_values end |
#eql?(o) ⇒ Boolean
288 289 290 |
# File 'lib/pinterest_sdk/models/promotion_common.rb', line 288 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
294 295 296 |
# File 'lib/pinterest_sdk/models/promotion_common.rb', line 294 def hash [discount_status, end_time, external_id, platform_type, promotion_code, promotion_custom_id, promotion_title, promotion_type, start_time, template_values].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/pinterest_sdk/models/promotion_common.rb', line 178 def list_invalid_properties warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' invalid_properties = Array.new if !@external_id.nil? && @external_id.to_s.length > 64 invalid_properties.push('invalid value for "external_id", the character length must be smaller than or equal to 64.') end if !@promotion_custom_id.nil? && @promotion_custom_id.to_s.length > 50 invalid_properties.push('invalid value for "promotion_custom_id", the character length must be smaller than or equal to 50.') end if !@template_values.nil? && @template_values.length > 2 invalid_properties.push('invalid value for "template_values", number of items must be less than or equal to 2.') end if !@template_values.nil? && @template_values.length < 0 invalid_properties.push('invalid value for "template_values", number of items must be greater than or equal to 0.') end invalid_properties end |
#to_hash ⇒ Hash
Returns the object in the form of hash
323 324 325 326 327 328 329 330 331 332 333 334 335 |
# File 'lib/pinterest_sdk/models/promotion_common.rb', line 323 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end hash[param] = _to_hash(value) end hash end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
202 203 204 205 206 207 208 209 210 211 |
# File 'lib/pinterest_sdk/models/promotion_common.rb', line 202 def valid? warn '[DEPRECATED] the `valid?` method is obsolete' discount_status_validator = EnumAttributeValidator.new('String', ["OTHER", "ACTIVE", "PAUSED", "SCHEDULED", "EXPIRED"]) return false unless discount_status_validator.valid?(@discount_status) return false if !@external_id.nil? && @external_id.to_s.length > 64 return false if !@promotion_custom_id.nil? && @promotion_custom_id.to_s.length > 50 return false if !@template_values.nil? && @template_values.length > 2 return false if !@template_values.nil? && @template_values.length < 0 true end |