Class: PinterestSdkClient::Promotion
- Inherits:
-
ApiModelBase
- Object
- ApiModelBase
- PinterestSdkClient::Promotion
- Defined in:
- lib/pinterest_sdk/models/promotion.rb
Defined Under Namespace
Classes: EnumAttributeValidator
Instance Attribute Summary collapse
-
#ad_account_id ⇒ Object
The Ad Account ID that this promotion belongs to.
-
#discount_status ⇒ Object
Returns the value of attribute discount_status.
-
#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_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 = {}) ⇒ Promotion
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 = {}) ⇒ Promotion
Initializes the object
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 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 201 202 203 204 205 206 207 |
# File 'lib/pinterest_sdk/models/promotion.rb', line 132 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `PinterestSdkClient::Promotion` 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::Promotion`. 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?(:'ad_account_id') self.ad_account_id = attributes[:'ad_account_id'] else self.ad_account_id = nil end 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?(:'id') self.id = attributes[:'id'] else self.id = nil 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'] else self.promotion_title = nil end if attributes.key?(:'promotion_type') self.promotion_type = attributes[:'promotion_type'] else self.promotion_type = nil end if attributes.key?(:'start_time') self.start_time = attributes[:'start_time'] end if attributes.key?(:'status') self.status = attributes[:'status'] end if attributes.key?(:'template_values') if (value = attributes[:'template_values']).is_a?(Array) self.template_values = value end end end |
Instance Attribute Details
#ad_account_id ⇒ Object
The Ad Account ID that this promotion belongs to.
19 20 21 |
# File 'lib/pinterest_sdk/models/promotion.rb', line 19 def ad_account_id @ad_account_id end |
#discount_status ⇒ Object
Returns the value of attribute discount_status.
21 22 23 |
# File 'lib/pinterest_sdk/models/promotion.rb', line 21 def discount_status @discount_status end |
#end_time ⇒ Object
Promotion end time. Unix timestamp in seconds. Independent of campaign end time.
24 25 26 |
# File 'lib/pinterest_sdk/models/promotion.rb', line 24 def end_time @end_time end |
#external_id ⇒ Object
Platform-specific ID for this promotion. Will be null for promotions first created within Pinterest.
27 28 29 |
# File 'lib/pinterest_sdk/models/promotion.rb', line 27 def external_id @external_id end |
#id ⇒ Object
Promotion ID
30 31 32 |
# File 'lib/pinterest_sdk/models/promotion.rb', line 30 def id @id end |
#platform_type ⇒ Object
The source integration platform used when creating the promotion. Currently supported values are 'DEFAULT' and 'SHOPIFY'.
33 34 35 |
# File 'lib/pinterest_sdk/models/promotion.rb', line 33 def platform_type @platform_type end |
#promotion_code ⇒ Object
Code that can be used to redeem a promotion.
36 37 38 |
# File 'lib/pinterest_sdk/models/promotion.rb', line 36 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.
39 40 41 |
# File 'lib/pinterest_sdk/models/promotion.rb', line 39 def promotion_custom_id @promotion_custom_id end |
#promotion_title ⇒ Object
Internal name for the promotion.
42 43 44 |
# File 'lib/pinterest_sdk/models/promotion.rb', line 42 def promotion_title @promotion_title end |
#promotion_type ⇒ Object
Returns the value of attribute promotion_type.
44 45 46 |
# File 'lib/pinterest_sdk/models/promotion.rb', line 44 def promotion_type @promotion_type end |
#start_time ⇒ Object
Promotion start time. Unix timestamp in seconds. Independent of campaign start time.
47 48 49 |
# File 'lib/pinterest_sdk/models/promotion.rb', line 47 def start_time @start_time end |
#status ⇒ Object
Returns the value of attribute status.
49 50 51 |
# File 'lib/pinterest_sdk/models/promotion.rb', line 49 def status @status end |
#template_values ⇒ Object
List of values to be inserted in the promotion type-specific template.
52 53 54 |
# File 'lib/pinterest_sdk/models/promotion.rb', line 52 def template_values @template_values end |
Class Method Details
.acceptable_attribute_map ⇒ Object
Returns attribute mapping this model knows about
96 97 98 |
# File 'lib/pinterest_sdk/models/promotion.rb', line 96 def self.acceptable_attribute_map attribute_map end |
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
101 102 103 |
# File 'lib/pinterest_sdk/models/promotion.rb', line 101 def self.acceptable_attributes acceptable_attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/pinterest_sdk/models/promotion.rb', line 77 def self.attribute_map { :'ad_account_id' => :'ad_account_id', :'discount_status' => :'discount_status', :'end_time' => :'end_time', :'external_id' => :'external_id', :'id' => :'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', :'status' => :'status', :'template_values' => :'template_values' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 |
# File 'lib/pinterest_sdk/models/promotion.rb', line 416 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
125 126 127 128 |
# File 'lib/pinterest_sdk/models/promotion.rb', line 125 def self.openapi_nullable Set.new([ ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/pinterest_sdk/models/promotion.rb', line 106 def self.openapi_types { :'ad_account_id' => :'String', :'discount_status' => :'DiscountStatus', :'end_time' => :'Integer', :'external_id' => :'String', :'id' => :'String', :'platform_type' => :'String', :'promotion_code' => :'String', :'promotion_custom_id' => :'String', :'promotion_title' => :'String', :'promotion_type' => :'PromotionType', :'start_time' => :'Integer', :'status' => :'EntityStatus', :'template_values' => :'Array<PromotionTemplateValue>' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
# File 'lib/pinterest_sdk/models/promotion.rb', line 383 def ==(o) return true if self.equal?(o) self.class == o.class && ad_account_id == o.ad_account_id && discount_status == o.discount_status && end_time == o.end_time && external_id == o.external_id && id == o.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 && status == o.status && template_values == o.template_values end |
#eql?(o) ⇒ Boolean
403 404 405 |
# File 'lib/pinterest_sdk/models/promotion.rb', line 403 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
409 410 411 |
# File 'lib/pinterest_sdk/models/promotion.rb', line 409 def hash [ad_account_id, discount_status, end_time, external_id, id, platform_type, promotion_code, promotion_custom_id, promotion_title, promotion_type, start_time, status, template_values].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
# File 'lib/pinterest_sdk/models/promotion.rb', line 211 def list_invalid_properties warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' invalid_properties = Array.new if @ad_account_id.nil? invalid_properties.push('invalid value for "ad_account_id", ad_account_id cannot be nil.') end pattern = Regexp.new(/^\d+$/) if @ad_account_id !~ pattern invalid_properties.push("invalid value for \"ad_account_id\", must conform to the pattern #{pattern}.") end 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 @id.nil? invalid_properties.push('invalid value for "id", id cannot be nil.') end if @id.to_s.length > 18 invalid_properties.push('invalid value for "id", the character length must be smaller than or equal to 18.') end pattern = Regexp.new(/^\d+$/) if @id !~ pattern invalid_properties.push("invalid value for \"id\", must conform to the pattern #{pattern}.") 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 @promotion_title.nil? invalid_properties.push('invalid value for "promotion_title", promotion_title cannot be nil.') end if @promotion_type.nil? invalid_properties.push('invalid value for "promotion_type", promotion_type cannot be nil.') 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
438 439 440 441 442 443 444 445 446 447 448 449 450 |
# File 'lib/pinterest_sdk/models/promotion.rb', line 438 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
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/pinterest_sdk/models/promotion.rb', line 265 def valid? warn '[DEPRECATED] the `valid?` method is obsolete' return false if @ad_account_id.nil? return false if @ad_account_id !~ Regexp.new(/^\d+$/) return false if !@external_id.nil? && @external_id.to_s.length > 64 return false if @id.nil? return false if @id.to_s.length > 18 return false if @id !~ Regexp.new(/^\d+$/) return false if !@promotion_custom_id.nil? && @promotion_custom_id.to_s.length > 50 return false if @promotion_title.nil? return false if @promotion_type.nil? return false if !@template_values.nil? && @template_values.length > 2 return false if !@template_values.nil? && @template_values.length < 0 true end |