Class: MDOT::Client
- Inherits:
-
Common::Client::Base
- Object
- Common::Client::Base
- MDOT::Client
- Includes:
- Common::Client::Concerns::Monitoring
- Defined in:
- lib/mdot/client.rb
Overview
Medical Devices Ordering Tool
This service integrates with the DLC API and allows veterans to reorder medical devices such as hearing aid batteries.
Constant Summary collapse
- STATSD_KEY_PREFIX =
'api.mdot'
Instance Method Summary collapse
-
#get_supplies ⇒ Faraday::Response
GETs medical supplies available for reorder for veteran.
-
#initialize(current_user) ⇒ Client
constructor
A new instance of Client.
-
#submit_order(request_body) ⇒ Faraday::Response
POSTs to DLC endpoint to create a new order.
Methods included from Common::Client::Concerns::Monitoring
Methods inherited from Common::Client::Base
Methods included from SentryLogging
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger
Constructor Details
#initialize(current_user) ⇒ Client
Returns a new instance of Client.
27 28 29 30 |
# File 'lib/mdot/client.rb', line 27 def initialize(current_user) @user = current_user @supplies = 'supplies' end |
Instance Method Details
#get_supplies ⇒ Faraday::Response
GETs medical supplies available for reorder for veteran.
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/mdot/client.rb', line 37 def get_supplies with_monitoring_and_error_handling do raw_response = perform(:get, @supplies, nil, headers) MDOT::Response.new( response: raw_response, schema: :supplies, uuid: @user.uuid ) end end |
#submit_order(request_body) ⇒ Faraday::Response
POSTs to DLC endpoint to create a new order.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/mdot/client.rb', line 54 def submit_order(request_body) request_body.deep_transform_keys! { |key| key.to_s.camelize(:lower) } if request_body['order'].blank? raise_backend_exception( MDOT::ExceptionKey.new('MDOT_supplies_not_selected'), self.class ) end with_monitoring_and_error_handling do perform(:post, @supplies, request_body, submission_headers).body end end |