Sha256: a1f5dcc2d373e19fae5767554e48f05d3318982a640f5b109b573c78b5674062

Contents?: true

Size: 492 Bytes

Versions: 20

Compression:

Stored size: 492 Bytes

Contents

module Ecoportal
  module API
    module Common
      class Response
        attr_reader :status, :body
        def initialize(response)
          @status = response.status
          @body   = JSON.parse(response.to_s) rescue nil
          response.flush
        end
        def success?
          @status.success?
        end
        def print
          puts "Status: #{@status.code}"
          puts "Body:"
          puts JSON.pretty_generate(@body)
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
ecoportal-api-0.3.3 lib/ecoportal/api/common/response.rb
ecoportal-api-0.3.1 lib/ecoportal/api/common/response.rb
ecoportal-api-0.3.0 lib/ecoportal/api/common/response.rb
ecoportal-api-0.3.0.pre1 lib/ecoportal/api/common/response.rb
ecoportal-api-0.2.2 lib/ecoportal/api/common/response.rb
ecoportal-api-0.2.1 lib/ecoportal/api/common/response.rb
ecoportal-api-0.2.0 lib/ecoportal/api/common/response.rb
ecoportal-api-0.1.12 lib/ecoportal/api/common/response.rb
ecoportal-api-0.1.11 lib/ecoportal/api/common/response.rb
ecoportal-api-0.1.10 lib/ecoportal/api/common/response.rb
ecoportal-api-0.1.9 lib/ecoportal/api/common/response.rb
ecoportal-api-0.1.8 lib/ecoportal/api/common/response.rb
ecoportal-api-0.1.7 lib/ecoportal/api/common/response.rb
ecoportal-api-0.1.6 lib/ecoportal/api/common/response.rb
ecoportal-api-0.1.5 lib/ecoportal/api/common/response.rb
ecoportal-api-0.1.4 lib/ecoportal/api/common/response.rb
ecoportal-api-0.1.3 lib/ecoportal/api/common/response.rb
ecoportal-api-0.1.2 lib/ecoportal/api/common/response.rb
ecoportal-api-0.1.1 lib/ecoportal/api/common/response.rb
ecoportal-api-0.1.0 lib/ecoportal/api/common/response.rb