Sha256: 0640568db3d3eb3568b1c4f9b08305246e59fd69288a24f70801ab7442fba408

Contents?: true

Size: 555 Bytes

Versions: 1

Compression:

Stored size: 555 Bytes

Contents

module Datacentred
  # A response from the API server.
  class Response
    attr_reader :body, :status

    # A response from the API server, initialized with A Faraday HTTP Response.
    #
    # @param [Faraday::Response] server_response A response object returned from Faraday.
    # @raise [Errors::Error] Raised if response isn't a 2xx status code.
    def initialize(server_response)
      @body = JSON.parse server_response.body rescue nil
      @status = server_response.status
      Errors.raise_unless_successful(status, @body)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
datacentred-1.1.1 lib/datacentred/response.rb