Class: K2ConnectRuby::K2Entity::K2Token
- Inherits:
-
Object
- Object
- K2ConnectRuby::K2Entity::K2Token
- Defined in:
- lib/k2-connect-ruby/k2_entity/k2_token.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#token_response ⇒ Object
readonly
Returns the value of attribute token_response.
Instance Method Summary collapse
-
#initialize(client_id, client_secret) ⇒ K2Token
constructor
A new instance of K2Token.
- #introspect_token(access_token) ⇒ Object
- #request_token ⇒ Object
- #revoke_token(access_token) ⇒ Object
- #token_info(access_token) ⇒ Object
- #validate_client_credentials(client_id, client_secret) ⇒ Object
Constructor Details
#initialize(client_id, client_secret) ⇒ K2Token
Returns a new instance of K2Token.
8 9 10 11 12 |
# File 'lib/k2-connect-ruby/k2_entity/k2_token.rb', line 8 def initialize(client_id, client_secret) validate_client_credentials(client_id, client_secret) @client_id = client_id @client_secret = client_secret end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
6 7 8 |
# File 'lib/k2-connect-ruby/k2_entity/k2_token.rb', line 6 def access_token @access_token end |
#token_response ⇒ Object (readonly)
Returns the value of attribute token_response.
6 7 8 |
# File 'lib/k2-connect-ruby/k2_entity/k2_token.rb', line 6 def token_response @token_response end |
Instance Method Details
#introspect_token(access_token) ⇒ Object
26 27 28 29 30 |
# File 'lib/k2-connect-ruby/k2_entity/k2_token.rb', line 26 def introspect_token(access_token) result = K2ConnectRuby::K2Services::SendIntrospectTokenRequestService.call(@client_id, @client_secret, access_token) result.data[:response_body] end |
#request_token ⇒ Object
14 15 16 17 18 |
# File 'lib/k2-connect-ruby/k2_entity/k2_token.rb', line 14 def request_token result = K2ConnectRuby::K2Services::SendRequestTokenRequestService.call(@client_id, @client_secret) @access_token = result.data[:response_body][:access_token] end |
#revoke_token(access_token) ⇒ Object
20 21 22 23 24 |
# File 'lib/k2-connect-ruby/k2_entity/k2_token.rb', line 20 def revoke_token(access_token) result = K2ConnectRuby::K2Services::SendRevokeTokenRequestService.call(@client_id, @client_secret, access_token) true end |
#token_info(access_token) ⇒ Object
32 33 34 35 |
# File 'lib/k2-connect-ruby/k2_entity/k2_token.rb', line 32 def token_info(access_token) result = K2ConnectRuby::K2Services::SendTokenInfoRequestService.call(access_token) result.data[:response_body] end |
#validate_client_credentials(client_id, client_secret) ⇒ Object
37 38 39 |
# File 'lib/k2-connect-ruby/k2_entity/k2_token.rb', line 37 def validate_client_credentials(client_id, client_secret) raise ArgumentError, "Nil or Empty Client Id or Secret!" if client_id.blank? || client_secret.blank? end |