Class: V0::VirtualAgent::JwtToken

Inherits:
Common::Client::Base show all
Defined in:
app/controllers/v0/virtual_agent/jwt_token.rb

Instance Method Summary collapse

Methods inherited from Common::Client::Base

configuration, #raise_backend_exception

Methods included from SentryLogging

#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger

Instance Method Details

#configObject



19
20
21
# File 'app/controllers/v0/virtual_agent/jwt_token.rb', line 19

def config
  VAOS::Configuration.instance
end

#new_jwt_token(user) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/v0/virtual_agent/jwt_token.rb', line 6

def new_jwt_token(user)
  url = '/users/v2/session?processRules=true'
  # get the basic unsigned JWT token
  token = VAOS::JwtWrapper.new(user).token
  # request a signed JWT token
  response = perform(:post, url, token, headers)
  # raise Common::Exceptions::BackendServiceException.new('VAOS_502', source: self.class) unless body?(response)

  Rails.logger.info('Chatbot JWT session created',
                    { account_uuid: user., jti: decoded_token(token)['jti'] })
  response.body
end