Class: StickyIoRestfulApiV2025731::OfferData

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/sticky_io_restful_api_v2025731/models/offer_data.rb

Overview

OfferData Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(id:, name:, cycle_type_id:, expire_cycles:, is_seasonal:, created_at:, updated_at:, is_archived:, products:, billing_models:, is_prepaid:, type:, cycle_type:, terminating_cycle_type:, prepaid_profile:, trial:, cycle_products:, seasonal_products:, is_trial:, pivot:, additional_properties: nil) ⇒ OfferData

Returns a new instance of OfferData.



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
# File 'lib/sticky_io_restful_api_v2025731/models/offer_data.rb', line 131

def initialize(id:, name:, cycle_type_id:, expire_cycles:, is_seasonal:,
               created_at:, updated_at:, is_archived:, products:,
               billing_models:, is_prepaid:, type:, cycle_type:,
               terminating_cycle_type:, prepaid_profile:, trial:,
               cycle_products:, seasonal_products:, is_trial:, pivot:,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @id = id
  @name = name
  @cycle_type_id = cycle_type_id
  @expire_cycles = expire_cycles
  @is_seasonal = is_seasonal
  @created_at = created_at
  @updated_at = updated_at
  @is_archived = is_archived
  @products = products
  @billing_models = billing_models
  @is_prepaid = is_prepaid
  @type = type
  @cycle_type = cycle_type
  @terminating_cycle_type = terminating_cycle_type
  @prepaid_profile = prepaid_profile
  @trial = trial
  @cycle_products = cycle_products
  @seasonal_products = seasonal_products
  @is_trial = is_trial
  @pivot = pivot
  @additional_properties = additional_properties
end

Instance Attribute Details

#billing_modelsArray[BillingModel]

TODO: Write general description for this method

Returns:



50
51
52
# File 'lib/sticky_io_restful_api_v2025731/models/offer_data.rb', line 50

def billing_models
  @billing_models
end

#created_atCreatedAt

TODO: Write general description for this method

Returns:



34
35
36
# File 'lib/sticky_io_restful_api_v2025731/models/offer_data.rb', line 34

def created_at
  @created_at
end

#cycle_productsObject

TODO: Write general description for this method

Returns:

  • (Object)


78
79
80
# File 'lib/sticky_io_restful_api_v2025731/models/offer_data.rb', line 78

def cycle_products
  @cycle_products
end

#cycle_typeCycleType

TODO: Write general description for this method

Returns:



62
63
64
# File 'lib/sticky_io_restful_api_v2025731/models/offer_data.rb', line 62

def cycle_type
  @cycle_type
end

#cycle_type_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


22
23
24
# File 'lib/sticky_io_restful_api_v2025731/models/offer_data.rb', line 22

def cycle_type_id
  @cycle_type_id
end

#expire_cyclesInteger

TODO: Write general description for this method

Returns:

  • (Integer)


26
27
28
# File 'lib/sticky_io_restful_api_v2025731/models/offer_data.rb', line 26

def expire_cycles
  @expire_cycles
end

#idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


14
15
16
# File 'lib/sticky_io_restful_api_v2025731/models/offer_data.rb', line 14

def id
  @id
end

#is_archivedInteger

TODO: Write general description for this method

Returns:

  • (Integer)


42
43
44
# File 'lib/sticky_io_restful_api_v2025731/models/offer_data.rb', line 42

def is_archived
  @is_archived
end

#is_prepaidInteger

TODO: Write general description for this method

Returns:

  • (Integer)


54
55
56
# File 'lib/sticky_io_restful_api_v2025731/models/offer_data.rb', line 54

def is_prepaid
  @is_prepaid
end

#is_seasonalInteger

TODO: Write general description for this method

Returns:

  • (Integer)


30
31
32
# File 'lib/sticky_io_restful_api_v2025731/models/offer_data.rb', line 30

def is_seasonal
  @is_seasonal
end

#is_trialInteger

TODO: Write general description for this method

Returns:

  • (Integer)


86
87
88
# File 'lib/sticky_io_restful_api_v2025731/models/offer_data.rb', line 86

def is_trial
  @is_trial
end

#nameString

TODO: Write general description for this method

Returns:

  • (String)


18
19
20
# File 'lib/sticky_io_restful_api_v2025731/models/offer_data.rb', line 18

def name
  @name
end

#pivotPivot

TODO: Write general description for this method

Returns:



90
91
92
# File 'lib/sticky_io_restful_api_v2025731/models/offer_data.rb', line 90

def pivot
  @pivot
end

#prepaid_profileObject

TODO: Write general description for this method

Returns:

  • (Object)


70
71
72
# File 'lib/sticky_io_restful_api_v2025731/models/offer_data.rb', line 70

def prepaid_profile
  @prepaid_profile
end

#productsArray[Object]

TODO: Write general description for this method

Returns:

  • (Array[Object])


46
47
48
# File 'lib/sticky_io_restful_api_v2025731/models/offer_data.rb', line 46

def products
  @products
end

#seasonal_productsObject

TODO: Write general description for this method

Returns:

  • (Object)


82
83
84
# File 'lib/sticky_io_restful_api_v2025731/models/offer_data.rb', line 82

def seasonal_products
  @seasonal_products
end

#terminating_cycle_typeTerminatingCycleType

TODO: Write general description for this method



66
67
68
# File 'lib/sticky_io_restful_api_v2025731/models/offer_data.rb', line 66

def terminating_cycle_type
  @terminating_cycle_type
end

#trialObject

TODO: Write general description for this method

Returns:

  • (Object)


74
75
76
# File 'lib/sticky_io_restful_api_v2025731/models/offer_data.rb', line 74

def trial
  @trial
end

#typeTypeOffer

TODO: Write general description for this method

Returns:



58
59
60
# File 'lib/sticky_io_restful_api_v2025731/models/offer_data.rb', line 58

def type
  @type
end

#updated_atUpdatedAtOffer

TODO: Write general description for this method

Returns:



38
39
40
# File 'lib/sticky_io_restful_api_v2025731/models/offer_data.rb', line 38

def updated_at
  @updated_at
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
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
234
235
236
237
238
# File 'lib/sticky_io_restful_api_v2025731/models/offer_data.rb', line 164

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : nil
  name = hash.key?('name') ? hash['name'] : nil
  cycle_type_id = hash.key?('cycle_type_id') ? hash['cycle_type_id'] : nil
  expire_cycles = hash.key?('expire_cycles') ? hash['expire_cycles'] : nil
  is_seasonal = hash.key?('is_seasonal') ? hash['is_seasonal'] : nil
  created_at = CreatedAt.from_hash(hash['created_at']) if hash['created_at']
  updated_at = UpdatedAtOffer.from_hash(hash['updated_at']) if hash['updated_at']
  is_archived = hash.key?('is_archived') ? hash['is_archived'] : nil
  products = hash.key?('products') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:OfferDataProducts), hash['products']
  ) : nil
  # Parameter is an array, so we need to iterate through it
  billing_models = nil
  unless hash['billing_models'].nil?
    billing_models = []
    hash['billing_models'].each do |structure|
      billing_models << (BillingModel.from_hash(structure) if structure)
    end
  end

  billing_models = nil unless hash.key?('billing_models')
  is_prepaid = hash.key?('is_prepaid') ? hash['is_prepaid'] : nil
  type = TypeOffer.from_hash(hash['type']) if hash['type']
  cycle_type = CycleType.from_hash(hash['cycle_type']) if hash['cycle_type']
  terminating_cycle_type = TerminatingCycleType.from_hash(hash['terminating_cycle_type']) if
    hash['terminating_cycle_type']
  prepaid_profile = hash.key?('prepaid_profile') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:OfferDataPrepaidProfile), hash['prepaid_profile']
  ) : nil
  trial = hash.key?('trial') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:OfferDataTrial), hash['trial']
  ) : nil
  cycle_products = hash.key?('cycle_products') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:OfferDataCycleProducts), hash['cycle_products']
  ) : nil
  seasonal_products = hash.key?('seasonal_products') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:OfferDataSeasonalProducts), hash['seasonal_products']
  ) : nil
  is_trial = hash.key?('is_trial') ? hash['is_trial'] : nil
  pivot = Pivot.from_hash(hash['pivot']) if hash['pivot']

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  OfferData.new(id: id,
                name: name,
                cycle_type_id: cycle_type_id,
                expire_cycles: expire_cycles,
                is_seasonal: is_seasonal,
                created_at: created_at,
                updated_at: updated_at,
                is_archived: is_archived,
                products: products,
                billing_models: billing_models,
                is_prepaid: is_prepaid,
                type: type,
                cycle_type: cycle_type,
                terminating_cycle_type: terminating_cycle_type,
                prepaid_profile: prepaid_profile,
                trial: trial,
                cycle_products: cycle_products,
                seasonal_products: seasonal_products,
                is_trial: is_trial,
                pivot: pivot,
                additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/sticky_io_restful_api_v2025731/models/offer_data.rb', line 93

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['name'] = 'name'
  @_hash['cycle_type_id'] = 'cycle_type_id'
  @_hash['expire_cycles'] = 'expire_cycles'
  @_hash['is_seasonal'] = 'is_seasonal'
  @_hash['created_at'] = 'created_at'
  @_hash['updated_at'] = 'updated_at'
  @_hash['is_archived'] = 'is_archived'
  @_hash['products'] = 'products'
  @_hash['billing_models'] = 'billing_models'
  @_hash['is_prepaid'] = 'is_prepaid'
  @_hash['type'] = 'type'
  @_hash['cycle_type'] = 'cycle_type'
  @_hash['terminating_cycle_type'] = 'terminating_cycle_type'
  @_hash['prepaid_profile'] = 'prepaid_profile'
  @_hash['trial'] = 'trial'
  @_hash['cycle_products'] = 'cycle_products'
  @_hash['seasonal_products'] = 'seasonal_products'
  @_hash['is_trial'] = 'is_trial'
  @_hash['pivot'] = 'pivot'
  @_hash
end

.nullablesObject

An array for nullable fields



124
125
126
127
128
129
# File 'lib/sticky_io_restful_api_v2025731/models/offer_data.rb', line 124

def self.nullables
  %w[
    cycle_products
    seasonal_products
  ]
end

.optionalsObject

An array for optional fields



119
120
121
# File 'lib/sticky_io_restful_api_v2025731/models/offer_data.rb', line 119

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (OfferData | Hash)

    value against the validation is performed.



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
# File 'lib/sticky_io_restful_api_v2025731/models/offer_data.rb', line 242

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.id,
                            ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.name,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.cycle_type_id,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.expire_cycles,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.is_seasonal,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.created_at,
                              ->(val) { CreatedAt.validate(val) },
                              is_model_hash: true) and
        APIHelper.valid_type?(value.updated_at,
                              ->(val) { UpdatedAtOffer.validate(val) },
                              is_model_hash: true) and
        APIHelper.valid_type?(value.is_archived,
                              ->(val) { val.instance_of? Integer }) and
        UnionTypeLookUp.get(:OfferDataProducts)
                       .validate(value.products) and
        APIHelper.valid_type?(value.billing_models,
                              ->(val) { BillingModel.validate(val) },
                              is_model_hash: true,
                              is_inner_model_hash: true) and
        APIHelper.valid_type?(value.is_prepaid,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.type,
                              ->(val) { TypeOffer.validate(val) },
                              is_model_hash: true) and
        APIHelper.valid_type?(value.cycle_type,
                              ->(val) { CycleType.validate(val) },
                              is_model_hash: true) and
        APIHelper.valid_type?(value.terminating_cycle_type,
                              ->(val) { TerminatingCycleType.validate(val) },
                              is_model_hash: true) and
        UnionTypeLookUp.get(:OfferDataPrepaidProfile)
                       .validate(value.prepaid_profile) and
        UnionTypeLookUp.get(:OfferDataTrial)
                       .validate(value.trial) and
        UnionTypeLookUp.get(:OfferDataCycleProducts)
                       .validate(value.cycle_products) and
        UnionTypeLookUp.get(:OfferDataSeasonalProducts)
                       .validate(value.seasonal_products) and
        APIHelper.valid_type?(value.is_trial,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.pivot,
                              ->(val) { Pivot.validate(val) },
                              is_model_hash: true)
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['id'],
                          ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['name'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['cycle_type_id'],
                            ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['expire_cycles'],
                            ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['is_seasonal'],
                            ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['created_at'],
                            ->(val) { CreatedAt.validate(val) },
                            is_model_hash: true) and
      APIHelper.valid_type?(value['updated_at'],
                            ->(val) { UpdatedAtOffer.validate(val) },
                            is_model_hash: true) and
      APIHelper.valid_type?(value['is_archived'],
                            ->(val) { val.instance_of? Integer }) and
      UnionTypeLookUp.get(:OfferDataProducts)
                     .validate(value['products']) and
      APIHelper.valid_type?(value['billing_models'],
                            ->(val) { BillingModel.validate(val) },
                            is_model_hash: true,
                            is_inner_model_hash: true) and
      APIHelper.valid_type?(value['is_prepaid'],
                            ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['type'],
                            ->(val) { TypeOffer.validate(val) },
                            is_model_hash: true) and
      APIHelper.valid_type?(value['cycle_type'],
                            ->(val) { CycleType.validate(val) },
                            is_model_hash: true) and
      APIHelper.valid_type?(value['terminating_cycle_type'],
                            ->(val) { TerminatingCycleType.validate(val) },
                            is_model_hash: true) and
      UnionTypeLookUp.get(:OfferDataPrepaidProfile)
                     .validate(value['prepaid_profile']) and
      UnionTypeLookUp.get(:OfferDataTrial)
                     .validate(value['trial']) and
      UnionTypeLookUp.get(:OfferDataCycleProducts)
                     .validate(value['cycle_products']) and
      UnionTypeLookUp.get(:OfferDataSeasonalProducts)
                     .validate(value['seasonal_products']) and
      APIHelper.valid_type?(value['is_trial'],
                            ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['pivot'],
                            ->(val) { Pivot.validate(val) },
                            is_model_hash: true)
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



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

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id.inspect}, name: #{@name.inspect}, cycle_type_id:"\
  " #{@cycle_type_id.inspect}, expire_cycles: #{@expire_cycles.inspect}, is_seasonal:"\
  " #{@is_seasonal.inspect}, created_at: #{@created_at.inspect}, updated_at:"\
  " #{@updated_at.inspect}, is_archived: #{@is_archived.inspect}, products:"\
  " #{@products.inspect}, billing_models: #{@billing_models.inspect}, is_prepaid:"\
  " #{@is_prepaid.inspect}, type: #{@type.inspect}, cycle_type: #{@cycle_type.inspect},"\
  " terminating_cycle_type: #{@terminating_cycle_type.inspect}, prepaid_profile:"\
  " #{@prepaid_profile.inspect}, trial: #{@trial.inspect}, cycle_products:"\
  " #{@cycle_products.inspect}, seasonal_products: #{@seasonal_products.inspect}, is_trial:"\
  " #{@is_trial.inspect}, pivot: #{@pivot.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



351
352
353
354
355
356
357
358
359
360
361
# File 'lib/sticky_io_restful_api_v2025731/models/offer_data.rb', line 351

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id}, name: #{@name}, cycle_type_id: #{@cycle_type_id},"\
  " expire_cycles: #{@expire_cycles}, is_seasonal: #{@is_seasonal}, created_at:"\
  " #{@created_at}, updated_at: #{@updated_at}, is_archived: #{@is_archived}, products:"\
  " #{@products}, billing_models: #{@billing_models}, is_prepaid: #{@is_prepaid}, type:"\
  " #{@type}, cycle_type: #{@cycle_type}, terminating_cycle_type: #{@terminating_cycle_type},"\
  " prepaid_profile: #{@prepaid_profile}, trial: #{@trial}, cycle_products:"\
  " #{@cycle_products}, seasonal_products: #{@seasonal_products}, is_trial: #{@is_trial},"\
  " pivot: #{@pivot}, additional_properties: #{@additional_properties}>"
end