Class: Clowk::SDK::Token
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Resource
#destroy, #find, #initialize, #list, #search, #show
Class Method Details
.resource_path ⇒ Object
6
7
8
|
# File 'lib/clowk/sdk/token.rb', line 6
def self.resource_path
"tokens"
end
|
Instance Method Details
#verify(token:) ⇒ Object
10
11
12
|
# File 'lib/clowk/sdk/token.rb', line 10
def verify(token:)
client.post("#{self.class.resource_path}/verify", {token: token})
end
|
#verify_with_session(token:) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/clowk/sdk/token.rb', line 14
def verify_with_session(token:)
response = verify(token:)
unless response.success?
raise Clowk::InvalidTokenError, response.body_parsed&.dig("error") || "token verification failed"
end
data = response.body_parsed&.dig("data") || response.body_parsed
data&.deep_symbolize_keys
end
|