コード例 #1
0
  /**
   * Update inventory for a product variation.
   *
   * @param productVariation ProductVariation
   * @param apiKey apiKey
   * @return JSONObject
   */
  public JSONObject updateInventoryJSONObject(ProductVariation productVariation, String apiKey) {
    String url = PropertiesUtil.getUpdateInventory();
    // 发起POST请求
    JSONObject jsonObject =
        CommonUtil.httpsRequest(
            url, "POST", productVariation.updateInventoryObject() + "key=" + apiKey);

    if (null != jsonObject) {
      return jsonObject;
    } else {
      return null;
    }
  }
コード例 #2
0
  /**
   * Disable a product and all of its product variations. This marks the product available for sale.
   *
   * @param product Product
   * @param apiKey apiKey
   * @return JSONObject
   */
  public JSONObject disableProductVariationJSONObject(
      ProductVariation productVariation, String apiKey) {
    String url = PropertiesUtil.getDisableProductVariation();
    // 发起POST请求
    JSONObject jsonObject =
        CommonUtil.httpsRequest(
            url, "POST", productVariation.disableProductVariationObject() + "key=" + apiKey);

    if (null != jsonObject) {
      return jsonObject;
    } else {
      return null;
    }
  }
コード例 #3
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;
    }
  }