com.facebook.ads.sdk.IGUserForIGOnlyAPI Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of facebook-java-business-sdk Show documentation
Show all versions of facebook-java-business-sdk Show documentation
Facebook Business Solutions SDK for Java
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.ads.sdk;
import java.io.File;
import java.lang.reflect.Modifier;
import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.google.common.base.Function;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.SettableFuture;
import com.google.gson.JsonObject;
import com.google.gson.JsonArray;
import com.google.gson.annotations.SerializedName;
import com.google.gson.reflect.TypeToken;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import com.facebook.ads.sdk.APIException.MalformedResponseException;
/**
* This class is auto-generated.
*
* For any issues or feature requests related to this class, please let us know
* on github and we'll fix in our codegen framework. We'll not be able to accept
* pull request for this class.
*
*/
public class IGUserForIGOnlyAPI extends APINode {
@SerializedName("account_type")
private String mAccountType = null;
@SerializedName("biography")
private String mBiography = null;
@SerializedName("followers_count")
private Long mFollowersCount = null;
@SerializedName("follows_count")
private Long mFollowsCount = null;
@SerializedName("id")
private String mId = null;
@SerializedName("media_count")
private Long mMediaCount = null;
@SerializedName("name")
private String mName = null;
@SerializedName("profile_picture_url")
private String mProfilePictureUrl = null;
@SerializedName("user_id")
private Long mUserId = null;
@SerializedName("username")
private String mUsername = null;
@SerializedName("website")
private String mWebsite = null;
protected static Gson gson = null;
IGUserForIGOnlyAPI() {
}
public IGUserForIGOnlyAPI(Long id, APIContext context) {
this(id.toString(), context);
}
public IGUserForIGOnlyAPI(String id, APIContext context) {
this.mId = id;
this.context = context;
}
public IGUserForIGOnlyAPI fetch() throws APIException{
IGUserForIGOnlyAPI newInstance = fetchById(this.getPrefixedId().toString(), this.context);
this.copyFrom(newInstance);
return this;
}
public static IGUserForIGOnlyAPI 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 IGUserForIGOnlyAPI 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", IGUserForIGOnlyAPI.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", IGUserForIGOnlyAPI.getParser())
.setParam("ids", APIRequest.joinStringList(ids))
.requestFields(fields)
.executeAsyncBase();
}
private String getPrefixedId() {
return getId();
}
public String getId() {
return getFieldId().toString();
}
public static IGUserForIGOnlyAPI loadJSON(String json, APIContext context, String header) {
IGUserForIGOnlyAPI igUserForIGOnlyAPI = getGson().fromJson(json, IGUserForIGOnlyAPI.class);
if (context.isDebug()) {
JsonParser parser = new JsonParser();
JsonElement o1 = parser.parse(json);
JsonElement o2 = parser.parse(igUserForIGOnlyAPI.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);
}
}
igUserForIGOnlyAPI.context = context;
igUserForIGOnlyAPI.rawValue = json;
igUserForIGOnlyAPI.header = header;
return igUserForIGOnlyAPI;
}
public static APINodeList parseResponse(String json, APIContext context, APIRequest request, String header) throws MalformedResponseException {
APINodeList igUserForIGOnlyAPIs = 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++) {
igUserForIGOnlyAPIs.add(loadJSON(arr.get(i).getAsJsonObject().toString(), context, header));
};
return igUserForIGOnlyAPIs;
} 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;
igUserForIGOnlyAPIs.setCursors(before, after);
}
String previous = paging.has("previous") ? paging.get("previous").getAsString() : null;
String next = paging.has("next") ? paging.get("next").getAsString() : null;
igUserForIGOnlyAPIs.setPaging(previous, next);
if (context.hasAppSecret()) {
igUserForIGOnlyAPIs.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++) {
igUserForIGOnlyAPIs.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()) {
igUserForIGOnlyAPIs.add(loadJSON(entry.getValue().toString(), context, header));
}
break;
}
}
if (!isRedownload) {
igUserForIGOnlyAPIs.add(loadJSON(obj.toString(), context, header));
}
}
return igUserForIGOnlyAPIs;
} 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()) {
igUserForIGOnlyAPIs.add(loadJSON(entry.getValue().toString(), context, header));
}
return igUserForIGOnlyAPIs;
} 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)
) {
igUserForIGOnlyAPIs.add(loadJSON(value.toString(), context, header));
} else {
isIdIndexedArray = false;
break;
}
}
if (isIdIndexedArray) {
return igUserForIGOnlyAPIs;
}
// Sixth, check if it's pure JsonObject
igUserForIGOnlyAPIs.clear();
igUserForIGOnlyAPIs.add(loadJSON(json, context, header));
return igUserForIGOnlyAPIs;
}
}
} 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 APIRequestGetContentPublishingLimit getContentPublishingLimit() {
return new APIRequestGetContentPublishingLimit(this.getPrefixedId().toString(), context);
}
public APIRequestGetConversations getConversations() {
return new APIRequestGetConversations(this.getPrefixedId().toString(), context);
}
public APIRequestGetLiveMedia getLiveMedia() {
return new APIRequestGetLiveMedia(this.getPrefixedId().toString(), context);
}
public APIRequestGetMedia getMedia() {
return new APIRequestGetMedia(this.getPrefixedId().toString(), context);
}
public APIRequestCreateMedia createMedia() {
return new APIRequestCreateMedia(this.getPrefixedId().toString(), context);
}
public APIRequestCreateMediaPublish createMediaPublish() {
return new APIRequestCreateMediaPublish(this.getPrefixedId().toString(), context);
}
public APIRequestCreateMention createMention() {
return new APIRequestCreateMention(this.getPrefixedId().toString(), context);
}
public APIRequestCreateMessageAttachment createMessageAttachment() {
return new APIRequestCreateMessageAttachment(this.getPrefixedId().toString(), context);
}
public APIRequestCreateMessage createMessage() {
return new APIRequestCreateMessage(this.getPrefixedId().toString(), context);
}
public APIRequestDeleteMessengerProfile deleteMessengerProfile() {
return new APIRequestDeleteMessengerProfile(this.getPrefixedId().toString(), context);
}
public APIRequestGetMessengerProfile getMessengerProfile() {
return new APIRequestGetMessengerProfile(this.getPrefixedId().toString(), context);
}
public APIRequestCreateMessengerProfile createMessengerProfile() {
return new APIRequestCreateMessengerProfile(this.getPrefixedId().toString(), context);
}
public APIRequestGetStories getStories() {
return new APIRequestGetStories(this.getPrefixedId().toString(), context);
}
public APIRequestDeleteSubscribedApps deleteSubscribedApps() {
return new APIRequestDeleteSubscribedApps(this.getPrefixedId().toString(), context);
}
public APIRequestGetSubscribedApps getSubscribedApps() {
return new APIRequestGetSubscribedApps(this.getPrefixedId().toString(), context);
}
public APIRequestCreateSubscribedApp createSubscribedApp() {
return new APIRequestCreateSubscribedApp(this.getPrefixedId().toString(), context);
}
public APIRequestGetTags getTags() {
return new APIRequestGetTags(this.getPrefixedId().toString(), context);
}
public APIRequestGetWelcomeMessageFlows getWelcomeMessageFlows() {
return new APIRequestGetWelcomeMessageFlows(this.getPrefixedId().toString(), context);
}
public APIRequestGet get() {
return new APIRequestGet(this.getPrefixedId().toString(), context);
}
public String getFieldAccountType() {
return mAccountType;
}
public String getFieldBiography() {
return mBiography;
}
public Long getFieldFollowersCount() {
return mFollowersCount;
}
public Long getFieldFollowsCount() {
return mFollowsCount;
}
public String getFieldId() {
return mId;
}
public Long getFieldMediaCount() {
return mMediaCount;
}
public String getFieldName() {
return mName;
}
public String getFieldProfilePictureUrl() {
return mProfilePictureUrl;
}
public Long getFieldUserId() {
return mUserId;
}
public String getFieldUsername() {
return mUsername;
}
public String getFieldWebsite() {
return mWebsite;
}
public static class APIRequestGetContentPublishingLimit extends APIRequest {
APINodeList lastResponse = null;
@Override
public APINodeList getLastResponse() {
return lastResponse;
}
public static final String[] PARAMS = {
"since",
};
public static final String[] FIELDS = {
"config",
"quota_usage",
};
@Override
public APINodeList parseResponse(String response, String header) throws APIException {
return ContentPublishingLimitResponse.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 APIRequestGetContentPublishingLimit.this.parseResponse(result.getBody(), result.getHeader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
},
MoreExecutors.directExecutor()
);
};
public APIRequestGetContentPublishingLimit(String nodeId, APIContext context) {
super(context, nodeId, "/content_publishing_limit", "GET", Arrays.asList(PARAMS));
}
@Override
public APIRequestGetContentPublishingLimit setParam(String param, Object value) {
setParamInternal(param, value);
return this;
}
@Override
public APIRequestGetContentPublishingLimit setParams(Map params) {
setParamsInternal(params);
return this;
}
public APIRequestGetContentPublishingLimit setSince (String since) {
this.setParam("since", since);
return this;
}
public APIRequestGetContentPublishingLimit requestAllFields () {
return this.requestAllFields(true);
}
public APIRequestGetContentPublishingLimit requestAllFields (boolean value) {
for (String field : FIELDS) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGetContentPublishingLimit requestFields (List fields) {
return this.requestFields(fields, true);
}
@Override
public APIRequestGetContentPublishingLimit requestFields (List fields, boolean value) {
for (String field : fields) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGetContentPublishingLimit requestField (String field) {
this.requestField(field, true);
return this;
}
@Override
public APIRequestGetContentPublishingLimit requestField (String field, boolean value) {
this.requestFieldInternal(field, value);
return this;
}
public APIRequestGetContentPublishingLimit requestConfigField () {
return this.requestConfigField(true);
}
public APIRequestGetContentPublishingLimit requestConfigField (boolean value) {
this.requestField("config", value);
return this;
}
public APIRequestGetContentPublishingLimit requestQuotaUsageField () {
return this.requestQuotaUsageField(true);
}
public APIRequestGetContentPublishingLimit requestQuotaUsageField (boolean value) {
this.requestField("quota_usage", value);
return this;
}
}
public static class APIRequestGetConversations extends APIRequest {
APINodeList lastResponse = null;
@Override
public APINodeList getLastResponse() {
return lastResponse;
}
public static final String[] PARAMS = {
"folder",
"platform",
"tags",
"user_id",
};
public static final String[] FIELDS = {
"can_reply",
"folder",
"former_participants",
"id",
"is_subscribed",
"link",
"linked_group",
"message_count",
"name",
"participants",
"scoped_thread_key",
"senders",
"snippet",
"subject",
"unread_count",
"updated_time",
"wallpaper",
};
@Override
public APINodeList parseResponse(String response, String header) throws APIException {
return UnifiedThread.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 APIRequestGetConversations.this.parseResponse(result.getBody(), result.getHeader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
},
MoreExecutors.directExecutor()
);
};
public APIRequestGetConversations(String nodeId, APIContext context) {
super(context, nodeId, "/conversations", "GET", Arrays.asList(PARAMS));
}
@Override
public APIRequestGetConversations setParam(String param, Object value) {
setParamInternal(param, value);
return this;
}
@Override
public APIRequestGetConversations setParams(Map params) {
setParamsInternal(params);
return this;
}
public APIRequestGetConversations setFolder (String folder) {
this.setParam("folder", folder);
return this;
}
public APIRequestGetConversations setPlatform (UnifiedThread.EnumPlatform platform) {
this.setParam("platform", platform);
return this;
}
public APIRequestGetConversations setPlatform (String platform) {
this.setParam("platform", platform);
return this;
}
public APIRequestGetConversations setTags (List tags) {
this.setParam("tags", tags);
return this;
}
public APIRequestGetConversations setTags (String tags) {
this.setParam("tags", tags);
return this;
}
public APIRequestGetConversations setUserId (String userId) {
this.setParam("user_id", userId);
return this;
}
public APIRequestGetConversations requestAllFields () {
return this.requestAllFields(true);
}
public APIRequestGetConversations requestAllFields (boolean value) {
for (String field : FIELDS) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGetConversations requestFields (List fields) {
return this.requestFields(fields, true);
}
@Override
public APIRequestGetConversations requestFields (List fields, boolean value) {
for (String field : fields) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGetConversations requestField (String field) {
this.requestField(field, true);
return this;
}
@Override
public APIRequestGetConversations requestField (String field, boolean value) {
this.requestFieldInternal(field, value);
return this;
}
public APIRequestGetConversations requestCanReplyField () {
return this.requestCanReplyField(true);
}
public APIRequestGetConversations requestCanReplyField (boolean value) {
this.requestField("can_reply", value);
return this;
}
public APIRequestGetConversations requestFolderField () {
return this.requestFolderField(true);
}
public APIRequestGetConversations requestFolderField (boolean value) {
this.requestField("folder", value);
return this;
}
public APIRequestGetConversations requestFormerParticipantsField () {
return this.requestFormerParticipantsField(true);
}
public APIRequestGetConversations requestFormerParticipantsField (boolean value) {
this.requestField("former_participants", value);
return this;
}
public APIRequestGetConversations requestIdField () {
return this.requestIdField(true);
}
public APIRequestGetConversations requestIdField (boolean value) {
this.requestField("id", value);
return this;
}
public APIRequestGetConversations requestIsSubscribedField () {
return this.requestIsSubscribedField(true);
}
public APIRequestGetConversations requestIsSubscribedField (boolean value) {
this.requestField("is_subscribed", value);
return this;
}
public APIRequestGetConversations requestLinkField () {
return this.requestLinkField(true);
}
public APIRequestGetConversations requestLinkField (boolean value) {
this.requestField("link", value);
return this;
}
public APIRequestGetConversations requestLinkedGroupField () {
return this.requestLinkedGroupField(true);
}
public APIRequestGetConversations requestLinkedGroupField (boolean value) {
this.requestField("linked_group", value);
return this;
}
public APIRequestGetConversations requestMessageCountField () {
return this.requestMessageCountField(true);
}
public APIRequestGetConversations requestMessageCountField (boolean value) {
this.requestField("message_count", value);
return this;
}
public APIRequestGetConversations requestNameField () {
return this.requestNameField(true);
}
public APIRequestGetConversations requestNameField (boolean value) {
this.requestField("name", value);
return this;
}
public APIRequestGetConversations requestParticipantsField () {
return this.requestParticipantsField(true);
}
public APIRequestGetConversations requestParticipantsField (boolean value) {
this.requestField("participants", value);
return this;
}
public APIRequestGetConversations requestScopedThreadKeyField () {
return this.requestScopedThreadKeyField(true);
}
public APIRequestGetConversations requestScopedThreadKeyField (boolean value) {
this.requestField("scoped_thread_key", value);
return this;
}
public APIRequestGetConversations requestSendersField () {
return this.requestSendersField(true);
}
public APIRequestGetConversations requestSendersField (boolean value) {
this.requestField("senders", value);
return this;
}
public APIRequestGetConversations requestSnippetField () {
return this.requestSnippetField(true);
}
public APIRequestGetConversations requestSnippetField (boolean value) {
this.requestField("snippet", value);
return this;
}
public APIRequestGetConversations requestSubjectField () {
return this.requestSubjectField(true);
}
public APIRequestGetConversations requestSubjectField (boolean value) {
this.requestField("subject", value);
return this;
}
public APIRequestGetConversations requestUnreadCountField () {
return this.requestUnreadCountField(true);
}
public APIRequestGetConversations requestUnreadCountField (boolean value) {
this.requestField("unread_count", value);
return this;
}
public APIRequestGetConversations requestUpdatedTimeField () {
return this.requestUpdatedTimeField(true);
}
public APIRequestGetConversations requestUpdatedTimeField (boolean value) {
this.requestField("updated_time", value);
return this;
}
public APIRequestGetConversations requestWallpaperField () {
return this.requestWallpaperField(true);
}
public APIRequestGetConversations requestWallpaperField (boolean value) {
this.requestField("wallpaper", value);
return this;
}
}
public static class APIRequestGetLiveMedia extends APIRequest {
APINodeList lastResponse = null;
@Override
public APINodeList getLastResponse() {
return lastResponse;
}
public static final String[] PARAMS = {
};
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 APIRequestGetLiveMedia.this.parseResponse(result.getBody(), result.getHeader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
},
MoreExecutors.directExecutor()
);
};
public APIRequestGetLiveMedia(String nodeId, APIContext context) {
super(context, nodeId, "/live_media", "GET", Arrays.asList(PARAMS));
}
@Override
public APIRequestGetLiveMedia setParam(String param, Object value) {
setParamInternal(param, value);
return this;
}
@Override
public APIRequestGetLiveMedia setParams(Map params) {
setParamsInternal(params);
return this;
}
public APIRequestGetLiveMedia requestAllFields () {
return this.requestAllFields(true);
}
public APIRequestGetLiveMedia requestAllFields (boolean value) {
for (String field : FIELDS) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGetLiveMedia requestFields (List fields) {
return this.requestFields(fields, true);
}
@Override
public APIRequestGetLiveMedia requestFields (List fields, boolean value) {
for (String field : fields) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGetLiveMedia requestField (String field) {
this.requestField(field, true);
return this;
}
@Override
public APIRequestGetLiveMedia requestField (String field, boolean value) {
this.requestFieldInternal(field, value);
return this;
}
}
public static class APIRequestGetMedia extends APIRequest {
APINodeList lastResponse = null;
@Override
public APINodeList getLastResponse() {
return lastResponse;
}
public static final String[] PARAMS = {
"since",
"until",
};
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 APIRequestGetMedia.this.parseResponse(result.getBody(), result.getHeader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
},
MoreExecutors.directExecutor()
);
};
public APIRequestGetMedia(String nodeId, APIContext context) {
super(context, nodeId, "/media", "GET", Arrays.asList(PARAMS));
}
@Override
public APIRequestGetMedia setParam(String param, Object value) {
setParamInternal(param, value);
return this;
}
@Override
public APIRequestGetMedia setParams(Map params) {
setParamsInternal(params);
return this;
}
public APIRequestGetMedia setSince (String since) {
this.setParam("since", since);
return this;
}
public APIRequestGetMedia setUntil (String until) {
this.setParam("until", until);
return this;
}
public APIRequestGetMedia requestAllFields () {
return this.requestAllFields(true);
}
public APIRequestGetMedia requestAllFields (boolean value) {
for (String field : FIELDS) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGetMedia requestFields (List fields) {
return this.requestFields(fields, true);
}
@Override
public APIRequestGetMedia requestFields (List fields, boolean value) {
for (String field : fields) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGetMedia requestField (String field) {
this.requestField(field, true);
return this;
}
@Override
public APIRequestGetMedia requestField (String field, boolean value) {
this.requestFieldInternal(field, value);
return this;
}
}
public static class APIRequestCreateMedia extends APIRequest {
APINode lastResponse = null;
@Override
public APINode getLastResponse() {
return lastResponse;
}
public static final String[] PARAMS = {
"audio_name",
"caption",
"children",
"collaborators",
"cover_url",
"image_url",
"is_carousel_item",
"location_id",
"media_type",
"product_tags",
"share_to_feed",
"thumb_offset",
"upload_type",
"user_tags",
"video_url",
};
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 APIRequestCreateMedia.this.parseResponse(result.getBody(), result.getHeader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
},
MoreExecutors.directExecutor()
);
};
public APIRequestCreateMedia(String nodeId, APIContext context) {
super(context, nodeId, "/media", "POST", Arrays.asList(PARAMS));
}
@Override
public APIRequestCreateMedia setParam(String param, Object value) {
setParamInternal(param, value);
return this;
}
@Override
public APIRequestCreateMedia setParams(Map params) {
setParamsInternal(params);
return this;
}
public APIRequestCreateMedia setAudioName (String audioName) {
this.setParam("audio_name", audioName);
return this;
}
public APIRequestCreateMedia setCaption (String caption) {
this.setParam("caption", caption);
return this;
}
public APIRequestCreateMedia setChildren (List children) {
this.setParam("children", children);
return this;
}
public APIRequestCreateMedia setChildren (String children) {
this.setParam("children", children);
return this;
}
public APIRequestCreateMedia setCollaborators (List collaborators) {
this.setParam("collaborators", collaborators);
return this;
}
public APIRequestCreateMedia setCollaborators (String collaborators) {
this.setParam("collaborators", collaborators);
return this;
}
public APIRequestCreateMedia setCoverUrl (String coverUrl) {
this.setParam("cover_url", coverUrl);
return this;
}
public APIRequestCreateMedia setImageUrl (String imageUrl) {
this.setParam("image_url", imageUrl);
return this;
}
public APIRequestCreateMedia setIsCarouselItem (Boolean isCarouselItem) {
this.setParam("is_carousel_item", isCarouselItem);
return this;
}
public APIRequestCreateMedia setIsCarouselItem (String isCarouselItem) {
this.setParam("is_carousel_item", isCarouselItem);
return this;
}
public APIRequestCreateMedia setLocationId (String locationId) {
this.setParam("location_id", locationId);
return this;
}
public APIRequestCreateMedia setMediaType (String mediaType) {
this.setParam("media_type", mediaType);
return this;
}
public APIRequestCreateMedia setProductTags (List