Class: RestAPIBuilder::RestClientResponseParser
- Inherits:
-
Object
- Object
- RestAPIBuilder::RestClientResponseParser
- Defined in:
- lib/rest_api_builder/rest_client_response_parser.rb
Instance Method Summary collapse
-
#initialize(logger:, parse_json:) ⇒ RestClientResponseParser
constructor
A new instance of RestClientResponseParser.
- #parse_response(response, success:) ⇒ Object
Constructor Details
#initialize(logger:, parse_json:) ⇒ RestClientResponseParser
Returns a new instance of RestClientResponseParser.
5 6 7 8 |
# File 'lib/rest_api_builder/rest_client_response_parser.rb', line 5 def initialize(logger:, parse_json:) @logger = logger @parse_json = parse_json end |
Instance Method Details
#parse_response(response, success:) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rest_api_builder/rest_client_response_parser.rb', line 10 def parse_response(response, success:) body = @parse_json ? parse_json(response.body) : response.body result = { success: success, status: response.code, body: body, headers: response.headers } maybe_log_result(result) result end |