xbim_identity 2.0.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 (103) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +174 -0
  4. data/Rakefile +10 -0
  5. data/lib/xbim_identity/api/authentication_api.rb +118 -0
  6. data/lib/xbim_identity/api/client_applications_api.rb +315 -0
  7. data/lib/xbim_identity/api/invitations_api.rb +489 -0
  8. data/lib/xbim_identity/api/me_api.rb +148 -0
  9. data/lib/xbim_identity/api/members_api.rb +406 -0
  10. data/lib/xbim_identity/api/registration_api.rb +85 -0
  11. data/lib/xbim_identity/api/tenants_api.rb +709 -0
  12. data/lib/xbim_identity/api/users_api.rb +308 -0
  13. data/lib/xbim_identity/api_client.rb +390 -0
  14. data/lib/xbim_identity/api_error.rb +57 -0
  15. data/lib/xbim_identity/configuration.rb +278 -0
  16. data/lib/xbim_identity/models/application_type.rb +39 -0
  17. data/lib/xbim_identity/models/client_app.rb +351 -0
  18. data/lib/xbim_identity/models/client_app_endpoint.rb +239 -0
  19. data/lib/xbim_identity/models/draft_invitation.rb +379 -0
  20. data/lib/xbim_identity/models/invitation.rb +379 -0
  21. data/lib/xbim_identity/models/invitation_create.rb +253 -0
  22. data/lib/xbim_identity/models/invitation_edit.rb +239 -0
  23. data/lib/xbim_identity/models/invite_status.rb +41 -0
  24. data/lib/xbim_identity/models/master.rb +331 -0
  25. data/lib/xbim_identity/models/master_base.rb +243 -0
  26. data/lib/xbim_identity/models/master_subscription.rb +323 -0
  27. data/lib/xbim_identity/models/o_data_boolean.rb +230 -0
  28. data/lib/xbim_identity/models/o_data_client_app_endpoint_list.rb +252 -0
  29. data/lib/xbim_identity/models/o_data_client_app_list.rb +252 -0
  30. data/lib/xbim_identity/models/o_data_invitation_list.rb +252 -0
  31. data/lib/xbim_identity/models/o_data_string.rb +230 -0
  32. data/lib/xbim_identity/models/o_data_tenant_list.rb +252 -0
  33. data/lib/xbim_identity/models/o_data_tenant_user_list.rb +252 -0
  34. data/lib/xbim_identity/models/o_data_user_list.rb +252 -0
  35. data/lib/xbim_identity/models/problem_details.rb +259 -0
  36. data/lib/xbim_identity/models/region.rb +280 -0
  37. data/lib/xbim_identity/models/region_info.rb +256 -0
  38. data/lib/xbim_identity/models/subscription.rb +309 -0
  39. data/lib/xbim_identity/models/team_member_create.rb +229 -0
  40. data/lib/xbim_identity/models/team_member_edit.rb +219 -0
  41. data/lib/xbim_identity/models/tenancy_type.rb +38 -0
  42. data/lib/xbim_identity/models/tenant.rb +383 -0
  43. data/lib/xbim_identity/models/tenant_create.rb +267 -0
  44. data/lib/xbim_identity/models/tenant_edit.rb +229 -0
  45. data/lib/xbim_identity/models/tenant_role.rb +39 -0
  46. data/lib/xbim_identity/models/tenant_user.rb +299 -0
  47. data/lib/xbim_identity/models/token_err_response.rb +219 -0
  48. data/lib/xbim_identity/models/token_response.rb +259 -0
  49. data/lib/xbim_identity/models/user.rb +261 -0
  50. data/lib/xbim_identity/models/user_create.rb +247 -0
  51. data/lib/xbim_identity/models/user_tenant.rb +279 -0
  52. data/lib/xbim_identity/version.rb +15 -0
  53. data/lib/xbim_identity.rb +83 -0
  54. data/spec/api/authentication_api_spec.rb +52 -0
  55. data/spec/api/client_applications_api_spec.rb +101 -0
  56. data/spec/api/invitations_api_spec.rb +130 -0
  57. data/spec/api/me_api_spec.rb +61 -0
  58. data/spec/api/members_api_spec.rb +113 -0
  59. data/spec/api/registration_api_spec.rb +48 -0
  60. data/spec/api/tenants_api_spec.rb +176 -0
  61. data/spec/api/users_api_spec.rb +95 -0
  62. data/spec/api_client_spec.rb +226 -0
  63. data/spec/configuration_spec.rb +42 -0
  64. data/spec/models/application_type_spec.rb +28 -0
  65. data/spec/models/client_app_endpoint_spec.rb +46 -0
  66. data/spec/models/client_app_spec.rb +112 -0
  67. data/spec/models/draft_invitation_spec.rb +130 -0
  68. data/spec/models/invitation_create_spec.rb +52 -0
  69. data/spec/models/invitation_edit_spec.rb +46 -0
  70. data/spec/models/invitation_spec.rb +130 -0
  71. data/spec/models/invite_status_spec.rb +28 -0
  72. data/spec/models/master_base_spec.rb +46 -0
  73. data/spec/models/master_spec.rb +94 -0
  74. data/spec/models/master_subscription_spec.rb +94 -0
  75. data/spec/models/o_data_boolean_spec.rb +40 -0
  76. data/spec/models/o_data_client_app_endpoint_list_spec.rb +52 -0
  77. data/spec/models/o_data_client_app_list_spec.rb +52 -0
  78. data/spec/models/o_data_invitation_list_spec.rb +52 -0
  79. data/spec/models/o_data_string_spec.rb +40 -0
  80. data/spec/models/o_data_tenant_list_spec.rb +52 -0
  81. data/spec/models/o_data_tenant_user_list_spec.rb +52 -0
  82. data/spec/models/o_data_user_list_spec.rb +52 -0
  83. data/spec/models/problem_details_spec.rb +58 -0
  84. data/spec/models/region_info_spec.rb +46 -0
  85. data/spec/models/region_spec.rb +58 -0
  86. data/spec/models/subscription_spec.rb +88 -0
  87. data/spec/models/team_member_create_spec.rb +40 -0
  88. data/spec/models/team_member_edit_spec.rb +34 -0
  89. data/spec/models/tenancy_type_spec.rb +28 -0
  90. data/spec/models/tenant_create_spec.rb +58 -0
  91. data/spec/models/tenant_edit_spec.rb +40 -0
  92. data/spec/models/tenant_role_spec.rb +28 -0
  93. data/spec/models/tenant_spec.rb +130 -0
  94. data/spec/models/tenant_user_spec.rb +82 -0
  95. data/spec/models/token_err_response_spec.rb +34 -0
  96. data/spec/models/token_response_spec.rb +58 -0
  97. data/spec/models/user_create_spec.rb +46 -0
  98. data/spec/models/user_spec.rb +58 -0
  99. data/spec/models/user_tenant_spec.rb +70 -0
  100. data/spec/spec_helper.rb +111 -0
  101. data/xbim_identity-1.0.0.gem +0 -0
  102. data/xbim_identity.gemspec +38 -0
  103. metadata +184 -0
@@ -0,0 +1,243 @@
1
+ =begin
2
+ #Xbim Flex Identity API 2.0
3
+
4
+ #Communication centralised around construction data
5
+
6
+ The version of the OpenAPI document: 2.0
7
+ Contact: info@xbim.net
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.4.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module XbimIdentity
17
+ class MasterBase
18
+ attr_accessor :id
19
+
20
+ attr_accessor :name
21
+
22
+ attr_accessor :email
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'id' => :'id',
28
+ :'name' => :'name',
29
+ :'email' => :'email'
30
+ }
31
+ end
32
+
33
+ # Returns all the JSON keys this model knows about
34
+ def self.acceptable_attributes
35
+ attribute_map.values
36
+ end
37
+
38
+ # Attribute type mapping.
39
+ def self.openapi_types
40
+ {
41
+ :'id' => :'String',
42
+ :'name' => :'String',
43
+ :'email' => :'String'
44
+ }
45
+ end
46
+
47
+ # List of attributes with nullable: true
48
+ def self.openapi_nullable
49
+ Set.new([
50
+ :'id',
51
+ :'email'
52
+ ])
53
+ end
54
+
55
+ # Initializes the object
56
+ # @param [Hash] attributes Model attributes in the form of hash
57
+ def initialize(attributes = {})
58
+ if (!attributes.is_a?(Hash))
59
+ fail ArgumentError, "The input argument (attributes) must be a hash in `XbimIdentity::MasterBase` initialize method"
60
+ end
61
+
62
+ # check to see if the attribute exists and convert string to symbol for hash key
63
+ attributes = attributes.each_with_object({}) { |(k, v), h|
64
+ if (!self.class.attribute_map.key?(k.to_sym))
65
+ fail ArgumentError, "`#{k}` is not a valid attribute in `XbimIdentity::MasterBase`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
66
+ end
67
+ h[k.to_sym] = v
68
+ }
69
+
70
+ if attributes.key?(:'id')
71
+ self.id = attributes[:'id']
72
+ end
73
+
74
+ if attributes.key?(:'name')
75
+ self.name = attributes[:'name']
76
+ end
77
+
78
+ if attributes.key?(:'email')
79
+ self.email = attributes[:'email']
80
+ end
81
+ end
82
+
83
+ # Show invalid properties with the reasons. Usually used together with valid?
84
+ # @return Array for valid properties with the reasons
85
+ def list_invalid_properties
86
+ invalid_properties = Array.new
87
+ if @name.nil?
88
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
89
+ end
90
+
91
+ invalid_properties
92
+ end
93
+
94
+ # Check to see if the all the properties in the model are valid
95
+ # @return true if the model is valid
96
+ def valid?
97
+ return false if @name.nil?
98
+ true
99
+ end
100
+
101
+ # Checks equality by comparing each attribute.
102
+ # @param [Object] Object to be compared
103
+ def ==(o)
104
+ return true if self.equal?(o)
105
+ self.class == o.class &&
106
+ id == o.id &&
107
+ name == o.name &&
108
+ email == o.email
109
+ end
110
+
111
+ # @see the `==` method
112
+ # @param [Object] Object to be compared
113
+ def eql?(o)
114
+ self == o
115
+ end
116
+
117
+ # Calculates hash code according to all attributes.
118
+ # @return [Integer] Hash code
119
+ def hash
120
+ [id, name, email].hash
121
+ end
122
+
123
+ # Builds the object from hash
124
+ # @param [Hash] attributes Model attributes in the form of hash
125
+ # @return [Object] Returns the model itself
126
+ def self.build_from_hash(attributes)
127
+ new.build_from_hash(attributes)
128
+ end
129
+
130
+ # Builds the object from hash
131
+ # @param [Hash] attributes Model attributes in the form of hash
132
+ # @return [Object] Returns the model itself
133
+ def build_from_hash(attributes)
134
+ return nil unless attributes.is_a?(Hash)
135
+ self.class.openapi_types.each_pair do |key, type|
136
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
137
+ self.send("#{key}=", nil)
138
+ elsif type =~ /\AArray<(.*)>/i
139
+ # check to ensure the input is an array given that the attribute
140
+ # is documented as an array but the input is not
141
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
142
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
143
+ end
144
+ elsif !attributes[self.class.attribute_map[key]].nil?
145
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
146
+ end
147
+ end
148
+
149
+ self
150
+ end
151
+
152
+ # Deserializes the data based on type
153
+ # @param string type Data type
154
+ # @param string value Value to be deserialized
155
+ # @return [Object] Deserialized data
156
+ def _deserialize(type, value)
157
+ case type.to_sym
158
+ when :Time
159
+ Time.parse(value)
160
+ when :Date
161
+ Date.parse(value)
162
+ when :String
163
+ value.to_s
164
+ when :Integer
165
+ value.to_i
166
+ when :Float
167
+ value.to_f
168
+ when :Boolean
169
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
170
+ true
171
+ else
172
+ false
173
+ end
174
+ when :Object
175
+ # generic object (usually a Hash), return directly
176
+ value
177
+ when /\AArray<(?<inner_type>.+)>\z/
178
+ inner_type = Regexp.last_match[:inner_type]
179
+ value.map { |v| _deserialize(inner_type, v) }
180
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
181
+ k_type = Regexp.last_match[:k_type]
182
+ v_type = Regexp.last_match[:v_type]
183
+ {}.tap do |hash|
184
+ value.each do |k, v|
185
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
186
+ end
187
+ end
188
+ else # model
189
+ # models (e.g. Pet) or oneOf
190
+ klass = XbimIdentity.const_get(type)
191
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
192
+ end
193
+ end
194
+
195
+ # Returns the string representation of the object
196
+ # @return [String] String presentation of the object
197
+ def to_s
198
+ to_hash.to_s
199
+ end
200
+
201
+ # to_body is an alias to to_hash (backward compatibility)
202
+ # @return [Hash] Returns the object in the form of hash
203
+ def to_body
204
+ to_hash
205
+ end
206
+
207
+ # Returns the object in the form of hash
208
+ # @return [Hash] Returns the object in the form of hash
209
+ def to_hash
210
+ hash = {}
211
+ self.class.attribute_map.each_pair do |attr, param|
212
+ value = self.send(attr)
213
+ if value.nil?
214
+ is_nullable = self.class.openapi_nullable.include?(attr)
215
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
216
+ end
217
+
218
+ hash[param] = _to_hash(value)
219
+ end
220
+ hash
221
+ end
222
+
223
+ # Outputs non-array value in the form of hash
224
+ # For object, use to_hash. Otherwise, just return the value
225
+ # @param [Object] value Any valid value
226
+ # @return [Hash] Returns the value in the form of hash
227
+ def _to_hash(value)
228
+ if value.is_a?(Array)
229
+ value.compact.map { |v| _to_hash(v) }
230
+ elsif value.is_a?(Hash)
231
+ {}.tap do |hash|
232
+ value.each { |k, v| hash[k] = _to_hash(v) }
233
+ end
234
+ elsif value.respond_to? :to_hash
235
+ value.to_hash
236
+ else
237
+ value
238
+ end
239
+ end
240
+
241
+ end
242
+
243
+ end
@@ -0,0 +1,323 @@
1
+ =begin
2
+ #Xbim Flex Identity API 2.0
3
+
4
+ #Communication centralised around construction data
5
+
6
+ The version of the OpenAPI document: 2.0
7
+ Contact: info@xbim.net
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.4.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module XbimIdentity
17
+ class MasterSubscription
18
+ attr_accessor :tenant_subscription_id
19
+
20
+ attr_accessor :has_soft_limits
21
+
22
+ attr_accessor :master_subscription_id
23
+
24
+ attr_accessor :max_tenants
25
+
26
+ attr_accessor :max_users
27
+
28
+ attr_accessor :region_code
29
+
30
+ attr_accessor :region
31
+
32
+ attr_accessor :master
33
+
34
+ attr_accessor :template_subscription
35
+
36
+ attr_accessor :date_created
37
+
38
+ attr_accessor :date_modified
39
+
40
+ # Attribute mapping from ruby-style variable name to JSON key.
41
+ def self.attribute_map
42
+ {
43
+ :'tenant_subscription_id' => :'tenantSubscriptionId',
44
+ :'has_soft_limits' => :'hasSoftLimits',
45
+ :'master_subscription_id' => :'masterSubscriptionId',
46
+ :'max_tenants' => :'maxTenants',
47
+ :'max_users' => :'maxUsers',
48
+ :'region_code' => :'regionCode',
49
+ :'region' => :'region',
50
+ :'master' => :'master',
51
+ :'template_subscription' => :'templateSubscription',
52
+ :'date_created' => :'dateCreated',
53
+ :'date_modified' => :'dateModified'
54
+ }
55
+ end
56
+
57
+ # Returns all the JSON keys this model knows about
58
+ def self.acceptable_attributes
59
+ attribute_map.values
60
+ end
61
+
62
+ # Attribute type mapping.
63
+ def self.openapi_types
64
+ {
65
+ :'tenant_subscription_id' => :'String',
66
+ :'has_soft_limits' => :'Boolean',
67
+ :'master_subscription_id' => :'String',
68
+ :'max_tenants' => :'Integer',
69
+ :'max_users' => :'Integer',
70
+ :'region_code' => :'String',
71
+ :'region' => :'Region',
72
+ :'master' => :'Master',
73
+ :'template_subscription' => :'Subscription',
74
+ :'date_created' => :'Time',
75
+ :'date_modified' => :'Time'
76
+ }
77
+ end
78
+
79
+ # List of attributes with nullable: true
80
+ def self.openapi_nullable
81
+ Set.new([
82
+ :'has_soft_limits',
83
+ :'master_subscription_id',
84
+ :'max_tenants',
85
+ :'max_users',
86
+ :'region_code',
87
+ :'region',
88
+ :'master',
89
+ :'template_subscription',
90
+ :'date_created',
91
+ :'date_modified'
92
+ ])
93
+ end
94
+
95
+ # Initializes the object
96
+ # @param [Hash] attributes Model attributes in the form of hash
97
+ def initialize(attributes = {})
98
+ if (!attributes.is_a?(Hash))
99
+ fail ArgumentError, "The input argument (attributes) must be a hash in `XbimIdentity::MasterSubscription` initialize method"
100
+ end
101
+
102
+ # check to see if the attribute exists and convert string to symbol for hash key
103
+ attributes = attributes.each_with_object({}) { |(k, v), h|
104
+ if (!self.class.attribute_map.key?(k.to_sym))
105
+ fail ArgumentError, "`#{k}` is not a valid attribute in `XbimIdentity::MasterSubscription`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
106
+ end
107
+ h[k.to_sym] = v
108
+ }
109
+
110
+ if attributes.key?(:'tenant_subscription_id')
111
+ self.tenant_subscription_id = attributes[:'tenant_subscription_id']
112
+ end
113
+
114
+ if attributes.key?(:'has_soft_limits')
115
+ self.has_soft_limits = attributes[:'has_soft_limits']
116
+ end
117
+
118
+ if attributes.key?(:'master_subscription_id')
119
+ self.master_subscription_id = attributes[:'master_subscription_id']
120
+ end
121
+
122
+ if attributes.key?(:'max_tenants')
123
+ self.max_tenants = attributes[:'max_tenants']
124
+ end
125
+
126
+ if attributes.key?(:'max_users')
127
+ self.max_users = attributes[:'max_users']
128
+ end
129
+
130
+ if attributes.key?(:'region_code')
131
+ self.region_code = attributes[:'region_code']
132
+ end
133
+
134
+ if attributes.key?(:'region')
135
+ self.region = attributes[:'region']
136
+ end
137
+
138
+ if attributes.key?(:'master')
139
+ self.master = attributes[:'master']
140
+ end
141
+
142
+ if attributes.key?(:'template_subscription')
143
+ self.template_subscription = attributes[:'template_subscription']
144
+ end
145
+
146
+ if attributes.key?(:'date_created')
147
+ self.date_created = attributes[:'date_created']
148
+ end
149
+
150
+ if attributes.key?(:'date_modified')
151
+ self.date_modified = attributes[:'date_modified']
152
+ end
153
+ end
154
+
155
+ # Show invalid properties with the reasons. Usually used together with valid?
156
+ # @return Array for valid properties with the reasons
157
+ def list_invalid_properties
158
+ invalid_properties = Array.new
159
+ if @tenant_subscription_id.nil?
160
+ invalid_properties.push('invalid value for "tenant_subscription_id", tenant_subscription_id cannot be nil.')
161
+ end
162
+
163
+ invalid_properties
164
+ end
165
+
166
+ # Check to see if the all the properties in the model are valid
167
+ # @return true if the model is valid
168
+ def valid?
169
+ return false if @tenant_subscription_id.nil?
170
+ true
171
+ end
172
+
173
+ # Checks equality by comparing each attribute.
174
+ # @param [Object] Object to be compared
175
+ def ==(o)
176
+ return true if self.equal?(o)
177
+ self.class == o.class &&
178
+ tenant_subscription_id == o.tenant_subscription_id &&
179
+ has_soft_limits == o.has_soft_limits &&
180
+ master_subscription_id == o.master_subscription_id &&
181
+ max_tenants == o.max_tenants &&
182
+ max_users == o.max_users &&
183
+ region_code == o.region_code &&
184
+ region == o.region &&
185
+ master == o.master &&
186
+ template_subscription == o.template_subscription &&
187
+ date_created == o.date_created &&
188
+ date_modified == o.date_modified
189
+ end
190
+
191
+ # @see the `==` method
192
+ # @param [Object] Object to be compared
193
+ def eql?(o)
194
+ self == o
195
+ end
196
+
197
+ # Calculates hash code according to all attributes.
198
+ # @return [Integer] Hash code
199
+ def hash
200
+ [tenant_subscription_id, has_soft_limits, master_subscription_id, max_tenants, max_users, region_code, region, master, template_subscription, date_created, date_modified].hash
201
+ end
202
+
203
+ # Builds the object from hash
204
+ # @param [Hash] attributes Model attributes in the form of hash
205
+ # @return [Object] Returns the model itself
206
+ def self.build_from_hash(attributes)
207
+ new.build_from_hash(attributes)
208
+ end
209
+
210
+ # Builds the object from hash
211
+ # @param [Hash] attributes Model attributes in the form of hash
212
+ # @return [Object] Returns the model itself
213
+ def build_from_hash(attributes)
214
+ return nil unless attributes.is_a?(Hash)
215
+ self.class.openapi_types.each_pair do |key, type|
216
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
217
+ self.send("#{key}=", nil)
218
+ elsif type =~ /\AArray<(.*)>/i
219
+ # check to ensure the input is an array given that the attribute
220
+ # is documented as an array but the input is not
221
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
222
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
223
+ end
224
+ elsif !attributes[self.class.attribute_map[key]].nil?
225
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
226
+ end
227
+ end
228
+
229
+ self
230
+ end
231
+
232
+ # Deserializes the data based on type
233
+ # @param string type Data type
234
+ # @param string value Value to be deserialized
235
+ # @return [Object] Deserialized data
236
+ def _deserialize(type, value)
237
+ case type.to_sym
238
+ when :Time
239
+ Time.parse(value)
240
+ when :Date
241
+ Date.parse(value)
242
+ when :String
243
+ value.to_s
244
+ when :Integer
245
+ value.to_i
246
+ when :Float
247
+ value.to_f
248
+ when :Boolean
249
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
250
+ true
251
+ else
252
+ false
253
+ end
254
+ when :Object
255
+ # generic object (usually a Hash), return directly
256
+ value
257
+ when /\AArray<(?<inner_type>.+)>\z/
258
+ inner_type = Regexp.last_match[:inner_type]
259
+ value.map { |v| _deserialize(inner_type, v) }
260
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
261
+ k_type = Regexp.last_match[:k_type]
262
+ v_type = Regexp.last_match[:v_type]
263
+ {}.tap do |hash|
264
+ value.each do |k, v|
265
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
266
+ end
267
+ end
268
+ else # model
269
+ # models (e.g. Pet) or oneOf
270
+ klass = XbimIdentity.const_get(type)
271
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
272
+ end
273
+ end
274
+
275
+ # Returns the string representation of the object
276
+ # @return [String] String presentation of the object
277
+ def to_s
278
+ to_hash.to_s
279
+ end
280
+
281
+ # to_body is an alias to to_hash (backward compatibility)
282
+ # @return [Hash] Returns the object in the form of hash
283
+ def to_body
284
+ to_hash
285
+ end
286
+
287
+ # Returns the object in the form of hash
288
+ # @return [Hash] Returns the object in the form of hash
289
+ def to_hash
290
+ hash = {}
291
+ self.class.attribute_map.each_pair do |attr, param|
292
+ value = self.send(attr)
293
+ if value.nil?
294
+ is_nullable = self.class.openapi_nullable.include?(attr)
295
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
296
+ end
297
+
298
+ hash[param] = _to_hash(value)
299
+ end
300
+ hash
301
+ end
302
+
303
+ # Outputs non-array value in the form of hash
304
+ # For object, use to_hash. Otherwise, just return the value
305
+ # @param [Object] value Any valid value
306
+ # @return [Hash] Returns the value in the form of hash
307
+ def _to_hash(value)
308
+ if value.is_a?(Array)
309
+ value.compact.map { |v| _to_hash(v) }
310
+ elsif value.is_a?(Hash)
311
+ {}.tap do |hash|
312
+ value.each { |k, v| hash[k] = _to_hash(v) }
313
+ end
314
+ elsif value.respond_to? :to_hash
315
+ value.to_hash
316
+ else
317
+ value
318
+ end
319
+ end
320
+
321
+ end
322
+
323
+ end