class APIClientBuilder::Response

The default page object to be used to hold the response from the API in your response handler object. Any response object that will replace this must response to success?, and items

Attributes

body[RW]
status_code[RW]

Public Class Methods

new(body, status_code, success_range) click to toggle source

@param body [String/Array/Hash] the response body @param status_code [Integer] the response status code @param success_range [Array<Integer>] the success range of this response

# File lib/api_client_builder/response.rb, line 11
def initialize(body, status_code, success_range)
  @body = body
  @status_code = status_code
  @success_range = success_range
  @failed_reason = nil
end

Public Instance Methods

mark_failed(reason) click to toggle source

Used to mark why the response failed

# File lib/api_client_builder/response.rb, line 19
def mark_failed(reason)
  @failed_reason = reason
end
success?() click to toggle source

Defines the success conditional for a response by determining whether or not the status code of the response is within the defined success range

@return [Boolean] whether or not the response is a success

# File lib/api_client_builder/response.rb, line 28
def success?
  @failed_reason.nil? && @success_range.include?(@status_code)
end