def create_http_request(http_method, path, *arguments)
        http_method = http_method.to_sym

        if [:post, :put].include?(http_method)
          data = arguments.shift
        end

        headers = arguments.first.is_a?(Hash) ? arguments.shift : {}

        case http_method
        when :post
          request = Net::HTTP::Post.new(path,headers)
          request["Content-Length"] = 0 # Default to 0
        when :put
          request = Net::HTTP::Put.new(path,headers)
          request["Content-Length"] = 0 # Default to 0
        when :get
          request = Net::HTTP::Get.new(path,headers)
        when :delete
          request =  Net::HTTP::Delete.new(path,headers)
        else
          raise ArgumentError, "Don't know how to handle http_method: :#{http_method.to_s}"
        end
      
        # handling basic http auth
        request.basic_auth @config[:username], @config[:password]

        if data.is_a?(Hash)
          request.set_form_data(data)
        elsif data
          request.body = data.to_s
          request["Content-Length"] = request.body.length
        end

        request
      end
def create_http_request(http_method, path, *arguments)
        http_method = http_method.to_sym

        if [:post, :put].include?(http_method)
          data = arguments.shift
        end

        headers = arguments.first.is_a?(Hash) ? arguments.shift : {}

        case http_method
        when :post
          request = Net::HTTP::Post.new(path,headers)
          request["Content-Length"] = 0 # Default to 0
        when :put
          request = Net::HTTP::Put.new(path,headers)
          request["Content-Length"] = 0 # Default to 0
        when :get
          request = Net::HTTP::Get.new(path,headers)
        when :delete
          request =  Net::HTTP::Delete.new(path,headers)
        else
          raise ArgumentError, "Don't know how to handle http_method: :#{http_method.to_s}"
        end
      
        # handling basic http auth
        request.basic_auth @config[:username], @config[:password]

        if data.is_a?(Hash)
          request.set_form_data(data)
        elsif data
          request.body = data.to_s
          request["Content-Length"] = request.body.length
        end

        request
      end
snippet based on oauth gem