kinde_sdk 1.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 (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,397 @@
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 'json'
15
+ require 'logger'
16
+ require 'tempfile'
17
+ require 'time'
18
+ require 'typhoeus'
19
+
20
+ module KindeApi
21
+ class ApiClient
22
+ # The Configuration object holding settings to be used in the API client.
23
+ attr_accessor :config
24
+
25
+ # Defines the headers to be used in HTTP requests of all API calls by default.
26
+ #
27
+ # @return [Hash]
28
+ attr_accessor :default_headers
29
+
30
+ # Initializes the ApiClient
31
+ # @option config [Configuration] Configuration for initializing the object, default to Configuration.default
32
+ def initialize(config = Configuration.default)
33
+ @config = config
34
+ @user_agent = "OpenAPI-Generator/#{VERSION}/ruby"
35
+ @default_headers = {
36
+ "Accept-Encoding" => "*",
37
+ 'Content-Type' => 'application/json',
38
+ 'User-Agent' => @user_agent
39
+ }
40
+ end
41
+
42
+ def self.default
43
+ @@default ||= ApiClient.new
44
+ end
45
+
46
+ # Call an API with given options.
47
+ #
48
+ # @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
49
+ # the data deserialized from response body (could be nil), response status code and response headers.
50
+ def call_api(http_method, path, opts = {})
51
+ request = build_request(http_method, path, opts)
52
+ response = request.run
53
+
54
+ if @config.debugging
55
+ @config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
56
+ end
57
+
58
+ unless response.success?
59
+ if response.timed_out?
60
+ fail ApiError.new('Connection timed out')
61
+ elsif response.code == 0
62
+ # Errors from libcurl will be made visible here
63
+ fail ApiError.new(:code => 0,
64
+ :message => response.return_message)
65
+ else
66
+ fail ApiError.new(:code => response.code,
67
+ :response_headers => response.headers,
68
+ :response_body => response.body),
69
+ response.status_message
70
+ end
71
+ end
72
+
73
+ if opts[:return_type]
74
+ data = deserialize(response, opts[:return_type])
75
+ else
76
+ data = nil
77
+ end
78
+ return data, response.code, response.headers
79
+ end
80
+
81
+ # Builds the HTTP request
82
+ #
83
+ # @param [String] http_method HTTP method/verb (e.g. POST)
84
+ # @param [String] path URL path (e.g. /account/new)
85
+ # @option opts [Hash] :header_params Header parameters
86
+ # @option opts [Hash] :query_params Query parameters
87
+ # @option opts [Hash] :form_params Query parameters
88
+ # @option opts [Object] :body HTTP body (JSON/XML)
89
+ # @return [Typhoeus::Request] A Typhoeus Request
90
+ def build_request(http_method, path, opts = {})
91
+ url = build_request_url(path, opts)
92
+ http_method = http_method.to_sym.downcase
93
+
94
+ header_params = @default_headers.merge(opts[:header_params] || {})
95
+ query_params = opts[:query_params] || {}
96
+ form_params = opts[:form_params] || {}
97
+ follow_location = opts[:follow_location] || true
98
+
99
+ update_params_for_auth! header_params, query_params, opts[:auth_names]
100
+
101
+ # set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
102
+ _verify_ssl_host = @config.verify_ssl_host ? 2 : 0
103
+
104
+ req_opts = {
105
+ :method => http_method,
106
+ :headers => header_params,
107
+ :params => query_params,
108
+ :params_encoding => @config.params_encoding,
109
+ :timeout => @config.timeout,
110
+ :ssl_verifypeer => @config.verify_ssl,
111
+ :ssl_verifyhost => _verify_ssl_host,
112
+ :sslcert => @config.cert_file,
113
+ :sslkey => @config.key_file,
114
+ :verbose => @config.debugging,
115
+ :followlocation => follow_location
116
+ }
117
+
118
+ # set custom cert, if provided
119
+ req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
120
+
121
+ if [:post, :patch, :put, :delete].include?(http_method)
122
+ req_body = build_request_body(header_params, form_params, opts[:body])
123
+ req_opts.update :body => req_body
124
+ if @config.debugging
125
+ @config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
126
+ end
127
+ end
128
+
129
+ request = Typhoeus::Request.new(url, req_opts)
130
+ download_file(request) if opts[:return_type] == 'File'
131
+ request
132
+ end
133
+
134
+ # Builds the HTTP request body
135
+ #
136
+ # @param [Hash] header_params Header parameters
137
+ # @param [Hash] form_params Query parameters
138
+ # @param [Object] body HTTP body (JSON/XML)
139
+ # @return [String] HTTP body data in the form of string
140
+ def build_request_body(header_params, form_params, body)
141
+ # http form
142
+ if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
143
+ header_params['Content-Type'] == 'multipart/form-data'
144
+ data = {}
145
+ form_params.each do |key, value|
146
+ case value
147
+ when ::File, ::Array, nil
148
+ # let typhoeus handle File, Array and nil parameters
149
+ data[key] = value
150
+ else
151
+ data[key] = value.to_s
152
+ end
153
+ end
154
+ elsif body
155
+ data = body.is_a?(String) ? body : body.to_json
156
+ else
157
+ data = nil
158
+ end
159
+ data
160
+ end
161
+
162
+ # Save response body into a file in (the defined) temporary folder, using the filename
163
+ # from the "Content-Disposition" header if provided, otherwise a random filename.
164
+ # The response body is written to the file in chunks in order to handle files which
165
+ # size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
166
+ # process can use.
167
+ #
168
+ # @see Configuration#temp_folder_path
169
+ def download_file(request)
170
+ tempfile = nil
171
+ encoding = nil
172
+ request.on_headers do |response|
173
+ content_disposition = response.headers['Content-Disposition']
174
+ if content_disposition && content_disposition =~ /filename=/i
175
+ filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
176
+ prefix = sanitize_filename(filename)
177
+ else
178
+ prefix = 'download-'
179
+ end
180
+ prefix = prefix + '-' unless prefix.end_with?('-')
181
+ encoding = response.body.encoding
182
+ tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
183
+ @tempfile = tempfile
184
+ end
185
+ request.on_body do |chunk|
186
+ chunk.force_encoding(encoding)
187
+ tempfile.write(chunk)
188
+ end
189
+ request.on_complete do |response|
190
+ if tempfile
191
+ tempfile.close
192
+ @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
193
+ "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
194
+ "will be deleted automatically with GC. It's also recommended to delete the temp file "\
195
+ "explicitly with `tempfile.delete`"
196
+ end
197
+ end
198
+ end
199
+
200
+ # Check if the given MIME is a JSON MIME.
201
+ # JSON MIME examples:
202
+ # application/json
203
+ # application/json; charset=UTF8
204
+ # APPLICATION/JSON
205
+ # text/plain
206
+ # text/plain; charset=utf-8
207
+ # */*
208
+ # @param [String] mime MIME
209
+ # @return [Boolean] True if the MIME is application/json
210
+ def json_mime?(mime)
211
+ prepared_mime = mime.to_s.downcase.strip.split(";")[0]
212
+ result = %w[*/* application/json text/plain].find { |i| i == prepared_mime }
213
+ result != nil
214
+ end
215
+
216
+ # Deserialize the response to the given return type.
217
+ #
218
+ # @param [Response] response HTTP response
219
+ # @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
220
+ def deserialize(response, return_type)
221
+ body = response.body
222
+
223
+ # handle file downloading - return the File instance processed in request callbacks
224
+ # note that response body is empty when the file is written in chunks in request on_body callback
225
+ return @tempfile if return_type == 'File'
226
+
227
+ return nil if body.nil? || body.empty?
228
+
229
+ # return response body directly for String return type
230
+ return body if return_type == 'String'
231
+
232
+ # ensuring a default content type
233
+ content_type = response.headers['Content-Type'] || 'application/json'
234
+
235
+ fail "Content-Type is not supported: #{content_type}" unless json_mime?(content_type)
236
+
237
+ begin
238
+ data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
239
+ rescue JSON::ParserError => e
240
+ if %w(String Date Time).include?(return_type)
241
+ data = body
242
+ else
243
+ raise e
244
+ end
245
+ end
246
+
247
+ convert_to_type data, return_type
248
+ end
249
+
250
+ # Convert data to the given return type.
251
+ # @param [Object] data Data to be converted
252
+ # @param [String] return_type Return type
253
+ # @return [Mixed] Data in a particular type
254
+ def convert_to_type(data, return_type)
255
+ return nil if data.nil?
256
+ case return_type
257
+ when 'String'
258
+ data.to_s
259
+ when 'Integer'
260
+ data.to_i
261
+ when 'Float'
262
+ data.to_f
263
+ when 'Boolean'
264
+ data == true
265
+ when 'Time'
266
+ # parse date time (expecting ISO 8601 format)
267
+ Time.parse data
268
+ when 'Date'
269
+ # parse date time (expecting ISO 8601 format)
270
+ Date.parse data
271
+ when 'Object'
272
+ # generic object (usually a Hash), return directly
273
+ data
274
+ when /\AArray<(.+)>\z/
275
+ # e.g. Array<Pet>
276
+ sub_type = $1
277
+ data.map { |item| convert_to_type(item, sub_type) }
278
+ when /\AHash\<String, (.+)\>\z/
279
+ # e.g. Hash<String, Integer>
280
+ sub_type = $1
281
+ {}.tap do |hash|
282
+ data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
283
+ end
284
+ else
285
+ # models (e.g. Pet) or oneOf
286
+ klass = KindeApi.const_get(return_type)
287
+ klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data)
288
+ end
289
+ end
290
+
291
+ # Sanitize filename by removing path.
292
+ # e.g. ../../sun.gif becomes sun.gif
293
+ #
294
+ # @param [String] filename the filename to be sanitized
295
+ # @return [String] the sanitized filename
296
+ def sanitize_filename(filename)
297
+ filename.gsub(/.*[\/\\]/, '')
298
+ end
299
+
300
+ def build_request_url(path, opts = {})
301
+ # Add leading and trailing slashes to path
302
+ path = "/#{path}".gsub(/\/+/, '/')
303
+ @config.base_url(opts[:operation]) + path
304
+ end
305
+
306
+ # Update header and query params based on authentication settings.
307
+ #
308
+ # @param [Hash] header_params Header parameters
309
+ # @param [Hash] query_params Query parameters
310
+ # @param [String] auth_names Authentication scheme name
311
+ def update_params_for_auth!(header_params, query_params, auth_names)
312
+ Array(auth_names).each do |auth_name|
313
+ auth_setting = @config.auth_settings[auth_name]
314
+ next unless auth_setting
315
+ case auth_setting[:in]
316
+ when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
317
+ when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
318
+ else fail ArgumentError, 'Authentication token must be in `query` or `header`'
319
+ end
320
+ end
321
+ end
322
+
323
+ # Sets user agent in HTTP header
324
+ #
325
+ # @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0)
326
+ def user_agent=(user_agent)
327
+ @user_agent = user_agent
328
+ @default_headers['User-Agent'] = @user_agent
329
+ end
330
+
331
+ # Return Accept header based on an array of accepts provided.
332
+ # @param [Array] accepts array for Accept
333
+ # @return [String] the Accept header (e.g. application/json)
334
+ def select_header_accept(accepts)
335
+ return nil if accepts.nil? || accepts.empty?
336
+ # use JSON when present, otherwise use all of the provided
337
+ json_accept = accepts.find { |s| json_mime?(s) }
338
+ json_accept || accepts.join(',')
339
+ end
340
+
341
+ # Return Content-Type header based on an array of content types provided.
342
+ # @param [Array] content_types array for Content-Type
343
+ # @return [String] the Content-Type header (e.g. application/json)
344
+ def select_header_content_type(content_types)
345
+ # return nil by default
346
+ return if content_types.nil? || content_types.empty?
347
+ # use JSON when present, otherwise use the first one
348
+ json_content_type = content_types.find { |s| json_mime?(s) }
349
+ json_content_type || content_types.first
350
+ end
351
+
352
+ # Convert object (array, hash, object, etc) to JSON string.
353
+ # @param [Object] model object to be converted into JSON string
354
+ # @return [String] JSON string representation of the object
355
+ def object_to_http_body(model)
356
+ return model if model.nil? || model.is_a?(String)
357
+ local_body = nil
358
+ if model.is_a?(Array)
359
+ local_body = model.map { |m| object_to_hash(m) }
360
+ else
361
+ local_body = object_to_hash(model)
362
+ end
363
+ local_body.to_json
364
+ end
365
+
366
+ # Convert object(non-array) to hash.
367
+ # @param [Object] obj object to be converted into JSON string
368
+ # @return [String] JSON string representation of the object
369
+ def object_to_hash(obj)
370
+ if obj.respond_to?(:to_hash)
371
+ obj.to_hash
372
+ else
373
+ obj
374
+ end
375
+ end
376
+
377
+ # Build parameter value according to the given collection format.
378
+ # @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi
379
+ def build_collection_param(param, collection_format)
380
+ case collection_format
381
+ when :csv
382
+ param.join(',')
383
+ when :ssv
384
+ param.join(' ')
385
+ when :tsv
386
+ param.join("\t")
387
+ when :pipes
388
+ param.join('|')
389
+ when :multi
390
+ # return the array directly as typhoeus will handle it as expected
391
+ param
392
+ else
393
+ fail "unknown collection format: #{collection_format.inspect}"
394
+ end
395
+ end
396
+ end
397
+ end
@@ -0,0 +1,58 @@
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 ApiError < StandardError
15
+ attr_reader :code, :response_headers, :response_body
16
+
17
+ # Usage examples:
18
+ # ApiError.new
19
+ # ApiError.new("message")
20
+ # ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
21
+ # ApiError.new(:code => 404, :message => "Not Found")
22
+ def initialize(arg = nil)
23
+ if arg.is_a? Hash
24
+ if arg.key?(:message) || arg.key?('message')
25
+ super(arg[:message] || arg['message'])
26
+ else
27
+ super arg
28
+ end
29
+
30
+ arg.each do |k, v|
31
+ instance_variable_set "@#{k}", v
32
+ end
33
+ else
34
+ super arg
35
+ @message = arg
36
+ end
37
+ end
38
+
39
+ # Override to_s to display a friendly error message
40
+ def to_s
41
+ message
42
+ end
43
+
44
+ def message
45
+ if @message.nil?
46
+ msg = "Error message: the server returns an error"
47
+ else
48
+ msg = @message
49
+ end
50
+
51
+ msg += "\nHTTP status code: #{code}" if code
52
+ msg += "\nResponse headers: #{response_headers}" if response_headers
53
+ msg += "\nResponse body: #{response_body}" if response_body
54
+
55
+ msg
56
+ end
57
+ end
58
+ end