kinde_sdk 1.6.6 → 1.7.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.
- checksums.yaml +4 -4
- data/app/controllers/kinde_sdk/auth_controller.rb +96 -13
- data/kinde_api/lib/kinde_api/api/frontend/billing_api.rb +148 -0
- data/kinde_api/lib/kinde_api/api/frontend/feature_flags_api.rb +85 -0
- data/kinde_api/lib/kinde_api/api/frontend/o_auth_api.rb +241 -0
- data/kinde_api/lib/kinde_api/api/frontend/permissions_api.rb +85 -0
- data/kinde_api/lib/kinde_api/api/frontend/properties_api.rb +85 -0
- data/kinde_api/lib/kinde_api/api/frontend/roles_api.rb +85 -0
- data/kinde_api/lib/kinde_api/api/frontend/self_serve_portal_api.rb +89 -0
- data/kinde_api/lib/kinde_api/models/frontend/error.rb +230 -0
- data/kinde_api/lib/kinde_api/models/frontend/error_response.rb +221 -0
- data/kinde_api/lib/kinde_api/models/frontend/get_entitlement_response.rb +228 -0
- data/kinde_api/lib/kinde_api/models/frontend/get_entitlement_response_data.rb +229 -0
- data/kinde_api/lib/kinde_api/models/frontend/get_entitlement_response_data_entitlement.rb +295 -0
- data/kinde_api/lib/kinde_api/models/frontend/get_entitlements_response.rb +228 -0
- data/kinde_api/lib/kinde_api/models/frontend/get_entitlements_response_data.rb +244 -0
- data/kinde_api/lib/kinde_api/models/frontend/get_entitlements_response_data_entitlements_inner.rb +294 -0
- data/kinde_api/lib/kinde_api/models/frontend/get_entitlements_response_data_plans_inner.rb +240 -0
- data/kinde_api/lib/kinde_api/models/frontend/get_entitlements_response_metadata.rb +230 -0
- data/kinde_api/lib/kinde_api/models/frontend/get_feature_flags_response.rb +219 -0
- data/kinde_api/lib/kinde_api/models/frontend/get_feature_flags_response_data.rb +222 -0
- data/kinde_api/lib/kinde_api/models/frontend/get_feature_flags_response_data_feature_flags_inner.rb +259 -0
- data/kinde_api/lib/kinde_api/models/frontend/get_feature_flags_response_data_feature_flags_inner_value.rb +108 -0
- data/kinde_api/lib/kinde_api/models/frontend/get_user_permissions_response.rb +228 -0
- data/kinde_api/lib/kinde_api/models/frontend/get_user_permissions_response_data.rb +232 -0
- data/kinde_api/lib/kinde_api/models/frontend/get_user_permissions_response_data_permissions_inner.rb +240 -0
- data/kinde_api/lib/kinde_api/models/frontend/get_user_permissions_response_metadata.rb +230 -0
- data/kinde_api/lib/kinde_api/models/frontend/get_user_properties_response.rb +228 -0
- data/kinde_api/lib/kinde_api/models/frontend/get_user_properties_response_data.rb +222 -0
- data/kinde_api/lib/kinde_api/models/frontend/get_user_properties_response_data_properties_inner.rb +249 -0
- data/kinde_api/lib/kinde_api/models/frontend/get_user_properties_response_data_properties_inner_value.rb +107 -0
- data/kinde_api/lib/kinde_api/models/frontend/get_user_properties_response_metadata.rb +230 -0
- data/kinde_api/lib/kinde_api/models/frontend/get_user_roles_response.rb +228 -0
- data/kinde_api/lib/kinde_api/models/frontend/get_user_roles_response_data.rb +232 -0
- data/kinde_api/lib/kinde_api/models/frontend/get_user_roles_response_data_roles_inner.rb +240 -0
- data/kinde_api/lib/kinde_api/models/frontend/get_user_roles_response_metadata.rb +230 -0
- data/kinde_api/lib/kinde_api/models/frontend/portal_link.rb +220 -0
- data/kinde_api/lib/kinde_api/models/frontend/token_error_response.rb +230 -0
- data/kinde_api/lib/kinde_api/models/frontend/token_introspect.rb +262 -0
- data/kinde_api/lib/kinde_api/models/frontend/user_profile_v2.rb +323 -0
- data/kinde_api/lib/kinde_api.rb +28 -0
- data/lib/kinde_sdk/client/entitlements.rb +86 -0
- data/lib/kinde_sdk/client/feature_flags.rb +246 -10
- data/lib/kinde_sdk/client/permissions.rb +197 -6
- data/lib/kinde_sdk/client/roles.rb +218 -0
- data/lib/kinde_sdk/client.rb +242 -3
- data/lib/kinde_sdk/configuration.rb +2 -0
- data/lib/kinde_sdk/errors.rb +7 -0
- data/lib/kinde_sdk/internal/frontend_client.rb +111 -0
- data/lib/kinde_sdk/version.rb +1 -1
- data/lib/kinde_sdk.rb +9 -2
- metadata +54 -12
@@ -0,0 +1,262 @@
|
|
1
|
+
=begin
|
2
|
+
#Kinde Account API
|
3
|
+
|
4
|
+
# Provides endpoints to operate on an authenticated user. ## Intro ## How to use 1. Get a user access token - this can be obtained when a user signs in via the methods you've setup in Kinde (e.g. Google, passwordless, etc). 2. Call one of the endpoints below using the user access token in the Authorization header as a Bearer token. Typically, you can use the `getToken` command in the relevant SDK.
|
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::Frontend
|
17
|
+
class TokenIntrospect
|
18
|
+
# Indicates the status of the token.
|
19
|
+
attr_accessor :active
|
20
|
+
|
21
|
+
# Array of intended token recipients.
|
22
|
+
attr_accessor :aud
|
23
|
+
|
24
|
+
# Identifier for the requesting client.
|
25
|
+
attr_accessor :client_id
|
26
|
+
|
27
|
+
# Token expiration timestamp.
|
28
|
+
attr_accessor :exp
|
29
|
+
|
30
|
+
# Token issuance timestamp.
|
31
|
+
attr_accessor :iat
|
32
|
+
|
33
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
34
|
+
def self.attribute_map
|
35
|
+
{
|
36
|
+
:'active' => :'active',
|
37
|
+
:'aud' => :'aud',
|
38
|
+
:'client_id' => :'client_id',
|
39
|
+
:'exp' => :'exp',
|
40
|
+
:'iat' => :'iat'
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
# Returns all the JSON keys this model knows about
|
45
|
+
def self.acceptable_attributes
|
46
|
+
attribute_map.values
|
47
|
+
end
|
48
|
+
|
49
|
+
# Attribute type mapping.
|
50
|
+
def self.openapi_types
|
51
|
+
{
|
52
|
+
:'active' => :'Boolean',
|
53
|
+
:'aud' => :'Array<String>',
|
54
|
+
:'client_id' => :'String',
|
55
|
+
:'exp' => :'Integer',
|
56
|
+
:'iat' => :'Integer'
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
# List of attributes with nullable: true
|
61
|
+
def self.openapi_nullable
|
62
|
+
Set.new([
|
63
|
+
])
|
64
|
+
end
|
65
|
+
|
66
|
+
# Initializes the object
|
67
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
68
|
+
def initialize(attributes = {})
|
69
|
+
if (!attributes.is_a?(Hash))
|
70
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `KindeApi::Frontend::TokenIntrospect` initialize method"
|
71
|
+
end
|
72
|
+
|
73
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
74
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
75
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
76
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `KindeApi::Frontend::TokenIntrospect`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
77
|
+
end
|
78
|
+
h[k.to_sym] = v
|
79
|
+
}
|
80
|
+
|
81
|
+
if attributes.key?(:'active')
|
82
|
+
self.active = attributes[:'active']
|
83
|
+
end
|
84
|
+
|
85
|
+
if attributes.key?(:'aud')
|
86
|
+
if (value = attributes[:'aud']).is_a?(Array)
|
87
|
+
self.aud = value
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
if attributes.key?(:'client_id')
|
92
|
+
self.client_id = attributes[:'client_id']
|
93
|
+
end
|
94
|
+
|
95
|
+
if attributes.key?(:'exp')
|
96
|
+
self.exp = attributes[:'exp']
|
97
|
+
end
|
98
|
+
|
99
|
+
if attributes.key?(:'iat')
|
100
|
+
self.iat = attributes[:'iat']
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
105
|
+
# @return Array for valid properties with the reasons
|
106
|
+
def list_invalid_properties
|
107
|
+
invalid_properties = Array.new
|
108
|
+
invalid_properties
|
109
|
+
end
|
110
|
+
|
111
|
+
# Check to see if the all the properties in the model are valid
|
112
|
+
# @return true if the model is valid
|
113
|
+
def valid?
|
114
|
+
true
|
115
|
+
end
|
116
|
+
|
117
|
+
# Checks equality by comparing each attribute.
|
118
|
+
# @param [Object] Object to be compared
|
119
|
+
def ==(o)
|
120
|
+
return true if self.equal?(o)
|
121
|
+
self.class == o.class &&
|
122
|
+
active == o.active &&
|
123
|
+
aud == o.aud &&
|
124
|
+
client_id == o.client_id &&
|
125
|
+
exp == o.exp &&
|
126
|
+
iat == o.iat
|
127
|
+
end
|
128
|
+
|
129
|
+
# @see the `==` method
|
130
|
+
# @param [Object] Object to be compared
|
131
|
+
def eql?(o)
|
132
|
+
self == o
|
133
|
+
end
|
134
|
+
|
135
|
+
# Calculates hash code according to all attributes.
|
136
|
+
# @return [Integer] Hash code
|
137
|
+
def hash
|
138
|
+
[active, aud, client_id, exp, iat].hash
|
139
|
+
end
|
140
|
+
|
141
|
+
# Builds the object from hash
|
142
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
143
|
+
# @return [Object] Returns the model itself
|
144
|
+
def self.build_from_hash(attributes)
|
145
|
+
new.build_from_hash(attributes)
|
146
|
+
end
|
147
|
+
|
148
|
+
# Builds the object from hash
|
149
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
150
|
+
# @return [Object] Returns the model itself
|
151
|
+
def build_from_hash(attributes)
|
152
|
+
return nil unless attributes.is_a?(Hash)
|
153
|
+
attributes = attributes.transform_keys(&:to_sym)
|
154
|
+
self.class.openapi_types.each_pair do |key, type|
|
155
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
156
|
+
self.send("#{key}=", nil)
|
157
|
+
elsif type =~ /\AArray<(.*)>/i
|
158
|
+
# check to ensure the input is an array given that the attribute
|
159
|
+
# is documented as an array but the input is not
|
160
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
161
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
162
|
+
end
|
163
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
164
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
self
|
169
|
+
end
|
170
|
+
|
171
|
+
# Deserializes the data based on type
|
172
|
+
# @param string type Data type
|
173
|
+
# @param string value Value to be deserialized
|
174
|
+
# @return [Object] Deserialized data
|
175
|
+
def _deserialize(type, value)
|
176
|
+
case type.to_sym
|
177
|
+
when :Time
|
178
|
+
Time.parse(value)
|
179
|
+
when :Date
|
180
|
+
Date.parse(value)
|
181
|
+
when :String
|
182
|
+
value.to_s
|
183
|
+
when :Integer
|
184
|
+
value.to_i
|
185
|
+
when :Float
|
186
|
+
value.to_f
|
187
|
+
when :Boolean
|
188
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
189
|
+
true
|
190
|
+
else
|
191
|
+
false
|
192
|
+
end
|
193
|
+
when :Object
|
194
|
+
# generic object (usually a Hash), return directly
|
195
|
+
value
|
196
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
197
|
+
inner_type = Regexp.last_match[:inner_type]
|
198
|
+
value.map { |v| _deserialize(inner_type, v) }
|
199
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
200
|
+
k_type = Regexp.last_match[:k_type]
|
201
|
+
v_type = Regexp.last_match[:v_type]
|
202
|
+
{}.tap do |hash|
|
203
|
+
value.each do |k, v|
|
204
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
205
|
+
end
|
206
|
+
end
|
207
|
+
else # model
|
208
|
+
# models (e.g. Pet) or oneOf
|
209
|
+
klass = KindeFrontendApi.const_get(type)
|
210
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
# Returns the string representation of the object
|
215
|
+
# @return [String] String presentation of the object
|
216
|
+
def to_s
|
217
|
+
to_hash.to_s
|
218
|
+
end
|
219
|
+
|
220
|
+
# to_body is an alias to to_hash (backward compatibility)
|
221
|
+
# @return [Hash] Returns the object in the form of hash
|
222
|
+
def to_body
|
223
|
+
to_hash
|
224
|
+
end
|
225
|
+
|
226
|
+
# Returns the object in the form of hash
|
227
|
+
# @return [Hash] Returns the object in the form of hash
|
228
|
+
def to_hash
|
229
|
+
hash = {}
|
230
|
+
self.class.attribute_map.each_pair do |attr, param|
|
231
|
+
value = self.send(attr)
|
232
|
+
if value.nil?
|
233
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
234
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
235
|
+
end
|
236
|
+
|
237
|
+
hash[param] = _to_hash(value)
|
238
|
+
end
|
239
|
+
hash
|
240
|
+
end
|
241
|
+
|
242
|
+
# Outputs non-array value in the form of hash
|
243
|
+
# For object, use to_hash. Otherwise, just return the value
|
244
|
+
# @param [Object] value Any valid value
|
245
|
+
# @return [Hash] Returns the value in the form of hash
|
246
|
+
def _to_hash(value)
|
247
|
+
if value.is_a?(Array)
|
248
|
+
value.compact.map { |v| _to_hash(v) }
|
249
|
+
elsif value.is_a?(Hash)
|
250
|
+
{}.tap do |hash|
|
251
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
252
|
+
end
|
253
|
+
elsif value.respond_to? :to_hash
|
254
|
+
value.to_hash
|
255
|
+
else
|
256
|
+
value
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
end
|
261
|
+
|
262
|
+
end
|
@@ -0,0 +1,323 @@
|
|
1
|
+
=begin
|
2
|
+
#Kinde Account API
|
3
|
+
|
4
|
+
# Provides endpoints to operate on an authenticated user. ## Intro ## How to use 1. Get a user access token - this can be obtained when a user signs in via the methods you've setup in Kinde (e.g. Google, passwordless, etc). 2. Call one of the endpoints below using the user access token in the Authorization header as a Bearer token. Typically, you can use the `getToken` command in the relevant SDK.
|
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::Frontend
|
17
|
+
class UserProfileV2
|
18
|
+
# Unique ID of the user in Kinde.
|
19
|
+
attr_accessor :sub
|
20
|
+
|
21
|
+
# Value of the user's ID in a third-party system when the user is imported into Kinde.
|
22
|
+
attr_accessor :provided_id
|
23
|
+
|
24
|
+
# User's first and last name separated by a space.
|
25
|
+
attr_accessor :name
|
26
|
+
|
27
|
+
# User's first name.
|
28
|
+
attr_accessor :given_name
|
29
|
+
|
30
|
+
# User's last name.
|
31
|
+
attr_accessor :family_name
|
32
|
+
|
33
|
+
# Date the user was last updated at (In Unix time).
|
34
|
+
attr_accessor :updated_at
|
35
|
+
|
36
|
+
# User's email address if available.
|
37
|
+
attr_accessor :email
|
38
|
+
|
39
|
+
# Whether the user's email address has been verified.
|
40
|
+
attr_accessor :email_verified
|
41
|
+
|
42
|
+
# URL that point's to the user's picture or avatar
|
43
|
+
attr_accessor :picture
|
44
|
+
|
45
|
+
# User's preferred username.
|
46
|
+
attr_accessor :preferred_username
|
47
|
+
|
48
|
+
# Unique ID of the user in Kinde
|
49
|
+
attr_accessor :id
|
50
|
+
|
51
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
52
|
+
def self.attribute_map
|
53
|
+
{
|
54
|
+
:'sub' => :'sub',
|
55
|
+
:'provided_id' => :'provided_id',
|
56
|
+
:'name' => :'name',
|
57
|
+
:'given_name' => :'given_name',
|
58
|
+
:'family_name' => :'family_name',
|
59
|
+
:'updated_at' => :'updated_at',
|
60
|
+
:'email' => :'email',
|
61
|
+
:'email_verified' => :'email_verified',
|
62
|
+
:'picture' => :'picture',
|
63
|
+
:'preferred_username' => :'preferred_username',
|
64
|
+
:'id' => :'id'
|
65
|
+
}
|
66
|
+
end
|
67
|
+
|
68
|
+
# Returns all the JSON keys this model knows about
|
69
|
+
def self.acceptable_attributes
|
70
|
+
attribute_map.values
|
71
|
+
end
|
72
|
+
|
73
|
+
# Attribute type mapping.
|
74
|
+
def self.openapi_types
|
75
|
+
{
|
76
|
+
:'sub' => :'String',
|
77
|
+
:'provided_id' => :'String',
|
78
|
+
:'name' => :'String',
|
79
|
+
:'given_name' => :'String',
|
80
|
+
:'family_name' => :'String',
|
81
|
+
:'updated_at' => :'Integer',
|
82
|
+
:'email' => :'String',
|
83
|
+
:'email_verified' => :'Boolean',
|
84
|
+
:'picture' => :'String',
|
85
|
+
:'preferred_username' => :'String',
|
86
|
+
:'id' => :'String'
|
87
|
+
}
|
88
|
+
end
|
89
|
+
|
90
|
+
# List of attributes with nullable: true
|
91
|
+
def self.openapi_nullable
|
92
|
+
Set.new([
|
93
|
+
:'provided_id',
|
94
|
+
:'picture',
|
95
|
+
:'preferred_username',
|
96
|
+
])
|
97
|
+
end
|
98
|
+
|
99
|
+
# Initializes the object
|
100
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
101
|
+
def initialize(attributes = {})
|
102
|
+
if (!attributes.is_a?(Hash))
|
103
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `KindeApi::Frontend::UserProfileV2` initialize method"
|
104
|
+
end
|
105
|
+
|
106
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
107
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
108
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
109
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `KindeApi::Frontend::UserProfileV2`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
110
|
+
end
|
111
|
+
h[k.to_sym] = v
|
112
|
+
}
|
113
|
+
|
114
|
+
if attributes.key?(:'sub')
|
115
|
+
self.sub = attributes[:'sub']
|
116
|
+
end
|
117
|
+
|
118
|
+
if attributes.key?(:'provided_id')
|
119
|
+
self.provided_id = attributes[:'provided_id']
|
120
|
+
end
|
121
|
+
|
122
|
+
if attributes.key?(:'name')
|
123
|
+
self.name = attributes[:'name']
|
124
|
+
end
|
125
|
+
|
126
|
+
if attributes.key?(:'given_name')
|
127
|
+
self.given_name = attributes[:'given_name']
|
128
|
+
end
|
129
|
+
|
130
|
+
if attributes.key?(:'family_name')
|
131
|
+
self.family_name = attributes[:'family_name']
|
132
|
+
end
|
133
|
+
|
134
|
+
if attributes.key?(:'updated_at')
|
135
|
+
self.updated_at = attributes[:'updated_at']
|
136
|
+
end
|
137
|
+
|
138
|
+
if attributes.key?(:'email')
|
139
|
+
self.email = attributes[:'email']
|
140
|
+
end
|
141
|
+
|
142
|
+
if attributes.key?(:'email_verified')
|
143
|
+
self.email_verified = attributes[:'email_verified']
|
144
|
+
end
|
145
|
+
|
146
|
+
if attributes.key?(:'picture')
|
147
|
+
self.picture = attributes[:'picture']
|
148
|
+
end
|
149
|
+
|
150
|
+
if attributes.key?(:'preferred_username')
|
151
|
+
self.preferred_username = attributes[:'preferred_username']
|
152
|
+
end
|
153
|
+
|
154
|
+
if attributes.key?(:'id')
|
155
|
+
self.id = attributes[:'id']
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
160
|
+
# @return Array for valid properties with the reasons
|
161
|
+
def list_invalid_properties
|
162
|
+
invalid_properties = Array.new
|
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
|
+
true
|
170
|
+
end
|
171
|
+
|
172
|
+
# Checks equality by comparing each attribute.
|
173
|
+
# @param [Object] Object to be compared
|
174
|
+
def ==(o)
|
175
|
+
return true if self.equal?(o)
|
176
|
+
self.class == o.class &&
|
177
|
+
sub == o.sub &&
|
178
|
+
provided_id == o.provided_id &&
|
179
|
+
name == o.name &&
|
180
|
+
given_name == o.given_name &&
|
181
|
+
family_name == o.family_name &&
|
182
|
+
updated_at == o.updated_at &&
|
183
|
+
email == o.email &&
|
184
|
+
email_verified == o.email_verified &&
|
185
|
+
picture == o.picture &&
|
186
|
+
preferred_username == o.preferred_username &&
|
187
|
+
id == o.id
|
188
|
+
end
|
189
|
+
|
190
|
+
# @see the `==` method
|
191
|
+
# @param [Object] Object to be compared
|
192
|
+
def eql?(o)
|
193
|
+
self == o
|
194
|
+
end
|
195
|
+
|
196
|
+
# Calculates hash code according to all attributes.
|
197
|
+
# @return [Integer] Hash code
|
198
|
+
def hash
|
199
|
+
[sub, provided_id, name, given_name, family_name, updated_at, email, email_verified, picture, preferred_username, id].hash
|
200
|
+
end
|
201
|
+
|
202
|
+
# Builds the object from hash
|
203
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
204
|
+
# @return [Object] Returns the model itself
|
205
|
+
def self.build_from_hash(attributes)
|
206
|
+
new.build_from_hash(attributes)
|
207
|
+
end
|
208
|
+
|
209
|
+
# Builds the object from hash
|
210
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
211
|
+
# @return [Object] Returns the model itself
|
212
|
+
def build_from_hash(attributes)
|
213
|
+
return nil unless attributes.is_a?(Hash)
|
214
|
+
attributes = attributes.transform_keys(&:to_sym)
|
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 = KindeFrontendApi.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
|
data/kinde_api/lib/kinde_api.rb
CHANGED
@@ -257,6 +257,34 @@ KindeApi.autoload :TimezonesApi, 'kinde_api/api/timezones_api'
|
|
257
257
|
KindeApi.autoload :UsersApi, 'kinde_api/api/users_api'
|
258
258
|
KindeApi.autoload :WebhooksApi, 'kinde_api/api/webhooks_api'
|
259
259
|
|
260
|
+
# Frontend APIs - Following PHP pattern
|
261
|
+
module KindeApi
|
262
|
+
module Frontend
|
263
|
+
# Frontend API classes
|
264
|
+
autoload :BillingApi, 'kinde_api/api/frontend/billing_api'
|
265
|
+
autoload :FeatureFlagsApi, 'kinde_api/api/frontend/feature_flags_api'
|
266
|
+
autoload :OAuthApi, 'kinde_api/api/frontend/o_auth_api'
|
267
|
+
autoload :PermissionsApi, 'kinde_api/api/frontend/permissions_api'
|
268
|
+
autoload :PropertiesApi, 'kinde_api/api/frontend/properties_api'
|
269
|
+
autoload :RolesApi, 'kinde_api/api/frontend/roles_api'
|
270
|
+
autoload :SelfServePortalApi, 'kinde_api/api/frontend/self_serve_portal_api'
|
271
|
+
|
272
|
+
# Frontend models
|
273
|
+
autoload :Error, 'kinde_api/models/frontend/error'
|
274
|
+
autoload :ErrorResponse, 'kinde_api/models/frontend/error_response'
|
275
|
+
autoload :GetEntitlementResponse, 'kinde_api/models/frontend/get_entitlement_response'
|
276
|
+
autoload :GetEntitlementsResponse, 'kinde_api/models/frontend/get_entitlements_response'
|
277
|
+
autoload :GetFeatureFlagsResponse, 'kinde_api/models/frontend/get_feature_flags_response'
|
278
|
+
autoload :GetUserPermissionsResponse, 'kinde_api/models/frontend/get_user_permissions_response'
|
279
|
+
autoload :GetUserPropertiesResponse, 'kinde_api/models/frontend/get_user_properties_response'
|
280
|
+
autoload :GetUserRolesResponse, 'kinde_api/models/frontend/get_user_roles_response'
|
281
|
+
autoload :PortalLink, 'kinde_api/models/frontend/portal_link'
|
282
|
+
autoload :TokenErrorResponse, 'kinde_api/models/frontend/token_error_response'
|
283
|
+
autoload :TokenIntrospect, 'kinde_api/models/frontend/token_introspect'
|
284
|
+
autoload :UserProfileV2, 'kinde_api/models/frontend/user_profile_v2'
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
260
288
|
module KindeApi
|
261
289
|
class << self
|
262
290
|
# Customize default settings for the SDK using block.
|
@@ -0,0 +1,86 @@
|
|
1
|
+
module KindeSdk
|
2
|
+
class Client
|
3
|
+
module Entitlements
|
4
|
+
# Get all entitlements for the authenticated user
|
5
|
+
# Matches the JavaScript SDK API: getEntitlements(options?)
|
6
|
+
#
|
7
|
+
# @param options [Hash] Options for retrieving entitlements
|
8
|
+
# @option options [Boolean] :force_api (false) If true, calls the API to get fresh entitlements,
|
9
|
+
# otherwise uses existing getAllEntitlements method
|
10
|
+
# @return [Array] Array of entitlement objects
|
11
|
+
def get_entitlements(options = {})
|
12
|
+
# Entitlements are always fetched from API (they don't exist in tokens)
|
13
|
+
# The options parameter is kept for consistency with other methods
|
14
|
+
getAllEntitlements
|
15
|
+
end
|
16
|
+
|
17
|
+
# Check if user has billing entitlements
|
18
|
+
# Matches the JavaScript SDK API: hasBillingEntitlements(params)
|
19
|
+
#
|
20
|
+
# @param billing_entitlements [Array<String>] Array of billing entitlement price names to check
|
21
|
+
# @param options [Hash] Options for retrieving entitlements
|
22
|
+
# @return [Boolean] True if user has all specified billing entitlements, false otherwise
|
23
|
+
def has_billing_entitlements?(billing_entitlements, options = {})
|
24
|
+
return true if billing_entitlements.nil? || billing_entitlements.empty?
|
25
|
+
|
26
|
+
begin
|
27
|
+
entitlements = get_entitlements(options)
|
28
|
+
billing_entitlements_array = Array(billing_entitlements)
|
29
|
+
|
30
|
+
# Extract price names from entitlements (billing entitlements use price_name)
|
31
|
+
entitlement_price_names = entitlements.map do |ent|
|
32
|
+
ent.respond_to?(:price_name) ? ent.price_name : ent['price_name']
|
33
|
+
end.compact
|
34
|
+
|
35
|
+
billing_entitlements_array.all? { |price_name| entitlement_price_names.include?(price_name) }
|
36
|
+
rescue StandardError => e
|
37
|
+
log_error("Error checking billing entitlements: #{e.message}")
|
38
|
+
false
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Check if user has feature entitlements
|
43
|
+
#
|
44
|
+
# @param entitlement_keys [Array<String>] Array of entitlement feature keys to check
|
45
|
+
# @param options [Hash] Options for retrieving entitlements
|
46
|
+
# @return [Boolean] True if user has all specified entitlements, false otherwise
|
47
|
+
def has_entitlements?(entitlement_keys, options = {})
|
48
|
+
return true if entitlement_keys.nil? || entitlement_keys.empty?
|
49
|
+
|
50
|
+
begin
|
51
|
+
entitlements = get_entitlements(options)
|
52
|
+
entitlement_keys_array = Array(entitlement_keys)
|
53
|
+
|
54
|
+
# Extract feature keys from entitlements
|
55
|
+
entitlement_feature_keys = entitlements.map do |ent|
|
56
|
+
ent.respond_to?(:feature_key) ? ent.feature_key : ent['feature_key']
|
57
|
+
end.compact
|
58
|
+
|
59
|
+
entitlement_keys_array.all? { |key| entitlement_feature_keys.include?(key) }
|
60
|
+
rescue StandardError => e
|
61
|
+
log_error("Error checking entitlements: #{e.message}")
|
62
|
+
false
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# JavaScript SDK compatible aliases
|
67
|
+
alias_method :hasBillingEntitlements, :has_billing_entitlements?
|
68
|
+
alias_method :hasEntitlements, :has_entitlements?
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
# Configurable logging that works with or without Rails
|
73
|
+
def log_error(message)
|
74
|
+
if defined?(Rails) && Rails.logger
|
75
|
+
Rails.logger.error(message)
|
76
|
+
elsif @logger
|
77
|
+
@logger.error(message)
|
78
|
+
elsif respond_to?(:logger) && logger
|
79
|
+
logger.error(message)
|
80
|
+
else
|
81
|
+
$stderr.puts "[KindeSdk] ERROR: #{message}"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|