Sha256: c156a41beac3156ba1c031358b322d47a047474ded825acce770a7e454c04ad0

Contents?: true

Size: 919 Bytes

Versions: 2

Compression:

Stored size: 919 Bytes

Contents

module EventMachine
  module Smsified

    ##
    # Functions as a proxy on the EventMachine HTTP Response so you can get the raw and parsed response
    #
    class ResponseProxy
      attr_reader :raw, :parsed

      def initialize(parsed, raw)
        @parsed = parsed
        @raw = raw
      end
    end

    ##
    # Used by em-http-request to parse the JSON coming in
    #
    class JSONify
      def response(resp)
        resp.response = ResponseProxy.new(Yajl::Parser.parse(resp.response), resp.response)
      end
    end

    ##
    # The result object from the API. Used to access the parsed and raw HTTP response.
    #
    class Response
      attr_reader :data, :http
      
      ##
      # Provides the standard response for the library
      #
      # @param [Object] an HTTParty result object
      def initialize(parsed, raw)
        @data = parsed
        @http = raw
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
em-smsified-0.3.0 lib/em-smsified/response.rb
em-smsified-0.2.0 lib/em-smsified/response.rb