kinde_sdk 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +15 -0
  3. data/Gemfile.lock +119 -0
  4. data/LICENSE +21 -0
  5. data/README.md +342 -0
  6. data/Rakefile +10 -0
  7. data/kinde_api/.gitignore +39 -0
  8. data/kinde_api/.rspec +2 -0
  9. data/kinde_api/README.md +103 -0
  10. data/kinde_api/docs/AddOrganizationUsers200Response.md +22 -0
  11. data/kinde_api/docs/AddOrganizationUsersRequest.md +18 -0
  12. data/kinde_api/docs/ApiResult.md +18 -0
  13. data/kinde_api/docs/ConnectedAppsAccessToken.md +20 -0
  14. data/kinde_api/docs/ConnectedAppsApi.md +219 -0
  15. data/kinde_api/docs/ConnectedAppsAuthUrl.md +20 -0
  16. data/kinde_api/docs/CreateOrganization201Response.md +20 -0
  17. data/kinde_api/docs/CreateOrganizationRequest.md +20 -0
  18. data/kinde_api/docs/CreateUser200Response.md +22 -0
  19. data/kinde_api/docs/CreateUserRequest.md +20 -0
  20. data/kinde_api/docs/CreateUserRequestIdentitiesInner.md +20 -0
  21. data/kinde_api/docs/CreateUserRequestIdentitiesInnerDetails.md +18 -0
  22. data/kinde_api/docs/CreateUserRequestProfile.md +20 -0
  23. data/kinde_api/docs/EnvironmentsApi.md +216 -0
  24. data/kinde_api/docs/Error.md +20 -0
  25. data/kinde_api/docs/ErrorResponse.md +18 -0
  26. data/kinde_api/docs/FeatureFlagsApi.md +239 -0
  27. data/kinde_api/docs/GetOrganizationUsers200Response.md +24 -0
  28. data/kinde_api/docs/GetOrganizations200Response.md +24 -0
  29. data/kinde_api/docs/GetUsers200Response.md +24 -0
  30. data/kinde_api/docs/OAuthApi.md +141 -0
  31. data/kinde_api/docs/Organization.md +22 -0
  32. data/kinde_api/docs/OrganizationUser.md +26 -0
  33. data/kinde_api/docs/OrganizationsApi.md +671 -0
  34. data/kinde_api/docs/RemoveOrganizationUsers200Response.md +20 -0
  35. data/kinde_api/docs/RemoveOrganizationUsersRequest.md +18 -0
  36. data/kinde_api/docs/SuccessResponse.md +20 -0
  37. data/kinde_api/docs/UpdateUserRequest.md +22 -0
  38. data/kinde_api/docs/User.md +28 -0
  39. data/kinde_api/docs/UserIdentity.md +20 -0
  40. data/kinde_api/docs/UserIdentityResult.md +20 -0
  41. data/kinde_api/docs/UserProfile.md +26 -0
  42. data/kinde_api/docs/UserProfileV2.md +30 -0
  43. data/kinde_api/docs/UsersApi.md +603 -0
  44. data/kinde_api/lib/kinde_api/api/connected_apps_api.rb +221 -0
  45. data/kinde_api/lib/kinde_api/api/environments_api.rb +212 -0
  46. data/kinde_api/lib/kinde_api/api/feature_flags_api.rb +309 -0
  47. data/kinde_api/lib/kinde_api/api/o_auth_api.rb +136 -0
  48. data/kinde_api/lib/kinde_api/api/organizations_api.rb +634 -0
  49. data/kinde_api/lib/kinde_api/api/users_api.rb +560 -0
  50. data/kinde_api/lib/kinde_api/api_client.rb +397 -0
  51. data/kinde_api/lib/kinde_api/api_error.rb +58 -0
  52. data/kinde_api/lib/kinde_api/configuration.rb +295 -0
  53. data/kinde_api/lib/kinde_api/models/add_organization_users200_response.rb +239 -0
  54. data/kinde_api/lib/kinde_api/models/add_organization_users_request.rb +220 -0
  55. data/kinde_api/lib/kinde_api/models/api_result.rb +218 -0
  56. data/kinde_api/lib/kinde_api/models/connected_apps_access_token.rb +228 -0
  57. data/kinde_api/lib/kinde_api/models/connected_apps_auth_url.rb +228 -0
  58. data/kinde_api/lib/kinde_api/models/create_organization201_response.rb +228 -0
  59. data/kinde_api/lib/kinde_api/models/create_organization_request.rb +252 -0
  60. data/kinde_api/lib/kinde_api/models/create_user200_response.rb +239 -0
  61. data/kinde_api/lib/kinde_api/models/create_user_request.rb +229 -0
  62. data/kinde_api/lib/kinde_api/models/create_user_request_identities_inner.rb +228 -0
  63. data/kinde_api/lib/kinde_api/models/create_user_request_identities_inner_details.rb +219 -0
  64. data/kinde_api/lib/kinde_api/models/create_user_request_profile.rb +229 -0
  65. data/kinde_api/lib/kinde_api/models/error.rb +228 -0
  66. data/kinde_api/lib/kinde_api/models/error_response.rb +219 -0
  67. data/kinde_api/lib/kinde_api/models/get_organization_users200_response.rb +249 -0
  68. data/kinde_api/lib/kinde_api/models/get_organizations200_response.rb +249 -0
  69. data/kinde_api/lib/kinde_api/models/get_users200_response.rb +249 -0
  70. data/kinde_api/lib/kinde_api/models/organization.rb +235 -0
  71. data/kinde_api/lib/kinde_api/models/organization_user.rb +253 -0
  72. data/kinde_api/lib/kinde_api/models/remove_organization_users200_response.rb +228 -0
  73. data/kinde_api/lib/kinde_api/models/remove_organization_users_request.rb +220 -0
  74. data/kinde_api/lib/kinde_api/models/success_response.rb +226 -0
  75. data/kinde_api/lib/kinde_api/models/update_user_request.rb +238 -0
  76. data/kinde_api/lib/kinde_api/models/user.rb +269 -0
  77. data/kinde_api/lib/kinde_api/models/user_identity.rb +227 -0
  78. data/kinde_api/lib/kinde_api/models/user_identity_result.rb +229 -0
  79. data/kinde_api/lib/kinde_api/models/user_profile.rb +259 -0
  80. data/kinde_api/lib/kinde_api/models/user_profile_v2.rb +279 -0
  81. data/kinde_api/lib/kinde_api/version.rb +15 -0
  82. data/kinde_api/lib/kinde_api.rb +73 -0
  83. data/kinde_api/spec/api/connected_apps_api_spec.rb +72 -0
  84. data/kinde_api/spec/api/environments_api_spec.rb +71 -0
  85. data/kinde_api/spec/api/feature_flags_api_spec.rb +82 -0
  86. data/kinde_api/spec/api/o_auth_api_spec.rb +57 -0
  87. data/kinde_api/spec/api/organizations_api_spec.rb +154 -0
  88. data/kinde_api/spec/api/users_api_spec.rb +141 -0
  89. data/kinde_api/spec/api_client_spec.rb +229 -0
  90. data/kinde_api/spec/configuration_spec.rb +42 -0
  91. data/kinde_api/spec/models/add_organization_users200_response_spec.rb +46 -0
  92. data/kinde_api/spec/models/add_organization_users_request_spec.rb +34 -0
  93. data/kinde_api/spec/models/api_result_spec.rb +34 -0
  94. data/kinde_api/spec/models/connected_apps_access_token_spec.rb +40 -0
  95. data/kinde_api/spec/models/connected_apps_auth_url_spec.rb +40 -0
  96. data/kinde_api/spec/models/create_organization201_response_spec.rb +40 -0
  97. data/kinde_api/spec/models/create_organization_request_spec.rb +44 -0
  98. data/kinde_api/spec/models/create_user200_response_spec.rb +46 -0
  99. data/kinde_api/spec/models/create_user_request_identities_inner_details_spec.rb +34 -0
  100. data/kinde_api/spec/models/create_user_request_identities_inner_spec.rb +40 -0
  101. data/kinde_api/spec/models/create_user_request_profile_spec.rb +40 -0
  102. data/kinde_api/spec/models/create_user_request_spec.rb +40 -0
  103. data/kinde_api/spec/models/error_response_spec.rb +34 -0
  104. data/kinde_api/spec/models/error_spec.rb +40 -0
  105. data/kinde_api/spec/models/get_organization_users200_response_spec.rb +52 -0
  106. data/kinde_api/spec/models/get_organizations200_response_spec.rb +52 -0
  107. data/kinde_api/spec/models/get_users200_response_spec.rb +52 -0
  108. data/kinde_api/spec/models/organization_spec.rb +46 -0
  109. data/kinde_api/spec/models/organization_user_spec.rb +58 -0
  110. data/kinde_api/spec/models/remove_organization_users200_response_spec.rb +40 -0
  111. data/kinde_api/spec/models/remove_organization_users_request_spec.rb +34 -0
  112. data/kinde_api/spec/models/success_response_spec.rb +40 -0
  113. data/kinde_api/spec/models/update_user_request_spec.rb +46 -0
  114. data/kinde_api/spec/models/user_identity_result_spec.rb +40 -0
  115. data/kinde_api/spec/models/user_identity_spec.rb +40 -0
  116. data/kinde_api/spec/models/user_profile_spec.rb +58 -0
  117. data/kinde_api/spec/models/user_profile_v2_spec.rb +70 -0
  118. data/kinde_api/spec/models/user_spec.rb +64 -0
  119. data/kinde_api/spec/spec_helper.rb +111 -0
  120. data/kinde_sdk.gemspec +33 -0
  121. data/lib/kinde_sdk/client.rb +49 -0
  122. data/lib/kinde_sdk/configuration.rb +50 -0
  123. data/lib/kinde_sdk/version.rb +3 -0
  124. data/lib/kinde_sdk.rb +109 -0
  125. data/openapitools.json +7 -0
  126. data/spec/kinde_sdk_spec.rb +105 -0
  127. data/spec/spec_helper.rb +82 -0
  128. metadata +291 -0
@@ -0,0 +1,295 @@
1
+ =begin
2
+ #Kinde Management API
3
+
4
+ #Provides endpoints to manage your Kinde Businesses
5
+
6
+ The version of the OpenAPI document: 1
7
+ Contact: support@kinde.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.4.0
10
+
11
+ =end
12
+
13
+ module KindeApi
14
+ class Configuration
15
+ # Defines url scheme
16
+ attr_accessor :scheme
17
+
18
+ # Defines url host
19
+ attr_accessor :host
20
+
21
+ # Defines url base path
22
+ attr_accessor :base_path
23
+
24
+ # Define server configuration index
25
+ attr_accessor :server_index
26
+
27
+ # Define server operation configuration index
28
+ attr_accessor :server_operation_index
29
+
30
+ # Default server variables
31
+ attr_accessor :server_variables
32
+
33
+ # Default server operation variables
34
+ attr_accessor :server_operation_variables
35
+
36
+ # Defines API keys used with API Key authentications.
37
+ #
38
+ # @return [Hash] key: parameter name, value: parameter value (API key)
39
+ #
40
+ # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
41
+ # config.api_key['api_key'] = 'xxx'
42
+ attr_accessor :api_key
43
+
44
+ # Defines API key prefixes used with API Key authentications.
45
+ #
46
+ # @return [Hash] key: parameter name, value: API key prefix
47
+ #
48
+ # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
49
+ # config.api_key_prefix['api_key'] = 'Token'
50
+ attr_accessor :api_key_prefix
51
+
52
+ # Defines the username used with HTTP basic authentication.
53
+ #
54
+ # @return [String]
55
+ attr_accessor :username
56
+
57
+ # Defines the password used with HTTP basic authentication.
58
+ #
59
+ # @return [String]
60
+ attr_accessor :password
61
+
62
+ # Defines the access token (Bearer) used with OAuth2.
63
+ attr_accessor :access_token
64
+
65
+ # Defines a Proc used to fetch or refresh access tokens (Bearer) used with OAuth2.
66
+ # Overrides the access_token if set
67
+ # @return [Proc]
68
+ attr_accessor :access_token_getter
69
+
70
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
71
+ # details will be logged with `logger.debug` (see the `logger` attribute).
72
+ # Default to false.
73
+ #
74
+ # @return [true, false]
75
+ attr_accessor :debugging
76
+
77
+ # Defines the logger used for debugging.
78
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
79
+ #
80
+ # @return [#debug]
81
+ attr_accessor :logger
82
+
83
+ # Defines the temporary folder to store downloaded files
84
+ # (for API endpoints that have file response).
85
+ # Default to use `Tempfile`.
86
+ #
87
+ # @return [String]
88
+ attr_accessor :temp_folder_path
89
+
90
+ # The time limit for HTTP request in seconds.
91
+ # Default to 0 (never times out).
92
+ attr_accessor :timeout
93
+
94
+ # Set this to false to skip client side validation in the operation.
95
+ # Default to true.
96
+ # @return [true, false]
97
+ attr_accessor :client_side_validation
98
+
99
+ ### TLS/SSL setting
100
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
101
+ # Default to true.
102
+ #
103
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
104
+ #
105
+ # @return [true, false]
106
+ attr_accessor :verify_ssl
107
+
108
+ ### TLS/SSL setting
109
+ # Set this to false to skip verifying SSL host name
110
+ # Default to true.
111
+ #
112
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
113
+ #
114
+ # @return [true, false]
115
+ attr_accessor :verify_ssl_host
116
+
117
+ ### TLS/SSL setting
118
+ # Set this to customize the certificate file to verify the peer.
119
+ #
120
+ # @return [String] the path to the certificate file
121
+ #
122
+ # @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
123
+ # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
124
+ attr_accessor :ssl_ca_cert
125
+
126
+ ### TLS/SSL setting
127
+ # Client certificate file (for client certificate)
128
+ attr_accessor :cert_file
129
+
130
+ ### TLS/SSL setting
131
+ # Client private key file (for client certificate)
132
+ attr_accessor :key_file
133
+
134
+ # Set this to customize parameters encoding of array parameter with multi collectionFormat.
135
+ # Default to nil.
136
+ #
137
+ # @see The params_encoding option of Ethon. Related source code:
138
+ # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
139
+ attr_accessor :params_encoding
140
+
141
+
142
+ attr_accessor :inject_format
143
+
144
+ attr_accessor :force_ending_format
145
+
146
+ def initialize
147
+ @scheme = 'https'
148
+ @host = 'app.kinde.com'
149
+ @base_path = ''
150
+ @server_index = 0
151
+ @server_operation_index = {}
152
+ @server_variables = {}
153
+ @server_operation_variables = {}
154
+ @api_key = {}
155
+ @api_key_prefix = {}
156
+ @client_side_validation = true
157
+ @verify_ssl = true
158
+ @verify_ssl_host = true
159
+ @cert_file = nil
160
+ @key_file = nil
161
+ @timeout = 0
162
+ @params_encoding = nil
163
+ @debugging = false
164
+ @inject_format = false
165
+ @force_ending_format = false
166
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
167
+
168
+ yield(self) if block_given?
169
+ end
170
+
171
+ # The default Configuration object.
172
+ def self.default
173
+ @@default ||= Configuration.new
174
+ end
175
+
176
+ def configure
177
+ yield(self) if block_given?
178
+ end
179
+
180
+ def scheme=(scheme)
181
+ # remove :// from scheme
182
+ @scheme = scheme.sub(/:\/\//, '')
183
+ end
184
+
185
+ def host=(host)
186
+ # remove http(s):// and anything after a slash
187
+ @host = host.sub(/https?:\/\//, '').split('/').first
188
+ end
189
+
190
+ def base_path=(base_path)
191
+ # Add leading and trailing slashes to base_path
192
+ @base_path = "/#{base_path}".gsub(/\/+/, '/')
193
+ @base_path = '' if @base_path == '/'
194
+ end
195
+
196
+ # Returns base URL for specified operation based on server settings
197
+ def base_url(operation = nil)
198
+ index = server_operation_index.fetch(operation, server_index)
199
+ return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
200
+
201
+ server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
202
+ end
203
+
204
+ # Gets API key (with prefix if set).
205
+ # @param [String] param_name the parameter name of API key auth
206
+ def api_key_with_prefix(param_name, param_alias = nil)
207
+ key = @api_key[param_name]
208
+ key = @api_key.fetch(param_alias, key) unless param_alias.nil?
209
+ if @api_key_prefix[param_name]
210
+ "#{@api_key_prefix[param_name]} #{key}"
211
+ else
212
+ key
213
+ end
214
+ end
215
+
216
+ # Gets access_token using access_token_getter or uses the static access_token
217
+ def access_token_with_refresh
218
+ return access_token if access_token_getter.nil?
219
+ access_token_getter.call
220
+ end
221
+
222
+ # Gets Basic Auth token string
223
+ def basic_auth_token
224
+ 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
225
+ end
226
+
227
+ # Returns Auth Settings hash for api client.
228
+ def auth_settings
229
+ {
230
+ 'kindeBearerAuth' =>
231
+ {
232
+ type: 'bearer',
233
+ in: 'header',
234
+ format: 'JWT',
235
+ key: 'Authorization',
236
+ value: "Bearer #{access_token_with_refresh}"
237
+ },
238
+ }
239
+ end
240
+
241
+ # Returns an array of Server setting
242
+ def server_settings
243
+ [
244
+ {
245
+ url: "https://{businessName}.kinde.com",
246
+ description: "No description provided",
247
+ variables: {
248
+ businessName: {
249
+ description: "Business name created in the Kinde admin area.",
250
+ default_value: "app",
251
+ }
252
+ }
253
+ }
254
+ ]
255
+ end
256
+
257
+ def operation_server_settings
258
+ {}
259
+ end
260
+
261
+ # Returns URL based on server settings
262
+ #
263
+ # @param index array index of the server settings
264
+ # @param variables hash of variable and the corresponding value
265
+ def server_url(index, variables = {}, servers = nil)
266
+ servers = server_settings if servers == nil
267
+
268
+ # check array index out of bound
269
+ if (index < 0 || index >= servers.size)
270
+ fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
271
+ end
272
+
273
+ server = servers[index]
274
+ url = server[:url]
275
+
276
+ return url unless server.key? :variables
277
+
278
+ # go through variable and assign a value
279
+ server[:variables].each do |name, variable|
280
+ if variables.key?(name)
281
+ if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
282
+ url.gsub! "{" + name.to_s + "}", variables[name]
283
+ else
284
+ fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
285
+ end
286
+ else
287
+ # use default value
288
+ url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
289
+ end
290
+ end
291
+
292
+ url
293
+ end
294
+ end
295
+ end
@@ -0,0 +1,239 @@
1
+ =begin
2
+ #Kinde Management API
3
+
4
+ #Provides endpoints to manage your Kinde Businesses
5
+
6
+ The version of the OpenAPI document: 1
7
+ Contact: support@kinde.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.4.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module KindeApi
17
+ class AddOrganizationUsers200Response
18
+ # Response code.
19
+ attr_accessor :code
20
+
21
+ # Response message.
22
+ attr_accessor :message
23
+
24
+ attr_accessor :users_added
25
+
26
+ # Attribute mapping from ruby-style variable name to JSON key.
27
+ def self.attribute_map
28
+ {
29
+ :'code' => :'code',
30
+ :'message' => :'message',
31
+ :'users_added' => :'users_added'
32
+ }
33
+ end
34
+
35
+ # Returns all the JSON keys this model knows about
36
+ def self.acceptable_attributes
37
+ attribute_map.values
38
+ end
39
+
40
+ # Attribute type mapping.
41
+ def self.openapi_types
42
+ {
43
+ :'code' => :'String',
44
+ :'message' => :'String',
45
+ :'users_added' => :'Array<String>'
46
+ }
47
+ end
48
+
49
+ # List of attributes with nullable: true
50
+ def self.openapi_nullable
51
+ Set.new([
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 `KindeApi::AddOrganizationUsers200Response` 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 `KindeApi::AddOrganizationUsers200Response`. 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?(:'code')
71
+ self.code = attributes[:'code']
72
+ end
73
+
74
+ if attributes.key?(:'message')
75
+ self.message = attributes[:'message']
76
+ end
77
+
78
+ if attributes.key?(:'users_added')
79
+ if (value = attributes[:'users_added']).is_a?(Array)
80
+ self.users_added = value
81
+ end
82
+ end
83
+ end
84
+
85
+ # Show invalid properties with the reasons. Usually used together with valid?
86
+ # @return Array for valid properties with the reasons
87
+ def list_invalid_properties
88
+ invalid_properties = Array.new
89
+ invalid_properties
90
+ end
91
+
92
+ # Check to see if the all the properties in the model are valid
93
+ # @return true if the model is valid
94
+ def valid?
95
+ true
96
+ end
97
+
98
+ # Checks equality by comparing each attribute.
99
+ # @param [Object] Object to be compared
100
+ def ==(o)
101
+ return true if self.equal?(o)
102
+ self.class == o.class &&
103
+ code == o.code &&
104
+ message == o.message &&
105
+ users_added == o.users_added
106
+ end
107
+
108
+ # @see the `==` method
109
+ # @param [Object] Object to be compared
110
+ def eql?(o)
111
+ self == o
112
+ end
113
+
114
+ # Calculates hash code according to all attributes.
115
+ # @return [Integer] Hash code
116
+ def hash
117
+ [code, message, users_added].hash
118
+ end
119
+
120
+ # Builds the object from hash
121
+ # @param [Hash] attributes Model attributes in the form of hash
122
+ # @return [Object] Returns the model itself
123
+ def self.build_from_hash(attributes)
124
+ new.build_from_hash(attributes)
125
+ end
126
+
127
+ # Builds the object from hash
128
+ # @param [Hash] attributes Model attributes in the form of hash
129
+ # @return [Object] Returns the model itself
130
+ def build_from_hash(attributes)
131
+ return nil unless attributes.is_a?(Hash)
132
+ attributes = attributes.transform_keys(&:to_sym)
133
+ self.class.openapi_types.each_pair do |key, type|
134
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
135
+ self.send("#{key}=", nil)
136
+ elsif type =~ /\AArray<(.*)>/i
137
+ # check to ensure the input is an array given that the attribute
138
+ # is documented as an array but the input is not
139
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
140
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
141
+ end
142
+ elsif !attributes[self.class.attribute_map[key]].nil?
143
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
144
+ end
145
+ end
146
+
147
+ self
148
+ end
149
+
150
+ # Deserializes the data based on type
151
+ # @param string type Data type
152
+ # @param string value Value to be deserialized
153
+ # @return [Object] Deserialized data
154
+ def _deserialize(type, value)
155
+ case type.to_sym
156
+ when :Time
157
+ Time.parse(value)
158
+ when :Date
159
+ Date.parse(value)
160
+ when :String
161
+ value.to_s
162
+ when :Integer
163
+ value.to_i
164
+ when :Float
165
+ value.to_f
166
+ when :Boolean
167
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
168
+ true
169
+ else
170
+ false
171
+ end
172
+ when :Object
173
+ # generic object (usually a Hash), return directly
174
+ value
175
+ when /\AArray<(?<inner_type>.+)>\z/
176
+ inner_type = Regexp.last_match[:inner_type]
177
+ value.map { |v| _deserialize(inner_type, v) }
178
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
179
+ k_type = Regexp.last_match[:k_type]
180
+ v_type = Regexp.last_match[:v_type]
181
+ {}.tap do |hash|
182
+ value.each do |k, v|
183
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
184
+ end
185
+ end
186
+ else # model
187
+ # models (e.g. Pet) or oneOf
188
+ klass = KindeApi.const_get(type)
189
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
190
+ end
191
+ end
192
+
193
+ # Returns the string representation of the object
194
+ # @return [String] String presentation of the object
195
+ def to_s
196
+ to_hash.to_s
197
+ end
198
+
199
+ # to_body is an alias to to_hash (backward compatibility)
200
+ # @return [Hash] Returns the object in the form of hash
201
+ def to_body
202
+ to_hash
203
+ end
204
+
205
+ # Returns the object in the form of hash
206
+ # @return [Hash] Returns the object in the form of hash
207
+ def to_hash
208
+ hash = {}
209
+ self.class.attribute_map.each_pair do |attr, param|
210
+ value = self.send(attr)
211
+ if value.nil?
212
+ is_nullable = self.class.openapi_nullable.include?(attr)
213
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
214
+ end
215
+
216
+ hash[param] = _to_hash(value)
217
+ end
218
+ hash
219
+ end
220
+
221
+ # Outputs non-array value in the form of hash
222
+ # For object, use to_hash. Otherwise, just return the value
223
+ # @param [Object] value Any valid value
224
+ # @return [Hash] Returns the value in the form of hash
225
+ def _to_hash(value)
226
+ if value.is_a?(Array)
227
+ value.compact.map { |v| _to_hash(v) }
228
+ elsif value.is_a?(Hash)
229
+ {}.tap do |hash|
230
+ value.each { |k, v| hash[k] = _to_hash(v) }
231
+ end
232
+ elsif value.respond_to? :to_hash
233
+ value.to_hash
234
+ else
235
+ value
236
+ end
237
+ end
238
+ end
239
+ end