Class: MHVLogging::Client

Inherits:
Common::Client::Base show all
Includes:
Common::Client::Concerns::MHVSessionBasedClient
Defined in:
lib/mhv_logging/client.rb

Overview

Core class responsible for MHV logging interface operations

Constant Summary

Constants included from Common::Client::Concerns::MhvLockedSessionClient

Common::Client::Concerns::MhvLockedSessionClient::LOCK_RETRY_DELAY, Common::Client::Concerns::MhvLockedSessionClient::RETRY_ATTEMPTS

Instance Attribute Summary

Attributes included from Common::Client::Concerns::MHVSessionBasedClient

#session

Attributes included from Common::Client::Concerns::MhvLockedSessionClient

#session

Instance Method Summary collapse

Methods included from Common::Client::Concerns::MHVSessionBasedClient

#auth_headers, #get_session, #get_session_tagged, #invalid?, #session_config_key, #token_headers, #user_key

Methods included from SentryLogging

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

Methods included from Common::Client::Concerns::MhvLockedSessionClient

#authenticate, #initialize, #invalid?, #lock_and_get_session, #obtain_redis_lock, #refresh_session, #release_redis_lock

Methods inherited from Common::Client::Base

#config, configuration, #delete, #get, #perform, #post, #put, #raise_backend_exception, #raise_not_authenticated, #request, #sanitize_headers!, #service_name

Instance Method Details

#auditloginFaraday::Response

Communicate to MHV, for compliance purposes, that the user has signed in

Returns:

  • (Faraday::Response)

    a Faraday response object



29
30
31
32
# File 'lib/mhv_logging/client.rb', line 29

def auditlogin
  body = { isSuccessful: true, activityDetails: 'Signed in VA.GOV' }
  perform(:post, 'activity/auditlogin', body, token_headers)
end

#auditlogoutFaraday::Response

Communicate to MHV, for compliance purposes, that the user has signed in

Returns:

  • (Faraday::Response)

    a Faraday response object



39
40
41
42
# File 'lib/mhv_logging/client.rb', line 39

def auditlogout
  body = { isSuccessful: true, activityDetails: 'Signed out VA.GOV' }
  perform(:post, 'activity/auditlogout', body, token_headers)
end

#connectionFaraday::Connection (private)

Note:

Override connection in superclass because we don’t want breakers for this client Creates a connection with middleware for mapping errors, parsing XML, and adding breakers functionality

Returns a Faraday connection instance.

Returns:

  • (Faraday::Connection)

    a Faraday connection instance



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/mhv_logging/client.rb', line 53

def connection
  @connection ||=
    Faraday.new(config.base_path, headers: config.base_request_headers, request: config.request_options) do |conn|
      conn.request :json

      # Uncomment this if you want curl command equivalent or response output to log
      # conn.request(:curl, ::Logger.new(STDOUT), :warn) unless Rails.env.production?
      # conn.response(:logger, ::Logger.new(STDOUT), bodies: true) unless Rails.env.production?

      conn.response :snakecase
      conn.response :raise_custom_error, error_prefix: 'MHV'
      conn.response :mhv_errors
      conn.response :mhv_xml_html_errors
      conn.response :json_parser
      conn.adapter Faraday.default_adapter
    end
end