Class: Rx::Middleware::Response::RxParser
- Inherits:
-
Faraday::Response::Middleware
- Object
- Faraday::Response::Middleware
- Rx::Middleware::Response::RxParser
- Defined in:
- lib/rx/middleware/response/rx_parser.rb
Overview
Middleware class responsible for customizing MHV Rx response parsing
Instance Method Summary collapse
-
#on_complete(env) ⇒ Faraday::Env
Override the Faraday #on_complete method to filter body through custom #parse.
Instance Method Details
#on_complete(env) ⇒ Faraday::Env
Override the Faraday #on_complete method to filter body through custom #parse
15 16 17 18 19 20 21 22 |
# File 'lib/rx/middleware/response/rx_parser.rb', line 15 def on_complete(env) return unless env.response_headers['content-type']&.match?(/\bjson/) # If POST for prescriptions is successful message body is irrelevant # if it was not successul an exception would have already been raised return if env.method == :post env[:body] = parse(env.body) if env.body.present? end |