com.facebook.ads.sdk.Campaign.java Source code

Java tutorial

Introduction

Here is the source code for com.facebook.ads.sdk.Campaign.java

Source

/**
 * Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
 *
 * You are hereby granted a non-exclusive, worldwide, royalty-free license to
 * use, copy, modify, and distribute this software in source code or binary
 * form for use in connection with the web services and APIs provided by
 * Facebook.
 *
 * As with any software that integrates with the Facebook platform, your use
 * of this software is subject to the Facebook Developer Principles and
 * Policies [http://developers.facebook.com/policy/]. This copyright notice
 * shall be included in all copies or substantial portions of the software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 *
 */

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.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-genereated.
 *
 * 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 Campaign extends APINode {
    @SerializedName("account_id")
    private String mAccountId = null;
    @SerializedName("adlabels")
    private List<AdLabel> mAdlabels = null;
    @SerializedName("brand_lift_studies")
    private List<AdStudy> mBrandLiftStudies = null;
    @SerializedName("budget_rebalance_flag")
    private Boolean mBudgetRebalanceFlag = null;
    @SerializedName("buying_type")
    private String mBuyingType = null;
    @SerializedName("can_create_brand_lift_study")
    private Boolean mCanCreateBrandLiftStudy = null;
    @SerializedName("can_use_spend_cap")
    private Boolean mCanUseSpendCap = null;
    @SerializedName("configured_status")
    private EnumConfiguredStatus mConfiguredStatus = null;
    @SerializedName("created_time")
    private String mCreatedTime = null;
    @SerializedName("effective_status")
    private EnumEffectiveStatus mEffectiveStatus = null;
    @SerializedName("id")
    private String mId = null;
    @SerializedName("name")
    private String mName = null;
    @SerializedName("objective")
    private String mObjective = null;
    @SerializedName("recommendations")
    private List<AdRecommendation> mRecommendations = null;
    @SerializedName("spend_cap")
    private String mSpendCap = null;
    @SerializedName("start_time")
    private String mStartTime = null;
    @SerializedName("status")
    private EnumStatus mStatus = null;
    @SerializedName("stop_time")
    private String mStopTime = null;
    @SerializedName("updated_time")
    private String mUpdatedTime = null;
    protected static Gson gson = null;

    Campaign() {
    }

    public Campaign(Long id, APIContext context) {
        this(id.toString(), context);
    }

    public Campaign(String id, APIContext context) {
        this.mId = id;
        this.context = context;
    }

    public Campaign fetch() throws APIException {
        Campaign newInstance = fetchById(this.getPrefixedId().toString(), this.context);
        this.copyFrom(newInstance);
        return this;
    }

    public static Campaign fetchById(Long id, APIContext context) throws APIException {
        return fetchById(id.toString(), context);
    }

    public static Campaign fetchById(String id, APIContext context) throws APIException {
        Campaign campaign = new APIRequestGet(id, context).requestAllFields().execute();
        return campaign;
    }

    public static APINodeList<Campaign> fetchByIds(List<String> ids, List<String> fields, APIContext context)
            throws APIException {
        return (APINodeList<Campaign>) (new APIRequest<Campaign>(context, "", "/", "GET", Campaign.getParser())
                .setParam("ids", String.join(",", ids)).requestFields(fields).execute());
    }

    private String getPrefixedId() {
        return getId();
    }

    public String getId() {
        return getFieldId().toString();
    }

    public static Campaign loadJSON(String json, APIContext context) {
        Campaign campaign = getGson().fromJson(json, Campaign.class);
        if (context.isDebug()) {
            JsonParser parser = new JsonParser();
            JsonElement o1 = parser.parse(json);
            JsonElement o2 = parser.parse(campaign.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);
            }
            ;
        }
        campaign.context = context;
        campaign.rawValue = json;
        return campaign;
    }

    public static APINodeList<Campaign> parseResponse(String json, APIContext context, APIRequest request)
            throws MalformedResponseException {
        APINodeList<Campaign> campaigns = new APINodeList<Campaign>(request, json);
        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++) {
                    campaigns.add(loadJSON(arr.get(i).getAsJsonObject().toString(), context));
                }
                ;
                return campaigns;
            } else if (result.isJsonObject()) {
                obj = result.getAsJsonObject();
                if (obj.has("data")) {
                    if (obj.has("paging")) {
                        JsonObject paging = obj.get("paging").getAsJsonObject().get("cursors").getAsJsonObject();
                        String before = paging.has("before") ? paging.get("before").getAsString() : null;
                        String after = paging.has("after") ? paging.get("after").getAsString() : null;
                        campaigns.setPaging(before, after);
                    }
                    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++) {
                            campaigns.add(loadJSON(arr.get(i).getAsJsonObject().toString(), context));
                        }
                        ;
                    } 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<String, JsonElement> entry : obj.entrySet()) {
                                    campaigns.add(loadJSON(entry.getValue().toString(), context));
                                }
                                break;
                            }
                        }
                        if (!isRedownload) {
                            campaigns.add(loadJSON(obj.toString(), context));
                        }
                    }
                    return campaigns;
                } else if (obj.has("images")) {
                    // Fourth, check if it's a map of image objects
                    obj = obj.get("images").getAsJsonObject();
                    for (Map.Entry<String, JsonElement> entry : obj.entrySet()) {
                        campaigns.add(loadJSON(entry.getValue().toString(), context));
                    }
                    return campaigns;
                } 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)) {
                            campaigns.add(loadJSON(value.toString(), context));
                        } else {
                            isIdIndexedArray = false;
                            break;
                        }
                    }
                    if (isIdIndexedArray) {
                        return campaigns;
                    }

                    // Sixth, check if it's pure JsonObject
                    campaigns.clear();
                    campaigns.add(loadJSON(json, context));
                    return campaigns;
                }
            }
        } 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 APIRequestDeleteAdLabels deleteAdLabels() {
        return new APIRequestDeleteAdLabels(this.getPrefixedId().toString(), context);
    }

    public APIRequestCreateAdLabel createAdLabel() {
        return new APIRequestCreateAdLabel(this.getPrefixedId().toString(), context);
    }

    public APIRequestGetAds getAds() {
        return new APIRequestGetAds(this.getPrefixedId().toString(), context);
    }

    public APIRequestGetAdSets getAdSets() {
        return new APIRequestGetAdSets(this.getPrefixedId().toString(), context);
    }

    public APIRequestGetInsights getInsights() {
        return new APIRequestGetInsights(this.getPrefixedId().toString(), context);
    }

    public APIRequestGetInsightsAsync getInsightsAsync() {
        return new APIRequestGetInsightsAsync(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 getFieldAccountId() {
        return mAccountId;
    }

    public List<AdLabel> getFieldAdlabels() {
        return mAdlabels;
    }

    public List<AdStudy> getFieldBrandLiftStudies() {
        return mBrandLiftStudies;
    }

    public Boolean getFieldBudgetRebalanceFlag() {
        return mBudgetRebalanceFlag;
    }

    public String getFieldBuyingType() {
        return mBuyingType;
    }

    public Boolean getFieldCanCreateBrandLiftStudy() {
        return mCanCreateBrandLiftStudy;
    }

    public Boolean getFieldCanUseSpendCap() {
        return mCanUseSpendCap;
    }

    public EnumConfiguredStatus getFieldConfiguredStatus() {
        return mConfiguredStatus;
    }

    public String getFieldCreatedTime() {
        return mCreatedTime;
    }

    public EnumEffectiveStatus getFieldEffectiveStatus() {
        return mEffectiveStatus;
    }

    public String getFieldId() {
        return mId;
    }

    public String getFieldName() {
        return mName;
    }

    public String getFieldObjective() {
        return mObjective;
    }

    public List<AdRecommendation> getFieldRecommendations() {
        return mRecommendations;
    }

    public String getFieldSpendCap() {
        return mSpendCap;
    }

    public String getFieldStartTime() {
        return mStartTime;
    }

    public EnumStatus getFieldStatus() {
        return mStatus;
    }

    public String getFieldStopTime() {
        return mStopTime;
    }

    public String getFieldUpdatedTime() {
        return mUpdatedTime;
    }

    public static class APIRequestDeleteAdLabels extends APIRequest<APINode> {

        APINodeList<APINode> lastResponse = null;

        @Override
        public APINodeList<APINode> getLastResponse() {
            return lastResponse;
        }

        public static final String[] PARAMS = { "adlabels", "execution_options", };

        public static final String[] FIELDS = {};

        @Override
        public APINodeList<APINode> parseResponse(String response) throws APIException {
            return APINode.parseResponse(response, getContext(), this);
        }

        @Override
        public APINodeList<APINode> execute() throws APIException {
            return execute(new HashMap<String, Object>());
        }

        @Override
        public APINodeList<APINode> execute(Map<String, Object> extraParams) throws APIException {
            lastResponse = parseResponse(executeInternal(extraParams));
            return lastResponse;
        }

        public APIRequestDeleteAdLabels(String nodeId, APIContext context) {
            super(context, nodeId, "/adlabels", "DELETE", Arrays.asList(PARAMS));
        }

        @Override
        public APIRequestDeleteAdLabels setParam(String param, Object value) {
            setParamInternal(param, value);
            return this;
        }

        @Override
        public APIRequestDeleteAdLabels setParams(Map<String, Object> params) {
            setParamsInternal(params);
            return this;
        }

        public APIRequestDeleteAdLabels setAdlabels(List<Object> adlabels) {
            this.setParam("adlabels", adlabels);
            return this;
        }

        public APIRequestDeleteAdLabels setAdlabels(String adlabels) {
            this.setParam("adlabels", adlabels);
            return this;
        }

        public APIRequestDeleteAdLabels setExecutionOptions(List<AdLabel.EnumExecutionOptions> executionOptions) {
            this.setParam("execution_options", executionOptions);
            return this;
        }

        public APIRequestDeleteAdLabels setExecutionOptions(String executionOptions) {
            this.setParam("execution_options", executionOptions);
            return this;
        }

        public APIRequestDeleteAdLabels requestAllFields() {
            return this.requestAllFields(true);
        }

        public APIRequestDeleteAdLabels requestAllFields(boolean value) {
            for (String field : FIELDS) {
                this.requestField(field, value);
            }
            return this;
        }

        @Override
        public APIRequestDeleteAdLabels requestFields(List<String> fields) {
            return this.requestFields(fields, true);
        }

        @Override
        public APIRequestDeleteAdLabels requestFields(List<String> fields, boolean value) {
            for (String field : fields) {
                this.requestField(field, value);
            }
            return this;
        }

        @Override
        public APIRequestDeleteAdLabels requestField(String field) {
            this.requestField(field, true);
            return this;
        }

        @Override
        public APIRequestDeleteAdLabels requestField(String field, boolean value) {
            this.requestFieldInternal(field, value);
            return this;
        }

    }

    public static class APIRequestCreateAdLabel extends APIRequest<AdLabel> {

        AdLabel lastResponse = null;

        @Override
        public AdLabel getLastResponse() {
            return lastResponse;
        }

        public static final String[] PARAMS = { "adlabels", "execution_options", };

        public static final String[] FIELDS = {};

        @Override
        public AdLabel parseResponse(String response) throws APIException {
            return AdLabel.parseResponse(response, getContext(), this).head();
        }

        @Override
        public AdLabel execute() throws APIException {
            return execute(new HashMap<String, Object>());
        }

        @Override
        public AdLabel execute(Map<String, Object> extraParams) throws APIException {
            lastResponse = parseResponse(executeInternal(extraParams));
            return lastResponse;
        }

        public APIRequestCreateAdLabel(String nodeId, APIContext context) {
            super(context, nodeId, "/adlabels", "POST", Arrays.asList(PARAMS));
        }

        @Override
        public APIRequestCreateAdLabel setParam(String param, Object value) {
            setParamInternal(param, value);
            return this;
        }

        @Override
        public APIRequestCreateAdLabel setParams(Map<String, Object> params) {
            setParamsInternal(params);
            return this;
        }

        public APIRequestCreateAdLabel setAdlabels(List<Object> adlabels) {
            this.setParam("adlabels", adlabels);
            return this;
        }

        public APIRequestCreateAdLabel setAdlabels(String adlabels) {
            this.setParam("adlabels", adlabels);
            return this;
        }

        public APIRequestCreateAdLabel setExecutionOptions(List<AdLabel.EnumExecutionOptions> executionOptions) {
            this.setParam("execution_options", executionOptions);
            return this;
        }

        public APIRequestCreateAdLabel setExecutionOptions(String executionOptions) {
            this.setParam("execution_options", executionOptions);
            return this;
        }

        public APIRequestCreateAdLabel requestAllFields() {
            return this.requestAllFields(true);
        }

        public APIRequestCreateAdLabel requestAllFields(boolean value) {
            for (String field : FIELDS) {
                this.requestField(field, value);
            }
            return this;
        }

        @Override
        public APIRequestCreateAdLabel requestFields(List<String> fields) {
            return this.requestFields(fields, true);
        }

        @Override
        public APIRequestCreateAdLabel requestFields(List<String> fields, boolean value) {
            for (String field : fields) {
                this.requestField(field, value);
            }
            return this;
        }

        @Override
        public APIRequestCreateAdLabel requestField(String field) {
            this.requestField(field, true);
            return this;
        }

        @Override
        public APIRequestCreateAdLabel requestField(String field, boolean value) {
            this.requestFieldInternal(field, value);
            return this;
        }

    }

    public static class APIRequestGetAds extends APIRequest<Ad> {

        APINodeList<Ad> lastResponse = null;

        @Override
        public APINodeList<Ad> getLastResponse() {
            return lastResponse;
        }

        public static final String[] PARAMS = { "ad_draft_id", "date_preset", "effective_status", "include_deleted",
                "time_range", "updated_since", };

        public static final String[] FIELDS = { "account_id", "ad_review_feedback", "adlabels", "adset", "adset_id",
                "bid_amount", "bid_info", "bid_type", "campaign", "campaign_id", "configured_status",
                "conversion_specs", "created_time", "creative", "effective_status", "id", "last_updated_by_app_id",
                "name", "recommendations", "status", "tracking_specs", "updated_time", };

        @Override
        public APINodeList<Ad> parseResponse(String response) throws APIException {
            return Ad.parseResponse(response, getContext(), this);
        }

        @Override
        public APINodeList<Ad> execute() throws APIException {
            return execute(new HashMap<String, Object>());
        }

        @Override
        public APINodeList<Ad> execute(Map<String, Object> extraParams) throws APIException {
            lastResponse = parseResponse(executeInternal(extraParams));
            return lastResponse;
        }

        public APIRequestGetAds(String nodeId, APIContext context) {
            super(context, nodeId, "/ads", "GET", Arrays.asList(PARAMS));
        }

        @Override
        public APIRequestGetAds setParam(String param, Object value) {
            setParamInternal(param, value);
            return this;
        }

        @Override
        public APIRequestGetAds setParams(Map<String, Object> params) {
            setParamsInternal(params);
            return this;
        }

        public APIRequestGetAds setAdDraftId(String adDraftId) {
            this.setParam("ad_draft_id", adDraftId);
            return this;
        }

        public APIRequestGetAds setDatePreset(Ad.EnumDatePreset datePreset) {
            this.setParam("date_preset", datePreset);
            return this;
        }

        public APIRequestGetAds setDatePreset(String datePreset) {
            this.setParam("date_preset", datePreset);
            return this;
        }

        public APIRequestGetAds setEffectiveStatus(List<String> effectiveStatus) {
            this.setParam("effective_status", effectiveStatus);
            return this;
        }

        public APIRequestGetAds setEffectiveStatus(String effectiveStatus) {
            this.setParam("effective_status", effectiveStatus);
            return this;
        }

        public APIRequestGetAds setIncludeDeleted(Boolean includeDeleted) {
            this.setParam("include_deleted", includeDeleted);
            return this;
        }

        public APIRequestGetAds setIncludeDeleted(String includeDeleted) {
            this.setParam("include_deleted", includeDeleted);
            return this;
        }

        public APIRequestGetAds setTimeRange(Object timeRange) {
            this.setParam("time_range", timeRange);
            return this;
        }

        public APIRequestGetAds setTimeRange(String timeRange) {
            this.setParam("time_range", timeRange);
            return this;
        }

        public APIRequestGetAds setUpdatedSince(Long updatedSince) {
            this.setParam("updated_since", updatedSince);
            return this;
        }

        public APIRequestGetAds setUpdatedSince(String updatedSince) {
            this.setParam("updated_since", updatedSince);
            return this;
        }

        public APIRequestGetAds requestAllFields() {
            return this.requestAllFields(true);
        }

        public APIRequestGetAds requestAllFields(boolean value) {
            for (String field : FIELDS) {
                this.requestField(field, value);
            }
            return this;
        }

        @Override
        public APIRequestGetAds requestFields(List<String> fields) {
            return this.requestFields(fields, true);
        }

        @Override
        public APIRequestGetAds requestFields(List<String> fields, boolean value) {
            for (String field : fields) {
                this.requestField(field, value);
            }
            return this;
        }

        @Override
        public APIRequestGetAds requestField(String field) {
            this.requestField(field, true);
            return this;
        }

        @Override
        public APIRequestGetAds requestField(String field, boolean value) {
            this.requestFieldInternal(field, value);
            return this;
        }

        public APIRequestGetAds requestAccountIdField() {
            return this.requestAccountIdField(true);
        }

        public APIRequestGetAds requestAccountIdField(boolean value) {
            this.requestField("account_id", value);
            return this;
        }

        public APIRequestGetAds requestAdReviewFeedbackField() {
            return this.requestAdReviewFeedbackField(true);
        }

        public APIRequestGetAds requestAdReviewFeedbackField(boolean value) {
            this.requestField("ad_review_feedback", value);
            return this;
        }

        public APIRequestGetAds requestAdlabelsField() {
            return this.requestAdlabelsField(true);
        }

        public APIRequestGetAds requestAdlabelsField(boolean value) {
            this.requestField("adlabels", value);
            return this;
        }

        public APIRequestGetAds requestAdsetField() {
            return this.requestAdsetField(true);
        }

        public APIRequestGetAds requestAdsetField(boolean value) {
            this.requestField("adset", value);
            return this;
        }

        public APIRequestGetAds requestAdsetIdField() {
            return this.requestAdsetIdField(true);
        }

        public APIRequestGetAds requestAdsetIdField(boolean value) {
            this.requestField("adset_id", value);
            return this;
        }

        public APIRequestGetAds requestBidAmountField() {
            return this.requestBidAmountField(true);
        }

        public APIRequestGetAds requestBidAmountField(boolean value) {
            this.requestField("bid_amount", value);
            return this;
        }

        public APIRequestGetAds requestBidInfoField() {
            return this.requestBidInfoField(true);
        }

        public APIRequestGetAds requestBidInfoField(boolean value) {
            this.requestField("bid_info", value);
            return this;
        }

        public APIRequestGetAds requestBidTypeField() {
            return this.requestBidTypeField(true);
        }

        public APIRequestGetAds requestBidTypeField(boolean value) {
            this.requestField("bid_type", value);
            return this;
        }

        public APIRequestGetAds requestCampaignField() {
            return this.requestCampaignField(true);
        }

        public APIRequestGetAds requestCampaignField(boolean value) {
            this.requestField("campaign", value);
            return this;
        }

        public APIRequestGetAds requestCampaignIdField() {
            return this.requestCampaignIdField(true);
        }

        public APIRequestGetAds requestCampaignIdField(boolean value) {
            this.requestField("campaign_id", value);
            return this;
        }

        public APIRequestGetAds requestConfiguredStatusField() {
            return this.requestConfiguredStatusField(true);
        }

        public APIRequestGetAds requestConfiguredStatusField(boolean value) {
            this.requestField("configured_status", value);
            return this;
        }

        public APIRequestGetAds requestConversionSpecsField() {
            return this.requestConversionSpecsField(true);
        }

        public APIRequestGetAds requestConversionSpecsField(boolean value) {
            this.requestField("conversion_specs", value);
            return this;
        }

        public APIRequestGetAds requestCreatedTimeField() {
            return this.requestCreatedTimeField(true);
        }

        public APIRequestGetAds requestCreatedTimeField(boolean value) {
            this.requestField("created_time", value);
            return this;
        }

        public APIRequestGetAds requestCreativeField() {
            return this.requestCreativeField(true);
        }

        public APIRequestGetAds requestCreativeField(boolean value) {
            this.requestField("creative", value);
            return this;
        }

        public APIRequestGetAds requestEffectiveStatusField() {
            return this.requestEffectiveStatusField(true);
        }

        public APIRequestGetAds requestEffectiveStatusField(boolean value) {
            this.requestField("effective_status", value);
            return this;
        }

        public APIRequestGetAds requestIdField() {
            return this.requestIdField(true);
        }

        public APIRequestGetAds requestIdField(boolean value) {
            this.requestField("id", value);
            return this;
        }

        public APIRequestGetAds requestLastUpdatedByAppIdField() {
            return this.requestLastUpdatedByAppIdField(true);
        }

        public APIRequestGetAds requestLastUpdatedByAppIdField(boolean value) {
            this.requestField("last_updated_by_app_id", value);
            return this;
        }

        public APIRequestGetAds requestNameField() {
            return this.requestNameField(true);
        }

        public APIRequestGetAds requestNameField(boolean value) {
            this.requestField("name", value);
            return this;
        }

        public APIRequestGetAds requestRecommendationsField() {
            return this.requestRecommendationsField(true);
        }

        public APIRequestGetAds requestRecommendationsField(boolean value) {
            this.requestField("recommendations", value);
            return this;
        }

        public APIRequestGetAds requestStatusField() {
            return this.requestStatusField(true);
        }

        public APIRequestGetAds requestStatusField(boolean value) {
            this.requestField("status", value);
            return this;
        }

        public APIRequestGetAds requestTrackingSpecsField() {
            return this.requestTrackingSpecsField(true);
        }

        public APIRequestGetAds requestTrackingSpecsField(boolean value) {
            this.requestField("tracking_specs", value);
            return this;
        }

        public APIRequestGetAds requestUpdatedTimeField() {
            return this.requestUpdatedTimeField(true);
        }

        public APIRequestGetAds requestUpdatedTimeField(boolean value) {
            this.requestField("updated_time", value);
            return this;
        }
    }

    public static class APIRequestGetAdSets extends APIRequest<AdSet> {

        APINodeList<AdSet> lastResponse = null;

        @Override
        public APINodeList<AdSet> getLastResponse() {
            return lastResponse;
        }

        public static final String[] PARAMS = { "ad_draft_id", "date_preset", "effective_status", "is_completed",
                "time_range", };

        public static final String[] FIELDS = { "account_id", "adlabels", "adset_schedule",
                "attribution_window_days", "bid_amount", "bid_info", "billing_event", "budget_remaining",
                "campaign", "campaign_id", "configured_status", "created_time", "creative_sequence", "daily_budget",
                "effective_status", "end_time", "frequency_cap", "frequency_cap_reset_period",
                "frequency_control_specs", "id", "is_autobid", "is_average_price_pacing", "lifetime_budget",
                "lifetime_frequency_cap", "lifetime_imps", "name", "optimization_goal", "pacing_type",
                "promoted_object", "recommendations", "recurring_budget_semantics", "rf_prediction_id", "rtb_flag",
                "start_time", "status", "targeting", "time_based_ad_rotation_id_blocks",
                "time_based_ad_rotation_intervals", "updated_time", "use_new_app_click",
                "view_through_attribution_window_days", };

        @Override
        public APINodeList<AdSet> parseResponse(String response) throws APIException {
            return AdSet.parseResponse(response, getContext(), this);
        }

        @Override
        public APINodeList<AdSet> execute() throws APIException {
            return execute(new HashMap<String, Object>());
        }

        @Override
        public APINodeList<AdSet> execute(Map<String, Object> extraParams) throws APIException {
            lastResponse = parseResponse(executeInternal(extraParams));
            return lastResponse;
        }

        public APIRequestGetAdSets(String nodeId, APIContext context) {
            super(context, nodeId, "/adsets", "GET", Arrays.asList(PARAMS));
        }

        @Override
        public APIRequestGetAdSets setParam(String param, Object value) {
            setParamInternal(param, value);
            return this;
        }

        @Override
        public APIRequestGetAdSets setParams(Map<String, Object> params) {
            setParamsInternal(params);
            return this;
        }

        public APIRequestGetAdSets setAdDraftId(String adDraftId) {
            this.setParam("ad_draft_id", adDraftId);
            return this;
        }

        public APIRequestGetAdSets setDatePreset(AdSet.EnumDatePreset datePreset) {
            this.setParam("date_preset", datePreset);
            return this;
        }

        public APIRequestGetAdSets setDatePreset(String datePreset) {
            this.setParam("date_preset", datePreset);
            return this;
        }

        public APIRequestGetAdSets setEffectiveStatus(List<AdSet.EnumEffectiveStatus> effectiveStatus) {
            this.setParam("effective_status", effectiveStatus);
            return this;
        }

        public APIRequestGetAdSets setEffectiveStatus(String effectiveStatus) {
            this.setParam("effective_status", effectiveStatus);
            return this;
        }

        public APIRequestGetAdSets setIsCompleted(Boolean isCompleted) {
            this.setParam("is_completed", isCompleted);
            return this;
        }

        public APIRequestGetAdSets setIsCompleted(String isCompleted) {
            this.setParam("is_completed", isCompleted);
            return this;
        }

        public APIRequestGetAdSets setTimeRange(Object timeRange) {
            this.setParam("time_range", timeRange);
            return this;
        }

        public APIRequestGetAdSets setTimeRange(String timeRange) {
            this.setParam("time_range", timeRange);
            return this;
        }

        public APIRequestGetAdSets requestAllFields() {
            return this.requestAllFields(true);
        }

        public APIRequestGetAdSets requestAllFields(boolean value) {
            for (String field : FIELDS) {
                this.requestField(field, value);
            }
            return this;
        }

        @Override
        public APIRequestGetAdSets requestFields(List<String> fields) {
            return this.requestFields(fields, true);
        }

        @Override
        public APIRequestGetAdSets requestFields(List<String> fields, boolean value) {
            for (String field : fields) {
                this.requestField(field, value);
            }
            return this;
        }

        @Override
        public APIRequestGetAdSets requestField(String field) {
            this.requestField(field, true);
            return this;
        }

        @Override
        public APIRequestGetAdSets requestField(String field, boolean value) {
            this.requestFieldInternal(field, value);
            return this;
        }

        public APIRequestGetAdSets requestAccountIdField() {
            return this.requestAccountIdField(true);
        }

        public APIRequestGetAdSets requestAccountIdField(boolean value) {
            this.requestField("account_id", value);
            return this;
        }

        public APIRequestGetAdSets requestAdlabelsField() {
            return this.requestAdlabelsField(true);
        }

        public APIRequestGetAdSets requestAdlabelsField(boolean value) {
            this.requestField("adlabels", value);
            return this;
        }

        public APIRequestGetAdSets requestAdsetScheduleField() {
            return this.requestAdsetScheduleField(true);
        }

        public APIRequestGetAdSets requestAdsetScheduleField(boolean value) {
            this.requestField("adset_schedule", value);
            return this;
        }

        public APIRequestGetAdSets requestAttributionWindowDaysField() {
            return this.requestAttributionWindowDaysField(true);
        }

        public APIRequestGetAdSets requestAttributionWindowDaysField(boolean value) {
            this.requestField("attribution_window_days", value);
            return this;
        }

        public APIRequestGetAdSets requestBidAmountField() {
            return this.requestBidAmountField(true);
        }

        public APIRequestGetAdSets requestBidAmountField(boolean value) {
            this.requestField("bid_amount", value);
            return this;
        }

        public APIRequestGetAdSets requestBidInfoField() {
            return this.requestBidInfoField(true);
        }

        public APIRequestGetAdSets requestBidInfoField(boolean value) {
            this.requestField("bid_info", value);
            return this;
        }

        public APIRequestGetAdSets requestBillingEventField() {
            return this.requestBillingEventField(true);
        }

        public APIRequestGetAdSets requestBillingEventField(boolean value) {
            this.requestField("billing_event", value);
            return this;
        }

        public APIRequestGetAdSets requestBudgetRemainingField() {
            return this.requestBudgetRemainingField(true);
        }

        public APIRequestGetAdSets requestBudgetRemainingField(boolean value) {
            this.requestField("budget_remaining", value);
            return this;
        }

        public APIRequestGetAdSets requestCampaignField() {
            return this.requestCampaignField(true);
        }

        public APIRequestGetAdSets requestCampaignField(boolean value) {
            this.requestField("campaign", value);
            return this;
        }

        public APIRequestGetAdSets requestCampaignIdField() {
            return this.requestCampaignIdField(true);
        }

        public APIRequestGetAdSets requestCampaignIdField(boolean value) {
            this.requestField("campaign_id", value);
            return this;
        }

        public APIRequestGetAdSets requestConfiguredStatusField() {
            return this.requestConfiguredStatusField(true);
        }

        public APIRequestGetAdSets requestConfiguredStatusField(boolean value) {
            this.requestField("configured_status", value);
            return this;
        }

        public APIRequestGetAdSets requestCreatedTimeField() {
            return this.requestCreatedTimeField(true);
        }

        public APIRequestGetAdSets requestCreatedTimeField(boolean value) {
            this.requestField("created_time", value);
            return this;
        }

        public APIRequestGetAdSets requestCreativeSequenceField() {
            return this.requestCreativeSequenceField(true);
        }

        public APIRequestGetAdSets requestCreativeSequenceField(boolean value) {
            this.requestField("creative_sequence", value);
            return this;
        }

        public APIRequestGetAdSets requestDailyBudgetField() {
            return this.requestDailyBudgetField(true);
        }

        public APIRequestGetAdSets requestDailyBudgetField(boolean value) {
            this.requestField("daily_budget", value);
            return this;
        }

        public APIRequestGetAdSets requestEffectiveStatusField() {
            return this.requestEffectiveStatusField(true);
        }

        public APIRequestGetAdSets requestEffectiveStatusField(boolean value) {
            this.requestField("effective_status", value);
            return this;
        }

        public APIRequestGetAdSets requestEndTimeField() {
            return this.requestEndTimeField(true);
        }

        public APIRequestGetAdSets requestEndTimeField(boolean value) {
            this.requestField("end_time", value);
            return this;
        }

        public APIRequestGetAdSets requestFrequencyCapField() {
            return this.requestFrequencyCapField(true);
        }

        public APIRequestGetAdSets requestFrequencyCapField(boolean value) {
            this.requestField("frequency_cap", value);
            return this;
        }

        public APIRequestGetAdSets requestFrequencyCapResetPeriodField() {
            return this.requestFrequencyCapResetPeriodField(true);
        }

        public APIRequestGetAdSets requestFrequencyCapResetPeriodField(boolean value) {
            this.requestField("frequency_cap_reset_period", value);
            return this;
        }

        public APIRequestGetAdSets requestFrequencyControlSpecsField() {
            return this.requestFrequencyControlSpecsField(true);
        }

        public APIRequestGetAdSets requestFrequencyControlSpecsField(boolean value) {
            this.requestField("frequency_control_specs", value);
            return this;
        }

        public APIRequestGetAdSets requestIdField() {
            return this.requestIdField(true);
        }

        public APIRequestGetAdSets requestIdField(boolean value) {
            this.requestField("id", value);
            return this;
        }

        public APIRequestGetAdSets requestIsAutobidField() {
            return this.requestIsAutobidField(true);
        }

        public APIRequestGetAdSets requestIsAutobidField(boolean value) {
            this.requestField("is_autobid", value);
            return this;
        }

        public APIRequestGetAdSets requestIsAveragePricePacingField() {
            return this.requestIsAveragePricePacingField(true);
        }

        public APIRequestGetAdSets requestIsAveragePricePacingField(boolean value) {
            this.requestField("is_average_price_pacing", value);
            return this;
        }

        public APIRequestGetAdSets requestLifetimeBudgetField() {
            return this.requestLifetimeBudgetField(true);
        }

        public APIRequestGetAdSets requestLifetimeBudgetField(boolean value) {
            this.requestField("lifetime_budget", value);
            return this;
        }

        public APIRequestGetAdSets requestLifetimeFrequencyCapField() {
            return this.requestLifetimeFrequencyCapField(true);
        }

        public APIRequestGetAdSets requestLifetimeFrequencyCapField(boolean value) {
            this.requestField("lifetime_frequency_cap", value);
            return this;
        }

        public APIRequestGetAdSets requestLifetimeImpsField() {
            return this.requestLifetimeImpsField(true);
        }

        public APIRequestGetAdSets requestLifetimeImpsField(boolean value) {
            this.requestField("lifetime_imps", value);
            return this;
        }

        public APIRequestGetAdSets requestNameField() {
            return this.requestNameField(true);
        }

        public APIRequestGetAdSets requestNameField(boolean value) {
            this.requestField("name", value);
            return this;
        }

        public APIRequestGetAdSets requestOptimizationGoalField() {
            return this.requestOptimizationGoalField(true);
        }

        public APIRequestGetAdSets requestOptimizationGoalField(boolean value) {
            this.requestField("optimization_goal", value);
            return this;
        }

        public APIRequestGetAdSets requestPacingTypeField() {
            return this.requestPacingTypeField(true);
        }

        public APIRequestGetAdSets requestPacingTypeField(boolean value) {
            this.requestField("pacing_type", value);
            return this;
        }

        public APIRequestGetAdSets requestPromotedObjectField() {
            return this.requestPromotedObjectField(true);
        }

        public APIRequestGetAdSets requestPromotedObjectField(boolean value) {
            this.requestField("promoted_object", value);
            return this;
        }

        public APIRequestGetAdSets requestRecommendationsField() {
            return this.requestRecommendationsField(true);
        }

        public APIRequestGetAdSets requestRecommendationsField(boolean value) {
            this.requestField("recommendations", value);
            return this;
        }

        public APIRequestGetAdSets requestRecurringBudgetSemanticsField() {
            return this.requestRecurringBudgetSemanticsField(true);
        }

        public APIRequestGetAdSets requestRecurringBudgetSemanticsField(boolean value) {
            this.requestField("recurring_budget_semantics", value);
            return this;
        }

        public APIRequestGetAdSets requestRfPredictionIdField() {
            return this.requestRfPredictionIdField(true);
        }

        public APIRequestGetAdSets requestRfPredictionIdField(boolean value) {
            this.requestField("rf_prediction_id", value);
            return this;
        }

        public APIRequestGetAdSets requestRtbFlagField() {
            return this.requestRtbFlagField(true);
        }

        public APIRequestGetAdSets requestRtbFlagField(boolean value) {
            this.requestField("rtb_flag", value);
            return this;
        }

        public APIRequestGetAdSets requestStartTimeField() {
            return this.requestStartTimeField(true);
        }

        public APIRequestGetAdSets requestStartTimeField(boolean value) {
            this.requestField("start_time", value);
            return this;
        }

        public APIRequestGetAdSets requestStatusField() {
            return this.requestStatusField(true);
        }

        public APIRequestGetAdSets requestStatusField(boolean value) {
            this.requestField("status", value);
            return this;
        }

        public APIRequestGetAdSets requestTargetingField() {
            return this.requestTargetingField(true);
        }

        public APIRequestGetAdSets requestTargetingField(boolean value) {
            this.requestField("targeting", value);
            return this;
        }

        public APIRequestGetAdSets requestTimeBasedAdRotationIdBlocksField() {
            return this.requestTimeBasedAdRotationIdBlocksField(true);
        }

        public APIRequestGetAdSets requestTimeBasedAdRotationIdBlocksField(boolean value) {
            this.requestField("time_based_ad_rotation_id_blocks", value);
            return this;
        }

        public APIRequestGetAdSets requestTimeBasedAdRotationIntervalsField() {
            return this.requestTimeBasedAdRotationIntervalsField(true);
        }

        public APIRequestGetAdSets requestTimeBasedAdRotationIntervalsField(boolean value) {
            this.requestField("time_based_ad_rotation_intervals", value);
            return this;
        }

        public APIRequestGetAdSets requestUpdatedTimeField() {
            return this.requestUpdatedTimeField(true);
        }

        public APIRequestGetAdSets requestUpdatedTimeField(boolean value) {
            this.requestField("updated_time", value);
            return this;
        }

        public APIRequestGetAdSets requestUseNewAppClickField() {
            return this.requestUseNewAppClickField(true);
        }

        public APIRequestGetAdSets requestUseNewAppClickField(boolean value) {
            this.requestField("use_new_app_click", value);
            return this;
        }

        public APIRequestGetAdSets requestViewThroughAttributionWindowDaysField() {
            return this.requestViewThroughAttributionWindowDaysField(true);
        }

        public APIRequestGetAdSets requestViewThroughAttributionWindowDaysField(boolean value) {
            this.requestField("view_through_attribution_window_days", value);
            return this;
        }
    }

    public static class APIRequestGetInsights extends APIRequest<AdsInsights> {

        APINodeList<AdsInsights> lastResponse = null;

        @Override
        public APINodeList<AdsInsights> getLastResponse() {
            return lastResponse;
        }

        public static final String[] PARAMS = { "action_attribution_windows", "action_breakdowns",
                "action_report_time", "breakdowns", "date_preset", "default_summary", "export_columns",
                "export_format", "export_name", "fields", "filtering", "level", "product_id_limit", "sort",
                "summary", "summary_action_breakdowns", "time_increment", "time_range", "time_ranges", };

        public static final String[] FIELDS = {};

        @Override
        public APINodeList<AdsInsights> parseResponse(String response) throws APIException {
            return AdsInsights.parseResponse(response, getContext(), this);
        }

        @Override
        public APINodeList<AdsInsights> execute() throws APIException {
            return execute(new HashMap<String, Object>());
        }

        @Override
        public APINodeList<AdsInsights> execute(Map<String, Object> extraParams) throws APIException {
            lastResponse = parseResponse(executeInternal(extraParams));
            return lastResponse;
        }

        public APIRequestGetInsights(String nodeId, APIContext context) {
            super(context, nodeId, "/insights", "GET", Arrays.asList(PARAMS));
        }

        @Override
        public APIRequestGetInsights setParam(String param, Object value) {
            setParamInternal(param, value);
            return this;
        }

        @Override
        public APIRequestGetInsights setParams(Map<String, Object> params) {
            setParamsInternal(params);
            return this;
        }

        public APIRequestGetInsights setActionAttributionWindows(
                List<AdsInsights.EnumActionAttributionWindows> actionAttributionWindows) {
            this.setParam("action_attribution_windows", actionAttributionWindows);
            return this;
        }

        public APIRequestGetInsights setActionAttributionWindows(String actionAttributionWindows) {
            this.setParam("action_attribution_windows", actionAttributionWindows);
            return this;
        }

        public APIRequestGetInsights setActionBreakdowns(List<AdsInsights.EnumActionBreakdowns> actionBreakdowns) {
            this.setParam("action_breakdowns", actionBreakdowns);
            return this;
        }

        public APIRequestGetInsights setActionBreakdowns(String actionBreakdowns) {
            this.setParam("action_breakdowns", actionBreakdowns);
            return this;
        }

        public APIRequestGetInsights setActionReportTime(AdsInsights.EnumActionReportTime actionReportTime) {
            this.setParam("action_report_time", actionReportTime);
            return this;
        }

        public APIRequestGetInsights setActionReportTime(String actionReportTime) {
            this.setParam("action_report_time", actionReportTime);
            return this;
        }

        public APIRequestGetInsights setBreakdowns(List<AdsInsights.EnumBreakdowns> breakdowns) {
            this.setParam("breakdowns", breakdowns);
            return this;
        }

        public APIRequestGetInsights setBreakdowns(String breakdowns) {
            this.setParam("breakdowns", breakdowns);
            return this;
        }

        public APIRequestGetInsights setDatePreset(AdsInsights.EnumDatePreset datePreset) {
            this.setParam("date_preset", datePreset);
            return this;
        }

        public APIRequestGetInsights setDatePreset(String datePreset) {
            this.setParam("date_preset", datePreset);
            return this;
        }

        public APIRequestGetInsights setDefaultSummary(Boolean defaultSummary) {
            this.setParam("default_summary", defaultSummary);
            return this;
        }

        public APIRequestGetInsights setDefaultSummary(String defaultSummary) {
            this.setParam("default_summary", defaultSummary);
            return this;
        }

        public APIRequestGetInsights setExportColumns(List<String> exportColumns) {
            this.setParam("export_columns", exportColumns);
            return this;
        }

        public APIRequestGetInsights setExportColumns(String exportColumns) {
            this.setParam("export_columns", exportColumns);
            return this;
        }

        public APIRequestGetInsights setExportFormat(String exportFormat) {
            this.setParam("export_format", exportFormat);
            return this;
        }

        public APIRequestGetInsights setExportName(String exportName) {
            this.setParam("export_name", exportName);
            return this;
        }

        public APIRequestGetInsights setFields(List<AdsInsights.EnumSummary> fields) {
            this.setParam("fields", fields);
            return this;
        }

        public APIRequestGetInsights setFields(String fields) {
            this.setParam("fields", fields);
            return this;
        }

        public APIRequestGetInsights setFiltering(List<Object> filtering) {
            this.setParam("filtering", filtering);
            return this;
        }

        public APIRequestGetInsights setFiltering(String filtering) {
            this.setParam("filtering", filtering);
            return this;
        }

        public APIRequestGetInsights setLevel(AdsInsights.EnumLevel level) {
            this.setParam("level", level);
            return this;
        }

        public APIRequestGetInsights setLevel(String level) {
            this.setParam("level", level);
            return this;
        }

        public APIRequestGetInsights setProductIdLimit(Long productIdLimit) {
            this.setParam("product_id_limit", productIdLimit);
            return this;
        }

        public APIRequestGetInsights setProductIdLimit(String productIdLimit) {
            this.setParam("product_id_limit", productIdLimit);
            return this;
        }

        public APIRequestGetInsights setSort(List<String> sort) {
            this.setParam("sort", sort);
            return this;
        }

        public APIRequestGetInsights setSort(String sort) {
            this.setParam("sort", sort);
            return this;
        }

        public APIRequestGetInsights setSummary(List<AdsInsights.EnumSummary> summary) {
            this.setParam("summary", summary);
            return this;
        }

        public APIRequestGetInsights setSummary(String summary) {
            this.setParam("summary", summary);
            return this;
        }

        public APIRequestGetInsights setSummaryActionBreakdowns(
                List<AdsInsights.EnumSummaryActionBreakdowns> summaryActionBreakdowns) {
            this.setParam("summary_action_breakdowns", summaryActionBreakdowns);
            return this;
        }

        public APIRequestGetInsights setSummaryActionBreakdowns(String summaryActionBreakdowns) {
            this.setParam("summary_action_breakdowns", summaryActionBreakdowns);
            return this;
        }

        public APIRequestGetInsights setTimeIncrement(String timeIncrement) {
            this.setParam("time_increment", timeIncrement);
            return this;
        }

        public APIRequestGetInsights setTimeRange(Object timeRange) {
            this.setParam("time_range", timeRange);
            return this;
        }

        public APIRequestGetInsights setTimeRange(String timeRange) {
            this.setParam("time_range", timeRange);
            return this;
        }

        public APIRequestGetInsights setTimeRanges(List<Object> timeRanges) {
            this.setParam("time_ranges", timeRanges);
            return this;
        }

        public APIRequestGetInsights setTimeRanges(String timeRanges) {
            this.setParam("time_ranges", timeRanges);
            return this;
        }

        public APIRequestGetInsights requestAllFields() {
            return this.requestAllFields(true);
        }

        public APIRequestGetInsights requestAllFields(boolean value) {
            for (String field : FIELDS) {
                this.requestField(field, value);
            }
            return this;
        }

        @Override
        public APIRequestGetInsights requestFields(List<String> fields) {
            return this.requestFields(fields, true);
        }

        @Override
        public APIRequestGetInsights requestFields(List<String> fields, boolean value) {
            for (String field : fields) {
                this.requestField(field, value);
            }
            return this;
        }

        @Override
        public APIRequestGetInsights requestField(String field) {
            this.requestField(field, true);
            return this;
        }

        @Override
        public APIRequestGetInsights requestField(String field, boolean value) {
            this.requestFieldInternal(field, value);
            return this;
        }

    }

    public static class APIRequestGetInsightsAsync extends APIRequest<AdReportRun> {

        APINodeList<AdReportRun> lastResponse = null;

        @Override
        public APINodeList<AdReportRun> getLastResponse() {
            return lastResponse;
        }

        public static final String[] PARAMS = { "action_attribution_windows", "action_breakdowns",
                "action_report_time", "breakdowns", "date_preset", "default_summary", "export_columns",
                "export_format", "export_name", "fields", "filtering", "level", "product_id_limit", "sort",
                "summary", "summary_action_breakdowns", "time_increment", "time_range", "time_ranges", };

        public static final String[] FIELDS = {};

        @Override
        public APINodeList<AdReportRun> parseResponse(String response) throws APIException {
            return AdReportRun.parseResponse(response, getContext(), this);
        }

        @Override
        public APINodeList<AdReportRun> execute() throws APIException {
            return execute(new HashMap<String, Object>());
        }

        @Override
        public APINodeList<AdReportRun> execute(Map<String, Object> extraParams) throws APIException {
            lastResponse = parseResponse(executeInternal(extraParams));
            return lastResponse;
        }

        public APIRequestGetInsightsAsync(String nodeId, APIContext context) {
            super(context, nodeId, "/insights", "POST", Arrays.asList(PARAMS));
        }

        @Override
        public APIRequestGetInsightsAsync setParam(String param, Object value) {
            setParamInternal(param, value);
            return this;
        }

        @Override
        public APIRequestGetInsightsAsync setParams(Map<String, Object> params) {
            setParamsInternal(params);
            return this;
        }

        public APIRequestGetInsightsAsync setActionAttributionWindows(
                List<AdsInsights.EnumActionAttributionWindows> actionAttributionWindows) {
            this.setParam("action_attribution_windows", actionAttributionWindows);
            return this;
        }

        public APIRequestGetInsightsAsync setActionAttributionWindows(String actionAttributionWindows) {
            this.setParam("action_attribution_windows", actionAttributionWindows);
            return this;
        }

        public APIRequestGetInsightsAsync setActionBreakdowns(
                List<AdsInsights.EnumActionBreakdowns> actionBreakdowns) {
            this.setParam("action_breakdowns", actionBreakdowns);
            return this;
        }

        public APIRequestGetInsightsAsync setActionBreakdowns(String actionBreakdowns) {
            this.setParam("action_breakdowns", actionBreakdowns);
            return this;
        }

        public APIRequestGetInsightsAsync setActionReportTime(AdsInsights.EnumActionReportTime actionReportTime) {
            this.setParam("action_report_time", actionReportTime);
            return this;
        }

        public APIRequestGetInsightsAsync setActionReportTime(String actionReportTime) {
            this.setParam("action_report_time", actionReportTime);
            return this;
        }

        public APIRequestGetInsightsAsync setBreakdowns(List<AdsInsights.EnumBreakdowns> breakdowns) {
            this.setParam("breakdowns", breakdowns);
            return this;
        }

        public APIRequestGetInsightsAsync setBreakdowns(String breakdowns) {
            this.setParam("breakdowns", breakdowns);
            return this;
        }

        public APIRequestGetInsightsAsync setDatePreset(AdsInsights.EnumDatePreset datePreset) {
            this.setParam("date_preset", datePreset);
            return this;
        }

        public APIRequestGetInsightsAsync setDatePreset(String datePreset) {
            this.setParam("date_preset", datePreset);
            return this;
        }

        public APIRequestGetInsightsAsync setDefaultSummary(Boolean defaultSummary) {
            this.setParam("default_summary", defaultSummary);
            return this;
        }

        public APIRequestGetInsightsAsync setDefaultSummary(String defaultSummary) {
            this.setParam("default_summary", defaultSummary);
            return this;
        }

        public APIRequestGetInsightsAsync setExportColumns(List<String> exportColumns) {
            this.setParam("export_columns", exportColumns);
            return this;
        }

        public APIRequestGetInsightsAsync setExportColumns(String exportColumns) {
            this.setParam("export_columns", exportColumns);
            return this;
        }

        public APIRequestGetInsightsAsync setExportFormat(String exportFormat) {
            this.setParam("export_format", exportFormat);
            return this;
        }

        public APIRequestGetInsightsAsync setExportName(String exportName) {
            this.setParam("export_name", exportName);
            return this;
        }

        public APIRequestGetInsightsAsync setFields(List<AdsInsights.EnumSummary> fields) {
            this.setParam("fields", fields);
            return this;
        }

        public APIRequestGetInsightsAsync setFields(String fields) {
            this.setParam("fields", fields);
            return this;
        }

        public APIRequestGetInsightsAsync setFiltering(List<Object> filtering) {
            this.setParam("filtering", filtering);
            return this;
        }

        public APIRequestGetInsightsAsync setFiltering(String filtering) {
            this.setParam("filtering", filtering);
            return this;
        }

        public APIRequestGetInsightsAsync setLevel(AdsInsights.EnumLevel level) {
            this.setParam("level", level);
            return this;
        }

        public APIRequestGetInsightsAsync setLevel(String level) {
            this.setParam("level", level);
            return this;
        }

        public APIRequestGetInsightsAsync setProductIdLimit(Long productIdLimit) {
            this.setParam("product_id_limit", productIdLimit);
            return this;
        }

        public APIRequestGetInsightsAsync setProductIdLimit(String productIdLimit) {
            this.setParam("product_id_limit", productIdLimit);
            return this;
        }

        public APIRequestGetInsightsAsync setSort(List<String> sort) {
            this.setParam("sort", sort);
            return this;
        }

        public APIRequestGetInsightsAsync setSort(String sort) {
            this.setParam("sort", sort);
            return this;
        }

        public APIRequestGetInsightsAsync setSummary(List<AdsInsights.EnumSummary> summary) {
            this.setParam("summary", summary);
            return this;
        }

        public APIRequestGetInsightsAsync setSummary(String summary) {
            this.setParam("summary", summary);
            return this;
        }

        public APIRequestGetInsightsAsync setSummaryActionBreakdowns(
                List<AdsInsights.EnumSummaryActionBreakdowns> summaryActionBreakdowns) {
            this.setParam("summary_action_breakdowns", summaryActionBreakdowns);
            return this;
        }

        public APIRequestGetInsightsAsync setSummaryActionBreakdowns(String summaryActionBreakdowns) {
            this.setParam("summary_action_breakdowns", summaryActionBreakdowns);
            return this;
        }

        public APIRequestGetInsightsAsync setTimeIncrement(String timeIncrement) {
            this.setParam("time_increment", timeIncrement);
            return this;
        }

        public APIRequestGetInsightsAsync setTimeRange(Object timeRange) {
            this.setParam("time_range", timeRange);
            return this;
        }

        public APIRequestGetInsightsAsync setTimeRange(String timeRange) {
            this.setParam("time_range", timeRange);
            return this;
        }

        public APIRequestGetInsightsAsync setTimeRanges(List<Object> timeRanges) {
            this.setParam("time_ranges", timeRanges);
            return this;
        }

        public APIRequestGetInsightsAsync setTimeRanges(String timeRanges) {
            this.setParam("time_ranges", timeRanges);
            return this;
        }

        public APIRequestGetInsightsAsync requestAllFields() {
            return this.requestAllFields(true);
        }

        public APIRequestGetInsightsAsync requestAllFields(boolean value) {
            for (String field : FIELDS) {
                this.requestField(field, value);
            }
            return this;
        }

        @Override
        public APIRequestGetInsightsAsync requestFields(List<String> fields) {
            return this.requestFields(fields, true);
        }

        @Override
        public APIRequestGetInsightsAsync requestFields(List<String> fields, boolean value) {
            for (String field : fields) {
                this.requestField(field, value);
            }
            return this;
        }

        @Override
        public APIRequestGetInsightsAsync requestField(String field) {
            this.requestField(field, true);
            return this;
        }

        @Override
        public APIRequestGetInsightsAsync requestField(String field, boolean value) {
            this.requestFieldInternal(field, value);
            return this;
        }

    }

    public static class APIRequestDelete extends APIRequest<APINode> {

        APINode lastResponse = null;

        @Override
        public APINode getLastResponse() {
            return lastResponse;
        }

        public static final String[] PARAMS = {};

        public static final String[] FIELDS = {};

        @Override
        public APINode parseResponse(String response) throws APIException {
            return APINode.parseResponse(response, getContext(), this).head();
        }

        @Override
        public APINode execute() throws APIException {
            return execute(new HashMap<String, Object>());
        }

        @Override
        public APINode execute(Map<String, Object> extraParams) throws APIException {
            lastResponse = parseResponse(executeInternal(extraParams));
            return lastResponse;
        }

        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<String, Object> params) {
            setParamsInternal(params);
            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<String> fields) {
            return this.requestFields(fields, true);
        }

        @Override
        public APIRequestDelete requestFields(List<String> 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<Campaign> {

        Campaign lastResponse = null;

        @Override
        public Campaign getLastResponse() {
            return lastResponse;
        }

        public static final String[] PARAMS = {};

        public static final String[] FIELDS = { "account_id", "adlabels", "brand_lift_studies",
                "budget_rebalance_flag", "buying_type", "can_create_brand_lift_study", "can_use_spend_cap",
                "configured_status", "created_time", "effective_status", "id", "name", "objective",
                "recommendations", "spend_cap", "start_time", "status", "stop_time", "updated_time", };

        @Override
        public Campaign parseResponse(String response) throws APIException {
            return Campaign.parseResponse(response, getContext(), this).head();
        }

        @Override
        public Campaign execute() throws APIException {
            return execute(new HashMap<String, Object>());
        }

        @Override
        public Campaign execute(Map<String, Object> extraParams) throws APIException {
            lastResponse = parseResponse(executeInternal(extraParams));
            return lastResponse;
        }

        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<String, Object> 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<String> fields) {
            return this.requestFields(fields, true);
        }

        @Override
        public APIRequestGet requestFields(List<String> 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 requestAccountIdField() {
            return this.requestAccountIdField(true);
        }

        public APIRequestGet requestAccountIdField(boolean value) {
            this.requestField("account_id", value);
            return this;
        }

        public APIRequestGet requestAdlabelsField() {
            return this.requestAdlabelsField(true);
        }

        public APIRequestGet requestAdlabelsField(boolean value) {
            this.requestField("adlabels", value);
            return this;
        }

        public APIRequestGet requestBrandLiftStudiesField() {
            return this.requestBrandLiftStudiesField(true);
        }

        public APIRequestGet requestBrandLiftStudiesField(boolean value) {
            this.requestField("brand_lift_studies", value);
            return this;
        }

        public APIRequestGet requestBudgetRebalanceFlagField() {
            return this.requestBudgetRebalanceFlagField(true);
        }

        public APIRequestGet requestBudgetRebalanceFlagField(boolean value) {
            this.requestField("budget_rebalance_flag", value);
            return this;
        }

        public APIRequestGet requestBuyingTypeField() {
            return this.requestBuyingTypeField(true);
        }

        public APIRequestGet requestBuyingTypeField(boolean value) {
            this.requestField("buying_type", value);
            return this;
        }

        public APIRequestGet requestCanCreateBrandLiftStudyField() {
            return this.requestCanCreateBrandLiftStudyField(true);
        }

        public APIRequestGet requestCanCreateBrandLiftStudyField(boolean value) {
            this.requestField("can_create_brand_lift_study", value);
            return this;
        }

        public APIRequestGet requestCanUseSpendCapField() {
            return this.requestCanUseSpendCapField(true);
        }

        public APIRequestGet requestCanUseSpendCapField(boolean value) {
            this.requestField("can_use_spend_cap", value);
            return this;
        }

        public APIRequestGet requestConfiguredStatusField() {
            return this.requestConfiguredStatusField(true);
        }

        public APIRequestGet requestConfiguredStatusField(boolean value) {
            this.requestField("configured_status", value);
            return this;
        }

        public APIRequestGet requestCreatedTimeField() {
            return this.requestCreatedTimeField(true);
        }

        public APIRequestGet requestCreatedTimeField(boolean value) {
            this.requestField("created_time", value);
            return this;
        }

        public APIRequestGet requestEffectiveStatusField() {
            return this.requestEffectiveStatusField(true);
        }

        public APIRequestGet requestEffectiveStatusField(boolean value) {
            this.requestField("effective_status", value);
            return this;
        }

        public APIRequestGet requestIdField() {
            return this.requestIdField(true);
        }

        public APIRequestGet requestIdField(boolean value) {
            this.requestField("id", value);
            return this;
        }

        public APIRequestGet requestNameField() {
            return this.requestNameField(true);
        }

        public APIRequestGet requestNameField(boolean value) {
            this.requestField("name", value);
            return this;
        }

        public APIRequestGet requestObjectiveField() {
            return this.requestObjectiveField(true);
        }

        public APIRequestGet requestObjectiveField(boolean value) {
            this.requestField("objective", value);
            return this;
        }

        public APIRequestGet requestRecommendationsField() {
            return this.requestRecommendationsField(true);
        }

        public APIRequestGet requestRecommendationsField(boolean value) {
            this.requestField("recommendations", value);
            return this;
        }

        public APIRequestGet requestSpendCapField() {
            return this.requestSpendCapField(true);
        }

        public APIRequestGet requestSpendCapField(boolean value) {
            this.requestField("spend_cap", value);
            return this;
        }

        public APIRequestGet requestStartTimeField() {
            return this.requestStartTimeField(true);
        }

        public APIRequestGet requestStartTimeField(boolean value) {
            this.requestField("start_time", value);
            return this;
        }

        public APIRequestGet requestStatusField() {
            return this.requestStatusField(true);
        }

        public APIRequestGet requestStatusField(boolean value) {
            this.requestField("status", value);
            return this;
        }

        public APIRequestGet requestStopTimeField() {
            return this.requestStopTimeField(true);
        }

        public APIRequestGet requestStopTimeField(boolean value) {
            this.requestField("stop_time", value);
            return this;
        }

        public APIRequestGet requestUpdatedTimeField() {
            return this.requestUpdatedTimeField(true);
        }

        public APIRequestGet requestUpdatedTimeField(boolean value) {
            this.requestField("updated_time", value);
            return this;
        }
    }

    public static class APIRequestUpdate extends APIRequest<Campaign> {

        Campaign lastResponse = null;

        @Override
        public Campaign getLastResponse() {
            return lastResponse;
        }

        public static final String[] PARAMS = { "adlabels", "budget_rebalance_flag", "execution_options", "name",
                "objective", "promoted_object", "spend_cap", "status", };

        public static final String[] FIELDS = {};

        @Override
        public Campaign parseResponse(String response) throws APIException {
            return Campaign.parseResponse(response, getContext(), this).head();
        }

        @Override
        public Campaign execute() throws APIException {
            return execute(new HashMap<String, Object>());
        }

        @Override
        public Campaign execute(Map<String, Object> extraParams) throws APIException {
            lastResponse = parseResponse(executeInternal(extraParams));
            return lastResponse;
        }

        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<String, Object> params) {
            setParamsInternal(params);
            return this;
        }

        public APIRequestUpdate setAdlabels(List<Object> adlabels) {
            this.setParam("adlabels", adlabels);
            return this;
        }

        public APIRequestUpdate setAdlabels(String adlabels) {
            this.setParam("adlabels", adlabels);
            return this;
        }

        public APIRequestUpdate setBudgetRebalanceFlag(Boolean budgetRebalanceFlag) {
            this.setParam("budget_rebalance_flag", budgetRebalanceFlag);
            return this;
        }

        public APIRequestUpdate setBudgetRebalanceFlag(String budgetRebalanceFlag) {
            this.setParam("budget_rebalance_flag", budgetRebalanceFlag);
            return this;
        }

        public APIRequestUpdate setExecutionOptions(List<Campaign.EnumExecutionOptions> executionOptions) {
            this.setParam("execution_options", executionOptions);
            return this;
        }

        public APIRequestUpdate setExecutionOptions(String executionOptions) {
            this.setParam("execution_options", executionOptions);
            return this;
        }

        public APIRequestUpdate setName(String name) {
            this.setParam("name", name);
            return this;
        }

        public APIRequestUpdate setObjective(Campaign.EnumObjective objective) {
            this.setParam("objective", objective);
            return this;
        }

        public APIRequestUpdate setObjective(String objective) {
            this.setParam("objective", objective);
            return this;
        }

        public APIRequestUpdate setPromotedObject(Object promotedObject) {
            this.setParam("promoted_object", promotedObject);
            return this;
        }

        public APIRequestUpdate setPromotedObject(String promotedObject) {
            this.setParam("promoted_object", promotedObject);
            return this;
        }

        public APIRequestUpdate setSpendCap(Long spendCap) {
            this.setParam("spend_cap", spendCap);
            return this;
        }

        public APIRequestUpdate setSpendCap(String spendCap) {
            this.setParam("spend_cap", spendCap);
            return this;
        }

        public APIRequestUpdate setStatus(Campaign.EnumStatus status) {
            this.setParam("status", status);
            return this;
        }

        public APIRequestUpdate setStatus(String status) {
            this.setParam("status", status);
            return this;
        }

        public APIRequestUpdate requestAllFields() {
            return this.requestAllFields(true);
        }

        public APIRequestUpdate requestAllFields(boolean value) {
            for (String field : FIELDS) {
                this.requestField(field, value);
            }
            return this;
        }

        @Override
        public APIRequestUpdate requestFields(List<String> fields) {
            return this.requestFields(fields, true);
        }

        @Override
        public APIRequestUpdate requestFields(List<String> fields, boolean value) {
            for (String field : fields) {
                this.requestField(field, value);
            }
            return this;
        }

        @Override
        public APIRequestUpdate requestField(String field) {
            this.requestField(field, true);
            return this;
        }

        @Override
        public APIRequestUpdate requestField(String field, boolean value) {
            this.requestFieldInternal(field, value);
            return this;
        }

    }

    public static enum EnumConfiguredStatus {
        @SerializedName("ACTIVE")
        VALUE_ACTIVE("ACTIVE"), @SerializedName("PAUSED")
        VALUE_PAUSED("PAUSED"), @SerializedName("DELETED")
        VALUE_DELETED("DELETED"), @SerializedName("ARCHIVED")
        VALUE_ARCHIVED("ARCHIVED"), NULL(null);

        private String value;

        private EnumConfiguredStatus(String value) {
            this.value = value;
        }

        @Override
        public String toString() {
            return value;
        }
    }

    public static enum EnumEffectiveStatus {
        @SerializedName("ACTIVE")
        VALUE_ACTIVE("ACTIVE"), @SerializedName("PAUSED")
        VALUE_PAUSED("PAUSED"), @SerializedName("DELETED")
        VALUE_DELETED("DELETED"), @SerializedName("PENDING_REVIEW")
        VALUE_PENDING_REVIEW("PENDING_REVIEW"), @SerializedName("DISAPPROVED")
        VALUE_DISAPPROVED("DISAPPROVED"), @SerializedName("PREAPPROVED")
        VALUE_PREAPPROVED("PREAPPROVED"), @SerializedName("PENDING_BILLING_INFO")
        VALUE_PENDING_BILLING_INFO("PENDING_BILLING_INFO"), @SerializedName("CAMPAIGN_PAUSED")
        VALUE_CAMPAIGN_PAUSED("CAMPAIGN_PAUSED"), @SerializedName("ARCHIVED")
        VALUE_ARCHIVED("ARCHIVED"), @SerializedName("ADSET_PAUSED")
        VALUE_ADSET_PAUSED("ADSET_PAUSED"), NULL(null);

        private String value;

        private EnumEffectiveStatus(String value) {
            this.value = value;
        }

        @Override
        public String toString() {
            return value;
        }
    }

    public static enum EnumStatus {
        @SerializedName("ACTIVE")
        VALUE_ACTIVE("ACTIVE"), @SerializedName("PAUSED")
        VALUE_PAUSED("PAUSED"), @SerializedName("DELETED")
        VALUE_DELETED("DELETED"), @SerializedName("ARCHIVED")
        VALUE_ARCHIVED("ARCHIVED"), NULL(null);

        private String value;

        private EnumStatus(String value) {
            this.value = value;
        }

        @Override
        public String toString() {
            return value;
        }
    }

    public static enum EnumDatePreset {
        @SerializedName("today")
        VALUE_TODAY("today"), @SerializedName("yesterday")
        VALUE_YESTERDAY("yesterday"), @SerializedName("last_3_days")
        VALUE_LAST_3_DAYS("last_3_days"), @SerializedName("this_week")
        VALUE_THIS_WEEK("this_week"), @SerializedName("last_week")
        VALUE_LAST_WEEK("last_week"), @SerializedName("last_7_days")
        VALUE_LAST_7_DAYS("last_7_days"), @SerializedName("last_14_days")
        VALUE_LAST_14_DAYS("last_14_days"), @SerializedName("last_28_days")
        VALUE_LAST_28_DAYS("last_28_days"), @SerializedName("last_30_days")
        VALUE_LAST_30_DAYS("last_30_days"), @SerializedName("last_90_days")
        VALUE_LAST_90_DAYS("last_90_days"), @SerializedName("this_month")
        VALUE_THIS_MONTH("this_month"), @SerializedName("last_month")
        VALUE_LAST_MONTH("last_month"), @SerializedName("this_quarter")
        VALUE_THIS_QUARTER("this_quarter"), @SerializedName("last_3_months")
        VALUE_LAST_3_MONTHS("last_3_months"), @SerializedName("lifetime")
        VALUE_LIFETIME("lifetime"), NULL(null);

        private String value;

        private EnumDatePreset(String value) {
            this.value = value;
        }

        @Override
        public String toString() {
            return value;
        }
    }

    public static enum EnumDeleteStrategy {
        @SerializedName("DELETE_ANY")
        VALUE_DELETE_ANY("DELETE_ANY"), @SerializedName("DELETE_OLDEST")
        VALUE_DELETE_OLDEST("DELETE_OLDEST"), @SerializedName("DELETE_ARCHIVED_BEFORE")
        VALUE_DELETE_ARCHIVED_BEFORE("DELETE_ARCHIVED_BEFORE"), NULL(null);

        private String value;

        private EnumDeleteStrategy(String value) {
            this.value = value;
        }

        @Override
        public String toString() {
            return value;
        }
    }

    public static enum EnumExecutionOptions {
        @SerializedName("validate_only")
        VALUE_VALIDATE_ONLY("validate_only"), @SerializedName("include_recommendations")
        VALUE_INCLUDE_RECOMMENDATIONS("include_recommendations"), NULL(null);

        private String value;

        private EnumExecutionOptions(String value) {
            this.value = value;
        }

        @Override
        public String toString() {
            return value;
        }
    }

    public static enum EnumObjective {
        @SerializedName("APP_INSTALLS")
        VALUE_APP_INSTALLS("APP_INSTALLS"), @SerializedName("BRAND_AWARENESS")
        VALUE_BRAND_AWARENESS("BRAND_AWARENESS"), @SerializedName("CANVAS_APP_ENGAGEMENT")
        VALUE_CANVAS_APP_ENGAGEMENT("CANVAS_APP_ENGAGEMENT"), @SerializedName("CANVAS_APP_INSTALLS")
        VALUE_CANVAS_APP_INSTALLS("CANVAS_APP_INSTALLS"), @SerializedName("CONVERSIONS")
        VALUE_CONVERSIONS("CONVERSIONS"), @SerializedName("EVENT_RESPONSES")
        VALUE_EVENT_RESPONSES("EVENT_RESPONSES"), @SerializedName("LEAD_GENERATION")
        VALUE_LEAD_GENERATION("LEAD_GENERATION"), @SerializedName("LINK_CLICKS")
        VALUE_LINK_CLICKS("LINK_CLICKS"), @SerializedName("LOCAL_AWARENESS")
        VALUE_LOCAL_AWARENESS("LOCAL_AWARENESS"), @SerializedName("MOBILE_APP_ENGAGEMENT")
        VALUE_MOBILE_APP_ENGAGEMENT("MOBILE_APP_ENGAGEMENT"), @SerializedName("MOBILE_APP_INSTALLS")
        VALUE_MOBILE_APP_INSTALLS("MOBILE_APP_INSTALLS"), @SerializedName("OFFER_CLAIMS")
        VALUE_OFFER_CLAIMS("OFFER_CLAIMS"), @SerializedName("PAGE_LIKES")
        VALUE_PAGE_LIKES("PAGE_LIKES"), @SerializedName("POST_ENGAGEMENT")
        VALUE_POST_ENGAGEMENT("POST_ENGAGEMENT"), @SerializedName("PRODUCT_CATALOG_SALES")
        VALUE_PRODUCT_CATALOG_SALES("PRODUCT_CATALOG_SALES"), @SerializedName("REACH")
        VALUE_REACH("REACH"), @SerializedName("VIDEO_VIEWS")
        VALUE_VIDEO_VIEWS("VIDEO_VIEWS"), NULL(null);

        private String value;

        private EnumObjective(String value) {
            this.value = value;
        }

        @Override
        public String toString() {
            return value;
        }
    }

    public static enum EnumOperator {
        @SerializedName("ALL")
        VALUE_ALL("ALL"), @SerializedName("ANY")
        VALUE_ANY("ANY"), NULL(null);

        private String value;

        private EnumOperator(String value) {
            this.value = value;
        }

        @Override
        public String toString() {
            return value;
        }
    }

    synchronized /*package*/ static Gson getGson() {
        if (gson != null) {
            return gson;
        } else {
            gson = new GsonBuilder().excludeFieldsWithModifiers(Modifier.STATIC)
                    .excludeFieldsWithModifiers(Modifier.PROTECTED).disableHtmlEscaping().create();
        }
        return gson;
    }

    public Campaign copyFrom(Campaign instance) {
        this.mAccountId = instance.mAccountId;
        this.mAdlabels = instance.mAdlabels;
        this.mBrandLiftStudies = instance.mBrandLiftStudies;
        this.mBudgetRebalanceFlag = instance.mBudgetRebalanceFlag;
        this.mBuyingType = instance.mBuyingType;
        this.mCanCreateBrandLiftStudy = instance.mCanCreateBrandLiftStudy;
        this.mCanUseSpendCap = instance.mCanUseSpendCap;
        this.mConfiguredStatus = instance.mConfiguredStatus;
        this.mCreatedTime = instance.mCreatedTime;
        this.mEffectiveStatus = instance.mEffectiveStatus;
        this.mId = instance.mId;
        this.mName = instance.mName;
        this.mObjective = instance.mObjective;
        this.mRecommendations = instance.mRecommendations;
        this.mSpendCap = instance.mSpendCap;
        this.mStartTime = instance.mStartTime;
        this.mStatus = instance.mStatus;
        this.mStopTime = instance.mStopTime;
        this.mUpdatedTime = instance.mUpdatedTime;
        this.context = instance.context;
        this.rawValue = instance.rawValue;
        return this;
    }

    public static APIRequest.ResponseParser<Campaign> getParser() {
        return new APIRequest.ResponseParser<Campaign>() {
            public APINodeList<Campaign> parseResponse(String response, APIContext context,
                    APIRequest<Campaign> request) throws MalformedResponseException {
                return Campaign.parseResponse(response, context, request);
            }
        };
    }
}