Sha256: 9a9a08cfa7c2f2dde56fbff637bc27ec04ab8c7269446db6b3b420d4ab0f25ef

Contents?: true

Size: 621 Bytes

Versions: 1

Compression:

Stored size: 621 Bytes

Contents

require "http"

module PlayWhe
  module HTTP
    class Response
      attr_reader :response

      def initialize(response)
        @response = response
      end

      def status
        response.status
      end

      def body
        response.to_s
      end

      def ok?
        status == 200
      end
    end

    class Adapter
      attr_reader :http_client

      def initialize(http_client)
        @http_client = http_client
      end

      def post(url, data)
        Response.new http_client.post(url, form: data)
      rescue ::HTTP::Error
        raise PlayWhe::NetworkError
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
playwhe-0.2.0 lib/playwhe/http.rb