class TwitterAds::Response
Generic container for API responses.
Attributes
body[R]
code[R]
headers[R]
raw_body[R]
Public Class Methods
new(code, headers, body)
click to toggle source
Creates a new Response
object instance.
@example
response = Response.new(code, headers, body)
@param code [String] The HTTP status code. @param headers [Hash] A Hash object containing HTTP response headers. @param body [String] The response body.
@since 0.1.0
@return [Response] The Response
object instance.
# File lib/twitter-ads/http/response.rb, line 26 def initialize(code, headers, body) @code = code.to_i @headers = headers @raw_body = body # handle non-JSON responses begin @body = TwitterAds::Utils.symbolize!(MultiJson.load(body)) rescue MultiJson::ParseError @body = raw_body end self end
Public Instance Methods
error?()
click to toggle source
inspect()
click to toggle source
Returns an inspection string for the current Response
instance.
@example
response.inspect
@since 0.1.0
@return [String] The inspection string.
# File lib/twitter-ads/http/response.rb, line 49 def inspect "#<#{self.class.name}:0x#{object_id} code=\"#{@code}\" error=\"#{error?}\">" end