Sha256: da720e1e2a33f4444987add94d0a7fab94921ec0e8918506589e9400492df604

Contents?: true

Size: 598 Bytes

Versions: 6

Compression:

Stored size: 598 Bytes

Contents

module Expedia

  module HTTPService

    class Response

      attr_reader :status, :body, :headers

      # Creates a new Response object, which standardizes the response received From Expedia.
      def initialize(status, body, headers)
        @status = status
        @body = MultiJson.load(body) rescue ''
        @headers = headers
      end

      # Simple predicate method to check if there is any exception
      def exception?
        @headers['content-type'] != 'application/json' ||
          (@body && @body[@body.keys[0]]['EanWsError']) ? true : false
      end

    end

  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
expedia-0.0.7 lib/expedia/http_service/response.rb
expedia-0.0.6 lib/expedia/http_service/response.rb
expedia-0.0.5 lib/expedia/http_service/response.rb
expedia-0.0.4 lib/expedia/http_service/response.rb
expedia-0.0.3 lib/expedia/http_service/response.rb
expedia-0.0.2 lib/expedia/http_service/response.rb