Class: PinterestSdkClient::PromotionCreateRequest

Inherits:
ApiModelBase
  • Object
show all
Defined in:
lib/pinterest_sdk/models/promotion_create_request.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 = {}) ⇒ PromotionCreateRequest

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/pinterest_sdk/models/promotion_create_request.rb', line 126

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

Instance Attribute Details

#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_create_request.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_create_request.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_create_request.rb', line 25

def external_id
  @external_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_create_request.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_create_request.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_create_request.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_create_request.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_create_request.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_create_request.rb', line 42

def start_time
  @start_time
end

#template_valuesObject

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



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

def template_values
  @template_values
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



86
87
88
# File 'lib/pinterest_sdk/models/promotion_create_request.rb', line 86

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



91
92
93
# File 'lib/pinterest_sdk/models/promotion_create_request.rb', line 91

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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_create_request.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

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
# File 'lib/pinterest_sdk/models/promotion_create_request.rb', line 342

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)



118
119
120
121
122
# File 'lib/pinterest_sdk/models/promotion_create_request.rb', line 118

def self.openapi_all_of
  [
  :'PromotionCommon'
  ]
end

.openapi_nullableObject

List of attributes with nullable: true



112
113
114
115
# File 'lib/pinterest_sdk/models/promotion_create_request.rb', line 112

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

.openapi_typesObject

Attribute type mapping.



96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/pinterest_sdk/models/promotion_create_request.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.

Parameters:

  • Object (Object)

    to be compared



312
313
314
315
316
317
318
319
320
321
322
323
324
325
# File 'lib/pinterest_sdk/models/promotion_create_request.rb', line 312

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

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


329
330
331
# File 'lib/pinterest_sdk/models/promotion_create_request.rb', line 329

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



335
336
337
# File 'lib/pinterest_sdk/models/promotion_create_request.rb', line 335

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_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/pinterest_sdk/models/promotion_create_request.rb', line 189

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 @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_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



364
365
366
367
368
369
370
371
372
373
374
375
376
# File 'lib/pinterest_sdk/models/promotion_create_request.rb', line 364

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



221
222
223
224
225
226
227
228
229
230
231
232
# File 'lib/pinterest_sdk/models/promotion_create_request.rb', line 221

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 @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