class Bearer::Response
Bearer::Response
encapsulates some vitals of a response that came back from the bearer proxy.
Attributes
data[RW]
The data contained by the HTTP body of the response deserialized from JSON.
http_body[RW]
The raw HTTP body of the response.
http_headers[RW]
A Hash of the HTTP headers of the response.
http_status[RW]
The integer HTTP status code of the response.
request_id[RW]
The Bearer
request ID of the response.
Public Class Methods
from_net_http(http_resp)
click to toggle source
Initializes a Bearer::Response
object from a Net::HTTP::HTTPResponse object.
# File lib/bearer/response.rb, line 70 def self.from_net_http(http_resp) resp = Bearer::Response.new begin resp.data = JSON.parse(http_resp.body, symbolize_names: true) rescue JSON::ParserError => _e resp.data = "response body is not JSON parsable" end resp.http_body = http_resp.body resp.http_headers = Headers.from_net_http(http_resp) resp.http_status = http_resp.code.to_i resp.request_id = http_resp["bearer-request-id"] resp end