Class: StickyIoRestfulApiV2025731::LegacySubscription

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

Overview

LegacySubscription 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(next_product_id:, type:, type_name:, cycle:, week:, week_name:, day:, day_name:, additional_properties: nil) ⇒ LegacySubscription

Returns a new instance of LegacySubscription.



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/sticky_io_restful_api_v2025731/models/legacy_subscription.rb', line 74

def initialize(next_product_id:, type:, type_name:, cycle:, week:,
               week_name:, day:, day_name:, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @next_product_id = next_product_id
  @type = type
  @type_name = type_name
  @cycle = cycle
  @week = week
  @week_name = week_name
  @day = day
  @day_name = day_name
  @additional_properties = additional_properties
end

Instance Attribute Details

#cycleInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def cycle
  @cycle
end

#dayString

TODO: Write general description for this method

Returns:

  • (String)


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

def day
  @day
end

#day_nameString

TODO: Write general description for this method

Returns:

  • (String)


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

def day_name
  @day_name
end

#next_product_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def next_product_id
  @next_product_id
end

#typeInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def type
  @type
end

#type_nameString

TODO: Write general description for this method

Returns:

  • (String)


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

def type_name
  @type_name
end

#weekString

TODO: Write general description for this method

Returns:

  • (String)


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

def week
  @week
end

#week_nameString

TODO: Write general description for this method

Returns:

  • (String)


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

def week_name
  @week_name
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/sticky_io_restful_api_v2025731/models/legacy_subscription.rb', line 91

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  next_product_id =
    hash.key?('next_product_id') ? hash['next_product_id'] : nil
  type = hash.key?('type') ? hash['type'] : nil
  type_name = hash.key?('type_name') ? hash['type_name'] : nil
  cycle = hash.key?('cycle') ? hash['cycle'] : nil
  week = hash.key?('week') ? hash['week'] : nil
  week_name = hash.key?('week_name') ? hash['week_name'] : nil
  day = hash.key?('day') ? hash['day'] : nil
  day_name = hash.key?('day_name') ? hash['day_name'] : 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.
  LegacySubscription.new(next_product_id: next_product_id,
                         type: type,
                         type_name: type_name,
                         cycle: cycle,
                         week: week,
                         week_name: week_name,
                         day: day,
                         day_name: day_name,
                         additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/sticky_io_restful_api_v2025731/models/legacy_subscription.rb', line 45

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['next_product_id'] = 'next_product_id'
  @_hash['type'] = 'type'
  @_hash['type_name'] = 'type_name'
  @_hash['cycle'] = 'cycle'
  @_hash['week'] = 'week'
  @_hash['week_name'] = 'week_name'
  @_hash['day'] = 'day'
  @_hash['day_name'] = 'day_name'
  @_hash
end

.nullablesObject

An array for nullable fields



64
65
66
67
68
69
70
71
72
# File 'lib/sticky_io_restful_api_v2025731/models/legacy_subscription.rb', line 64

def self.nullables
  %w[
    type_name
    week
    week_name
    day
    day_name
  ]
end

.optionalsObject

An array for optional fields



59
60
61
# File 'lib/sticky_io_restful_api_v2025731/models/legacy_subscription.rb', line 59

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



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

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.next_product_id,
                            ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.type,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.type_name,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.cycle,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.week,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.week_name,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.day,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.day_name,
                              ->(val) { val.instance_of? String })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['next_product_id'],
                          ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['type'],
                            ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['type_name'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['cycle'],
                            ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['week'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['week_name'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['day'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['day_name'],
                            ->(val) { val.instance_of? String })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



179
180
181
182
183
184
185
# File 'lib/sticky_io_restful_api_v2025731/models/legacy_subscription.rb', line 179

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} next_product_id: #{@next_product_id.inspect}, type: #{@type.inspect},"\
  " type_name: #{@type_name.inspect}, cycle: #{@cycle.inspect}, week: #{@week.inspect},"\
  " week_name: #{@week_name.inspect}, day: #{@day.inspect}, day_name: #{@day_name.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



171
172
173
174
175
176
# File 'lib/sticky_io_restful_api_v2025731/models/legacy_subscription.rb', line 171

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} next_product_id: #{@next_product_id}, type: #{@type}, type_name:"\
  " #{@type_name}, cycle: #{@cycle}, week: #{@week}, week_name: #{@week_name}, day: #{@day},"\
  " day_name: #{@day_name}, additional_properties: #{@additional_properties}>"
end