Sha256: a50ba8faa2125e5efb7592c837e3aab8cbcae1fdc1fe0617762ddcd788cb7dfe

Contents?: true

Size: 937 Bytes

Versions: 1

Compression:

Stored size: 937 Bytes

Contents

module Hubscreen

  # Hubscreen::Response
  #
  # Parent Class for all Hubscreen response objects. Designed for direct access to the response either through the "raw_hash" which is the hash representation of the JSON response or the "raw_response" which is the OpenStruct representation
  #
  # By default all APIRequests will return a Response object. To disable this, set Hubscreen.configure(encapsulate_response: false)

  class Response
    attr_accessor :raw_hash, :raw_response, :status_code

    def initialize(response_json_hash)
      @raw_hash = response_json_hash
      @raw_response = RecursiveOpenStruct.new(response_json_hash)
    end

    # Prints out the raw response in formatted JSON.
    # This method is primarily used to aid in debugging
    def pretty_response
      JSON.pretty_generate(@raw_hash)
    end

    #Type Cast Helpers
    def contact
      Contact.new(self)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hubscreen-0.0.5 lib/hubscreen/response.rb