Sha256: 133da45d69b07041abf131567d8715017f583bec7d1ca2cbc3b0258fb97a96ee

Contents?: true

Size: 1.13 KB

Versions: 22

Compression:

Stored size: 1.13 KB

Contents

# bandwidth
#
# This file was automatically generated by APIMATIC v2.0
# ( https://apimatic.io ).

module Bandwidth
  # Http response received.
  class ApiResponse
    attr_reader(:status_code, :reason_phrase, :headers, :raw_body, :request,
                :data, :errors)

    # 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.
    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

    # returns true if status_code is between 200-300
    def success?
      status_code >= 200 && status_code < 300
    end

    # returns true if status_code is between 400-600
    def error?
      status_code >= 400 && status_code < 600
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
bandwidth-sdk-10.5.0 lib/bandwidth/http/api_response.rb
bandwidth-sdk-10.4.0 lib/bandwidth/http/api_response.rb
bandwidth-sdk-10.3.0 lib/bandwidth/http/api_response.rb
bandwidth-sdk-10.2.0 lib/bandwidth/http/api_response.rb
bandwidth-sdk-10.1.0 lib/bandwidth/http/api_response.rb
bandwidth-sdk-10.0.0 lib/bandwidth/http/api_response.rb
bandwidth-sdk-9.4.1 lib/bandwidth/http/api_response.rb
bandwidth-sdk-9.4.0 lib/bandwidth/http/api_response.rb
bandwidth-sdk-9.3.0 lib/bandwidth/http/api_response.rb
bandwidth-sdk-9.2.0 lib/bandwidth/http/api_response.rb
bandwidth-sdk-9.1.2 lib/bandwidth/http/api_response.rb
bandwidth-sdk-9.1.1 lib/bandwidth/http/api_response.rb
bandwidth-sdk-9.1.0 lib/bandwidth/http/api_response.rb
bandwidth-sdk-9.0.0 lib/bandwidth/http/api_response.rb
bandwidth-sdk-8.0.0 lib/bandwidth/http/api_response.rb
bandwidth-sdk-7.1.0 lib/bandwidth/http/api_response.rb
bandwidth-sdk-7.0.0 lib/bandwidth/http/api_response.rb
bandwidth-sdk-6.2.0 lib/bandwidth/http/api_response.rb
bandwidth-sdk-6.1.0 lib/bandwidth/http/api_response.rb
bandwidth-sdk-6.0.0 lib/bandwidth/http/api_response.rb