All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.facebook.ads.sdk.PageCallToAction Maven / Gradle / Ivy

There is a newer version: 20.0.4
Show newest version
/**
 * 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.common.base.Function;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
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 PageCallToAction extends APINode {
  @SerializedName("android_app")
  private Application mAndroidApp = null;
  @SerializedName("android_deeplink")
  private String mAndroidDeeplink = null;
  @SerializedName("android_destination_type")
  private String mAndroidDestinationType = null;
  @SerializedName("android_package_name")
  private String mAndroidPackageName = null;
  @SerializedName("android_url")
  private String mAndroidUrl = null;
  @SerializedName("created_time")
  private String mCreatedTime = null;
  @SerializedName("email_address")
  private String mEmailAddress = null;
  @SerializedName("from")
  private Page mFrom = null;
  @SerializedName("id")
  private String mId = null;
  @SerializedName("intl_number_with_plus")
  private String mIntlNumberWithPlus = null;
  @SerializedName("iphone_app")
  private Application mIphoneApp = null;
  @SerializedName("iphone_deeplink")
  private String mIphoneDeeplink = null;
  @SerializedName("iphone_destination_type")
  private String mIphoneDestinationType = null;
  @SerializedName("iphone_url")
  private String mIphoneUrl = null;
  @SerializedName("status")
  private String mStatus = null;
  @SerializedName("type")
  private String mType = null;
  @SerializedName("updated_time")
  private String mUpdatedTime = null;
  @SerializedName("web_destination_type")
  private String mWebDestinationType = null;
  @SerializedName("web_url")
  private String mWebUrl = null;
  protected static Gson gson = null;

  PageCallToAction() {
  }

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

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

    this.context = context;
  }

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

  public static PageCallToAction 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 PageCallToAction 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", PageCallToAction.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", PageCallToAction.getParser())
        .setParam("ids", APIRequest.joinStringList(ids))
        .requestFields(fields)
        .executeAsyncBase();
  }

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

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

  public static APINodeList parseResponse(String json, APIContext context, APIRequest request, String header) throws MalformedResponseException {
    APINodeList pageCallToActions = 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++) {
          pageCallToActions.add(loadJSON(arr.get(i).getAsJsonObject().toString(), context, header));
        };
        return pageCallToActions;
      } 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;
                pageCallToActions.setCursors(before, after);
            }
            String previous = paging.has("previous") ? paging.get("previous").getAsString() : null;
            String next = paging.has("next") ? paging.get("next").getAsString() : null;
            pageCallToActions.setPaging(previous, next);
            if (context.hasAppSecret()) {
              pageCallToActions.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++) {
              pageCallToActions.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()) {
                  pageCallToActions.add(loadJSON(entry.getValue().toString(), context, header));
                }
                break;
              }
            }
            if (!isRedownload) {
              pageCallToActions.add(loadJSON(obj.toString(), context, header));
            }
          }
          return pageCallToActions;
        } 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()) {
              pageCallToActions.add(loadJSON(entry.getValue().toString(), context, header));
          }
          return pageCallToActions;
        } 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)
            ) {
              pageCallToActions.add(loadJSON(value.toString(), context, header));
            } else {
              isIdIndexedArray = false;
              break;
            }
          }
          if (isIdIndexedArray) {
            return pageCallToActions;
          }

          // Sixth, check if it's pure JsonObject
          pageCallToActions.clear();
          pageCallToActions.add(loadJSON(json, context, header));
          return pageCallToActions;
        }
      }
    } 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 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 Application getFieldAndroidApp() {
    if (mAndroidApp != null) {
      mAndroidApp.context = getContext();
    }
    return mAndroidApp;
  }

  public String getFieldAndroidDeeplink() {
    return mAndroidDeeplink;
  }

  public String getFieldAndroidDestinationType() {
    return mAndroidDestinationType;
  }

  public String getFieldAndroidPackageName() {
    return mAndroidPackageName;
  }

  public String getFieldAndroidUrl() {
    return mAndroidUrl;
  }

  public String getFieldCreatedTime() {
    return mCreatedTime;
  }

  public String getFieldEmailAddress() {
    return mEmailAddress;
  }

  public Page getFieldFrom() {
    if (mFrom != null) {
      mFrom.context = getContext();
    }
    return mFrom;
  }

  public String getFieldId() {
    return mId;
  }

  public String getFieldIntlNumberWithPlus() {
    return mIntlNumberWithPlus;
  }

  public Application getFieldIphoneApp() {
    if (mIphoneApp != null) {
      mIphoneApp.context = getContext();
    }
    return mIphoneApp;
  }

  public String getFieldIphoneDeeplink() {
    return mIphoneDeeplink;
  }

  public String getFieldIphoneDestinationType() {
    return mIphoneDestinationType;
  }

  public String getFieldIphoneUrl() {
    return mIphoneUrl;
  }

  public String getFieldStatus() {
    return mStatus;
  }

  public String getFieldType() {
    return mType;
  }

  public String getFieldUpdatedTime() {
    return mUpdatedTime;
  }

  public String getFieldWebDestinationType() {
    return mWebDestinationType;
  }

  public String getFieldWebUrl() {
    return mWebUrl;
  }



  public static class APIRequestDelete extends APIRequest {

    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, 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);
             }
           }
         }
      );
    };

    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 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 {

    PageCallToAction lastResponse = null;
    @Override
    public PageCallToAction getLastResponse() {
      return lastResponse;
    }
    public static final String[] PARAMS = {
    };

    public static final String[] FIELDS = {
      "android_app",
      "android_deeplink",
      "android_destination_type",
      "android_package_name",
      "android_url",
      "created_time",
      "email_address",
      "from",
      "id",
      "intl_number_with_plus",
      "iphone_app",
      "iphone_deeplink",
      "iphone_destination_type",
      "iphone_url",
      "status",
      "type",
      "updated_time",
      "web_destination_type",
      "web_url",
    };

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

    @Override
    public PageCallToAction execute() throws APIException {
      return execute(new HashMap());
    }

    @Override
    public PageCallToAction 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 PageCallToAction apply(ResponseWrapper result) {
             try {
               return APIRequestGet.this.parseResponse(result.getBody(), result.getHeader());
             } catch (Exception e) {
               throw new RuntimeException(e);
             }
           }
         }
      );
    };

    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 requestAndroidAppField () {
      return this.requestAndroidAppField(true);
    }
    public APIRequestGet requestAndroidAppField (boolean value) {
      this.requestField("android_app", value);
      return this;
    }
    public APIRequestGet requestAndroidDeeplinkField () {
      return this.requestAndroidDeeplinkField(true);
    }
    public APIRequestGet requestAndroidDeeplinkField (boolean value) {
      this.requestField("android_deeplink", value);
      return this;
    }
    public APIRequestGet requestAndroidDestinationTypeField () {
      return this.requestAndroidDestinationTypeField(true);
    }
    public APIRequestGet requestAndroidDestinationTypeField (boolean value) {
      this.requestField("android_destination_type", value);
      return this;
    }
    public APIRequestGet requestAndroidPackageNameField () {
      return this.requestAndroidPackageNameField(true);
    }
    public APIRequestGet requestAndroidPackageNameField (boolean value) {
      this.requestField("android_package_name", value);
      return this;
    }
    public APIRequestGet requestAndroidUrlField () {
      return this.requestAndroidUrlField(true);
    }
    public APIRequestGet requestAndroidUrlField (boolean value) {
      this.requestField("android_url", value);
      return this;
    }
    public APIRequestGet requestCreatedTimeField () {
      return this.requestCreatedTimeField(true);
    }
    public APIRequestGet requestCreatedTimeField (boolean value) {
      this.requestField("created_time", value);
      return this;
    }
    public APIRequestGet requestEmailAddressField () {
      return this.requestEmailAddressField(true);
    }
    public APIRequestGet requestEmailAddressField (boolean value) {
      this.requestField("email_address", value);
      return this;
    }
    public APIRequestGet requestFromField () {
      return this.requestFromField(true);
    }
    public APIRequestGet requestFromField (boolean value) {
      this.requestField("from", value);
      return this;
    }
    public APIRequestGet requestIdField () {
      return this.requestIdField(true);
    }
    public APIRequestGet requestIdField (boolean value) {
      this.requestField("id", value);
      return this;
    }
    public APIRequestGet requestIntlNumberWithPlusField () {
      return this.requestIntlNumberWithPlusField(true);
    }
    public APIRequestGet requestIntlNumberWithPlusField (boolean value) {
      this.requestField("intl_number_with_plus", value);
      return this;
    }
    public APIRequestGet requestIphoneAppField () {
      return this.requestIphoneAppField(true);
    }
    public APIRequestGet requestIphoneAppField (boolean value) {
      this.requestField("iphone_app", value);
      return this;
    }
    public APIRequestGet requestIphoneDeeplinkField () {
      return this.requestIphoneDeeplinkField(true);
    }
    public APIRequestGet requestIphoneDeeplinkField (boolean value) {
      this.requestField("iphone_deeplink", value);
      return this;
    }
    public APIRequestGet requestIphoneDestinationTypeField () {
      return this.requestIphoneDestinationTypeField(true);
    }
    public APIRequestGet requestIphoneDestinationTypeField (boolean value) {
      this.requestField("iphone_destination_type", value);
      return this;
    }
    public APIRequestGet requestIphoneUrlField () {
      return this.requestIphoneUrlField(true);
    }
    public APIRequestGet requestIphoneUrlField (boolean value) {
      this.requestField("iphone_url", value);
      return this;
    }
    public APIRequestGet requestStatusField () {
      return this.requestStatusField(true);
    }
    public APIRequestGet requestStatusField (boolean value) {
      this.requestField("status", value);
      return this;
    }
    public APIRequestGet requestTypeField () {
      return this.requestTypeField(true);
    }
    public APIRequestGet requestTypeField (boolean value) {
      this.requestField("type", value);
      return this;
    }
    public APIRequestGet requestUpdatedTimeField () {
      return this.requestUpdatedTimeField(true);
    }
    public APIRequestGet requestUpdatedTimeField (boolean value) {
      this.requestField("updated_time", value);
      return this;
    }
    public APIRequestGet requestWebDestinationTypeField () {
      return this.requestWebDestinationTypeField(true);
    }
    public APIRequestGet requestWebDestinationTypeField (boolean value) {
      this.requestField("web_destination_type", value);
      return this;
    }
    public APIRequestGet requestWebUrlField () {
      return this.requestWebUrlField(true);
    }
    public APIRequestGet requestWebUrlField (boolean value) {
      this.requestField("web_url", value);
      return this;
    }
  }

  public static class APIRequestUpdate extends APIRequest {

    PageCallToAction lastResponse = null;
    @Override
    public PageCallToAction getLastResponse() {
      return lastResponse;
    }
    public static final String[] PARAMS = {
      "type",
      "intl_number_with_plus",
      "email_address",
      "web_destination_type",
      "web_url",
      "android_destination_type",
      "android_deeplink",
      "android_package_name",
      "android_url",
      "android_app_id",
      "iphone_destination_type",
      "iphone_deeplink",
      "iphone_url",
      "iphone_app_id",
    };

    public static final String[] FIELDS = {
    };

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

    @Override
    public PageCallToAction execute() throws APIException {
      return execute(new HashMap());
    }

    @Override
    public PageCallToAction 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 PageCallToAction apply(ResponseWrapper result) {
             try {
               return APIRequestUpdate.this.parseResponse(result.getBody(), result.getHeader());
             } catch (Exception e) {
               throw new RuntimeException(e);
             }
           }
         }
      );
    };

    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 setType (PageCallToAction.EnumType type) {
      this.setParam("type", type);
      return this;
    }
    public APIRequestUpdate setType (String type) {
      this.setParam("type", type);
      return this;
    }

    public APIRequestUpdate setIntlNumberWithPlus (String intlNumberWithPlus) {
      this.setParam("intl_number_with_plus", intlNumberWithPlus);
      return this;
    }

    public APIRequestUpdate setEmailAddress (String emailAddress) {
      this.setParam("email_address", emailAddress);
      return this;
    }

    public APIRequestUpdate setWebDestinationType (PageCallToAction.EnumWebDestinationType webDestinationType) {
      this.setParam("web_destination_type", webDestinationType);
      return this;
    }
    public APIRequestUpdate setWebDestinationType (String webDestinationType) {
      this.setParam("web_destination_type", webDestinationType);
      return this;
    }

    public APIRequestUpdate setWebUrl (String webUrl) {
      this.setParam("web_url", webUrl);
      return this;
    }

    public APIRequestUpdate setAndroidDestinationType (PageCallToAction.EnumAndroidDestinationType androidDestinationType) {
      this.setParam("android_destination_type", androidDestinationType);
      return this;
    }
    public APIRequestUpdate setAndroidDestinationType (String androidDestinationType) {
      this.setParam("android_destination_type", androidDestinationType);
      return this;
    }

    public APIRequestUpdate setAndroidDeeplink (String androidDeeplink) {
      this.setParam("android_deeplink", androidDeeplink);
      return this;
    }

    public APIRequestUpdate setAndroidPackageName (String androidPackageName) {
      this.setParam("android_package_name", androidPackageName);
      return this;
    }

    public APIRequestUpdate setAndroidUrl (String androidUrl) {
      this.setParam("android_url", androidUrl);
      return this;
    }

    public APIRequestUpdate setAndroidAppId (Long androidAppId) {
      this.setParam("android_app_id", androidAppId);
      return this;
    }
    public APIRequestUpdate setAndroidAppId (String androidAppId) {
      this.setParam("android_app_id", androidAppId);
      return this;
    }

    public APIRequestUpdate setIphoneDestinationType (PageCallToAction.EnumIphoneDestinationType iphoneDestinationType) {
      this.setParam("iphone_destination_type", iphoneDestinationType);
      return this;
    }
    public APIRequestUpdate setIphoneDestinationType (String iphoneDestinationType) {
      this.setParam("iphone_destination_type", iphoneDestinationType);
      return this;
    }

    public APIRequestUpdate setIphoneDeeplink (String iphoneDeeplink) {
      this.setParam("iphone_deeplink", iphoneDeeplink);
      return this;
    }

    public APIRequestUpdate setIphoneUrl (String iphoneUrl) {
      this.setParam("iphone_url", iphoneUrl);
      return this;
    }

    public APIRequestUpdate setIphoneAppId (Long iphoneAppId) {
      this.setParam("iphone_app_id", iphoneAppId);
      return this;
    }
    public APIRequestUpdate setIphoneAppId (String iphoneAppId) {
      this.setParam("iphone_app_id", iphoneAppId);
      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 fields) {
      return this.requestFields(fields, true);
    }

    @Override
    public APIRequestUpdate requestFields (List 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 EnumAndroidDestinationType {
      @SerializedName("WEBSITE")
      VALUE_WEBSITE("WEBSITE"),
      @SerializedName("APP_DEEPLINK")
      VALUE_APP_DEEPLINK("APP_DEEPLINK"),
      @SerializedName("FACEBOOK_APP")
      VALUE_FACEBOOK_APP("FACEBOOK_APP"),
      @SerializedName("PHONE_CALL")
      VALUE_PHONE_CALL("PHONE_CALL"),
      @SerializedName("MESSENGER")
      VALUE_MESSENGER("MESSENGER"),
      @SerializedName("EMAIL")
      VALUE_EMAIL("EMAIL"),
      @SerializedName("SHOP_ON_FACEBOOK")
      VALUE_SHOP_ON_FACEBOOK("SHOP_ON_FACEBOOK"),
      @SerializedName("NONE")
      VALUE_NONE("NONE"),
      NULL(null);

      private String value;

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

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

  public static enum EnumIphoneDestinationType {
      @SerializedName("WEBSITE")
      VALUE_WEBSITE("WEBSITE"),
      @SerializedName("APP_DEEPLINK")
      VALUE_APP_DEEPLINK("APP_DEEPLINK"),
      @SerializedName("FACEBOOK_APP")
      VALUE_FACEBOOK_APP("FACEBOOK_APP"),
      @SerializedName("PHONE_CALL")
      VALUE_PHONE_CALL("PHONE_CALL"),
      @SerializedName("MESSENGER")
      VALUE_MESSENGER("MESSENGER"),
      @SerializedName("EMAIL")
      VALUE_EMAIL("EMAIL"),
      @SerializedName("SHOP_ON_FACEBOOK")
      VALUE_SHOP_ON_FACEBOOK("SHOP_ON_FACEBOOK"),
      @SerializedName("NONE")
      VALUE_NONE("NONE"),
      NULL(null);

      private String value;

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

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

  public static enum EnumType {
      @SerializedName("BOOK_NOW")
      VALUE_BOOK_NOW("BOOK_NOW"),
      @SerializedName("CALL_NOW")
      VALUE_CALL_NOW("CALL_NOW"),
      @SerializedName("CHARITY_DONATE")
      VALUE_CHARITY_DONATE("CHARITY_DONATE"),
      @SerializedName("CONTACT_US")
      VALUE_CONTACT_US("CONTACT_US"),
      @SerializedName("DONATE_NOW")
      VALUE_DONATE_NOW("DONATE_NOW"),
      @SerializedName("MESSAGE")
      VALUE_MESSAGE("MESSAGE"),
      @SerializedName("OPEN_APP")
      VALUE_OPEN_APP("OPEN_APP"),
      @SerializedName("PLAY_NOW")
      VALUE_PLAY_NOW("PLAY_NOW"),
      @SerializedName("SHOP_NOW")
      VALUE_SHOP_NOW("SHOP_NOW"),
      @SerializedName("SIGN_UP")
      VALUE_SIGN_UP("SIGN_UP"),
      @SerializedName("WATCH_NOW")
      VALUE_WATCH_NOW("WATCH_NOW"),
      @SerializedName("GET_OFFER")
      VALUE_GET_OFFER("GET_OFFER"),
      @SerializedName("GET_OFFER_VIEW")
      VALUE_GET_OFFER_VIEW("GET_OFFER_VIEW"),
      @SerializedName("REQUEST_QUOTE")
      VALUE_REQUEST_QUOTE("REQUEST_QUOTE"),
      @SerializedName("BOOK_APPOINTMENT")
      VALUE_BOOK_APPOINTMENT("BOOK_APPOINTMENT"),
      @SerializedName("LISTEN")
      VALUE_LISTEN("LISTEN"),
      @SerializedName("EMAIL")
      VALUE_EMAIL("EMAIL"),
      @SerializedName("LEARN_MORE")
      VALUE_LEARN_MORE("LEARN_MORE"),
      @SerializedName("REQUEST_APPOINTMENT")
      VALUE_REQUEST_APPOINTMENT("REQUEST_APPOINTMENT"),
      @SerializedName("GET_DIRECTIONS")
      VALUE_GET_DIRECTIONS("GET_DIRECTIONS"),
      @SerializedName("BUY_TICKETS")
      VALUE_BUY_TICKETS("BUY_TICKETS"),
      @SerializedName("PLAY_MUSIC")
      VALUE_PLAY_MUSIC("PLAY_MUSIC"),
      @SerializedName("VISIT_GROUP")
      VALUE_VISIT_GROUP("VISIT_GROUP"),
      @SerializedName("SHOP_ON_FACEBOOK")
      VALUE_SHOP_ON_FACEBOOK("SHOP_ON_FACEBOOK"),
      @SerializedName("LOCAL_DEV_PLATFORM")
      VALUE_LOCAL_DEV_PLATFORM("LOCAL_DEV_PLATFORM"),
      @SerializedName("INTERESTED")
      VALUE_INTERESTED("INTERESTED"),
      @SerializedName("WOODHENGE_SUPPORT")
      VALUE_WOODHENGE_SUPPORT("WOODHENGE_SUPPORT"),
      NULL(null);

      private String value;

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

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

  public static enum EnumWebDestinationType {
      @SerializedName("EMAIL")
      VALUE_EMAIL("EMAIL"),
      @SerializedName("MESSENGER")
      VALUE_MESSENGER("MESSENGER"),
      @SerializedName("NONE")
      VALUE_NONE("NONE"),
      @SerializedName("WEBSITE")
      VALUE_WEBSITE("WEBSITE"),
      @SerializedName("SHOP_ON_FACEBOOK")
      VALUE_SHOP_ON_FACEBOOK("SHOP_ON_FACEBOOK"),
      @SerializedName("BECOME_SUPPORTER")
      VALUE_BECOME_SUPPORTER("BECOME_SUPPORTER"),
      NULL(null);

      private String value;

      private EnumWebDestinationType(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 PageCallToAction copyFrom(PageCallToAction instance) {
    this.mAndroidApp = instance.mAndroidApp;
    this.mAndroidDeeplink = instance.mAndroidDeeplink;
    this.mAndroidDestinationType = instance.mAndroidDestinationType;
    this.mAndroidPackageName = instance.mAndroidPackageName;
    this.mAndroidUrl = instance.mAndroidUrl;
    this.mCreatedTime = instance.mCreatedTime;
    this.mEmailAddress = instance.mEmailAddress;
    this.mFrom = instance.mFrom;
    this.mId = instance.mId;
    this.mIntlNumberWithPlus = instance.mIntlNumberWithPlus;
    this.mIphoneApp = instance.mIphoneApp;
    this.mIphoneDeeplink = instance.mIphoneDeeplink;
    this.mIphoneDestinationType = instance.mIphoneDestinationType;
    this.mIphoneUrl = instance.mIphoneUrl;
    this.mStatus = instance.mStatus;
    this.mType = instance.mType;
    this.mUpdatedTime = instance.mUpdatedTime;
    this.mWebDestinationType = instance.mWebDestinationType;
    this.mWebUrl = instance.mWebUrl;
    this.context = instance.context;
    this.rawValue = instance.rawValue;
    return this;
  }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy