class Bandwidth::ApiResponse
Http response received.
Attributes
data[R]
errors[R]
headers[R]
raw_body[R]
reason_phrase[R]
request[R]
status_code[R]
Public Class Methods
new(http_response, data: nil, errors: nil)
click to toggle source
The constructor @param [HttpResponse] The original, raw response from the api. @param [Object] The data field specified for the response. @param [Array<String>] Any errors returned by the server.
# File lib/bandwidth/http/api_response.rb, line 16 def initialize(http_response, data: nil, errors: nil) @status_code = http_response.status_code @reason_phrase = http_response.reason_phrase @headers = http_response.headers @raw_body = http_response.raw_body @request = http_response.request @data = data @errors = errors end
Public Instance Methods
error?()
click to toggle source
returns true if status_code
is between 400-600
# File lib/bandwidth/http/api_response.rb, line 34 def error? status_code >= 400 && status_code < 600 end
success?()
click to toggle source
returns true if status_code
is between 200-300
# File lib/bandwidth/http/api_response.rb, line 29 def success? status_code >= 200 && status_code < 300 end