Class: Common::Client::Base

Inherits:
Object
  • Object
show all
Includes:
SentryLogging
Defined in:
lib/common/client/base.rb

Overview

Base class for creating HTTP services. Wraps the Faraday gem and is configured via by passing in a Configuration::REST or Configuration::SOAP depending on the type of service you’re connecting to. Once configured requests are made via the ‘perform` method.

Examples:

Create a service and make a GET request

class MyService < Common::Client::Base
  configuration MyConfiguration

  def get_resource
    perform(:get, '/api/v1/resource')
  end
end

service = MyService.new
response = service.get_resource

a POST request with a body, headers, and Faraday options

def post_resource(json)
  headers = { 'Content-Type' => 'application/json' }
  options = { timeout: 60 }
  response = perform(:post, '/submit', json, headers, options)
end

Direct Known Subclasses

Apps::Client, Auth::ClientCredentials::Service, BB::Client, BID::Service, BenefitsClaims::Service, BenefitsDocuments::Service, BenefitsDocuments::WorkerService, BenefitsIntakeService::Service, BenefitsReferenceData::Service, BipClaims::Service, CARMA::Client::MuleSoftClient, Caseflow::Service, CentralMail::Service, Chip::Service, DebtManagementCenter::BaseService, DecisionReview::PdfValidation::Service, DecisionReview::Service, DecisionReviewV1::Service, DirectDeposit::Client, EMIS::Service, EVSS::Service, Facilities::AccessSatisfactionClient, Facilities::AccessWaitTimeClient, Facilities::Client, Facilities::DrivetimeBands::Client, Facilities::Metadata::Client, Form1010Ezr::Service, Forms::Client, GI::Client, HCA::EnrollmentEligibility::Service, HCA::Service, IAMSSOeOAuth::Service, IHub::Service, InheritedProofing::Logingov::Service, InheritedProofing::MHV::Service::ConfigMethods, LGY::Service, Lighthouse::Facilities::Client, Lighthouse::LettersGenerator::Service, Lighthouse::VeteransHealth::Client, MAP::SecurityToken::Service, MAP::SignUp::Service, MDOT::Client, MHVAC::Client, MHVLogging::Client, MPI::Service, MailAutomation::Client, MedicalRecords::Client, OIDC::Service, Okta::DirectoryService, Okta::Service, PHRMgr::Client, PagerDuty::Service, Preneeds::Service, Rx::Client, SM::Client, Salesforce::Service, Search::Service, SearchClickTracking::Service, SearchTypeahead::Service, SignIn::Idme::Service, SignIn::Logingov::Service, SimpleFormsApiSubmission::Service, TokenValidation::V2::Client, V0::VirtualAgent::JwtToken, VAProfile::Profile::V3::Service, VAProfile::Service, VBS::Client, VEText::Service, VRE::Service, VeteranVerification::Service, VirtualRegionalOffice::Client

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SentryLogging

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

Class Method Details

.configuration(configuration = nil) ⇒ Object

Sets the configuration singleton to use



53
54
55
# File 'lib/common/client/base.rb', line 53

def self.configuration(configuration = nil)
  @configuration ||= configuration.instance
end

Instance Method Details

#raise_backend_exception(key, source, error = nil) ⇒ Object



57
58
59
60
61
62
63
64
# File 'lib/common/client/base.rb', line 57

def raise_backend_exception(key, source, error = nil)
  raise Common::Exceptions::BackendServiceException.new(
    key,
    { source: source.to_s },
    error&.status,
    error&.body
  )
end