コード例 #1
0
  /**
   * Use the endpoint to create a new product. Each product creation must include at least one
   * variation because each product must have at least 1 variation.
   *
   * @param product Product Object
   * @param apiKey apiKey
   * @return JSONObject
   */
  public JSONObject createProductVariationJSONObject(
      ProductVariation productVariation, String apiKey) {
    String url = PropertiesUtil.getCreateProductVariation();
    // 发起POST请求
    JSONObject jsonObject =
        CommonUtil.httpsRequest(
            url, "POST", productVariation.createProductVariationObject() + "key=" + apiKey);

    if (null != jsonObject) {
      return jsonObject;
    } else {
      return null;
    }
  }
コード例 #2
0
  /**
   * Use the endpoint to create a new product. Each product creation must include at least one
   * variation because each product must have at least 1 variation.
   *
   * @param product Product Object
   * @param apiKey apiKey
   * @return Boolean
   */
  public Boolean createProductVariationBoolean(ProductVariation productVariation, String apiKey) {
    String url = PropertiesUtil.getCreateProductVariation();
    // 发起POST请求
    JSONObject jsonObject =
        CommonUtil.httpsRequest(
            url, "POST", productVariation.createProductVariationObject() + "key=" + apiKey);

    if (null != jsonObject) {
      int code = jsonObject.getInt("code");
      if (0 == code) {
        return true;
      } else {
        return false;
      }
    } else {
      return false;
    }
  }