kleister 1.14.1 → 1.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -0
  3. data/README.md +3 -3
  4. data/lib/kleister/api/auth_api.rb +137 -73
  5. data/lib/kleister/api/fabric_api.rb +37 -42
  6. data/lib/kleister/api/forge_api.rb +37 -42
  7. data/lib/kleister/api/{team_api.rb → group_api.rb} +359 -379
  8. data/lib/kleister/api/minecraft_api.rb +37 -42
  9. data/lib/kleister/api/mod_api.rb +471 -232
  10. data/lib/kleister/api/neoforge_api.rb +37 -42
  11. data/lib/kleister/api/pack_api.rb +215 -240
  12. data/lib/kleister/api/profile_api.rb +16 -16
  13. data/lib/kleister/api/quilt_api.rb +37 -42
  14. data/lib/kleister/api/user_api.rb +259 -279
  15. data/lib/kleister/api_client.rb +1 -1
  16. data/lib/kleister/api_error.rb +1 -1
  17. data/lib/kleister/configuration.rb +1 -8
  18. data/lib/kleister/models/{build_version_params.rb → attach_build_to_version_request.rb} +8 -20
  19. data/lib/kleister/models/{quilt_build_params.rb → attach_minecraft_to_build_request.rb} +8 -20
  20. data/lib/kleister/models/auth_token.rb +1 -1
  21. data/lib/kleister/models/auth_verify.rb +1 -1
  22. data/lib/kleister/models/build.rb +3 -13
  23. data/lib/kleister/models/build_version.rb +2 -3
  24. data/lib/kleister/models/{pack_back.rb → create_build_request.rb} +76 -58
  25. data/lib/kleister/models/{mods.rb → create_group_request.rb} +19 -18
  26. data/lib/kleister/models/{pack_icon.rb → create_mod_request.rb} +48 -54
  27. data/lib/kleister/models/{forge_builds.rb → create_pack_request.rb} +33 -23
  28. data/lib/kleister/models/create_user_request.rb +257 -0
  29. data/lib/kleister/models/{builds.rb → create_version_request.rb} +25 -23
  30. data/lib/kleister/models/{packs.rb → delete_group_from_mod_request.rb} +20 -21
  31. data/lib/kleister/models/delete_group_from_pack_request.rb +219 -0
  32. data/lib/kleister/models/delete_pack_from_group_request.rb +219 -0
  33. data/lib/kleister/models/{users.rb → delete_pack_from_user_request.rb} +20 -21
  34. data/lib/kleister/models/fabric.rb +1 -1
  35. data/lib/kleister/models/forge.rb +1 -1
  36. data/lib/kleister/models/{team.rb → group.rb} +5 -5
  37. data/lib/kleister/models/{team_mod.rb → group_mod.rb} +21 -21
  38. data/lib/kleister/models/{team_pack.rb → group_pack.rb} +21 -21
  39. data/lib/kleister/models/{build_versions.rb → list_build_versions200_response.rb} +56 -18
  40. data/lib/kleister/models/{pack_teams.rb → list_builds200_response.rb} +59 -20
  41. data/lib/kleister/models/{fabric_builds.rb → list_fabric_builds200_response.rb} +56 -18
  42. data/lib/kleister/models/{fabrics.rb → list_fabrics200_response.rb} +52 -13
  43. data/lib/kleister/models/list_forge_builds200_response.rb +266 -0
  44. data/lib/kleister/models/{forges.rb → list_forges200_response.rb} +52 -13
  45. data/lib/kleister/models/list_group_mods200_response.rb +266 -0
  46. data/lib/kleister/models/list_group_packs200_response.rb +266 -0
  47. data/lib/kleister/models/list_group_users200_response.rb +266 -0
  48. data/lib/kleister/models/list_groups200_response.rb +259 -0
  49. data/lib/kleister/models/{minecraft_builds.rb → list_minecraft_builds200_response.rb} +56 -18
  50. data/lib/kleister/models/list_minecrafts200_response.rb +259 -0
  51. data/lib/kleister/models/list_mod_groups200_response.rb +266 -0
  52. data/lib/kleister/models/list_mod_users200_response.rb +266 -0
  53. data/lib/kleister/models/{team_mods.rb → list_mods200_response.rb} +52 -20
  54. data/lib/kleister/models/{neoforge_builds.rb → list_neoforge_builds200_response.rb} +56 -18
  55. data/lib/kleister/models/{neoforges.rb → list_neoforges200_response.rb} +52 -13
  56. data/lib/kleister/models/list_pack_groups200_response.rb +266 -0
  57. data/lib/kleister/models/{pack_users.rb → list_pack_users200_response.rb} +56 -17
  58. data/lib/kleister/models/list_packs200_response.rb +259 -0
  59. data/lib/kleister/models/{mod_teams.rb → list_providers200_response.rb} +31 -23
  60. data/lib/kleister/models/{quilt_builds.rb → list_quilt_builds200_response.rb} +56 -17
  61. data/lib/kleister/models/{quilts.rb → list_quilts200_response.rb} +52 -13
  62. data/lib/kleister/models/list_user_groups200_response.rb +266 -0
  63. data/lib/kleister/models/{user_teams.rb → list_user_mods200_response.rb} +59 -20
  64. data/lib/kleister/models/{user_packs.rb → list_user_packs200_response.rb} +56 -17
  65. data/lib/kleister/models/{team_users.rb → list_users200_response.rb} +52 -20
  66. data/lib/kleister/models/{version_builds.rb → list_version_builds200_response.rb} +56 -18
  67. data/lib/kleister/models/{versions.rb → list_versions200_response.rb} +52 -13
  68. data/lib/kleister/models/{auth_login.rb → login_auth_request.rb} +4 -4
  69. data/lib/kleister/models/minecraft.rb +1 -1
  70. data/lib/kleister/models/mod.rb +10 -3
  71. data/lib/kleister/models/{team_packs.rb → mod_avatar.rb} +32 -23
  72. data/lib/kleister/models/neoforge.rb +1 -1
  73. data/lib/kleister/models/notification.rb +2 -3
  74. data/lib/kleister/models/pack.rb +8 -22
  75. data/lib/kleister/models/{minecrafts.rb → pack_avatar.rb} +34 -18
  76. data/lib/kleister/models/{mod_users.rb → permit_group_mod_request.rb} +29 -25
  77. data/lib/kleister/models/{forge_build_params.rb → permit_group_pack_request.rb} +15 -17
  78. data/lib/kleister/models/{fabric_build_params.rb → permit_pack_group_request.rb} +24 -26
  79. data/lib/kleister/models/{user_mods.rb → permit_pack_user_request.rb} +29 -25
  80. data/lib/kleister/models/profile.rb +20 -20
  81. data/lib/kleister/models/provider.rb +1 -1
  82. data/lib/kleister/models/quilt.rb +1 -1
  83. data/lib/kleister/models/{teams.rb → redirect_auth_request.rb} +20 -21
  84. data/lib/kleister/models/update_profile_request.rb +237 -0
  85. data/lib/kleister/models/update_user_request.rb +253 -0
  86. data/lib/kleister/models/user.rb +1 -1
  87. data/lib/kleister/models/user_auth.rb +1 -1
  88. data/lib/kleister/models/{user_team.rb → user_group.rb} +23 -23
  89. data/lib/kleister/models/user_mod.rb +1 -1
  90. data/lib/kleister/models/user_pack.rb +1 -1
  91. data/lib/kleister/models/validation.rb +1 -1
  92. data/lib/kleister/models/version.rb +3 -11
  93. data/lib/kleister/models/version_file.rb +3 -18
  94. data/lib/kleister/version.rb +2 -2
  95. data/lib/kleister.rb +57 -56
  96. metadata +58 -57
  97. data/lib/kleister/models/minecraft_build_params.rb +0 -233
  98. data/lib/kleister/models/mod_team_params.rb +0 -265
  99. data/lib/kleister/models/mod_user_params.rb +0 -265
  100. data/lib/kleister/models/neoforge_build_params.rb +0 -233
  101. data/lib/kleister/models/pack_logo.rb +0 -275
  102. data/lib/kleister/models/pack_team_params.rb +0 -265
  103. data/lib/kleister/models/pack_user_params.rb +0 -265
  104. data/lib/kleister/models/providers.rb +0 -220
  105. data/lib/kleister/models/team_mod_params.rb +0 -265
  106. data/lib/kleister/models/team_pack_params.rb +0 -265
  107. data/lib/kleister/models/team_user_params.rb +0 -265
  108. data/lib/kleister/models/user_mod_params.rb +0 -265
  109. data/lib/kleister/models/user_pack_params.rb +0 -265
  110. data/lib/kleister/models/user_team_params.rb +0 -265
  111. data/lib/kleister/models/version_build_params.rb +0 -233
@@ -1,275 +0,0 @@
1
- # Kleister OpenAPI
2
- #
3
- # API definition for Kleister, manage mod packs for Minecraft
4
- #
5
- # The version of the OpenAPI document: 1.0.0-alpha1
6
- # Contact: kleister@webhippie.de
7
- # Generated by: https://openapi-generator.tech
8
- # Generator version: 7.6.0
9
- #
10
-
11
- require 'date'
12
- require 'time'
13
-
14
- module Kleister
15
- # Model to represent pack logo
16
- class PackLogo
17
- attr_accessor :id, :slug, :content_type, :md5, :path, :url, :upload, :created_at, :updated_at
18
-
19
- # Attribute mapping from ruby-style variable name to JSON key.
20
- def self.attribute_map
21
- {
22
- id: :id,
23
- slug: :slug,
24
- content_type: :content_type,
25
- md5: :md5,
26
- path: :path,
27
- url: :url,
28
- upload: :upload,
29
- created_at: :created_at,
30
- updated_at: :updated_at
31
- }
32
- end
33
-
34
- # Returns all the JSON keys this model knows about
35
- def self.acceptable_attributes
36
- attribute_map.values
37
- end
38
-
39
- # Attribute type mapping.
40
- def self.openapi_types
41
- {
42
- id: :String,
43
- slug: :String,
44
- content_type: :String,
45
- md5: :String,
46
- path: :String,
47
- url: :String,
48
- upload: :String,
49
- created_at: :Time,
50
- updated_at: :Time
51
- }
52
- end
53
-
54
- # List of attributes with nullable: true
55
- def self.openapi_nullable
56
- Set.new(%i[
57
- slug
58
- content_type
59
- md5
60
- path
61
- url
62
- upload
63
- ])
64
- end
65
-
66
- # Initializes the object
67
- # @param [Hash] attributes Model attributes in the form of hash
68
- def initialize(attributes = {})
69
- unless attributes.is_a?(Hash)
70
- raise ArgumentError, 'The input argument (attributes) must be a hash in `Kleister::PackLogo` initialize method'
71
- end
72
-
73
- # check to see if the attribute exists and convert string to symbol for hash key
74
- attributes = attributes.each_with_object({}) do |(k, v), h|
75
- unless self.class.attribute_map.key?(k.to_sym)
76
- raise ArgumentError, "`#{k}` is not a valid attribute in `Kleister::PackLogo`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
77
- end
78
-
79
- h[k.to_sym] = v
80
- end
81
-
82
- if attributes.key?(:id)
83
- self.id = attributes[:id]
84
- end
85
-
86
- if attributes.key?(:slug)
87
- self.slug = attributes[:slug]
88
- end
89
-
90
- if attributes.key?(:content_type)
91
- self.content_type = attributes[:content_type]
92
- end
93
-
94
- if attributes.key?(:md5)
95
- self.md5 = attributes[:md5]
96
- end
97
-
98
- if attributes.key?(:path)
99
- self.path = attributes[:path]
100
- end
101
-
102
- if attributes.key?(:url)
103
- self.url = attributes[:url]
104
- end
105
-
106
- if attributes.key?(:upload)
107
- self.upload = attributes[:upload]
108
- end
109
-
110
- if attributes.key?(:created_at)
111
- self.created_at = attributes[:created_at]
112
- end
113
-
114
- if attributes.key?(:updated_at)
115
- self.updated_at = attributes[:updated_at]
116
- end
117
- end
118
-
119
- # Show invalid properties with the reasons. Usually used together with valid?
120
- # @return Array for valid properties with the reasons
121
- def list_invalid_properties
122
- warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
123
- []
124
- end
125
-
126
- # Check to see if the all the properties in the model are valid
127
- # @return true if the model is valid
128
- def valid?
129
- warn '[DEPRECATED] the `valid?` method is obsolete'
130
- true
131
- end
132
-
133
- # Checks equality by comparing each attribute.
134
- # @param [Object] Object to be compared
135
- def ==(other)
136
- return true if equal?(other)
137
-
138
- self.class == other.class &&
139
- id == other.id &&
140
- slug == other.slug &&
141
- content_type == other.content_type &&
142
- md5 == other.md5 &&
143
- path == other.path &&
144
- url == other.url &&
145
- upload == other.upload &&
146
- created_at == other.created_at &&
147
- updated_at == other.updated_at
148
- end
149
-
150
- # @see the `==` method
151
- # @param [Object] Object to be compared
152
- def eql?(other)
153
- self == other
154
- end
155
-
156
- # Calculates hash code according to all attributes.
157
- # @return [Integer] Hash code
158
- def hash
159
- [id, slug, content_type, md5, path, url, upload, created_at, updated_at].hash
160
- end
161
-
162
- # Builds the object from hash
163
- # @param [Hash] attributes Model attributes in the form of hash
164
- # @return [Object] Returns the model itself
165
- def self.build_from_hash(attributes)
166
- return nil unless attributes.is_a?(Hash)
167
-
168
- attributes = attributes.transform_keys(&:to_sym)
169
- transformed_hash = {}
170
- openapi_types.each_pair do |key, type|
171
- if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
172
- transformed_hash[key.to_s] = nil
173
- elsif type =~ /\AArray<(.*)>/i
174
- # check to ensure the input is an array given that the attribute
175
- # is documented as an array but the input is not
176
- if attributes[attribute_map[key]].is_a?(Array)
177
- transformed_hash[key.to_s] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
178
- end
179
- elsif !attributes[attribute_map[key]].nil?
180
- transformed_hash[key.to_s] = _deserialize(type, attributes[attribute_map[key]])
181
- end
182
- end
183
- new(transformed_hash)
184
- end
185
-
186
- # Deserializes the data based on type
187
- # @param string type Data type
188
- # @param string value Value to be deserialized
189
- # @return [Object] Deserialized data
190
- def self._deserialize(type, value)
191
- case type.to_sym
192
- when :Time
193
- Time.parse(value)
194
- when :Date
195
- Date.parse(value)
196
- when :String
197
- value.to_s
198
- when :Integer
199
- value.to_i
200
- when :Float
201
- value.to_f
202
- when :Boolean
203
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
204
- true
205
- else
206
- false
207
- end
208
- when :Object
209
- # generic object (usually a Hash), return directly
210
- value
211
- when /\AArray<(?<inner_type>.+)>\z/
212
- inner_type = Regexp.last_match[:inner_type]
213
- value.map { |v| _deserialize(inner_type, v) }
214
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
215
- k_type = Regexp.last_match[:k_type]
216
- v_type = Regexp.last_match[:v_type]
217
- {}.tap do |hash|
218
- value.each do |k, v|
219
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
220
- end
221
- end
222
- else # model
223
- # models (e.g. Pet) or oneOf
224
- klass = Kleister.const_get(type)
225
- klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
226
- end
227
- end
228
-
229
- # Returns the string representation of the object
230
- # @return [String] String presentation of the object
231
- def to_s
232
- to_hash.to_s
233
- end
234
-
235
- # to_body is an alias to to_hash (backward compatibility)
236
- # @return [Hash] Returns the object in the form of hash
237
- def to_body
238
- to_hash
239
- end
240
-
241
- # Returns the object in the form of hash
242
- # @return [Hash] Returns the object in the form of hash
243
- def to_hash
244
- hash = {}
245
- self.class.attribute_map.each_pair do |attr, param|
246
- value = send(attr)
247
- if value.nil?
248
- is_nullable = self.class.openapi_nullable.include?(attr)
249
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
250
- end
251
-
252
- hash[param] = _to_hash(value)
253
- end
254
- hash
255
- end
256
-
257
- # Outputs non-array value in the form of hash
258
- # For object, use to_hash. Otherwise, just return the value
259
- # @param [Object] value Any valid value
260
- # @return [Hash] Returns the value in the form of hash
261
- def _to_hash(value)
262
- if value.is_a?(Array)
263
- value.compact.map { |v| _to_hash(v) }
264
- elsif value.is_a?(Hash)
265
- {}.tap do |hash|
266
- value.each { |k, v| hash[k] = _to_hash(v) }
267
- end
268
- elsif value.respond_to? :to_hash
269
- value.to_hash
270
- else
271
- value
272
- end
273
- end
274
- end
275
- end
@@ -1,265 +0,0 @@
1
- # Kleister OpenAPI
2
- #
3
- # API definition for Kleister, manage mod packs for Minecraft
4
- #
5
- # The version of the OpenAPI document: 1.0.0-alpha1
6
- # Contact: kleister@webhippie.de
7
- # Generated by: https://openapi-generator.tech
8
- # Generator version: 7.6.0
9
- #
10
-
11
- require 'date'
12
- require 'time'
13
-
14
- module Kleister
15
- # Parameters to attach or unlink pack team
16
- class PackTeamParams
17
- attr_accessor :team, :perm
18
-
19
- class EnumAttributeValidator
20
- attr_reader :datatype, :allowable_values
21
-
22
- def initialize(datatype, allowable_values)
23
- @allowable_values = allowable_values.map do |value|
24
- case datatype.to_s
25
- when /Integer/i
26
- value.to_i
27
- when /Float/i
28
- value.to_f
29
- else
30
- value
31
- end
32
- end
33
- end
34
-
35
- def valid?(value)
36
- !value || allowable_values.include?(value)
37
- end
38
- end
39
-
40
- # Attribute mapping from ruby-style variable name to JSON key.
41
- def self.attribute_map
42
- {
43
- team: :team,
44
- perm: :perm
45
- }
46
- end
47
-
48
- # Returns all the JSON keys this model knows about
49
- def self.acceptable_attributes
50
- attribute_map.values
51
- end
52
-
53
- # Attribute type mapping.
54
- def self.openapi_types
55
- {
56
- team: :String,
57
- perm: :String
58
- }
59
- end
60
-
61
- # List of attributes with nullable: true
62
- def self.openapi_nullable
63
- Set.new([
64
- ])
65
- end
66
-
67
- # Initializes the object
68
- # @param [Hash] attributes Model attributes in the form of hash
69
- def initialize(attributes = {})
70
- unless attributes.is_a?(Hash)
71
- raise ArgumentError, 'The input argument (attributes) must be a hash in `Kleister::PackTeamParams` initialize method'
72
- end
73
-
74
- # check to see if the attribute exists and convert string to symbol for hash key
75
- attributes = attributes.each_with_object({}) do |(k, v), h|
76
- unless self.class.attribute_map.key?(k.to_sym)
77
- raise ArgumentError,
78
- "`#{k}` is not a valid attribute in `Kleister::PackTeamParams`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
79
- end
80
-
81
- h[k.to_sym] = v
82
- end
83
-
84
- self.team = if attributes.key?(:team)
85
- attributes[:team]
86
- end
87
-
88
- self.perm = if attributes.key?(:perm)
89
- attributes[:perm]
90
- else
91
- 'user'
92
- end
93
- end
94
-
95
- # Show invalid properties with the reasons. Usually used together with valid?
96
- # @return Array for valid properties with the reasons
97
- def list_invalid_properties
98
- warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
99
- invalid_properties = []
100
- if @team.nil?
101
- invalid_properties.push('invalid value for "team", team cannot be nil.')
102
- end
103
-
104
- invalid_properties
105
- end
106
-
107
- # Check to see if the all the properties in the model are valid
108
- # @return true if the model is valid
109
- def valid?
110
- warn '[DEPRECATED] the `valid?` method is obsolete'
111
- return false if @team.nil?
112
-
113
- perm_validator = EnumAttributeValidator.new('String', %w[user admin owner])
114
- return false unless perm_validator.valid?(@perm)
115
-
116
- true
117
- end
118
-
119
- # Custom attribute writer method checking allowed values (enum).
120
- # @param [Object] perm Object to be assigned
121
- def perm=(perm)
122
- validator = EnumAttributeValidator.new('String', %w[user admin owner])
123
- unless validator.valid?(perm)
124
- raise ArgumentError, "invalid value for \"perm\", must be one of #{validator.allowable_values}."
125
- end
126
-
127
- @perm = perm
128
- end
129
-
130
- # Checks equality by comparing each attribute.
131
- # @param [Object] Object to be compared
132
- def ==(other)
133
- return true if equal?(other)
134
-
135
- self.class == other.class &&
136
- team == other.team &&
137
- perm == other.perm
138
- end
139
-
140
- # @see the `==` method
141
- # @param [Object] Object to be compared
142
- def eql?(other)
143
- self == other
144
- end
145
-
146
- # Calculates hash code according to all attributes.
147
- # @return [Integer] Hash code
148
- def hash
149
- [team, perm].hash
150
- end
151
-
152
- # Builds the object from hash
153
- # @param [Hash] attributes Model attributes in the form of hash
154
- # @return [Object] Returns the model itself
155
- def self.build_from_hash(attributes)
156
- return nil unless attributes.is_a?(Hash)
157
-
158
- attributes = attributes.transform_keys(&:to_sym)
159
- transformed_hash = {}
160
- openapi_types.each_pair do |key, type|
161
- if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
162
- transformed_hash[key.to_s] = nil
163
- elsif type =~ /\AArray<(.*)>/i
164
- # check to ensure the input is an array given that the attribute
165
- # is documented as an array but the input is not
166
- if attributes[attribute_map[key]].is_a?(Array)
167
- transformed_hash[key.to_s] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
168
- end
169
- elsif !attributes[attribute_map[key]].nil?
170
- transformed_hash[key.to_s] = _deserialize(type, attributes[attribute_map[key]])
171
- end
172
- end
173
- new(transformed_hash)
174
- end
175
-
176
- # Deserializes the data based on type
177
- # @param string type Data type
178
- # @param string value Value to be deserialized
179
- # @return [Object] Deserialized data
180
- def self._deserialize(type, value)
181
- case type.to_sym
182
- when :Time
183
- Time.parse(value)
184
- when :Date
185
- Date.parse(value)
186
- when :String
187
- value.to_s
188
- when :Integer
189
- value.to_i
190
- when :Float
191
- value.to_f
192
- when :Boolean
193
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
194
- true
195
- else
196
- false
197
- end
198
- when :Object
199
- # generic object (usually a Hash), return directly
200
- value
201
- when /\AArray<(?<inner_type>.+)>\z/
202
- inner_type = Regexp.last_match[:inner_type]
203
- value.map { |v| _deserialize(inner_type, v) }
204
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
205
- k_type = Regexp.last_match[:k_type]
206
- v_type = Regexp.last_match[:v_type]
207
- {}.tap do |hash|
208
- value.each do |k, v|
209
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
210
- end
211
- end
212
- else # model
213
- # models (e.g. Pet) or oneOf
214
- klass = Kleister.const_get(type)
215
- klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
216
- end
217
- end
218
-
219
- # Returns the string representation of the object
220
- # @return [String] String presentation of the object
221
- def to_s
222
- to_hash.to_s
223
- end
224
-
225
- # to_body is an alias to to_hash (backward compatibility)
226
- # @return [Hash] Returns the object in the form of hash
227
- def to_body
228
- to_hash
229
- end
230
-
231
- # Returns the object in the form of hash
232
- # @return [Hash] Returns the object in the form of hash
233
- def to_hash
234
- hash = {}
235
- self.class.attribute_map.each_pair do |attr, param|
236
- value = send(attr)
237
- if value.nil?
238
- is_nullable = self.class.openapi_nullable.include?(attr)
239
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
240
- end
241
-
242
- hash[param] = _to_hash(value)
243
- end
244
- hash
245
- end
246
-
247
- # Outputs non-array value in the form of hash
248
- # For object, use to_hash. Otherwise, just return the value
249
- # @param [Object] value Any valid value
250
- # @return [Hash] Returns the value in the form of hash
251
- def _to_hash(value)
252
- if value.is_a?(Array)
253
- value.compact.map { |v| _to_hash(v) }
254
- elsif value.is_a?(Hash)
255
- {}.tap do |hash|
256
- value.each { |k, v| hash[k] = _to_hash(v) }
257
- end
258
- elsif value.respond_to? :to_hash
259
- value.to_hash
260
- else
261
- value
262
- end
263
- end
264
- end
265
- end