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
-
#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
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
#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 |