Class: IGMarkets::RequestFormatter
- Inherits:
-
Object
- Object
- IGMarkets::RequestFormatter
- Defined in:
- lib/ig_markets/request_formatter.rb
Overview
This class contains methods for formatting a REST request and its response for inspection and debugging.
Class Method Summary collapse
-
.format_request(options) ⇒ String
Formats a request options hash that is ready to be passed to ‘Excon`.
-
.format_response(response) ⇒ String
Formats a response received from ‘Excon`.
Class Method Details
.format_request(options) ⇒ String
Formats a request options hash that is ready to be passed to ‘Excon`.
12 13 14 15 16 17 18 19 |
# File 'lib/ig_markets/request_formatter.rb', line 12 def format_request() result = "#{[:method].to_s.upcase} #{[:url]}\n" result += format_request_headers [:headers] result += format_request_body [:body] result end |
.format_response(response) ⇒ String
Formats a response received from ‘Excon`.
26 27 28 29 30 31 32 33 |
# File 'lib/ig_markets/request_formatter.rb', line 26 def format_response(response) result = " Response:\n" result += format_response_headers response.headers result += format_response_body response.body result end |