public String prepareURL(String method, HashMap<String, String> params)
      throws IllegalArgumentException {

    String ret = Connection.baseURL + method + "?";
    boolean first = true;
    boolean illegalMethod = true;

    // Validate given method is a supported method
    for (final String s : Connection.methods) {
      if (s.equals(method)) {
        illegalMethod = false;
        break;
      }
    }
    if (illegalMethod) {
      throw new IllegalArgumentException(
          String.format("Invalid method |%s|", method));
    }

    for (final Map.Entry<String, String> entry : params.entrySet()) {
      try {
        // Skip null
        if ((entry.getValue() == null) || (entry.getKey() == null)) {
          continue;
        }
        if (entry.getValue().length() == 0) {
          continue;
        }

        if (first) {
          first = false;
        } else {
          ret += "&";
        }

        ret += String.format(
            "%s=%s",
            URLEncoder.encode(entry.getKey(), "UTF-8"),
            URLEncoder.encode(entry.getValue(), "UTF-8")
            );
      } catch (final UnsupportedEncodingException e) {
        throw new IllegalArgumentException(e);
      }
    }

    return ret;
  }