Class: StickyIoRestfulApiV2025731::DataGetVolumeDiscounts

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

Overview

DataGetVolumeDiscounts 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:, description:, is_active:, created_at:, updated_at:, created_by:, updated_by:, is_exclude_non_recurring:, apply_to_type_id:, quantities:, products:, campaigns:, additional_properties: nil) ⇒ DataGetVolumeDiscounts

Returns a new instance of DataGetVolumeDiscounts.



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/data_get_volume_discounts.rb', line 95

def initialize(id:, name:, description:, is_active:, created_at:,
               updated_at:, created_by:, updated_by:,
               is_exclude_non_recurring:, apply_to_type_id:, quantities:,
               products:, campaigns:, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @id = id
  @name = name
  @description = description
  @is_active = is_active
  @created_at = created_at
  @updated_at = updated_at
  @created_by = created_by
  @updated_by = updated_by
  @is_exclude_non_recurring = is_exclude_non_recurring
  @apply_to_type_id = apply_to_type_id
  @quantities = quantities
  @products = products
  @campaigns = campaigns
  @additional_properties = additional_properties
end

Instance Attribute Details

#apply_to_type_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def apply_to_type_id
  @apply_to_type_id
end

#campaignsArray[Object]

TODO: Write general description for this method

Returns:

  • (Array[Object])


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

def campaigns
  @campaigns
end

#created_atString

TODO: Write general description for this method

Returns:

  • (String)


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

def created_at
  @created_at
end

#created_byInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def created_by
  @created_by
end

#descriptionString

TODO: Write general description for this method

Returns:

  • (String)


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

def description
  @description
end

#idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def id
  @id
end

#is_activeInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def is_active
  @is_active
end

#is_exclude_non_recurringInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def is_exclude_non_recurring
  @is_exclude_non_recurring
end

#nameString

TODO: Write general description for this method

Returns:

  • (String)


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

def name
  @name
end

#productsArray[Object]

TODO: Write general description for this method

Returns:

  • (Array[Object])


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

def products
  @products
end

#quantitiesArray[Object]

TODO: Write general description for this method

Returns:

  • (Array[Object])


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

def quantities
  @quantities
end

#updated_atString

TODO: Write general description for this method

Returns:

  • (String)


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

def updated_at
  @updated_at
end

#updated_byObject

TODO: Write general description for this method

Returns:

  • (Object)


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

def updated_by
  @updated_by
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



119
120
121
122
123
124
125
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
# File 'lib/sticky_io_restful_api_v2025731/models/data_get_volume_discounts.rb', line 119

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
  description = hash.key?('description') ? hash['description'] : nil
  is_active = hash.key?('is_active') ? hash['is_active'] : nil
  created_at = hash.key?('created_at') ? hash['created_at'] : nil
  updated_at = hash.key?('updated_at') ? hash['updated_at'] : nil
  created_by = hash.key?('created_by') ? hash['created_by'] : nil
  updated_by = hash.key?('updated_by') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:DataGetVolumeDiscountsUpdatedBy), hash['updated_by']
  ) : nil
  is_exclude_non_recurring =
    hash.key?('is_exclude_non_recurring') ? hash['is_exclude_non_recurring'] : nil
  apply_to_type_id =
    hash.key?('apply_to_type_id') ? hash['apply_to_type_id'] : nil
  quantities = hash.key?('quantities') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:DataGetVolumeDiscountsQuantities), hash['quantities']
  ) : nil
  products = hash.key?('products') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:DataGetVolumeDiscountsProducts), hash['products']
  ) : nil
  campaigns = hash.key?('campaigns') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:DataGetVolumeDiscountsCampaigns), hash['campaigns']
  ) : nil

  # 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.
  DataGetVolumeDiscounts.new(id: id,
                             name: name,
                             description: description,
                             is_active: is_active,
                             created_at: created_at,
                             updated_at: updated_at,
                             created_by: created_by,
                             updated_by: updated_by,
                             is_exclude_non_recurring: is_exclude_non_recurring,
                             apply_to_type_id: apply_to_type_id,
                             quantities: quantities,
                             products: products,
                             campaigns: campaigns,
                             additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/sticky_io_restful_api_v2025731/models/data_get_volume_discounts.rb', line 65

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['name'] = 'name'
  @_hash['description'] = 'description'
  @_hash['is_active'] = 'is_active'
  @_hash['created_at'] = 'created_at'
  @_hash['updated_at'] = 'updated_at'
  @_hash['created_by'] = 'created_by'
  @_hash['updated_by'] = 'updated_by'
  @_hash['is_exclude_non_recurring'] = 'is_exclude_non_recurring'
  @_hash['apply_to_type_id'] = 'apply_to_type_id'
  @_hash['quantities'] = 'quantities'
  @_hash['products'] = 'products'
  @_hash['campaigns'] = 'campaigns'
  @_hash
end

.nullablesObject

An array for nullable fields



89
90
91
92
93
# File 'lib/sticky_io_restful_api_v2025731/models/data_get_volume_discounts.rb', line 89

def self.nullables
  %w[
    updated_by
  ]
end

.optionalsObject

An array for optional fields



84
85
86
# File 'lib/sticky_io_restful_api_v2025731/models/data_get_volume_discounts.rb', line 84

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



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

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.description,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.is_active,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.created_at,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.updated_at,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.created_by,
                              ->(val) { val.instance_of? Integer }) and
        UnionTypeLookUp.get(:DataGetVolumeDiscountsUpdatedBy)
                       .validate(value.updated_by) and
        APIHelper.valid_type?(value.is_exclude_non_recurring,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.apply_to_type_id,
                              ->(val) { val.instance_of? Integer }) and
        UnionTypeLookUp.get(:DataGetVolumeDiscountsQuantities)
                       .validate(value.quantities) and
        UnionTypeLookUp.get(:DataGetVolumeDiscountsProducts)
                       .validate(value.products) and
        UnionTypeLookUp.get(:DataGetVolumeDiscountsCampaigns)
                       .validate(value.campaigns)
    )
  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['description'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['is_active'],
                            ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['created_at'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['updated_at'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['created_by'],
                            ->(val) { val.instance_of? Integer }) and
      UnionTypeLookUp.get(:DataGetVolumeDiscountsUpdatedBy)
                     .validate(value['updated_by']) and
      APIHelper.valid_type?(value['is_exclude_non_recurring'],
                            ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['apply_to_type_id'],
                            ->(val) { val.instance_of? Integer }) and
      UnionTypeLookUp.get(:DataGetVolumeDiscountsQuantities)
                     .validate(value['quantities']) and
      UnionTypeLookUp.get(:DataGetVolumeDiscountsProducts)
                     .validate(value['products']) and
      UnionTypeLookUp.get(:DataGetVolumeDiscountsCampaigns)
                     .validate(value['campaigns'])
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



249
250
251
252
253
254
255
256
257
258
# File 'lib/sticky_io_restful_api_v2025731/models/data_get_volume_discounts.rb', line 249

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id.inspect}, name: #{@name.inspect}, description:"\
  " #{@description.inspect}, is_active: #{@is_active.inspect}, created_at:"\
  " #{@created_at.inspect}, updated_at: #{@updated_at.inspect}, created_by:"\
  " #{@created_by.inspect}, updated_by: #{@updated_by.inspect}, is_exclude_non_recurring:"\
  " #{@is_exclude_non_recurring.inspect}, apply_to_type_id: #{@apply_to_type_id.inspect},"\
  " quantities: #{@quantities.inspect}, products: #{@products.inspect}, campaigns:"\
  " #{@campaigns.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



238
239
240
241
242
243
244
245
246
# File 'lib/sticky_io_restful_api_v2025731/models/data_get_volume_discounts.rb', line 238

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id}, name: #{@name}, description: #{@description}, is_active:"\
  " #{@is_active}, created_at: #{@created_at}, updated_at: #{@updated_at}, created_by:"\
  " #{@created_by}, updated_by: #{@updated_by}, is_exclude_non_recurring:"\
  " #{@is_exclude_non_recurring}, apply_to_type_id: #{@apply_to_type_id}, quantities:"\
  " #{@quantities}, products: #{@products}, campaigns: #{@campaigns}, additional_properties:"\
  " #{@additional_properties}>"
end