Sha256: df29194ebccae18e29fab4ee43106b31a58314aa7da5d37a0968a631334a3cfc

Contents?: true

Size: 619 Bytes

Versions: 3

Compression:

Stored size: 619 Bytes

Contents

require 'howitzer/exceptions'

module Mailgun
  # A Mailgun::Response object is instantiated for each response generated
  # by the Client request. The Response object supports deserialization of
  # the JSON result.

  class Response

    attr_accessor :body
    attr_accessor :code

    def initialize(response)
      @body = response.body
      @code = response.code
    end

    # Return response as Ruby Hash
    #
    # @return [Hash] A standard Ruby Hash containing the HTTP result.

    def to_h
      JSON.parse(@body)
    rescue Exception => e
      log.error Howitzer::ParseError, e.message
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
howitzer-1.1.1 lib/howitzer/mailgun/response.rb
howitzer-1.1.0 lib/howitzer/mailgun/response.rb
howitzer-1.0.2 lib/howitzer/mailgun/response.rb