Class: VRE::Service
- Inherits:
-
Common::Client::Base
- Object
- Common::Client::Base
- VRE::Service
- Includes:
- Common::Client::Concerns::Monitoring
- Defined in:
- lib/vre/service.rb
Direct Known Subclasses
Instance Method Summary collapse
- #end_point ⇒ Object private
-
#get_token ⇒ Hash
Makes call to VRE and retrieves a token.
- #request_headers ⇒ Object
- #send_to_vre(payload:) ⇒ Object
Methods included from Common::Client::Concerns::Monitoring
#increment, #increment_failure, #increment_total, #with_monitoring
Methods inherited from Common::Client::Base
#config, configuration, #connection, #delete, #get, #perform, #post, #put, #raise_backend_exception, #raise_not_authenticated, #request, #sanitize_headers!, #service_name
Methods included from SentryLogging
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger, #set_sentry_metadata
Instance Method Details
#end_point ⇒ Object (private)
46 47 48 |
# File 'lib/vre/service.rb', line 46 def end_point "#{Settings.veteran_readiness_and_employment.base_url}/api/endpoints/vaGov/new_application" end |
#get_token ⇒ Hash
Makes call to VRE and retrieves a token. Token is valid for 3 minutes so we just fire this on every api call
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/vre/service.rb', line 15 def get_token with_monitoring do conn = Faraday.new( "#{Settings.veteran_readiness_and_employment.auth_endpoint}?grant_type=client_credentials", headers: { 'Authorization' => "Basic #{Settings.veteran_readiness_and_employment.credentials}" } ) request = conn.post JSON.parse(request.body)['access_token'] end end |
#request_headers ⇒ Object
38 39 40 41 42 |
# File 'lib/vre/service.rb', line 38 def request_headers { Authorization: "Bearer #{get_token}" } end |
#send_to_vre(payload:) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/vre/service.rb', line 27 def send_to_vre(payload:) with_monitoring do perform( :post, end_point, payload, request_headers ) # see lib/common/client/base.rb#L94 end end |