Sha256: 528572e12ace5659827466f6f9c158c0c2eb1f04a4de663b23a41d4600525d61

Contents?: true

Size: 604 Bytes

Versions: 1

Compression:

Stored size: 604 Bytes

Contents

require_relative 'response'

module Postmates
  module Request
    def get(path, options = {})
      request(:get, path, options)
    end

    def post(path, options = {})
      request(:post, path, options)
    end

    private

    def request(method, path, options)
      response = connection.send(method) do |request|
        case method
        when :get 
          request.url(path, options)
        when :post
          request.path = path
          request.body = options unless options.empty?
        end
      end
      raw_response ? response : Response.build(response.body)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
postmates-0.1.0 lib/postmates/request.rb