def send(method, params = [], id = nil)
      check_auth()

      json = {
        :id => id.nil? || id.is_a?(Integer) == false ? rand(999 - 100) + 100 : id,
        :jsonrpc => "2.0",
        :method => method,
        :params => params.is_a?(Array) ? params : []
      }.to_json

      uri = URI.parse(API_URL)
      http = http_or_http_proxy(uri)

      req = Net::HTTP::Post.new(uri.request_uri, @headers)
      req.basic_auth(@login, @password)
      req.add_field('User-Agent', "sdk=RUBY; sdk-version=#{SDK_VERSION}; lang-version=#{RUBY_VERSION}; platform=#{RUBY_PLATFORM}")
      req.add_field('CALLR-Login-As', @login_as) unless @login_as.to_s.empty?

      begin
        res = http.request(req, json)
        if res.code.to_i != 200
          raise CallrException.new("HTTP_CODE_ERROR", -1, {:http_code => res.code.to_i, :http_message => res.message})
        end
        return parse_response(res)
      rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Errno::ETIMEDOUT, Errno::ECONNREFUSED,
          Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
        raise CallrException.new("HTTP_EXCEPTION", -2, {:exception => e})
      end
    end
def send(method, params = [], id = nil)
      check_auth()

      json = {
        :id => id.nil? || id.is_a?(Integer) == false ? rand(999 - 100) + 100 : id,
        :jsonrpc => "2.0",
        :method => method,
        :params => params.is_a?(Array) ? params : []
      }.to_json

      uri = URI.parse(API_URL)
      http = http_or_http_proxy(uri)

      req = Net::HTTP::Post.new(uri.request_uri, @headers)
      req.basic_auth(@login, @password)
      req.add_field('User-Agent', "sdk=RUBY; sdk-version=#{SDK_VERSION}; lang-version=#{RUBY_VERSION}; platform=#{RUBY_PLATFORM}")
      req.add_field('CALLR-Login-As', @login_as) unless @login_as.to_s.empty?

      begin
        res = http.request(req, json)
        if res.code.to_i != 200
          raise CallrException.new("HTTP_CODE_ERROR", -1, {:http_code => res.code.to_i, :http_message => res.message})
        end
        return parse_response(res)
      rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Errno::ETIMEDOUT, Errno::ECONNREFUSED,
          Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
        raise CallrException.new("HTTP_EXCEPTION", -2, {:exception => e})
      end
    end
Send a request to CALLR webservice