Class: Solifyn::ProductUpdate

Inherits:
Object
  • Object
show all
Defined in:
lib/solifyn/models/product_update.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ ProductUpdate

Initializes the object

Parameters:

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

    Model attributes in the form of hash



210
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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
# File 'lib/solifyn/models/product_update.rb', line 210

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `Solifyn::ProductUpdate` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!self.class.attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `Solifyn::ProductUpdate`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

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

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

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

  if attributes.key?(:'currency')
    self.currency = attributes[:'currency']
  else
    self.currency = 'USD'
  end

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

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

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

  if attributes.key?(:'has_license_key')
    self.has_license_key = attributes[:'has_license_key']
  else
    self.has_license_key = false
  end

  if attributes.key?(:'has_digital_delivery')
    self.has_digital_delivery = attributes[:'has_digital_delivery']
  else
    self.has_digital_delivery = false
  end

  if attributes.key?(:'has_github_access')
    self.has_github_access = attributes[:'has_github_access']
  else
    self.has_github_access = false
  end

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

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

  if attributes.key?(:'has_discord_access')
    self.has_discord_access = attributes[:'has_discord_access']
  else
    self.has_discord_access = false
  end

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

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

  if attributes.key?(:'is_tax_inclusive')
    self.is_tax_inclusive = attributes[:'is_tax_inclusive']
  else
    self.is_tax_inclusive = false
  end

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

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

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

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

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

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

  if attributes.key?(:'pay_what_you_want')
    self.pay_what_you_want = attributes[:'pay_what_you_want']
  else
    self.pay_what_you_want = false
  end

  if attributes.key?(:'metadata')
    if (value = attributes[:'metadata']).is_a?(Hash)
      self. = value
    end
  end

  if attributes.key?(:'custom_fields')
    if (value = attributes[:'custom_fields']).is_a?(Array)
      self.custom_fields = value
    end
  end

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

  if attributes.key?(:'is_listed')
    self.is_listed = attributes[:'is_listed']
  else
    self.is_listed = true
  end

  if attributes.key?(:'is_free')
    self.is_free = attributes[:'is_free']
  else
    self.is_free = false
  end

  if attributes.key?(:'addons')
    if (value = attributes[:'addons']).is_a?(Array)
      self.addons = value
    end
  end
end

Instance Attribute Details

#activation_limitObject

Maximum concurrent activated instances allowed per license key.



67
68
69
# File 'lib/solifyn/models/product_update.rb', line 67

def activation_limit
  @activation_limit
end

#addonsObject

Product addons configurations.



103
104
105
# File 'lib/solifyn/models/product_update.rb', line 103

def addons
  @addons
end

#billing_periodObject

Billing period in days (for Subscription products).



73
74
75
# File 'lib/solifyn/models/product_update.rb', line 73

def billing_period
  @billing_period
end

#brand_idObject

Brand id for the product, if not provided will default to primary brand.



70
71
72
# File 'lib/solifyn/models/product_update.rb', line 70

def brand_id
  @brand_id
end

#currencyObject

Product pricing currency.



28
29
30
# File 'lib/solifyn/models/product_update.rb', line 28

def currency
  @currency
end

#custom_fieldsObject

Form field configurations to gather during checkout.



91
92
93
# File 'lib/solifyn/models/product_update.rb', line 91

def custom_fields
  @custom_fields
end

#descriptionObject

A description of the product.



22
23
24
# File 'lib/solifyn/models/product_update.rb', line 22

def description
  @description
end

#discord_guild_idObject

Discord Guild (Server) ID to grant access to.



58
59
60
# File 'lib/solifyn/models/product_update.rb', line 58

def discord_guild_id
  @discord_guild_id
end

#discord_role_idObject

Discord Role ID to assign to the user.



61
62
63
# File 'lib/solifyn/models/product_update.rb', line 61

def discord_role_id
  @discord_role_id
end

#discountObject

Percentage or flat rate discount.



37
38
39
# File 'lib/solifyn/models/product_update.rb', line 37

def discount
  @discount
end

#expiration_daysObject

Subscription expiration duration in days.



79
80
81
# File 'lib/solifyn/models/product_update.rb', line 79

def expiration_days
  @expiration_days
end

#github_permissionObject

GitHub collaborator permission level.



52
53
54
# File 'lib/solifyn/models/product_update.rb', line 52

def github_permission
  @github_permission
end

#github_repoObject

GitHub repository to grant access to (format: owner/repo).



49
50
51
# File 'lib/solifyn/models/product_update.rb', line 49

def github_repo
  @github_repo
end

#has_digital_deliveryObject

Whether the purchase includes downloadable files.



43
44
45
# File 'lib/solifyn/models/product_update.rb', line 43

def has_digital_delivery
  @has_digital_delivery
end

#has_discord_accessObject

Whether the purchase includes Discord server role access.



55
56
57
# File 'lib/solifyn/models/product_update.rb', line 55

def has_discord_access
  @has_discord_access
end

#has_github_accessObject

Whether the purchase includes GitHub repository access.



46
47
48
# File 'lib/solifyn/models/product_update.rb', line 46

def has_github_access
  @has_github_access
end

#has_license_keyObject

Whether to automatically issue license keys upon successful orders.



40
41
42
# File 'lib/solifyn/models/product_update.rb', line 40

def has_license_key
  @has_license_key
end

#image_urlObject

URL of the product cover image.



31
32
33
# File 'lib/solifyn/models/product_update.rb', line 31

def image_url
  @image_url
end

#is_freeObject

Whether the product is free of charge.



100
101
102
# File 'lib/solifyn/models/product_update.rb', line 100

def is_free
  @is_free
end

#is_listedObject

Whether the product is publicly visible.



97
98
99
# File 'lib/solifyn/models/product_update.rb', line 97

def is_listed
  @is_listed
end

#is_tax_inclusiveObject

Whether tax is included in the base price.



64
65
66
# File 'lib/solifyn/models/product_update.rb', line 64

def is_tax_inclusive
  @is_tax_inclusive
end

#metadataObject

Developer key-value metadata pairs.



88
89
90
# File 'lib/solifyn/models/product_update.rb', line 88

def 
  @metadata
end

#nameObject

Product display name.



19
20
21
# File 'lib/solifyn/models/product_update.rb', line 19

def name
  @name
end

#pay_what_you_wantObject

Allow pay-what-you-want pricing.



85
86
87
# File 'lib/solifyn/models/product_update.rb', line 85

def pay_what_you_want
  @pay_what_you_want
end

#priceObject

Price value.



25
26
27
# File 'lib/solifyn/models/product_update.rb', line 25

def price
  @price
end

#statement_descriptorObject

Custom billing descriptor.



82
83
84
# File 'lib/solifyn/models/product_update.rb', line 82

def statement_descriptor
  @statement_descriptor
end

#stockObject

Initial stock quantity limit.



94
95
96
# File 'lib/solifyn/models/product_update.rb', line 94

def stock
  @stock
end

#tax_categoryObject

Tax classification.



34
35
36
# File 'lib/solifyn/models/product_update.rb', line 34

def tax_category
  @tax_category
end

#trial_period_daysObject

Trial duration in days.



76
77
78
# File 'lib/solifyn/models/product_update.rb', line 76

def trial_period_days
  @trial_period_days
end

Class Method Details

._deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
# File 'lib/solifyn/models/product_update.rb', line 490

def self._deserialize(type, value)
  case type.to_sym
  when :Time
    Time.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :Boolean
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    # models (e.g. Pet) or oneOf
    klass = Solifyn.const_get(type)
    klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
  end
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



163
164
165
# File 'lib/solifyn/models/product_update.rb', line 163

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

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



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
# File 'lib/solifyn/models/product_update.rb', line 128

def self.attribute_map
  {
    :'name' => :'name',
    :'description' => :'description',
    :'price' => :'price',
    :'currency' => :'currency',
    :'image_url' => :'imageUrl',
    :'tax_category' => :'taxCategory',
    :'discount' => :'discount',
    :'has_license_key' => :'hasLicenseKey',
    :'has_digital_delivery' => :'hasDigitalDelivery',
    :'has_github_access' => :'hasGithubAccess',
    :'github_repo' => :'githubRepo',
    :'github_permission' => :'githubPermission',
    :'has_discord_access' => :'hasDiscordAccess',
    :'discord_guild_id' => :'discordGuildId',
    :'discord_role_id' => :'discordRoleId',
    :'is_tax_inclusive' => :'isTaxInclusive',
    :'activation_limit' => :'activationLimit',
    :'brand_id' => :'brandId',
    :'billing_period' => :'billingPeriod',
    :'trial_period_days' => :'trialPeriodDays',
    :'expiration_days' => :'expirationDays',
    :'statement_descriptor' => :'statementDescriptor',
    :'pay_what_you_want' => :'payWhatYouWant',
    :'metadata' => :'metadata',
    :'custom_fields' => :'customFields',
    :'stock' => :'stock',
    :'is_listed' => :'isListed',
    :'is_free' => :'isFree',
    :'addons' => :'addons'
  }
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



466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
# File 'lib/solifyn/models/product_update.rb', line 466

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_nullableObject

List of attributes with nullable: true



203
204
205
206
# File 'lib/solifyn/models/product_update.rb', line 203

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

.openapi_typesObject

Attribute type mapping.



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/solifyn/models/product_update.rb', line 168

def self.openapi_types
  {
    :'name' => :'String',
    :'description' => :'String',
    :'price' => :'Float',
    :'currency' => :'String',
    :'image_url' => :'String',
    :'tax_category' => :'String',
    :'discount' => :'Float',
    :'has_license_key' => :'Boolean',
    :'has_digital_delivery' => :'Boolean',
    :'has_github_access' => :'Boolean',
    :'github_repo' => :'String',
    :'github_permission' => :'String',
    :'has_discord_access' => :'Boolean',
    :'discord_guild_id' => :'String',
    :'discord_role_id' => :'String',
    :'is_tax_inclusive' => :'Boolean',
    :'activation_limit' => :'Integer',
    :'brand_id' => :'String',
    :'billing_period' => :'Integer',
    :'trial_period_days' => :'Integer',
    :'expiration_days' => :'Integer',
    :'statement_descriptor' => :'String',
    :'pay_what_you_want' => :'Boolean',
    :'metadata' => :'Hash<String, String>',
    :'custom_fields' => :'Array<ProductCreateCustomFieldsInner>',
    :'stock' => :'Integer',
    :'is_listed' => :'Boolean',
    :'is_free' => :'Boolean',
    :'addons' => :'Array<ProductCreateAddonsInner>'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
# File 'lib/solifyn/models/product_update.rb', line 417

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      name == o.name &&
      description == o.description &&
      price == o.price &&
      currency == o.currency &&
      image_url == o.image_url &&
      tax_category == o.tax_category &&
      discount == o.discount &&
      has_license_key == o.has_license_key &&
      has_digital_delivery == o.has_digital_delivery &&
      has_github_access == o.has_github_access &&
      github_repo == o.github_repo &&
      github_permission == o.github_permission &&
      has_discord_access == o.has_discord_access &&
      discord_guild_id == o.discord_guild_id &&
      discord_role_id == o.discord_role_id &&
      is_tax_inclusive == o.is_tax_inclusive &&
      activation_limit == o.activation_limit &&
      brand_id == o.brand_id &&
      billing_period == o.billing_period &&
      trial_period_days == o.trial_period_days &&
      expiration_days == o.expiration_days &&
      statement_descriptor == o.statement_descriptor &&
      pay_what_you_want == o.pay_what_you_want &&
       == o. &&
      custom_fields == o.custom_fields &&
      stock == o.stock &&
      is_listed == o.is_listed &&
      is_free == o.is_free &&
      addons == o.addons
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



561
562
563
564
565
566
567
568
569
570
571
572
573
# File 'lib/solifyn/models/product_update.rb', line 561

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


453
454
455
# File 'lib/solifyn/models/product_update.rb', line 453

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



459
460
461
# File 'lib/solifyn/models/product_update.rb', line 459

def hash
  [name, description, price, currency, image_url, tax_category, discount, has_license_key, has_digital_delivery, has_github_access, github_repo, github_permission, has_discord_access, discord_guild_id, discord_role_id, is_tax_inclusive, activation_limit, brand_id, billing_period, trial_period_days, expiration_days, statement_descriptor, pay_what_you_want, , custom_fields, stock, is_listed, is_free, addons].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



366
367
368
369
370
# File 'lib/solifyn/models/product_update.rb', line 366

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



537
538
539
# File 'lib/solifyn/models/product_update.rb', line 537

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



543
544
545
546
547
548
549
550
551
552
553
554
555
# File 'lib/solifyn/models/product_update.rb', line 543

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

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



531
532
533
# File 'lib/solifyn/models/product_update.rb', line 531

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



374
375
376
377
378
379
380
381
382
383
# File 'lib/solifyn/models/product_update.rb', line 374

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  currency_validator = EnumAttributeValidator.new('String', ["USD", "SGD", "INR", "AUD", "BRL", "CAD", "DKK", "EUR", "NOK", "GBP", "SEK", "CHF", "HKD", "HUF", "JPY", "MXN", "MYR", "PLN", "CZK", "NZD", "AED", "COP", "RON", "THB", "BGN", "IDR", "DOP", "PHP", "TRY", "KRW", "TWD", "VND", "PKR", "CLP", "UYU", "ARS", "ZAR", "DZD", "TND", "MAD", "KES", "KWD", "JOD", "ALL", "XCD", "AMD", "BSD", "BHD", "BOB", "BAM", "KHR", "CRC", "XOF", "EGP", "ETB", "GMD", "GHS", "GTQ", "GYD", "ILS", "JMD", "MOP", "MGA", "MUR", "MDL", "MNT", "NAD", "NGN", "MKD", "OMR", "PYG", "PEN", "QAR", "RWF", "SAR", "RSD", "LKR", "TZS", "TTD", "UZS", "RUB", "CNY"])
  return false unless currency_validator.valid?(@currency)
  tax_category_validator = EnumAttributeValidator.new('String', ["digital_products", "saas", "physical_products", "service"])
  return false unless tax_category_validator.valid?(@tax_category)
  github_permission_validator = EnumAttributeValidator.new('String', ["pull", "triage", "push", "maintain", "admin"])
  return false unless github_permission_validator.valid?(@github_permission)
  true
end