From 4d3173deb2cd5ae3c5df156852c819d40d9c7e0a Mon Sep 17 00:00:00 2001 From: generatedunixname89002005295453 Date: Tue, 23 Jan 2024 15:34:26 -0800 Subject: [PATCH] Auto-generated java SDK code update Summary: ignore-conflict-markers Reviewed By: stcheng Differential Revision: D53019933 fbshipit-source-id: 69b86a5a5647ceae3ea7845489db5c5bfa51f850 --- pom.xml | 2 +- .../java/com/facebook/ads/sdk/APIConfig.java | 4 +- .../java/com/facebook/ads/sdk/AdAccount.java | 165 ++++++ .../ads/sdk/AdAccountAdRulesHistory.java | 4 + .../facebook/ads/sdk/AdAccountAdVolume.java | 14 + .../ads/sdk/AdAccountBusinessConstraints.java | 24 + .../java/com/facebook/ads/sdk/AdCreative.java | 2 + .../ads/sdk/AdCreativeBrandedContentAds.java | 12 + .../facebook/ads/sdk/AdPromotedObject.java | 32 ++ .../com/facebook/ads/sdk/AdReportRun.java | 2 + .../facebook/ads/sdk/AdRuleExecutionSpec.java | 2 + .../com/facebook/ads/sdk/AdRuleHistory.java | 4 + .../java/com/facebook/ads/sdk/AdVideo.java | 6 +- .../com/facebook/ads/sdk/AdsActionStats.java | 48 ++ .../facebook/ads/sdk/AdsHistogramStats.java | 48 ++ .../com/facebook/ads/sdk/AdsInsights.java | 9 + .../java/com/facebook/ads/sdk/AdsPixel.java | 10 + .../com/facebook/ads/sdk/Application.java | 6 + .../java/com/facebook/ads/sdk/Business.java | 12 +- .../java/com/facebook/ads/sdk/Canvas.java | 116 ++++ .../com/facebook/ads/sdk/CanvasPreview.java | 235 ++++++++ .../com/facebook/ads/sdk/CustomAudience.java | 260 +++++++++ .../facebook/ads/sdk/CustomAudienceSalts.java | 247 ++++++++ .../ads/sdk/DestinationCatalogSettings.java | 420 -------------- .../java/com/facebook/ads/sdk/GameItem.java | 534 ------------------ src/main/java/com/facebook/ads/sdk/Group.java | 10 - .../java/com/facebook/ads/sdk/IGMedia.java | 24 + .../ads/sdk/InstagramInsightsResult.java | 4 + src/main/java/com/facebook/ads/sdk/Page.java | 190 ------- .../com/facebook/ads/sdk/ProductItem.java | 6 + .../java/com/facebook/ads/sdk/Profile.java | 10 - .../ads/sdk/ProfilePictureSource.java | 17 - src/main/java/com/facebook/ads/sdk/User.java | 334 ----------- .../ads/sdk/VideoCopyrightCheckStatus.java | 247 ++++++++ .../com/facebook/ads/sdk/VideoStatus.java | 315 +++++++++++ ...ticlesStats.java => VideoStatusError.java} | 128 ++--- .../ads/sdk/VideoStatusProcessingPhase.java | 252 +++++++++ .../ads/sdk/VideoStatusPublishingPhase.java | 276 +++++++++ .../ads/sdk/VideoStatusUploadingPhase.java | 276 +++++++++ .../ads/sdk/WhatsAppBusinessAccount.java | 6 - .../com/facebook/ads/sdk/WhitehatFBDLRun.java | 510 ----------------- 41 files changed, 2695 insertions(+), 2128 deletions(-) create mode 100644 src/main/java/com/facebook/ads/sdk/CanvasPreview.java create mode 100644 src/main/java/com/facebook/ads/sdk/CustomAudienceSalts.java delete mode 100644 src/main/java/com/facebook/ads/sdk/DestinationCatalogSettings.java delete mode 100644 src/main/java/com/facebook/ads/sdk/GameItem.java create mode 100644 src/main/java/com/facebook/ads/sdk/VideoCopyrightCheckStatus.java create mode 100644 src/main/java/com/facebook/ads/sdk/VideoStatus.java rename src/main/java/com/facebook/ads/sdk/{InstantArticlesStats.java => VideoStatusError.java} (60%) create mode 100644 src/main/java/com/facebook/ads/sdk/VideoStatusProcessingPhase.java create mode 100644 src/main/java/com/facebook/ads/sdk/VideoStatusPublishingPhase.java create mode 100644 src/main/java/com/facebook/ads/sdk/VideoStatusUploadingPhase.java delete mode 100644 src/main/java/com/facebook/ads/sdk/WhitehatFBDLRun.java diff --git a/pom.xml b/pom.xml index 57c1a392..c34aec3d 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.facebook.business.sdk facebook-java-business-sdk jar - 18.0.4 + 19.0.0 ${project.groupId}:${project.artifactId} Facebook Business Solutions SDK for Java https://developers.facebook.com/docs/marketing-api/sdks diff --git a/src/main/java/com/facebook/ads/sdk/APIConfig.java b/src/main/java/com/facebook/ads/sdk/APIConfig.java index 1c8c3281..f0a8787f 100644 --- a/src/main/java/com/facebook/ads/sdk/APIConfig.java +++ b/src/main/java/com/facebook/ads/sdk/APIConfig.java @@ -24,8 +24,8 @@ package com.facebook.ads.sdk; public class APIConfig { - public static final String DEFAULT_API_VERSION = "v18.0"; + public static final String DEFAULT_API_VERSION = "v19.0"; public static final String DEFAULT_API_BASE = "https://graph.facebook.com"; public static final String DEFAULT_VIDEO_API_BASE = "https://graph-video.facebook.com"; - public static final String USER_AGENT = "fbbizsdk-java-v18.0.4"; + public static final String USER_AGENT = "fbbizsdk-java-v19.0.0"; }; diff --git a/src/main/java/com/facebook/ads/sdk/AdAccount.java b/src/main/java/com/facebook/ads/sdk/AdAccount.java index 26f9eace..e4a866f3 100644 --- a/src/main/java/com/facebook/ads/sdk/AdAccount.java +++ b/src/main/java/com/facebook/ads/sdk/AdAccount.java @@ -561,6 +561,10 @@ public APIRequestGetAgencies getAgencies() { return new APIRequestGetAgencies(this.getPrefixedId().toString(), context); } + public APIRequestCreateAgency createAgency() { + return new APIRequestCreateAgency(this.getPrefixedId().toString(), context); + } + public APIRequestGetApplications getApplications() { return new APIRequestGetApplications(this.getPrefixedId().toString(), context); } @@ -1121,7 +1125,9 @@ public APINodeList getLastResponse() { public static final String[] FIELDS = { "audience_controls", + "campaigns_with_error", "placement_controls", + "status", }; @Override @@ -1220,6 +1226,13 @@ public APIRequestGetAccountControls requestAudienceControlsField (boolean value) this.requestField("audience_controls", value); return this; } + public APIRequestGetAccountControls requestCampaignsWithErrorField () { + return this.requestCampaignsWithErrorField(true); + } + public APIRequestGetAccountControls requestCampaignsWithErrorField (boolean value) { + this.requestField("campaigns_with_error", value); + return this; + } public APIRequestGetAccountControls requestPlacementControlsField () { return this.requestPlacementControlsField(true); } @@ -1227,6 +1240,13 @@ public APIRequestGetAccountControls requestPlacementControlsField (boolean value this.requestField("placement_controls", value); return this; } + public APIRequestGetAccountControls requestStatusField () { + return this.requestStatusField(true); + } + public APIRequestGetAccountControls requestStatusField (boolean value) { + this.requestField("status", value); + return this; + } } public static class APIRequestCreateAccountControl extends APIRequest { @@ -13170,6 +13190,126 @@ public APIRequestGetAgencies requestVerticalIdField (boolean value) { } } + public static class APIRequestCreateAgency extends APIRequest { + + AdAccount lastResponse = null; + @Override + public AdAccount getLastResponse() { + return lastResponse; + } + public static final String[] PARAMS = { + "business", + "permitted_tasks", + }; + + public static final String[] FIELDS = { + }; + + @Override + public AdAccount parseResponse(String response, String header) throws APIException { + return AdAccount.parseResponse(response, getContext(), this, header).head(); + } + + @Override + public AdAccount execute() throws APIException { + return execute(new HashMap()); + } + + @Override + public AdAccount 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 AdAccount apply(ResponseWrapper result) { + try { + return APIRequestCreateAgency.this.parseResponse(result.getBody(), result.getHeader()); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + ); + }; + + public APIRequestCreateAgency(String nodeId, APIContext context) { + super(context, nodeId, "/agencies", "POST", Arrays.asList(PARAMS)); + } + + @Override + public APIRequestCreateAgency setParam(String param, Object value) { + setParamInternal(param, value); + return this; + } + + @Override + public APIRequestCreateAgency setParams(Map params) { + setParamsInternal(params); + return this; + } + + + public APIRequestCreateAgency setBusiness (String business) { + this.setParam("business", business); + return this; + } + + public APIRequestCreateAgency setPermittedTasks (List permittedTasks) { + this.setParam("permitted_tasks", permittedTasks); + return this; + } + public APIRequestCreateAgency setPermittedTasks (String permittedTasks) { + this.setParam("permitted_tasks", permittedTasks); + return this; + } + + public APIRequestCreateAgency requestAllFields () { + return this.requestAllFields(true); + } + + public APIRequestCreateAgency requestAllFields (boolean value) { + for (String field : FIELDS) { + this.requestField(field, value); + } + return this; + } + + @Override + public APIRequestCreateAgency requestFields (List fields) { + return this.requestFields(fields, true); + } + + @Override + public APIRequestCreateAgency requestFields (List fields, boolean value) { + for (String field : fields) { + this.requestField(field, value); + } + return this; + } + + @Override + public APIRequestCreateAgency requestField (String field) { + this.requestField(field, true); + return this; + } + + @Override + public APIRequestCreateAgency requestField (String field, boolean value) { + this.requestFieldInternal(field, value); + return this; + } + + } + public static class APIRequestGetApplications extends APIRequest { APINodeList lastResponse = null; @@ -29091,6 +29231,31 @@ public String toString() { } } + public static enum EnumPermittedTasks { + @SerializedName("AA_ANALYZE") + VALUE_AA_ANALYZE("AA_ANALYZE"), + @SerializedName("ADVERTISE") + VALUE_ADVERTISE("ADVERTISE"), + @SerializedName("ANALYZE") + VALUE_ANALYZE("ANALYZE"), + @SerializedName("DRAFT") + VALUE_DRAFT("DRAFT"), + @SerializedName("MANAGE") + VALUE_MANAGE("MANAGE"), + ; + + private String value; + + private EnumPermittedTasks(String value) { + this.value = value; + } + + @Override + public String toString() { + return value; + } + } + public static enum EnumTasks { @SerializedName("AA_ANALYZE") VALUE_AA_ANALYZE("AA_ANALYZE"), diff --git a/src/main/java/com/facebook/ads/sdk/AdAccountAdRulesHistory.java b/src/main/java/com/facebook/ads/sdk/AdAccountAdRulesHistory.java index 693eac44..72d0f8cd 100644 --- a/src/main/java/com/facebook/ads/sdk/AdAccountAdRulesHistory.java +++ b/src/main/java/com/facebook/ads/sdk/AdAccountAdRulesHistory.java @@ -329,8 +329,12 @@ public static enum EnumAction { VALUE_EMAIL("EMAIL"), @SerializedName("ENABLE_ADVANTAGE_PLUS_CREATIVE") VALUE_ENABLE_ADVANTAGE_PLUS_CREATIVE("ENABLE_ADVANTAGE_PLUS_CREATIVE"), + @SerializedName("ENABLE_ADVANTAGE_PLUS_PLACEMENTS") + VALUE_ENABLE_ADVANTAGE_PLUS_PLACEMENTS("ENABLE_ADVANTAGE_PLUS_PLACEMENTS"), @SerializedName("ENABLE_AUTOFLOW") VALUE_ENABLE_AUTOFLOW("ENABLE_AUTOFLOW"), + @SerializedName("ENABLE_SEMANTIC_BASED_AUDIENCE_EXPANSION") + VALUE_ENABLE_SEMANTIC_BASED_AUDIENCE_EXPANSION("ENABLE_SEMANTIC_BASED_AUDIENCE_EXPANSION"), @SerializedName("ENDPOINT_PINGED") VALUE_ENDPOINT_PINGED("ENDPOINT_PINGED"), @SerializedName("ERROR") diff --git a/src/main/java/com/facebook/ads/sdk/AdAccountAdVolume.java b/src/main/java/com/facebook/ads/sdk/AdAccountAdVolume.java index a338dc24..a0299149 100644 --- a/src/main/java/com/facebook/ads/sdk/AdAccountAdVolume.java +++ b/src/main/java/com/facebook/ads/sdk/AdAccountAdVolume.java @@ -344,10 +344,18 @@ public static enum EnumRecommendationType { VALUE_ADS_REPORTING("ADS_REPORTING"), @SerializedName("ADVANCED_CAMPAIGN_BUDGET") VALUE_ADVANCED_CAMPAIGN_BUDGET("ADVANCED_CAMPAIGN_BUDGET"), + @SerializedName("ADVANTAGE_APP_CAMPAIGN") + VALUE_ADVANTAGE_APP_CAMPAIGN("ADVANTAGE_APP_CAMPAIGN"), @SerializedName("ADVANTAGE_CUSTOM_AUDIENCE") VALUE_ADVANTAGE_CUSTOM_AUDIENCE("ADVANTAGE_CUSTOM_AUDIENCE"), @SerializedName("ADVANTAGE_CUSTOM_AUDIENCE_UPSELL") VALUE_ADVANTAGE_CUSTOM_AUDIENCE_UPSELL("ADVANTAGE_CUSTOM_AUDIENCE_UPSELL"), + @SerializedName("ADVANTAGE_DETAILED_TARGETING") + VALUE_ADVANTAGE_DETAILED_TARGETING("ADVANTAGE_DETAILED_TARGETING"), + @SerializedName("ADVANTAGE_LOOKALIKE_AUDIENCE") + VALUE_ADVANTAGE_LOOKALIKE_AUDIENCE("ADVANTAGE_LOOKALIKE_AUDIENCE"), + @SerializedName("ADVANTAGE_PLUS_AUDIENCE") + VALUE_ADVANTAGE_PLUS_AUDIENCE("ADVANTAGE_PLUS_AUDIENCE"), @SerializedName("ADVANTAGE_PLUS_AUDIENCE_FRICTION") VALUE_ADVANTAGE_PLUS_AUDIENCE_FRICTION("ADVANTAGE_PLUS_AUDIENCE_FRICTION"), @SerializedName("ADVANTAGE_PLUS_AUDIENCE_TOGGLE") @@ -356,6 +364,8 @@ public static enum EnumRecommendationType { VALUE_ADVANTAGE_PLUS_CREATIVE("ADVANTAGE_PLUS_CREATIVE"), @SerializedName("ADVANTAGE_PLUS_CREATIVE_CATALOG") VALUE_ADVANTAGE_PLUS_CREATIVE_CATALOG("ADVANTAGE_PLUS_CREATIVE_CATALOG"), + @SerializedName("ADVANTAGE_PLUS_PLACEMENTS_FRICTION") + VALUE_ADVANTAGE_PLUS_PLACEMENTS_FRICTION("ADVANTAGE_PLUS_PLACEMENTS_FRICTION"), @SerializedName("ADVANTAGE_SHOPPING_CAMPAIGN") VALUE_ADVANTAGE_SHOPPING_CAMPAIGN("ADVANTAGE_SHOPPING_CAMPAIGN"), @SerializedName("ADVANTAGE_SHOPPING_CAMPAIGN_FRAGMENTATION") @@ -456,6 +466,8 @@ public static enum EnumRecommendationType { VALUE_HIGH_COST("HIGH_COST"), @SerializedName("HISTORICAL_BENCHMARK") VALUE_HISTORICAL_BENCHMARK("HISTORICAL_BENCHMARK"), + @SerializedName("IG_MULTI_ADS") + VALUE_IG_MULTI_ADS("IG_MULTI_ADS"), @SerializedName("LEARNING_LIMITED") VALUE_LEARNING_LIMITED("LEARNING_LIMITED"), @SerializedName("LEARNING_PAUSE_FRICTION") @@ -518,6 +530,8 @@ public static enum EnumRecommendationType { VALUE_SPEND_LIMIT("SPEND_LIMIT"), @SerializedName("SYD_TEST_MODE") VALUE_SYD_TEST_MODE("SYD_TEST_MODE"), + @SerializedName("TAILORED_LEAD_AD_CAMPAIGN") + VALUE_TAILORED_LEAD_AD_CAMPAIGN("TAILORED_LEAD_AD_CAMPAIGN"), @SerializedName("TOP_ADSETS_WITH_ADS_UNDER_CAP") VALUE_TOP_ADSETS_WITH_ADS_UNDER_CAP("TOP_ADSETS_WITH_ADS_UNDER_CAP"), @SerializedName("TOP_CAMPAIGNS_WITH_ADS_UNDER_CAP") diff --git a/src/main/java/com/facebook/ads/sdk/AdAccountBusinessConstraints.java b/src/main/java/com/facebook/ads/sdk/AdAccountBusinessConstraints.java index f69fa15c..5f175978 100644 --- a/src/main/java/com/facebook/ads/sdk/AdAccountBusinessConstraints.java +++ b/src/main/java/com/facebook/ads/sdk/AdAccountBusinessConstraints.java @@ -42,8 +42,12 @@ public class AdAccountBusinessConstraints extends APINode { @SerializedName("audience_controls") private Object mAudienceControls = null; + @SerializedName("campaigns_with_error") + private List mCampaignsWithError = null; @SerializedName("placement_controls") private Object mPlacementControls = null; + @SerializedName("status") + private String mStatus = null; protected static Gson gson = null; public AdAccountBusinessConstraints() { @@ -204,6 +208,15 @@ public AdAccountBusinessConstraints setFieldAudienceControls(Object value) { return this; } + public List getFieldCampaignsWithError() { + return mCampaignsWithError; + } + + public AdAccountBusinessConstraints setFieldCampaignsWithError(List value) { + this.mCampaignsWithError = value; + return this; + } + public Object getFieldPlacementControls() { return mPlacementControls; } @@ -213,6 +226,15 @@ public AdAccountBusinessConstraints setFieldPlacementControls(Object value) { return this; } + public String getFieldStatus() { + return mStatus; + } + + public AdAccountBusinessConstraints setFieldStatus(String value) { + this.mStatus = value; + return this; + } + @@ -231,7 +253,9 @@ public AdAccountBusinessConstraints setFieldPlacementControls(Object value) { public AdAccountBusinessConstraints copyFrom(AdAccountBusinessConstraints instance) { this.mAudienceControls = instance.mAudienceControls; + this.mCampaignsWithError = instance.mCampaignsWithError; this.mPlacementControls = instance.mPlacementControls; + this.mStatus = instance.mStatus; this.context = instance.context; this.rawValue = instance.rawValue; return this; diff --git a/src/main/java/com/facebook/ads/sdk/AdCreative.java b/src/main/java/com/facebook/ads/sdk/AdCreative.java index 6c83c49e..3854cffe 100644 --- a/src/main/java/com/facebook/ads/sdk/AdCreative.java +++ b/src/main/java/com/facebook/ads/sdk/AdCreative.java @@ -2734,6 +2734,8 @@ public static enum EnumAuthorizationCategory { VALUE_NONE("NONE"), @SerializedName("POLITICAL") VALUE_POLITICAL("POLITICAL"), + @SerializedName("POLITICAL_WITH_DIGITALLY_CREATED_MEDIA") + VALUE_POLITICAL_WITH_DIGITALLY_CREATED_MEDIA("POLITICAL_WITH_DIGITALLY_CREATED_MEDIA"), ; private String value; diff --git a/src/main/java/com/facebook/ads/sdk/AdCreativeBrandedContentAds.java b/src/main/java/com/facebook/ads/sdk/AdCreativeBrandedContentAds.java index a78aa896..f2d4c879 100644 --- a/src/main/java/com/facebook/ads/sdk/AdCreativeBrandedContentAds.java +++ b/src/main/java/com/facebook/ads/sdk/AdCreativeBrandedContentAds.java @@ -50,6 +50,8 @@ public class AdCreativeBrandedContentAds extends APINode { private Boolean mIsMcaInternal = null; @SerializedName("partners") private List mPartners = null; + @SerializedName("promoted_page_id") + private String mPromotedPageId = null; @SerializedName("ui_version") private Long mUiVersion = null; protected static Gson gson = null; @@ -253,6 +255,15 @@ public AdCreativeBrandedContentAds setFieldPartners(String value) { this.mPartners = AdCreativeBrandedContentAdsPartners.getGson().fromJson(value, type); return this; } + public String getFieldPromotedPageId() { + return mPromotedPageId; + } + + public AdCreativeBrandedContentAds setFieldPromotedPageId(String value) { + this.mPromotedPageId = value; + return this; + } + public Long getFieldUiVersion() { return mUiVersion; } @@ -284,6 +295,7 @@ public AdCreativeBrandedContentAds copyFrom(AdCreativeBrandedContentAds instance this.mInstagramBoostPostAccessToken = instance.mInstagramBoostPostAccessToken; this.mIsMcaInternal = instance.mIsMcaInternal; this.mPartners = instance.mPartners; + this.mPromotedPageId = instance.mPromotedPageId; this.mUiVersion = instance.mUiVersion; this.context = instance.context; this.rawValue = instance.rawValue; diff --git a/src/main/java/com/facebook/ads/sdk/AdPromotedObject.java b/src/main/java/com/facebook/ads/sdk/AdPromotedObject.java index 36a9fd66..53e8ea3a 100644 --- a/src/main/java/com/facebook/ads/sdk/AdPromotedObject.java +++ b/src/main/java/com/facebook/ads/sdk/AdPromotedObject.java @@ -82,10 +82,14 @@ public class AdPromotedObject extends APINode { private String mProductCatalogId = null; @SerializedName("product_item_id") private String mProductItemId = null; + @SerializedName("product_set") + private ProductSet mProductSet = null; @SerializedName("product_set_id") private String mProductSetId = null; @SerializedName("retention_days") private String mRetentionDays = null; + @SerializedName("whatsapp_phone_number") + private String mWhatsappPhoneNumber = null; protected static Gson gson = null; public AdPromotedObject() { @@ -434,6 +438,23 @@ public AdPromotedObject setFieldProductItemId(String value) { return this; } + public ProductSet getFieldProductSet() { + if (mProductSet != null) { + mProductSet.context = getContext(); + } + return mProductSet; + } + + public AdPromotedObject setFieldProductSet(ProductSet value) { + this.mProductSet = value; + return this; + } + + public AdPromotedObject setFieldProductSet(String value) { + Type type = new TypeToken(){}.getType(); + this.mProductSet = ProductSet.getGson().fromJson(value, type); + return this; + } public String getFieldProductSetId() { return mProductSetId; } @@ -452,6 +473,15 @@ public AdPromotedObject setFieldRetentionDays(String value) { return this; } + public String getFieldWhatsappPhoneNumber() { + return mWhatsappPhoneNumber; + } + + public AdPromotedObject setFieldWhatsappPhoneNumber(String value) { + this.mWhatsappPhoneNumber = value; + return this; + } + public static enum EnumCustomEventType { @@ -563,8 +593,10 @@ public AdPromotedObject copyFrom(AdPromotedObject instance) { this.mPlacePageSetId = instance.mPlacePageSetId; this.mProductCatalogId = instance.mProductCatalogId; this.mProductItemId = instance.mProductItemId; + this.mProductSet = instance.mProductSet; this.mProductSetId = instance.mProductSetId; this.mRetentionDays = instance.mRetentionDays; + this.mWhatsappPhoneNumber = instance.mWhatsappPhoneNumber; this.context = instance.context; this.rawValue = instance.rawValue; return this; diff --git a/src/main/java/com/facebook/ads/sdk/AdReportRun.java b/src/main/java/com/facebook/ads/sdk/AdReportRun.java index 17232ea9..355c1546 100644 --- a/src/main/java/com/facebook/ads/sdk/AdReportRun.java +++ b/src/main/java/com/facebook/ads/sdk/AdReportRun.java @@ -1865,6 +1865,8 @@ public static enum EnumBreakdowns { VALUE_IMPRESSION_DEVICE("impression_device"), @SerializedName("is_conversion_id_modeled") VALUE_IS_CONVERSION_ID_MODELED("is_conversion_id_modeled"), + @SerializedName("landing_destination") + VALUE_LANDING_DESTINATION("landing_destination"), @SerializedName("link_url_asset") VALUE_LINK_URL_ASSET("link_url_asset"), @SerializedName("marketing_messages_btn_name") diff --git a/src/main/java/com/facebook/ads/sdk/AdRuleExecutionSpec.java b/src/main/java/com/facebook/ads/sdk/AdRuleExecutionSpec.java index b50ad1cd..15112152 100644 --- a/src/main/java/com/facebook/ads/sdk/AdRuleExecutionSpec.java +++ b/src/main/java/com/facebook/ads/sdk/AdRuleExecutionSpec.java @@ -417,6 +417,8 @@ public static enum EnumExecutionType { VALUE_CHANGE_BUDGET("CHANGE_BUDGET"), @SerializedName("CHANGE_CAMPAIGN_BUDGET") VALUE_CHANGE_CAMPAIGN_BUDGET("CHANGE_CAMPAIGN_BUDGET"), + @SerializedName("DCO") + VALUE_DCO("DCO"), @SerializedName("INCREASE_RADIUS") VALUE_INCREASE_RADIUS("INCREASE_RADIUS"), @SerializedName("NOTIFICATION") diff --git a/src/main/java/com/facebook/ads/sdk/AdRuleHistory.java b/src/main/java/com/facebook/ads/sdk/AdRuleHistory.java index f35097c9..d3be1dae 100644 --- a/src/main/java/com/facebook/ads/sdk/AdRuleHistory.java +++ b/src/main/java/com/facebook/ads/sdk/AdRuleHistory.java @@ -318,8 +318,12 @@ public static enum EnumAction { VALUE_EMAIL("EMAIL"), @SerializedName("ENABLE_ADVANTAGE_PLUS_CREATIVE") VALUE_ENABLE_ADVANTAGE_PLUS_CREATIVE("ENABLE_ADVANTAGE_PLUS_CREATIVE"), + @SerializedName("ENABLE_ADVANTAGE_PLUS_PLACEMENTS") + VALUE_ENABLE_ADVANTAGE_PLUS_PLACEMENTS("ENABLE_ADVANTAGE_PLUS_PLACEMENTS"), @SerializedName("ENABLE_AUTOFLOW") VALUE_ENABLE_AUTOFLOW("ENABLE_AUTOFLOW"), + @SerializedName("ENABLE_SEMANTIC_BASED_AUDIENCE_EXPANSION") + VALUE_ENABLE_SEMANTIC_BASED_AUDIENCE_EXPANSION("ENABLE_SEMANTIC_BASED_AUDIENCE_EXPANSION"), @SerializedName("ENDPOINT_PINGED") VALUE_ENDPOINT_PINGED("ENDPOINT_PINGED"), @SerializedName("ERROR") diff --git a/src/main/java/com/facebook/ads/sdk/AdVideo.java b/src/main/java/com/facebook/ads/sdk/AdVideo.java index a743cdde..4dc78082 100644 --- a/src/main/java/com/facebook/ads/sdk/AdVideo.java +++ b/src/main/java/com/facebook/ads/sdk/AdVideo.java @@ -123,7 +123,7 @@ public class AdVideo extends APINode { @SerializedName("spherical") private Boolean mSpherical = null; @SerializedName("status") - private Object mStatus = null; + private VideoStatus mStatus = null; @SerializedName("title") private String mTitle = null; @SerializedName("universal_video_id") @@ -609,7 +609,7 @@ public Boolean getFieldSpherical() { return mSpherical; } - public Object getFieldStatus() { + public VideoStatus getFieldStatus() { return mStatus; } @@ -6772,6 +6772,8 @@ public static enum EnumContainerType { VALUE_CONTAINED_POST_COPYRIGHT_REFERENCE_BROADCAST("CONTAINED_POST_COPYRIGHT_REFERENCE_BROADCAST"), @SerializedName("COPYRIGHT_REFERENCE_BROADCAST") VALUE_COPYRIGHT_REFERENCE_BROADCAST("COPYRIGHT_REFERENCE_BROADCAST"), + @SerializedName("COPYRIGHT_REFERENCE_IG_XPOST_VIDEO") + VALUE_COPYRIGHT_REFERENCE_IG_XPOST_VIDEO("COPYRIGHT_REFERENCE_IG_XPOST_VIDEO"), @SerializedName("COPYRIGHT_REFERENCE_VIDEO") VALUE_COPYRIGHT_REFERENCE_VIDEO("COPYRIGHT_REFERENCE_VIDEO"), @SerializedName("CREATION_ML_PRECREATION") diff --git a/src/main/java/com/facebook/ads/sdk/AdsActionStats.java b/src/main/java/com/facebook/ads/sdk/AdsActionStats.java index 8a1a685f..004ef66f 100644 --- a/src/main/java/com/facebook/ads/sdk/AdsActionStats.java +++ b/src/main/java/com/facebook/ads/sdk/AdsActionStats.java @@ -100,8 +100,16 @@ public class AdsActionStats extends APINode { private String mInteractiveComponentStickerResponse = null; @SerializedName("skan_click") private String mSkanClick = null; + @SerializedName("skan_click_second_postback") + private String mSkanClickSecondPostback = null; + @SerializedName("skan_click_third_postback") + private String mSkanClickThirdPostback = null; @SerializedName("skan_view") private String mSkanView = null; + @SerializedName("skan_view_second_postback") + private String mSkanViewSecondPostback = null; + @SerializedName("skan_view_third_postback") + private String mSkanViewThirdPostback = null; @SerializedName("value") private String mValue = null; protected static Gson gson = null; @@ -525,6 +533,24 @@ public AdsActionStats setFieldSkanClick(String value) { return this; } + public String getFieldSkanClickSecondPostback() { + return mSkanClickSecondPostback; + } + + public AdsActionStats setFieldSkanClickSecondPostback(String value) { + this.mSkanClickSecondPostback = value; + return this; + } + + public String getFieldSkanClickThirdPostback() { + return mSkanClickThirdPostback; + } + + public AdsActionStats setFieldSkanClickThirdPostback(String value) { + this.mSkanClickThirdPostback = value; + return this; + } + public String getFieldSkanView() { return mSkanView; } @@ -534,6 +560,24 @@ public AdsActionStats setFieldSkanView(String value) { return this; } + public String getFieldSkanViewSecondPostback() { + return mSkanViewSecondPostback; + } + + public AdsActionStats setFieldSkanViewSecondPostback(String value) { + this.mSkanViewSecondPostback = value; + return this; + } + + public String getFieldSkanViewThirdPostback() { + return mSkanViewThirdPostback; + } + + public AdsActionStats setFieldSkanViewThirdPostback(String value) { + this.mSkanViewThirdPostback = value; + return this; + } + public String getFieldValue() { return mValue; } @@ -590,7 +634,11 @@ public AdsActionStats copyFrom(AdsActionStats instance) { this.mInteractiveComponentStickerId = instance.mInteractiveComponentStickerId; this.mInteractiveComponentStickerResponse = instance.mInteractiveComponentStickerResponse; this.mSkanClick = instance.mSkanClick; + this.mSkanClickSecondPostback = instance.mSkanClickSecondPostback; + this.mSkanClickThirdPostback = instance.mSkanClickThirdPostback; this.mSkanView = instance.mSkanView; + this.mSkanViewSecondPostback = instance.mSkanViewSecondPostback; + this.mSkanViewThirdPostback = instance.mSkanViewThirdPostback; this.mValue = instance.mValue; this.context = instance.context; this.rawValue = instance.rawValue; diff --git a/src/main/java/com/facebook/ads/sdk/AdsHistogramStats.java b/src/main/java/com/facebook/ads/sdk/AdsHistogramStats.java index b5f110c5..c6707a5c 100644 --- a/src/main/java/com/facebook/ads/sdk/AdsHistogramStats.java +++ b/src/main/java/com/facebook/ads/sdk/AdsHistogramStats.java @@ -100,8 +100,16 @@ public class AdsHistogramStats extends APINode { private String mInteractiveComponentStickerResponse = null; @SerializedName("skan_click") private List mSkanClick = null; + @SerializedName("skan_click_second_postback") + private List mSkanClickSecondPostback = null; + @SerializedName("skan_click_third_postback") + private List mSkanClickThirdPostback = null; @SerializedName("skan_view") private List mSkanView = null; + @SerializedName("skan_view_second_postback") + private List mSkanViewSecondPostback = null; + @SerializedName("skan_view_third_postback") + private List mSkanViewThirdPostback = null; @SerializedName("value") private List mValue = null; protected static Gson gson = null; @@ -525,6 +533,24 @@ public AdsHistogramStats setFieldSkanClick(List value) { return this; } + public List getFieldSkanClickSecondPostback() { + return mSkanClickSecondPostback; + } + + public AdsHistogramStats setFieldSkanClickSecondPostback(List value) { + this.mSkanClickSecondPostback = value; + return this; + } + + public List getFieldSkanClickThirdPostback() { + return mSkanClickThirdPostback; + } + + public AdsHistogramStats setFieldSkanClickThirdPostback(List value) { + this.mSkanClickThirdPostback = value; + return this; + } + public List getFieldSkanView() { return mSkanView; } @@ -534,6 +560,24 @@ public AdsHistogramStats setFieldSkanView(List value) { return this; } + public List getFieldSkanViewSecondPostback() { + return mSkanViewSecondPostback; + } + + public AdsHistogramStats setFieldSkanViewSecondPostback(List value) { + this.mSkanViewSecondPostback = value; + return this; + } + + public List getFieldSkanViewThirdPostback() { + return mSkanViewThirdPostback; + } + + public AdsHistogramStats setFieldSkanViewThirdPostback(List value) { + this.mSkanViewThirdPostback = value; + return this; + } + public List getFieldValue() { return mValue; } @@ -590,7 +634,11 @@ public AdsHistogramStats copyFrom(AdsHistogramStats instance) { this.mInteractiveComponentStickerId = instance.mInteractiveComponentStickerId; this.mInteractiveComponentStickerResponse = instance.mInteractiveComponentStickerResponse; this.mSkanClick = instance.mSkanClick; + this.mSkanClickSecondPostback = instance.mSkanClickSecondPostback; + this.mSkanClickThirdPostback = instance.mSkanClickThirdPostback; this.mSkanView = instance.mSkanView; + this.mSkanViewSecondPostback = instance.mSkanViewSecondPostback; + this.mSkanViewThirdPostback = instance.mSkanViewThirdPostback; this.mValue = instance.mValue; this.context = instance.context; this.rawValue = instance.rawValue; diff --git a/src/main/java/com/facebook/ads/sdk/AdsInsights.java b/src/main/java/com/facebook/ads/sdk/AdsInsights.java index 4fbc7a2d..8f88b5be 100644 --- a/src/main/java/com/facebook/ads/sdk/AdsInsights.java +++ b/src/main/java/com/facebook/ads/sdk/AdsInsights.java @@ -347,6 +347,8 @@ public class AdsInsights extends APINode { private String mImpressionDevice = null; @SerializedName("is_conversion_id_modeled") private String mIsConversionIdModeled = null; + @SerializedName("landing_destination") + private String mLandingDestination = null; @SerializedName("link_url_asset") private String mLinkUrlAsset = null; @SerializedName("marketing_messages_btn_name") @@ -2106,6 +2108,10 @@ public String getFieldIsConversionIdModeled() { return mIsConversionIdModeled; } + public String getFieldLandingDestination() { + return mLandingDestination; + } + public String getFieldLinkUrlAsset() { return mLinkUrlAsset; } @@ -2334,6 +2340,8 @@ public static enum EnumBreakdowns { VALUE_IMPRESSION_DEVICE("impression_device"), @SerializedName("is_conversion_id_modeled") VALUE_IS_CONVERSION_ID_MODELED("is_conversion_id_modeled"), + @SerializedName("landing_destination") + VALUE_LANDING_DESTINATION("landing_destination"), @SerializedName("link_url_asset") VALUE_LINK_URL_ASSET("link_url_asset"), @SerializedName("marketing_messages_btn_name") @@ -2677,6 +2685,7 @@ public AdsInsights copyFrom(AdsInsights instance) { this.mImageAsset = instance.mImageAsset; this.mImpressionDevice = instance.mImpressionDevice; this.mIsConversionIdModeled = instance.mIsConversionIdModeled; + this.mLandingDestination = instance.mLandingDestination; this.mLinkUrlAsset = instance.mLinkUrlAsset; this.mMarketingMessagesBtnName = instance.mMarketingMessagesBtnName; this.mMdsaLandingDestination = instance.mMdsaLandingDestination; diff --git a/src/main/java/com/facebook/ads/sdk/AdsPixel.java b/src/main/java/com/facebook/ads/sdk/AdsPixel.java index 780d5456..703d1803 100644 --- a/src/main/java/com/facebook/ads/sdk/AdsPixel.java +++ b/src/main/java/com/facebook/ads/sdk/AdsPixel.java @@ -2033,6 +2033,7 @@ public APINode getLastResponse() { "namespace_id", "partner_agent", "platforms", + "progress", "test_event_code", "trace", "upload_id", @@ -2124,6 +2125,15 @@ public APIRequestCreateEvent setPlatforms (String platforms) { return this; } + public APIRequestCreateEvent setProgress (Object progress) { + this.setParam("progress", progress); + return this; + } + public APIRequestCreateEvent setProgress (String progress) { + this.setParam("progress", progress); + return this; + } + public APIRequestCreateEvent setTestEventCode (String testEventCode) { this.setParam("test_event_code", testEventCode); return this; diff --git a/src/main/java/com/facebook/ads/sdk/Application.java b/src/main/java/com/facebook/ads/sdk/Application.java index 618e3991..c25b9309 100644 --- a/src/main/java/com/facebook/ads/sdk/Application.java +++ b/src/main/java/com/facebook/ads/sdk/Application.java @@ -7049,6 +7049,7 @@ public APINode getLastResponse() { "click_attr_window", "custom_events", "decline_reason", + "engagement_type", "event", "event_reported_time", "fb_ad_id", @@ -7158,6 +7159,11 @@ public APIRequestCreateMmpAuditing setDeclineReason (String declineReason) { return this; } + public APIRequestCreateMmpAuditing setEngagementType (String engagementType) { + this.setParam("engagement_type", engagementType); + return this; + } + public APIRequestCreateMmpAuditing setEvent (String event) { this.setParam("event", event); return this; diff --git a/src/main/java/com/facebook/ads/sdk/Business.java b/src/main/java/com/facebook/ads/sdk/Business.java index 040a9f74..49719989 100644 --- a/src/main/java/com/facebook/ads/sdk/Business.java +++ b/src/main/java/com/facebook/ads/sdk/Business.java @@ -21111,7 +21111,6 @@ public APINodeList getLastResponse() { return lastResponse; } public static final String[] PARAMS = { - "breaking_change", "height", "redirect", "type", @@ -21183,15 +21182,6 @@ public APIRequestGetPicture setParams(Map params) { } - public APIRequestGetPicture setBreakingChange (ProfilePictureSource.EnumBreakingChange breakingChange) { - this.setParam("breaking_change", breakingChange); - return this; - } - public APIRequestGetPicture setBreakingChange (String breakingChange) { - this.setParam("breaking_change", breakingChange); - return this; - } - public APIRequestGetPicture setHeight (Long height) { this.setParam("height", height); return this; @@ -23853,6 +23843,8 @@ public static enum EnumVertical { VALUE_MARKETING("MARKETING"), @SerializedName("NON_PROFIT") VALUE_NON_PROFIT("NON_PROFIT"), + @SerializedName("NOT_SET") + VALUE_NOT_SET("NOT_SET"), @SerializedName("ORGANIZATIONS_AND_ASSOCIATIONS") VALUE_ORGANIZATIONS_AND_ASSOCIATIONS("ORGANIZATIONS_AND_ASSOCIATIONS"), @SerializedName("OTHER") diff --git a/src/main/java/com/facebook/ads/sdk/Canvas.java b/src/main/java/com/facebook/ads/sdk/Canvas.java index d1d49041..380a47fa 100644 --- a/src/main/java/com/facebook/ads/sdk/Canvas.java +++ b/src/main/java/com/facebook/ads/sdk/Canvas.java @@ -303,6 +303,10 @@ public String toString() { return getGson().toJson(this); } + public APIRequestGetPreview getPreview() { + return new APIRequestGetPreview(this.getPrefixedId().toString(), context); + } + public APIRequestGetPreviews getPreviews() { return new APIRequestGetPreviews(this.getPrefixedId().toString(), context); } @@ -441,6 +445,118 @@ public Boolean getFieldUseRetailerItemIds() { + public static class APIRequestGetPreview extends APIRequest { + + APINodeList lastResponse = null; + @Override + public APINodeList getLastResponse() { + return lastResponse; + } + public static final String[] PARAMS = { + }; + + public static final String[] FIELDS = { + "body", + }; + + @Override + public APINodeList parseResponse(String response, String header) throws APIException { + return CanvasPreview.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 APIRequestGetPreview.this.parseResponse(result.getBody(), result.getHeader()); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + ); + }; + + public APIRequestGetPreview(String nodeId, APIContext context) { + super(context, nodeId, "/preview", "GET", Arrays.asList(PARAMS)); + } + + @Override + public APIRequestGetPreview setParam(String param, Object value) { + setParamInternal(param, value); + return this; + } + + @Override + public APIRequestGetPreview setParams(Map params) { + setParamsInternal(params); + return this; + } + + + public APIRequestGetPreview requestAllFields () { + return this.requestAllFields(true); + } + + public APIRequestGetPreview requestAllFields (boolean value) { + for (String field : FIELDS) { + this.requestField(field, value); + } + return this; + } + + @Override + public APIRequestGetPreview requestFields (List fields) { + return this.requestFields(fields, true); + } + + @Override + public APIRequestGetPreview requestFields (List fields, boolean value) { + for (String field : fields) { + this.requestField(field, value); + } + return this; + } + + @Override + public APIRequestGetPreview requestField (String field) { + this.requestField(field, true); + return this; + } + + @Override + public APIRequestGetPreview requestField (String field, boolean value) { + this.requestFieldInternal(field, value); + return this; + } + + public APIRequestGetPreview requestBodyField () { + return this.requestBodyField(true); + } + public APIRequestGetPreview requestBodyField (boolean value) { + this.requestField("body", value); + return this; + } + } + public static class APIRequestGetPreviews extends APIRequest { APINodeList lastResponse = null; diff --git a/src/main/java/com/facebook/ads/sdk/CanvasPreview.java b/src/main/java/com/facebook/ads/sdk/CanvasPreview.java new file mode 100644 index 00000000..123f95a1 --- /dev/null +++ b/src/main/java/com/facebook/ads/sdk/CanvasPreview.java @@ -0,0 +1,235 @@ +/* + * 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.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 CanvasPreview extends APINode { + @SerializedName("body") + private String mBody = null; + protected static Gson gson = null; + + public CanvasPreview() { + } + + public String getId() { + return null; + } + public static CanvasPreview loadJSON(String json, APIContext context, String header) { + CanvasPreview canvasPreview = getGson().fromJson(json, CanvasPreview.class); + if (context.isDebug()) { + JsonParser parser = new JsonParser(); + JsonElement o1 = parser.parse(json); + JsonElement o2 = parser.parse(canvasPreview.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); + } + } + canvasPreview.context = context; + canvasPreview.rawValue = json; + canvasPreview.header = header; + return canvasPreview; + } + + public static APINodeList parseResponse(String json, APIContext context, APIRequest request, String header) throws MalformedResponseException { + APINodeList canvasPreviews = 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++) { + canvasPreviews.add(loadJSON(arr.get(i).getAsJsonObject().toString(), context, header)); + }; + return canvasPreviews; + } 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; + canvasPreviews.setCursors(before, after); + } + String previous = paging.has("previous") ? paging.get("previous").getAsString() : null; + String next = paging.has("next") ? paging.get("next").getAsString() : null; + canvasPreviews.setPaging(previous, next); + if (context.hasAppSecret()) { + canvasPreviews.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++) { + canvasPreviews.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()) { + canvasPreviews.add(loadJSON(entry.getValue().toString(), context, header)); + } + break; + } + } + if (!isRedownload) { + canvasPreviews.add(loadJSON(obj.toString(), context, header)); + } + } + return canvasPreviews; + } 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()) { + canvasPreviews.add(loadJSON(entry.getValue().toString(), context, header)); + } + return canvasPreviews; + } 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) + ) { + canvasPreviews.add(loadJSON(value.toString(), context, header)); + } else { + isIdIndexedArray = false; + break; + } + } + if (isIdIndexedArray) { + return canvasPreviews; + } + + // Sixth, check if it's pure JsonObject + canvasPreviews.clear(); + canvasPreviews.add(loadJSON(json, context, header)); + return canvasPreviews; + } + } + } 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 String getFieldBody() { + return mBody; + } + + public CanvasPreview setFieldBody(String value) { + this.mBody = 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 CanvasPreview copyFrom(CanvasPreview instance) { + this.mBody = instance.mBody; + 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 CanvasPreview.parseResponse(response, context, request, header); + } + }; + } +} diff --git a/src/main/java/com/facebook/ads/sdk/CustomAudience.java b/src/main/java/com/facebook/ads/sdk/CustomAudience.java index d940723e..a28d0355 100644 --- a/src/main/java/com/facebook/ads/sdk/CustomAudience.java +++ b/src/main/java/com/facebook/ads/sdk/CustomAudience.java @@ -343,6 +343,14 @@ public APIRequestGetAds getAds() { return new APIRequestGetAds(this.getPrefixedId().toString(), context); } + public APIRequestGetSalts getSalts() { + return new APIRequestGetSalts(this.getPrefixedId().toString(), context); + } + + public APIRequestCreateSalt createSalt() { + return new APIRequestCreateSalt(this.getPrefixedId().toString(), context); + } + public APIRequestGetSessions getSessions() { return new APIRequestGetSessions(this.getPrefixedId().toString(), context); } @@ -1876,6 +1884,258 @@ public APIRequestGetAds requestUpdatedTimeField (boolean value) { } } + public static class APIRequestGetSalts extends APIRequest { + + APINodeList lastResponse = null; + @Override + public APINodeList getLastResponse() { + return lastResponse; + } + public static final String[] PARAMS = { + "params", + }; + + public static final String[] FIELDS = { + "app_id", + "public_key", + }; + + @Override + public APINodeList parseResponse(String response, String header) throws APIException { + return CustomAudienceSalts.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 APIRequestGetSalts.this.parseResponse(result.getBody(), result.getHeader()); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + ); + }; + + public APIRequestGetSalts(String nodeId, APIContext context) { + super(context, nodeId, "/salts", "GET", Arrays.asList(PARAMS)); + } + + @Override + public APIRequestGetSalts setParam(String param, Object value) { + setParamInternal(param, value); + return this; + } + + @Override + public APIRequestGetSalts setParams(Map params) { + setParamsInternal(params); + return this; + } + + + public APIRequestGetSalts setparamParams (List params) { + this.setParam("params", params); + return this; + } + public APIRequestGetSalts setParams (String params) { + this.setParam("params", params); + return this; + } + + public APIRequestGetSalts requestAllFields () { + return this.requestAllFields(true); + } + + public APIRequestGetSalts requestAllFields (boolean value) { + for (String field : FIELDS) { + this.requestField(field, value); + } + return this; + } + + @Override + public APIRequestGetSalts requestFields (List fields) { + return this.requestFields(fields, true); + } + + @Override + public APIRequestGetSalts requestFields (List fields, boolean value) { + for (String field : fields) { + this.requestField(field, value); + } + return this; + } + + @Override + public APIRequestGetSalts requestField (String field) { + this.requestField(field, true); + return this; + } + + @Override + public APIRequestGetSalts requestField (String field, boolean value) { + this.requestFieldInternal(field, value); + return this; + } + + public APIRequestGetSalts requestAppIdField () { + return this.requestAppIdField(true); + } + public APIRequestGetSalts requestAppIdField (boolean value) { + this.requestField("app_id", value); + return this; + } + public APIRequestGetSalts requestPublicKeyField () { + return this.requestPublicKeyField(true); + } + public APIRequestGetSalts requestPublicKeyField (boolean value) { + this.requestField("public_key", value); + return this; + } + } + + public static class APIRequestCreateSalt extends APIRequest { + + CustomAudience lastResponse = null; + @Override + public CustomAudience getLastResponse() { + return lastResponse; + } + public static final String[] PARAMS = { + "salt", + "valid_from", + "valid_to", + }; + + public static final String[] FIELDS = { + }; + + @Override + public CustomAudience parseResponse(String response, String header) throws APIException { + return CustomAudience.parseResponse(response, getContext(), this, header).head(); + } + + @Override + public CustomAudience execute() throws APIException { + return execute(new HashMap()); + } + + @Override + public CustomAudience 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 CustomAudience apply(ResponseWrapper result) { + try { + return APIRequestCreateSalt.this.parseResponse(result.getBody(), result.getHeader()); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + ); + }; + + public APIRequestCreateSalt(String nodeId, APIContext context) { + super(context, nodeId, "/salts", "POST", Arrays.asList(PARAMS)); + } + + @Override + public APIRequestCreateSalt setParam(String param, Object value) { + setParamInternal(param, value); + return this; + } + + @Override + public APIRequestCreateSalt setParams(Map params) { + setParamsInternal(params); + return this; + } + + + public APIRequestCreateSalt setSalt (String salt) { + this.setParam("salt", salt); + return this; + } + + public APIRequestCreateSalt setValidFrom (String validFrom) { + this.setParam("valid_from", validFrom); + return this; + } + + public APIRequestCreateSalt setValidTo (String validTo) { + this.setParam("valid_to", validTo); + return this; + } + + public APIRequestCreateSalt requestAllFields () { + return this.requestAllFields(true); + } + + public APIRequestCreateSalt requestAllFields (boolean value) { + for (String field : FIELDS) { + this.requestField(field, value); + } + return this; + } + + @Override + public APIRequestCreateSalt requestFields (List fields) { + return this.requestFields(fields, true); + } + + @Override + public APIRequestCreateSalt requestFields (List fields, boolean value) { + for (String field : fields) { + this.requestField(field, value); + } + return this; + } + + @Override + public APIRequestCreateSalt requestField (String field) { + this.requestField(field, true); + return this; + } + + @Override + public APIRequestCreateSalt requestField (String field, boolean value) { + this.requestFieldInternal(field, value); + return this; + } + + } + public static class APIRequestGetSessions extends APIRequest { APINodeList lastResponse = null; diff --git a/src/main/java/com/facebook/ads/sdk/CustomAudienceSalts.java b/src/main/java/com/facebook/ads/sdk/CustomAudienceSalts.java new file mode 100644 index 00000000..963521ff --- /dev/null +++ b/src/main/java/com/facebook/ads/sdk/CustomAudienceSalts.java @@ -0,0 +1,247 @@ +/* + * 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.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 CustomAudienceSalts extends APINode { + @SerializedName("app_id") + private Long mAppId = null; + @SerializedName("public_key") + private String mPublicKey = null; + protected static Gson gson = null; + + public CustomAudienceSalts() { + } + + public String getId() { + return null; + } + public static CustomAudienceSalts loadJSON(String json, APIContext context, String header) { + CustomAudienceSalts customAudienceSalts = getGson().fromJson(json, CustomAudienceSalts.class); + if (context.isDebug()) { + JsonParser parser = new JsonParser(); + JsonElement o1 = parser.parse(json); + JsonElement o2 = parser.parse(customAudienceSalts.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); + } + } + customAudienceSalts.context = context; + customAudienceSalts.rawValue = json; + customAudienceSalts.header = header; + return customAudienceSalts; + } + + public static APINodeList parseResponse(String json, APIContext context, APIRequest request, String header) throws MalformedResponseException { + APINodeList customAudienceSaltss = 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++) { + customAudienceSaltss.add(loadJSON(arr.get(i).getAsJsonObject().toString(), context, header)); + }; + return customAudienceSaltss; + } 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; + customAudienceSaltss.setCursors(before, after); + } + String previous = paging.has("previous") ? paging.get("previous").getAsString() : null; + String next = paging.has("next") ? paging.get("next").getAsString() : null; + customAudienceSaltss.setPaging(previous, next); + if (context.hasAppSecret()) { + customAudienceSaltss.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++) { + customAudienceSaltss.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()) { + customAudienceSaltss.add(loadJSON(entry.getValue().toString(), context, header)); + } + break; + } + } + if (!isRedownload) { + customAudienceSaltss.add(loadJSON(obj.toString(), context, header)); + } + } + return customAudienceSaltss; + } 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()) { + customAudienceSaltss.add(loadJSON(entry.getValue().toString(), context, header)); + } + return customAudienceSaltss; + } 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) + ) { + customAudienceSaltss.add(loadJSON(value.toString(), context, header)); + } else { + isIdIndexedArray = false; + break; + } + } + if (isIdIndexedArray) { + return customAudienceSaltss; + } + + // Sixth, check if it's pure JsonObject + customAudienceSaltss.clear(); + customAudienceSaltss.add(loadJSON(json, context, header)); + return customAudienceSaltss; + } + } + } 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 Long getFieldAppId() { + return mAppId; + } + + public CustomAudienceSalts setFieldAppId(Long value) { + this.mAppId = value; + return this; + } + + public String getFieldPublicKey() { + return mPublicKey; + } + + public CustomAudienceSalts setFieldPublicKey(String value) { + this.mPublicKey = 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 CustomAudienceSalts copyFrom(CustomAudienceSalts instance) { + this.mAppId = instance.mAppId; + this.mPublicKey = instance.mPublicKey; + 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 CustomAudienceSalts.parseResponse(response, context, request, header); + } + }; + } +} diff --git a/src/main/java/com/facebook/ads/sdk/DestinationCatalogSettings.java b/src/main/java/com/facebook/ads/sdk/DestinationCatalogSettings.java deleted file mode 100644 index 0ee48568..00000000 --- a/src/main/java/com/facebook/ads/sdk/DestinationCatalogSettings.java +++ /dev/null @@ -1,420 +0,0 @@ -/* - * 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.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 DestinationCatalogSettings extends APINode { - @SerializedName("generate_items_from_pages") - private Boolean mGenerateItemsFromPages = null; - @SerializedName("id") - private String mId = null; - protected static Gson gson = null; - - DestinationCatalogSettings() { - } - - public DestinationCatalogSettings(Long id, APIContext context) { - this(id.toString(), context); - } - - public DestinationCatalogSettings(String id, APIContext context) { - this.mId = id; - - this.context = context; - } - - public DestinationCatalogSettings fetch() throws APIException{ - DestinationCatalogSettings newInstance = fetchById(this.getPrefixedId().toString(), this.context); - this.copyFrom(newInstance); - return this; - } - - public static DestinationCatalogSettings 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 DestinationCatalogSettings 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", DestinationCatalogSettings.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", DestinationCatalogSettings.getParser()) - .setParam("ids", APIRequest.joinStringList(ids)) - .requestFields(fields) - .executeAsyncBase(); - } - - private String getPrefixedId() { - return getId(); - } - - public String getId() { - return getFieldId().toString(); - } - public static DestinationCatalogSettings loadJSON(String json, APIContext context, String header) { - DestinationCatalogSettings destinationCatalogSettings = getGson().fromJson(json, DestinationCatalogSettings.class); - if (context.isDebug()) { - JsonParser parser = new JsonParser(); - JsonElement o1 = parser.parse(json); - JsonElement o2 = parser.parse(destinationCatalogSettings.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); - } - } - destinationCatalogSettings.context = context; - destinationCatalogSettings.rawValue = json; - destinationCatalogSettings.header = header; - return destinationCatalogSettings; - } - - public static APINodeList parseResponse(String json, APIContext context, APIRequest request, String header) throws MalformedResponseException { - APINodeList destinationCatalogSettingss = 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++) { - destinationCatalogSettingss.add(loadJSON(arr.get(i).getAsJsonObject().toString(), context, header)); - }; - return destinationCatalogSettingss; - } 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; - destinationCatalogSettingss.setCursors(before, after); - } - String previous = paging.has("previous") ? paging.get("previous").getAsString() : null; - String next = paging.has("next") ? paging.get("next").getAsString() : null; - destinationCatalogSettingss.setPaging(previous, next); - if (context.hasAppSecret()) { - destinationCatalogSettingss.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++) { - destinationCatalogSettingss.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()) { - destinationCatalogSettingss.add(loadJSON(entry.getValue().toString(), context, header)); - } - break; - } - } - if (!isRedownload) { - destinationCatalogSettingss.add(loadJSON(obj.toString(), context, header)); - } - } - return destinationCatalogSettingss; - } 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()) { - destinationCatalogSettingss.add(loadJSON(entry.getValue().toString(), context, header)); - } - return destinationCatalogSettingss; - } 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) - ) { - destinationCatalogSettingss.add(loadJSON(value.toString(), context, header)); - } else { - isIdIndexedArray = false; - break; - } - } - if (isIdIndexedArray) { - return destinationCatalogSettingss; - } - - // Sixth, check if it's pure JsonObject - destinationCatalogSettingss.clear(); - destinationCatalogSettingss.add(loadJSON(json, context, header)); - return destinationCatalogSettingss; - } - } - } 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 APIRequestGet get() { - return new APIRequestGet(this.getPrefixedId().toString(), context); - } - - - public Boolean getFieldGenerateItemsFromPages() { - return mGenerateItemsFromPages; - } - - public String getFieldId() { - return mId; - } - - - - public static class APIRequestGet extends APIRequest { - - DestinationCatalogSettings lastResponse = null; - @Override - public DestinationCatalogSettings getLastResponse() { - return lastResponse; - } - public static final String[] PARAMS = { - }; - - public static final String[] FIELDS = { - "generate_items_from_pages", - "id", - }; - - @Override - public DestinationCatalogSettings parseResponse(String response, String header) throws APIException { - return DestinationCatalogSettings.parseResponse(response, getContext(), this, header).head(); - } - - @Override - public DestinationCatalogSettings execute() throws APIException { - return execute(new HashMap()); - } - - @Override - public DestinationCatalogSettings 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 DestinationCatalogSettings 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 requestGenerateItemsFromPagesField () { - return this.requestGenerateItemsFromPagesField(true); - } - public APIRequestGet requestGenerateItemsFromPagesField (boolean value) { - this.requestField("generate_items_from_pages", value); - return this; - } - public APIRequestGet requestIdField () { - return this.requestIdField(true); - } - public APIRequestGet requestIdField (boolean value) { - this.requestField("id", 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 DestinationCatalogSettings copyFrom(DestinationCatalogSettings instance) { - this.mGenerateItemsFromPages = instance.mGenerateItemsFromPages; - this.mId = instance.mId; - 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 DestinationCatalogSettings.parseResponse(response, context, request, header); - } - }; - } -} diff --git a/src/main/java/com/facebook/ads/sdk/GameItem.java b/src/main/java/com/facebook/ads/sdk/GameItem.java deleted file mode 100644 index ed150902..00000000 --- a/src/main/java/com/facebook/ads/sdk/GameItem.java +++ /dev/null @@ -1,534 +0,0 @@ -/* - * 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.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 GameItem extends APINode { - @SerializedName("count") - private Long mCount = null; - @SerializedName("created") - private String mCreated = null; - @SerializedName("ext_id") - private String mExtId = null; - @SerializedName("id") - private String mId = null; - @SerializedName("item_def") - private String mItemDef = null; - @SerializedName("owner") - private User mOwner = null; - @SerializedName("status") - private String mStatus = null; - @SerializedName("updated") - private String mUpdated = null; - protected static Gson gson = null; - - GameItem() { - } - - public GameItem(Long id, APIContext context) { - this(id.toString(), context); - } - - public GameItem(String id, APIContext context) { - this.mId = id; - - this.context = context; - } - - public GameItem fetch() throws APIException{ - GameItem newInstance = fetchById(this.getPrefixedId().toString(), this.context); - this.copyFrom(newInstance); - return this; - } - - public static GameItem 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 GameItem 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", GameItem.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", GameItem.getParser()) - .setParam("ids", APIRequest.joinStringList(ids)) - .requestFields(fields) - .executeAsyncBase(); - } - - private String getPrefixedId() { - return getId(); - } - - public String getId() { - return getFieldId().toString(); - } - public static GameItem loadJSON(String json, APIContext context, String header) { - GameItem gameItem = getGson().fromJson(json, GameItem.class); - if (context.isDebug()) { - JsonParser parser = new JsonParser(); - JsonElement o1 = parser.parse(json); - JsonElement o2 = parser.parse(gameItem.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); - } - } - gameItem.context = context; - gameItem.rawValue = json; - gameItem.header = header; - return gameItem; - } - - public static APINodeList parseResponse(String json, APIContext context, APIRequest request, String header) throws MalformedResponseException { - APINodeList gameItems = 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++) { - gameItems.add(loadJSON(arr.get(i).getAsJsonObject().toString(), context, header)); - }; - return gameItems; - } 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; - gameItems.setCursors(before, after); - } - String previous = paging.has("previous") ? paging.get("previous").getAsString() : null; - String next = paging.has("next") ? paging.get("next").getAsString() : null; - gameItems.setPaging(previous, next); - if (context.hasAppSecret()) { - gameItems.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++) { - gameItems.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()) { - gameItems.add(loadJSON(entry.getValue().toString(), context, header)); - } - break; - } - } - if (!isRedownload) { - gameItems.add(loadJSON(obj.toString(), context, header)); - } - } - return gameItems; - } 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()) { - gameItems.add(loadJSON(entry.getValue().toString(), context, header)); - } - return gameItems; - } 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) - ) { - gameItems.add(loadJSON(value.toString(), context, header)); - } else { - isIdIndexedArray = false; - break; - } - } - if (isIdIndexedArray) { - return gameItems; - } - - // Sixth, check if it's pure JsonObject - gameItems.clear(); - gameItems.add(loadJSON(json, context, header)); - return gameItems; - } - } - } 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 APIRequestGet get() { - return new APIRequestGet(this.getPrefixedId().toString(), context); - } - - - public Long getFieldCount() { - return mCount; - } - - public String getFieldCreated() { - return mCreated; - } - - public String getFieldExtId() { - return mExtId; - } - - public String getFieldId() { - return mId; - } - - public String getFieldItemDef() { - return mItemDef; - } - - public User getFieldOwner() { - if (mOwner != null) { - mOwner.context = getContext(); - } - return mOwner; - } - - public String getFieldStatus() { - return mStatus; - } - - public String getFieldUpdated() { - return mUpdated; - } - - - - public static class APIRequestGet extends APIRequest { - - GameItem lastResponse = null; - @Override - public GameItem getLastResponse() { - return lastResponse; - } - public static final String[] PARAMS = { - }; - - public static final String[] FIELDS = { - "count", - "created", - "ext_id", - "id", - "item_def", - "owner", - "status", - "updated", - }; - - @Override - public GameItem parseResponse(String response, String header) throws APIException { - return GameItem.parseResponse(response, getContext(), this, header).head(); - } - - @Override - public GameItem execute() throws APIException { - return execute(new HashMap()); - } - - @Override - public GameItem 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 GameItem 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 requestCountField () { - return this.requestCountField(true); - } - public APIRequestGet requestCountField (boolean value) { - this.requestField("count", value); - return this; - } - public APIRequestGet requestCreatedField () { - return this.requestCreatedField(true); - } - public APIRequestGet requestCreatedField (boolean value) { - this.requestField("created", value); - return this; - } - public APIRequestGet requestExtIdField () { - return this.requestExtIdField(true); - } - public APIRequestGet requestExtIdField (boolean value) { - this.requestField("ext_id", value); - return this; - } - public APIRequestGet requestIdField () { - return this.requestIdField(true); - } - public APIRequestGet requestIdField (boolean value) { - this.requestField("id", value); - return this; - } - public APIRequestGet requestItemDefField () { - return this.requestItemDefField(true); - } - public APIRequestGet requestItemDefField (boolean value) { - this.requestField("item_def", value); - return this; - } - public APIRequestGet requestOwnerField () { - return this.requestOwnerField(true); - } - public APIRequestGet requestOwnerField (boolean value) { - this.requestField("owner", value); - return this; - } - public APIRequestGet requestStatusField () { - return this.requestStatusField(true); - } - public APIRequestGet requestStatusField (boolean value) { - this.requestField("status", value); - return this; - } - public APIRequestGet requestUpdatedField () { - return this.requestUpdatedField(true); - } - public APIRequestGet requestUpdatedField (boolean value) { - this.requestField("updated", value); - return this; - } - } - - public static enum EnumAction { - @SerializedName("CONSUME") - VALUE_CONSUME("CONSUME"), - @SerializedName("DROP") - VALUE_DROP("DROP"), - @SerializedName("MARK") - VALUE_MARK("MARK"), - ; - - private String value; - - private EnumAction(String value) { - this.value = value; - } - - @Override - public String toString() { - return value; - } - } - - - synchronized /*package*/ static Gson getGson() { - if (gson != null) { - return gson; - } else { - gson = new GsonBuilder() - .excludeFieldsWithModifiers(Modifier.STATIC) - .excludeFieldsWithModifiers(Modifier.PROTECTED) - .disableHtmlEscaping() - .create(); - } - return gson; - } - - public GameItem copyFrom(GameItem instance) { - this.mCount = instance.mCount; - this.mCreated = instance.mCreated; - this.mExtId = instance.mExtId; - this.mId = instance.mId; - this.mItemDef = instance.mItemDef; - this.mOwner = instance.mOwner; - this.mStatus = instance.mStatus; - this.mUpdated = instance.mUpdated; - 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 GameItem.parseResponse(response, context, request, header); - } - }; - } -} diff --git a/src/main/java/com/facebook/ads/sdk/Group.java b/src/main/java/com/facebook/ads/sdk/Group.java index 9e7a4a5e..0414ab26 100644 --- a/src/main/java/com/facebook/ads/sdk/Group.java +++ b/src/main/java/com/facebook/ads/sdk/Group.java @@ -5780,7 +5780,6 @@ public APINodeList getLastResponse() { return lastResponse; } public static final String[] PARAMS = { - "breaking_change", "height", "redirect", "type", @@ -5852,15 +5851,6 @@ public APIRequestGetPicture setParams(Map params) { } - public APIRequestGetPicture setBreakingChange (ProfilePictureSource.EnumBreakingChange breakingChange) { - this.setParam("breaking_change", breakingChange); - return this; - } - public APIRequestGetPicture setBreakingChange (String breakingChange) { - this.setParam("breaking_change", breakingChange); - return this; - } - public APIRequestGetPicture setHeight (Long height) { this.setParam("height", height); return this; diff --git a/src/main/java/com/facebook/ads/sdk/IGMedia.java b/src/main/java/com/facebook/ads/sdk/IGMedia.java index 68fecc77..e0cef5c3 100644 --- a/src/main/java/com/facebook/ads/sdk/IGMedia.java +++ b/src/main/java/com/facebook/ads/sdk/IGMedia.java @@ -1697,6 +1697,10 @@ public IGMedia getLastResponse() { return lastResponse; } public static final String[] PARAMS = { + "primary_fb_page_id", + "primary_ig_user_id", + "secondary_fb_page_id", + "secondary_ig_user_id", }; public static final String[] FIELDS = { @@ -1772,6 +1776,26 @@ public APIRequestGet setParams(Map params) { } + public APIRequestGet setPrimaryFbPageId (String primaryFbPageId) { + this.setParam("primary_fb_page_id", primaryFbPageId); + return this; + } + + public APIRequestGet setPrimaryIgUserId (String primaryIgUserId) { + this.setParam("primary_ig_user_id", primaryIgUserId); + return this; + } + + public APIRequestGet setSecondaryFbPageId (String secondaryFbPageId) { + this.setParam("secondary_fb_page_id", secondaryFbPageId); + return this; + } + + public APIRequestGet setSecondaryIgUserId (String secondaryIgUserId) { + this.setParam("secondary_ig_user_id", secondaryIgUserId); + return this; + } + public APIRequestGet requestAllFields () { return this.requestAllFields(true); } diff --git a/src/main/java/com/facebook/ads/sdk/InstagramInsightsResult.java b/src/main/java/com/facebook/ads/sdk/InstagramInsightsResult.java index 702993c7..18de57dc 100644 --- a/src/main/java/com/facebook/ads/sdk/InstagramInsightsResult.java +++ b/src/main/java/com/facebook/ads/sdk/InstagramInsightsResult.java @@ -309,6 +309,8 @@ public static enum EnumMetric { VALUE_CAROUSEL_ALBUM_SAVED("carousel_album_saved"), @SerializedName("carousel_album_video_views") VALUE_CAROUSEL_ALBUM_VIDEO_VIEWS("carousel_album_video_views"), + @SerializedName("clips_replays_count") + VALUE_CLIPS_REPLAYS_COUNT("clips_replays_count"), @SerializedName("comments") VALUE_COMMENTS("comments"), @SerializedName("engagement") @@ -317,6 +319,8 @@ public static enum EnumMetric { VALUE_EXITS("exits"), @SerializedName("follows") VALUE_FOLLOWS("follows"), + @SerializedName("ig_reels_aggregated_all_plays_count") + VALUE_IG_REELS_AGGREGATED_ALL_PLAYS_COUNT("ig_reels_aggregated_all_plays_count"), @SerializedName("ig_reels_avg_watch_time") VALUE_IG_REELS_AVG_WATCH_TIME("ig_reels_avg_watch_time"), @SerializedName("ig_reels_video_view_total_time") diff --git a/src/main/java/com/facebook/ads/sdk/Page.java b/src/main/java/com/facebook/ads/sdk/Page.java index 1ea97938..e5cd5ff6 100644 --- a/src/main/java/com/facebook/ads/sdk/Page.java +++ b/src/main/java/com/facebook/ads/sdk/Page.java @@ -749,10 +749,6 @@ public APIRequestGetInstagramAccounts getInstagramAccounts() { return new APIRequestGetInstagramAccounts(this.getPrefixedId().toString(), context); } - public APIRequestGetInstantArticlesStats getInstantArticlesStats() { - return new APIRequestGetInstantArticlesStats(this.getPrefixedId().toString(), context); - } - public APIRequestGetLeadGenForms getLeadGenForms() { return new APIRequestGetLeadGenForms(this.getPrefixedId().toString(), context); } @@ -14860,182 +14856,6 @@ public APIRequestGetInstagramAccounts requestUsernameField (boolean value) { } } - public static class APIRequestGetInstantArticlesStats extends APIRequest { - - APINodeList lastResponse = null; - @Override - public APINodeList getLastResponse() { - return lastResponse; - } - public static final String[] PARAMS = { - "metrics_list", - "page_list", - "since", - "until", - }; - - public static final String[] FIELDS = { - "error", - "metadata", - "metric", - "totals", - "x_axis_breakdown", - }; - - @Override - public APINodeList parseResponse(String response, String header) throws APIException { - return InstantArticlesStats.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 APIRequestGetInstantArticlesStats.this.parseResponse(result.getBody(), result.getHeader()); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - } - ); - }; - - public APIRequestGetInstantArticlesStats(String nodeId, APIContext context) { - super(context, nodeId, "/instant_articles_stats", "GET", Arrays.asList(PARAMS)); - } - - @Override - public APIRequestGetInstantArticlesStats setParam(String param, Object value) { - setParamInternal(param, value); - return this; - } - - @Override - public APIRequestGetInstantArticlesStats setParams(Map params) { - setParamsInternal(params); - return this; - } - - - public APIRequestGetInstantArticlesStats setMetricsList (List> metricsList) { - this.setParam("metrics_list", metricsList); - return this; - } - public APIRequestGetInstantArticlesStats setMetricsList (String metricsList) { - this.setParam("metrics_list", metricsList); - return this; - } - - public APIRequestGetInstantArticlesStats setPageList (List pageList) { - this.setParam("page_list", pageList); - return this; - } - public APIRequestGetInstantArticlesStats setPageList (String pageList) { - this.setParam("page_list", pageList); - return this; - } - - public APIRequestGetInstantArticlesStats setSince (String since) { - this.setParam("since", since); - return this; - } - - public APIRequestGetInstantArticlesStats setUntil (String until) { - this.setParam("until", until); - return this; - } - - public APIRequestGetInstantArticlesStats requestAllFields () { - return this.requestAllFields(true); - } - - public APIRequestGetInstantArticlesStats requestAllFields (boolean value) { - for (String field : FIELDS) { - this.requestField(field, value); - } - return this; - } - - @Override - public APIRequestGetInstantArticlesStats requestFields (List fields) { - return this.requestFields(fields, true); - } - - @Override - public APIRequestGetInstantArticlesStats requestFields (List fields, boolean value) { - for (String field : fields) { - this.requestField(field, value); - } - return this; - } - - @Override - public APIRequestGetInstantArticlesStats requestField (String field) { - this.requestField(field, true); - return this; - } - - @Override - public APIRequestGetInstantArticlesStats requestField (String field, boolean value) { - this.requestFieldInternal(field, value); - return this; - } - - public APIRequestGetInstantArticlesStats requestErrorField () { - return this.requestErrorField(true); - } - public APIRequestGetInstantArticlesStats requestErrorField (boolean value) { - this.requestField("error", value); - return this; - } - public APIRequestGetInstantArticlesStats requestMetadataField () { - return this.requestMetadataField(true); - } - public APIRequestGetInstantArticlesStats requestMetadataField (boolean value) { - this.requestField("metadata", value); - return this; - } - public APIRequestGetInstantArticlesStats requestMetricField () { - return this.requestMetricField(true); - } - public APIRequestGetInstantArticlesStats requestMetricField (boolean value) { - this.requestField("metric", value); - return this; - } - public APIRequestGetInstantArticlesStats requestTotalsField () { - return this.requestTotalsField(true); - } - public APIRequestGetInstantArticlesStats requestTotalsField (boolean value) { - this.requestField("totals", value); - return this; - } - public APIRequestGetInstantArticlesStats requestXAxisBreakdownField () { - return this.requestXAxisBreakdownField(true); - } - public APIRequestGetInstantArticlesStats requestXAxisBreakdownField (boolean value) { - this.requestField("x_axis_breakdown", value); - return this; - } - } - public static class APIRequestGetLeadGenForms extends APIRequest { APINodeList lastResponse = null; @@ -23312,7 +23132,6 @@ public APINodeList getLastResponse() { return lastResponse; } public static final String[] PARAMS = { - "breaking_change", "height", "redirect", "type", @@ -23384,15 +23203,6 @@ public APIRequestGetPicture setParams(Map params) { } - public APIRequestGetPicture setBreakingChange (ProfilePictureSource.EnumBreakingChange breakingChange) { - this.setParam("breaking_change", breakingChange); - return this; - } - public APIRequestGetPicture setBreakingChange (String breakingChange) { - this.setParam("breaking_change", breakingChange); - return this; - } - public APIRequestGetPicture setHeight (Long height) { this.setParam("height", height); return this; diff --git a/src/main/java/com/facebook/ads/sdk/ProductItem.java b/src/main/java/com/facebook/ads/sdk/ProductItem.java index 3e3182d3..159f2a90 100644 --- a/src/main/java/com/facebook/ads/sdk/ProductItem.java +++ b/src/main/java/com/facebook/ads/sdk/ProductItem.java @@ -3436,6 +3436,8 @@ public static enum EnumErrorType { VALUE_INVALID_MONETIZER_RETURN_POLICY("INVALID_MONETIZER_RETURN_POLICY"), @SerializedName("INVALID_PRE_ORDER_PARAMS") VALUE_INVALID_PRE_ORDER_PARAMS("INVALID_PRE_ORDER_PARAMS"), + @SerializedName("INVALID_SHELTER_PAGE_ID") + VALUE_INVALID_SHELTER_PAGE_ID("INVALID_SHELTER_PAGE_ID"), @SerializedName("INVALID_SHIPPING_PROFILE_PARAMS") VALUE_INVALID_SHIPPING_PROFILE_PARAMS("INVALID_SHIPPING_PROFILE_PARAMS"), @SerializedName("INVALID_SUBSCRIPTION_DISABLE_PARAMS") @@ -3570,6 +3572,10 @@ public static enum EnumErrorType { VALUE_VIDEO_FETCH_FAILED_TIMED_OUT("VIDEO_FETCH_FAILED_TIMED_OUT"), @SerializedName("VIDEO_NOT_DOWNLOADABLE") VALUE_VIDEO_NOT_DOWNLOADABLE("VIDEO_NOT_DOWNLOADABLE"), + @SerializedName("WHATSAPP_DISABLED_BY_USER") + VALUE_WHATSAPP_DISABLED_BY_USER("WHATSAPP_DISABLED_BY_USER"), + @SerializedName("WHATSAPP_POLICY_VIOLATION") + VALUE_WHATSAPP_POLICY_VIOLATION("WHATSAPP_POLICY_VIOLATION"), ; private String value; diff --git a/src/main/java/com/facebook/ads/sdk/Profile.java b/src/main/java/com/facebook/ads/sdk/Profile.java index 1bd4e533..098529ef 100644 --- a/src/main/java/com/facebook/ads/sdk/Profile.java +++ b/src/main/java/com/facebook/ads/sdk/Profile.java @@ -334,7 +334,6 @@ public APINodeList getLastResponse() { return lastResponse; } public static final String[] PARAMS = { - "breaking_change", "height", "redirect", "type", @@ -406,15 +405,6 @@ public APIRequestGetPicture setParams(Map params) { } - public APIRequestGetPicture setBreakingChange (ProfilePictureSource.EnumBreakingChange breakingChange) { - this.setParam("breaking_change", breakingChange); - return this; - } - public APIRequestGetPicture setBreakingChange (String breakingChange) { - this.setParam("breaking_change", breakingChange); - return this; - } - public APIRequestGetPicture setHeight (Long height) { this.setParam("height", height); return this; diff --git a/src/main/java/com/facebook/ads/sdk/ProfilePictureSource.java b/src/main/java/com/facebook/ads/sdk/ProfilePictureSource.java index 500ad4d1..2f90fa3e 100644 --- a/src/main/java/com/facebook/ads/sdk/ProfilePictureSource.java +++ b/src/main/java/com/facebook/ads/sdk/ProfilePictureSource.java @@ -313,23 +313,6 @@ public String toString() { } } - public static enum EnumBreakingChange { - @SerializedName("PROFILE_PICTURE") - VALUE_PROFILE_PICTURE("PROFILE_PICTURE"), - ; - - private String value; - - private EnumBreakingChange(String value) { - this.value = value; - } - - @Override - public String toString() { - return value; - } - } - synchronized /*package*/ static Gson getGson() { if (gson != null) { diff --git a/src/main/java/com/facebook/ads/sdk/User.java b/src/main/java/com/facebook/ads/sdk/User.java index 00af6e30..5c20f8bb 100644 --- a/src/main/java/com/facebook/ads/sdk/User.java +++ b/src/main/java/com/facebook/ads/sdk/User.java @@ -439,10 +439,6 @@ public APIRequestGetEvents getEvents() { return new APIRequestGetEvents(this.getPrefixedId().toString(), context); } - public APIRequestGetFbdlRuns getFbdlRuns() { - return new APIRequestGetFbdlRuns(this.getPrefixedId().toString(), context); - } - public APIRequestGetFeed getFeed() { return new APIRequestGetFeed(this.getPrefixedId().toString(), context); } @@ -463,10 +459,6 @@ public APIRequestCreateFundraiser createFundraiser() { return new APIRequestCreateFundraiser(this.getPrefixedId().toString(), context); } - public APIRequestCreateGameItem createGameItem() { - return new APIRequestCreateGameItem(this.getPrefixedId().toString(), context); - } - public APIRequestCreateGameTime createGameTime() { return new APIRequestCreateGameTime(this.getPrefixedId().toString(), context); } @@ -8441,174 +8433,6 @@ public APIRequestGetEvents requestUpdatedTimeField (boolean value) { } } - public static class APIRequestGetFbdlRuns extends APIRequest { - - APINodeList lastResponse = null; - @Override - public APINodeList getLastResponse() { - return lastResponse; - } - public static final String[] PARAMS = { - }; - - public static final String[] FIELDS = { - "creation_time", - "id", - "is_pinned", - "note", - "result", - "run_code", - "status", - "user_type", - }; - - @Override - public APINodeList parseResponse(String response, String header) throws APIException { - return WhitehatFBDLRun.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 APIRequestGetFbdlRuns.this.parseResponse(result.getBody(), result.getHeader()); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - } - ); - }; - - public APIRequestGetFbdlRuns(String nodeId, APIContext context) { - super(context, nodeId, "/fbdl_runs", "GET", Arrays.asList(PARAMS)); - } - - @Override - public APIRequestGetFbdlRuns setParam(String param, Object value) { - setParamInternal(param, value); - return this; - } - - @Override - public APIRequestGetFbdlRuns setParams(Map params) { - setParamsInternal(params); - return this; - } - - - public APIRequestGetFbdlRuns requestAllFields () { - return this.requestAllFields(true); - } - - public APIRequestGetFbdlRuns requestAllFields (boolean value) { - for (String field : FIELDS) { - this.requestField(field, value); - } - return this; - } - - @Override - public APIRequestGetFbdlRuns requestFields (List fields) { - return this.requestFields(fields, true); - } - - @Override - public APIRequestGetFbdlRuns requestFields (List fields, boolean value) { - for (String field : fields) { - this.requestField(field, value); - } - return this; - } - - @Override - public APIRequestGetFbdlRuns requestField (String field) { - this.requestField(field, true); - return this; - } - - @Override - public APIRequestGetFbdlRuns requestField (String field, boolean value) { - this.requestFieldInternal(field, value); - return this; - } - - public APIRequestGetFbdlRuns requestCreationTimeField () { - return this.requestCreationTimeField(true); - } - public APIRequestGetFbdlRuns requestCreationTimeField (boolean value) { - this.requestField("creation_time", value); - return this; - } - public APIRequestGetFbdlRuns requestIdField () { - return this.requestIdField(true); - } - public APIRequestGetFbdlRuns requestIdField (boolean value) { - this.requestField("id", value); - return this; - } - public APIRequestGetFbdlRuns requestIsPinnedField () { - return this.requestIsPinnedField(true); - } - public APIRequestGetFbdlRuns requestIsPinnedField (boolean value) { - this.requestField("is_pinned", value); - return this; - } - public APIRequestGetFbdlRuns requestNoteField () { - return this.requestNoteField(true); - } - public APIRequestGetFbdlRuns requestNoteField (boolean value) { - this.requestField("note", value); - return this; - } - public APIRequestGetFbdlRuns requestResultField () { - return this.requestResultField(true); - } - public APIRequestGetFbdlRuns requestResultField (boolean value) { - this.requestField("result", value); - return this; - } - public APIRequestGetFbdlRuns requestRunCodeField () { - return this.requestRunCodeField(true); - } - public APIRequestGetFbdlRuns requestRunCodeField (boolean value) { - this.requestField("run_code", value); - return this; - } - public APIRequestGetFbdlRuns requestStatusField () { - return this.requestStatusField(true); - } - public APIRequestGetFbdlRuns requestStatusField (boolean value) { - this.requestField("status", value); - return this; - } - public APIRequestGetFbdlRuns requestUserTypeField () { - return this.requestUserTypeField(true); - } - public APIRequestGetFbdlRuns requestUserTypeField (boolean value) { - this.requestField("user_type", value); - return this; - } - } - public static class APIRequestGetFeed extends APIRequest { APINodeList lastResponse = null; @@ -11243,154 +11067,6 @@ public APIRequestCreateFundraiser requestField (String field, boolean value) { } - public static class APIRequestCreateGameItem extends APIRequest { - - GameItem lastResponse = null; - @Override - public GameItem getLastResponse() { - return lastResponse; - } - public static final String[] PARAMS = { - "action", - "app_id", - "drop_table_id", - "ext_id", - "item_id", - "quantity", - }; - - public static final String[] FIELDS = { - }; - - @Override - public GameItem parseResponse(String response, String header) throws APIException { - return GameItem.parseResponse(response, getContext(), this, header).head(); - } - - @Override - public GameItem execute() throws APIException { - return execute(new HashMap()); - } - - @Override - public GameItem 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 GameItem apply(ResponseWrapper result) { - try { - return APIRequestCreateGameItem.this.parseResponse(result.getBody(), result.getHeader()); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - } - ); - }; - - public APIRequestCreateGameItem(String nodeId, APIContext context) { - super(context, nodeId, "/game_items", "POST", Arrays.asList(PARAMS)); - } - - @Override - public APIRequestCreateGameItem setParam(String param, Object value) { - setParamInternal(param, value); - return this; - } - - @Override - public APIRequestCreateGameItem setParams(Map params) { - setParamsInternal(params); - return this; - } - - - public APIRequestCreateGameItem setAction (GameItem.EnumAction action) { - this.setParam("action", action); - return this; - } - public APIRequestCreateGameItem setAction (String action) { - this.setParam("action", action); - return this; - } - - public APIRequestCreateGameItem setAppId (String appId) { - this.setParam("app_id", appId); - return this; - } - - public APIRequestCreateGameItem setDropTableId (String dropTableId) { - this.setParam("drop_table_id", dropTableId); - return this; - } - - public APIRequestCreateGameItem setExtId (String extId) { - this.setParam("ext_id", extId); - return this; - } - - public APIRequestCreateGameItem setItemId (String itemId) { - this.setParam("item_id", itemId); - return this; - } - - public APIRequestCreateGameItem setQuantity (Long quantity) { - this.setParam("quantity", quantity); - return this; - } - public APIRequestCreateGameItem setQuantity (String quantity) { - this.setParam("quantity", quantity); - return this; - } - - public APIRequestCreateGameItem requestAllFields () { - return this.requestAllFields(true); - } - - public APIRequestCreateGameItem requestAllFields (boolean value) { - for (String field : FIELDS) { - this.requestField(field, value); - } - return this; - } - - @Override - public APIRequestCreateGameItem requestFields (List fields) { - return this.requestFields(fields, true); - } - - @Override - public APIRequestCreateGameItem requestFields (List fields, boolean value) { - for (String field : fields) { - this.requestField(field, value); - } - return this; - } - - @Override - public APIRequestCreateGameItem requestField (String field) { - this.requestField(field, true); - return this; - } - - @Override - public APIRequestCreateGameItem requestField (String field, boolean value) { - this.requestFieldInternal(field, value); - return this; - } - - } - public static class APIRequestCreateGameTime extends APIRequest { APINode lastResponse = null; @@ -17771,7 +17447,6 @@ public APINodeList getLastResponse() { return lastResponse; } public static final String[] PARAMS = { - "breaking_change", "height", "redirect", "type", @@ -17843,15 +17518,6 @@ public APIRequestGetPicture setParams(Map params) { } - public APIRequestGetPicture setBreakingChange (ProfilePictureSource.EnumBreakingChange breakingChange) { - this.setParam("breaking_change", breakingChange); - return this; - } - public APIRequestGetPicture setBreakingChange (String breakingChange) { - this.setParam("breaking_change", breakingChange); - return this; - } - public APIRequestGetPicture setHeight (Long height) { this.setParam("height", height); return this; diff --git a/src/main/java/com/facebook/ads/sdk/VideoCopyrightCheckStatus.java b/src/main/java/com/facebook/ads/sdk/VideoCopyrightCheckStatus.java new file mode 100644 index 00000000..9b0b7c12 --- /dev/null +++ b/src/main/java/com/facebook/ads/sdk/VideoCopyrightCheckStatus.java @@ -0,0 +1,247 @@ +/* + * 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.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 VideoCopyrightCheckStatus extends APINode { + @SerializedName("matches_found") + private Boolean mMatchesFound = null; + @SerializedName("status") + private String mStatus = null; + protected static Gson gson = null; + + public VideoCopyrightCheckStatus() { + } + + public String getId() { + return null; + } + public static VideoCopyrightCheckStatus loadJSON(String json, APIContext context, String header) { + VideoCopyrightCheckStatus videoCopyrightCheckStatus = getGson().fromJson(json, VideoCopyrightCheckStatus.class); + if (context.isDebug()) { + JsonParser parser = new JsonParser(); + JsonElement o1 = parser.parse(json); + JsonElement o2 = parser.parse(videoCopyrightCheckStatus.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); + } + } + videoCopyrightCheckStatus.context = context; + videoCopyrightCheckStatus.rawValue = json; + videoCopyrightCheckStatus.header = header; + return videoCopyrightCheckStatus; + } + + public static APINodeList parseResponse(String json, APIContext context, APIRequest request, String header) throws MalformedResponseException { + APINodeList videoCopyrightCheckStatuss = 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++) { + videoCopyrightCheckStatuss.add(loadJSON(arr.get(i).getAsJsonObject().toString(), context, header)); + }; + return videoCopyrightCheckStatuss; + } 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; + videoCopyrightCheckStatuss.setCursors(before, after); + } + String previous = paging.has("previous") ? paging.get("previous").getAsString() : null; + String next = paging.has("next") ? paging.get("next").getAsString() : null; + videoCopyrightCheckStatuss.setPaging(previous, next); + if (context.hasAppSecret()) { + videoCopyrightCheckStatuss.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++) { + videoCopyrightCheckStatuss.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()) { + videoCopyrightCheckStatuss.add(loadJSON(entry.getValue().toString(), context, header)); + } + break; + } + } + if (!isRedownload) { + videoCopyrightCheckStatuss.add(loadJSON(obj.toString(), context, header)); + } + } + return videoCopyrightCheckStatuss; + } 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()) { + videoCopyrightCheckStatuss.add(loadJSON(entry.getValue().toString(), context, header)); + } + return videoCopyrightCheckStatuss; + } 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) + ) { + videoCopyrightCheckStatuss.add(loadJSON(value.toString(), context, header)); + } else { + isIdIndexedArray = false; + break; + } + } + if (isIdIndexedArray) { + return videoCopyrightCheckStatuss; + } + + // Sixth, check if it's pure JsonObject + videoCopyrightCheckStatuss.clear(); + videoCopyrightCheckStatuss.add(loadJSON(json, context, header)); + return videoCopyrightCheckStatuss; + } + } + } 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 Boolean getFieldMatchesFound() { + return mMatchesFound; + } + + public VideoCopyrightCheckStatus setFieldMatchesFound(Boolean value) { + this.mMatchesFound = value; + return this; + } + + public String getFieldStatus() { + return mStatus; + } + + public VideoCopyrightCheckStatus setFieldStatus(String value) { + this.mStatus = 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 VideoCopyrightCheckStatus copyFrom(VideoCopyrightCheckStatus instance) { + this.mMatchesFound = instance.mMatchesFound; + this.mStatus = instance.mStatus; + 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 VideoCopyrightCheckStatus.parseResponse(response, context, request, header); + } + }; + } +} diff --git a/src/main/java/com/facebook/ads/sdk/VideoStatus.java b/src/main/java/com/facebook/ads/sdk/VideoStatus.java new file mode 100644 index 00000000..4b71162a --- /dev/null +++ b/src/main/java/com/facebook/ads/sdk/VideoStatus.java @@ -0,0 +1,315 @@ +/* + * 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.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 VideoStatus extends APINode { + @SerializedName("copyright_check_status") + private VideoCopyrightCheckStatus mCopyrightCheckStatus = null; + @SerializedName("processing_phase") + private VideoStatusProcessingPhase mProcessingPhase = null; + @SerializedName("processing_progress") + private Long mProcessingProgress = null; + @SerializedName("publishing_phase") + private VideoStatusPublishingPhase mPublishingPhase = null; + @SerializedName("uploading_phase") + private VideoStatusUploadingPhase mUploadingPhase = null; + @SerializedName("video_status") + private String mVideoStatus = null; + protected static Gson gson = null; + + public VideoStatus() { + } + + public String getId() { + return null; + } + public static VideoStatus loadJSON(String json, APIContext context, String header) { + VideoStatus videoStatus = getGson().fromJson(json, VideoStatus.class); + if (context.isDebug()) { + JsonParser parser = new JsonParser(); + JsonElement o1 = parser.parse(json); + JsonElement o2 = parser.parse(videoStatus.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); + } + } + videoStatus.context = context; + videoStatus.rawValue = json; + videoStatus.header = header; + return videoStatus; + } + + public static APINodeList parseResponse(String json, APIContext context, APIRequest request, String header) throws MalformedResponseException { + APINodeList videoStatuss = 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++) { + videoStatuss.add(loadJSON(arr.get(i).getAsJsonObject().toString(), context, header)); + }; + return videoStatuss; + } 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; + videoStatuss.setCursors(before, after); + } + String previous = paging.has("previous") ? paging.get("previous").getAsString() : null; + String next = paging.has("next") ? paging.get("next").getAsString() : null; + videoStatuss.setPaging(previous, next); + if (context.hasAppSecret()) { + videoStatuss.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++) { + videoStatuss.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()) { + videoStatuss.add(loadJSON(entry.getValue().toString(), context, header)); + } + break; + } + } + if (!isRedownload) { + videoStatuss.add(loadJSON(obj.toString(), context, header)); + } + } + return videoStatuss; + } 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()) { + videoStatuss.add(loadJSON(entry.getValue().toString(), context, header)); + } + return videoStatuss; + } 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) + ) { + videoStatuss.add(loadJSON(value.toString(), context, header)); + } else { + isIdIndexedArray = false; + break; + } + } + if (isIdIndexedArray) { + return videoStatuss; + } + + // Sixth, check if it's pure JsonObject + videoStatuss.clear(); + videoStatuss.add(loadJSON(json, context, header)); + return videoStatuss; + } + } + } 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 VideoCopyrightCheckStatus getFieldCopyrightCheckStatus() { + return mCopyrightCheckStatus; + } + + public VideoStatus setFieldCopyrightCheckStatus(VideoCopyrightCheckStatus value) { + this.mCopyrightCheckStatus = value; + return this; + } + + public VideoStatus setFieldCopyrightCheckStatus(String value) { + Type type = new TypeToken(){}.getType(); + this.mCopyrightCheckStatus = VideoCopyrightCheckStatus.getGson().fromJson(value, type); + return this; + } + public VideoStatusProcessingPhase getFieldProcessingPhase() { + return mProcessingPhase; + } + + public VideoStatus setFieldProcessingPhase(VideoStatusProcessingPhase value) { + this.mProcessingPhase = value; + return this; + } + + public VideoStatus setFieldProcessingPhase(String value) { + Type type = new TypeToken(){}.getType(); + this.mProcessingPhase = VideoStatusProcessingPhase.getGson().fromJson(value, type); + return this; + } + public Long getFieldProcessingProgress() { + return mProcessingProgress; + } + + public VideoStatus setFieldProcessingProgress(Long value) { + this.mProcessingProgress = value; + return this; + } + + public VideoStatusPublishingPhase getFieldPublishingPhase() { + return mPublishingPhase; + } + + public VideoStatus setFieldPublishingPhase(VideoStatusPublishingPhase value) { + this.mPublishingPhase = value; + return this; + } + + public VideoStatus setFieldPublishingPhase(String value) { + Type type = new TypeToken(){}.getType(); + this.mPublishingPhase = VideoStatusPublishingPhase.getGson().fromJson(value, type); + return this; + } + public VideoStatusUploadingPhase getFieldUploadingPhase() { + return mUploadingPhase; + } + + public VideoStatus setFieldUploadingPhase(VideoStatusUploadingPhase value) { + this.mUploadingPhase = value; + return this; + } + + public VideoStatus setFieldUploadingPhase(String value) { + Type type = new TypeToken(){}.getType(); + this.mUploadingPhase = VideoStatusUploadingPhase.getGson().fromJson(value, type); + return this; + } + public String getFieldVideoStatus() { + return mVideoStatus; + } + + public VideoStatus setFieldVideoStatus(String value) { + this.mVideoStatus = 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 VideoStatus copyFrom(VideoStatus instance) { + this.mCopyrightCheckStatus = instance.mCopyrightCheckStatus; + this.mProcessingPhase = instance.mProcessingPhase; + this.mProcessingProgress = instance.mProcessingProgress; + this.mPublishingPhase = instance.mPublishingPhase; + this.mUploadingPhase = instance.mUploadingPhase; + this.mVideoStatus = instance.mVideoStatus; + 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 VideoStatus.parseResponse(response, context, request, header); + } + }; + } +} diff --git a/src/main/java/com/facebook/ads/sdk/InstantArticlesStats.java b/src/main/java/com/facebook/ads/sdk/VideoStatusError.java similarity index 60% rename from src/main/java/com/facebook/ads/sdk/InstantArticlesStats.java rename to src/main/java/com/facebook/ads/sdk/VideoStatusError.java index a5fa53b9..3d0ec4dc 100644 --- a/src/main/java/com/facebook/ads/sdk/InstantArticlesStats.java +++ b/src/main/java/com/facebook/ads/sdk/VideoStatusError.java @@ -39,31 +39,25 @@ * pull request for this class. * */ -public class InstantArticlesStats extends APINode { - @SerializedName("error") - private String mError = null; - @SerializedName("metadata") - private List> mMetadata = null; - @SerializedName("metric") - private Object mMetric = null; - @SerializedName("totals") - private List> mTotals = null; - @SerializedName("x_axis_breakdown") - private List>> mXAxisBreakdown = null; +public class VideoStatusError extends APINode { + @SerializedName("code") + private Long mCode = null; + @SerializedName("message") + private String mMessage = null; protected static Gson gson = null; - public InstantArticlesStats() { + public VideoStatusError() { } public String getId() { return null; } - public static InstantArticlesStats loadJSON(String json, APIContext context, String header) { - InstantArticlesStats instantArticlesStats = getGson().fromJson(json, InstantArticlesStats.class); + public static VideoStatusError loadJSON(String json, APIContext context, String header) { + VideoStatusError videoStatusError = getGson().fromJson(json, VideoStatusError.class); if (context.isDebug()) { JsonParser parser = new JsonParser(); JsonElement o1 = parser.parse(json); - JsonElement o2 = parser.parse(instantArticlesStats.toString()); + JsonElement o2 = parser.parse(videoStatusError.toString()); if (o1.getAsJsonObject().get("__fb_trace_id__") != null) { o2.getAsJsonObject().add("__fb_trace_id__", o1.getAsJsonObject().get("__fb_trace_id__")); } @@ -73,14 +67,14 @@ public static InstantArticlesStats loadJSON(String json, APIContext context, Str context.log("[Object]" + o2); } } - instantArticlesStats.context = context; - instantArticlesStats.rawValue = json; - instantArticlesStats.header = header; - return instantArticlesStats; + videoStatusError.context = context; + videoStatusError.rawValue = json; + videoStatusError.header = header; + return videoStatusError; } - public static APINodeList parseResponse(String json, APIContext context, APIRequest request, String header) throws MalformedResponseException { - APINodeList instantArticlesStatss = new APINodeList(request, json, header); + public static APINodeList parseResponse(String json, APIContext context, APIRequest request, String header) throws MalformedResponseException { + APINodeList videoStatusErrors = new APINodeList(request, json, header); JsonArray arr; JsonObject obj; JsonParser parser = new JsonParser(); @@ -91,9 +85,9 @@ public static APINodeList parseResponse(String json, APICo // First, check if it's a pure JSON Array arr = result.getAsJsonArray(); for (int i = 0; i < arr.size(); i++) { - instantArticlesStatss.add(loadJSON(arr.get(i).getAsJsonObject().toString(), context, header)); + videoStatusErrors.add(loadJSON(arr.get(i).getAsJsonObject().toString(), context, header)); }; - return instantArticlesStatss; + return videoStatusErrors; } else if (result.isJsonObject()) { obj = result.getAsJsonObject(); if (obj.has("data")) { @@ -103,20 +97,20 @@ public static APINodeList parseResponse(String json, APICo 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; - instantArticlesStatss.setCursors(before, after); + videoStatusErrors.setCursors(before, after); } String previous = paging.has("previous") ? paging.get("previous").getAsString() : null; String next = paging.has("next") ? paging.get("next").getAsString() : null; - instantArticlesStatss.setPaging(previous, next); + videoStatusErrors.setPaging(previous, next); if (context.hasAppSecret()) { - instantArticlesStatss.setAppSecret(context.getAppSecretProof()); + videoStatusErrors.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++) { - instantArticlesStatss.add(loadJSON(arr.get(i).getAsJsonObject().toString(), context, header)); + videoStatusErrors.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" @@ -127,23 +121,23 @@ public static APINodeList parseResponse(String json, APICo isRedownload = true; obj = obj.getAsJsonObject(s); for (Map.Entry entry : obj.entrySet()) { - instantArticlesStatss.add(loadJSON(entry.getValue().toString(), context, header)); + videoStatusErrors.add(loadJSON(entry.getValue().toString(), context, header)); } break; } } if (!isRedownload) { - instantArticlesStatss.add(loadJSON(obj.toString(), context, header)); + videoStatusErrors.add(loadJSON(obj.toString(), context, header)); } } - return instantArticlesStatss; + return videoStatusErrors; } 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()) { - instantArticlesStatss.add(loadJSON(entry.getValue().toString(), context, header)); + videoStatusErrors.add(loadJSON(entry.getValue().toString(), context, header)); } - return instantArticlesStatss; + return videoStatusErrors; } else { // Fifth, check if it's an array of objects indexed by id boolean isIdIndexedArray = true; @@ -160,20 +154,20 @@ public static APINodeList parseResponse(String json, APICo value.getAsJsonObject().get("id") != null && value.getAsJsonObject().get("id").getAsString().equals(key) ) { - instantArticlesStatss.add(loadJSON(value.toString(), context, header)); + videoStatusErrors.add(loadJSON(value.toString(), context, header)); } else { isIdIndexedArray = false; break; } } if (isIdIndexedArray) { - return instantArticlesStatss; + return videoStatusErrors; } // Sixth, check if it's pure JsonObject - instantArticlesStatss.clear(); - instantArticlesStatss.add(loadJSON(json, context, header)); - return instantArticlesStatss; + videoStatusErrors.clear(); + videoStatusErrors.add(loadJSON(json, context, header)); + return videoStatusErrors; } } } catch (Exception e) { @@ -201,48 +195,21 @@ public String toString() { } - public String getFieldError() { - return mError; + public Long getFieldCode() { + return mCode; } - public InstantArticlesStats setFieldError(String value) { - this.mError = value; + public VideoStatusError setFieldCode(Long value) { + this.mCode = value; return this; } - public List> getFieldMetadata() { - return mMetadata; + public String getFieldMessage() { + return mMessage; } - public InstantArticlesStats setFieldMetadata(List> value) { - this.mMetadata = value; - return this; - } - - public Object getFieldMetric() { - return mMetric; - } - - public InstantArticlesStats setFieldMetric(Object value) { - this.mMetric = value; - return this; - } - - public List> getFieldTotals() { - return mTotals; - } - - public InstantArticlesStats setFieldTotals(List> value) { - this.mTotals = value; - return this; - } - - public List>> getFieldXAxisBreakdown() { - return mXAxisBreakdown; - } - - public InstantArticlesStats setFieldXAxisBreakdown(List>> value) { - this.mXAxisBreakdown = value; + public VideoStatusError setFieldMessage(String value) { + this.mMessage = value; return this; } @@ -262,21 +229,18 @@ public InstantArticlesStats setFieldXAxisBreakdown(List return gson; } - public InstantArticlesStats copyFrom(InstantArticlesStats instance) { - this.mError = instance.mError; - this.mMetadata = instance.mMetadata; - this.mMetric = instance.mMetric; - this.mTotals = instance.mTotals; - this.mXAxisBreakdown = instance.mXAxisBreakdown; + public VideoStatusError copyFrom(VideoStatusError instance) { + this.mCode = instance.mCode; + this.mMessage = instance.mMessage; 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 InstantArticlesStats.parseResponse(response, context, request, header); + public static APIRequest.ResponseParser getParser() { + return new APIRequest.ResponseParser() { + public APINodeList parseResponse(String response, APIContext context, APIRequest request, String header) throws MalformedResponseException { + return VideoStatusError.parseResponse(response, context, request, header); } }; } diff --git a/src/main/java/com/facebook/ads/sdk/VideoStatusProcessingPhase.java b/src/main/java/com/facebook/ads/sdk/VideoStatusProcessingPhase.java new file mode 100644 index 00000000..3f1171a3 --- /dev/null +++ b/src/main/java/com/facebook/ads/sdk/VideoStatusProcessingPhase.java @@ -0,0 +1,252 @@ +/* + * 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.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 VideoStatusProcessingPhase extends APINode { + @SerializedName("errors") + private List mErrors = null; + @SerializedName("status") + private String mStatus = null; + protected static Gson gson = null; + + public VideoStatusProcessingPhase() { + } + + public String getId() { + return null; + } + public static VideoStatusProcessingPhase loadJSON(String json, APIContext context, String header) { + VideoStatusProcessingPhase videoStatusProcessingPhase = getGson().fromJson(json, VideoStatusProcessingPhase.class); + if (context.isDebug()) { + JsonParser parser = new JsonParser(); + JsonElement o1 = parser.parse(json); + JsonElement o2 = parser.parse(videoStatusProcessingPhase.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); + } + } + videoStatusProcessingPhase.context = context; + videoStatusProcessingPhase.rawValue = json; + videoStatusProcessingPhase.header = header; + return videoStatusProcessingPhase; + } + + public static APINodeList parseResponse(String json, APIContext context, APIRequest request, String header) throws MalformedResponseException { + APINodeList videoStatusProcessingPhases = 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++) { + videoStatusProcessingPhases.add(loadJSON(arr.get(i).getAsJsonObject().toString(), context, header)); + }; + return videoStatusProcessingPhases; + } 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; + videoStatusProcessingPhases.setCursors(before, after); + } + String previous = paging.has("previous") ? paging.get("previous").getAsString() : null; + String next = paging.has("next") ? paging.get("next").getAsString() : null; + videoStatusProcessingPhases.setPaging(previous, next); + if (context.hasAppSecret()) { + videoStatusProcessingPhases.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++) { + videoStatusProcessingPhases.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()) { + videoStatusProcessingPhases.add(loadJSON(entry.getValue().toString(), context, header)); + } + break; + } + } + if (!isRedownload) { + videoStatusProcessingPhases.add(loadJSON(obj.toString(), context, header)); + } + } + return videoStatusProcessingPhases; + } 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()) { + videoStatusProcessingPhases.add(loadJSON(entry.getValue().toString(), context, header)); + } + return videoStatusProcessingPhases; + } 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) + ) { + videoStatusProcessingPhases.add(loadJSON(value.toString(), context, header)); + } else { + isIdIndexedArray = false; + break; + } + } + if (isIdIndexedArray) { + return videoStatusProcessingPhases; + } + + // Sixth, check if it's pure JsonObject + videoStatusProcessingPhases.clear(); + videoStatusProcessingPhases.add(loadJSON(json, context, header)); + return videoStatusProcessingPhases; + } + } + } 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 List getFieldErrors() { + return mErrors; + } + + public VideoStatusProcessingPhase setFieldErrors(List value) { + this.mErrors = value; + return this; + } + + public VideoStatusProcessingPhase setFieldErrors(String value) { + Type type = new TypeToken>(){}.getType(); + this.mErrors = VideoStatusError.getGson().fromJson(value, type); + return this; + } + public String getFieldStatus() { + return mStatus; + } + + public VideoStatusProcessingPhase setFieldStatus(String value) { + this.mStatus = 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 VideoStatusProcessingPhase copyFrom(VideoStatusProcessingPhase instance) { + this.mErrors = instance.mErrors; + this.mStatus = instance.mStatus; + 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 VideoStatusProcessingPhase.parseResponse(response, context, request, header); + } + }; + } +} diff --git a/src/main/java/com/facebook/ads/sdk/VideoStatusPublishingPhase.java b/src/main/java/com/facebook/ads/sdk/VideoStatusPublishingPhase.java new file mode 100644 index 00000000..49d97dce --- /dev/null +++ b/src/main/java/com/facebook/ads/sdk/VideoStatusPublishingPhase.java @@ -0,0 +1,276 @@ +/* + * 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.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 VideoStatusPublishingPhase extends APINode { + @SerializedName("errors") + private List mErrors = null; + @SerializedName("publish_status") + private String mPublishStatus = null; + @SerializedName("publish_time") + private String mPublishTime = null; + @SerializedName("status") + private String mStatus = null; + protected static Gson gson = null; + + public VideoStatusPublishingPhase() { + } + + public String getId() { + return null; + } + public static VideoStatusPublishingPhase loadJSON(String json, APIContext context, String header) { + VideoStatusPublishingPhase videoStatusPublishingPhase = getGson().fromJson(json, VideoStatusPublishingPhase.class); + if (context.isDebug()) { + JsonParser parser = new JsonParser(); + JsonElement o1 = parser.parse(json); + JsonElement o2 = parser.parse(videoStatusPublishingPhase.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); + } + } + videoStatusPublishingPhase.context = context; + videoStatusPublishingPhase.rawValue = json; + videoStatusPublishingPhase.header = header; + return videoStatusPublishingPhase; + } + + public static APINodeList parseResponse(String json, APIContext context, APIRequest request, String header) throws MalformedResponseException { + APINodeList videoStatusPublishingPhases = 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++) { + videoStatusPublishingPhases.add(loadJSON(arr.get(i).getAsJsonObject().toString(), context, header)); + }; + return videoStatusPublishingPhases; + } 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; + videoStatusPublishingPhases.setCursors(before, after); + } + String previous = paging.has("previous") ? paging.get("previous").getAsString() : null; + String next = paging.has("next") ? paging.get("next").getAsString() : null; + videoStatusPublishingPhases.setPaging(previous, next); + if (context.hasAppSecret()) { + videoStatusPublishingPhases.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++) { + videoStatusPublishingPhases.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()) { + videoStatusPublishingPhases.add(loadJSON(entry.getValue().toString(), context, header)); + } + break; + } + } + if (!isRedownload) { + videoStatusPublishingPhases.add(loadJSON(obj.toString(), context, header)); + } + } + return videoStatusPublishingPhases; + } 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()) { + videoStatusPublishingPhases.add(loadJSON(entry.getValue().toString(), context, header)); + } + return videoStatusPublishingPhases; + } 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) + ) { + videoStatusPublishingPhases.add(loadJSON(value.toString(), context, header)); + } else { + isIdIndexedArray = false; + break; + } + } + if (isIdIndexedArray) { + return videoStatusPublishingPhases; + } + + // Sixth, check if it's pure JsonObject + videoStatusPublishingPhases.clear(); + videoStatusPublishingPhases.add(loadJSON(json, context, header)); + return videoStatusPublishingPhases; + } + } + } 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 List getFieldErrors() { + return mErrors; + } + + public VideoStatusPublishingPhase setFieldErrors(List value) { + this.mErrors = value; + return this; + } + + public VideoStatusPublishingPhase setFieldErrors(String value) { + Type type = new TypeToken>(){}.getType(); + this.mErrors = VideoStatusError.getGson().fromJson(value, type); + return this; + } + public String getFieldPublishStatus() { + return mPublishStatus; + } + + public VideoStatusPublishingPhase setFieldPublishStatus(String value) { + this.mPublishStatus = value; + return this; + } + + public String getFieldPublishTime() { + return mPublishTime; + } + + public VideoStatusPublishingPhase setFieldPublishTime(String value) { + this.mPublishTime = value; + return this; + } + + public String getFieldStatus() { + return mStatus; + } + + public VideoStatusPublishingPhase setFieldStatus(String value) { + this.mStatus = 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 VideoStatusPublishingPhase copyFrom(VideoStatusPublishingPhase instance) { + this.mErrors = instance.mErrors; + this.mPublishStatus = instance.mPublishStatus; + this.mPublishTime = instance.mPublishTime; + this.mStatus = instance.mStatus; + 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 VideoStatusPublishingPhase.parseResponse(response, context, request, header); + } + }; + } +} diff --git a/src/main/java/com/facebook/ads/sdk/VideoStatusUploadingPhase.java b/src/main/java/com/facebook/ads/sdk/VideoStatusUploadingPhase.java new file mode 100644 index 00000000..50c4ce5e --- /dev/null +++ b/src/main/java/com/facebook/ads/sdk/VideoStatusUploadingPhase.java @@ -0,0 +1,276 @@ +/* + * 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.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 VideoStatusUploadingPhase extends APINode { + @SerializedName("bytes_transferred") + private Long mBytesTransferred = null; + @SerializedName("errors") + private List mErrors = null; + @SerializedName("source_file_size") + private Long mSourceFileSize = null; + @SerializedName("status") + private String mStatus = null; + protected static Gson gson = null; + + public VideoStatusUploadingPhase() { + } + + public String getId() { + return null; + } + public static VideoStatusUploadingPhase loadJSON(String json, APIContext context, String header) { + VideoStatusUploadingPhase videoStatusUploadingPhase = getGson().fromJson(json, VideoStatusUploadingPhase.class); + if (context.isDebug()) { + JsonParser parser = new JsonParser(); + JsonElement o1 = parser.parse(json); + JsonElement o2 = parser.parse(videoStatusUploadingPhase.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); + } + } + videoStatusUploadingPhase.context = context; + videoStatusUploadingPhase.rawValue = json; + videoStatusUploadingPhase.header = header; + return videoStatusUploadingPhase; + } + + public static APINodeList parseResponse(String json, APIContext context, APIRequest request, String header) throws MalformedResponseException { + APINodeList videoStatusUploadingPhases = 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++) { + videoStatusUploadingPhases.add(loadJSON(arr.get(i).getAsJsonObject().toString(), context, header)); + }; + return videoStatusUploadingPhases; + } 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; + videoStatusUploadingPhases.setCursors(before, after); + } + String previous = paging.has("previous") ? paging.get("previous").getAsString() : null; + String next = paging.has("next") ? paging.get("next").getAsString() : null; + videoStatusUploadingPhases.setPaging(previous, next); + if (context.hasAppSecret()) { + videoStatusUploadingPhases.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++) { + videoStatusUploadingPhases.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()) { + videoStatusUploadingPhases.add(loadJSON(entry.getValue().toString(), context, header)); + } + break; + } + } + if (!isRedownload) { + videoStatusUploadingPhases.add(loadJSON(obj.toString(), context, header)); + } + } + return videoStatusUploadingPhases; + } 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()) { + videoStatusUploadingPhases.add(loadJSON(entry.getValue().toString(), context, header)); + } + return videoStatusUploadingPhases; + } 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) + ) { + videoStatusUploadingPhases.add(loadJSON(value.toString(), context, header)); + } else { + isIdIndexedArray = false; + break; + } + } + if (isIdIndexedArray) { + return videoStatusUploadingPhases; + } + + // Sixth, check if it's pure JsonObject + videoStatusUploadingPhases.clear(); + videoStatusUploadingPhases.add(loadJSON(json, context, header)); + return videoStatusUploadingPhases; + } + } + } 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 Long getFieldBytesTransferred() { + return mBytesTransferred; + } + + public VideoStatusUploadingPhase setFieldBytesTransferred(Long value) { + this.mBytesTransferred = value; + return this; + } + + public List getFieldErrors() { + return mErrors; + } + + public VideoStatusUploadingPhase setFieldErrors(List value) { + this.mErrors = value; + return this; + } + + public VideoStatusUploadingPhase setFieldErrors(String value) { + Type type = new TypeToken>(){}.getType(); + this.mErrors = VideoStatusError.getGson().fromJson(value, type); + return this; + } + public Long getFieldSourceFileSize() { + return mSourceFileSize; + } + + public VideoStatusUploadingPhase setFieldSourceFileSize(Long value) { + this.mSourceFileSize = value; + return this; + } + + public String getFieldStatus() { + return mStatus; + } + + public VideoStatusUploadingPhase setFieldStatus(String value) { + this.mStatus = 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 VideoStatusUploadingPhase copyFrom(VideoStatusUploadingPhase instance) { + this.mBytesTransferred = instance.mBytesTransferred; + this.mErrors = instance.mErrors; + this.mSourceFileSize = instance.mSourceFileSize; + this.mStatus = instance.mStatus; + 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 VideoStatusUploadingPhase.parseResponse(response, context, request, header); + } + }; + } +} diff --git a/src/main/java/com/facebook/ads/sdk/WhatsAppBusinessAccount.java b/src/main/java/com/facebook/ads/sdk/WhatsAppBusinessAccount.java index 42f543ab..e71fb8b0 100644 --- a/src/main/java/com/facebook/ads/sdk/WhatsAppBusinessAccount.java +++ b/src/main/java/com/facebook/ads/sdk/WhatsAppBusinessAccount.java @@ -1387,7 +1387,6 @@ public APINode getLastResponse() { public static final String[] PARAMS = { "categories", "clone_flow_id", - "clone_template", "endpoint_uri", "name", }; @@ -1462,11 +1461,6 @@ public APIRequestCreateFlow setCloneFlowId (String cloneFlowId) { return this; } - public APIRequestCreateFlow setCloneTemplate (String cloneTemplate) { - this.setParam("clone_template", cloneTemplate); - return this; - } - public APIRequestCreateFlow setEndpointUri (String endpointUri) { this.setParam("endpoint_uri", endpointUri); return this; diff --git a/src/main/java/com/facebook/ads/sdk/WhitehatFBDLRun.java b/src/main/java/com/facebook/ads/sdk/WhitehatFBDLRun.java deleted file mode 100644 index ec6e0b27..00000000 --- a/src/main/java/com/facebook/ads/sdk/WhitehatFBDLRun.java +++ /dev/null @@ -1,510 +0,0 @@ -/* - * 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.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 WhitehatFBDLRun extends APINode { - @SerializedName("creation_time") - private String mCreationTime = null; - @SerializedName("id") - private String mId = null; - @SerializedName("is_pinned") - private Boolean mIsPinned = null; - @SerializedName("note") - private String mNote = null; - @SerializedName("result") - private List> mResult = null; - @SerializedName("run_code") - private String mRunCode = null; - @SerializedName("status") - private String mStatus = null; - @SerializedName("user_type") - private String mUserType = null; - protected static Gson gson = null; - - WhitehatFBDLRun() { - } - - public WhitehatFBDLRun(Long id, APIContext context) { - this(id.toString(), context); - } - - public WhitehatFBDLRun(String id, APIContext context) { - this.mId = id; - - this.context = context; - } - - public WhitehatFBDLRun fetch() throws APIException{ - WhitehatFBDLRun newInstance = fetchById(this.getPrefixedId().toString(), this.context); - this.copyFrom(newInstance); - return this; - } - - public static WhitehatFBDLRun 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 WhitehatFBDLRun 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", WhitehatFBDLRun.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", WhitehatFBDLRun.getParser()) - .setParam("ids", APIRequest.joinStringList(ids)) - .requestFields(fields) - .executeAsyncBase(); - } - - private String getPrefixedId() { - return getId(); - } - - public String getId() { - return getFieldId().toString(); - } - public static WhitehatFBDLRun loadJSON(String json, APIContext context, String header) { - WhitehatFBDLRun whitehatFBDLRun = getGson().fromJson(json, WhitehatFBDLRun.class); - if (context.isDebug()) { - JsonParser parser = new JsonParser(); - JsonElement o1 = parser.parse(json); - JsonElement o2 = parser.parse(whitehatFBDLRun.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); - } - } - whitehatFBDLRun.context = context; - whitehatFBDLRun.rawValue = json; - whitehatFBDLRun.header = header; - return whitehatFBDLRun; - } - - public static APINodeList parseResponse(String json, APIContext context, APIRequest request, String header) throws MalformedResponseException { - APINodeList whitehatFBDLRuns = 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++) { - whitehatFBDLRuns.add(loadJSON(arr.get(i).getAsJsonObject().toString(), context, header)); - }; - return whitehatFBDLRuns; - } 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; - whitehatFBDLRuns.setCursors(before, after); - } - String previous = paging.has("previous") ? paging.get("previous").getAsString() : null; - String next = paging.has("next") ? paging.get("next").getAsString() : null; - whitehatFBDLRuns.setPaging(previous, next); - if (context.hasAppSecret()) { - whitehatFBDLRuns.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++) { - whitehatFBDLRuns.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()) { - whitehatFBDLRuns.add(loadJSON(entry.getValue().toString(), context, header)); - } - break; - } - } - if (!isRedownload) { - whitehatFBDLRuns.add(loadJSON(obj.toString(), context, header)); - } - } - return whitehatFBDLRuns; - } 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()) { - whitehatFBDLRuns.add(loadJSON(entry.getValue().toString(), context, header)); - } - return whitehatFBDLRuns; - } 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) - ) { - whitehatFBDLRuns.add(loadJSON(value.toString(), context, header)); - } else { - isIdIndexedArray = false; - break; - } - } - if (isIdIndexedArray) { - return whitehatFBDLRuns; - } - - // Sixth, check if it's pure JsonObject - whitehatFBDLRuns.clear(); - whitehatFBDLRuns.add(loadJSON(json, context, header)); - return whitehatFBDLRuns; - } - } - } 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 APIRequestGet get() { - return new APIRequestGet(this.getPrefixedId().toString(), context); - } - - - public String getFieldCreationTime() { - return mCreationTime; - } - - public String getFieldId() { - return mId; - } - - public Boolean getFieldIsPinned() { - return mIsPinned; - } - - public String getFieldNote() { - return mNote; - } - - public List> getFieldResult() { - return mResult; - } - - public String getFieldRunCode() { - return mRunCode; - } - - public String getFieldStatus() { - return mStatus; - } - - public String getFieldUserType() { - return mUserType; - } - - - - public static class APIRequestGet extends APIRequest { - - WhitehatFBDLRun lastResponse = null; - @Override - public WhitehatFBDLRun getLastResponse() { - return lastResponse; - } - public static final String[] PARAMS = { - }; - - public static final String[] FIELDS = { - "creation_time", - "id", - "is_pinned", - "note", - "result", - "run_code", - "status", - "user_type", - }; - - @Override - public WhitehatFBDLRun parseResponse(String response, String header) throws APIException { - return WhitehatFBDLRun.parseResponse(response, getContext(), this, header).head(); - } - - @Override - public WhitehatFBDLRun execute() throws APIException { - return execute(new HashMap()); - } - - @Override - public WhitehatFBDLRun 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 WhitehatFBDLRun 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 requestIdField () { - return this.requestIdField(true); - } - public APIRequestGet requestIdField (boolean value) { - this.requestField("id", value); - return this; - } - public APIRequestGet requestIsPinnedField () { - return this.requestIsPinnedField(true); - } - public APIRequestGet requestIsPinnedField (boolean value) { - this.requestField("is_pinned", value); - return this; - } - public APIRequestGet requestNoteField () { - return this.requestNoteField(true); - } - public APIRequestGet requestNoteField (boolean value) { - this.requestField("note", value); - return this; - } - public APIRequestGet requestResultField () { - return this.requestResultField(true); - } - public APIRequestGet requestResultField (boolean value) { - this.requestField("result", value); - return this; - } - public APIRequestGet requestRunCodeField () { - return this.requestRunCodeField(true); - } - public APIRequestGet requestRunCodeField (boolean value) { - this.requestField("run_code", value); - return this; - } - public APIRequestGet requestStatusField () { - return this.requestStatusField(true); - } - public APIRequestGet requestStatusField (boolean value) { - this.requestField("status", value); - return this; - } - public APIRequestGet requestUserTypeField () { - return this.requestUserTypeField(true); - } - public APIRequestGet requestUserTypeField (boolean value) { - this.requestField("user_type", 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 WhitehatFBDLRun copyFrom(WhitehatFBDLRun instance) { - this.mCreationTime = instance.mCreationTime; - this.mId = instance.mId; - this.mIsPinned = instance.mIsPinned; - this.mNote = instance.mNote; - this.mResult = instance.mResult; - this.mRunCode = instance.mRunCode; - this.mStatus = instance.mStatus; - this.mUserType = instance.mUserType; - 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 WhitehatFBDLRun.parseResponse(response, context, request, header); - } - }; - } -}