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
@@ -0,0 +1,266 @@
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.12.0
9
+ #
10
+
11
+ require 'date'
12
+ require 'time'
13
+
14
+ module Kleister
15
+ class ListPackGroups200Response
16
+ attr_accessor :total, :limit, :offset, :pack, :groups
17
+
18
+ # Attribute mapping from ruby-style variable name to JSON key.
19
+ def self.attribute_map
20
+ {
21
+ total: :total,
22
+ limit: :limit,
23
+ offset: :offset,
24
+ pack: :pack,
25
+ groups: :groups
26
+ }
27
+ end
28
+
29
+ # Returns all the JSON keys this model knows about
30
+ def self.acceptable_attributes
31
+ attribute_map.values
32
+ end
33
+
34
+ # Attribute type mapping.
35
+ def self.openapi_types
36
+ {
37
+ total: :Integer,
38
+ limit: :Integer,
39
+ offset: :Integer,
40
+ pack: :Pack,
41
+ groups: :'Array<GroupPack>'
42
+ }
43
+ end
44
+
45
+ # List of attributes with nullable: true
46
+ def self.openapi_nullable
47
+ Set.new([
48
+ ])
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ unless attributes.is_a?(Hash)
55
+ raise ArgumentError, 'The input argument (attributes) must be a hash in `Kleister::ListPackGroups200Response` initialize method'
56
+ end
57
+
58
+ # check to see if the attribute exists and convert string to symbol for hash key
59
+ attributes = attributes.each_with_object({}) do |(k, v), h|
60
+ unless self.class.attribute_map.key?(k.to_sym)
61
+ raise ArgumentError, "`#{k}` is not a valid attribute in `Kleister::ListPackGroups200Response`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
62
+ end
63
+
64
+ h[k.to_sym] = v
65
+ end
66
+
67
+ self.total = if attributes.key?(:total)
68
+ attributes[:total]
69
+ end
70
+
71
+ self.limit = if attributes.key?(:limit)
72
+ attributes[:limit]
73
+ end
74
+
75
+ self.offset = if attributes.key?(:offset)
76
+ attributes[:offset]
77
+ end
78
+
79
+ if attributes.key?(:pack)
80
+ self.pack = attributes[:pack]
81
+ end
82
+
83
+ if attributes.key?(:groups)
84
+ if (value = attributes[:groups]).is_a?(Array)
85
+ self.groups = value
86
+ end
87
+ else
88
+ self.groups = nil
89
+ end
90
+ end
91
+
92
+ # Show invalid properties with the reasons. Usually used together with valid?
93
+ # @return Array for valid properties with the reasons
94
+ def list_invalid_properties
95
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
96
+ invalid_properties = []
97
+ if @total.nil?
98
+ invalid_properties.push('invalid value for "total", total cannot be nil.')
99
+ end
100
+
101
+ if @limit.nil?
102
+ invalid_properties.push('invalid value for "limit", limit cannot be nil.')
103
+ end
104
+
105
+ if @offset.nil?
106
+ invalid_properties.push('invalid value for "offset", offset cannot be nil.')
107
+ end
108
+
109
+ if @groups.nil?
110
+ invalid_properties.push('invalid value for "groups", groups cannot be nil.')
111
+ end
112
+
113
+ invalid_properties
114
+ end
115
+
116
+ # Check to see if the all the properties in the model are valid
117
+ # @return true if the model is valid
118
+ def valid?
119
+ warn '[DEPRECATED] the `valid?` method is obsolete'
120
+ return false if @total.nil?
121
+ return false if @limit.nil?
122
+ return false if @offset.nil?
123
+ return false if @groups.nil?
124
+
125
+ true
126
+ end
127
+
128
+ # Checks equality by comparing each attribute.
129
+ # @param [Object] Object to be compared
130
+ def ==(other)
131
+ return true if equal?(other)
132
+
133
+ self.class == other.class &&
134
+ total == other.total &&
135
+ limit == other.limit &&
136
+ offset == other.offset &&
137
+ pack == other.pack &&
138
+ groups == other.groups
139
+ end
140
+
141
+ # @see the `==` method
142
+ # @param [Object] Object to be compared
143
+ def eql?(other)
144
+ self == other
145
+ end
146
+
147
+ # Calculates hash code according to all attributes.
148
+ # @return [Integer] Hash code
149
+ def hash
150
+ [total, limit, offset, pack, groups].hash
151
+ end
152
+
153
+ # Builds the object from hash
154
+ # @param [Hash] attributes Model attributes in the form of hash
155
+ # @return [Object] Returns the model itself
156
+ def self.build_from_hash(attributes)
157
+ return nil unless attributes.is_a?(Hash)
158
+
159
+ attributes = attributes.transform_keys(&:to_sym)
160
+ transformed_hash = {}
161
+ openapi_types.each_pair do |key, type|
162
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
163
+ transformed_hash[key.to_s] = nil
164
+ elsif type =~ /\AArray<(.*)>/i
165
+ # check to ensure the input is an array given that the attribute
166
+ # is documented as an array but the input is not
167
+ if attributes[attribute_map[key]].is_a?(Array)
168
+ transformed_hash[key.to_s] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
169
+ end
170
+ elsif !attributes[attribute_map[key]].nil?
171
+ transformed_hash[key.to_s] = _deserialize(type, attributes[attribute_map[key]])
172
+ end
173
+ end
174
+ new(transformed_hash)
175
+ end
176
+
177
+ # Deserializes the data based on type
178
+ # @param string type Data type
179
+ # @param string value Value to be deserialized
180
+ # @return [Object] Deserialized data
181
+ def self._deserialize(type, value)
182
+ case type.to_sym
183
+ when :Time
184
+ Time.parse(value)
185
+ when :Date
186
+ Date.parse(value)
187
+ when :String
188
+ value.to_s
189
+ when :Integer
190
+ value.to_i
191
+ when :Float
192
+ value.to_f
193
+ when :Boolean
194
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
195
+ true
196
+ else
197
+ false
198
+ end
199
+ when :Object
200
+ # generic object (usually a Hash), return directly
201
+ value
202
+ when /\AArray<(?<inner_type>.+)>\z/
203
+ inner_type = Regexp.last_match[:inner_type]
204
+ value.map { |v| _deserialize(inner_type, v) }
205
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
206
+ k_type = Regexp.last_match[:k_type]
207
+ v_type = Regexp.last_match[:v_type]
208
+ {}.tap do |hash|
209
+ value.each do |k, v|
210
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
211
+ end
212
+ end
213
+ else # model
214
+ # models (e.g. Pet) or oneOf
215
+ klass = Kleister.const_get(type)
216
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
217
+ end
218
+ end
219
+
220
+ # Returns the string representation of the object
221
+ # @return [String] String presentation of the object
222
+ def to_s
223
+ to_hash.to_s
224
+ end
225
+
226
+ # to_body is an alias to to_hash (backward compatibility)
227
+ # @return [Hash] Returns the object in the form of hash
228
+ def to_body
229
+ to_hash
230
+ end
231
+
232
+ # Returns the object in the form of hash
233
+ # @return [Hash] Returns the object in the form of hash
234
+ def to_hash
235
+ hash = {}
236
+ self.class.attribute_map.each_pair do |attr, param|
237
+ value = send(attr)
238
+ if value.nil?
239
+ is_nullable = self.class.openapi_nullable.include?(attr)
240
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
241
+ end
242
+
243
+ hash[param] = _to_hash(value)
244
+ end
245
+ hash
246
+ end
247
+
248
+ # Outputs non-array value in the form of hash
249
+ # For object, use to_hash. Otherwise, just return the value
250
+ # @param [Object] value Any valid value
251
+ # @return [Hash] Returns the value in the form of hash
252
+ def _to_hash(value)
253
+ if value.is_a?(Array)
254
+ value.compact.map { |v| _to_hash(v) }
255
+ elsif value.is_a?(Hash)
256
+ {}.tap do |hash|
257
+ value.each { |k, v| hash[k] = _to_hash(v) }
258
+ end
259
+ elsif value.respond_to? :to_hash
260
+ value.to_hash
261
+ else
262
+ value
263
+ end
264
+ end
265
+ end
266
+ end
@@ -5,22 +5,23 @@
5
5
  # The version of the OpenAPI document: 1.0.0-alpha1
6
6
  # Contact: kleister@webhippie.de
7
7
  # Generated by: https://openapi-generator.tech
8
- # Generator version: 7.6.0
8
+ # Generator version: 7.12.0
9
9
  #
10
10
 
11
11
  require 'date'
12
12
  require 'time'
13
13
 
14
14
  module Kleister
15
- # Model to represent pack users
16
- class PackUsers
17
- attr_accessor :pack, :total, :users
15
+ class ListPackUsers200Response
16
+ attr_accessor :total, :limit, :offset, :pack, :users
18
17
 
19
18
  # Attribute mapping from ruby-style variable name to JSON key.
20
19
  def self.attribute_map
21
20
  {
22
- pack: :pack,
23
21
  total: :total,
22
+ limit: :limit,
23
+ offset: :offset,
24
+ pack: :pack,
24
25
  users: :users
25
26
  }
26
27
  end
@@ -33,8 +34,10 @@ module Kleister
33
34
  # Attribute type mapping.
34
35
  def self.openapi_types
35
36
  {
36
- pack: :Pack,
37
37
  total: :Integer,
38
+ limit: :Integer,
39
+ offset: :Integer,
40
+ pack: :Pack,
38
41
  users: :'Array<UserPack>'
39
42
  }
40
43
  end
@@ -49,28 +52,40 @@ module Kleister
49
52
  # @param [Hash] attributes Model attributes in the form of hash
50
53
  def initialize(attributes = {})
51
54
  unless attributes.is_a?(Hash)
52
- raise ArgumentError, 'The input argument (attributes) must be a hash in `Kleister::PackUsers` initialize method'
55
+ raise ArgumentError, 'The input argument (attributes) must be a hash in `Kleister::ListPackUsers200Response` initialize method'
53
56
  end
54
57
 
55
58
  # check to see if the attribute exists and convert string to symbol for hash key
56
59
  attributes = attributes.each_with_object({}) do |(k, v), h|
57
60
  unless self.class.attribute_map.key?(k.to_sym)
58
- raise ArgumentError, "`#{k}` is not a valid attribute in `Kleister::PackUsers`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
61
+ raise ArgumentError, "`#{k}` is not a valid attribute in `Kleister::ListPackUsers200Response`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
59
62
  end
60
63
 
61
64
  h[k.to_sym] = v
62
65
  end
63
66
 
67
+ self.total = if attributes.key?(:total)
68
+ attributes[:total]
69
+ end
70
+
71
+ self.limit = if attributes.key?(:limit)
72
+ attributes[:limit]
73
+ end
74
+
75
+ self.offset = if attributes.key?(:offset)
76
+ attributes[:offset]
77
+ end
78
+
64
79
  if attributes.key?(:pack)
65
80
  self.pack = attributes[:pack]
66
81
  end
67
82
 
68
- if attributes.key?(:total)
69
- self.total = attributes[:total]
70
- end
71
-
72
- if attributes.key?(:users) && (value = attributes[:users]).is_a?(Array)
73
- self.users = value
83
+ if attributes.key?(:users)
84
+ if (value = attributes[:users]).is_a?(Array)
85
+ self.users = value
86
+ end
87
+ else
88
+ self.users = nil
74
89
  end
75
90
  end
76
91
 
@@ -78,13 +93,35 @@ module Kleister
78
93
  # @return Array for valid properties with the reasons
79
94
  def list_invalid_properties
80
95
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
81
- []
96
+ invalid_properties = []
97
+ if @total.nil?
98
+ invalid_properties.push('invalid value for "total", total cannot be nil.')
99
+ end
100
+
101
+ if @limit.nil?
102
+ invalid_properties.push('invalid value for "limit", limit cannot be nil.')
103
+ end
104
+
105
+ if @offset.nil?
106
+ invalid_properties.push('invalid value for "offset", offset cannot be nil.')
107
+ end
108
+
109
+ if @users.nil?
110
+ invalid_properties.push('invalid value for "users", users cannot be nil.')
111
+ end
112
+
113
+ invalid_properties
82
114
  end
83
115
 
84
116
  # Check to see if the all the properties in the model are valid
85
117
  # @return true if the model is valid
86
118
  def valid?
87
119
  warn '[DEPRECATED] the `valid?` method is obsolete'
120
+ return false if @total.nil?
121
+ return false if @limit.nil?
122
+ return false if @offset.nil?
123
+ return false if @users.nil?
124
+
88
125
  true
89
126
  end
90
127
 
@@ -94,8 +131,10 @@ module Kleister
94
131
  return true if equal?(other)
95
132
 
96
133
  self.class == other.class &&
97
- pack == other.pack &&
98
134
  total == other.total &&
135
+ limit == other.limit &&
136
+ offset == other.offset &&
137
+ pack == other.pack &&
99
138
  users == other.users
100
139
  end
101
140
 
@@ -108,7 +147,7 @@ module Kleister
108
147
  # Calculates hash code according to all attributes.
109
148
  # @return [Integer] Hash code
110
149
  def hash
111
- [pack, total, users].hash
150
+ [total, limit, offset, pack, users].hash
112
151
  end
113
152
 
114
153
  # Builds the object from hash
@@ -0,0 +1,259 @@
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.12.0
9
+ #
10
+
11
+ require 'date'
12
+ require 'time'
13
+
14
+ module Kleister
15
+ class ListPacks200Response
16
+ attr_accessor :total, :limit, :offset, :packs
17
+
18
+ # Attribute mapping from ruby-style variable name to JSON key.
19
+ def self.attribute_map
20
+ {
21
+ total: :total,
22
+ limit: :limit,
23
+ offset: :offset,
24
+ packs: :packs
25
+ }
26
+ end
27
+
28
+ # Returns all the JSON keys this model knows about
29
+ def self.acceptable_attributes
30
+ attribute_map.values
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.openapi_types
35
+ {
36
+ total: :Integer,
37
+ limit: :Integer,
38
+ offset: :Integer,
39
+ packs: :'Array<Pack>'
40
+ }
41
+ end
42
+
43
+ # List of attributes with nullable: true
44
+ def self.openapi_nullable
45
+ Set.new([
46
+ ])
47
+ end
48
+
49
+ # Initializes the object
50
+ # @param [Hash] attributes Model attributes in the form of hash
51
+ def initialize(attributes = {})
52
+ unless attributes.is_a?(Hash)
53
+ raise ArgumentError, 'The input argument (attributes) must be a hash in `Kleister::ListPacks200Response` initialize method'
54
+ end
55
+
56
+ # check to see if the attribute exists and convert string to symbol for hash key
57
+ attributes = attributes.each_with_object({}) do |(k, v), h|
58
+ unless self.class.attribute_map.key?(k.to_sym)
59
+ raise ArgumentError, "`#{k}` is not a valid attribute in `Kleister::ListPacks200Response`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
60
+ end
61
+
62
+ h[k.to_sym] = v
63
+ end
64
+
65
+ self.total = if attributes.key?(:total)
66
+ attributes[:total]
67
+ end
68
+
69
+ self.limit = if attributes.key?(:limit)
70
+ attributes[:limit]
71
+ end
72
+
73
+ self.offset = if attributes.key?(:offset)
74
+ attributes[:offset]
75
+ end
76
+
77
+ if attributes.key?(:packs)
78
+ if (value = attributes[:packs]).is_a?(Array)
79
+ self.packs = value
80
+ end
81
+ else
82
+ self.packs = nil
83
+ end
84
+ end
85
+
86
+ # Show invalid properties with the reasons. Usually used together with valid?
87
+ # @return Array for valid properties with the reasons
88
+ def list_invalid_properties
89
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
90
+ invalid_properties = []
91
+ if @total.nil?
92
+ invalid_properties.push('invalid value for "total", total cannot be nil.')
93
+ end
94
+
95
+ if @limit.nil?
96
+ invalid_properties.push('invalid value for "limit", limit cannot be nil.')
97
+ end
98
+
99
+ if @offset.nil?
100
+ invalid_properties.push('invalid value for "offset", offset cannot be nil.')
101
+ end
102
+
103
+ if @packs.nil?
104
+ invalid_properties.push('invalid value for "packs", packs cannot be nil.')
105
+ end
106
+
107
+ invalid_properties
108
+ end
109
+
110
+ # Check to see if the all the properties in the model are valid
111
+ # @return true if the model is valid
112
+ def valid?
113
+ warn '[DEPRECATED] the `valid?` method is obsolete'
114
+ return false if @total.nil?
115
+ return false if @limit.nil?
116
+ return false if @offset.nil?
117
+ return false if @packs.nil?
118
+
119
+ true
120
+ end
121
+
122
+ # Checks equality by comparing each attribute.
123
+ # @param [Object] Object to be compared
124
+ def ==(other)
125
+ return true if equal?(other)
126
+
127
+ self.class == other.class &&
128
+ total == other.total &&
129
+ limit == other.limit &&
130
+ offset == other.offset &&
131
+ packs == other.packs
132
+ end
133
+
134
+ # @see the `==` method
135
+ # @param [Object] Object to be compared
136
+ def eql?(other)
137
+ self == other
138
+ end
139
+
140
+ # Calculates hash code according to all attributes.
141
+ # @return [Integer] Hash code
142
+ def hash
143
+ [total, limit, offset, packs].hash
144
+ end
145
+
146
+ # Builds the object from hash
147
+ # @param [Hash] attributes Model attributes in the form of hash
148
+ # @return [Object] Returns the model itself
149
+ def self.build_from_hash(attributes)
150
+ return nil unless attributes.is_a?(Hash)
151
+
152
+ attributes = attributes.transform_keys(&:to_sym)
153
+ transformed_hash = {}
154
+ openapi_types.each_pair do |key, type|
155
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
156
+ transformed_hash[key.to_s] = nil
157
+ elsif type =~ /\AArray<(.*)>/i
158
+ # check to ensure the input is an array given that the attribute
159
+ # is documented as an array but the input is not
160
+ if attributes[attribute_map[key]].is_a?(Array)
161
+ transformed_hash[key.to_s] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
162
+ end
163
+ elsif !attributes[attribute_map[key]].nil?
164
+ transformed_hash[key.to_s] = _deserialize(type, attributes[attribute_map[key]])
165
+ end
166
+ end
167
+ new(transformed_hash)
168
+ end
169
+
170
+ # Deserializes the data based on type
171
+ # @param string type Data type
172
+ # @param string value Value to be deserialized
173
+ # @return [Object] Deserialized data
174
+ def self._deserialize(type, value)
175
+ case type.to_sym
176
+ when :Time
177
+ Time.parse(value)
178
+ when :Date
179
+ Date.parse(value)
180
+ when :String
181
+ value.to_s
182
+ when :Integer
183
+ value.to_i
184
+ when :Float
185
+ value.to_f
186
+ when :Boolean
187
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
188
+ true
189
+ else
190
+ false
191
+ end
192
+ when :Object
193
+ # generic object (usually a Hash), return directly
194
+ value
195
+ when /\AArray<(?<inner_type>.+)>\z/
196
+ inner_type = Regexp.last_match[:inner_type]
197
+ value.map { |v| _deserialize(inner_type, v) }
198
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
199
+ k_type = Regexp.last_match[:k_type]
200
+ v_type = Regexp.last_match[:v_type]
201
+ {}.tap do |hash|
202
+ value.each do |k, v|
203
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
204
+ end
205
+ end
206
+ else # model
207
+ # models (e.g. Pet) or oneOf
208
+ klass = Kleister.const_get(type)
209
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
210
+ end
211
+ end
212
+
213
+ # Returns the string representation of the object
214
+ # @return [String] String presentation of the object
215
+ def to_s
216
+ to_hash.to_s
217
+ end
218
+
219
+ # to_body is an alias to to_hash (backward compatibility)
220
+ # @return [Hash] Returns the object in the form of hash
221
+ def to_body
222
+ to_hash
223
+ end
224
+
225
+ # Returns the object in the form of hash
226
+ # @return [Hash] Returns the object in the form of hash
227
+ def to_hash
228
+ hash = {}
229
+ self.class.attribute_map.each_pair do |attr, param|
230
+ value = send(attr)
231
+ if value.nil?
232
+ is_nullable = self.class.openapi_nullable.include?(attr)
233
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
234
+ end
235
+
236
+ hash[param] = _to_hash(value)
237
+ end
238
+ hash
239
+ end
240
+
241
+ # Outputs non-array value in the form of hash
242
+ # For object, use to_hash. Otherwise, just return the value
243
+ # @param [Object] value Any valid value
244
+ # @return [Hash] Returns the value in the form of hash
245
+ def _to_hash(value)
246
+ if value.is_a?(Array)
247
+ value.compact.map { |v| _to_hash(v) }
248
+ elsif value.is_a?(Hash)
249
+ {}.tap do |hash|
250
+ value.each { |k, v| hash[k] = _to_hash(v) }
251
+ end
252
+ elsif value.respond_to? :to_hash
253
+ value.to_hash
254
+ else
255
+ value
256
+ end
257
+ end
258
+ end
259
+ end