Class: StickyIoRestfulApiV2025731::Unit

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

Overview

Unit 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(step_number:, name:, duration:, price:, is_parent_cancellable:, is_shippable:, is_notifiable:, is_one_time_pairable:, shipping_price_type_id:, product_id: SKIP, shipping_price: SKIP, additional_properties: nil) ⇒ Unit

Returns a new instance of Unit.



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

def initialize(step_number:, name:, duration:, price:,
               is_parent_cancellable:, is_shippable:, is_notifiable:,
               is_one_time_pairable:, shipping_price_type_id:,
               product_id: SKIP, shipping_price: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @step_number = step_number
  @name = name
  @duration = duration
  @price = price
  @is_parent_cancellable = is_parent_cancellable
  @product_id = product_id unless product_id == SKIP
  @is_shippable = is_shippable
  @is_notifiable = is_notifiable
  @is_one_time_pairable = is_one_time_pairable
  @shipping_price_type_id = shipping_price_type_id
  @shipping_price = shipping_price unless shipping_price == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#durationInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def duration
  @duration
end

#is_notifiableInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def is_notifiable
  @is_notifiable
end

#is_one_time_pairableInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def is_one_time_pairable
  @is_one_time_pairable
end

#is_parent_cancellableInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def is_parent_cancellable
  @is_parent_cancellable
end

#is_shippableInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def is_shippable
  @is_shippable
end

#nameString

TODO: Write general description for this method

Returns:

  • (String)


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

def name
  @name
end

#priceFloat

TODO: Write general description for this method

Returns:

  • (Float)


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

def price
  @price
end

#product_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def product_id
  @product_id
end

#shipping_priceFloat

TODO: Write general description for this method

Returns:

  • (Float)


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

def shipping_price
  @shipping_price
end

#shipping_price_type_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def shipping_price_type_id
  @shipping_price_type_id
end

#step_numberInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def step_number
  @step_number
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



109
110
111
112
113
114
115
116
117
118
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
# File 'lib/sticky_io_restful_api_v2025731/models/unit.rb', line 109

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  step_number = hash.key?('step_number') ? hash['step_number'] : nil
  name = hash.key?('name') ? hash['name'] : nil
  duration = hash.key?('duration') ? hash['duration'] : nil
  price = hash.key?('price') ? hash['price'] : nil
  is_parent_cancellable =
    hash.key?('is_parent_cancellable') ? hash['is_parent_cancellable'] : nil
  is_shippable = hash.key?('is_shippable') ? hash['is_shippable'] : nil
  is_notifiable = hash.key?('is_notifiable') ? hash['is_notifiable'] : nil
  is_one_time_pairable =
    hash.key?('is_one_time_pairable') ? hash['is_one_time_pairable'] : nil
  shipping_price_type_id =
    hash.key?('shipping_price_type_id') ? hash['shipping_price_type_id'] : nil
  product_id = hash.key?('product_id') ? hash['product_id'] : SKIP
  shipping_price =
    hash.key?('shipping_price') ? hash['shipping_price'] : 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.
  Unit.new(step_number: step_number,
           name: name,
           duration: duration,
           price: price,
           is_parent_cancellable: is_parent_cancellable,
           is_shippable: is_shippable,
           is_notifiable: is_notifiable,
           is_one_time_pairable: is_one_time_pairable,
           shipping_price_type_id: shipping_price_type_id,
           product_id: product_id,
           shipping_price: shipping_price,
           additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/sticky_io_restful_api_v2025731/models/unit.rb', line 57

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['step_number'] = 'step_number'
  @_hash['name'] = 'name'
  @_hash['duration'] = 'duration'
  @_hash['price'] = 'price'
  @_hash['is_parent_cancellable'] = 'is_parent_cancellable'
  @_hash['product_id'] = 'product_id'
  @_hash['is_shippable'] = 'is_shippable'
  @_hash['is_notifiable'] = 'is_notifiable'
  @_hash['is_one_time_pairable'] = 'is_one_time_pairable'
  @_hash['shipping_price_type_id'] = 'shipping_price_type_id'
  @_hash['shipping_price'] = 'shipping_price'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  []
end

.optionalsObject

An array for optional fields



74
75
76
77
78
79
# File 'lib/sticky_io_restful_api_v2025731/models/unit.rb', line 74

def self.optionals
  %w[
    product_id
    shipping_price
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



163
164
165
166
167
168
169
170
171
172
# File 'lib/sticky_io_restful_api_v2025731/models/unit.rb', line 163

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} step_number: #{@step_number.inspect}, name: #{@name.inspect}, duration:"\
  " #{@duration.inspect}, price: #{@price.inspect}, is_parent_cancellable:"\
  " #{@is_parent_cancellable.inspect}, product_id: #{@product_id.inspect}, is_shippable:"\
  " #{@is_shippable.inspect}, is_notifiable: #{@is_notifiable.inspect}, is_one_time_pairable:"\
  " #{@is_one_time_pairable.inspect}, shipping_price_type_id:"\
  " #{@shipping_price_type_id.inspect}, shipping_price: #{@shipping_price.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



152
153
154
155
156
157
158
159
160
# File 'lib/sticky_io_restful_api_v2025731/models/unit.rb', line 152

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} step_number: #{@step_number}, name: #{@name}, duration: #{@duration},"\
  " price: #{@price}, is_parent_cancellable: #{@is_parent_cancellable}, product_id:"\
  " #{@product_id}, is_shippable: #{@is_shippable}, is_notifiable: #{@is_notifiable},"\
  " is_one_time_pairable: #{@is_one_time_pairable}, shipping_price_type_id:"\
  " #{@shipping_price_type_id}, shipping_price: #{@shipping_price}, additional_properties:"\
  " #{@additional_properties}>"
end