com.facebook.ads.sdk.IGUser 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 IGUser extends APINode {
@SerializedName("biography")
private String mBiography = null;
@SerializedName("business_discovery")
private IGUser mBusinessDiscovery = null;
@SerializedName("followers_count")
private Long mFollowersCount = null;
@SerializedName("follows_count")
private Long mFollowsCount = null;
@SerializedName("id")
private String mId = null;
@SerializedName("ig_id")
private Long mIgId = null;
@SerializedName("media_count")
private Long mMediaCount = null;
@SerializedName("mentioned_comment")
private IGComment mMentionedComment = null;
@SerializedName("mentioned_media")
private IGMedia mMentionedMedia = null;
@SerializedName("name")
private String mName = null;
@SerializedName("owner_business")
private Business mOwnerBusiness = null;
@SerializedName("profile_picture_url")
private String mProfilePictureUrl = null;
@SerializedName("shopping_product_tag_eligibility")
private Boolean mShoppingProductTagEligibility = null;
@SerializedName("shopping_review_status")
private String mShoppingReviewStatus = null;
@SerializedName("username")
private String mUsername = null;
@SerializedName("website")
private String mWebsite = null;
protected static Gson gson = null;
IGUser() {
}
public IGUser(Long id, APIContext context) {
this(id.toString(), context);
}
public IGUser(String id, APIContext context) {
this.mId = id;
this.context = context;
}
public IGUser fetch() throws APIException{
IGUser newInstance = fetchById(this.getPrefixedId().toString(), this.context);
this.copyFrom(newInstance);
return this;
}
public static IGUser 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 IGUser 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", IGUser.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", IGUser.getParser())
.setParam("ids", APIRequest.joinStringList(ids))
.requestFields(fields)
.executeAsyncBase();
}
private String getPrefixedId() {
return getId();
}
public String getId() {
return getFieldId().toString();
}
public static IGUser loadJSON(String json, APIContext context, String header) {
IGUser igUser = getGson().fromJson(json, IGUser.class);
if (context.isDebug()) {
JsonParser parser = new JsonParser();
JsonElement o1 = parser.parse(json);
JsonElement o2 = parser.parse(igUser.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);
}
}
igUser.context = context;
igUser.rawValue = json;
igUser.header = header;
return igUser;
}
public static APINodeList parseResponse(String json, APIContext context, APIRequest request, String header) throws MalformedResponseException {
APINodeList igUsers = 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++) {
igUsers.add(loadJSON(arr.get(i).getAsJsonObject().toString(), context, header));
};
return igUsers;
} 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;
igUsers.setCursors(before, after);
}
String previous = paging.has("previous") ? paging.get("previous").getAsString() : null;
String next = paging.has("next") ? paging.get("next").getAsString() : null;
igUsers.setPaging(previous, next);
if (context.hasAppSecret()) {
igUsers.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++) {
igUsers.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()) {
igUsers.add(loadJSON(entry.getValue().toString(), context, header));
}
break;
}
}
if (!isRedownload) {
igUsers.add(loadJSON(obj.toString(), context, header));
}
}
return igUsers;
} 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()) {
igUsers.add(loadJSON(entry.getValue().toString(), context, header));
}
return igUsers;
} 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)
) {
igUsers.add(loadJSON(value.toString(), context, header));
} else {
isIdIndexedArray = false;
break;
}
}
if (isIdIndexedArray) {
return igUsers;
}
// Sixth, check if it's pure JsonObject
igUsers.clear();
igUsers.add(loadJSON(json, context, header));
return igUsers;
}
}
} 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 APIRequestGetAvailableCatalogs getAvailableCatalogs() {
return new APIRequestGetAvailableCatalogs(this.getPrefixedId().toString(), context);
}
public APIRequestGetCatalogProductSearch getCatalogProductSearch() {
return new APIRequestGetCatalogProductSearch(this.getPrefixedId().toString(), context);
}
public APIRequestGetContentPublishingLimit getContentPublishingLimit() {
return new APIRequestGetContentPublishingLimit(this.getPrefixedId().toString(), context);
}
public APIRequestGetInsights getInsights() {
return new APIRequestGetInsights(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 APIRequestGetNotificationMessageTokens getNotificationMessageTokens() {
return new APIRequestGetNotificationMessageTokens(this.getPrefixedId().toString(), context);
}
public APIRequestGetProductAppeal getProductAppeal() {
return new APIRequestGetProductAppeal(this.getPrefixedId().toString(), context);
}
public APIRequestCreateProductAppeal createProductAppeal() {
return new APIRequestCreateProductAppeal(this.getPrefixedId().toString(), context);
}
public APIRequestGetRecentlySearchedHashtags getRecentlySearchedHashtags() {
return new APIRequestGetRecentlySearchedHashtags(this.getPrefixedId().toString(), context);
}
public APIRequestGetStories getStories() {
return new APIRequestGetStories(this.getPrefixedId().toString(), context);
}
public APIRequestGetTags getTags() {
return new APIRequestGetTags(this.getPrefixedId().toString(), context);
}
public APIRequestGet get() {
return new APIRequestGet(this.getPrefixedId().toString(), context);
}
public String getFieldBiography() {
return mBiography;
}
public IGUser getFieldBusinessDiscovery() {
if (mBusinessDiscovery != null) {
mBusinessDiscovery.context = getContext();
}
return mBusinessDiscovery;
}
public Long getFieldFollowersCount() {
return mFollowersCount;
}
public Long getFieldFollowsCount() {
return mFollowsCount;
}
public String getFieldId() {
return mId;
}
public Long getFieldIgId() {
return mIgId;
}
public Long getFieldMediaCount() {
return mMediaCount;
}
public IGComment getFieldMentionedComment() {
if (mMentionedComment != null) {
mMentionedComment.context = getContext();
}
return mMentionedComment;
}
public IGMedia getFieldMentionedMedia() {
if (mMentionedMedia != null) {
mMentionedMedia.context = getContext();
}
return mMentionedMedia;
}
public String getFieldName() {
return mName;
}
public Business getFieldOwnerBusiness() {
if (mOwnerBusiness != null) {
mOwnerBusiness.context = getContext();
}
return mOwnerBusiness;
}
public String getFieldProfilePictureUrl() {
return mProfilePictureUrl;
}
public Boolean getFieldShoppingProductTagEligibility() {
return mShoppingProductTagEligibility;
}
public String getFieldShoppingReviewStatus() {
return mShoppingReviewStatus;
}
public String getFieldUsername() {
return mUsername;
}
public String getFieldWebsite() {
return mWebsite;
}
public static class APIRequestGetAvailableCatalogs 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 APIRequestGetAvailableCatalogs.this.parseResponse(result.getBody(), result.getHeader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
);
};
public APIRequestGetAvailableCatalogs(String nodeId, APIContext context) {
super(context, nodeId, "/available_catalogs", "GET", Arrays.asList(PARAMS));
}
@Override
public APIRequestGetAvailableCatalogs setParam(String param, Object value) {
setParamInternal(param, value);
return this;
}
@Override
public APIRequestGetAvailableCatalogs setParams(Map params) {
setParamsInternal(params);
return this;
}
public APIRequestGetAvailableCatalogs requestAllFields () {
return this.requestAllFields(true);
}
public APIRequestGetAvailableCatalogs requestAllFields (boolean value) {
for (String field : FIELDS) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGetAvailableCatalogs requestFields (List fields) {
return this.requestFields(fields, true);
}
@Override
public APIRequestGetAvailableCatalogs requestFields (List fields, boolean value) {
for (String field : fields) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGetAvailableCatalogs requestField (String field) {
this.requestField(field, true);
return this;
}
@Override
public APIRequestGetAvailableCatalogs requestField (String field, boolean value) {
this.requestFieldInternal(field, value);
return this;
}
}
public static class APIRequestGetCatalogProductSearch extends APIRequest {
APINodeList lastResponse = null;
@Override
public APINodeList getLastResponse() {
return lastResponse;
}
public static final String[] PARAMS = {
"catalog_id",
"q",
};
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 APIRequestGetCatalogProductSearch.this.parseResponse(result.getBody(), result.getHeader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
);
};
public APIRequestGetCatalogProductSearch(String nodeId, APIContext context) {
super(context, nodeId, "/catalog_product_search", "GET", Arrays.asList(PARAMS));
}
@Override
public APIRequestGetCatalogProductSearch setParam(String param, Object value) {
setParamInternal(param, value);
return this;
}
@Override
public APIRequestGetCatalogProductSearch setParams(Map params) {
setParamsInternal(params);
return this;
}
public APIRequestGetCatalogProductSearch setCatalogId (String catalogId) {
this.setParam("catalog_id", catalogId);
return this;
}
public APIRequestGetCatalogProductSearch setQ (String q) {
this.setParam("q", q);
return this;
}
public APIRequestGetCatalogProductSearch requestAllFields () {
return this.requestAllFields(true);
}
public APIRequestGetCatalogProductSearch requestAllFields (boolean value) {
for (String field : FIELDS) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGetCatalogProductSearch requestFields (List fields) {
return this.requestFields(fields, true);
}
@Override
public APIRequestGetCatalogProductSearch requestFields (List fields, boolean value) {
for (String field : fields) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGetCatalogProductSearch requestField (String field) {
this.requestField(field, true);
return this;
}
@Override
public APIRequestGetCatalogProductSearch requestField (String field, boolean value) {
this.requestFieldInternal(field, value);
return this;
}
}
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 = {
};
@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 APIRequestGetContentPublishingLimit.this.parseResponse(result.getBody(), result.getHeader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
);
};
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 static class APIRequestGetInsights extends APIRequest {
APINodeList lastResponse = null;
@Override
public APINodeList getLastResponse() {
return lastResponse;
}
public static final String[] PARAMS = {
"breakdown",
"metric",
"metric_type",
"period",
"since",
"timeframe",
"until",
};
public static final String[] FIELDS = {
"description",
"id",
"name",
"period",
"title",
"total_value",
"values",
};
@Override
public APINodeList parseResponse(String response, String header) throws APIException {
return InstagramInsightsResult.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 APIRequestGetInsights.this.parseResponse(result.getBody(), result.getHeader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
);
};
public APIRequestGetInsights(String nodeId, APIContext context) {
super(context, nodeId, "/insights", "GET", Arrays.asList(PARAMS));
}
@Override
public APIRequestGetInsights setParam(String param, Object value) {
setParamInternal(param, value);
return this;
}
@Override
public APIRequestGetInsights setParams(Map params) {
setParamsInternal(params);
return this;
}
public APIRequestGetInsights setBreakdown (List breakdown) {
this.setParam("breakdown", breakdown);
return this;
}
public APIRequestGetInsights setBreakdown (String breakdown) {
this.setParam("breakdown", breakdown);
return this;
}
public APIRequestGetInsights setMetric (List metric) {
this.setParam("metric", metric);
return this;
}
public APIRequestGetInsights setMetric (String metric) {
this.setParam("metric", metric);
return this;
}
public APIRequestGetInsights setMetricType (InstagramInsightsResult.EnumMetricType metricType) {
this.setParam("metric_type", metricType);
return this;
}
public APIRequestGetInsights setMetricType (String metricType) {
this.setParam("metric_type", metricType);
return this;
}
public APIRequestGetInsights setPeriod (List period) {
this.setParam("period", period);
return this;
}
public APIRequestGetInsights setPeriod (String period) {
this.setParam("period", period);
return this;
}
public APIRequestGetInsights setSince (String since) {
this.setParam("since", since);
return this;
}
public APIRequestGetInsights setTimeframe (InstagramInsightsResult.EnumTimeframe timeframe) {
this.setParam("timeframe", timeframe);
return this;
}
public APIRequestGetInsights setTimeframe (String timeframe) {
this.setParam("timeframe", timeframe);
return this;
}
public APIRequestGetInsights setUntil (String until) {
this.setParam("until", until);
return this;
}
public APIRequestGetInsights requestAllFields () {
return this.requestAllFields(true);
}
public APIRequestGetInsights requestAllFields (boolean value) {
for (String field : FIELDS) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGetInsights requestFields (List fields) {
return this.requestFields(fields, true);
}
@Override
public APIRequestGetInsights requestFields (List fields, boolean value) {
for (String field : fields) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGetInsights requestField (String field) {
this.requestField(field, true);
return this;
}
@Override
public APIRequestGetInsights requestField (String field, boolean value) {
this.requestFieldInternal(field, value);
return this;
}
public APIRequestGetInsights requestDescriptionField () {
return this.requestDescriptionField(true);
}
public APIRequestGetInsights requestDescriptionField (boolean value) {
this.requestField("description", value);
return this;
}
public APIRequestGetInsights requestIdField () {
return this.requestIdField(true);
}
public APIRequestGetInsights requestIdField (boolean value) {
this.requestField("id", value);
return this;
}
public APIRequestGetInsights requestNameField () {
return this.requestNameField(true);
}
public APIRequestGetInsights requestNameField (boolean value) {
this.requestField("name", value);
return this;
}
public APIRequestGetInsights requestPeriodField () {
return this.requestPeriodField(true);
}
public APIRequestGetInsights requestPeriodField (boolean value) {
this.requestField("period", value);
return this;
}
public APIRequestGetInsights requestTitleField () {
return this.requestTitleField(true);
}
public APIRequestGetInsights requestTitleField (boolean value) {
this.requestField("title", value);
return this;
}
public APIRequestGetInsights requestTotalValueField () {
return this.requestTotalValueField(true);
}
public APIRequestGetInsights requestTotalValueField (boolean value) {
this.requestField("total_value", value);
return this;
}
public APIRequestGetInsights requestValuesField () {
return this.requestValuesField(true);
}
public APIRequestGetInsights requestValuesField (boolean value) {
this.requestField("values", value);
return this;
}
}
public static class APIRequestGetLiveMedia extends APIRequest {
APINodeList lastResponse = null;
@Override
public APINodeList getLastResponse() {
return lastResponse;
}
public static final String[] PARAMS = {
"since",
"until",
};
public static final String[] FIELDS = {
"caption",
"comments_count",
"id",
"ig_id",
"is_comment_enabled",
"is_shared_to_feed",
"like_count",
"media_product_type",
"media_type",
"media_url",
"owner",
"permalink",
"shortcode",
"thumbnail_url",
"timestamp",
"username",
};
@Override
public APINodeList parseResponse(String response, String header) throws APIException {
return IGMedia.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);
}
}
}
);
};
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 setSince (String since) {
this.setParam("since", since);
return this;
}
public APIRequestGetLiveMedia setUntil (String until) {
this.setParam("until", until);
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 APIRequestGetLiveMedia requestCaptionField () {
return this.requestCaptionField(true);
}
public APIRequestGetLiveMedia requestCaptionField (boolean value) {
this.requestField("caption", value);
return this;
}
public APIRequestGetLiveMedia requestCommentsCountField () {
return this.requestCommentsCountField(true);
}
public APIRequestGetLiveMedia requestCommentsCountField (boolean value) {
this.requestField("comments_count", value);
return this;
}
public APIRequestGetLiveMedia requestIdField () {
return this.requestIdField(true);
}
public APIRequestGetLiveMedia requestIdField (boolean value) {
this.requestField("id", value);
return this;
}
public APIRequestGetLiveMedia requestIgIdField () {
return this.requestIgIdField(true);
}
public APIRequestGetLiveMedia requestIgIdField (boolean value) {
this.requestField("ig_id", value);
return this;
}
public APIRequestGetLiveMedia requestIsCommentEnabledField () {
return this.requestIsCommentEnabledField(true);
}
public APIRequestGetLiveMedia requestIsCommentEnabledField (boolean value) {
this.requestField("is_comment_enabled", value);
return this;
}
public APIRequestGetLiveMedia requestIsSharedToFeedField () {
return this.requestIsSharedToFeedField(true);
}
public APIRequestGetLiveMedia requestIsSharedToFeedField (boolean value) {
this.requestField("is_shared_to_feed", value);
return this;
}
public APIRequestGetLiveMedia requestLikeCountField () {
return this.requestLikeCountField(true);
}
public APIRequestGetLiveMedia requestLikeCountField (boolean value) {
this.requestField("like_count", value);
return this;
}
public APIRequestGetLiveMedia requestMediaProductTypeField () {
return this.requestMediaProductTypeField(true);
}
public APIRequestGetLiveMedia requestMediaProductTypeField (boolean value) {
this.requestField("media_product_type", value);
return this;
}
public APIRequestGetLiveMedia requestMediaTypeField () {
return this.requestMediaTypeField(true);
}
public APIRequestGetLiveMedia requestMediaTypeField (boolean value) {
this.requestField("media_type", value);
return this;
}
public APIRequestGetLiveMedia requestMediaUrlField () {
return this.requestMediaUrlField(true);
}
public APIRequestGetLiveMedia requestMediaUrlField (boolean value) {
this.requestField("media_url", value);
return this;
}
public APIRequestGetLiveMedia requestOwnerField () {
return this.requestOwnerField(true);
}
public APIRequestGetLiveMedia requestOwnerField (boolean value) {
this.requestField("owner", value);
return this;
}
public APIRequestGetLiveMedia requestPermalinkField () {
return this.requestPermalinkField(true);
}
public APIRequestGetLiveMedia requestPermalinkField (boolean value) {
this.requestField("permalink", value);
return this;
}
public APIRequestGetLiveMedia requestShortcodeField () {
return this.requestShortcodeField(true);
}
public APIRequestGetLiveMedia requestShortcodeField (boolean value) {
this.requestField("shortcode", value);
return this;
}
public APIRequestGetLiveMedia requestThumbnailUrlField () {
return this.requestThumbnailUrlField(true);
}
public APIRequestGetLiveMedia requestThumbnailUrlField (boolean value) {
this.requestField("thumbnail_url", value);
return this;
}
public APIRequestGetLiveMedia requestTimestampField () {
return this.requestTimestampField(true);
}
public APIRequestGetLiveMedia requestTimestampField (boolean value) {
this.requestField("timestamp", value);
return this;
}
public APIRequestGetLiveMedia requestUsernameField () {
return this.requestUsernameField(true);
}
public APIRequestGetLiveMedia requestUsernameField (boolean value) {
this.requestField("username", 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 = {
"caption",
"comments_count",
"id",
"ig_id",
"is_comment_enabled",
"is_shared_to_feed",
"like_count",
"media_product_type",
"media_type",
"media_url",
"owner",
"permalink",
"shortcode",
"thumbnail_url",
"timestamp",
"username",
};
@Override
public APINodeList parseResponse(String response, String header) throws APIException {
return IGMedia.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);
}
}
}
);
};
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 APIRequestGetMedia requestCaptionField () {
return this.requestCaptionField(true);
}
public APIRequestGetMedia requestCaptionField (boolean value) {
this.requestField("caption", value);
return this;
}
public APIRequestGetMedia requestCommentsCountField () {
return this.requestCommentsCountField(true);
}
public APIRequestGetMedia requestCommentsCountField (boolean value) {
this.requestField("comments_count", value);
return this;
}
public APIRequestGetMedia requestIdField () {
return this.requestIdField(true);
}
public APIRequestGetMedia requestIdField (boolean value) {
this.requestField("id", value);
return this;
}
public APIRequestGetMedia requestIgIdField () {
return this.requestIgIdField(true);
}
public APIRequestGetMedia requestIgIdField (boolean value) {
this.requestField("ig_id", value);
return this;
}
public APIRequestGetMedia requestIsCommentEnabledField () {
return this.requestIsCommentEnabledField(true);
}
public APIRequestGetMedia requestIsCommentEnabledField (boolean value) {
this.requestField("is_comment_enabled", value);
return this;
}
public APIRequestGetMedia requestIsSharedToFeedField () {
return this.requestIsSharedToFeedField(true);
}
public APIRequestGetMedia requestIsSharedToFeedField (boolean value) {
this.requestField("is_shared_to_feed", value);
return this;
}
public APIRequestGetMedia requestLikeCountField () {
return this.requestLikeCountField(true);
}
public APIRequestGetMedia requestLikeCountField (boolean value) {
this.requestField("like_count", value);
return this;
}
public APIRequestGetMedia requestMediaProductTypeField () {
return this.requestMediaProductTypeField(true);
}
public APIRequestGetMedia requestMediaProductTypeField (boolean value) {
this.requestField("media_product_type", value);
return this;
}
public APIRequestGetMedia requestMediaTypeField () {
return this.requestMediaTypeField(true);
}
public APIRequestGetMedia requestMediaTypeField (boolean value) {
this.requestField("media_type", value);
return this;
}
public APIRequestGetMedia requestMediaUrlField () {
return this.requestMediaUrlField(true);
}
public APIRequestGetMedia requestMediaUrlField (boolean value) {
this.requestField("media_url", value);
return this;
}
public APIRequestGetMedia requestOwnerField () {
return this.requestOwnerField(true);
}
public APIRequestGetMedia requestOwnerField (boolean value) {
this.requestField("owner", value);
return this;
}
public APIRequestGetMedia requestPermalinkField () {
return this.requestPermalinkField(true);
}
public APIRequestGetMedia requestPermalinkField (boolean value) {
this.requestField("permalink", value);
return this;
}
public APIRequestGetMedia requestShortcodeField () {
return this.requestShortcodeField(true);
}
public APIRequestGetMedia requestShortcodeField (boolean value) {
this.requestField("shortcode", value);
return this;
}
public APIRequestGetMedia requestThumbnailUrlField () {
return this.requestThumbnailUrlField(true);
}
public APIRequestGetMedia requestThumbnailUrlField (boolean value) {
this.requestField("thumbnail_url", value);
return this;
}
public APIRequestGetMedia requestTimestampField () {
return this.requestTimestampField(true);
}
public APIRequestGetMedia requestTimestampField (boolean value) {
this.requestField("timestamp", value);
return this;
}
public APIRequestGetMedia requestUsernameField () {
return this.requestUsernameField(true);
}
public APIRequestGetMedia requestUsernameField (boolean value) {
this.requestField("username", value);
return this;
}
}
public static class APIRequestCreateMedia extends APIRequest {
IGMedia lastResponse = null;
@Override
public IGMedia getLastResponse() {
return lastResponse;
}
public static final String[] PARAMS = {
"audio_name",
"caption",
"children",
"cover_url",
"image_url",
"is_carousel_item",
"location_id",
"media_type",
"product_tags",
"share_to_feed",
"thumb_offset",
"user_tags",
"video_url",
};
public static final String[] FIELDS = {
};
@Override
public IGMedia parseResponse(String response, String header) throws APIException {
return IGMedia.parseResponse(response, getContext(), this, header).head();
}
@Override
public IGMedia execute() throws APIException {
return execute(new HashMap());
}
@Override
public IGMedia 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 IGMedia apply(ResponseWrapper result) {
try {
return APIRequestCreateMedia.this.parseResponse(result.getBody(), result.getHeader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
);
};
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 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