Sha256: 75c2bbab852e87ef7612028cb7ea71932bc590ea1d8fcbc943174b0802ffda0e

Contents?: true

Size: 810 Bytes

Versions: 9

Compression:

Stored size: 810 Bytes

Contents

require 'poms/api/drivers/net_http'
require 'poms/api/request'
require 'poms/api/auth'
require 'poms/errors'

module Poms
  module Api
    # The Client module isolates all HTTP interactions, regardless of the driver
    # module to implement the actual operations. Use the Client module to build
    # signed requests and execute them.
    #
    # @see Poms::Api::Drivers::NetHttp
    module Client
      module_function

      def execute(request)
        handle_response(Drivers::NetHttp.execute(Auth.sign(request)))
      end

      def handle_response(response)
        case response.code
        when 400..499 then raise Errors::HttpMissingError, response.code
        when 500..599 then raise Errors::HttpServerError, response.code
        else
          response
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
poms-3.0.0 lib/poms/api/client.rb
poms-2.6.0 lib/poms/api/client.rb
poms-2.5.1 lib/poms/api/client.rb
poms-2.5.0 lib/poms/api/client.rb
poms-2.4.0 lib/poms/api/client.rb
poms-2.3.1 lib/poms/api/client.rb
poms-2.3.0 lib/poms/api/client.rb
poms-2.2.1 lib/poms/api/client.rb
poms-2.2.0 lib/poms/api/client.rb