kinde_sdk 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +103 -19
  3. data/kinde_api/README.md +58 -23
  4. data/kinde_api/docs/AddOrganizationUsersRequest.md +1 -1
  5. data/kinde_api/docs/AddOrganizationUsersRequestUsersInner.md +22 -0
  6. data/kinde_api/docs/{AddOrganizationUsers200Response.md → AddOrganizationUsersResponse.md} +2 -2
  7. data/kinde_api/docs/Application.md +20 -0
  8. data/kinde_api/docs/CallbacksApi.md +219 -0
  9. data/kinde_api/docs/ConnectedAppsApi.md +9 -9
  10. data/kinde_api/docs/CreateOrganizationRequest.md +11 -1
  11. data/kinde_api/docs/CreateOrganizationResponse.md +22 -0
  12. data/kinde_api/docs/CreateOrganizationResponseOrganization.md +18 -0
  13. data/kinde_api/docs/CreateOrganizationUserRoleRequest.md +18 -0
  14. data/kinde_api/docs/CreatePermissionRequest.md +22 -0
  15. data/kinde_api/docs/CreateRoleRequest.md +24 -0
  16. data/kinde_api/docs/CreateSubscriberSuccessResponse.md +18 -0
  17. data/kinde_api/docs/CreateSubscriberSuccessResponseSubscriber.md +18 -0
  18. data/kinde_api/docs/{CreateUser200Response.md → CreateUserResponse.md} +2 -2
  19. data/kinde_api/docs/EnvironmentsApi.md +71 -4
  20. data/kinde_api/docs/FeatureFlagsApi.md +9 -11
  21. data/kinde_api/docs/GetApplicationsResponse.md +24 -0
  22. data/kinde_api/docs/GetEnvironmentFeatureFlagsResponse.md +24 -0
  23. data/kinde_api/docs/GetOrganizationFeatureFlagsResponse.md +22 -0
  24. data/kinde_api/docs/GetOrganizationFeatureFlagsResponseFeatureFlagsValue.md +20 -0
  25. data/kinde_api/docs/{GetOrganizations200Response.md → GetOrganizationsResponse.md} +2 -2
  26. data/kinde_api/docs/GetOrganizationsUserRolesResponse.md +24 -0
  27. data/kinde_api/docs/{GetOrganizationUsers200Response.md → GetOrganizationsUsersResponse.md} +2 -2
  28. data/kinde_api/docs/GetRedirectCallbackUrlsResponse.md +18 -0
  29. data/kinde_api/docs/OrganizationUser.md +3 -1
  30. data/kinde_api/docs/OrganizationUserRole.md +22 -0
  31. data/kinde_api/docs/OrganizationsApi.md +494 -59
  32. data/kinde_api/docs/Permissions.md +22 -0
  33. data/kinde_api/docs/PermissionsApi.md +229 -0
  34. data/kinde_api/docs/RedirectCallbackUrls.md +18 -0
  35. data/kinde_api/docs/Roles.md +22 -0
  36. data/kinde_api/docs/RolesApi.md +229 -0
  37. data/kinde_api/docs/SubscribersApi.md +229 -0
  38. data/kinde_api/docs/UpdateOrganizationRequest.md +28 -0
  39. data/kinde_api/docs/UpdateOrganizationUsersRequest.md +18 -0
  40. data/kinde_api/docs/UpdateOrganizationUsersRequestUsersInner.md +24 -0
  41. data/kinde_api/docs/UpdateOrganizationUsersResponse.md +24 -0
  42. data/kinde_api/docs/UpdateUserRequest.md +3 -1
  43. data/kinde_api/docs/User.md +15 -1
  44. data/kinde_api/docs/UserIdentityResult.md +1 -3
  45. data/kinde_api/docs/UserProfile.md +3 -1
  46. data/kinde_api/docs/UserProfileV2.md +6 -2
  47. data/kinde_api/docs/UsersApi.md +31 -259
  48. data/kinde_api/docs/{GetUsers200Response.md → UsersResponse.md} +2 -2
  49. data/kinde_api/lib/kinde_api/api/callbacks_api.rb +221 -0
  50. data/kinde_api/lib/kinde_api/api/connected_apps_api.rb +8 -8
  51. data/kinde_api/lib/kinde_api/api/environments_api.rb +61 -4
  52. data/kinde_api/lib/kinde_api/api/feature_flags_api.rb +8 -15
  53. data/kinde_api/lib/kinde_api/api/organizations_api.rb +492 -57
  54. data/kinde_api/lib/kinde_api/api/permissions_api.rb +226 -0
  55. data/kinde_api/lib/kinde_api/api/roles_api.rb +226 -0
  56. data/kinde_api/lib/kinde_api/api/subscribers_api.rb +228 -0
  57. data/kinde_api/lib/kinde_api/api/users_api.rb +30 -233
  58. data/kinde_api/lib/kinde_api/api_client.rb +1 -13
  59. data/kinde_api/lib/kinde_api/configuration.rb +3 -77
  60. data/kinde_api/lib/kinde_api/models/add_organization_users_request.rb +2 -2
  61. data/kinde_api/lib/kinde_api/models/add_organization_users_request_users_inner.rb +242 -0
  62. data/kinde_api/lib/kinde_api/models/{add_organization_users200_response.rb → add_organization_users_response.rb} +3 -3
  63. data/kinde_api/lib/kinde_api/models/application.rb +226 -0
  64. data/kinde_api/lib/kinde_api/models/create_organization_request.rb +54 -4
  65. data/kinde_api/lib/kinde_api/models/{remove_organization_users200_response.rb → create_organization_response.rb} +19 -12
  66. data/kinde_api/lib/kinde_api/models/{create_organization201_response.rb → create_organization_response_organization.rb} +8 -18
  67. data/kinde_api/lib/kinde_api/models/create_organization_user_role_request.rb +218 -0
  68. data/kinde_api/lib/kinde_api/models/create_permission_request.rb +238 -0
  69. data/kinde_api/lib/kinde_api/models/create_role_request.rb +248 -0
  70. data/kinde_api/lib/kinde_api/models/create_subscriber_success_response.rb +217 -0
  71. data/kinde_api/lib/kinde_api/models/create_subscriber_success_response_subscriber.rb +218 -0
  72. data/kinde_api/lib/kinde_api/models/create_user_request_identities_inner.rb +34 -0
  73. data/kinde_api/lib/kinde_api/models/{create_user200_response.rb → create_user_response.rb} +3 -3
  74. data/kinde_api/lib/kinde_api/models/get_applications_response.rb +249 -0
  75. data/kinde_api/lib/kinde_api/models/get_environment_feature_flags_response.rb +250 -0
  76. data/kinde_api/lib/kinde_api/models/get_organization_feature_flags_response.rb +240 -0
  77. data/kinde_api/lib/kinde_api/models/get_organization_feature_flags_response_feature_flags_value.rb +260 -0
  78. data/kinde_api/lib/kinde_api/models/{get_organizations200_response.rb → get_organizations_response.rb} +3 -3
  79. data/kinde_api/lib/kinde_api/models/get_organizations_user_roles_response.rb +249 -0
  80. data/kinde_api/lib/kinde_api/models/{get_organization_users200_response.rb → get_organizations_users_response.rb} +3 -3
  81. data/kinde_api/lib/kinde_api/models/get_redirect_callback_urls_response.rb +220 -0
  82. data/kinde_api/lib/kinde_api/models/organization_user.rb +15 -4
  83. data/kinde_api/lib/kinde_api/models/organization_user_role.rb +235 -0
  84. data/kinde_api/lib/kinde_api/models/permissions.rb +238 -0
  85. data/kinde_api/lib/kinde_api/models/redirect_callback_urls.rb +220 -0
  86. data/kinde_api/lib/kinde_api/models/roles.rb +238 -0
  87. data/kinde_api/lib/kinde_api/models/update_organization_request.rb +268 -0
  88. data/kinde_api/lib/kinde_api/models/{remove_organization_users_request.rb → update_organization_users_request.rb} +5 -5
  89. data/kinde_api/lib/kinde_api/models/update_organization_users_request_users_inner.rb +252 -0
  90. data/kinde_api/lib/kinde_api/models/update_organization_users_response.rb +250 -0
  91. data/kinde_api/lib/kinde_api/models/update_user_request.rb +14 -4
  92. data/kinde_api/lib/kinde_api/models/user.rb +79 -5
  93. data/kinde_api/lib/kinde_api/models/user_identity_result.rb +4 -14
  94. data/kinde_api/lib/kinde_api/models/user_profile.rb +14 -4
  95. data/kinde_api/lib/kinde_api/models/user_profile_v2.rb +25 -5
  96. data/kinde_api/lib/kinde_api/models/{get_users200_response.rb → users_response.rb} +3 -3
  97. data/kinde_api/lib/kinde_api.rb +32 -8
  98. data/kinde_api/spec/api/callbacks_api_spec.rb +73 -0
  99. data/kinde_api/spec/api/connected_apps_api_spec.rb +1 -1
  100. data/kinde_api/spec/api/environments_api_spec.rb +11 -0
  101. data/kinde_api/spec/api/feature_flags_api_spec.rb +1 -2
  102. data/kinde_api/spec/api/organizations_api_spec.rb +93 -14
  103. data/kinde_api/spec/api/permissions_api_spec.rb +74 -0
  104. data/kinde_api/spec/api/roles_api_spec.rb +74 -0
  105. data/kinde_api/spec/api/subscribers_api_spec.rb +76 -0
  106. data/kinde_api/spec/api/users_api_spec.rb +6 -47
  107. data/kinde_api/spec/api_client_spec.rb +0 -12
  108. data/kinde_api/spec/models/add_organization_users_request_users_inner_spec.rb +46 -0
  109. data/kinde_api/spec/models/{add_organization_users200_response_spec.rb → add_organization_users_response_spec.rb} +6 -6
  110. data/kinde_api/spec/models/{remove_organization_users200_response_spec.rb → application_spec.rb} +8 -8
  111. data/kinde_api/spec/models/create_organization_request_spec.rb +30 -0
  112. data/kinde_api/spec/models/create_organization_response_organization_spec.rb +34 -0
  113. data/kinde_api/spec/models/{create_organization201_response_spec.rb → create_organization_response_spec.rb} +13 -7
  114. data/kinde_api/spec/models/create_organization_user_role_request_spec.rb +34 -0
  115. data/kinde_api/spec/models/create_permission_request_spec.rb +46 -0
  116. data/kinde_api/spec/models/create_role_request_spec.rb +52 -0
  117. data/kinde_api/spec/models/create_subscriber_success_response_spec.rb +34 -0
  118. data/kinde_api/spec/models/create_subscriber_success_response_subscriber_spec.rb +34 -0
  119. data/kinde_api/spec/models/create_user_request_identities_inner_spec.rb +4 -0
  120. data/kinde_api/spec/models/{create_user200_response_spec.rb → create_user_response_spec.rb} +6 -6
  121. data/kinde_api/spec/models/get_applications_response_spec.rb +52 -0
  122. data/kinde_api/spec/models/get_environment_feature_flags_response_spec.rb +52 -0
  123. data/kinde_api/spec/models/get_organization_feature_flags_response_feature_flags_value_spec.rb +44 -0
  124. data/kinde_api/spec/models/get_organization_feature_flags_response_spec.rb +46 -0
  125. data/kinde_api/spec/models/{get_organizations200_response_spec.rb → get_organizations_response_spec.rb} +6 -6
  126. data/kinde_api/spec/models/get_organizations_user_roles_response_spec.rb +52 -0
  127. data/kinde_api/spec/models/{get_organization_users200_response_spec.rb → get_organizations_users_response_spec.rb} +6 -6
  128. data/kinde_api/spec/models/get_redirect_callback_urls_response_spec.rb +34 -0
  129. data/kinde_api/spec/models/organization_user_role_spec.rb +46 -0
  130. data/kinde_api/spec/models/organization_user_spec.rb +6 -0
  131. data/kinde_api/spec/models/permissions_spec.rb +46 -0
  132. data/kinde_api/spec/models/redirect_callback_urls_spec.rb +34 -0
  133. data/kinde_api/spec/models/roles_spec.rb +46 -0
  134. data/kinde_api/spec/models/update_organization_request_spec.rb +64 -0
  135. data/kinde_api/spec/models/{remove_organization_users_request_spec.rb → update_organization_users_request_spec.rb} +6 -6
  136. data/kinde_api/spec/models/update_organization_users_request_users_inner_spec.rb +52 -0
  137. data/kinde_api/spec/models/update_organization_users_response_spec.rb +52 -0
  138. data/kinde_api/spec/models/update_user_request_spec.rb +6 -0
  139. data/kinde_api/spec/models/user_identity_result_spec.rb +0 -6
  140. data/kinde_api/spec/models/user_profile_spec.rb +6 -0
  141. data/kinde_api/spec/models/user_profile_v2_spec.rb +12 -0
  142. data/kinde_api/spec/models/user_spec.rb +42 -0
  143. data/kinde_api/spec/models/{get_users200_response_spec.rb → users_response_spec.rb} +6 -6
  144. data/kinde_sdk.gemspec +1 -1
  145. data/lib/kinde_sdk/client/feature_flags.rb +64 -0
  146. data/lib/kinde_sdk/client/permissions.rb +20 -0
  147. data/lib/kinde_sdk/client.rb +33 -18
  148. data/lib/kinde_sdk/configuration.rb +0 -2
  149. data/lib/kinde_sdk/version.rb +1 -1
  150. data/lib/kinde_sdk.rb +27 -12
  151. data/spec/kinde_sdk_spec.rb +131 -5
  152. data/spec/spec_helper.rb +2 -0
  153. metadata +134 -36
  154. data/kinde_api/docs/CreateOrganization201Response.md +0 -20
  155. data/kinde_api/docs/RemoveOrganizationUsers200Response.md +0 -20
  156. data/kinde_api/docs/RemoveOrganizationUsersRequest.md +0 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3166fc3f21315cb21235d7c303440266daef8b2d4b37d983e2bc06bb28fd5acd
4
- data.tar.gz: 7421f7964d90a458b47724a4073711480a6caeac1cc6fe3e68989dfbe2045821
3
+ metadata.gz: 2edea62c5bda0b80177bcb0444a278e5deb6b6a99317f29f2e5d51033dd6a488
4
+ data.tar.gz: 360a4ef5a4de05384ad6186960f22c3955839d63edcc7df6cb3f76f66428fdb0
5
5
  SHA512:
6
- metadata.gz: 380bac0d796adc5daf5b55faea19d130e32fc248b2e2fb5f91e0e74bb267b4ac617fb1f51163ce2871a0c78ed2447161a8be316f972a20d694dfd9a665b9fb2c
7
- data.tar.gz: d667129a0d21dca7dd07baecedc96e78470eb0952744c7921e2bdb96445524bb378eef2625c99c87b6357ff1183b44e32e1df93fea1f05bf518bb926f53a51d8
6
+ metadata.gz: 6b69c73af4c5ca4c291e54cba3c9284d74d2aaab8024c27c6d09b7f40ac859cf3004dabf362dd5839acf46d2bfab25f9fcd4a67377ea52afb948e619b6827eec
7
+ data.tar.gz: b9b249b70f9983335153b5d6ba6ab8187588c4a9da240e97fb6e1f17076b37d600d16a7ea61c9693adf419d80cdbdfa671f867b8a8d94dab9331c6925ef564e0
data/README.md CHANGED
@@ -65,7 +65,6 @@ KindeSdk.configure do |c|
65
65
  # c.authorize_url = '/oauth2/auth' # default value
66
66
  # c.token_url = '/oauth2/token' # default value
67
67
  # c.debugging = false # default value
68
- # c.business_name = nil # default value
69
68
  c.logger = Rails.logger
70
69
  end
71
70
  ```
@@ -76,16 +75,13 @@ Here is detailed explanation on them:
76
75
  - `Client id` and `Client secret` can be fetched from your Kinde application credentials in a setting section.
77
76
  - `Callback url` refers to your callback processing controller action. Remember that
78
77
  the url must be defined in allowed callback urls of your kinde organization's [application config](#Kinde-configuration).
78
+ Callback url is an optional parameter, you can set the desired url in runtime, see examples below.
79
79
  - `Logout url` will be triggered after successful logout on kinde. Same as callback url, it should be
80
80
  defined in allowed logout urls of your kinde organization's application config
81
81
  - `Scope` is an oauth special parameter which is used to limit some rights. Probably, you don't need to change in.
82
82
  - `PKCE enabled` is a flag that can turn off PKCE auth flow. By default it is activated to improve your security.
83
83
  - `Authorize url` and `Token url` are paths to oauth2 methods in kinde. You don't need to change it.
84
84
  - `Debugging` set to true start writing verbose request logs. Might be useful while developing your application.
85
- - `Business name` is a parameter which is used in requests building. By default it is extracted from your
86
- `domain` endpoint. For example, if your domain is `https://your-biz.kinde.com`, then business name will be set
87
- to `your-biz`, for `https://example-chamois.au.kinde.com` it'll be `example-chamois.au` and so on.
88
- You don't need to change it in general, but it is possible to override if needed.
89
85
  - `Logger` might be set to any kind of loggers you are using. By default it is set to `Rails.logger` if gem is used in
90
86
  rails application or `Logger.new(STDOUT)` if it is not a rails app.
91
87
 
@@ -129,6 +125,11 @@ KindeSdk.auth_url
129
125
  ```
130
126
  If you are about to use PCKE, our recommendation to save code verifier output somewhere near your later tokens output.
131
127
 
128
+ The `#auth_url` method can have another redirect url just in runtime. Use it with the argument:
129
+ ```ruby
130
+ KindeSdk.auth_url(redirect_uri: "your-another-desired-callback")
131
+ ```
132
+
132
133
  You can put the link right in your web-application page or you can use it under the hood through redirection.
133
134
  After visiting the link you'll be redirected to Kinde's sign in/sign up form.
134
135
  And after authorizing in Kinde, you'll be redirected to callback url.
@@ -140,7 +141,7 @@ Callback will be triggered with body, where will be code present. You are free t
140
141
  Next, it needs to be exchanged for the access and refresh tokens.
141
142
  `code` is the parameter which received in the callback endpoint, `code_verifier` (if PKCE enabled) should be used from previous step:
142
143
  ```ruby
143
- KindeSdk.fetch_tokens(code, code_verifier)
144
+ KindeSdk.fetch_tokens(code, code_verifier: code_verifier)
144
145
  # =>
145
146
  {"access_token"=>"eyJhbGciOiJSUzI1NiIsIm...",
146
147
  "expires_in"=>86399,
@@ -155,9 +156,14 @@ This is your tokens - save the whole hash in your session, redis or any other st
155
156
  # In case of preventing cookie overflow, you need to limit what exactly your are saving.
156
157
  # Here is the required minimum of params. But in general you are able save it wherever you want to.
157
158
  # For example, in database, without any limiting.
158
- session[:kinde_auth] = KindeSdk.fetch_tokens(code).slice(:access_token, :refresh_token, :expires_at)
159
+ session[:kinde_auth] = KindeSdk.fetch_tokens(code).slice(:access_token, :id_token, :refresh_token, :expires_at)
159
160
  # ...
160
- client = KindeSdk.client(session[:kinde_auth]["access_token"]) # => #<KindeSdk::Client:0x00007faf31e5ecb8>
161
+ client = KindeSdk.client(session[:kinde_auth]) # => #<KindeSdk::Client:0x00007faf31e5ecb8>
162
+ ```
163
+
164
+ The `#fetch_tokens` method can have another callback url (just lake the `#auth_url` method), just use it in a same way:
165
+ ```ruby
166
+ KindeSdk.fetch_tokens(code, redirect_uri: "your-another-desired-callback")
161
167
  ```
162
168
 
163
169
  #### Token expiration and refreshing
@@ -165,9 +171,15 @@ For proper refreshing you'll need to use `access_token`, `refresh_token` and pro
165
171
  Use these two methods to work with refreshing:
166
172
  ```ruby
167
173
  KindeSdk.token_expired?(session[:kinde_auth]) # => false
168
- KindeSdk.refresh_token(session[:kinde_auth]) # => {"access_token" => "qwe...", "refresh_token" => "fqw...", .....}
174
+ KindeSdk.refresh_token(session[:kinde_auth]) # => {"access_token" => "qwe...", "refresh_token" => "fqw...", "expires_at"=>1685474405}
175
+ ```
176
+ or from your client instance:
177
+ ```ruby
178
+ client.token_expired? # => false
179
+ client.refresh_token # => {"access_token" => "qwe...", ...., "expires_at"=>1685474405}
169
180
  ```
170
- `KindeSdk#refresh_token` returns new token hash, so it needs to be updated in your storage.
181
+ If you are calling `#refresh_token` on a client instance, the instance token data will be automatically updated.
182
+ If you are calling `KindeSdk#refresh_token`, you'll need to store new token data in your configured storage (redis/session/etc).
171
183
 
172
184
  #### Audience
173
185
  An `audience` is the intended recipient of an access token - for example the API for your application.
@@ -193,9 +205,13 @@ KindeSdk.auth_url(scope: "openid offline")
193
205
  #### Getting claims
194
206
  We have provided a helper to grab any claim from your id or access tokens. The helper defaults to access tokens:
195
207
  ```ruby
196
- client = KindeSdk.client(session[:kinde_auth]["access_token"])
197
- client.get_claim("aud") #=> ['api.yourapp.com']
198
- client.get_claim("scp") #=> ["openid", "offline"]
208
+ client = KindeSdk.client(session[:kinde_auth])
209
+ client.get_claim("aud") #=> {name: "aud", value: ['api.yourapp.com']}
210
+ client.get_claim("scp") #=> {name: "scp", value: ["openid", "offline"]}
211
+ ```
212
+ By default claim data fetched from access_token, but you can also do it with id_token as well:
213
+ ```ruby
214
+ client.get_claim("some-claim", :id_token) # => {name: "some-claim", value: "some-data"}
199
215
  ```
200
216
 
201
217
  #### User permissions
@@ -216,12 +232,60 @@ permissions" => [
216
232
  ```
217
233
  We provide helper functions to more easily access permissions:
218
234
  ```ruby
219
- client = KindeSdk.client(session[:kinde_auth]["access_token"])
235
+ client = KindeSdk.client(session[:kinde_auth])
220
236
  client.get_permission("create:todos") # => {org_code: "org_1234", is_granted: true}
221
237
  client.permission_granted?("create:todos") # => true
222
238
  client.permission_granted?("create:orders") # => false
223
239
  ```
224
240
 
241
+ #### Feature flags
242
+ Kinde itself provides feature flag functionality - more [here](https://kinde.com/feature-flags/).
243
+ So, the SDK provides methods to work with them.
244
+ For example, you have data like below:
245
+ ```json
246
+ {
247
+ "asd": { "t": "b", "v": true },
248
+ "eeeeee": { "t": "i", "v": 111 },
249
+ "qqq": { "t": "s", "v": "aa" }
250
+ }
251
+ ```
252
+ where `t` refers to type (`b` - boolean, `i` - integer, `s` - string) and `v` refers to value.
253
+ You can fetch these flags with methods below:
254
+ ```ruby
255
+ client.get_flag("asd") # => { code: "asd", is_default: false, type: "boolean", value: true }
256
+ client.get_flag("eeeeee") # => { code: "eeeeee", is_default: false, type: "integer", value: 111 }
257
+ client.get_flag("qqq") # => { code: "qqq", is_default: false, type: "string", value: "aa" }
258
+ ```
259
+ Note that trying to call undefined flag leads to exception.
260
+
261
+ In addition to fetch existing flags, you can use fallbacks. For example:
262
+ ```ruby
263
+ client.get_flag("undefined", { default_value: true }) # => { code: "undefined", is_default: true, value: true }
264
+ ```
265
+
266
+ and with setting the type explicitly (output omitted except value):
267
+ ```ruby
268
+ client.get_flag("undefined_bool", { default_value: true }, "b") # => value = true
269
+ client.get_flag("undefined_string", { default_value: "true" }, "s") # => value = "true"
270
+ client.get_flag("undefined_int", { default_value: 111 }, "i") # => value = 111
271
+ ```
272
+ In the example above if you try to set default_value of different type (for example: `get_flag("flag", {default_value: 1}, "s")`), you'll get an exception.
273
+
274
+ Also you have wrapper methods, for example:
275
+ ```ruby
276
+ client.get_boolean_flag("eeeeee") # => leads to exception "Flag eeeeee value type is different from requested type"
277
+ client.get_boolean_flag("asd") # => true
278
+ client.get_boolean_flag("undefined", false) # => false
279
+
280
+ client.get_integer_flag("asd") # => exception "Flag asd value type is different from requested type"
281
+ client.get_integer_flag("undefined", "true") # => exception "Flag undefined value type is different from requested type"
282
+ client.get_integer_flag("eeeeee") # => 111
283
+ client.get_integer_flag("undefined", 123) # => 123
284
+
285
+ client.get_string_flag("qqq") # => "aa"
286
+ client.get_string_flag("undefined", "111") # => "111"
287
+ ```
288
+
225
289
  #### Client usage
226
290
  API part is mounted in the `KindeSdk::Client` instance, so the short usage is just simple as:
227
291
  ```ruby
@@ -293,13 +357,18 @@ Example of a returned token:
293
357
  "email",
294
358
  "offline"
295
359
  ],
296
- "sub" => "kp:123457890"
360
+ "sub" => "kp:123457890",
361
+ "feature_flags" => {
362
+ "asd" => { "t" => "b", "v" => true },
363
+ "eeeeee" => { "t" => "i", "v" => 111 },
364
+ "qqq" => { "t" => "s", "v" => "aa" }
365
+ }
297
366
  }
298
367
  ]
299
368
  ```
300
369
  The `id_token` will also contain an array of organizations that a user belongs to - this is useful if you wanted to build out an organization switcher for example:
301
370
  ```ruby
302
- client.get_claim("org_codes") # => ["org_1234", "org_5462"]
371
+ client.get_claim("org_codes", :id_token) # => {name: "org_codes", value: ["org_1234", "org_5462"]}
303
372
  ```
304
373
 
305
374
  ### API reference
@@ -309,7 +378,7 @@ Here are some selected examples of usage.
309
378
  #### Getting user info
310
379
 
311
380
  ```ruby
312
- KindeSdk.client(session[:kinde_auth]["access_token"]).oauth.get_user
381
+ KindeSdk.client(session[:kinde_auth]).oauth.get_user
313
382
  # => {id: ..., preferred_email: ..., provided_id: ..., last_name: ..., first_name: ...}
314
383
  ```
315
384
 
@@ -328,7 +397,7 @@ $redis.set("kinde_m2m_token", result["access_token"], ex: result["expires_in"].t
328
397
 
329
398
  ##### Organizations handling
330
399
  ```ruby
331
- client = KindeSdk.client($redis.get("kinde_m2m_token"))
400
+ client = KindeSdk.client({"access_token" => $redis.get("kinde_m2m_token")})
332
401
  # get organizations list:
333
402
  client.organizations.get_organizations
334
403
  # => {"code": "OK", "message": "Success", "next_token": "qweqweqwe", "organizations": [{"code": "org_casda123c", "name": "Default Organization", "is_default": true}]}
@@ -341,7 +410,22 @@ client.organizations.create_organization(create_organization_request: {name: "ne
341
410
 
342
411
  #### Create new user
343
412
  ```ruby
344
- client.users.create_user
413
+ client.users.create_user(
414
+ create_user_request: {
415
+ profile: {given_name: "AAAname", family_name: "AAAsurname"},
416
+ identities: [{type: "email", details: {email: "aaexample@asd.com"}}]
417
+ }
418
+ )
419
+ ```
420
+ Alternatively, using model instances:
421
+ ```ruby
422
+ request = KindeApi::CreateUserRequest.new(
423
+ profile: KindeApi::CreateUserRequestProfile.new(given_name: "AAAfirstname1", family_name: "AAAlastname1"),
424
+ identities: [
425
+ KindeApi::CreateUserRequestIdentitiesInner.new(type: "email", details: KindeApi::CreateUserRequestIdentitiesInnerDetails.new(email: "aaaaexample@example.com"))
426
+ ]
427
+ )
428
+ client.users.create_user(create_user_request: request)
345
429
  ```
346
430
 
347
431
  #### Add organization users
data/kinde_api/README.md CHANGED
@@ -12,16 +12,15 @@ KindeApi.configure do |config|
12
12
  config.access_token_getter = -> { 'YOUR TOKEN GETTER PROC' }
13
13
  end
14
14
 
15
- api_instance = KindeApi::ConnectedAppsApi.new
16
- key_code_ref = 'key_code_ref_example' # String | The unique key code reference of the connected app to authenticate against.
17
- user_id = 56 # Integer | The id of the user that needs to authenticate to the third-party connected app.
15
+ api_instance = KindeApi::CallbacksApi.new
16
+ app_id = 'app_id_example' # String | The identifier for the application.
17
+ urls = ['inner_example'] # Array<String> | Array of callback urls.
18
18
 
19
19
  begin
20
- #Get Connected App URL
21
- result = api_instance.get_connected_app_auth_url(key_code_ref, user_id)
22
- p result
20
+ #Add Redirect Callback URLs
21
+ api_instance.add_redirect_callback_urls(app_id, urls)
23
22
  rescue KindeApi::ApiError => e
24
- puts "Exception when calling ConnectedAppsApi->get_connected_app_auth_url: #{e}"
23
+ puts "Exception when calling CallbacksApi->add_redirect_callback_urls: #{e}"
25
24
  end
26
25
 
27
26
  ```
@@ -32,66 +31,102 @@ All URIs are relative to *https://app.kinde.com*
32
31
 
33
32
  Class | Method | HTTP request | Description
34
33
  ------------ | ------------- | ------------- | -------------
34
+ *KindeApi::CallbacksApi* | [**add_redirect_callback_urls**](docs/CallbacksApi.md#add_redirect_callback_urls) | **POST** /api/v1/applications/{app_id}/auth_redirect_urls | Add Redirect Callback URLs
35
+ *KindeApi::CallbacksApi* | [**get_callback_urls**](docs/CallbacksApi.md#get_callback_urls) | **GET** /api/v1/applications/{app_id}/auth_redirect_urls | List Callback URLs
36
+ *KindeApi::CallbacksApi* | [**replace_redirect_callback_urls**](docs/CallbacksApi.md#replace_redirect_callback_urls) | **PUT** /api/v1/applications/{app_id}/auth_redirect_urls | Replace redirect callback URLs
35
37
  *KindeApi::ConnectedAppsApi* | [**get_connected_app_auth_url**](docs/ConnectedAppsApi.md#get_connected_app_auth_url) | **GET** /api/v1/connected_apps/auth_url | Get Connected App URL
36
38
  *KindeApi::ConnectedAppsApi* | [**get_connected_app_token**](docs/ConnectedAppsApi.md#get_connected_app_token) | **GET** /api/v1/connected_apps/token | Get Connected App Token
37
39
  *KindeApi::ConnectedAppsApi* | [**revoke_connected_app_token**](docs/ConnectedAppsApi.md#revoke_connected_app_token) | **POST** /api/v1/connected_apps/revoke | Revoke Connected App Token
38
40
  *KindeApi::EnvironmentsApi* | [**delete_environement_feature_flag_override**](docs/EnvironmentsApi.md#delete_environement_feature_flag_override) | **DELETE** /api/v1/environment/feature_flags/{feature_flag_key} | Delete environment feature flag override
39
- *KindeApi::EnvironmentsApi* | [**delete_environement_feature_flag_overrides**](docs/EnvironmentsApi.md#delete_environement_feature_flag_overrides) | **DELETE** /api/v1/environment/feature_flags/ | Delete all environment feature flag overrides
41
+ *KindeApi::EnvironmentsApi* | [**delete_environement_feature_flag_overrides**](docs/EnvironmentsApi.md#delete_environement_feature_flag_overrides) | **DELETE** /api/v1/environment/feature_flags | Delete all environment feature flag overrides
42
+ *KindeApi::EnvironmentsApi* | [**get_environement_feature_flags**](docs/EnvironmentsApi.md#get_environement_feature_flags) | **GET** /api/v1/environment/feature_flags | List environment feature flags
40
43
  *KindeApi::EnvironmentsApi* | [**update_environement_feature_flag_override**](docs/EnvironmentsApi.md#update_environement_feature_flag_override) | **PATCH** /api/v1/environment/feature_flags/{feature_flag_key} | Update environment feature flag override
41
44
  *KindeApi::FeatureFlagsApi* | [**create_feature_flag**](docs/FeatureFlagsApi.md#create_feature_flag) | **POST** /api/v1/feature_flags | Create a new feature flag
42
45
  *KindeApi::FeatureFlagsApi* | [**delete_feature_flag**](docs/FeatureFlagsApi.md#delete_feature_flag) | **DELETE** /api/v1/feature_flags/{feature_flag_key} | Delete a feature flag
43
46
  *KindeApi::FeatureFlagsApi* | [**update_feature_flag**](docs/FeatureFlagsApi.md#update_feature_flag) | **PUT** /api/v1/feature_flags/{feature_flag_key} | Update a feature flag
44
47
  *KindeApi::OAuthApi* | [**get_user**](docs/OAuthApi.md#get_user) | **GET** /oauth2/user_profile | Returns the details of the currently logged in user
45
48
  *KindeApi::OAuthApi* | [**get_user_profile_v2**](docs/OAuthApi.md#get_user_profile_v2) | **GET** /oauth2/v2/user_profile | Returns the details of the currently logged in user
46
- *KindeApi::OrganizationsApi* | [**add_organization_users**](docs/OrganizationsApi.md#add_organization_users) | **POST** /api/v1/organization/users | Assign Users to an Organization
49
+ *KindeApi::OrganizationsApi* | [**add_organization_users**](docs/OrganizationsApi.md#add_organization_users) | **POST** /api/v1/organizations/{org_code}/users | Add Organization Users
47
50
  *KindeApi::OrganizationsApi* | [**create_organization**](docs/OrganizationsApi.md#create_organization) | **POST** /api/v1/organization | Create Organization
51
+ *KindeApi::OrganizationsApi* | [**create_organization_user_role**](docs/OrganizationsApi.md#create_organization_user_role) | **POST** /api/v1/organizations/{org_code}/users/{user_id}/roles | Add Organization User Role
48
52
  *KindeApi::OrganizationsApi* | [**delete_organization_feature_flag_override**](docs/OrganizationsApi.md#delete_organization_feature_flag_override) | **DELETE** /api/v1/organizations/{org_code}/feature_flags/{feature_flag_key} | Delete organization feature flag override
49
53
  *KindeApi::OrganizationsApi* | [**delete_organization_feature_flag_overrides**](docs/OrganizationsApi.md#delete_organization_feature_flag_overrides) | **DELETE** /api/v1/organizations/{org_code}/feature_flags | Delete all organization feature flag overrides
54
+ *KindeApi::OrganizationsApi* | [**delete_organization_user_role**](docs/OrganizationsApi.md#delete_organization_user_role) | **DELETE** /api/v1/organizations/{org_code}/users/{user_id}/roles/{role_id} | Delete Organization User Role
50
55
  *KindeApi::OrganizationsApi* | [**get_organization**](docs/OrganizationsApi.md#get_organization) | **GET** /api/v1/organization | Get Organization
51
- *KindeApi::OrganizationsApi* | [**get_organization_users**](docs/OrganizationsApi.md#get_organization_users) | **GET** /api/v1/organization/users | List Organization Users
56
+ *KindeApi::OrganizationsApi* | [**get_organization_feature_flags**](docs/OrganizationsApi.md#get_organization_feature_flags) | **GET** /api/v1/organizations/{org_code}/feature_flags | List organization feature flags
57
+ *KindeApi::OrganizationsApi* | [**get_organization_user_roles**](docs/OrganizationsApi.md#get_organization_user_roles) | **GET** /api/v1/organizations/{org_code}/users/{user_id}/roles | List Organization User Roles
58
+ *KindeApi::OrganizationsApi* | [**get_organization_users**](docs/OrganizationsApi.md#get_organization_users) | **GET** /api/v1/organizations/{org_code}/users | List Organization Users
52
59
  *KindeApi::OrganizationsApi* | [**get_organizations**](docs/OrganizationsApi.md#get_organizations) | **GET** /api/v1/organizations | List Organizations
53
- *KindeApi::OrganizationsApi* | [**remove_organization_users**](docs/OrganizationsApi.md#remove_organization_users) | **PATCH** /api/v1/organization/users | Remove Users from an Organization
60
+ *KindeApi::OrganizationsApi* | [**remove_organization_user**](docs/OrganizationsApi.md#remove_organization_user) | **DELETE** /api/v1/organizations/{org_code}/users/{user_id} | Remove Organization User
61
+ *KindeApi::OrganizationsApi* | [**update_organization**](docs/OrganizationsApi.md#update_organization) | **PATCH** /api/v1/organization/{org_code} | Update Organization
54
62
  *KindeApi::OrganizationsApi* | [**update_organization_feature_flag_override**](docs/OrganizationsApi.md#update_organization_feature_flag_override) | **PATCH** /api/v1/organizations/{org_code}/feature_flags/{feature_flag_key} | Update organization feature flag override
55
- *KindeApi::UsersApi* | [**add_organization_users**](docs/UsersApi.md#add_organization_users) | **POST** /api/v1/organization/users | Assign Users to an Organization
63
+ *KindeApi::OrganizationsApi* | [**update_organization_users**](docs/OrganizationsApi.md#update_organization_users) | **PATCH** /api/v1/organizations/{org_code}/users | Update organization users
64
+ *KindeApi::PermissionsApi* | [**create_permission**](docs/PermissionsApi.md#create_permission) | **POST** /api/v1/permissions | Create a new permission
65
+ *KindeApi::PermissionsApi* | [**get_permissions**](docs/PermissionsApi.md#get_permissions) | **GET** /api/v1/permissions | List Permissions
66
+ *KindeApi::PermissionsApi* | [**update_permissions**](docs/PermissionsApi.md#update_permissions) | **PATCH** /api/v1/permissions/{permission_id} | Update a permission
67
+ *KindeApi::RolesApi* | [**create_role**](docs/RolesApi.md#create_role) | **POST** /api/v1/role | Create a new role
68
+ *KindeApi::RolesApi* | [**get_roles**](docs/RolesApi.md#get_roles) | **GET** /api/v1/roles | List Roles
69
+ *KindeApi::RolesApi* | [**update_roles**](docs/RolesApi.md#update_roles) | **PATCH** /api/v1/roles/{role_id} | Update a role
70
+ *KindeApi::SubscribersApi* | [**create_subscriber**](docs/SubscribersApi.md#create_subscriber) | **POST** /api/v1/subscribers | Create a new subscriber
71
+ *KindeApi::SubscribersApi* | [**get_subscriber**](docs/SubscribersApi.md#get_subscriber) | **GET** /api/v1/subscribers/{subscriber_id} | Get Subscriber
72
+ *KindeApi::SubscribersApi* | [**get_subscribers**](docs/SubscribersApi.md#get_subscribers) | **GET** /api/v1/subscribers | List Subscribers
56
73
  *KindeApi::UsersApi* | [**create_user**](docs/UsersApi.md#create_user) | **POST** /api/v1/user | Create User
57
- *KindeApi::UsersApi* | [**deleteuser**](docs/UsersApi.md#deleteuser) | **DELETE** /api/v1/user | Delete User
58
- *KindeApi::UsersApi* | [**get_organization_users**](docs/UsersApi.md#get_organization_users) | **GET** /api/v1/organization/users | List Organization Users
74
+ *KindeApi::UsersApi* | [**delete_user**](docs/UsersApi.md#delete_user) | **DELETE** /api/v1/user | Delete User
59
75
  *KindeApi::UsersApi* | [**get_user_data**](docs/UsersApi.md#get_user_data) | **GET** /api/v1/user | Get User
60
76
  *KindeApi::UsersApi* | [**get_users**](docs/UsersApi.md#get_users) | **GET** /api/v1/users | List Users
61
- *KindeApi::UsersApi* | [**remove_organization_users**](docs/UsersApi.md#remove_organization_users) | **PATCH** /api/v1/organization/users | Remove Users from an Organization
62
77
  *KindeApi::UsersApi* | [**update_user**](docs/UsersApi.md#update_user) | **PATCH** /api/v1/user | Update User
63
78
 
64
79
 
65
80
  ## Documentation for Models
66
81
 
67
- - [KindeApi::AddOrganizationUsers200Response](docs/AddOrganizationUsers200Response.md)
68
82
  - [KindeApi::AddOrganizationUsersRequest](docs/AddOrganizationUsersRequest.md)
83
+ - [KindeApi::AddOrganizationUsersRequestUsersInner](docs/AddOrganizationUsersRequestUsersInner.md)
84
+ - [KindeApi::AddOrganizationUsersResponse](docs/AddOrganizationUsersResponse.md)
69
85
  - [KindeApi::ApiResult](docs/ApiResult.md)
86
+ - [KindeApi::Application](docs/Application.md)
70
87
  - [KindeApi::ConnectedAppsAccessToken](docs/ConnectedAppsAccessToken.md)
71
88
  - [KindeApi::ConnectedAppsAuthUrl](docs/ConnectedAppsAuthUrl.md)
72
- - [KindeApi::CreateOrganization201Response](docs/CreateOrganization201Response.md)
73
89
  - [KindeApi::CreateOrganizationRequest](docs/CreateOrganizationRequest.md)
74
- - [KindeApi::CreateUser200Response](docs/CreateUser200Response.md)
90
+ - [KindeApi::CreateOrganizationResponse](docs/CreateOrganizationResponse.md)
91
+ - [KindeApi::CreateOrganizationResponseOrganization](docs/CreateOrganizationResponseOrganization.md)
92
+ - [KindeApi::CreateOrganizationUserRoleRequest](docs/CreateOrganizationUserRoleRequest.md)
93
+ - [KindeApi::CreatePermissionRequest](docs/CreatePermissionRequest.md)
94
+ - [KindeApi::CreateRoleRequest](docs/CreateRoleRequest.md)
95
+ - [KindeApi::CreateSubscriberSuccessResponse](docs/CreateSubscriberSuccessResponse.md)
96
+ - [KindeApi::CreateSubscriberSuccessResponseSubscriber](docs/CreateSubscriberSuccessResponseSubscriber.md)
75
97
  - [KindeApi::CreateUserRequest](docs/CreateUserRequest.md)
76
98
  - [KindeApi::CreateUserRequestIdentitiesInner](docs/CreateUserRequestIdentitiesInner.md)
77
99
  - [KindeApi::CreateUserRequestIdentitiesInnerDetails](docs/CreateUserRequestIdentitiesInnerDetails.md)
78
100
  - [KindeApi::CreateUserRequestProfile](docs/CreateUserRequestProfile.md)
101
+ - [KindeApi::CreateUserResponse](docs/CreateUserResponse.md)
79
102
  - [KindeApi::Error](docs/Error.md)
80
103
  - [KindeApi::ErrorResponse](docs/ErrorResponse.md)
81
- - [KindeApi::GetOrganizationUsers200Response](docs/GetOrganizationUsers200Response.md)
82
- - [KindeApi::GetOrganizations200Response](docs/GetOrganizations200Response.md)
83
- - [KindeApi::GetUsers200Response](docs/GetUsers200Response.md)
104
+ - [KindeApi::GetApplicationsResponse](docs/GetApplicationsResponse.md)
105
+ - [KindeApi::GetEnvironmentFeatureFlagsResponse](docs/GetEnvironmentFeatureFlagsResponse.md)
106
+ - [KindeApi::GetOrganizationFeatureFlagsResponse](docs/GetOrganizationFeatureFlagsResponse.md)
107
+ - [KindeApi::GetOrganizationFeatureFlagsResponseFeatureFlagsValue](docs/GetOrganizationFeatureFlagsResponseFeatureFlagsValue.md)
108
+ - [KindeApi::GetOrganizationsResponse](docs/GetOrganizationsResponse.md)
109
+ - [KindeApi::GetOrganizationsUserRolesResponse](docs/GetOrganizationsUserRolesResponse.md)
110
+ - [KindeApi::GetOrganizationsUsersResponse](docs/GetOrganizationsUsersResponse.md)
111
+ - [KindeApi::GetRedirectCallbackUrlsResponse](docs/GetRedirectCallbackUrlsResponse.md)
84
112
  - [KindeApi::Organization](docs/Organization.md)
85
113
  - [KindeApi::OrganizationUser](docs/OrganizationUser.md)
86
- - [KindeApi::RemoveOrganizationUsers200Response](docs/RemoveOrganizationUsers200Response.md)
87
- - [KindeApi::RemoveOrganizationUsersRequest](docs/RemoveOrganizationUsersRequest.md)
114
+ - [KindeApi::OrganizationUserRole](docs/OrganizationUserRole.md)
115
+ - [KindeApi::Permissions](docs/Permissions.md)
116
+ - [KindeApi::RedirectCallbackUrls](docs/RedirectCallbackUrls.md)
117
+ - [KindeApi::Roles](docs/Roles.md)
88
118
  - [KindeApi::SuccessResponse](docs/SuccessResponse.md)
119
+ - [KindeApi::UpdateOrganizationRequest](docs/UpdateOrganizationRequest.md)
120
+ - [KindeApi::UpdateOrganizationUsersRequest](docs/UpdateOrganizationUsersRequest.md)
121
+ - [KindeApi::UpdateOrganizationUsersRequestUsersInner](docs/UpdateOrganizationUsersRequestUsersInner.md)
122
+ - [KindeApi::UpdateOrganizationUsersResponse](docs/UpdateOrganizationUsersResponse.md)
89
123
  - [KindeApi::UpdateUserRequest](docs/UpdateUserRequest.md)
90
124
  - [KindeApi::User](docs/User.md)
91
125
  - [KindeApi::UserIdentity](docs/UserIdentity.md)
92
126
  - [KindeApi::UserIdentityResult](docs/UserIdentityResult.md)
93
127
  - [KindeApi::UserProfile](docs/UserProfile.md)
94
128
  - [KindeApi::UserProfileV2](docs/UserProfileV2.md)
129
+ - [KindeApi::UsersResponse](docs/UsersResponse.md)
95
130
 
96
131
 
97
132
  ## Documentation for Authorization
@@ -4,7 +4,7 @@
4
4
 
5
5
  | Name | Type | Description | Notes |
6
6
  | ---- | ---- | ----------- | ----- |
7
- | **users** | **Array&lt;String&gt;** | List of user ids to be added to the organization. | [optional] |
7
+ | **users** | [**Array&lt;AddOrganizationUsersRequestUsersInner&gt;**](AddOrganizationUsersRequestUsersInner.md) | Users to be added to the organization. | [optional] |
8
8
 
9
9
  ## Example
10
10
 
@@ -0,0 +1,22 @@
1
+ # KindeApi::AddOrganizationUsersRequestUsersInner
2
+
3
+ ## Properties
4
+
5
+ | Name | Type | Description | Notes |
6
+ | ---- | ---- | ----------- | ----- |
7
+ | **id** | **String** | The users id. | [optional] |
8
+ | **roles** | **Array&lt;String&gt;** | Role keys to assign to the user. | [optional] |
9
+ | **permissions** | **Array&lt;String&gt;** | Permission keys to assign to the user. | [optional] |
10
+
11
+ ## Example
12
+
13
+ ```ruby
14
+ require 'kinde_api'
15
+
16
+ instance = KindeApi::AddOrganizationUsersRequestUsersInner.new(
17
+ id: null,
18
+ roles: null,
19
+ permissions: null
20
+ )
21
+ ```
22
+
@@ -1,4 +1,4 @@
1
- # KindeApi::AddOrganizationUsers200Response
1
+ # KindeApi::AddOrganizationUsersResponse
2
2
 
3
3
  ## Properties
4
4
 
@@ -13,7 +13,7 @@
13
13
  ```ruby
14
14
  require 'kinde_api'
15
15
 
16
- instance = KindeApi::AddOrganizationUsers200Response.new(
16
+ instance = KindeApi::AddOrganizationUsersResponse.new(
17
17
  code: null,
18
18
  message: null,
19
19
  users_added: null
@@ -0,0 +1,20 @@
1
+ # KindeApi::Application
2
+
3
+ ## Properties
4
+
5
+ | Name | Type | Description | Notes |
6
+ | ---- | ---- | ----------- | ----- |
7
+ | **app_id** | **String** | | [optional] |
8
+ | **name** | **String** | | [optional] |
9
+
10
+ ## Example
11
+
12
+ ```ruby
13
+ require 'kinde_api'
14
+
15
+ instance = KindeApi::Application.new(
16
+ app_id: null,
17
+ name: null
18
+ )
19
+ ```
20
+