Class: DebtManagementCenter::VBS::Request
- Inherits:
-
Object
- Object
- DebtManagementCenter::VBS::Request
- Extended by:
- Forwardable
- Includes:
- Common::Client::Concerns::Monitoring
- Defined in:
- lib/debt_management_center/vbs/request.rb
Overview
An object responsible for making HTTP calls to the VBS service that relate to DMC
Constant Summary collapse
- STATSD_KEY_PREFIX =
'api.vbs.financial_status_report.request'
Instance Attribute Summary collapse
Class Method Summary collapse
-
.build ⇒ DebtManagementCenter::VBS::Request
Builds a DebtManagementCenter::VBS::Request instance.
Instance Method Summary collapse
-
#connection ⇒ Faraday::Connection
Create a connection object that managers the attributes and the middleware stack for making our HTTP requests to VBS.
-
#headers ⇒ Hash
HTTP request headers for the VBS API.
-
#initialize ⇒ Request
constructor
A new instance of Request.
-
#mock_enabled? ⇒ Boolean
Betamocks enabled status from settings.
-
#post(path, params) ⇒ Faraday::Response
Make a HTTP POST call to the VBS service in order to submit VHA FSR.
Methods included from Common::Client::Concerns::Monitoring
#increment, #increment_failure, #increment_total, #with_monitoring
Constructor Details
#initialize ⇒ Request
Returns a new instance of Request.
34 35 36 |
# File 'lib/debt_management_center/vbs/request.rb', line 34 def initialize @settings = Settings.mcp.vbs_v2 end |
Instance Attribute Details
#host ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/debt_management_center/vbs/request.rb', line 16 class Request extend Forwardable include Common::Client::Concerns::Monitoring STATSD_KEY_PREFIX = 'api.vbs.financial_status_report.request' attr_reader :settings def_delegators :settings, :base_path, :host, :service_name, :url ## # Builds a DebtManagementCenter::VBS::Request instance # # @return [DebtManagementCenter::VBS::Request] an instance of this class def self.build new end def initialize @settings = Settings.mcp.vbs_v2 end ## # Make a HTTP POST call to the VBS service in order to submit VHA FSR # # @param path [String] # @param params [Hash] # # @return [Faraday::Response] # def post(path, params) with_monitoring do connection.post(path) do |req| req.body = params end end end ## # Create a connection object that managers the attributes # and the middleware stack for making our HTTP requests to VBS # # @return [Faraday::Connection] # def connection Faraday.new(url:, headers:) do |conn| conn.request :json conn.use :breakers conn.use Faraday::Response::RaiseError conn.response :raise_custom_error, error_prefix: service_name conn.response :json conn.response :betamocks if mock_enabled? conn.adapter Faraday.default_adapter end end ## # HTTP request headers for the VBS API # # @return [Hash] # def headers { 'Host' => host, 'Content-Type' => 'application/json', 'apiKey' => settings.api_key } end ## # Betamocks enabled status from settings # # @return [Boolean] # def mock_enabled? settings.mock || false end end |
#service_name ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/debt_management_center/vbs/request.rb', line 16 class Request extend Forwardable include Common::Client::Concerns::Monitoring STATSD_KEY_PREFIX = 'api.vbs.financial_status_report.request' attr_reader :settings def_delegators :settings, :base_path, :host, :service_name, :url ## # Builds a DebtManagementCenter::VBS::Request instance # # @return [DebtManagementCenter::VBS::Request] an instance of this class def self.build new end def initialize @settings = Settings.mcp.vbs_v2 end ## # Make a HTTP POST call to the VBS service in order to submit VHA FSR # # @param path [String] # @param params [Hash] # # @return [Faraday::Response] # def post(path, params) with_monitoring do connection.post(path) do |req| req.body = params end end end ## # Create a connection object that managers the attributes # and the middleware stack for making our HTTP requests to VBS # # @return [Faraday::Connection] # def connection Faraday.new(url:, headers:) do |conn| conn.request :json conn.use :breakers conn.use Faraday::Response::RaiseError conn.response :raise_custom_error, error_prefix: service_name conn.response :json conn.response :betamocks if mock_enabled? conn.adapter Faraday.default_adapter end end ## # HTTP request headers for the VBS API # # @return [Hash] # def headers { 'Host' => host, 'Content-Type' => 'application/json', 'apiKey' => settings.api_key } end ## # Betamocks enabled status from settings # # @return [Boolean] # def mock_enabled? settings.mock || false end end |
#settings ⇒ Config::Options
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/debt_management_center/vbs/request.rb', line 16 class Request extend Forwardable include Common::Client::Concerns::Monitoring STATSD_KEY_PREFIX = 'api.vbs.financial_status_report.request' attr_reader :settings def_delegators :settings, :base_path, :host, :service_name, :url ## # Builds a DebtManagementCenter::VBS::Request instance # # @return [DebtManagementCenter::VBS::Request] an instance of this class def self.build new end def initialize @settings = Settings.mcp.vbs_v2 end ## # Make a HTTP POST call to the VBS service in order to submit VHA FSR # # @param path [String] # @param params [Hash] # # @return [Faraday::Response] # def post(path, params) with_monitoring do connection.post(path) do |req| req.body = params end end end ## # Create a connection object that managers the attributes # and the middleware stack for making our HTTP requests to VBS # # @return [Faraday::Connection] # def connection Faraday.new(url:, headers:) do |conn| conn.request :json conn.use :breakers conn.use Faraday::Response::RaiseError conn.response :raise_custom_error, error_prefix: service_name conn.response :json conn.response :betamocks if mock_enabled? conn.adapter Faraday.default_adapter end end ## # HTTP request headers for the VBS API # # @return [Hash] # def headers { 'Host' => host, 'Content-Type' => 'application/json', 'apiKey' => settings.api_key } end ## # Betamocks enabled status from settings # # @return [Boolean] # def mock_enabled? settings.mock || false end end |
#url ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/debt_management_center/vbs/request.rb', line 16 class Request extend Forwardable include Common::Client::Concerns::Monitoring STATSD_KEY_PREFIX = 'api.vbs.financial_status_report.request' attr_reader :settings def_delegators :settings, :base_path, :host, :service_name, :url ## # Builds a DebtManagementCenter::VBS::Request instance # # @return [DebtManagementCenter::VBS::Request] an instance of this class def self.build new end def initialize @settings = Settings.mcp.vbs_v2 end ## # Make a HTTP POST call to the VBS service in order to submit VHA FSR # # @param path [String] # @param params [Hash] # # @return [Faraday::Response] # def post(path, params) with_monitoring do connection.post(path) do |req| req.body = params end end end ## # Create a connection object that managers the attributes # and the middleware stack for making our HTTP requests to VBS # # @return [Faraday::Connection] # def connection Faraday.new(url:, headers:) do |conn| conn.request :json conn.use :breakers conn.use Faraday::Response::RaiseError conn.response :raise_custom_error, error_prefix: service_name conn.response :json conn.response :betamocks if mock_enabled? conn.adapter Faraday.default_adapter end end ## # HTTP request headers for the VBS API # # @return [Hash] # def headers { 'Host' => host, 'Content-Type' => 'application/json', 'apiKey' => settings.api_key } end ## # Betamocks enabled status from settings # # @return [Boolean] # def mock_enabled? settings.mock || false end end |
Class Method Details
.build ⇒ DebtManagementCenter::VBS::Request
Builds a DebtManagementCenter::VBS::Request instance
30 31 32 |
# File 'lib/debt_management_center/vbs/request.rb', line 30 def self.build new end |
Instance Method Details
#connection ⇒ Faraday::Connection
Create a connection object that managers the attributes and the middleware stack for making our HTTP requests to VBS
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/debt_management_center/vbs/request.rb', line 60 def connection Faraday.new(url:, headers:) do |conn| conn.request :json conn.use :breakers conn.use Faraday::Response::RaiseError conn.response :raise_custom_error, error_prefix: service_name conn.response :json conn.response :betamocks if mock_enabled? conn.adapter Faraday.default_adapter end end |
#headers ⇒ Hash
HTTP request headers for the VBS API
77 78 79 80 81 82 83 |
# File 'lib/debt_management_center/vbs/request.rb', line 77 def headers { 'Host' => host, 'Content-Type' => 'application/json', 'apiKey' => settings.api_key } end |
#mock_enabled? ⇒ Boolean
Betamocks enabled status from settings
90 91 92 |
# File 'lib/debt_management_center/vbs/request.rb', line 90 def mock_enabled? settings.mock || false end |
#post(path, params) ⇒ Faraday::Response
Make a HTTP POST call to the VBS service in order to submit VHA FSR
46 47 48 49 50 51 52 |
# File 'lib/debt_management_center/vbs/request.rb', line 46 def post(path, params) with_monitoring do connection.post(path) do |req| req.body = params end end end |