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