com.facebook.ads.sdk.PageLabel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of facebook-java-business-sdk Show documentation
Show all versions of facebook-java-business-sdk Show documentation
Facebook Business Solutions SDK for Java
/**
* Copyright (c) 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 PageLabel extends APINode {
@SerializedName("creation_time")
private String mCreationTime = null;
@SerializedName("creator_id")
private Profile mCreatorId = null;
@SerializedName("from")
private Page mFrom = null;
@SerializedName("id")
private String mId = null;
@SerializedName("name")
private String mName = null;
protected static Gson gson = null;
PageLabel() {
}
public PageLabel(Long id, APIContext context) {
this(id.toString(), context);
}
public PageLabel(String id, APIContext context) {
this.mId = id;
this.context = context;
}
public PageLabel fetch() throws APIException{
PageLabel newInstance = fetchById(this.getPrefixedId().toString(), this.context);
this.copyFrom(newInstance);
return this;
}
public static PageLabel 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 PageLabel 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", PageLabel.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", PageLabel.getParser())
.setParam("ids", APIRequest.joinStringList(ids))
.requestFields(fields)
.executeAsyncBase();
}
private String getPrefixedId() {
return getId();
}
public String getId() {
return getFieldId().toString();
}
public static PageLabel loadJSON(String json, APIContext context, String header) {
PageLabel pageLabel = getGson().fromJson(json, PageLabel.class);
if (context.isDebug()) {
JsonParser parser = new JsonParser();
JsonElement o1 = parser.parse(json);
JsonElement o2 = parser.parse(pageLabel.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);
};
}
pageLabel.context = context;
pageLabel.rawValue = json;
pageLabel.header = header;
return pageLabel;
}
public static APINodeList parseResponse(String json, APIContext context, APIRequest request, String header) throws MalformedResponseException {
APINodeList pageLabels = 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++) {
pageLabels.add(loadJSON(arr.get(i).getAsJsonObject().toString(), context, header));
};
return pageLabels;
} 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;
pageLabels.setCursors(before, after);
}
String previous = paging.has("previous") ? paging.get("previous").getAsString() : null;
String next = paging.has("next") ? paging.get("next").getAsString() : null;
pageLabels.setPaging(previous, next);
if (context.hasAppSecret()) {
pageLabels.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++) {
pageLabels.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()) {
pageLabels.add(loadJSON(entry.getValue().toString(), context, header));
}
break;
}
}
if (!isRedownload) {
pageLabels.add(loadJSON(obj.toString(), context, header));
}
}
return pageLabels;
} 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()) {
pageLabels.add(loadJSON(entry.getValue().toString(), context, header));
}
return pageLabels;
} 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)
) {
pageLabels.add(loadJSON(value.toString(), context, header));
} else {
isIdIndexedArray = false;
break;
}
}
if (isIdIndexedArray) {
return pageLabels;
}
// Sixth, check if it's pure JsonObject
pageLabels.clear();
pageLabels.add(loadJSON(json, context, header));
return pageLabels;
}
}
} 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 APIRequestDeleteUsers deleteUsers() {
return new APIRequestDeleteUsers(this.getPrefixedId().toString(), context);
}
public APIRequestGetUsers getUsers() {
return new APIRequestGetUsers(this.getPrefixedId().toString(), context);
}
public APIRequestCreateUser createUser() {
return new APIRequestCreateUser(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 String getFieldCreationTime() {
return mCreationTime;
}
public Profile getFieldCreatorId() {
if (mCreatorId != null) {
mCreatorId.context = getContext();
}
return mCreatorId;
}
public Page getFieldFrom() {
if (mFrom != null) {
mFrom.context = getContext();
}
return mFrom;
}
public String getFieldId() {
return mId;
}
public String getFieldName() {
return mName;
}
public static class APIRequestDeleteUsers extends APIRequest {
APINodeList lastResponse = null;
@Override
public APINodeList getLastResponse() {
return lastResponse;
}
public static final String[] PARAMS = {
"user_ids",
};
public static final String[] FIELDS = {
};
@Override
public APINodeList parseResponse(String response, String header) throws APIException {
return APINode.parseResponse(response, getContext(), this, header);
}
@Override
public APINodeList execute() throws APIException {
return execute(new HashMap());
}
@Override
public APINodeList execute(Map extraParams) throws APIException {
ResponseWrapper rw = executeInternal(extraParams);
lastResponse = parseResponse(rw.getBody(),rw.getHeader());
return lastResponse;
}
public ListenableFuture> executeAsync() throws APIException {
return executeAsync(new HashMap());
};
public ListenableFuture> executeAsync(Map extraParams) throws APIException {
return Futures.transform(
executeAsyncInternal(extraParams),
new Function>() {
public APINodeList apply(ResponseWrapper result) {
try {
return APIRequestDeleteUsers.this.parseResponse(result.getBody(), result.getHeader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
);
};
public APIRequestDeleteUsers(String nodeId, APIContext context) {
super(context, nodeId, "/users", "DELETE", Arrays.asList(PARAMS));
}
@Override
public APIRequestDeleteUsers setParam(String param, Object value) {
setParamInternal(param, value);
return this;
}
@Override
public APIRequestDeleteUsers setParams(Map params) {
setParamsInternal(params);
return this;
}
public APIRequestDeleteUsers setUserIds (List userIds) {
this.setParam("user_ids", userIds);
return this;
}
public APIRequestDeleteUsers setUserIds (String userIds) {
this.setParam("user_ids", userIds);
return this;
}
public APIRequestDeleteUsers requestAllFields () {
return this.requestAllFields(true);
}
public APIRequestDeleteUsers requestAllFields (boolean value) {
for (String field : FIELDS) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestDeleteUsers requestFields (List fields) {
return this.requestFields(fields, true);
}
@Override
public APIRequestDeleteUsers requestFields (List fields, boolean value) {
for (String field : fields) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestDeleteUsers requestField (String field) {
this.requestField(field, true);
return this;
}
@Override
public APIRequestDeleteUsers requestField (String field, boolean value) {
this.requestFieldInternal(field, value);
return this;
}
}
public static class APIRequestGetUsers extends APIRequest {
APINodeList lastResponse = null;
@Override
public APINodeList getLastResponse() {
return lastResponse;
}
public static final String[] PARAMS = {
};
public static final String[] FIELDS = {
"about",
"address",
"admin_notes",
"age_range",
"birthday",
"can_review_measurement_request",
"context",
"cover",
"currency",
"devices",
"education",
"email",
"employee_number",
"favorite_athletes",
"favorite_teams",
"first_name",
"gender",
"hometown",
"id",
"inspirational_people",
"install_type",
"installed",
"interested_in",
"is_famedeeplinkinguser",
"is_shared_login",
"is_verified",
"labels",
"languages",
"last_name",
"link",
"local_news_megaphone_dismiss_status",
"local_news_subscription_status",
"locale",
"location",
"meeting_for",
"middle_name",
"name",
"name_format",
"payment_pricepoints",
"political",
"profile_pic",
"public_key",
"quotes",
"relationship_status",
"religion",
"security_settings",
"shared_login_upgrade_required_by",
"short_name",
"significant_other",
"sports",
"test_group",
"third_party_id",
"timezone",
"token_for_business",
"updated_time",
"verified",
"video_upload_limits",
"viewer_can_send_gift",
"website",
"work",
};
@Override
public APINodeList parseResponse(String response, String header) throws APIException {
return User.parseResponse(response, getContext(), this, header);
}
@Override
public APINodeList execute() throws APIException {
return execute(new HashMap());
}
@Override
public APINodeList execute(Map extraParams) throws APIException {
ResponseWrapper rw = executeInternal(extraParams);
lastResponse = parseResponse(rw.getBody(),rw.getHeader());
return lastResponse;
}
public ListenableFuture> executeAsync() throws APIException {
return executeAsync(new HashMap());
};
public ListenableFuture> executeAsync(Map extraParams) throws APIException {
return Futures.transform(
executeAsyncInternal(extraParams),
new Function>() {
public APINodeList apply(ResponseWrapper result) {
try {
return APIRequestGetUsers.this.parseResponse(result.getBody(), result.getHeader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
);
};
public APIRequestGetUsers(String nodeId, APIContext context) {
super(context, nodeId, "/users", "GET", Arrays.asList(PARAMS));
}
@Override
public APIRequestGetUsers setParam(String param, Object value) {
setParamInternal(param, value);
return this;
}
@Override
public APIRequestGetUsers setParams(Map params) {
setParamsInternal(params);
return this;
}
public APIRequestGetUsers requestAllFields () {
return this.requestAllFields(true);
}
public APIRequestGetUsers requestAllFields (boolean value) {
for (String field : FIELDS) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGetUsers requestFields (List fields) {
return this.requestFields(fields, true);
}
@Override
public APIRequestGetUsers requestFields (List fields, boolean value) {
for (String field : fields) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGetUsers requestField (String field) {
this.requestField(field, true);
return this;
}
@Override
public APIRequestGetUsers requestField (String field, boolean value) {
this.requestFieldInternal(field, value);
return this;
}
public APIRequestGetUsers requestAboutField () {
return this.requestAboutField(true);
}
public APIRequestGetUsers requestAboutField (boolean value) {
this.requestField("about", value);
return this;
}
public APIRequestGetUsers requestAddressField () {
return this.requestAddressField(true);
}
public APIRequestGetUsers requestAddressField (boolean value) {
this.requestField("address", value);
return this;
}
public APIRequestGetUsers requestAdminNotesField () {
return this.requestAdminNotesField(true);
}
public APIRequestGetUsers requestAdminNotesField (boolean value) {
this.requestField("admin_notes", value);
return this;
}
public APIRequestGetUsers requestAgeRangeField () {
return this.requestAgeRangeField(true);
}
public APIRequestGetUsers requestAgeRangeField (boolean value) {
this.requestField("age_range", value);
return this;
}
public APIRequestGetUsers requestBirthdayField () {
return this.requestBirthdayField(true);
}
public APIRequestGetUsers requestBirthdayField (boolean value) {
this.requestField("birthday", value);
return this;
}
public APIRequestGetUsers requestCanReviewMeasurementRequestField () {
return this.requestCanReviewMeasurementRequestField(true);
}
public APIRequestGetUsers requestCanReviewMeasurementRequestField (boolean value) {
this.requestField("can_review_measurement_request", value);
return this;
}
public APIRequestGetUsers requestContextField () {
return this.requestContextField(true);
}
public APIRequestGetUsers requestContextField (boolean value) {
this.requestField("context", value);
return this;
}
public APIRequestGetUsers requestCoverField () {
return this.requestCoverField(true);
}
public APIRequestGetUsers requestCoverField (boolean value) {
this.requestField("cover", value);
return this;
}
public APIRequestGetUsers requestCurrencyField () {
return this.requestCurrencyField(true);
}
public APIRequestGetUsers requestCurrencyField (boolean value) {
this.requestField("currency", value);
return this;
}
public APIRequestGetUsers requestDevicesField () {
return this.requestDevicesField(true);
}
public APIRequestGetUsers requestDevicesField (boolean value) {
this.requestField("devices", value);
return this;
}
public APIRequestGetUsers requestEducationField () {
return this.requestEducationField(true);
}
public APIRequestGetUsers requestEducationField (boolean value) {
this.requestField("education", value);
return this;
}
public APIRequestGetUsers requestEmailField () {
return this.requestEmailField(true);
}
public APIRequestGetUsers requestEmailField (boolean value) {
this.requestField("email", value);
return this;
}
public APIRequestGetUsers requestEmployeeNumberField () {
return this.requestEmployeeNumberField(true);
}
public APIRequestGetUsers requestEmployeeNumberField (boolean value) {
this.requestField("employee_number", value);
return this;
}
public APIRequestGetUsers requestFavoriteAthletesField () {
return this.requestFavoriteAthletesField(true);
}
public APIRequestGetUsers requestFavoriteAthletesField (boolean value) {
this.requestField("favorite_athletes", value);
return this;
}
public APIRequestGetUsers requestFavoriteTeamsField () {
return this.requestFavoriteTeamsField(true);
}
public APIRequestGetUsers requestFavoriteTeamsField (boolean value) {
this.requestField("favorite_teams", value);
return this;
}
public APIRequestGetUsers requestFirstNameField () {
return this.requestFirstNameField(true);
}
public APIRequestGetUsers requestFirstNameField (boolean value) {
this.requestField("first_name", value);
return this;
}
public APIRequestGetUsers requestGenderField () {
return this.requestGenderField(true);
}
public APIRequestGetUsers requestGenderField (boolean value) {
this.requestField("gender", value);
return this;
}
public APIRequestGetUsers requestHometownField () {
return this.requestHometownField(true);
}
public APIRequestGetUsers requestHometownField (boolean value) {
this.requestField("hometown", value);
return this;
}
public APIRequestGetUsers requestIdField () {
return this.requestIdField(true);
}
public APIRequestGetUsers requestIdField (boolean value) {
this.requestField("id", value);
return this;
}
public APIRequestGetUsers requestInspirationalPeopleField () {
return this.requestInspirationalPeopleField(true);
}
public APIRequestGetUsers requestInspirationalPeopleField (boolean value) {
this.requestField("inspirational_people", value);
return this;
}
public APIRequestGetUsers requestInstallTypeField () {
return this.requestInstallTypeField(true);
}
public APIRequestGetUsers requestInstallTypeField (boolean value) {
this.requestField("install_type", value);
return this;
}
public APIRequestGetUsers requestInstalledField () {
return this.requestInstalledField(true);
}
public APIRequestGetUsers requestInstalledField (boolean value) {
this.requestField("installed", value);
return this;
}
public APIRequestGetUsers requestInterestedInField () {
return this.requestInterestedInField(true);
}
public APIRequestGetUsers requestInterestedInField (boolean value) {
this.requestField("interested_in", value);
return this;
}
public APIRequestGetUsers requestIsFamedeeplinkinguserField () {
return this.requestIsFamedeeplinkinguserField(true);
}
public APIRequestGetUsers requestIsFamedeeplinkinguserField (boolean value) {
this.requestField("is_famedeeplinkinguser", value);
return this;
}
public APIRequestGetUsers requestIsSharedLoginField () {
return this.requestIsSharedLoginField(true);
}
public APIRequestGetUsers requestIsSharedLoginField (boolean value) {
this.requestField("is_shared_login", value);
return this;
}
public APIRequestGetUsers requestIsVerifiedField () {
return this.requestIsVerifiedField(true);
}
public APIRequestGetUsers requestIsVerifiedField (boolean value) {
this.requestField("is_verified", value);
return this;
}
public APIRequestGetUsers requestLabelsField () {
return this.requestLabelsField(true);
}
public APIRequestGetUsers requestLabelsField (boolean value) {
this.requestField("labels", value);
return this;
}
public APIRequestGetUsers requestLanguagesField () {
return this.requestLanguagesField(true);
}
public APIRequestGetUsers requestLanguagesField (boolean value) {
this.requestField("languages", value);
return this;
}
public APIRequestGetUsers requestLastNameField () {
return this.requestLastNameField(true);
}
public APIRequestGetUsers requestLastNameField (boolean value) {
this.requestField("last_name", value);
return this;
}
public APIRequestGetUsers requestLinkField () {
return this.requestLinkField(true);
}
public APIRequestGetUsers requestLinkField (boolean value) {
this.requestField("link", value);
return this;
}
public APIRequestGetUsers requestLocalNewsMegaphoneDismissStatusField () {
return this.requestLocalNewsMegaphoneDismissStatusField(true);
}
public APIRequestGetUsers requestLocalNewsMegaphoneDismissStatusField (boolean value) {
this.requestField("local_news_megaphone_dismiss_status", value);
return this;
}
public APIRequestGetUsers requestLocalNewsSubscriptionStatusField () {
return this.requestLocalNewsSubscriptionStatusField(true);
}
public APIRequestGetUsers requestLocalNewsSubscriptionStatusField (boolean value) {
this.requestField("local_news_subscription_status", value);
return this;
}
public APIRequestGetUsers requestLocaleField () {
return this.requestLocaleField(true);
}
public APIRequestGetUsers requestLocaleField (boolean value) {
this.requestField("locale", value);
return this;
}
public APIRequestGetUsers requestLocationField () {
return this.requestLocationField(true);
}
public APIRequestGetUsers requestLocationField (boolean value) {
this.requestField("location", value);
return this;
}
public APIRequestGetUsers requestMeetingForField () {
return this.requestMeetingForField(true);
}
public APIRequestGetUsers requestMeetingForField (boolean value) {
this.requestField("meeting_for", value);
return this;
}
public APIRequestGetUsers requestMiddleNameField () {
return this.requestMiddleNameField(true);
}
public APIRequestGetUsers requestMiddleNameField (boolean value) {
this.requestField("middle_name", value);
return this;
}
public APIRequestGetUsers requestNameField () {
return this.requestNameField(true);
}
public APIRequestGetUsers requestNameField (boolean value) {
this.requestField("name", value);
return this;
}
public APIRequestGetUsers requestNameFormatField () {
return this.requestNameFormatField(true);
}
public APIRequestGetUsers requestNameFormatField (boolean value) {
this.requestField("name_format", value);
return this;
}
public APIRequestGetUsers requestPaymentPricepointsField () {
return this.requestPaymentPricepointsField(true);
}
public APIRequestGetUsers requestPaymentPricepointsField (boolean value) {
this.requestField("payment_pricepoints", value);
return this;
}
public APIRequestGetUsers requestPoliticalField () {
return this.requestPoliticalField(true);
}
public APIRequestGetUsers requestPoliticalField (boolean value) {
this.requestField("political", value);
return this;
}
public APIRequestGetUsers requestProfilePicField () {
return this.requestProfilePicField(true);
}
public APIRequestGetUsers requestProfilePicField (boolean value) {
this.requestField("profile_pic", value);
return this;
}
public APIRequestGetUsers requestPublicKeyField () {
return this.requestPublicKeyField(true);
}
public APIRequestGetUsers requestPublicKeyField (boolean value) {
this.requestField("public_key", value);
return this;
}
public APIRequestGetUsers requestQuotesField () {
return this.requestQuotesField(true);
}
public APIRequestGetUsers requestQuotesField (boolean value) {
this.requestField("quotes", value);
return this;
}
public APIRequestGetUsers requestRelationshipStatusField () {
return this.requestRelationshipStatusField(true);
}
public APIRequestGetUsers requestRelationshipStatusField (boolean value) {
this.requestField("relationship_status", value);
return this;
}
public APIRequestGetUsers requestReligionField () {
return this.requestReligionField(true);
}
public APIRequestGetUsers requestReligionField (boolean value) {
this.requestField("religion", value);
return this;
}
public APIRequestGetUsers requestSecuritySettingsField () {
return this.requestSecuritySettingsField(true);
}
public APIRequestGetUsers requestSecuritySettingsField (boolean value) {
this.requestField("security_settings", value);
return this;
}
public APIRequestGetUsers requestSharedLoginUpgradeRequiredByField () {
return this.requestSharedLoginUpgradeRequiredByField(true);
}
public APIRequestGetUsers requestSharedLoginUpgradeRequiredByField (boolean value) {
this.requestField("shared_login_upgrade_required_by", value);
return this;
}
public APIRequestGetUsers requestShortNameField () {
return this.requestShortNameField(true);
}
public APIRequestGetUsers requestShortNameField (boolean value) {
this.requestField("short_name", value);
return this;
}
public APIRequestGetUsers requestSignificantOtherField () {
return this.requestSignificantOtherField(true);
}
public APIRequestGetUsers requestSignificantOtherField (boolean value) {
this.requestField("significant_other", value);
return this;
}
public APIRequestGetUsers requestSportsField () {
return this.requestSportsField(true);
}
public APIRequestGetUsers requestSportsField (boolean value) {
this.requestField("sports", value);
return this;
}
public APIRequestGetUsers requestTestGroupField () {
return this.requestTestGroupField(true);
}
public APIRequestGetUsers requestTestGroupField (boolean value) {
this.requestField("test_group", value);
return this;
}
public APIRequestGetUsers requestThirdPartyIdField () {
return this.requestThirdPartyIdField(true);
}
public APIRequestGetUsers requestThirdPartyIdField (boolean value) {
this.requestField("third_party_id", value);
return this;
}
public APIRequestGetUsers requestTimezoneField () {
return this.requestTimezoneField(true);
}
public APIRequestGetUsers requestTimezoneField (boolean value) {
this.requestField("timezone", value);
return this;
}
public APIRequestGetUsers requestTokenForBusinessField () {
return this.requestTokenForBusinessField(true);
}
public APIRequestGetUsers requestTokenForBusinessField (boolean value) {
this.requestField("token_for_business", value);
return this;
}
public APIRequestGetUsers requestUpdatedTimeField () {
return this.requestUpdatedTimeField(true);
}
public APIRequestGetUsers requestUpdatedTimeField (boolean value) {
this.requestField("updated_time", value);
return this;
}
public APIRequestGetUsers requestVerifiedField () {
return this.requestVerifiedField(true);
}
public APIRequestGetUsers requestVerifiedField (boolean value) {
this.requestField("verified", value);
return this;
}
public APIRequestGetUsers requestVideoUploadLimitsField () {
return this.requestVideoUploadLimitsField(true);
}
public APIRequestGetUsers requestVideoUploadLimitsField (boolean value) {
this.requestField("video_upload_limits", value);
return this;
}
public APIRequestGetUsers requestViewerCanSendGiftField () {
return this.requestViewerCanSendGiftField(true);
}
public APIRequestGetUsers requestViewerCanSendGiftField (boolean value) {
this.requestField("viewer_can_send_gift", value);
return this;
}
public APIRequestGetUsers requestWebsiteField () {
return this.requestWebsiteField(true);
}
public APIRequestGetUsers requestWebsiteField (boolean value) {
this.requestField("website", value);
return this;
}
public APIRequestGetUsers requestWorkField () {
return this.requestWorkField(true);
}
public APIRequestGetUsers requestWorkField (boolean value) {
this.requestField("work", value);
return this;
}
}
public static class APIRequestCreateUser extends APIRequest {
PageLabel lastResponse = null;
@Override
public PageLabel getLastResponse() {
return lastResponse;
}
public static final String[] PARAMS = {
"user_ids",
};
public static final String[] FIELDS = {
};
@Override
public PageLabel parseResponse(String response, String header) throws APIException {
return PageLabel.parseResponse(response, getContext(), this, header).head();
}
@Override
public PageLabel execute() throws APIException {
return execute(new HashMap());
}
@Override
public PageLabel 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 PageLabel apply(ResponseWrapper result) {
try {
return APIRequestCreateUser.this.parseResponse(result.getBody(), result.getHeader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
);
};
public APIRequestCreateUser(String nodeId, APIContext context) {
super(context, nodeId, "/users", "POST", Arrays.asList(PARAMS));
}
@Override
public APIRequestCreateUser setParam(String param, Object value) {
setParamInternal(param, value);
return this;
}
@Override
public APIRequestCreateUser setParams(Map params) {
setParamsInternal(params);
return this;
}
public APIRequestCreateUser setUserIds (List userIds) {
this.setParam("user_ids", userIds);
return this;
}
public APIRequestCreateUser setUserIds (String userIds) {
this.setParam("user_ids", userIds);
return this;
}
public APIRequestCreateUser requestAllFields () {
return this.requestAllFields(true);
}
public APIRequestCreateUser requestAllFields (boolean value) {
for (String field : FIELDS) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestCreateUser requestFields (List fields) {
return this.requestFields(fields, true);
}
@Override
public APIRequestCreateUser requestFields (List fields, boolean value) {
for (String field : fields) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestCreateUser requestField (String field) {
this.requestField(field, true);
return this;
}
@Override
public APIRequestCreateUser requestField (String field, boolean value) {
this.requestFieldInternal(field, value);
return this;
}
}
public static class APIRequestDelete extends APIRequest {
APINode lastResponse = null;
@Override
public APINode getLastResponse() {
return lastResponse;
}
public static final String[] PARAMS = {
};
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 {
PageLabel lastResponse = null;
@Override
public PageLabel getLastResponse() {
return lastResponse;
}
public static final String[] PARAMS = {
};
public static final String[] FIELDS = {
"creation_time",
"creator_id",
"from",
"id",
"name",
};
@Override
public PageLabel parseResponse(String response, String header) throws APIException {
return PageLabel.parseResponse(response, getContext(), this, header).head();
}
@Override
public PageLabel execute() throws APIException {
return execute(new HashMap());
}
@Override
public PageLabel 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 PageLabel 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 requestCreationTimeField () {
return this.requestCreationTimeField(true);
}
public APIRequestGet requestCreationTimeField (boolean value) {
this.requestField("creation_time", value);
return this;
}
public APIRequestGet requestCreatorIdField () {
return this.requestCreatorIdField(true);
}
public APIRequestGet requestCreatorIdField (boolean value) {
this.requestField("creator_id", 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 requestNameField () {
return this.requestNameField(true);
}
public APIRequestGet requestNameField (boolean value) {
this.requestField("name", value);
return this;
}
}
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 PageLabel copyFrom(PageLabel instance) {
this.mCreationTime = instance.mCreationTime;
this.mCreatorId = instance.mCreatorId;
this.mFrom = instance.mFrom;
this.mId = instance.mId;
this.mName = instance.mName;
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 PageLabel.parseResponse(response, context, request, header);
}
};
}
}