Class: PinterestSdkClient::PromotionResponse

Inherits:
ApiModelBase show all
Defined in:
lib/pinterest_sdk/models/promotion_response.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ PromotionResponse

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



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_response.rb', line 140

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `PinterestSdkClient::PromotionResponse` 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::PromotionResponse`. 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?(:'ad_account_id')
    self. = attributes[:'ad_account_id']
  end

  if attributes.key?(:'id')
    self.id = attributes[:'id']
  end

  if attributes.key?(:'status')
    self.status = attributes[:'status']
  end
end

Instance Attribute Details

#ad_account_idObject

The Ad Account ID that this promotion belongs to.



48
49
50
# File 'lib/pinterest_sdk/models/promotion_response.rb', line 48

def 
  
end

#discount_statusObject

Discount status based on the current time and start and end time of discount



19
20
21
# File 'lib/pinterest_sdk/models/promotion_response.rb', line 19

def discount_status
  @discount_status
end

#end_timeObject

Promotion end time. Unix timestamp in seconds. Independent of campaign end time.



22
23
24
# File 'lib/pinterest_sdk/models/promotion_response.rb', line 22

def end_time
  @end_time
end

#external_idObject

Platform-specific ID for this promotion. Will be null for promotions first created within Pinterest.



25
26
27
# File 'lib/pinterest_sdk/models/promotion_response.rb', line 25

def external_id
  @external_id
end

#idObject

Promotion ID



51
52
53
# File 'lib/pinterest_sdk/models/promotion_response.rb', line 51

def id
  @id
end

#platform_typeObject

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_response.rb', line 28

def platform_type
  @platform_type
end

#promotion_codeObject

Code that can be used to redeem a promotion.



31
32
33
# File 'lib/pinterest_sdk/models/promotion_response.rb', line 31

def promotion_code
  @promotion_code
end

#promotion_custom_idObject

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_response.rb', line 34

def promotion_custom_id
  @promotion_custom_id
end

#promotion_titleObject

Internal name for the promotion.



37
38
39
# File 'lib/pinterest_sdk/models/promotion_response.rb', line 37

def promotion_title
  @promotion_title
end

#promotion_typeObject

Returns the value of attribute promotion_type.



39
40
41
# File 'lib/pinterest_sdk/models/promotion_response.rb', line 39

def promotion_type
  @promotion_type
end

#start_timeObject

Promotion start time. Unix timestamp in seconds. Independent of campaign start time.



42
43
44
# File 'lib/pinterest_sdk/models/promotion_response.rb', line 42

def start_time
  @start_time
end

#statusObject

Returns the value of attribute status.



53
54
55
# File 'lib/pinterest_sdk/models/promotion_response.rb', line 53

def status
  @status
end

#template_valuesObject

List of values to be inserted in the promotion type-specific template.



45
46
47
# File 'lib/pinterest_sdk/models/promotion_response.rb', line 45

def template_values
  @template_values
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



97
98
99
# File 'lib/pinterest_sdk/models/promotion_response.rb', line 97

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



102
103
104
# File 'lib/pinterest_sdk/models/promotion_response.rb', line 102

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/pinterest_sdk/models/promotion_response.rb', line 78

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',
    :'ad_account_id' => :'ad_account_id',
    :'id' => :'id',
    :'status' => :'status'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
# File 'lib/pinterest_sdk/models/promotion_response.rb', line 379

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_ofObject

List of class defined in allOf (OpenAPI v3)



132
133
134
135
136
# File 'lib/pinterest_sdk/models/promotion_response.rb', line 132

def self.openapi_all_of
  [
  :'PromotionCommon'
  ]
end

.openapi_nullableObject

List of attributes with nullable: true



126
127
128
129
# File 'lib/pinterest_sdk/models/promotion_response.rb', line 126

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_typesObject

Attribute type mapping.



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/pinterest_sdk/models/promotion_response.rb', line 107

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>',
    :'ad_account_id' => :'String',
    :'id' => :'String',
    :'status' => :'EntityStatus'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
# File 'lib/pinterest_sdk/models/promotion_response.rb', line 346

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 &&
       == o. &&
      id == o.id &&
      status == o.status
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


366
367
368
# File 'lib/pinterest_sdk/models/promotion_response.rb', line 366

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



372
373
374
# File 'lib/pinterest_sdk/models/promotion_response.rb', line 372

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_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



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
# File 'lib/pinterest_sdk/models/promotion_response.rb', line 211

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

  pattern = Regexp.new(/^\d+$/)
  if !.nil? &&  !~ pattern
    invalid_properties.push("invalid value for \"ad_account_id\", must conform to the pattern #{pattern}.")
  end

  pattern = Regexp.new(/^\d+$/)
  if !@id.nil? && @id !~ pattern
    invalid_properties.push("invalid value for \"id\", must conform to the pattern #{pattern}.")
  end

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



401
402
403
404
405
406
407
408
409
410
411
412
413
# File 'lib/pinterest_sdk/models/promotion_response.rb', line 401

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

Returns:

  • (Boolean)

    true if the model is valid



245
246
247
248
249
250
251
252
253
254
255
256
# File 'lib/pinterest_sdk/models/promotion_response.rb', line 245

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 !.nil? &&  !~ Regexp.new(/^\d+$/)
  return false if !@id.nil? && @id !~ Regexp.new(/^\d+$/)
  true
end