Class: PinterestSdkClient::PromotionUpdateRequest
- Inherits:
-
ApiModelBase
- Object
- ApiModelBase
- PinterestSdkClient::PromotionUpdateRequest
- Defined in:
- lib/pinterest_sdk/models/promotion_update_request.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.
-
#id ⇒ Object
Promotion ID.
-
#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.
-
#status ⇒ Object
Returns the value of attribute status.
-
#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_all_of ⇒ Object
List of class defined in allOf (OpenAPI v3).
-
.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 = {}) ⇒ PromotionUpdateRequest
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 = {}) ⇒ PromotionUpdateRequest
Initializes the object
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 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 |
# File 'lib/pinterest_sdk/models/promotion_update_request.rb', line 135 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `PinterestSdkClient::PromotionUpdateRequest` 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::PromotionUpdateRequest`. 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 if attributes.key?(:'id') self.id = attributes[:'id'] else self.id = nil end if attributes.key?(:'status') self.status = attributes[:'status'] 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_update_request.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_update_request.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_update_request.rb', line 25 def external_id @external_id end |
#id ⇒ Object
Promotion ID
48 49 50 |
# File 'lib/pinterest_sdk/models/promotion_update_request.rb', line 48 def id @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_update_request.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_update_request.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_update_request.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_update_request.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_update_request.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_update_request.rb', line 42 def start_time @start_time end |
#status ⇒ Object
Returns the value of attribute status.
50 51 52 |
# File 'lib/pinterest_sdk/models/promotion_update_request.rb', line 50 def status @status 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_update_request.rb', line 45 def template_values @template_values end |
Class Method Details
.acceptable_attribute_map ⇒ Object
Returns attribute mapping this model knows about
93 94 95 |
# File 'lib/pinterest_sdk/models/promotion_update_request.rb', line 93 def self.acceptable_attribute_map attribute_map end |
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
98 99 100 |
# File 'lib/pinterest_sdk/models/promotion_update_request.rb', line 98 def self.acceptable_attributes acceptable_attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/pinterest_sdk/models/promotion_update_request.rb', line 75 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', :'id' => :'id', :'status' => :'status' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 |
# File 'lib/pinterest_sdk/models/promotion_update_request.rb', line 355 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_all_of ⇒ Object
List of class defined in allOf (OpenAPI v3)
127 128 129 130 131 |
# File 'lib/pinterest_sdk/models/promotion_update_request.rb', line 127 def self.openapi_all_of [ :'PromotionCommon' ] end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
121 122 123 124 |
# File 'lib/pinterest_sdk/models/promotion_update_request.rb', line 121 def self.openapi_nullable Set.new([ ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/pinterest_sdk/models/promotion_update_request.rb', line 103 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>', :'id' => :'String', :'status' => :'EntityStatus' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 |
# File 'lib/pinterest_sdk/models/promotion_update_request.rb', line 323 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 && id == o.id && status == o.status end |
#eql?(o) ⇒ Boolean
342 343 344 |
# File 'lib/pinterest_sdk/models/promotion_update_request.rb', line 342 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
348 349 350 |
# File 'lib/pinterest_sdk/models/promotion_update_request.rb', line 348 def hash [discount_status, end_time, external_id, platform_type, promotion_code, promotion_custom_id, promotion_title, promotion_type, start_time, template_values, id, status].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
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 |
# File 'lib/pinterest_sdk/models/promotion_update_request.rb', line 204 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 if @id.nil? invalid_properties.push('invalid value for "id", id cannot be nil.') end pattern = Regexp.new(/^\d+$/) if @id !~ pattern invalid_properties.push("invalid value for \"id\", must conform to the pattern #{pattern}.") end invalid_properties end |
#to_hash ⇒ Hash
Returns the object in the form of hash
377 378 379 380 381 382 383 384 385 386 387 388 389 |
# File 'lib/pinterest_sdk/models/promotion_update_request.rb', line 377 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
237 238 239 240 241 242 243 244 245 246 247 248 |
# File 'lib/pinterest_sdk/models/promotion_update_request.rb', line 237 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 return false if @id.nil? return false if @id !~ Regexp.new(/^\d+$/) true end |