Class: StickyIoRestfulApiV2025731::DiscountsData1

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

Overview

DiscountsData1 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(type:, total:, product_id: SKIP, code: SKIP, valid: SKIP, error: SKIP, additional_properties: nil) ⇒ DiscountsData1

Returns a new instance of DiscountsData1.



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

def initialize(type:, total:, product_id: SKIP, code: SKIP, valid: SKIP,
               error: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @type = type
  @product_id = product_id unless product_id == SKIP
  @total = total
  @code = code unless code == SKIP
  @valid = valid unless valid == SKIP
  @error = error unless error == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#codeString

TODO: Write general description for this method

Returns:

  • (String)


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

def code
  @code
end

#errorString

TODO: Write general description for this method

Returns:

  • (String)


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

def error
  @error
end

#product_idString

TODO: Write general description for this method

Returns:

  • (String)


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

def product_id
  @product_id
end

#totalFloat

TODO: Write general description for this method

Returns:

  • (Float)


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

def total
  @total
end

#typeString

TODO: Write general description for this method

Returns:

  • (String)


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

def type
  @type
end

#validTrueClass | FalseClass

TODO: Write general description for this method

Returns:

  • (TrueClass | FalseClass)


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

def valid
  @valid
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/sticky_io_restful_api_v2025731/models/discounts_data1.rb', line 81

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  type = hash.key?('type') ? hash['type'] : nil
  total = hash.key?('total') ? hash['total'] : nil
  product_id = hash.key?('product_id') ? hash['product_id'] : SKIP
  code = hash.key?('code') ? hash['code'] : SKIP
  valid = hash.key?('valid') ? hash['valid'] : SKIP
  error = hash.key?('error') ? hash['error'] : SKIP

  # 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.
  DiscountsData1.new(type: type,
                     total: total,
                     product_id: product_id,
                     code: code,
                     valid: valid,
                     error: error,
                     additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



37
38
39
40
41
42
43
44
45
46
# File 'lib/sticky_io_restful_api_v2025731/models/discounts_data1.rb', line 37

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['type'] = 'type'
  @_hash['product_id'] = 'product_id'
  @_hash['total'] = 'total'
  @_hash['code'] = 'code'
  @_hash['valid'] = 'valid'
  @_hash['error'] = 'error'
  @_hash
end

.nullablesObject

An array for nullable fields



59
60
61
62
63
64
# File 'lib/sticky_io_restful_api_v2025731/models/discounts_data1.rb', line 59

def self.nullables
  %w[
    code
    error
  ]
end

.optionalsObject

An array for optional fields



49
50
51
52
53
54
55
56
# File 'lib/sticky_io_restful_api_v2025731/models/discounts_data1.rb', line 49

def self.optionals
  %w[
    product_id
    code
    valid
    error
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



118
119
120
121
122
123
# File 'lib/sticky_io_restful_api_v2025731/models/discounts_data1.rb', line 118

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} type: #{@type.inspect}, product_id: #{@product_id.inspect}, total:"\
  " #{@total.inspect}, code: #{@code.inspect}, valid: #{@valid.inspect}, error:"\
  " #{@error.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



110
111
112
113
114
115
# File 'lib/sticky_io_restful_api_v2025731/models/discounts_data1.rb', line 110

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} type: #{@type}, product_id: #{@product_id}, total: #{@total}, code:"\
  " #{@code}, valid: #{@valid}, error: #{@error}, additional_properties:"\
  " #{@additional_properties}>"
end