kleister 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +18 -0
- data/CONTRIBUTING.md +121 -0
- data/DCO +34 -0
- data/LICENSE +202 -0
- data/README.md +67 -0
- data/lib/kleister/api/auth_api.rb +331 -0
- data/lib/kleister/api/fabric_api.rb +367 -0
- data/lib/kleister/api/forge_api.rb +367 -0
- data/lib/kleister/api/minecraft_api.rb +367 -0
- data/lib/kleister/api/mod_api.rb +1603 -0
- data/lib/kleister/api/neoforge_api.rb +367 -0
- data/lib/kleister/api/pack_api.rb +1603 -0
- data/lib/kleister/api/profile_api.rb +198 -0
- data/lib/kleister/api/quilt_api.rb +367 -0
- data/lib/kleister/api/team_api.rb +1283 -0
- data/lib/kleister/api/user_api.rb +1283 -0
- data/lib/kleister/api_client.rb +429 -0
- data/lib/kleister/api_error.rb +56 -0
- data/lib/kleister/configuration.rb +397 -0
- data/lib/kleister/models/auth_login.rb +231 -0
- data/lib/kleister/models/auth_token.rb +227 -0
- data/lib/kleister/models/auth_verify.rb +227 -0
- data/lib/kleister/models/build.rb +365 -0
- data/lib/kleister/models/build_version.rb +261 -0
- data/lib/kleister/models/build_version_params.rb +233 -0
- data/lib/kleister/models/build_versions.rb +235 -0
- data/lib/kleister/models/builds.rb +227 -0
- data/lib/kleister/models/fabric.rb +235 -0
- data/lib/kleister/models/fabric_build_params.rb +233 -0
- data/lib/kleister/models/fabric_builds.rb +228 -0
- data/lib/kleister/models/fabrics.rb +220 -0
- data/lib/kleister/models/forge.rb +243 -0
- data/lib/kleister/models/forge_build_params.rb +233 -0
- data/lib/kleister/models/forge_builds.rb +227 -0
- data/lib/kleister/models/forges.rb +220 -0
- data/lib/kleister/models/minecraft.rb +243 -0
- data/lib/kleister/models/minecraft_build_params.rb +233 -0
- data/lib/kleister/models/minecraft_builds.rb +228 -0
- data/lib/kleister/models/minecrafts.rb +220 -0
- data/lib/kleister/models/mod.rb +350 -0
- data/lib/kleister/models/mod_team_params.rb +265 -0
- data/lib/kleister/models/mod_teams.rb +227 -0
- data/lib/kleister/models/mod_user_params.rb +265 -0
- data/lib/kleister/models/mod_users.rb +227 -0
- data/lib/kleister/models/mods.rb +220 -0
- data/lib/kleister/models/neoforge.rb +243 -0
- data/lib/kleister/models/neoforge_build_params.rb +233 -0
- data/lib/kleister/models/neoforge_builds.rb +228 -0
- data/lib/kleister/models/neoforges.rb +220 -0
- data/lib/kleister/models/notification.rb +228 -0
- data/lib/kleister/models/pack.rb +334 -0
- data/lib/kleister/models/pack_back.rb +289 -0
- data/lib/kleister/models/pack_icon.rb +289 -0
- data/lib/kleister/models/pack_logo.rb +289 -0
- data/lib/kleister/models/pack_team_params.rb +265 -0
- data/lib/kleister/models/pack_teams.rb +227 -0
- data/lib/kleister/models/pack_user_params.rb +265 -0
- data/lib/kleister/models/pack_users.rb +227 -0
- data/lib/kleister/models/packs.rb +220 -0
- data/lib/kleister/models/profile.rb +313 -0
- data/lib/kleister/models/quilt.rb +235 -0
- data/lib/kleister/models/quilt_build_params.rb +233 -0
- data/lib/kleister/models/quilt_builds.rb +227 -0
- data/lib/kleister/models/quilts.rb +220 -0
- data/lib/kleister/models/team.rb +267 -0
- data/lib/kleister/models/team_mod.rb +304 -0
- data/lib/kleister/models/team_mod_params.rb +265 -0
- data/lib/kleister/models/team_mods.rb +227 -0
- data/lib/kleister/models/team_pack.rb +304 -0
- data/lib/kleister/models/team_pack_params.rb +265 -0
- data/lib/kleister/models/team_packs.rb +227 -0
- data/lib/kleister/models/team_user_params.rb +265 -0
- data/lib/kleister/models/team_users.rb +227 -0
- data/lib/kleister/models/teams.rb +220 -0
- data/lib/kleister/models/user.rb +315 -0
- data/lib/kleister/models/user_auth.rb +234 -0
- data/lib/kleister/models/user_mod.rb +304 -0
- data/lib/kleister/models/user_mod_params.rb +265 -0
- data/lib/kleister/models/user_mods.rb +227 -0
- data/lib/kleister/models/user_pack.rb +304 -0
- data/lib/kleister/models/user_pack_params.rb +265 -0
- data/lib/kleister/models/user_packs.rb +227 -0
- data/lib/kleister/models/user_team.rb +304 -0
- data/lib/kleister/models/user_team_params.rb +265 -0
- data/lib/kleister/models/user_teams.rb +227 -0
- data/lib/kleister/models/users.rb +220 -0
- data/lib/kleister/models/validation.rb +220 -0
- data/lib/kleister/models/version.rb +280 -0
- data/lib/kleister/models/version_build_params.rb +233 -0
- data/lib/kleister/models/version_builds.rb +235 -0
- data/lib/kleister/models/version_file.rb +289 -0
- data/lib/kleister/models/versions.rb +227 -0
- data/lib/kleister/version.rb +13 -0
- data/lib/kleister.rb +121 -0
- metadata +180 -0
@@ -0,0 +1,220 @@
|
|
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 list of teams
|
16
|
+
class Teams
|
17
|
+
attr_accessor :total, :teams
|
18
|
+
|
19
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
20
|
+
def self.attribute_map
|
21
|
+
{
|
22
|
+
total: :total,
|
23
|
+
teams: :teams
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
# Returns all the JSON keys this model knows about
|
28
|
+
def self.acceptable_attributes
|
29
|
+
attribute_map.values
|
30
|
+
end
|
31
|
+
|
32
|
+
# Attribute type mapping.
|
33
|
+
def self.openapi_types
|
34
|
+
{
|
35
|
+
total: :Integer,
|
36
|
+
teams: :'Array<Team>'
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
# List of attributes with nullable: true
|
41
|
+
def self.openapi_nullable
|
42
|
+
Set.new([
|
43
|
+
])
|
44
|
+
end
|
45
|
+
|
46
|
+
# Initializes the object
|
47
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
48
|
+
def initialize(attributes = {})
|
49
|
+
unless attributes.is_a?(Hash)
|
50
|
+
raise ArgumentError, 'The input argument (attributes) must be a hash in `Kleister::Teams` initialize method'
|
51
|
+
end
|
52
|
+
|
53
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
54
|
+
attributes = attributes.each_with_object({}) do |(k, v), h|
|
55
|
+
unless self.class.attribute_map.key?(k.to_sym)
|
56
|
+
raise ArgumentError, "`#{k}` is not a valid attribute in `Kleister::Teams`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
57
|
+
end
|
58
|
+
|
59
|
+
h[k.to_sym] = v
|
60
|
+
end
|
61
|
+
|
62
|
+
if attributes.key?(:total)
|
63
|
+
self.total = attributes[:total]
|
64
|
+
end
|
65
|
+
|
66
|
+
if attributes.key?(:teams) && (value = attributes[:teams]).is_a?(Array)
|
67
|
+
self.teams = value
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
72
|
+
# @return Array for valid properties with the reasons
|
73
|
+
def list_invalid_properties
|
74
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
75
|
+
[]
|
76
|
+
end
|
77
|
+
|
78
|
+
# Check to see if the all the properties in the model are valid
|
79
|
+
# @return true if the model is valid
|
80
|
+
def valid?
|
81
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
82
|
+
true
|
83
|
+
end
|
84
|
+
|
85
|
+
# Checks equality by comparing each attribute.
|
86
|
+
# @param [Object] Object to be compared
|
87
|
+
def ==(other)
|
88
|
+
return true if equal?(other)
|
89
|
+
|
90
|
+
self.class == other.class &&
|
91
|
+
total == other.total &&
|
92
|
+
teams == other.teams
|
93
|
+
end
|
94
|
+
|
95
|
+
# @see the `==` method
|
96
|
+
# @param [Object] Object to be compared
|
97
|
+
def eql?(other)
|
98
|
+
self == other
|
99
|
+
end
|
100
|
+
|
101
|
+
# Calculates hash code according to all attributes.
|
102
|
+
# @return [Integer] Hash code
|
103
|
+
def hash
|
104
|
+
[total, teams].hash
|
105
|
+
end
|
106
|
+
|
107
|
+
# Builds the object from hash
|
108
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
109
|
+
# @return [Object] Returns the model itself
|
110
|
+
def self.build_from_hash(attributes)
|
111
|
+
return nil unless attributes.is_a?(Hash)
|
112
|
+
|
113
|
+
attributes = attributes.transform_keys(&:to_sym)
|
114
|
+
transformed_hash = {}
|
115
|
+
openapi_types.each_pair do |key, type|
|
116
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
117
|
+
transformed_hash[key.to_s] = nil
|
118
|
+
elsif type =~ /\AArray<(.*)>/i
|
119
|
+
# check to ensure the input is an array given that the attribute
|
120
|
+
# is documented as an array but the input is not
|
121
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
122
|
+
transformed_hash[key.to_s] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
|
123
|
+
end
|
124
|
+
elsif !attributes[attribute_map[key]].nil?
|
125
|
+
transformed_hash[key.to_s] = _deserialize(type, attributes[attribute_map[key]])
|
126
|
+
end
|
127
|
+
end
|
128
|
+
new(transformed_hash)
|
129
|
+
end
|
130
|
+
|
131
|
+
# Deserializes the data based on type
|
132
|
+
# @param string type Data type
|
133
|
+
# @param string value Value to be deserialized
|
134
|
+
# @return [Object] Deserialized data
|
135
|
+
def self._deserialize(type, value)
|
136
|
+
case type.to_sym
|
137
|
+
when :Time
|
138
|
+
Time.parse(value)
|
139
|
+
when :Date
|
140
|
+
Date.parse(value)
|
141
|
+
when :String
|
142
|
+
value.to_s
|
143
|
+
when :Integer
|
144
|
+
value.to_i
|
145
|
+
when :Float
|
146
|
+
value.to_f
|
147
|
+
when :Boolean
|
148
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
149
|
+
true
|
150
|
+
else
|
151
|
+
false
|
152
|
+
end
|
153
|
+
when :Object
|
154
|
+
# generic object (usually a Hash), return directly
|
155
|
+
value
|
156
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
157
|
+
inner_type = Regexp.last_match[:inner_type]
|
158
|
+
value.map { |v| _deserialize(inner_type, v) }
|
159
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
160
|
+
k_type = Regexp.last_match[:k_type]
|
161
|
+
v_type = Regexp.last_match[:v_type]
|
162
|
+
{}.tap do |hash|
|
163
|
+
value.each do |k, v|
|
164
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
165
|
+
end
|
166
|
+
end
|
167
|
+
else # model
|
168
|
+
# models (e.g. Pet) or oneOf
|
169
|
+
klass = Kleister.const_get(type)
|
170
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
# Returns the string representation of the object
|
175
|
+
# @return [String] String presentation of the object
|
176
|
+
def to_s
|
177
|
+
to_hash.to_s
|
178
|
+
end
|
179
|
+
|
180
|
+
# to_body is an alias to to_hash (backward compatibility)
|
181
|
+
# @return [Hash] Returns the object in the form of hash
|
182
|
+
def to_body
|
183
|
+
to_hash
|
184
|
+
end
|
185
|
+
|
186
|
+
# Returns the object in the form of hash
|
187
|
+
# @return [Hash] Returns the object in the form of hash
|
188
|
+
def to_hash
|
189
|
+
hash = {}
|
190
|
+
self.class.attribute_map.each_pair do |attr, param|
|
191
|
+
value = send(attr)
|
192
|
+
if value.nil?
|
193
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
194
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
195
|
+
end
|
196
|
+
|
197
|
+
hash[param] = _to_hash(value)
|
198
|
+
end
|
199
|
+
hash
|
200
|
+
end
|
201
|
+
|
202
|
+
# Outputs non-array value in the form of hash
|
203
|
+
# For object, use to_hash. Otherwise, just return the value
|
204
|
+
# @param [Object] value Any valid value
|
205
|
+
# @return [Hash] Returns the value in the form of hash
|
206
|
+
def _to_hash(value)
|
207
|
+
if value.is_a?(Array)
|
208
|
+
value.compact.map { |v| _to_hash(v) }
|
209
|
+
elsif value.is_a?(Hash)
|
210
|
+
{}.tap do |hash|
|
211
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
212
|
+
end
|
213
|
+
elsif value.respond_to? :to_hash
|
214
|
+
value.to_hash
|
215
|
+
else
|
216
|
+
value
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
@@ -0,0 +1,315 @@
|
|
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 user
|
16
|
+
class User
|
17
|
+
attr_accessor :id, :username, :password, :email, :fullname, :profile, :admin, :active, :created_at, :updated_at, :auths, :teams, :packs, :mods
|
18
|
+
|
19
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
20
|
+
def self.attribute_map
|
21
|
+
{
|
22
|
+
id: :id,
|
23
|
+
username: :username,
|
24
|
+
password: :password,
|
25
|
+
email: :email,
|
26
|
+
fullname: :fullname,
|
27
|
+
profile: :profile,
|
28
|
+
admin: :admin,
|
29
|
+
active: :active,
|
30
|
+
created_at: :created_at,
|
31
|
+
updated_at: :updated_at,
|
32
|
+
auths: :auths,
|
33
|
+
teams: :teams,
|
34
|
+
packs: :packs,
|
35
|
+
mods: :mods
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
# Returns all the JSON keys this model knows about
|
40
|
+
def self.acceptable_attributes
|
41
|
+
attribute_map.values
|
42
|
+
end
|
43
|
+
|
44
|
+
# Attribute type mapping.
|
45
|
+
def self.openapi_types
|
46
|
+
{
|
47
|
+
id: :String,
|
48
|
+
username: :String,
|
49
|
+
password: :String,
|
50
|
+
email: :String,
|
51
|
+
fullname: :String,
|
52
|
+
profile: :String,
|
53
|
+
admin: :Boolean,
|
54
|
+
active: :Boolean,
|
55
|
+
created_at: :Time,
|
56
|
+
updated_at: :Time,
|
57
|
+
auths: :'Array<UserAuth>',
|
58
|
+
teams: :'Array<UserTeam>',
|
59
|
+
packs: :'Array<UserPack>',
|
60
|
+
mods: :'Array<UserMod>'
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
# List of attributes with nullable: true
|
65
|
+
def self.openapi_nullable
|
66
|
+
Set.new(%i[
|
67
|
+
username
|
68
|
+
password
|
69
|
+
email
|
70
|
+
fullname
|
71
|
+
profile
|
72
|
+
admin
|
73
|
+
active
|
74
|
+
auths
|
75
|
+
teams
|
76
|
+
packs
|
77
|
+
mods
|
78
|
+
])
|
79
|
+
end
|
80
|
+
|
81
|
+
# Initializes the object
|
82
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
83
|
+
def initialize(attributes = {})
|
84
|
+
unless attributes.is_a?(Hash)
|
85
|
+
raise ArgumentError, 'The input argument (attributes) must be a hash in `Kleister::User` initialize method'
|
86
|
+
end
|
87
|
+
|
88
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
89
|
+
attributes = attributes.each_with_object({}) do |(k, v), h|
|
90
|
+
unless self.class.attribute_map.key?(k.to_sym)
|
91
|
+
raise ArgumentError, "`#{k}` is not a valid attribute in `Kleister::User`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
92
|
+
end
|
93
|
+
|
94
|
+
h[k.to_sym] = v
|
95
|
+
end
|
96
|
+
|
97
|
+
if attributes.key?(:id)
|
98
|
+
self.id = attributes[:id]
|
99
|
+
end
|
100
|
+
|
101
|
+
if attributes.key?(:username)
|
102
|
+
self.username = attributes[:username]
|
103
|
+
end
|
104
|
+
|
105
|
+
if attributes.key?(:password)
|
106
|
+
self.password = attributes[:password]
|
107
|
+
end
|
108
|
+
|
109
|
+
if attributes.key?(:email)
|
110
|
+
self.email = attributes[:email]
|
111
|
+
end
|
112
|
+
|
113
|
+
if attributes.key?(:fullname)
|
114
|
+
self.fullname = attributes[:fullname]
|
115
|
+
end
|
116
|
+
|
117
|
+
if attributes.key?(:profile)
|
118
|
+
self.profile = attributes[:profile]
|
119
|
+
end
|
120
|
+
|
121
|
+
if attributes.key?(:admin)
|
122
|
+
self.admin = attributes[:admin]
|
123
|
+
end
|
124
|
+
|
125
|
+
if attributes.key?(:active)
|
126
|
+
self.active = attributes[:active]
|
127
|
+
end
|
128
|
+
|
129
|
+
if attributes.key?(:created_at)
|
130
|
+
self.created_at = attributes[:created_at]
|
131
|
+
end
|
132
|
+
|
133
|
+
if attributes.key?(:updated_at)
|
134
|
+
self.updated_at = attributes[:updated_at]
|
135
|
+
end
|
136
|
+
|
137
|
+
if attributes.key?(:auths) && (value = attributes[:auths]).is_a?(Array)
|
138
|
+
self.auths = value
|
139
|
+
end
|
140
|
+
|
141
|
+
if attributes.key?(:teams) && (value = attributes[:teams]).is_a?(Array)
|
142
|
+
self.teams = value
|
143
|
+
end
|
144
|
+
|
145
|
+
if attributes.key?(:packs) && (value = attributes[:packs]).is_a?(Array)
|
146
|
+
self.packs = value
|
147
|
+
end
|
148
|
+
|
149
|
+
if attributes.key?(:mods) && (value = attributes[:mods]).is_a?(Array)
|
150
|
+
self.mods = value
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
155
|
+
# @return Array for valid properties with the reasons
|
156
|
+
def list_invalid_properties
|
157
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
158
|
+
[]
|
159
|
+
end
|
160
|
+
|
161
|
+
# Check to see if the all the properties in the model are valid
|
162
|
+
# @return true if the model is valid
|
163
|
+
def valid?
|
164
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
165
|
+
true
|
166
|
+
end
|
167
|
+
|
168
|
+
# Checks equality by comparing each attribute.
|
169
|
+
# @param [Object] Object to be compared
|
170
|
+
def ==(other)
|
171
|
+
return true if equal?(other)
|
172
|
+
|
173
|
+
self.class == other.class &&
|
174
|
+
id == other.id &&
|
175
|
+
username == other.username &&
|
176
|
+
password == other.password &&
|
177
|
+
email == other.email &&
|
178
|
+
fullname == other.fullname &&
|
179
|
+
profile == other.profile &&
|
180
|
+
admin == other.admin &&
|
181
|
+
active == other.active &&
|
182
|
+
created_at == other.created_at &&
|
183
|
+
updated_at == other.updated_at &&
|
184
|
+
auths == other.auths &&
|
185
|
+
teams == other.teams &&
|
186
|
+
packs == other.packs &&
|
187
|
+
mods == other.mods
|
188
|
+
end
|
189
|
+
|
190
|
+
# @see the `==` method
|
191
|
+
# @param [Object] Object to be compared
|
192
|
+
def eql?(other)
|
193
|
+
self == other
|
194
|
+
end
|
195
|
+
|
196
|
+
# Calculates hash code according to all attributes.
|
197
|
+
# @return [Integer] Hash code
|
198
|
+
def hash
|
199
|
+
[id, username, password, email, fullname, profile, admin, active, created_at, updated_at, auths, teams, packs, mods].hash
|
200
|
+
end
|
201
|
+
|
202
|
+
# Builds the object from hash
|
203
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
204
|
+
# @return [Object] Returns the model itself
|
205
|
+
def self.build_from_hash(attributes)
|
206
|
+
return nil unless attributes.is_a?(Hash)
|
207
|
+
|
208
|
+
attributes = attributes.transform_keys(&:to_sym)
|
209
|
+
transformed_hash = {}
|
210
|
+
openapi_types.each_pair do |key, type|
|
211
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
212
|
+
transformed_hash[key.to_s] = nil
|
213
|
+
elsif type =~ /\AArray<(.*)>/i
|
214
|
+
# check to ensure the input is an array given that the attribute
|
215
|
+
# is documented as an array but the input is not
|
216
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
217
|
+
transformed_hash[key.to_s] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
|
218
|
+
end
|
219
|
+
elsif !attributes[attribute_map[key]].nil?
|
220
|
+
transformed_hash[key.to_s] = _deserialize(type, attributes[attribute_map[key]])
|
221
|
+
end
|
222
|
+
end
|
223
|
+
new(transformed_hash)
|
224
|
+
end
|
225
|
+
|
226
|
+
# Deserializes the data based on type
|
227
|
+
# @param string type Data type
|
228
|
+
# @param string value Value to be deserialized
|
229
|
+
# @return [Object] Deserialized data
|
230
|
+
def self._deserialize(type, value)
|
231
|
+
case type.to_sym
|
232
|
+
when :Time
|
233
|
+
Time.parse(value)
|
234
|
+
when :Date
|
235
|
+
Date.parse(value)
|
236
|
+
when :String
|
237
|
+
value.to_s
|
238
|
+
when :Integer
|
239
|
+
value.to_i
|
240
|
+
when :Float
|
241
|
+
value.to_f
|
242
|
+
when :Boolean
|
243
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
244
|
+
true
|
245
|
+
else
|
246
|
+
false
|
247
|
+
end
|
248
|
+
when :Object
|
249
|
+
# generic object (usually a Hash), return directly
|
250
|
+
value
|
251
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
252
|
+
inner_type = Regexp.last_match[:inner_type]
|
253
|
+
value.map { |v| _deserialize(inner_type, v) }
|
254
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
255
|
+
k_type = Regexp.last_match[:k_type]
|
256
|
+
v_type = Regexp.last_match[:v_type]
|
257
|
+
{}.tap do |hash|
|
258
|
+
value.each do |k, v|
|
259
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
260
|
+
end
|
261
|
+
end
|
262
|
+
else # model
|
263
|
+
# models (e.g. Pet) or oneOf
|
264
|
+
klass = Kleister.const_get(type)
|
265
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
# Returns the string representation of the object
|
270
|
+
# @return [String] String presentation of the object
|
271
|
+
def to_s
|
272
|
+
to_hash.to_s
|
273
|
+
end
|
274
|
+
|
275
|
+
# to_body is an alias to to_hash (backward compatibility)
|
276
|
+
# @return [Hash] Returns the object in the form of hash
|
277
|
+
def to_body
|
278
|
+
to_hash
|
279
|
+
end
|
280
|
+
|
281
|
+
# Returns the object in the form of hash
|
282
|
+
# @return [Hash] Returns the object in the form of hash
|
283
|
+
def to_hash
|
284
|
+
hash = {}
|
285
|
+
self.class.attribute_map.each_pair do |attr, param|
|
286
|
+
value = send(attr)
|
287
|
+
if value.nil?
|
288
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
289
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
290
|
+
end
|
291
|
+
|
292
|
+
hash[param] = _to_hash(value)
|
293
|
+
end
|
294
|
+
hash
|
295
|
+
end
|
296
|
+
|
297
|
+
# Outputs non-array value in the form of hash
|
298
|
+
# For object, use to_hash. Otherwise, just return the value
|
299
|
+
# @param [Object] value Any valid value
|
300
|
+
# @return [Hash] Returns the value in the form of hash
|
301
|
+
def _to_hash(value)
|
302
|
+
if value.is_a?(Array)
|
303
|
+
value.compact.map { |v| _to_hash(v) }
|
304
|
+
elsif value.is_a?(Hash)
|
305
|
+
{}.tap do |hash|
|
306
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
307
|
+
end
|
308
|
+
elsif value.respond_to? :to_hash
|
309
|
+
value.to_hash
|
310
|
+
else
|
311
|
+
value
|
312
|
+
end
|
313
|
+
end
|
314
|
+
end
|
315
|
+
end
|