com.facebook.ads.sdk.ProductGroup Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of facebook-java-business-sdk Show documentation
Show all versions of facebook-java-business-sdk Show documentation
Facebook Business Solutions SDK for Java
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.ads.sdk;
import java.io.File;
import java.lang.reflect.Modifier;
import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.google.common.base.Function;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.SettableFuture;
import com.google.gson.JsonObject;
import com.google.gson.JsonArray;
import com.google.gson.annotations.SerializedName;
import com.google.gson.reflect.TypeToken;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import com.facebook.ads.sdk.APIException.MalformedResponseException;
/**
* This class is auto-generated.
*
* For any issues or feature requests related to this class, please let us know
* on github and we'll fix in our codegen framework. We'll not be able to accept
* pull request for this class.
*
*/
public class ProductGroup extends APINode {
@SerializedName("id")
private String mId = null;
@SerializedName("product_catalog")
private ProductCatalog mProductCatalog = null;
@SerializedName("retailer_id")
private String mRetailerId = null;
@SerializedName("variants")
private List mVariants = null;
protected static Gson gson = null;
ProductGroup() {
}
public ProductGroup(Long id, APIContext context) {
this(id.toString(), context);
}
public ProductGroup(String id, APIContext context) {
this.mId = id;
this.context = context;
}
public ProductGroup fetch() throws APIException{
ProductGroup newInstance = fetchById(this.getPrefixedId().toString(), this.context);
this.copyFrom(newInstance);
return this;
}
public static ProductGroup fetchById(Long id, APIContext context) throws APIException {
return fetchById(id.toString(), context);
}
public static ListenableFuture fetchByIdAsync(Long id, APIContext context) throws APIException {
return fetchByIdAsync(id.toString(), context);
}
public static ProductGroup fetchById(String id, APIContext context) throws APIException {
return
new APIRequestGet(id, context)
.requestAllFields()
.execute();
}
public static ListenableFuture fetchByIdAsync(String id, APIContext context) throws APIException {
return
new APIRequestGet(id, context)
.requestAllFields()
.executeAsync();
}
public static APINodeList fetchByIds(List ids, List fields, APIContext context) throws APIException {
return (APINodeList)(
new APIRequest(context, "", "/", "GET", ProductGroup.getParser())
.setParam("ids", APIRequest.joinStringList(ids))
.requestFields(fields)
.execute()
);
}
public static ListenableFuture> fetchByIdsAsync(List ids, List fields, APIContext context) throws APIException {
return
new APIRequest(context, "", "/", "GET", ProductGroup.getParser())
.setParam("ids", APIRequest.joinStringList(ids))
.requestFields(fields)
.executeAsyncBase();
}
private String getPrefixedId() {
return getId();
}
public String getId() {
return getFieldId().toString();
}
public static ProductGroup loadJSON(String json, APIContext context, String header) {
ProductGroup productGroup = getGson().fromJson(json, ProductGroup.class);
if (context.isDebug()) {
JsonParser parser = new JsonParser();
JsonElement o1 = parser.parse(json);
JsonElement o2 = parser.parse(productGroup.toString());
if (o1.getAsJsonObject().get("__fb_trace_id__") != null) {
o2.getAsJsonObject().add("__fb_trace_id__", o1.getAsJsonObject().get("__fb_trace_id__"));
}
if (!o1.equals(o2)) {
context.log("[Warning] When parsing response, object is not consistent with JSON:");
context.log("[JSON]" + o1);
context.log("[Object]" + o2);
}
}
productGroup.context = context;
productGroup.rawValue = json;
productGroup.header = header;
return productGroup;
}
public static APINodeList parseResponse(String json, APIContext context, APIRequest request, String header) throws MalformedResponseException {
APINodeList productGroups = new APINodeList(request, json, header);
JsonArray arr;
JsonObject obj;
JsonParser parser = new JsonParser();
Exception exception = null;
try{
JsonElement result = parser.parse(json);
if (result.isJsonArray()) {
// First, check if it's a pure JSON Array
arr = result.getAsJsonArray();
for (int i = 0; i < arr.size(); i++) {
productGroups.add(loadJSON(arr.get(i).getAsJsonObject().toString(), context, header));
};
return productGroups;
} else if (result.isJsonObject()) {
obj = result.getAsJsonObject();
if (obj.has("data")) {
if (obj.has("paging")) {
JsonObject paging = obj.get("paging").getAsJsonObject();
if (paging.has("cursors")) {
JsonObject cursors = paging.get("cursors").getAsJsonObject();
String before = cursors.has("before") ? cursors.get("before").getAsString() : null;
String after = cursors.has("after") ? cursors.get("after").getAsString() : null;
productGroups.setCursors(before, after);
}
String previous = paging.has("previous") ? paging.get("previous").getAsString() : null;
String next = paging.has("next") ? paging.get("next").getAsString() : null;
productGroups.setPaging(previous, next);
if (context.hasAppSecret()) {
productGroups.setAppSecret(context.getAppSecretProof());
}
}
if (obj.get("data").isJsonArray()) {
// Second, check if it's a JSON array with "data"
arr = obj.get("data").getAsJsonArray();
for (int i = 0; i < arr.size(); i++) {
productGroups.add(loadJSON(arr.get(i).getAsJsonObject().toString(), context, header));
};
} else if (obj.get("data").isJsonObject()) {
// Third, check if it's a JSON object with "data"
obj = obj.get("data").getAsJsonObject();
boolean isRedownload = false;
for (String s : new String[]{"campaigns", "adsets", "ads"}) {
if (obj.has(s)) {
isRedownload = true;
obj = obj.getAsJsonObject(s);
for (Map.Entry entry : obj.entrySet()) {
productGroups.add(loadJSON(entry.getValue().toString(), context, header));
}
break;
}
}
if (!isRedownload) {
productGroups.add(loadJSON(obj.toString(), context, header));
}
}
return productGroups;
} else if (obj.has("images")) {
// Fourth, check if it's a map of image objects
obj = obj.get("images").getAsJsonObject();
for (Map.Entry entry : obj.entrySet()) {
productGroups.add(loadJSON(entry.getValue().toString(), context, header));
}
return productGroups;
} else {
// Fifth, check if it's an array of objects indexed by id
boolean isIdIndexedArray = true;
for (Map.Entry entry : obj.entrySet()) {
String key = (String) entry.getKey();
if (key.equals("__fb_trace_id__")) {
continue;
}
JsonElement value = (JsonElement) entry.getValue();
if (
value != null &&
value.isJsonObject() &&
value.getAsJsonObject().has("id") &&
value.getAsJsonObject().get("id") != null &&
value.getAsJsonObject().get("id").getAsString().equals(key)
) {
productGroups.add(loadJSON(value.toString(), context, header));
} else {
isIdIndexedArray = false;
break;
}
}
if (isIdIndexedArray) {
return productGroups;
}
// Sixth, check if it's pure JsonObject
productGroups.clear();
productGroups.add(loadJSON(json, context, header));
return productGroups;
}
}
} catch (Exception e) {
exception = e;
}
throw new MalformedResponseException(
"Invalid response string: " + json,
exception
);
}
@Override
public APIContext getContext() {
return context;
}
@Override
public void setContext(APIContext context) {
this.context = context;
}
@Override
public String toString() {
return getGson().toJson(this);
}
public APIRequestGetProducts getProducts() {
return new APIRequestGetProducts(this.getPrefixedId().toString(), context);
}
public APIRequestCreateProduct createProduct() {
return new APIRequestCreateProduct(this.getPrefixedId().toString(), context);
}
public APIRequestDelete delete() {
return new APIRequestDelete(this.getPrefixedId().toString(), context);
}
public APIRequestGet get() {
return new APIRequestGet(this.getPrefixedId().toString(), context);
}
public APIRequestUpdate update() {
return new APIRequestUpdate(this.getPrefixedId().toString(), context);
}
public String getFieldId() {
return mId;
}
public ProductCatalog getFieldProductCatalog() {
if (mProductCatalog != null) {
mProductCatalog.context = getContext();
}
return mProductCatalog;
}
public String getFieldRetailerId() {
return mRetailerId;
}
public List getFieldVariants() {
return mVariants;
}
public static class APIRequestGetProducts extends APIRequest {
APINodeList lastResponse = null;
@Override
public APINodeList getLastResponse() {
return lastResponse;
}
public static final String[] PARAMS = {
};
public static final String[] FIELDS = {
"additional_image_cdn_urls",
"additional_image_urls",
"additional_variant_attributes",
"age_group",
"applinks",
"availability",
"brand",
"bundle_items",
"bundle_retailer_ids",
"capability_to_review_status",
"category",
"category_specific_fields",
"color",
"commerce_insights",
"condition",
"currency",
"custom_data",
"custom_label_0",
"custom_label_1",
"custom_label_2",
"custom_label_3",
"custom_label_4",
"custom_number_0",
"custom_number_1",
"custom_number_2",
"custom_number_3",
"custom_number_4",
"description",
"errors",
"expiration_date",
"fb_product_category",
"gender",
"gtin",
"id",
"image_cdn_urls",
"image_fetch_status",
"image_url",
"images",
"importer_address",
"importer_name",
"invalidation_errors",
"inventory",
"is_bundle_hero",
"manufacturer_info",
"manufacturer_part_number",
"marked_for_product_launch",
"material",
"mobile_link",
"name",
"ordering_index",
"origin_country",
"parent_product_id",
"pattern",
"post_conversion_signal_based_enforcement_appeal_eligibility",
"price",
"product_catalog",
"product_feed",
"product_group",
"product_local_info",
"product_type",
"quantity_to_sell_on_facebook",
"retailer_id",
"retailer_product_group_id",
"review_rejection_reasons",
"review_status",
"sale_price",
"sale_price_end_date",
"sale_price_start_date",
"shipping_weight_unit",
"shipping_weight_value",
"short_description",
"size",
"start_date",
"tags",
"url",
"video_fetch_status",
"visibility",
"wa_compliance_category",
};
@Override
public APINodeList parseResponse(String response, String header) throws APIException {
return ProductItem.parseResponse(response, getContext(), this, header);
}
@Override
public APINodeList execute() throws APIException {
return execute(new HashMap());
}
@Override
public APINodeList execute(Map extraParams) throws APIException {
ResponseWrapper rw = executeInternal(extraParams);
lastResponse = parseResponse(rw.getBody(),rw.getHeader());
return lastResponse;
}
public ListenableFuture> executeAsync() throws APIException {
return executeAsync(new HashMap());
};
public ListenableFuture> executeAsync(Map extraParams) throws APIException {
return Futures.transform(
executeAsyncInternal(extraParams),
new Function>() {
public APINodeList apply(ResponseWrapper result) {
try {
return APIRequestGetProducts.this.parseResponse(result.getBody(), result.getHeader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
},
MoreExecutors.directExecutor()
);
};
public APIRequestGetProducts(String nodeId, APIContext context) {
super(context, nodeId, "/products", "GET", Arrays.asList(PARAMS));
}
@Override
public APIRequestGetProducts setParam(String param, Object value) {
setParamInternal(param, value);
return this;
}
@Override
public APIRequestGetProducts setParams(Map params) {
setParamsInternal(params);
return this;
}
public APIRequestGetProducts requestAllFields () {
return this.requestAllFields(true);
}
public APIRequestGetProducts requestAllFields (boolean value) {
for (String field : FIELDS) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGetProducts requestFields (List fields) {
return this.requestFields(fields, true);
}
@Override
public APIRequestGetProducts requestFields (List fields, boolean value) {
for (String field : fields) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGetProducts requestField (String field) {
this.requestField(field, true);
return this;
}
@Override
public APIRequestGetProducts requestField (String field, boolean value) {
this.requestFieldInternal(field, value);
return this;
}
public APIRequestGetProducts requestAdditionalImageCdnUrlsField () {
return this.requestAdditionalImageCdnUrlsField(true);
}
public APIRequestGetProducts requestAdditionalImageCdnUrlsField (boolean value) {
this.requestField("additional_image_cdn_urls", value);
return this;
}
public APIRequestGetProducts requestAdditionalImageUrlsField () {
return this.requestAdditionalImageUrlsField(true);
}
public APIRequestGetProducts requestAdditionalImageUrlsField (boolean value) {
this.requestField("additional_image_urls", value);
return this;
}
public APIRequestGetProducts requestAdditionalVariantAttributesField () {
return this.requestAdditionalVariantAttributesField(true);
}
public APIRequestGetProducts requestAdditionalVariantAttributesField (boolean value) {
this.requestField("additional_variant_attributes", value);
return this;
}
public APIRequestGetProducts requestAgeGroupField () {
return this.requestAgeGroupField(true);
}
public APIRequestGetProducts requestAgeGroupField (boolean value) {
this.requestField("age_group", value);
return this;
}
public APIRequestGetProducts requestApplinksField () {
return this.requestApplinksField(true);
}
public APIRequestGetProducts requestApplinksField (boolean value) {
this.requestField("applinks", value);
return this;
}
public APIRequestGetProducts requestAvailabilityField () {
return this.requestAvailabilityField(true);
}
public APIRequestGetProducts requestAvailabilityField (boolean value) {
this.requestField("availability", value);
return this;
}
public APIRequestGetProducts requestBrandField () {
return this.requestBrandField(true);
}
public APIRequestGetProducts requestBrandField (boolean value) {
this.requestField("brand", value);
return this;
}
public APIRequestGetProducts requestBundleItemsField () {
return this.requestBundleItemsField(true);
}
public APIRequestGetProducts requestBundleItemsField (boolean value) {
this.requestField("bundle_items", value);
return this;
}
public APIRequestGetProducts requestBundleRetailerIdsField () {
return this.requestBundleRetailerIdsField(true);
}
public APIRequestGetProducts requestBundleRetailerIdsField (boolean value) {
this.requestField("bundle_retailer_ids", value);
return this;
}
public APIRequestGetProducts requestCapabilityToReviewStatusField () {
return this.requestCapabilityToReviewStatusField(true);
}
public APIRequestGetProducts requestCapabilityToReviewStatusField (boolean value) {
this.requestField("capability_to_review_status", value);
return this;
}
public APIRequestGetProducts requestCategoryField () {
return this.requestCategoryField(true);
}
public APIRequestGetProducts requestCategoryField (boolean value) {
this.requestField("category", value);
return this;
}
public APIRequestGetProducts requestCategorySpecificFieldsField () {
return this.requestCategorySpecificFieldsField(true);
}
public APIRequestGetProducts requestCategorySpecificFieldsField (boolean value) {
this.requestField("category_specific_fields", value);
return this;
}
public APIRequestGetProducts requestColorField () {
return this.requestColorField(true);
}
public APIRequestGetProducts requestColorField (boolean value) {
this.requestField("color", value);
return this;
}
public APIRequestGetProducts requestCommerceInsightsField () {
return this.requestCommerceInsightsField(true);
}
public APIRequestGetProducts requestCommerceInsightsField (boolean value) {
this.requestField("commerce_insights", value);
return this;
}
public APIRequestGetProducts requestConditionField () {
return this.requestConditionField(true);
}
public APIRequestGetProducts requestConditionField (boolean value) {
this.requestField("condition", value);
return this;
}
public APIRequestGetProducts requestCurrencyField () {
return this.requestCurrencyField(true);
}
public APIRequestGetProducts requestCurrencyField (boolean value) {
this.requestField("currency", value);
return this;
}
public APIRequestGetProducts requestCustomDataField () {
return this.requestCustomDataField(true);
}
public APIRequestGetProducts requestCustomDataField (boolean value) {
this.requestField("custom_data", value);
return this;
}
public APIRequestGetProducts requestCustomLabel0Field () {
return this.requestCustomLabel0Field(true);
}
public APIRequestGetProducts requestCustomLabel0Field (boolean value) {
this.requestField("custom_label_0", value);
return this;
}
public APIRequestGetProducts requestCustomLabel1Field () {
return this.requestCustomLabel1Field(true);
}
public APIRequestGetProducts requestCustomLabel1Field (boolean value) {
this.requestField("custom_label_1", value);
return this;
}
public APIRequestGetProducts requestCustomLabel2Field () {
return this.requestCustomLabel2Field(true);
}
public APIRequestGetProducts requestCustomLabel2Field (boolean value) {
this.requestField("custom_label_2", value);
return this;
}
public APIRequestGetProducts requestCustomLabel3Field () {
return this.requestCustomLabel3Field(true);
}
public APIRequestGetProducts requestCustomLabel3Field (boolean value) {
this.requestField("custom_label_3", value);
return this;
}
public APIRequestGetProducts requestCustomLabel4Field () {
return this.requestCustomLabel4Field(true);
}
public APIRequestGetProducts requestCustomLabel4Field (boolean value) {
this.requestField("custom_label_4", value);
return this;
}
public APIRequestGetProducts requestCustomNumber0Field () {
return this.requestCustomNumber0Field(true);
}
public APIRequestGetProducts requestCustomNumber0Field (boolean value) {
this.requestField("custom_number_0", value);
return this;
}
public APIRequestGetProducts requestCustomNumber1Field () {
return this.requestCustomNumber1Field(true);
}
public APIRequestGetProducts requestCustomNumber1Field (boolean value) {
this.requestField("custom_number_1", value);
return this;
}
public APIRequestGetProducts requestCustomNumber2Field () {
return this.requestCustomNumber2Field(true);
}
public APIRequestGetProducts requestCustomNumber2Field (boolean value) {
this.requestField("custom_number_2", value);
return this;
}
public APIRequestGetProducts requestCustomNumber3Field () {
return this.requestCustomNumber3Field(true);
}
public APIRequestGetProducts requestCustomNumber3Field (boolean value) {
this.requestField("custom_number_3", value);
return this;
}
public APIRequestGetProducts requestCustomNumber4Field () {
return this.requestCustomNumber4Field(true);
}
public APIRequestGetProducts requestCustomNumber4Field (boolean value) {
this.requestField("custom_number_4", value);
return this;
}
public APIRequestGetProducts requestDescriptionField () {
return this.requestDescriptionField(true);
}
public APIRequestGetProducts requestDescriptionField (boolean value) {
this.requestField("description", value);
return this;
}
public APIRequestGetProducts requestErrorsField () {
return this.requestErrorsField(true);
}
public APIRequestGetProducts requestErrorsField (boolean value) {
this.requestField("errors", value);
return this;
}
public APIRequestGetProducts requestExpirationDateField () {
return this.requestExpirationDateField(true);
}
public APIRequestGetProducts requestExpirationDateField (boolean value) {
this.requestField("expiration_date", value);
return this;
}
public APIRequestGetProducts requestFbProductCategoryField () {
return this.requestFbProductCategoryField(true);
}
public APIRequestGetProducts requestFbProductCategoryField (boolean value) {
this.requestField("fb_product_category", value);
return this;
}
public APIRequestGetProducts requestGenderField () {
return this.requestGenderField(true);
}
public APIRequestGetProducts requestGenderField (boolean value) {
this.requestField("gender", value);
return this;
}
public APIRequestGetProducts requestGtinField () {
return this.requestGtinField(true);
}
public APIRequestGetProducts requestGtinField (boolean value) {
this.requestField("gtin", value);
return this;
}
public APIRequestGetProducts requestIdField () {
return this.requestIdField(true);
}
public APIRequestGetProducts requestIdField (boolean value) {
this.requestField("id", value);
return this;
}
public APIRequestGetProducts requestImageCdnUrlsField () {
return this.requestImageCdnUrlsField(true);
}
public APIRequestGetProducts requestImageCdnUrlsField (boolean value) {
this.requestField("image_cdn_urls", value);
return this;
}
public APIRequestGetProducts requestImageFetchStatusField () {
return this.requestImageFetchStatusField(true);
}
public APIRequestGetProducts requestImageFetchStatusField (boolean value) {
this.requestField("image_fetch_status", value);
return this;
}
public APIRequestGetProducts requestImageUrlField () {
return this.requestImageUrlField(true);
}
public APIRequestGetProducts requestImageUrlField (boolean value) {
this.requestField("image_url", value);
return this;
}
public APIRequestGetProducts requestImagesField () {
return this.requestImagesField(true);
}
public APIRequestGetProducts requestImagesField (boolean value) {
this.requestField("images", value);
return this;
}
public APIRequestGetProducts requestImporterAddressField () {
return this.requestImporterAddressField(true);
}
public APIRequestGetProducts requestImporterAddressField (boolean value) {
this.requestField("importer_address", value);
return this;
}
public APIRequestGetProducts requestImporterNameField () {
return this.requestImporterNameField(true);
}
public APIRequestGetProducts requestImporterNameField (boolean value) {
this.requestField("importer_name", value);
return this;
}
public APIRequestGetProducts requestInvalidationErrorsField () {
return this.requestInvalidationErrorsField(true);
}
public APIRequestGetProducts requestInvalidationErrorsField (boolean value) {
this.requestField("invalidation_errors", value);
return this;
}
public APIRequestGetProducts requestInventoryField () {
return this.requestInventoryField(true);
}
public APIRequestGetProducts requestInventoryField (boolean value) {
this.requestField("inventory", value);
return this;
}
public APIRequestGetProducts requestIsBundleHeroField () {
return this.requestIsBundleHeroField(true);
}
public APIRequestGetProducts requestIsBundleHeroField (boolean value) {
this.requestField("is_bundle_hero", value);
return this;
}
public APIRequestGetProducts requestManufacturerInfoField () {
return this.requestManufacturerInfoField(true);
}
public APIRequestGetProducts requestManufacturerInfoField (boolean value) {
this.requestField("manufacturer_info", value);
return this;
}
public APIRequestGetProducts requestManufacturerPartNumberField () {
return this.requestManufacturerPartNumberField(true);
}
public APIRequestGetProducts requestManufacturerPartNumberField (boolean value) {
this.requestField("manufacturer_part_number", value);
return this;
}
public APIRequestGetProducts requestMarkedForProductLaunchField () {
return this.requestMarkedForProductLaunchField(true);
}
public APIRequestGetProducts requestMarkedForProductLaunchField (boolean value) {
this.requestField("marked_for_product_launch", value);
return this;
}
public APIRequestGetProducts requestMaterialField () {
return this.requestMaterialField(true);
}
public APIRequestGetProducts requestMaterialField (boolean value) {
this.requestField("material", value);
return this;
}
public APIRequestGetProducts requestMobileLinkField () {
return this.requestMobileLinkField(true);
}
public APIRequestGetProducts requestMobileLinkField (boolean value) {
this.requestField("mobile_link", value);
return this;
}
public APIRequestGetProducts requestNameField () {
return this.requestNameField(true);
}
public APIRequestGetProducts requestNameField (boolean value) {
this.requestField("name", value);
return this;
}
public APIRequestGetProducts requestOrderingIndexField () {
return this.requestOrderingIndexField(true);
}
public APIRequestGetProducts requestOrderingIndexField (boolean value) {
this.requestField("ordering_index", value);
return this;
}
public APIRequestGetProducts requestOriginCountryField () {
return this.requestOriginCountryField(true);
}
public APIRequestGetProducts requestOriginCountryField (boolean value) {
this.requestField("origin_country", value);
return this;
}
public APIRequestGetProducts requestParentProductIdField () {
return this.requestParentProductIdField(true);
}
public APIRequestGetProducts requestParentProductIdField (boolean value) {
this.requestField("parent_product_id", value);
return this;
}
public APIRequestGetProducts requestPatternField () {
return this.requestPatternField(true);
}
public APIRequestGetProducts requestPatternField (boolean value) {
this.requestField("pattern", value);
return this;
}
public APIRequestGetProducts requestPostConversionSignalBasedEnforcementAppealEligibilityField () {
return this.requestPostConversionSignalBasedEnforcementAppealEligibilityField(true);
}
public APIRequestGetProducts requestPostConversionSignalBasedEnforcementAppealEligibilityField (boolean value) {
this.requestField("post_conversion_signal_based_enforcement_appeal_eligibility", value);
return this;
}
public APIRequestGetProducts requestPriceField () {
return this.requestPriceField(true);
}
public APIRequestGetProducts requestPriceField (boolean value) {
this.requestField("price", value);
return this;
}
public APIRequestGetProducts requestProductCatalogField () {
return this.requestProductCatalogField(true);
}
public APIRequestGetProducts requestProductCatalogField (boolean value) {
this.requestField("product_catalog", value);
return this;
}
public APIRequestGetProducts requestProductFeedField () {
return this.requestProductFeedField(true);
}
public APIRequestGetProducts requestProductFeedField (boolean value) {
this.requestField("product_feed", value);
return this;
}
public APIRequestGetProducts requestProductGroupField () {
return this.requestProductGroupField(true);
}
public APIRequestGetProducts requestProductGroupField (boolean value) {
this.requestField("product_group", value);
return this;
}
public APIRequestGetProducts requestProductLocalInfoField () {
return this.requestProductLocalInfoField(true);
}
public APIRequestGetProducts requestProductLocalInfoField (boolean value) {
this.requestField("product_local_info", value);
return this;
}
public APIRequestGetProducts requestProductTypeField () {
return this.requestProductTypeField(true);
}
public APIRequestGetProducts requestProductTypeField (boolean value) {
this.requestField("product_type", value);
return this;
}
public APIRequestGetProducts requestQuantityToSellOnFacebookField () {
return this.requestQuantityToSellOnFacebookField(true);
}
public APIRequestGetProducts requestQuantityToSellOnFacebookField (boolean value) {
this.requestField("quantity_to_sell_on_facebook", value);
return this;
}
public APIRequestGetProducts requestRetailerIdField () {
return this.requestRetailerIdField(true);
}
public APIRequestGetProducts requestRetailerIdField (boolean value) {
this.requestField("retailer_id", value);
return this;
}
public APIRequestGetProducts requestRetailerProductGroupIdField () {
return this.requestRetailerProductGroupIdField(true);
}
public APIRequestGetProducts requestRetailerProductGroupIdField (boolean value) {
this.requestField("retailer_product_group_id", value);
return this;
}
public APIRequestGetProducts requestReviewRejectionReasonsField () {
return this.requestReviewRejectionReasonsField(true);
}
public APIRequestGetProducts requestReviewRejectionReasonsField (boolean value) {
this.requestField("review_rejection_reasons", value);
return this;
}
public APIRequestGetProducts requestReviewStatusField () {
return this.requestReviewStatusField(true);
}
public APIRequestGetProducts requestReviewStatusField (boolean value) {
this.requestField("review_status", value);
return this;
}
public APIRequestGetProducts requestSalePriceField () {
return this.requestSalePriceField(true);
}
public APIRequestGetProducts requestSalePriceField (boolean value) {
this.requestField("sale_price", value);
return this;
}
public APIRequestGetProducts requestSalePriceEndDateField () {
return this.requestSalePriceEndDateField(true);
}
public APIRequestGetProducts requestSalePriceEndDateField (boolean value) {
this.requestField("sale_price_end_date", value);
return this;
}
public APIRequestGetProducts requestSalePriceStartDateField () {
return this.requestSalePriceStartDateField(true);
}
public APIRequestGetProducts requestSalePriceStartDateField (boolean value) {
this.requestField("sale_price_start_date", value);
return this;
}
public APIRequestGetProducts requestShippingWeightUnitField () {
return this.requestShippingWeightUnitField(true);
}
public APIRequestGetProducts requestShippingWeightUnitField (boolean value) {
this.requestField("shipping_weight_unit", value);
return this;
}
public APIRequestGetProducts requestShippingWeightValueField () {
return this.requestShippingWeightValueField(true);
}
public APIRequestGetProducts requestShippingWeightValueField (boolean value) {
this.requestField("shipping_weight_value", value);
return this;
}
public APIRequestGetProducts requestShortDescriptionField () {
return this.requestShortDescriptionField(true);
}
public APIRequestGetProducts requestShortDescriptionField (boolean value) {
this.requestField("short_description", value);
return this;
}
public APIRequestGetProducts requestSizeField () {
return this.requestSizeField(true);
}
public APIRequestGetProducts requestSizeField (boolean value) {
this.requestField("size", value);
return this;
}
public APIRequestGetProducts requestStartDateField () {
return this.requestStartDateField(true);
}
public APIRequestGetProducts requestStartDateField (boolean value) {
this.requestField("start_date", value);
return this;
}
public APIRequestGetProducts requestTagsField () {
return this.requestTagsField(true);
}
public APIRequestGetProducts requestTagsField (boolean value) {
this.requestField("tags", value);
return this;
}
public APIRequestGetProducts requestUrlField () {
return this.requestUrlField(true);
}
public APIRequestGetProducts requestUrlField (boolean value) {
this.requestField("url", value);
return this;
}
public APIRequestGetProducts requestVideoFetchStatusField () {
return this.requestVideoFetchStatusField(true);
}
public APIRequestGetProducts requestVideoFetchStatusField (boolean value) {
this.requestField("video_fetch_status", value);
return this;
}
public APIRequestGetProducts requestVisibilityField () {
return this.requestVisibilityField(true);
}
public APIRequestGetProducts requestVisibilityField (boolean value) {
this.requestField("visibility", value);
return this;
}
public APIRequestGetProducts requestWaComplianceCategoryField () {
return this.requestWaComplianceCategoryField(true);
}
public APIRequestGetProducts requestWaComplianceCategoryField (boolean value) {
this.requestField("wa_compliance_category", value);
return this;
}
}
public static class APIRequestCreateProduct extends APIRequest {
ProductItem lastResponse = null;
@Override
public ProductItem getLastResponse() {
return lastResponse;
}
public static final String[] PARAMS = {
"additional_image_urls",
"additional_variant_attributes",
"android_app_name",
"android_class",
"android_package",
"android_url",
"availability",
"brand",
"category",
"checkout_url",
"color",
"commerce_tax_category",
"condition",
"currency",
"custom_data",
"custom_label_0",
"custom_label_1",
"custom_label_2",
"custom_label_3",
"custom_label_4",
"custom_number_0",
"custom_number_1",
"custom_number_2",
"custom_number_3",
"custom_number_4",
"description",
"expiration_date",
"fb_product_category",
"gender",
"gtin",
"image_url",
"inventory",
"ios_app_name",
"ios_app_store_id",
"ios_url",
"ipad_app_name",
"ipad_app_store_id",
"ipad_url",
"iphone_app_name",
"iphone_app_store_id",
"iphone_url",
"launch_date",
"manufacturer_part_number",
"marked_for_product_launch",
"material",
"mobile_link",
"name",
"ordering_index",
"pattern",
"price",
"product_priority_0",
"product_priority_1",
"product_priority_2",
"product_priority_3",
"product_priority_4",
"product_type",
"quantity_to_sell_on_facebook",
"retailer_id",
"return_policy_days",
"sale_price",
"sale_price_end_date",
"sale_price_start_date",
"short_description",
"size",
"start_date",
"url",
"visibility",
"windows_phone_app_id",
"windows_phone_app_name",
"windows_phone_url",
};
public static final String[] FIELDS = {
};
@Override
public ProductItem parseResponse(String response, String header) throws APIException {
return ProductItem.parseResponse(response, getContext(), this, header).head();
}
@Override
public ProductItem execute() throws APIException {
return execute(new HashMap());
}
@Override
public ProductItem execute(Map extraParams) throws APIException {
ResponseWrapper rw = executeInternal(extraParams);
lastResponse = parseResponse(rw.getBody(), rw.getHeader());
return lastResponse;
}
public ListenableFuture executeAsync() throws APIException {
return executeAsync(new HashMap());
};
public ListenableFuture executeAsync(Map extraParams) throws APIException {
return Futures.transform(
executeAsyncInternal(extraParams),
new Function() {
public ProductItem apply(ResponseWrapper result) {
try {
return APIRequestCreateProduct.this.parseResponse(result.getBody(), result.getHeader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
},
MoreExecutors.directExecutor()
);
};
public APIRequestCreateProduct(String nodeId, APIContext context) {
super(context, nodeId, "/products", "POST", Arrays.asList(PARAMS));
}
@Override
public APIRequestCreateProduct setParam(String param, Object value) {
setParamInternal(param, value);
return this;
}
@Override
public APIRequestCreateProduct setParams(Map params) {
setParamsInternal(params);
return this;
}
public APIRequestCreateProduct setAdditionalImageUrls (List additionalImageUrls) {
this.setParam("additional_image_urls", additionalImageUrls);
return this;
}
public APIRequestCreateProduct setAdditionalImageUrls (String additionalImageUrls) {
this.setParam("additional_image_urls", additionalImageUrls);
return this;
}
public APIRequestCreateProduct setAdditionalVariantAttributes (Map additionalVariantAttributes) {
this.setParam("additional_variant_attributes", additionalVariantAttributes);
return this;
}
public APIRequestCreateProduct setAdditionalVariantAttributes (String additionalVariantAttributes) {
this.setParam("additional_variant_attributes", additionalVariantAttributes);
return this;
}
public APIRequestCreateProduct setAndroidAppName (String androidAppName) {
this.setParam("android_app_name", androidAppName);
return this;
}
public APIRequestCreateProduct setAndroidClass (String androidClass) {
this.setParam("android_class", androidClass);
return this;
}
public APIRequestCreateProduct setAndroidPackage (String androidPackage) {
this.setParam("android_package", androidPackage);
return this;
}
public APIRequestCreateProduct setAndroidUrl (String androidUrl) {
this.setParam("android_url", androidUrl);
return this;
}
public APIRequestCreateProduct setAvailability (ProductItem.EnumAvailability availability) {
this.setParam("availability", availability);
return this;
}
public APIRequestCreateProduct setAvailability (String availability) {
this.setParam("availability", availability);
return this;
}
public APIRequestCreateProduct setBrand (String brand) {
this.setParam("brand", brand);
return this;
}
public APIRequestCreateProduct setCategory (String category) {
this.setParam("category", category);
return this;
}
public APIRequestCreateProduct setCheckoutUrl (String checkoutUrl) {
this.setParam("checkout_url", checkoutUrl);
return this;
}
public APIRequestCreateProduct setColor (String color) {
this.setParam("color", color);
return this;
}
public APIRequestCreateProduct setCommerceTaxCategory (ProductItem.EnumCommerceTaxCategory commerceTaxCategory) {
this.setParam("commerce_tax_category", commerceTaxCategory);
return this;
}
public APIRequestCreateProduct setCommerceTaxCategory (String commerceTaxCategory) {
this.setParam("commerce_tax_category", commerceTaxCategory);
return this;
}
public APIRequestCreateProduct setCondition (ProductItem.EnumCondition condition) {
this.setParam("condition", condition);
return this;
}
public APIRequestCreateProduct setCondition (String condition) {
this.setParam("condition", condition);
return this;
}
public APIRequestCreateProduct setCurrency (String currency) {
this.setParam("currency", currency);
return this;
}
public APIRequestCreateProduct setCustomData (Map customData) {
this.setParam("custom_data", customData);
return this;
}
public APIRequestCreateProduct setCustomData (String customData) {
this.setParam("custom_data", customData);
return this;
}
public APIRequestCreateProduct setCustomLabel0 (String customLabel0) {
this.setParam("custom_label_0", customLabel0);
return this;
}
public APIRequestCreateProduct setCustomLabel1 (String customLabel1) {
this.setParam("custom_label_1", customLabel1);
return this;
}
public APIRequestCreateProduct setCustomLabel2 (String customLabel2) {
this.setParam("custom_label_2", customLabel2);
return this;
}
public APIRequestCreateProduct setCustomLabel3 (String customLabel3) {
this.setParam("custom_label_3", customLabel3);
return this;
}
public APIRequestCreateProduct setCustomLabel4 (String customLabel4) {
this.setParam("custom_label_4", customLabel4);
return this;
}
public APIRequestCreateProduct setCustomNumber0 (Long customNumber0) {
this.setParam("custom_number_0", customNumber0);
return this;
}
public APIRequestCreateProduct setCustomNumber0 (String customNumber0) {
this.setParam("custom_number_0", customNumber0);
return this;
}
public APIRequestCreateProduct setCustomNumber1 (Long customNumber1) {
this.setParam("custom_number_1", customNumber1);
return this;
}
public APIRequestCreateProduct setCustomNumber1 (String customNumber1) {
this.setParam("custom_number_1", customNumber1);
return this;
}
public APIRequestCreateProduct setCustomNumber2 (Long customNumber2) {
this.setParam("custom_number_2", customNumber2);
return this;
}
public APIRequestCreateProduct setCustomNumber2 (String customNumber2) {
this.setParam("custom_number_2", customNumber2);
return this;
}
public APIRequestCreateProduct setCustomNumber3 (Long customNumber3) {
this.setParam("custom_number_3", customNumber3);
return this;
}
public APIRequestCreateProduct setCustomNumber3 (String customNumber3) {
this.setParam("custom_number_3", customNumber3);
return this;
}
public APIRequestCreateProduct setCustomNumber4 (Long customNumber4) {
this.setParam("custom_number_4", customNumber4);
return this;
}
public APIRequestCreateProduct setCustomNumber4 (String customNumber4) {
this.setParam("custom_number_4", customNumber4);
return this;
}
public APIRequestCreateProduct setDescription (String description) {
this.setParam("description", description);
return this;
}
public APIRequestCreateProduct setExpirationDate (String expirationDate) {
this.setParam("expiration_date", expirationDate);
return this;
}
public APIRequestCreateProduct setFbProductCategory (String fbProductCategory) {
this.setParam("fb_product_category", fbProductCategory);
return this;
}
public APIRequestCreateProduct setGender (ProductItem.EnumGender gender) {
this.setParam("gender", gender);
return this;
}
public APIRequestCreateProduct setGender (String gender) {
this.setParam("gender", gender);
return this;
}
public APIRequestCreateProduct setGtin (String gtin) {
this.setParam("gtin", gtin);
return this;
}
public APIRequestCreateProduct setImageUrl (String imageUrl) {
this.setParam("image_url", imageUrl);
return this;
}
public APIRequestCreateProduct setInventory (Long inventory) {
this.setParam("inventory", inventory);
return this;
}
public APIRequestCreateProduct setInventory (String inventory) {
this.setParam("inventory", inventory);
return this;
}
public APIRequestCreateProduct setIosAppName (String iosAppName) {
this.setParam("ios_app_name", iosAppName);
return this;
}
public APIRequestCreateProduct setIosAppStoreId (Long iosAppStoreId) {
this.setParam("ios_app_store_id", iosAppStoreId);
return this;
}
public APIRequestCreateProduct setIosAppStoreId (String iosAppStoreId) {
this.setParam("ios_app_store_id", iosAppStoreId);
return this;
}
public APIRequestCreateProduct setIosUrl (String iosUrl) {
this.setParam("ios_url", iosUrl);
return this;
}
public APIRequestCreateProduct setIpadAppName (String ipadAppName) {
this.setParam("ipad_app_name", ipadAppName);
return this;
}
public APIRequestCreateProduct setIpadAppStoreId (Long ipadAppStoreId) {
this.setParam("ipad_app_store_id", ipadAppStoreId);
return this;
}
public APIRequestCreateProduct setIpadAppStoreId (String ipadAppStoreId) {
this.setParam("ipad_app_store_id", ipadAppStoreId);
return this;
}
public APIRequestCreateProduct setIpadUrl (String ipadUrl) {
this.setParam("ipad_url", ipadUrl);
return this;
}
public APIRequestCreateProduct setIphoneAppName (String iphoneAppName) {
this.setParam("iphone_app_name", iphoneAppName);
return this;
}
public APIRequestCreateProduct setIphoneAppStoreId (Long iphoneAppStoreId) {
this.setParam("iphone_app_store_id", iphoneAppStoreId);
return this;
}
public APIRequestCreateProduct setIphoneAppStoreId (String iphoneAppStoreId) {
this.setParam("iphone_app_store_id", iphoneAppStoreId);
return this;
}
public APIRequestCreateProduct setIphoneUrl (String iphoneUrl) {
this.setParam("iphone_url", iphoneUrl);
return this;
}
public APIRequestCreateProduct setLaunchDate (String launchDate) {
this.setParam("launch_date", launchDate);
return this;
}
public APIRequestCreateProduct setManufacturerPartNumber (String manufacturerPartNumber) {
this.setParam("manufacturer_part_number", manufacturerPartNumber);
return this;
}
public APIRequestCreateProduct setMarkedForProductLaunch (ProductItem.EnumMarkedForProductLaunch markedForProductLaunch) {
this.setParam("marked_for_product_launch", markedForProductLaunch);
return this;
}
public APIRequestCreateProduct setMarkedForProductLaunch (String markedForProductLaunch) {
this.setParam("marked_for_product_launch", markedForProductLaunch);
return this;
}
public APIRequestCreateProduct setMaterial (String material) {
this.setParam("material", material);
return this;
}
public APIRequestCreateProduct setMobileLink (String mobileLink) {
this.setParam("mobile_link", mobileLink);
return this;
}
public APIRequestCreateProduct setName (String name) {
this.setParam("name", name);
return this;
}
public APIRequestCreateProduct setOrderingIndex (Long orderingIndex) {
this.setParam("ordering_index", orderingIndex);
return this;
}
public APIRequestCreateProduct setOrderingIndex (String orderingIndex) {
this.setParam("ordering_index", orderingIndex);
return this;
}
public APIRequestCreateProduct setPattern (String pattern) {
this.setParam("pattern", pattern);
return this;
}
public APIRequestCreateProduct setPrice (Long price) {
this.setParam("price", price);
return this;
}
public APIRequestCreateProduct setPrice (String price) {
this.setParam("price", price);
return this;
}
public APIRequestCreateProduct setProductPriority0 (Double productPriority0) {
this.setParam("product_priority_0", productPriority0);
return this;
}
public APIRequestCreateProduct setProductPriority0 (String productPriority0) {
this.setParam("product_priority_0", productPriority0);
return this;
}
public APIRequestCreateProduct setProductPriority1 (Double productPriority1) {
this.setParam("product_priority_1", productPriority1);
return this;
}
public APIRequestCreateProduct setProductPriority1 (String productPriority1) {
this.setParam("product_priority_1", productPriority1);
return this;
}
public APIRequestCreateProduct setProductPriority2 (Double productPriority2) {
this.setParam("product_priority_2", productPriority2);
return this;
}
public APIRequestCreateProduct setProductPriority2 (String productPriority2) {
this.setParam("product_priority_2", productPriority2);
return this;
}
public APIRequestCreateProduct setProductPriority3 (Double productPriority3) {
this.setParam("product_priority_3", productPriority3);
return this;
}
public APIRequestCreateProduct setProductPriority3 (String productPriority3) {
this.setParam("product_priority_3", productPriority3);
return this;
}
public APIRequestCreateProduct setProductPriority4 (Double productPriority4) {
this.setParam("product_priority_4", productPriority4);
return this;
}
public APIRequestCreateProduct setProductPriority4 (String productPriority4) {
this.setParam("product_priority_4", productPriority4);
return this;
}
public APIRequestCreateProduct setProductType (String productType) {
this.setParam("product_type", productType);
return this;
}
public APIRequestCreateProduct setQuantityToSellOnFacebook (Long quantityToSellOnFacebook) {
this.setParam("quantity_to_sell_on_facebook", quantityToSellOnFacebook);
return this;
}
public APIRequestCreateProduct setQuantityToSellOnFacebook (String quantityToSellOnFacebook) {
this.setParam("quantity_to_sell_on_facebook", quantityToSellOnFacebook);
return this;
}
public APIRequestCreateProduct setRetailerId (String retailerId) {
this.setParam("retailer_id", retailerId);
return this;
}
public APIRequestCreateProduct setReturnPolicyDays (Long returnPolicyDays) {
this.setParam("return_policy_days", returnPolicyDays);
return this;
}
public APIRequestCreateProduct setReturnPolicyDays (String returnPolicyDays) {
this.setParam("return_policy_days", returnPolicyDays);
return this;
}
public APIRequestCreateProduct setSalePrice (Long salePrice) {
this.setParam("sale_price", salePrice);
return this;
}
public APIRequestCreateProduct setSalePrice (String salePrice) {
this.setParam("sale_price", salePrice);
return this;
}
public APIRequestCreateProduct setSalePriceEndDate (String salePriceEndDate) {
this.setParam("sale_price_end_date", salePriceEndDate);
return this;
}
public APIRequestCreateProduct setSalePriceStartDate (String salePriceStartDate) {
this.setParam("sale_price_start_date", salePriceStartDate);
return this;
}
public APIRequestCreateProduct setShortDescription (String shortDescription) {
this.setParam("short_description", shortDescription);
return this;
}
public APIRequestCreateProduct setSize (String size) {
this.setParam("size", size);
return this;
}
public APIRequestCreateProduct setStartDate (String startDate) {
this.setParam("start_date", startDate);
return this;
}
public APIRequestCreateProduct setUrl (String url) {
this.setParam("url", url);
return this;
}
public APIRequestCreateProduct setVisibility (ProductItem.EnumVisibility visibility) {
this.setParam("visibility", visibility);
return this;
}
public APIRequestCreateProduct setVisibility (String visibility) {
this.setParam("visibility", visibility);
return this;
}
public APIRequestCreateProduct setWindowsPhoneAppId (String windowsPhoneAppId) {
this.setParam("windows_phone_app_id", windowsPhoneAppId);
return this;
}
public APIRequestCreateProduct setWindowsPhoneAppName (String windowsPhoneAppName) {
this.setParam("windows_phone_app_name", windowsPhoneAppName);
return this;
}
public APIRequestCreateProduct setWindowsPhoneUrl (String windowsPhoneUrl) {
this.setParam("windows_phone_url", windowsPhoneUrl);
return this;
}
public APIRequestCreateProduct requestAllFields () {
return this.requestAllFields(true);
}
public APIRequestCreateProduct requestAllFields (boolean value) {
for (String field : FIELDS) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestCreateProduct requestFields (List fields) {
return this.requestFields(fields, true);
}
@Override
public APIRequestCreateProduct requestFields (List fields, boolean value) {
for (String field : fields) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestCreateProduct requestField (String field) {
this.requestField(field, true);
return this;
}
@Override
public APIRequestCreateProduct requestField (String field, boolean value) {
this.requestFieldInternal(field, value);
return this;
}
}
public static class APIRequestDelete extends APIRequest {
APINode lastResponse = null;
@Override
public APINode getLastResponse() {
return lastResponse;
}
public static final String[] PARAMS = {
"deletion_method",
};
public static final String[] FIELDS = {
};
@Override
public APINode parseResponse(String response, String header) throws APIException {
return APINode.parseResponse(response, getContext(), this, header).head();
}
@Override
public APINode execute() throws APIException {
return execute(new HashMap());
}
@Override
public APINode execute(Map extraParams) throws APIException {
ResponseWrapper rw = executeInternal(extraParams);
lastResponse = parseResponse(rw.getBody(), rw.getHeader());
return lastResponse;
}
public ListenableFuture executeAsync() throws APIException {
return executeAsync(new HashMap());
};
public ListenableFuture executeAsync(Map extraParams) throws APIException {
return Futures.transform(
executeAsyncInternal(extraParams),
new Function() {
public APINode apply(ResponseWrapper result) {
try {
return APIRequestDelete.this.parseResponse(result.getBody(), result.getHeader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
},
MoreExecutors.directExecutor()
);
};
public APIRequestDelete(String nodeId, APIContext context) {
super(context, nodeId, "/", "DELETE", Arrays.asList(PARAMS));
}
@Override
public APIRequestDelete setParam(String param, Object value) {
setParamInternal(param, value);
return this;
}
@Override
public APIRequestDelete setParams(Map params) {
setParamsInternal(params);
return this;
}
public APIRequestDelete setDeletionMethod (EnumDeletionMethod deletionMethod) {
this.setParam("deletion_method", deletionMethod);
return this;
}
public APIRequestDelete setDeletionMethod (String deletionMethod) {
this.setParam("deletion_method", deletionMethod);
return this;
}
public APIRequestDelete requestAllFields () {
return this.requestAllFields(true);
}
public APIRequestDelete requestAllFields (boolean value) {
for (String field : FIELDS) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestDelete requestFields (List fields) {
return this.requestFields(fields, true);
}
@Override
public APIRequestDelete requestFields (List fields, boolean value) {
for (String field : fields) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestDelete requestField (String field) {
this.requestField(field, true);
return this;
}
@Override
public APIRequestDelete requestField (String field, boolean value) {
this.requestFieldInternal(field, value);
return this;
}
}
public static class APIRequestGet extends APIRequest {
ProductGroup lastResponse = null;
@Override
public ProductGroup getLastResponse() {
return lastResponse;
}
public static final String[] PARAMS = {
};
public static final String[] FIELDS = {
"id",
"product_catalog",
"retailer_id",
"variants",
};
@Override
public ProductGroup parseResponse(String response, String header) throws APIException {
return ProductGroup.parseResponse(response, getContext(), this, header).head();
}
@Override
public ProductGroup execute() throws APIException {
return execute(new HashMap());
}
@Override
public ProductGroup execute(Map extraParams) throws APIException {
ResponseWrapper rw = executeInternal(extraParams);
lastResponse = parseResponse(rw.getBody(), rw.getHeader());
return lastResponse;
}
public ListenableFuture executeAsync() throws APIException {
return executeAsync(new HashMap());
};
public ListenableFuture executeAsync(Map extraParams) throws APIException {
return Futures.transform(
executeAsyncInternal(extraParams),
new Function() {
public ProductGroup apply(ResponseWrapper result) {
try {
return APIRequestGet.this.parseResponse(result.getBody(), result.getHeader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
},
MoreExecutors.directExecutor()
);
};
public APIRequestGet(String nodeId, APIContext context) {
super(context, nodeId, "/", "GET", Arrays.asList(PARAMS));
}
@Override
public APIRequestGet setParam(String param, Object value) {
setParamInternal(param, value);
return this;
}
@Override
public APIRequestGet setParams(Map params) {
setParamsInternal(params);
return this;
}
public APIRequestGet requestAllFields () {
return this.requestAllFields(true);
}
public APIRequestGet requestAllFields (boolean value) {
for (String field : FIELDS) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGet requestFields (List fields) {
return this.requestFields(fields, true);
}
@Override
public APIRequestGet requestFields (List fields, boolean value) {
for (String field : fields) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGet requestField (String field) {
this.requestField(field, true);
return this;
}
@Override
public APIRequestGet requestField (String field, boolean value) {
this.requestFieldInternal(field, value);
return this;
}
public APIRequestGet requestIdField () {
return this.requestIdField(true);
}
public APIRequestGet requestIdField (boolean value) {
this.requestField("id", value);
return this;
}
public APIRequestGet requestProductCatalogField () {
return this.requestProductCatalogField(true);
}
public APIRequestGet requestProductCatalogField (boolean value) {
this.requestField("product_catalog", value);
return this;
}
public APIRequestGet requestRetailerIdField () {
return this.requestRetailerIdField(true);
}
public APIRequestGet requestRetailerIdField (boolean value) {
this.requestField("retailer_id", value);
return this;
}
public APIRequestGet requestVariantsField () {
return this.requestVariantsField(true);
}
public APIRequestGet requestVariantsField (boolean value) {
this.requestField("variants", value);
return this;
}
}
public static class APIRequestUpdate extends APIRequest {
ProductGroup lastResponse = null;
@Override
public ProductGroup getLastResponse() {
return lastResponse;
}
public static final String[] PARAMS = {
"default_product_id",
"variants",
};
public static final String[] FIELDS = {
};
@Override
public ProductGroup parseResponse(String response, String header) throws APIException {
return ProductGroup.parseResponse(response, getContext(), this, header).head();
}
@Override
public ProductGroup execute() throws APIException {
return execute(new HashMap());
}
@Override
public ProductGroup execute(Map extraParams) throws APIException {
ResponseWrapper rw = executeInternal(extraParams);
lastResponse = parseResponse(rw.getBody(), rw.getHeader());
return lastResponse;
}
public ListenableFuture executeAsync() throws APIException {
return executeAsync(new HashMap());
};
public ListenableFuture executeAsync(Map extraParams) throws APIException {
return Futures.transform(
executeAsyncInternal(extraParams),
new Function() {
public ProductGroup apply(ResponseWrapper result) {
try {
return APIRequestUpdate.this.parseResponse(result.getBody(), result.getHeader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
},
MoreExecutors.directExecutor()
);
};
public APIRequestUpdate(String nodeId, APIContext context) {
super(context, nodeId, "/", "POST", Arrays.asList(PARAMS));
}
@Override
public APIRequestUpdate setParam(String param, Object value) {
setParamInternal(param, value);
return this;
}
@Override
public APIRequestUpdate setParams(Map params) {
setParamsInternal(params);
return this;
}
public APIRequestUpdate setDefaultProductId (String defaultProductId) {
this.setParam("default_product_id", defaultProductId);
return this;
}
public APIRequestUpdate setVariants (List