diff --git a/CHANGELOG.md b/CHANGELOG.md index 414c34e..70433db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,6 +60,22 @@ All notable changes to this project are documented here. The format follows website secret and test, destinations, keywords, articles), with `BlogParams`, every `Blog*` model and constant class, and `WebhookEvents.ARTICLE_PUBLISHED`. Articles are ordinary posts now; `blogs()` (remote articles on a connected site) is unchanged. +- `ads()` drops the endpoints the API no longer serves: the account tree (`accountTree`), + campaign, ad set and network ad CRUD and duplication (`createCampaign`, `campaign`, + `updateCampaign`, `deleteCampaign`, `duplicateCampaign`, and the `AdSet` and `NetworkAd` + equivalents), creatives (`creatives`, `createCreative`, `creative`, `deleteCreative`), product + catalogs with their products, feeds, feed uploads and product sets, and the Ad Library + (`library`). Their models and params go with them (`AdAccountTree`, `AdCampaign`, `AdSet`, + `NetworkAd`, `AdCreative`, `ProductCatalog`, `CatalogProduct`, `ProductFeed`, `ProductSet`, + `AdLibraryPage`, `CreateAdCampaignParams`, `CreateAdCreativeParams`, `CatalogProductParams` and + the rest). `create`, `boost`, `bulkSetStatus`, insights, audiences and lead forms are + unchanged. +- `googleAds()` drops recommendations, the optimization score, keywords, keyword ideas and + metrics, search terms, negative keyword lists, assets and Performance Max asset groups, with + their `Google*` models and params. Bid strategies, the ad schedule, Local Services leads, + conversions and `query` are unchanged. +- `AdProvider.capabilities()` no longer carries `creatives`, `catalogs`, `adLibrary` or + `smartPlus`. ## [0.4.0] - 2026-10-18 diff --git a/CLAUDE.md b/CLAUDE.md index ddbd675..fba0c6a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -109,17 +109,13 @@ anything unwrapped. `setStatus` and `delete` also need the `publish` scope, and a boost or ad starts paused unless `paused` is false. Say both in the javadoc of anything new that spends. - `googleAds` (scope `ads`) covers `/v1/ads/google/*` plus the GAQL passthrough at - `POST /v1/ads/insights/query`: recommendations, the optimization score, keywords, keyword - ideas, search terms, bid strategies, the ad schedule, negative keyword lists, assets, - Performance Max asset groups, Local Services leads and conversions. A connection on another - network answers 400, so this is the one resource that is not network-agnostic. Campaigns, ad - groups, ads, audiences, insights, labels, change history, experiments and conversion value - rules are all on `ads` and work on Google through the shared routes — do not duplicate them - here. `GoogleAdsScope` carries the connection and the customer, and renders snake_case on a - query and camelCase in a body, because the API takes it both ways. An object id is - `~~`: a Google resource name has slashes and cannot ride in a path - segment. Applying a recommendation changes what the live account serves or bids, so it needs - `publish`; dismissing one only hides it. + `POST /v1/ads/insights/query`: bid strategies, the ad schedule, Local Services leads and + conversions. A connection on another network answers 400, so this is the one resource that is + not network-agnostic. Ads, audiences and insights are on `ads` and work on Google through the + shared routes; do not duplicate them here. `GoogleAdsScope` carries the connection and the + customer, and renders snake_case on a query and camelCase in a body, because the API takes it + both ways. An object id is `~~`: a Google resource name has slashes and + cannot ride in a path segment. ## API Contract diff --git a/README.md b/README.md index 97f6c53..e679238 100644 --- a/README.md +++ b/README.md @@ -112,12 +112,12 @@ long failed = client.posts().stream(PostListParams.create().workspaceId(workspac | `broadcasts()` | `list`, `get`, `create`, `update`, `delete`, `send`, `cancel`, `recipients` | | `sequences()` | `list`, `get`, `create`, `update`, `delete`, `enroll`, `unenroll`, `enrollments` | | `knowledge()` | `list`, `create`, `createText`, `createUrl`, `createFile`, `update`, `delete`, `sync`, `search` | -| `ads()` | `list`, `external`, `boostable`, `connections`, `sources`, `authorizeMeta`, `deleteConnection`, `boost`, `create`, `refresh`, `setStatus`, `delete`, `accountTree`, `createCampaign`, `campaign`, `updateCampaign`, `deleteCampaign`, `duplicateCampaign`, `createAdSet`, `adSet`, `updateAdSet`, `deleteAdSet`, `duplicateAdSet`, `createNetworkAd`, `networkAd`, `updateNetworkAd`, `deleteNetworkAd`, `duplicateNetworkAd`, `bulkSetStatus`, `creatives`, `createCreative`, `creative`, `deleteCreative`, `estimateReach`, `insights`, `adInsights`, `audiences`, `createAudience`, `audience`, `updateAudience`, `deleteAudience`, `addAudienceUsers`, `searchTargeting`, `leadForms`, `createLeadForm`, `leadForm`, `archiveLeadForm`, `leads`, `leadsFeed`, `leadPages`, `subscribeLeadPage`, `unsubscribeLeadPage`, `goals`, `catalogs`, `createCatalog`, `catalog`, `updateCatalog`, `deleteCatalog`, `catalogProducts`, `writeCatalogProducts`, `productFeeds`, `createProductFeed`, `deleteProductFeed`, `feedUploads`, `startFeedUpload`, `productSets`, `createProductSet`, `updateProductSet`, `deleteProductSet`, `reachFrequency`, `createReachFrequency`, `reachFrequencyPrediction`, `reserveReachFrequency`, `cancelReachFrequency`, `library`, `partnershipCreators`, `requestPartnership`, `revokePartnership`, `accountActivity`, `labels`, `createLabel`, `updateLabel`, `deleteLabel`, `applyLabel`, `studies`, `createStudy`, `study`, `deleteStudy`, `iosCampaignLimits`, `highDemandPeriods`, `createHighDemandPeriod`, `deleteHighDemandPeriod`, `valueRuleSets`, `createValueRuleSet`, `deleteValueRuleSet`, `uploadConversions`, `sendPixelConversions`, `listConversionBatches`, `pixels`, `createPixel`, `pixel`, `updatePixel`, `sharePixel`, `pixelStats`, `eventMatchQuality`, `customConversions`, `createCustomConversion`, `customConversion`, `updateCustomConversion`, `deleteCustomConversion` | +| `ads()` | `list`, `external`, `boostable`, `connections`, `sources`, `authorizeMeta`, `deleteConnection`, `boost`, `create`, `refresh`, `setStatus`, `delete`, `bulkSetStatus`, `estimateReach`, `insights`, `adInsights`, `audiences`, `createAudience`, `audience`, `updateAudience`, `deleteAudience`, `addAudienceUsers`, `searchTargeting`, `leadForms`, `createLeadForm`, `leadForm`, `archiveLeadForm`, `leads`, `leadsFeed`, `leadPages`, `subscribeLeadPage`, `unsubscribeLeadPage`, `goals`, `reachFrequency`, `createReachFrequency`, `reachFrequencyPrediction`, `reserveReachFrequency`, `cancelReachFrequency`, `partnershipCreators`, `requestPartnership`, `revokePartnership`, `accountActivity`, `labels`, `createLabel`, `updateLabel`, `deleteLabel`, `applyLabel`, `studies`, `createStudy`, `study`, `deleteStudy`, `iosCampaignLimits`, `highDemandPeriods`, `createHighDemandPeriod`, `deleteHighDemandPeriod`, `valueRuleSets`, `createValueRuleSet`, `deleteValueRuleSet`, `uploadConversions`, `sendPixelConversions`, `listConversionBatches`, `pixels`, `createPixel`, `pixel`, `updatePixel`, `sharePixel`, `pixelStats`, `eventMatchQuality`, `customConversions`, `createCustomConversion`, `customConversion`, `updateCustomConversion`, `deleteCustomConversion` | | `inbox()` | `list`, `threads`, `conversations`, `unreadCount`, `accounts`, `platforms`, `markThreadRead`, `markConversationRead`, `refresh`, `update`, `editComment`, `reply`, `hide`, `unhide`, `delete`, `like`, `unlike`, `repost`, `unrepost`, `bookmark`, `unbookmark`, `vote`, `pin`, `unpin`, `react`, `startConversation`, `setTyping`, `listApprovals`, `approveReply`, `rejectReply` | -| `ads()` | `list`, `external`, `boostable`, `connections`, `sources`, `authorizeMeta`, `deleteConnection`, `boost`, `create`, `refresh`, `setStatus`, `delete`, `accountTree`, `createCampaign`, `campaign`, `updateCampaign`, `deleteCampaign`, `duplicateCampaign`, `createAdSet`, `adSet`, `updateAdSet`, `deleteAdSet`, `duplicateAdSet`, `createNetworkAd`, `networkAd`, `updateNetworkAd`, `deleteNetworkAd`, `duplicateNetworkAd`, `bulkSetStatus`, `creatives`, `createCreative`, `creative`, `deleteCreative`, `estimateReach`, `insights`, `adInsights`, `audiences`, `createAudience`, `audience`, `updateAudience`, `deleteAudience`, `addAudienceUsers`, `searchTargeting`, `leadForms`, `createLeadForm`, `leadForm`, `archiveLeadForm`, `leads`, `leadsFeed`, `leadPages`, `subscribeLeadPage`, `unsubscribeLeadPage` | +| `ads()` | `list`, `external`, `boostable`, `connections`, `sources`, `authorizeMeta`, `deleteConnection`, `boost`, `create`, `refresh`, `setStatus`, `delete`, `bulkSetStatus`, `estimateReach`, `insights`, `adInsights`, `audiences`, `createAudience`, `audience`, `updateAudience`, `deleteAudience`, `addAudienceUsers`, `searchTargeting`, `leadForms`, `createLeadForm`, `leadForm`, `archiveLeadForm`, `leads`, `leadsFeed`, `leadPages`, `subscribeLeadPage`, `unsubscribeLeadPage` | | `whatsapp()` | `getProfile`, `updateProfile`, `requestDisplayName`, `setUsername`, `listTemplates`, `listTemplateLibrary`, `getTemplate`, `createTemplate`, `importTemplate`, `updateTemplate`, `deleteTemplate`, `listGroups`, `createGroup`, `getGroup`, `updateGroup`, `deleteGroup`, `getGroupInviteLink`, `resetGroupInviteLink`, `removeGroupParticipants`, `listBlocked`, `blockUsers`, `unblockUsers`, `getCommerceSettings`, `updateCommerceSettings`, `linkCatalog`, `listFlows`, `getFlow`, `createFlow`, `updateFlow`, `deleteFlow`, `uploadFlowJson`, `publishFlow`, `deprecateFlow`, `listFlowResponses`, `getEncryptionKeyStatus`, `setEncryptionKey`, `getAccountEvents`, `listSandboxSessions`, `createSandboxSession` | -| `ads()` | `list`, `external`, `boostable`, `connections`, `sources`, `providers`, `authorize`, `deleteConnection`, `boost`, `create`, `refresh`, `setStatus`, `delete`, `accountTree`, `createCampaign`, `campaign`, `updateCampaign`, `deleteCampaign`, `duplicateCampaign`, `createAdSet`, `adSet`, `updateAdSet`, `deleteAdSet`, `duplicateAdSet`, `createNetworkAd`, `networkAd`, `updateNetworkAd`, `deleteNetworkAd`, `duplicateNetworkAd`, `bulkSetStatus`, `creatives`, `createCreative`, `creative`, `deleteCreative`, `estimateReach`, `insights`, `adInsights`, `audiences`, `createAudience`, `audience`, `updateAudience`, `deleteAudience`, `addAudienceUsers`, `addAudienceCompanies`, `searchTargeting`, `leadForms`, `createLeadForm`, `leadForm`, `archiveLeadForm`, `leads`, `leadsFeed`, `leadPages`, `subscribeLeadPage`, `unsubscribeLeadPage`, `bidPricing`, `supplyForecast`, `conversionRules`, `createConversionRule`, `conversionRule`, `updateConversionRule`, `deleteConversionRule`, `attachConversionRule`, `detachConversionRule`, `conversionMetrics`, `sendConversionEvents` | -| `googleAds()` | `recommendations`, `optimizationScore`, `applyRecommendations`, `dismissRecommendations`, `keywords`, `createKeyword`, `updateKeyword`, `deleteKeyword`, `keywordIdeas`, `keywordMetrics`, `searchTerms`, `bidStrategies`, `createBidStrategy`, `adSchedule`, `setAdSchedule`, `negativeKeywordLists`, `createNegativeKeywordList`, `addNegativeKeywords`, `attachNegativeKeywordList`, `assets`, `createAsset`, `attachAsset`, `deleteAsset`, `assetGroups`, `createAssetGroup`, `updateAssetGroup`, `deleteAssetGroup`, `localServicesLeads`, `conversionActions`, `createConversionAction`, `uploadConversions`, `uploadConversionAdjustments`, `query` | +| `ads()` | `list`, `external`, `boostable`, `connections`, `sources`, `providers`, `authorize`, `deleteConnection`, `boost`, `create`, `refresh`, `setStatus`, `delete`, `bulkSetStatus`, `estimateReach`, `insights`, `adInsights`, `audiences`, `createAudience`, `audience`, `updateAudience`, `deleteAudience`, `addAudienceUsers`, `addAudienceCompanies`, `searchTargeting`, `leadForms`, `createLeadForm`, `leadForm`, `archiveLeadForm`, `leads`, `leadsFeed`, `leadPages`, `subscribeLeadPage`, `unsubscribeLeadPage`, `bidPricing`, `supplyForecast`, `conversionRules`, `createConversionRule`, `conversionRule`, `updateConversionRule`, `deleteConversionRule`, `attachConversionRule`, `detachConversionRule`, `conversionMetrics`, `sendConversionEvents` | +| `googleAds()` | `bidStrategies`, `createBidStrategy`, `adSchedule`, `setAdSchedule`, `localServicesLeads`, `conversionActions`, `createConversionAction`, `uploadConversions`, `uploadConversionAdjustments`, `query` | | `googleBusiness()` | `getLocation`, `updateLocation`, `getAttributes`, `updateAttributes`, `getMenus`, `replaceMenus`, `getServices`, `replaceServices`, `listMedia`, `addMedia`, `deleteMedia`, `listPlaceActions`, `createPlaceAction`, `updatePlaceAction`, `deletePlaceAction`, `getVerificationOptions`, `startVerification`, `completeVerification`, `getPerformance`, `getSearchKeywords`, `assign` | | `blogs()` | `listBlogs`, `listArticles`, `getArticle`, `createArticle`, `updateArticle`, `deleteArticle`, `listProducts`, `updateProduct` | | `validate()` | `post`, `length`, `media`, `subreddit` | @@ -464,22 +464,19 @@ client.ads().setStatus(boost.id(), workspace.id(), "active"); A boost or ad starts paused unless `paused(false)` is set, so nothing is spent until it is resumed. `boost`, `create`, `setStatus` and `delete` need the `publish` scope as well as `ads`. -The campaigns, ad sets and ads already on an ad account are read live from Meta and addressed by -their Meta ids plus the connection: +Insights and bulk status changes address the network's own campaign, ad set and ad ids plus the +connection: ```java -AdAccountTree tree = client.ads().accountTree("act_123", connectionId); - AdInsightsReport week = client.ads().insights( - connectionId, tree.campaigns().get(0).id(), + connectionId, campaignId, AdInsightsParams.of("2026-09-01", "2026-09-07").breakdown("age").daily(true)); client.ads().bulkSetStatus(BulkAdStatusParams.of(workspace.id(), connectionId, "paused") - .campaign(tree.campaigns().get(0).id())); + .campaign(campaignId)); ``` -Creating, updating, deleting and duplicating campaigns, ad sets and network ads, and -`bulkSetStatus`, need the `publish` scope as well as `ads`. `leadsFeed` pages with a cursor: pass +`bulkSetStatus` needs the `publish` scope as well as `ads`. `leadsFeed` pages with a cursor: pass `nextCursor` back through `LeadsFeedParams.cursor(...)` until it is null. ### Tracking @@ -509,41 +506,30 @@ List quality = client.ads().eventMatchQuality(pixel.id(), wor ### Google Ads -Campaigns, ad groups, ads, audiences, insights, labels, change history, experiments and -conversion value rules are all on `ads()` and dispatch by connection, so they work on Google +Ads, audiences and insights are on `ads()` and dispatch by connection, so they work on Google through the same calls as any other network. What only Google has is on `googleAds()`: ```java var scope = GoogleAdsScope.of(connectionId, "1234567890"); -for (var recommendation : client.googleAds().recommendations(scope, List.of("KEYWORD"))) { - System.out.println(recommendation.type() + " -> " + recommendation.impact().potentialClicks()); +for (var strategy : client.googleAds().bidStrategies(scope)) { + System.out.println(strategy.name() + " -> " + strategy.campaignCount()); } -client.googleAds().applyRecommendations( - GoogleAdsScope.of(connectionId, "1234567890").workspace(workspace.id()), - List.of("customers/1234567890/recommendations/ABC~1")); - -var ideas = client.googleAds().keywordIdeas( - new GoogleKeywordIdeasParams(scope).seeds(List.of("running shoes"))); +var report = client.googleAds().query(scope, "SELECT campaign.id, metrics.clicks FROM campaign"); ``` -Also here: `optimizationScore`, `keywords`, `createKeyword`, `updateKeyword`, `deleteKeyword`, -`keywordMetrics`, `searchTerms`, `bidStrategies`, `createBidStrategy`, `adSchedule`, -`setAdSchedule`, `negativeKeywordLists`, `createNegativeKeywordList`, `addNegativeKeywords`, -`attachNegativeKeywordList`, `assets`, `createAsset`, `attachAsset`, `deleteAsset`, -`assetGroups`, `createAssetGroup`, `updateAssetGroup`, `deleteAssetGroup`, -`localServicesLeads`, `conversionActions`, `createConversionAction`, `uploadConversions`, -`uploadConversionAdjustments`, and `query` for a raw read-only GAQL SELECT. +Also here: `createBidStrategy`, `adSchedule`, `setAdSchedule`, `localServicesLeads`, +`conversionActions`, `createConversionAction`, `uploadConversions` and +`uploadConversionAdjustments`. An object id is `~~` — a Google resource name has slashes and cannot ride in a URL path segment, so every id carries the account it belongs to. The customer has to be an account the connection's grant reaches; any other answers 404. Amounts are in the account's currency, in minor units. -Applying a recommendation changes what the live account serves or bids straight away, so it -needs `publish` as well as `ads`; dismissing one only hides it. A connection on another network -answers 400 on every call here. +A call that changes what the live account serves or bids needs `publish` as well as `ads`. A +connection on another network answers 400 on every call here. ## Validation diff --git a/src/main/java/com/fopost/sdk/model/AdAccountTree.java b/src/main/java/com/fopost/sdk/model/AdAccountTree.java deleted file mode 100644 index 128e328..0000000 --- a/src/main/java/com/fopost/sdk/model/AdAccountTree.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.fopost.sdk.model; - -import java.util.List; - -/** Every campaign on an ad account, with its ad sets and their ads. */ -public record AdAccountTree(String adAccountId, String currency, String workspaceId, List campaigns) { - - public record Campaign( - String id, - String name, - String status, - String effectiveStatus, - String objective, - Long budgetMinor, - String budgetType, - String createdAt, - List adSets) {} - - public record AdSetNode( - String id, - String name, - String campaignId, - String status, - String effectiveStatus, - Long budgetMinor, - String budgetType, - String endAt, - String optimizationGoal, - String createdAt, - List ads) {} -} diff --git a/src/main/java/com/fopost/sdk/model/AdCampaign.java b/src/main/java/com/fopost/sdk/model/AdCampaign.java deleted file mode 100644 index bff08d8..0000000 --- a/src/main/java/com/fopost/sdk/model/AdCampaign.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.fopost.sdk.model; - -/** - * A campaign on a Meta ad account, read live. {@code status} is ACTIVE, PAUSED, DELETED or - * ARCHIVED; {@code budgetMinor} is null when the budget lives on the ad sets. - */ -public record AdCampaign( - String id, - String name, - String status, - String effectiveStatus, - String objective, - Long budgetMinor, - String budgetType, - String createdAt) {} diff --git a/src/main/java/com/fopost/sdk/model/AdCreative.java b/src/main/java/com/fopost/sdk/model/AdCreative.java deleted file mode 100644 index f333e1f..0000000 --- a/src/main/java/com/fopost/sdk/model/AdCreative.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.fopost.sdk.model; - -/** A creative on a Meta ad account. {@code format} is image, video, carousel, post or other. */ -public record AdCreative( - String id, - String name, - String format, - String status, - String title, - String body, - String link, - String thumbnailUrl, - String callToAction, - String urlTags) {} diff --git a/src/main/java/com/fopost/sdk/model/AdLibraryEntry.java b/src/main/java/com/fopost/sdk/model/AdLibraryEntry.java deleted file mode 100644 index 5cda3c5..0000000 --- a/src/main/java/com/fopost/sdk/model/AdLibraryEntry.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.fopost.sdk.model; - -/** One public archive entry. Read live on every search and stored nowhere. */ -public record AdLibraryEntry( - String id, - String pageId, - String pageName, - java.util.List bodies, - java.util.List titles, - java.util.List linkUrls, - String snapshotUrl, - java.util.List publisherPlatforms, - String startedAt, - String endedAt, - String currency, - Long spendLower, - Long spendUpper, - Long impressionsLower, - Long impressionsUpper) {} diff --git a/src/main/java/com/fopost/sdk/model/AdLibraryPage.java b/src/main/java/com/fopost/sdk/model/AdLibraryPage.java deleted file mode 100644 index 16a0cf8..0000000 --- a/src/main/java/com/fopost/sdk/model/AdLibraryPage.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.fopost.sdk.model; - -/** One page of archive results; pass {@code nextCursor} back as {@code after}. */ -public record AdLibraryPage( - java.util.List entries, - String nextCursor) {} diff --git a/src/main/java/com/fopost/sdk/model/AdProvider.java b/src/main/java/com/fopost/sdk/model/AdProvider.java index 0e41ec7..f20717d 100644 --- a/src/main/java/com/fopost/sdk/model/AdProvider.java +++ b/src/main/java/com/fopost/sdk/model/AdProvider.java @@ -6,8 +6,8 @@ /** * An ad network from the API's registry. {@code configured} false cannot be connected yet. * - *

{@code capabilities} says what the network supports — campaigns, audiences, conversions, - * forecasts, adLibrary and so on. {@code targetingFacets} is what {@code searchTargeting} accepts + *

{@code capabilities} says what the network supports, such as audiences, conversions and + * forecasts. {@code targetingFacets} is what {@code searchTargeting} accepts * here, and {@code trackingMacros} what the network expands in a creative's tracking parameters. */ public record AdProvider( diff --git a/src/main/java/com/fopost/sdk/model/AdSet.java b/src/main/java/com/fopost/sdk/model/AdSet.java deleted file mode 100644 index 2e41497..0000000 --- a/src/main/java/com/fopost/sdk/model/AdSet.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.fopost.sdk.model; - -/** An ad set on a Meta ad account, read live. {@code budgetType} is daily or lifetime. */ -public record AdSet( - String id, - String name, - String campaignId, - String status, - String effectiveStatus, - Long budgetMinor, - String budgetType, - String endAt, - String optimizationGoal, - String createdAt) {} diff --git a/src/main/java/com/fopost/sdk/model/CatalogBatchResult.java b/src/main/java/com/fopost/sdk/model/CatalogBatchResult.java deleted file mode 100644 index beb9f75..0000000 --- a/src/main/java/com/fopost/sdk/model/CatalogBatchResult.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.fopost.sdk.model; - -/** What a catalog product batch was accepted as. */ -public record CatalogBatchResult( - java.util.List handles, - long accepted) {} diff --git a/src/main/java/com/fopost/sdk/model/CatalogProduct.java b/src/main/java/com/fopost/sdk/model/CatalogProduct.java deleted file mode 100644 index 0e7db03..0000000 --- a/src/main/java/com/fopost/sdk/model/CatalogProduct.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.fopost.sdk.model; - -/** One product in a catalog. {@code priceMinor} is minor units of {@code currency}. */ -public record CatalogProduct( - String id, - String retailerId, - String name, - String description, - String availability, - String condition, - Long priceMinor, - String currency, - String imageUrl, - String url) {} diff --git a/src/main/java/com/fopost/sdk/model/CatalogProductsPage.java b/src/main/java/com/fopost/sdk/model/CatalogProductsPage.java deleted file mode 100644 index ed8ca4b..0000000 --- a/src/main/java/com/fopost/sdk/model/CatalogProductsPage.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.fopost.sdk.model; - -/** One page of catalog products; pass {@code nextCursor} back as {@code after}. */ -public record CatalogProductsPage( - java.util.List products, - String nextCursor) {} diff --git a/src/main/java/com/fopost/sdk/model/GoogleAsset.java b/src/main/java/com/fopost/sdk/model/GoogleAsset.java deleted file mode 100644 index 5338a1f..0000000 --- a/src/main/java/com/fopost/sdk/model/GoogleAsset.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.fopost.sdk.model; - -/** A sitelink, callout, or structured snippet. */ -public record GoogleAsset(String id, String name, String type, String text, String finalUrl) {} diff --git a/src/main/java/com/fopost/sdk/model/GoogleAssetGroup.java b/src/main/java/com/fopost/sdk/model/GoogleAssetGroup.java deleted file mode 100644 index 0499695..0000000 --- a/src/main/java/com/fopost/sdk/model/GoogleAssetGroup.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.fopost.sdk.model; - -import java.util.List; - -/** A Performance Max asset group. */ -public record GoogleAssetGroup( - String id, String campaignId, String name, String status, List finalUrls) {} diff --git a/src/main/java/com/fopost/sdk/model/GoogleAssetLink.java b/src/main/java/com/fopost/sdk/model/GoogleAssetLink.java deleted file mode 100644 index 950b963..0000000 --- a/src/main/java/com/fopost/sdk/model/GoogleAssetLink.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.fopost.sdk.model; - -/** Where an asset is attached. An asset with no links serves nowhere. */ -public record GoogleAssetLink( - String id, String assetId, String level, String ownerId, String fieldType, String status) {} diff --git a/src/main/java/com/fopost/sdk/model/GoogleAssetsResult.java b/src/main/java/com/fopost/sdk/model/GoogleAssetsResult.java deleted file mode 100644 index 8c3e6a1..0000000 --- a/src/main/java/com/fopost/sdk/model/GoogleAssetsResult.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.fopost.sdk.model; - -import java.util.List; - -/** The account's assets with the links that place each one. */ -public record GoogleAssetsResult(List assets, List links) {} diff --git a/src/main/java/com/fopost/sdk/model/GoogleKeyword.java b/src/main/java/com/fopost/sdk/model/GoogleKeyword.java deleted file mode 100644 index 317b2ee..0000000 --- a/src/main/java/com/fopost/sdk/model/GoogleKeyword.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.fopost.sdk.model; - -/** - * A keyword on an ad group. - * - *

{@code id} is {@code ~keyword~~}: a Google resource name - * has slashes and cannot ride in a URL path segment, so every id here carries the account it - * belongs to. - */ -public record GoogleKeyword( - String id, - String adGroupId, - String text, - String matchType, - String status, - /** The account's currency, in minor units. */ - Long cpcBidMinor, - boolean negative) {} diff --git a/src/main/java/com/fopost/sdk/model/GoogleKeywordIdea.java b/src/main/java/com/fopost/sdk/model/GoogleKeywordIdea.java deleted file mode 100644 index 27dcab3..0000000 --- a/src/main/java/com/fopost/sdk/model/GoogleKeywordIdea.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.fopost.sdk.model; - -/** A keyword idea, or the historical metrics of a keyword you already have. */ -public record GoogleKeywordIdea( - String text, - long avgMonthlySearches, - String competition, - /** The account's currency, in minor units. */ - Long lowTopOfPageBidMinor, - Long highTopOfPageBidMinor) {} diff --git a/src/main/java/com/fopost/sdk/model/GoogleOptimizationScore.java b/src/main/java/com/fopost/sdk/model/GoogleOptimizationScore.java deleted file mode 100644 index c74c5cf..0000000 --- a/src/main/java/com/fopost/sdk/model/GoogleOptimizationScore.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.fopost.sdk.model; - -import java.util.List; - -/** Google's estimate of how well the account is set up, from 0 to 1. */ -public record GoogleOptimizationScore( - Double score, - /** How much this account's score counts against others under the same manager. */ - Double weight, - List campaigns) {} diff --git a/src/main/java/com/fopost/sdk/model/GoogleOptimizationScoreCampaign.java b/src/main/java/com/fopost/sdk/model/GoogleOptimizationScoreCampaign.java deleted file mode 100644 index 03155cf..0000000 --- a/src/main/java/com/fopost/sdk/model/GoogleOptimizationScoreCampaign.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.fopost.sdk.model; - -/** One campaign's optimization score. */ -public record GoogleOptimizationScoreCampaign(String id, String name, Double score) {} diff --git a/src/main/java/com/fopost/sdk/model/GoogleRecommendation.java b/src/main/java/com/fopost/sdk/model/GoogleRecommendation.java deleted file mode 100644 index 3581fc2..0000000 --- a/src/main/java/com/fopost/sdk/model/GoogleRecommendation.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.fopost.sdk.model; - -/** - * One of Google's own recommendations for the account. - * - *

{@code id} is the Google resource name rather than the {@code ~} form other objects use, - * because a recommendation is not an object you address again: it is what apply and dismiss take. - */ -public record GoogleRecommendation( - String id, - String type, - String campaignId, - String adGroupId, - boolean dismissed, - GoogleRecommendationImpact impact) {} diff --git a/src/main/java/com/fopost/sdk/model/GoogleRecommendationImpact.java b/src/main/java/com/fopost/sdk/model/GoogleRecommendationImpact.java deleted file mode 100644 index 834671f..0000000 --- a/src/main/java/com/fopost/sdk/model/GoogleRecommendationImpact.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.fopost.sdk.model; - -/** - * What Google projects applying a recommendation would change. A null field is one Google does - * not estimate for that recommendation. - */ -public record GoogleRecommendationImpact( - Double baseClicks, - Double potentialClicks, - /** The account's currency, in minor units. */ - Long baseCostMinor, - Long potentialCostMinor, - Double baseConversions, - Double potentialConversions) {} diff --git a/src/main/java/com/fopost/sdk/model/GoogleSearchTerm.java b/src/main/java/com/fopost/sdk/model/GoogleSearchTerm.java deleted file mode 100644 index dd51624..0000000 --- a/src/main/java/com/fopost/sdk/model/GoogleSearchTerm.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.fopost.sdk.model; - -/** What someone actually searched, with the metrics it earned. */ -public record GoogleSearchTerm(String term, String adGroupId, String status, AdInsights metrics) {} diff --git a/src/main/java/com/fopost/sdk/model/GoogleSharedSet.java b/src/main/java/com/fopost/sdk/model/GoogleSharedSet.java deleted file mode 100644 index b3e302f..0000000 --- a/src/main/java/com/fopost/sdk/model/GoogleSharedSet.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.fopost.sdk.model; - -/** A negative keyword list. */ -public record GoogleSharedSet(String id, String name, String type, int memberCount) {} diff --git a/src/main/java/com/fopost/sdk/model/NetworkAd.java b/src/main/java/com/fopost/sdk/model/NetworkAd.java deleted file mode 100644 index ba4ad11..0000000 --- a/src/main/java/com/fopost/sdk/model/NetworkAd.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.fopost.sdk.model; - -/** An ad inside an ad set on a Meta ad account, read live. */ -public record NetworkAd( - String id, - String name, - String campaignId, - String adSetId, - String creativeId, - String status, - String effectiveStatus, - String createdAt) {} diff --git a/src/main/java/com/fopost/sdk/model/ProductCatalog.java b/src/main/java/com/fopost/sdk/model/ProductCatalog.java deleted file mode 100644 index 4a7d71b..0000000 --- a/src/main/java/com/fopost/sdk/model/ProductCatalog.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.fopost.sdk.model; - -/** A product catalog on the connection's business portfolio, read live. */ -public record ProductCatalog( - String id, - String name, - String vertical, - Long productCount) {} diff --git a/src/main/java/com/fopost/sdk/model/ProductFeed.java b/src/main/java/com/fopost/sdk/model/ProductFeed.java deleted file mode 100644 index e02e4be..0000000 --- a/src/main/java/com/fopost/sdk/model/ProductFeed.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.fopost.sdk.model; - -/** Keeps a catalog in step with a product file you host. */ -public record ProductFeed( - String id, - String name, - String url, - String schedule, - String createdAt) {} diff --git a/src/main/java/com/fopost/sdk/model/ProductFeedUpload.java b/src/main/java/com/fopost/sdk/model/ProductFeedUpload.java deleted file mode 100644 index c147b84..0000000 --- a/src/main/java/com/fopost/sdk/model/ProductFeedUpload.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.fopost.sdk.model; - -/** One run the network made of a product feed. */ -public record ProductFeedUpload( - String id, - String startedAt, - String endedAt, - String status, - Long errorCount, - Long warningCount) {} diff --git a/src/main/java/com/fopost/sdk/model/ProductSet.java b/src/main/java/com/fopost/sdk/model/ProductSet.java deleted file mode 100644 index febfde3..0000000 --- a/src/main/java/com/fopost/sdk/model/ProductSet.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.fopost.sdk.model; - -/** The slice of a catalog one catalog ad runs from. */ -public record ProductSet( - String id, - String name, - Long productCount, - java.util.Map filter) {} diff --git a/src/main/java/com/fopost/sdk/param/CatalogProductBatchParams.java b/src/main/java/com/fopost/sdk/param/CatalogProductBatchParams.java deleted file mode 100644 index 0b05056..0000000 --- a/src/main/java/com/fopost/sdk/param/CatalogProductBatchParams.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.fopost.sdk.param; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -/** - * Up to 500 product upserts and deletes in one batch, keyed by your own retailer id. Upserts and - * deletes travel together. Also needs the {@code publish} scope. - * - *

{@code
- * CatalogProductBatchParams.of(workspaceId, connectionId)
- *         .upsert(CatalogProductParams.of(
- *                 "SKU-1042", "Trail Runner",
- *                 "https://yourbrand.com/shop/trail-runner",
- *                 "https://yourbrand.com/img/trail-runner.jpg",
- *                 12900, "USD"))
- *         .delete("SKU-0007");
- * }
- */ -public final class CatalogProductBatchParams { - - private final Map body = new LinkedHashMap<>(); - private final List> products = new ArrayList<>(); - - private CatalogProductBatchParams() {} - - public static CatalogProductBatchParams of(String workspaceId, String connectionId) { - CatalogProductBatchParams params = new CatalogProductBatchParams(); - params.body.put("workspaceId", workspaceId); - params.body.put("connectionId", connectionId); - return params; - } - - public CatalogProductBatchParams upsert(CatalogProductParams product) { - products.add(product.toMap()); - return this; - } - - public CatalogProductBatchParams delete(String retailerId) { - Map row = new LinkedHashMap<>(); - row.put("op", "delete"); - row.put("retailerId", retailerId); - products.add(row); - return this; - } - - public Map toMap() { - Map out = new LinkedHashMap<>(body); - out.put("products", new ArrayList<>(products)); - return out; - } -} diff --git a/src/main/java/com/fopost/sdk/param/CatalogProductParams.java b/src/main/java/com/fopost/sdk/param/CatalogProductParams.java deleted file mode 100644 index 31fff02..0000000 --- a/src/main/java/com/fopost/sdk/param/CatalogProductParams.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.fopost.sdk.param; - -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * One product in a catalog batch. {@code priceMinor} is minor units of {@code currency}, so 12900 - * with USD is $129.00. - */ -public final class CatalogProductParams { - - private final Map body = new LinkedHashMap<>(); - - private CatalogProductParams() {} - - public static CatalogProductParams of( - String retailerId, String name, String url, String imageUrl, long priceMinor, String currency) { - CatalogProductParams params = new CatalogProductParams(); - params.body.put("op", "upsert"); - params.body.put("retailerId", retailerId); - params.body.put("name", name); - params.body.put("url", url); - params.body.put("imageUrl", imageUrl); - params.body.put("priceMinor", priceMinor); - params.body.put("currency", currency); - return params; - } - - public CatalogProductParams description(String description) { - body.put("description", description); - return this; - } - - /** in stock, out of stock, preorder, available for order or discontinued. */ - public CatalogProductParams availability(String availability) { - body.put("availability", availability); - return this; - } - - /** new, refurbished or used. */ - public CatalogProductParams condition(String condition) { - body.put("condition", condition); - return this; - } - - public CatalogProductParams brand(String brand) { - body.put("brand", brand); - return this; - } - - public Map toMap() { - return new LinkedHashMap<>(body); - } -} diff --git a/src/main/java/com/fopost/sdk/param/CreateAdCampaignParams.java b/src/main/java/com/fopost/sdk/param/CreateAdCampaignParams.java deleted file mode 100644 index a9a201d..0000000 --- a/src/main/java/com/fopost/sdk/param/CreateAdCampaignParams.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.fopost.sdk.param; - -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * A campaign on a Meta ad account. {@code goal} is engagement, traffic, awareness or video_views. - * It starts paused unless {@link #paused(boolean)} is set to false. - */ -public final class CreateAdCampaignParams { - - private final Map body = new LinkedHashMap<>(); - - private CreateAdCampaignParams() {} - - public static CreateAdCampaignParams of( - String workspaceId, String connectionId, String adAccountId, String name, String goal) { - CreateAdCampaignParams params = new CreateAdCampaignParams(); - params.body.put("workspaceId", workspaceId); - params.body.put("connectionId", connectionId); - params.body.put("adAccountId", adAccountId); - params.body.put("name", name); - params.body.put("goal", goal); - return params; - } - - /** False starts delivery at once. Defaults to true. */ - public CreateAdCampaignParams paused(boolean paused) { - body.put("paused", paused); - return this; - } - - /** - * Hands targeting and creative rotation to the network. Needs its - * {@code smartPlus} capability. - */ - public CreateAdCampaignParams smartPlus(boolean smartPlus) { - body.put("smartPlus", smartPlus); - return this; - } - - public Map toMap() { - return new LinkedHashMap<>(body); - } -} diff --git a/src/main/java/com/fopost/sdk/param/CreateAdCreativeParams.java b/src/main/java/com/fopost/sdk/param/CreateAdCreativeParams.java deleted file mode 100644 index 8937076..0000000 --- a/src/main/java/com/fopost/sdk/param/CreateAdCreativeParams.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.fopost.sdk.param; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -/** - * A creative on a Meta ad account. {@code format} is image, video or carousel; {@code text} is the - * primary copy. A video needs {@link #mediaUrl(String)}, a carousel two to ten {@link #card}s. - */ -public final class CreateAdCreativeParams { - - private final Map body = new LinkedHashMap<>(); - - private CreateAdCreativeParams() {} - - public static CreateAdCreativeParams of( - String workspaceId, - String connectionId, - String adAccountId, - String pageId, - String name, - String format, - String text) { - CreateAdCreativeParams params = new CreateAdCreativeParams(); - params.body.put("workspaceId", workspaceId); - params.body.put("connectionId", connectionId); - params.body.put("adAccountId", adAccountId); - params.body.put("pageId", pageId); - params.body.put("name", name); - params.body.put("format", format); - params.body.put("text", text); - return params; - } - - public CreateAdCreativeParams headline(String headline) { - body.put("headline", headline); - return this; - } - - public CreateAdCreativeParams destinationUrl(String destinationUrl) { - body.put("destinationUrl", destinationUrl); - return this; - } - - /** LEARN_MORE (the default), SHOP_NOW, SIGN_UP, SUBSCRIBE, CONTACT_US, DOWNLOAD, and so on. */ - public CreateAdCreativeParams callToAction(String callToAction) { - body.put("callToAction", callToAction); - return this; - } - - /** A query string appended to every link in the ad, e.g. {@code utm_source=meta&utm_medium=paid}. */ - public CreateAdCreativeParams urlTags(String urlTags) { - body.put("urlTags", urlTags); - return this; - } - - /** A media library asset url: the image, or the video. */ - public CreateAdCreativeParams mediaUrl(String mediaUrl) { - body.put("mediaUrl", mediaUrl); - return this; - } - - /** A video's poster frame, as a library image. Meta picks a frame when omitted. */ - public CreateAdCreativeParams thumbnailMediaUrl(String thumbnailMediaUrl) { - body.put("thumbnailMediaUrl", thumbnailMediaUrl); - return this; - } - - public CreateAdCreativeParams card(String mediaUrl) { - return card(mediaUrl, null, null, null); - } - - /** One carousel card. {@code mediaUrl} is a library image; the rest may be null. */ - public CreateAdCreativeParams card( - String mediaUrl, String destinationUrl, String headline, String description) { - Map card = new LinkedHashMap<>(); - card.put("mediaUrl", mediaUrl); - Params.put(card, "destinationUrl", destinationUrl); - Params.put(card, "headline", headline); - Params.put(card, "description", description); - cards().add(card); - return this; - } - - public Map toMap() { - return new LinkedHashMap<>(body); - } - - @SuppressWarnings("unchecked") - private List> cards() { - return (List>) body.computeIfAbsent("cards", ignored -> new ArrayList<>()); - } -} diff --git a/src/main/java/com/fopost/sdk/param/CreateAdSetParams.java b/src/main/java/com/fopost/sdk/param/CreateAdSetParams.java deleted file mode 100644 index 44f7d5a..0000000 --- a/src/main/java/com/fopost/sdk/param/CreateAdSetParams.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.fopost.sdk.param; - -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * An ad set inside a campaign. {@code pageId} is the Page its ads run as; {@code goal} is - * engagement, traffic, awareness or video_views. It starts paused unless {@link #paused(boolean)} - * is set to false. - */ -public final class CreateAdSetParams { - - private final Map body = new LinkedHashMap<>(); - - private CreateAdSetParams() {} - - public static CreateAdSetParams of( - String workspaceId, - String connectionId, - String campaignId, - String pageId, - String name, - String goal, - AdBudgetParams budget, - AdTargetingParams targeting) { - CreateAdSetParams params = new CreateAdSetParams(); - params.body.put("workspaceId", workspaceId); - params.body.put("connectionId", connectionId); - params.body.put("campaignId", campaignId); - params.body.put("pageId", pageId); - params.body.put("name", name); - params.body.put("goal", goal); - params.body.put("budget", budget.toMap()); - params.body.put("targeting", targeting.toMap()); - return params; - } - - /** False starts delivery at once. Defaults to true. */ - public CreateAdSetParams paused(boolean paused) { - body.put("paused", paused); - return this; - } - - public Map toMap() { - return new LinkedHashMap<>(body); - } -} diff --git a/src/main/java/com/fopost/sdk/param/CreateCatalogParams.java b/src/main/java/com/fopost/sdk/param/CreateCatalogParams.java deleted file mode 100644 index fa80d1b..0000000 --- a/src/main/java/com/fopost/sdk/param/CreateCatalogParams.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.fopost.sdk.param; - -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * A product catalog on the connection's business portfolio. Also needs the {@code publish} scope. - */ -public final class CreateCatalogParams { - - private final Map body = new LinkedHashMap<>(); - - private CreateCatalogParams() {} - - public static CreateCatalogParams of( - String workspaceId, - String connectionId, - String name) { - CreateCatalogParams params = new CreateCatalogParams(); - params.body.put("workspaceId", workspaceId); - params.body.put("connectionId", connectionId); - params.body.put("name", name); - return params; - } - - /** The network's catalog vertical; commerce when unset. */ - public CreateCatalogParams vertical(String vertical) { - body.put("vertical", vertical); - return this; - } - public Map toMap() { - return new LinkedHashMap<>(body); - } -} diff --git a/src/main/java/com/fopost/sdk/param/CreateNetworkAdParams.java b/src/main/java/com/fopost/sdk/param/CreateNetworkAdParams.java deleted file mode 100644 index 8bc1d5a..0000000 --- a/src/main/java/com/fopost/sdk/param/CreateNetworkAdParams.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.fopost.sdk.param; - -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * An ad inside an ad set, from a creative made with {@code ads().createCreative(...)} or already on - * the ad account. It starts paused unless {@link #paused(boolean)} is set to false. - */ -public final class CreateNetworkAdParams { - - private final Map body = new LinkedHashMap<>(); - - private CreateNetworkAdParams() {} - - public static CreateNetworkAdParams of( - String workspaceId, String connectionId, String adSetId, String creativeId, String name) { - CreateNetworkAdParams params = new CreateNetworkAdParams(); - params.body.put("workspaceId", workspaceId); - params.body.put("connectionId", connectionId); - params.body.put("adSetId", adSetId); - params.body.put("creativeId", creativeId); - params.body.put("name", name); - return params; - } - - /** False starts delivery at once. Defaults to true. */ - public CreateNetworkAdParams paused(boolean paused) { - body.put("paused", paused); - return this; - } - - public Map toMap() { - return new LinkedHashMap<>(body); - } -} diff --git a/src/main/java/com/fopost/sdk/param/CreateProductFeedParams.java b/src/main/java/com/fopost/sdk/param/CreateProductFeedParams.java deleted file mode 100644 index c84e5f7..0000000 --- a/src/main/java/com/fopost/sdk/param/CreateProductFeedParams.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.fopost.sdk.param; - -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * A product feed. A {@link #schedule(String)} needs a {@link #url(String)}. Also needs the - * {@code publish} scope. - */ -public final class CreateProductFeedParams { - - private final Map body = new LinkedHashMap<>(); - - private CreateProductFeedParams() {} - - public static CreateProductFeedParams of( - String workspaceId, - String connectionId, - String name) { - CreateProductFeedParams params = new CreateProductFeedParams(); - params.body.put("workspaceId", workspaceId); - params.body.put("connectionId", connectionId); - params.body.put("name", name); - return params; - } - - /** Where the network fetches the file; omit for manual uploads. */ - public CreateProductFeedParams url(String url) { - body.put("url", url); - return this; - } - - /** HOURLY, DAILY or WEEKLY. Needs a url. */ - public CreateProductFeedParams schedule(String schedule) { - body.put("schedule", schedule); - return this; - } - public Map toMap() { - return new LinkedHashMap<>(body); - } -} diff --git a/src/main/java/com/fopost/sdk/param/GoogleAssetGroupParams.java b/src/main/java/com/fopost/sdk/param/GoogleAssetGroupParams.java deleted file mode 100644 index 445503f..0000000 --- a/src/main/java/com/fopost/sdk/param/GoogleAssetGroupParams.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.fopost.sdk.param; - -import java.util.List; -import java.util.Map; - -/** Create or change a Performance Max asset group. */ -public final class GoogleAssetGroupParams { - - private GoogleAssetGroupParams() {} - - /** Creates one. It starts paused unless a status says otherwise. */ - public static final class Create { - - private final Map body; - - public Create( - GoogleAdsScope scope, String campaignId, String name, List finalUrls) { - body = scope.toMap(); - body.put("campaignId", campaignId); - body.put("name", name); - body.put("finalUrls", finalUrls); - } - - /** {@code active} or {@code paused}. */ - public Create status(String status) { - body.put("status", status); - return this; - } - - public Map toMap() { - return body; - } - } - - /** Renames, pauses or resumes one. */ - public static final class Update { - - private final Map body; - - public Update(GoogleAdsScope scope) { - body = scope.toMap(); - } - - public Update name(String name) { - body.put("name", name); - return this; - } - - public Update status(String status) { - body.put("status", status); - return this; - } - - public Map toMap() { - return body; - } - } -} diff --git a/src/main/java/com/fopost/sdk/param/GoogleAssetParams.java b/src/main/java/com/fopost/sdk/param/GoogleAssetParams.java deleted file mode 100644 index 543958f..0000000 --- a/src/main/java/com/fopost/sdk/param/GoogleAssetParams.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.fopost.sdk.param; - -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -/** Add an asset to the library. The kind picks which other fields apply. */ -public final class GoogleAssetParams { - - private final Map body; - private final Map spec = new LinkedHashMap<>(); - - private GoogleAssetParams(GoogleAdsScope scope, String kind) { - body = scope.toMap(); - spec.put("kind", kind); - } - - /** A link under the ad, with its own destination. */ - public static GoogleAssetParams sitelink(GoogleAdsScope scope, String text, String finalUrl) { - GoogleAssetParams params = new GoogleAssetParams(scope, "sitelink"); - params.spec.put("text", text); - params.spec.put("finalUrl", finalUrl); - return params; - } - - /** A short phrase beside the ad. */ - public static GoogleAssetParams callout(GoogleAdsScope scope, String text) { - GoogleAssetParams params = new GoogleAssetParams(scope, "callout"); - params.spec.put("text", text); - return params; - } - - /** A header and the values listed under it. */ - public static GoogleAssetParams snippet( - GoogleAdsScope scope, String header, List values) { - GoogleAssetParams params = new GoogleAssetParams(scope, "snippet"); - params.spec.put("header", header); - params.spec.put("values", values); - return params; - } - - /** The lines under a sitelink. */ - public GoogleAssetParams descriptions(String description1, String description2) { - spec.put("description1", description1); - spec.put("description2", description2); - return this; - } - - public Map toMap() { - body.put("spec", spec); - return body; - } -} diff --git a/src/main/java/com/fopost/sdk/param/GoogleKeywordIdeasParams.java b/src/main/java/com/fopost/sdk/param/GoogleKeywordIdeasParams.java deleted file mode 100644 index 11f9bd6..0000000 --- a/src/main/java/com/fopost/sdk/param/GoogleKeywordIdeasParams.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.fopost.sdk.param; - -import java.util.List; -import java.util.Map; - -/** Ask for keyword ideas from seed terms, a landing page, or both. */ -public final class GoogleKeywordIdeasParams { - - private final Map body; - - public GoogleKeywordIdeasParams(GoogleAdsScope scope) { - body = scope.toMap(); - } - - public GoogleKeywordIdeasParams seeds(List seeds) { - body.put("seeds", seeds); - return this; - } - - public GoogleKeywordIdeasParams url(String url) { - body.put("url", url); - return this; - } - - public GoogleKeywordIdeasParams languageId(String languageId) { - body.put("languageId", languageId); - return this; - } - - public GoogleKeywordIdeasParams geoTargetIds(List geoTargetIds) { - body.put("geoTargetIds", geoTargetIds); - return this; - } - - public Map toMap() { - return body; - } -} diff --git a/src/main/java/com/fopost/sdk/param/GoogleKeywordParams.java b/src/main/java/com/fopost/sdk/param/GoogleKeywordParams.java deleted file mode 100644 index b0eae89..0000000 --- a/src/main/java/com/fopost/sdk/param/GoogleKeywordParams.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.fopost.sdk.param; - -import java.util.Map; - -/** Add a keyword to an ad group, or change one that is already there. */ -public final class GoogleKeywordParams { - - private GoogleKeywordParams() {} - - /** Adds a keyword. {@code matchType} is EXACT, PHRASE or BROAD. */ - public static final class Create { - - private final Map body; - - public Create(GoogleAdsScope scope, String adGroupId, String text, String matchType) { - body = scope.toMap(); - body.put("adGroupId", adGroupId); - body.put("text", text); - body.put("matchType", matchType); - } - - /** The account's currency, in minor units. */ - public Create cpcBidMinor(long minor) { - body.put("cpcBidMinor", minor); - return this; - } - - public Map toMap() { - return body; - } - } - - /** Pauses, resumes or rebids a keyword. */ - public static final class Update { - - private final Map body; - - public Update(GoogleAdsScope scope) { - body = scope.toMap(); - } - - /** {@code active} or {@code paused}. */ - public Update status(String status) { - body.put("status", status); - return this; - } - - public Update cpcBidMinor(long minor) { - body.put("cpcBidMinor", minor); - return this; - } - - public Map toMap() { - return body; - } - } -} diff --git a/src/main/java/com/fopost/sdk/param/GoogleNegativeKeywordParams.java b/src/main/java/com/fopost/sdk/param/GoogleNegativeKeywordParams.java deleted file mode 100644 index c74cbd9..0000000 --- a/src/main/java/com/fopost/sdk/param/GoogleNegativeKeywordParams.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.fopost.sdk.param; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -/** Add keywords a campaign should never match. */ -public final class GoogleNegativeKeywordParams { - - private final Map body; - private final List> keywords = new ArrayList<>(); - - public GoogleNegativeKeywordParams(GoogleAdsScope scope, String sharedSetId) { - body = scope.toMap(); - body.put("sharedSetId", sharedSetId); - } - - /** {@code matchType} is EXACT, PHRASE or BROAD. */ - public GoogleNegativeKeywordParams keyword(String text, String matchType) { - Map keyword = new LinkedHashMap<>(); - keyword.put("text", text); - keyword.put("matchType", matchType); - keywords.add(keyword); - return this; - } - - public Map toMap() { - body.put("keywords", keywords); - return body; - } -} diff --git a/src/main/java/com/fopost/sdk/param/ProductSetParams.java b/src/main/java/com/fopost/sdk/param/ProductSetParams.java deleted file mode 100644 index fc819c7..0000000 --- a/src/main/java/com/fopost/sdk/param/ProductSetParams.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.fopost.sdk.param; - -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * A product set: the slice of a catalog one catalog ad runs from. Without a - * {@link #filter(java.util.Map)} the set is the whole catalog. Also needs the {@code publish} scope. - */ -public final class ProductSetParams { - - private final Map body = new LinkedHashMap<>(); - - private ProductSetParams() {} - - public static ProductSetParams of( - String workspaceId, - String connectionId, - String name) { - ProductSetParams params = new ProductSetParams(); - params.body.put("workspaceId", workspaceId); - params.body.put("connectionId", connectionId); - params.body.put("name", name); - return params; - } - - /** The network's own product-set filter. */ - public ProductSetParams filter(java.util.Map filter) { - body.put("filter", filter); - return this; - } - public Map toMap() { - return new LinkedHashMap<>(body); - } -} diff --git a/src/main/java/com/fopost/sdk/param/StartFeedUploadParams.java b/src/main/java/com/fopost/sdk/param/StartFeedUploadParams.java deleted file mode 100644 index c6939f9..0000000 --- a/src/main/java/com/fopost/sdk/param/StartFeedUploadParams.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.fopost.sdk.param; - -import java.util.LinkedHashMap; -import java.util.Map; - -/** Fetches a feed now. Also needs the {@code publish} scope. */ -public final class StartFeedUploadParams { - - private final Map body = new LinkedHashMap<>(); - - private StartFeedUploadParams() {} - - public static StartFeedUploadParams of( - String workspaceId, - String connectionId) { - StartFeedUploadParams params = new StartFeedUploadParams(); - params.body.put("workspaceId", workspaceId); - params.body.put("connectionId", connectionId); - return params; - } - - /** Overrides the feed's own url for this run. */ - public StartFeedUploadParams url(String url) { - body.put("url", url); - return this; - } - public Map toMap() { - return new LinkedHashMap<>(body); - } -} diff --git a/src/main/java/com/fopost/sdk/param/UpdateAdCampaignParams.java b/src/main/java/com/fopost/sdk/param/UpdateAdCampaignParams.java deleted file mode 100644 index 4f28a9b..0000000 --- a/src/main/java/com/fopost/sdk/param/UpdateAdCampaignParams.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.fopost.sdk.param; - -import java.util.LinkedHashMap; -import java.util.Map; - -/** Changes to a campaign. Only what is set is sent. */ -public final class UpdateAdCampaignParams { - - private final Map body = new LinkedHashMap<>(); - - public static UpdateAdCampaignParams create() { - return new UpdateAdCampaignParams(); - } - - public UpdateAdCampaignParams name(String name) { - body.put("name", name); - return this; - } - - /** active or paused. */ - public UpdateAdCampaignParams status(String status) { - body.put("status", status); - return this; - } - - public Map toMap() { - return new LinkedHashMap<>(body); - } -} diff --git a/src/main/java/com/fopost/sdk/param/UpdateAdSetParams.java b/src/main/java/com/fopost/sdk/param/UpdateAdSetParams.java deleted file mode 100644 index 0b19ece..0000000 --- a/src/main/java/com/fopost/sdk/param/UpdateAdSetParams.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.fopost.sdk.param; - -import java.time.Instant; -import java.util.LinkedHashMap; -import java.util.Map; - -/** Changes to an ad set. Only what is set is sent. */ -public final class UpdateAdSetParams { - - private final Map body = new LinkedHashMap<>(); - - public static UpdateAdSetParams create() { - return new UpdateAdSetParams(); - } - - public UpdateAdSetParams name(String name) { - body.put("name", name); - return this; - } - - /** active or paused. */ - public UpdateAdSetParams status(String status) { - body.put("status", status); - return this; - } - - /** The new budget in minor units; the budget type set at creation stays. */ - public UpdateAdSetParams budgetMinor(long budgetMinor) { - body.put("budgetMinor", budgetMinor); - return this; - } - - public UpdateAdSetParams endAt(Instant endAt) { - Params.put(body, "endAt", Params.iso(endAt)); - return this; - } - - public UpdateAdSetParams targeting(AdTargetingParams targeting) { - body.put("targeting", targeting.toMap()); - return this; - } - - public Map toMap() { - return new LinkedHashMap<>(body); - } -} diff --git a/src/main/java/com/fopost/sdk/param/UpdateCatalogParams.java b/src/main/java/com/fopost/sdk/param/UpdateCatalogParams.java deleted file mode 100644 index 75334f3..0000000 --- a/src/main/java/com/fopost/sdk/param/UpdateCatalogParams.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.fopost.sdk.param; - -import java.util.LinkedHashMap; -import java.util.Map; - -/** Renames a catalog. Also needs the {@code publish} scope. */ -public final class UpdateCatalogParams { - - private final Map body = new LinkedHashMap<>(); - - private UpdateCatalogParams() {} - - public static UpdateCatalogParams of( - String workspaceId, - String connectionId, - String name) { - UpdateCatalogParams params = new UpdateCatalogParams(); - params.body.put("workspaceId", workspaceId); - params.body.put("connectionId", connectionId); - params.body.put("name", name); - return params; - } - - public Map toMap() { - return new LinkedHashMap<>(body); - } -} diff --git a/src/main/java/com/fopost/sdk/param/UpdateNetworkAdParams.java b/src/main/java/com/fopost/sdk/param/UpdateNetworkAdParams.java deleted file mode 100644 index 6a52d42..0000000 --- a/src/main/java/com/fopost/sdk/param/UpdateNetworkAdParams.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.fopost.sdk.param; - -import java.util.LinkedHashMap; -import java.util.Map; - -/** Changes to an ad inside an ad set. Only what is set is sent. */ -public final class UpdateNetworkAdParams { - - private final Map body = new LinkedHashMap<>(); - - public static UpdateNetworkAdParams create() { - return new UpdateNetworkAdParams(); - } - - public UpdateNetworkAdParams name(String name) { - body.put("name", name); - return this; - } - - /** active or paused. */ - public UpdateNetworkAdParams status(String status) { - body.put("status", status); - return this; - } - - /** Swap the creative the ad shows. */ - public UpdateNetworkAdParams creativeId(String creativeId) { - body.put("creativeId", creativeId); - return this; - } - - public Map toMap() { - return new LinkedHashMap<>(body); - } -} diff --git a/src/main/java/com/fopost/sdk/resource/AdsResource.java b/src/main/java/com/fopost/sdk/resource/AdsResource.java index 6b20b22..1c1ae77 100644 --- a/src/main/java/com/fopost/sdk/resource/AdsResource.java +++ b/src/main/java/com/fopost/sdk/resource/AdsResource.java @@ -5,42 +5,25 @@ import com.fopost.sdk.model.AdActivity; import com.fopost.sdk.model.AdLabel; import com.fopost.sdk.model.AdStudy; -import com.fopost.sdk.model.CatalogBatchResult; -import com.fopost.sdk.model.CatalogProductsPage; import com.fopost.sdk.model.HighDemandPeriod; import com.fopost.sdk.model.IosCampaignLimits; import com.fopost.sdk.model.PartnershipCreator; -import com.fopost.sdk.model.ProductCatalog; -import com.fopost.sdk.model.ProductFeed; -import com.fopost.sdk.model.ProductFeedUpload; -import com.fopost.sdk.model.ProductSet; import com.fopost.sdk.model.ReachFrequencyPrediction; import com.fopost.sdk.model.ValueRuleSet; import com.fopost.sdk.param.AdLabelParams; import com.fopost.sdk.param.ApplyAdLabelParams; -import com.fopost.sdk.param.CatalogProductBatchParams; import com.fopost.sdk.param.CreateAdStudyParams; -import com.fopost.sdk.param.CreateCatalogParams; import com.fopost.sdk.param.CreateHighDemandPeriodParams; -import com.fopost.sdk.param.CreateProductFeedParams; import com.fopost.sdk.param.CreateReachFrequencyParams; import com.fopost.sdk.param.CreateValueRuleSetParams; import com.fopost.sdk.param.PartnershipParams; -import com.fopost.sdk.param.ProductSetParams; import com.fopost.sdk.param.ReachFrequencyActionParams; -import com.fopost.sdk.param.StartFeedUploadParams; -import com.fopost.sdk.param.UpdateCatalogParams; -import com.fopost.sdk.model.AdAccountTree; import com.fopost.sdk.model.AdBusinessCenter; -import com.fopost.sdk.model.AdCampaign; import com.fopost.sdk.model.AdCommentsPage; import com.fopost.sdk.model.AdConnection; -import com.fopost.sdk.model.AdCreative; import com.fopost.sdk.model.AdIdentity; import com.fopost.sdk.model.AdInsightsReport; -import com.fopost.sdk.model.AdLibraryPage; import com.fopost.sdk.model.AdProvider; -import com.fopost.sdk.model.AdSet; import com.fopost.sdk.model.AdSource; import com.fopost.sdk.model.Audience; import com.fopost.sdk.model.AudiencesResult; @@ -57,7 +40,6 @@ import com.fopost.sdk.model.LeadPageSubscription; import com.fopost.sdk.model.LeadsFeed; import com.fopost.sdk.model.LeadsPage; -import com.fopost.sdk.model.NetworkAd; import com.fopost.sdk.model.ReachEstimate; import com.fopost.sdk.model.SparkPost; import com.fopost.sdk.model.SupplyForecast; @@ -67,19 +49,13 @@ import com.fopost.sdk.param.AdInsightsParams; import com.fopost.sdk.param.BoostPostParams; import com.fopost.sdk.param.BulkAdStatusParams; -import com.fopost.sdk.param.CreateAdCampaignParams; -import com.fopost.sdk.param.CreateAdCreativeParams; import com.fopost.sdk.param.CreateAdParams; -import com.fopost.sdk.param.CreateAdSetParams; import com.fopost.sdk.param.ConversionEventParams; import com.fopost.sdk.param.CreateAudienceParams; import com.fopost.sdk.param.CreateConversionRuleParams; import com.fopost.sdk.param.CreateLeadFormParams; -import com.fopost.sdk.param.CreateNetworkAdParams; import com.fopost.sdk.param.LeadsFeedParams; import com.fopost.sdk.param.ReachEstimateParams; -import com.fopost.sdk.param.UpdateAdCampaignParams; -import com.fopost.sdk.param.UpdateAdSetParams; import com.fopost.sdk.model.AdPixel; import com.fopost.sdk.model.AdPixelDetail; import com.fopost.sdk.model.AdPixelStats; @@ -93,14 +69,12 @@ import com.fopost.sdk.param.UploadConversionsParams; import com.fopost.sdk.param.UpdateAudienceParams; import com.fopost.sdk.param.UpdateConversionRuleParams; -import com.fopost.sdk.param.UpdateNetworkAdParams; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; /** - * Boosts, ads, campaigns, creatives, catalogs, audiences, predictions, the public ad archive, - * insights and lead forms on the connected ad accounts. + * Boosts, ads, audiences, predictions, insights and lead forms on the connected ad accounts. * *
{@code
  * BoostablePost candidate = client.ads().boostable(workspaceId).get(0);
@@ -114,11 +88,9 @@
  * }
* *

Every call needs the {@code ads} scope on an API key. {@link #boost}, {@link #create}, - * {@link #setStatus} and {@link #delete} spend money and also need the {@code publish} scope, as do - * creating, updating, deleting and duplicating campaigns, ad sets and network ads, and - * {@link #bulkSetStatus}. A - * boost or ad starts paused unless {@code paused} is set to false, so nothing is spent until it is - * resumed. + * {@link #setStatus} and {@link #delete} spend money and also need the {@code publish} scope, as does + * {@link #bulkSetStatus}. A boost or ad starts paused unless {@code paused} is set to false, so + * nothing is spent until it is resumed. */ public final class AdsResource { @@ -267,147 +239,6 @@ public void delete(String adId, String workspaceId) { http.request("DELETE", "/v1/ads/" + adId, null, workspaceQuery(workspaceId)); } - // ─── Campaigns, ad sets and ads ─────────────────────────────────────────── - - public AdAccountTree accountTree(String adAccountId, String connectionId) { - return accountTree(adAccountId, connectionId, null); - } - - /** Every campaign on the ad account with its ad sets and ads, read live from Meta. */ - public AdAccountTree accountTree(String adAccountId, String connectionId, String workspaceId) { - return http.convert( - ApiClient.unwrap(http.get( - "/v1/ads/accounts/" + adAccountId + "/tree", connectionQuery(workspaceId, connectionId))), - AdAccountTree.class); - } - - /** Needs the {@code publish} scope as well as {@code ads}. Starts paused unless {@code paused} is false. */ - public AdCampaign createCampaign(CreateAdCampaignParams params) { - return http.convert(ApiClient.unwrap(http.post("/v1/ads/campaigns", params.toMap())), AdCampaign.class); - } - - public AdCampaign campaign(String campaignId, String connectionId) { - return campaign(campaignId, connectionId, null); - } - - public AdCampaign campaign(String campaignId, String connectionId, String workspaceId) { - return http.convert( - ApiClient.unwrap( - http.get("/v1/ads/campaigns/" + campaignId, connectionQuery(workspaceId, connectionId))), - AdCampaign.class); - } - - /** Needs the {@code publish} scope as well as {@code ads}. */ - public AdCampaign updateCampaign( - String campaignId, String workspaceId, String connectionId, UpdateAdCampaignParams params) { - return http.convert( - ApiClient.unwrap(http.request( - "PATCH", - "/v1/ads/campaigns/" + campaignId, - params.toMap(), - connectionQuery(workspaceId, connectionId))), - AdCampaign.class); - } - - /** Deletes the campaign with its ad sets and ads. Needs the {@code publish} scope as well as {@code ads}. */ - public void deleteCampaign(String campaignId, String workspaceId, String connectionId) { - http.request("DELETE", "/v1/ads/campaigns/" + campaignId, null, connectionQuery(workspaceId, connectionId)); - } - - public String duplicateCampaign(String campaignId, String workspaceId, String connectionId) { - return duplicateCampaign(campaignId, workspaceId, connectionId, null); - } - - /** - * Copy the campaign and everything in it. Returns the copy's Meta id. The copy starts paused - * unless {@code paused} is false. Needs the {@code publish} scope as well as {@code ads}. - */ - public String duplicateCampaign(String campaignId, String workspaceId, String connectionId, Boolean paused) { - return duplicate("/v1/ads/campaigns/" + campaignId, workspaceId, connectionId, paused); - } - - /** Needs the {@code publish} scope as well as {@code ads}. Starts paused unless {@code paused} is false. */ - public AdSet createAdSet(CreateAdSetParams params) { - return http.convert(ApiClient.unwrap(http.post("/v1/ads/ad-sets", params.toMap())), AdSet.class); - } - - public AdSet adSet(String adSetId, String connectionId) { - return adSet(adSetId, connectionId, null); - } - - public AdSet adSet(String adSetId, String connectionId, String workspaceId) { - return http.convert( - ApiClient.unwrap(http.get("/v1/ads/ad-sets/" + adSetId, connectionQuery(workspaceId, connectionId))), - AdSet.class); - } - - /** Needs the {@code publish} scope as well as {@code ads}. */ - public AdSet updateAdSet(String adSetId, String workspaceId, String connectionId, UpdateAdSetParams params) { - return http.convert( - ApiClient.unwrap(http.request( - "PATCH", - "/v1/ads/ad-sets/" + adSetId, - params.toMap(), - connectionQuery(workspaceId, connectionId))), - AdSet.class); - } - - /** Needs the {@code publish} scope as well as {@code ads}. */ - public void deleteAdSet(String adSetId, String workspaceId, String connectionId) { - http.request("DELETE", "/v1/ads/ad-sets/" + adSetId, null, connectionQuery(workspaceId, connectionId)); - } - - public String duplicateAdSet(String adSetId, String workspaceId, String connectionId) { - return duplicateAdSet(adSetId, workspaceId, connectionId, null); - } - - /** Returns the copy's Meta id. Needs the {@code publish} scope as well as {@code ads}. */ - public String duplicateAdSet(String adSetId, String workspaceId, String connectionId, Boolean paused) { - return duplicate("/v1/ads/ad-sets/" + adSetId, workspaceId, connectionId, paused); - } - - /** - * An ad inside an ad set, unlike {@link #create}, which builds a whole campaign. Needs the - * {@code publish} scope as well as {@code ads}. Starts paused unless {@code paused} is false. - */ - public NetworkAd createNetworkAd(CreateNetworkAdParams params) { - return http.convert(ApiClient.unwrap(http.post("/v1/ads/ads", params.toMap())), NetworkAd.class); - } - - public NetworkAd networkAd(String adId, String connectionId) { - return networkAd(adId, connectionId, null); - } - - /** {@code adId} is Meta's ad id. */ - public NetworkAd networkAd(String adId, String connectionId, String workspaceId) { - return http.convert( - ApiClient.unwrap(http.get("/v1/ads/ads/" + adId, connectionQuery(workspaceId, connectionId))), - NetworkAd.class); - } - - /** Needs the {@code publish} scope as well as {@code ads}. */ - public NetworkAd updateNetworkAd( - String adId, String workspaceId, String connectionId, UpdateNetworkAdParams params) { - return http.convert( - ApiClient.unwrap(http.request( - "PATCH", "/v1/ads/ads/" + adId, params.toMap(), connectionQuery(workspaceId, connectionId))), - NetworkAd.class); - } - - /** Needs the {@code publish} scope as well as {@code ads}. */ - public void deleteNetworkAd(String adId, String workspaceId, String connectionId) { - http.request("DELETE", "/v1/ads/ads/" + adId, null, connectionQuery(workspaceId, connectionId)); - } - - public String duplicateNetworkAd(String adId, String workspaceId, String connectionId) { - return duplicateNetworkAd(adId, workspaceId, connectionId, null); - } - - /** Returns the copy's Meta id. Needs the {@code publish} scope as well as {@code ads}. */ - public String duplicateNetworkAd(String adId, String workspaceId, String connectionId, Boolean paused) { - return duplicate("/v1/ads/ads/" + adId, workspaceId, connectionId, paused); - } - /** * Pause or resume campaigns, ad sets and ads in one call; each object reports on its own. * Needs the {@code publish} scope as well as {@code ads}. @@ -417,39 +248,6 @@ public List bulkSetStatus(BulkAdStatusParams params) { ApiClient.unwrap(http.post("/v1/ads/status", params.toMap())), BulkAdStatusResult.class); } - // ─── Creatives ──────────────────────────────────────────────────────────── - - public List creatives(String connectionId, String adAccountId) { - return creatives(connectionId, adAccountId, null); - } - - /** The creatives on one ad account. */ - public List creatives(String connectionId, String adAccountId, String workspaceId) { - Map query = connectionQuery(workspaceId, connectionId); - query.put("ad_account_id", adAccountId); - return http.convertList( - ApiClient.unwrap(http.get("/v1/ads/creatives", query)).path("creatives"), AdCreative.class); - } - - public AdCreative createCreative(CreateAdCreativeParams params) { - return http.convert(ApiClient.unwrap(http.post("/v1/ads/creatives", params.toMap())), AdCreative.class); - } - - public AdCreative creative(String creativeId, String connectionId) { - return creative(creativeId, connectionId, null); - } - - public AdCreative creative(String creativeId, String connectionId, String workspaceId) { - return http.convert( - ApiClient.unwrap( - http.get("/v1/ads/creatives/" + creativeId, connectionQuery(workspaceId, connectionId))), - AdCreative.class); - } - - public void deleteCreative(String creativeId, String workspaceId, String connectionId) { - http.request("DELETE", "/v1/ads/creatives/" + creativeId, null, connectionQuery(workspaceId, connectionId)); - } - // ─── Reach and insights ─────────────────────────────────────────────────── /** The audience size a targeting would reach. */ @@ -1005,18 +803,6 @@ public void unsubscribeLeadPage(String pageId, String workspaceId, String connec http.request("DELETE", "/v1/ads/lead-pages/" + pageId, null, connectionQuery(workspaceId, connectionId)); } - // ─── Plumbing ───────────────────────────────────────────────────────────── - - private String duplicate(String path, String workspaceId, String connectionId, Boolean paused) { - Map body = new LinkedHashMap<>(); - if (paused != null) { - body.put("paused", paused); - } - return ApiClient.unwrap(http.post(path + "/duplicate", body, connectionQuery(workspaceId, connectionId))) - .path("id") - .asText(); - } - // ─── Goals ────────────────────────────────────────────────────── /** @@ -1033,172 +819,6 @@ public List goals(String connectionId, String workspaceId) { String.class); } - // ─── Product catalogs ─────────────────────────────────────────── - - /** Catalogs the connection's business portfolios reach. Read live, never stored. */ - public List catalogs(String connectionId) { - return catalogs(connectionId, null); - } - - public List catalogs(String connectionId, String workspaceId) { - return http.convertList( - ApiClient.unwrap(http.get("/v1/ads/catalogs", connectionQuery(workspaceId, connectionId))) - .path("catalogs"), - ProductCatalog.class); - } - - /** Created on the connection's business portfolio. Also needs the {@code publish} scope. */ - public ProductCatalog createCatalog(CreateCatalogParams params) { - return http.convert(ApiClient.unwrap(http.post("/v1/ads/catalogs", params.toMap())), ProductCatalog.class); - } - - public ProductCatalog catalog(String catalogId, String connectionId) { - return catalog(catalogId, connectionId, null); - } - - public ProductCatalog catalog(String catalogId, String connectionId, String workspaceId) { - return http.convert( - ApiClient.unwrap( - http.get("/v1/ads/catalogs/" + catalogId, connectionQuery(workspaceId, connectionId))), - ProductCatalog.class); - } - - /** Also needs the {@code publish} scope. */ - public ProductCatalog updateCatalog( - String catalogId, String workspaceId, String connectionId, UpdateCatalogParams params) { - return http.convert( - ApiClient.unwrap(http.request( - "PATCH", - "/v1/ads/catalogs/" + catalogId, - params.toMap(), - connectionQuery(workspaceId, connectionId))), - ProductCatalog.class); - } - - /** - * Deletes the catalog with every product, feed and set in it. Also needs the {@code publish} - * scope. - */ - public void deleteCatalog(String catalogId, String workspaceId, String connectionId) { - http.request("DELETE", "/v1/ads/catalogs/" + catalogId, null, connectionQuery(workspaceId, connectionId)); - } - - /** One page of products; pass {@code nextCursor} back as {@code after}. */ - public CatalogProductsPage catalogProducts(String catalogId, String connectionId) { - return catalogProducts(catalogId, connectionId, null, null); - } - - public CatalogProductsPage catalogProducts( - String catalogId, String connectionId, String workspaceId, String after) { - Map query = connectionQuery(workspaceId, connectionId); - if (after != null) { - query.put("after", after); - } - return http.convert( - ApiClient.unwrap(http.get("/v1/ads/catalogs/" + catalogId + "/products", query)), - CatalogProductsPage.class); - } - - /** - * Up to 500 upserts and deletes in one batch, keyed by your own retailer id. Also needs the - * {@code publish} scope. - */ - public CatalogBatchResult writeCatalogProducts(String catalogId, CatalogProductBatchParams params) { - return http.convert( - ApiClient.unwrap(http.post("/v1/ads/catalogs/" + catalogId + "/products", params.toMap())), - CatalogBatchResult.class); - } - - public List productFeeds(String catalogId, String connectionId) { - return productFeeds(catalogId, connectionId, null); - } - - public List productFeeds(String catalogId, String connectionId, String workspaceId) { - return http.convertList( - ApiClient.unwrap(http.get( - "/v1/ads/catalogs/" + catalogId + "/feeds", connectionQuery(workspaceId, connectionId))), - ProductFeed.class); - } - - /** Also needs the {@code publish} scope. */ - public ProductFeed createProductFeed(String catalogId, CreateProductFeedParams params) { - return http.convert( - ApiClient.unwrap(http.post("/v1/ads/catalogs/" + catalogId + "/feeds", params.toMap())), - ProductFeed.class); - } - - /** Also needs the {@code publish} scope. */ - public void deleteProductFeed(String catalogId, String feedId, String workspaceId, String connectionId) { - http.request( - "DELETE", - "/v1/ads/catalogs/" + catalogId + "/feeds/" + feedId, - null, - connectionQuery(workspaceId, connectionId)); - } - - /** Each run the network made of the feed. */ - public List feedUploads(String catalogId, String feedId, String connectionId) { - return feedUploads(catalogId, feedId, connectionId, null); - } - - public List feedUploads( - String catalogId, String feedId, String connectionId, String workspaceId) { - return http.convertList( - ApiClient.unwrap(http.get( - "/v1/ads/catalogs/" + catalogId + "/feeds/" + feedId + "/uploads", - connectionQuery(workspaceId, connectionId))), - ProductFeedUpload.class); - } - - /** Fetches the feed now and returns the id of the run. Also needs the {@code publish} scope. */ - public String startFeedUpload(String catalogId, String feedId, StartFeedUploadParams params) { - return ApiClient.unwrap(http.post( - "/v1/ads/catalogs/" + catalogId + "/feeds/" + feedId + "/uploads", params.toMap())) - .path("id") - .asText(); - } - - /** A catalog ad runs from a product set, not the whole catalog. */ - public List productSets(String catalogId, String connectionId) { - return productSets(catalogId, connectionId, null); - } - - public List productSets(String catalogId, String connectionId, String workspaceId) { - return http.convertList( - ApiClient.unwrap(http.get( - "/v1/ads/catalogs/" + catalogId + "/product-sets", - connectionQuery(workspaceId, connectionId))), - ProductSet.class); - } - - /** Also needs the {@code publish} scope. */ - public ProductSet createProductSet(String catalogId, ProductSetParams params) { - return http.convert( - ApiClient.unwrap(http.post("/v1/ads/catalogs/" + catalogId + "/product-sets", params.toMap())), - ProductSet.class); - } - - /** Also needs the {@code publish} scope. */ - public ProductSet updateProductSet( - String catalogId, String setId, String workspaceId, String connectionId, ProductSetParams params) { - return http.convert( - ApiClient.unwrap(http.request( - "PATCH", - "/v1/ads/catalogs/" + catalogId + "/product-sets/" + setId, - params.toMap(), - connectionQuery(workspaceId, connectionId))), - ProductSet.class); - } - - /** Also needs the {@code publish} scope. */ - public void deleteProductSet(String catalogId, String setId, String workspaceId, String connectionId) { - http.request( - "DELETE", - "/v1/ads/catalogs/" + catalogId + "/product-sets/" + setId, - null, - connectionQuery(workspaceId, connectionId)); - } - // ─── Reach and frequency ──────────────────────────────────────── public List reachFrequency(String connectionId, String adAccountId) { @@ -1255,38 +875,6 @@ public ReachFrequencyPrediction cancelReachFrequency( return reachFrequencyAction(predictionId, "cancel", params); } - // ─── Ad Library ───────────────────────────────────────────────── - - /** - * The public ad archive: ads anyone is running, by keyword or by Page. Read live on every call - * and stored nowhere, so an ad that stops running is simply absent from the next search. - * {@code countries} are two-letter codes the ad reached. - */ - public AdLibraryPage library(String connectionId, List countries, String query) { - return library(connectionId, countries, query, null, null, null); - } - - public AdLibraryPage library( - String connectionId, - List countries, - String query, - List pageIds, - String activeStatus, - String workspaceId) { - Map params = connectionQuery(workspaceId, connectionId); - params.put("countries", String.join(",", countries)); - if (query != null) { - params.put("q", query); - } - if (pageIds != null && !pageIds.isEmpty()) { - params.put("page_ids", String.join(",", pageIds)); - } - if (activeStatus != null) { - params.put("active_status", activeStatus); - } - return http.convert(ApiClient.unwrap(http.get("/v1/ads/library", params)), AdLibraryPage.class); - } - // ─── Partnership ads ──────────────────────────────────────────── /** Creators who allowlisted this Page to run partnership ads on their posts. */ diff --git a/src/main/java/com/fopost/sdk/resource/GoogleAdsResource.java b/src/main/java/com/fopost/sdk/resource/GoogleAdsResource.java index ce030ce..3ca5f2e 100644 --- a/src/main/java/com/fopost/sdk/resource/GoogleAdsResource.java +++ b/src/main/java/com/fopost/sdk/resource/GoogleAdsResource.java @@ -2,45 +2,30 @@ import com.fopost.sdk.internal.ApiClient; import com.fopost.sdk.model.GoogleAdScheduleSlot; -import com.fopost.sdk.model.GoogleAssetGroup; -import com.fopost.sdk.model.GoogleAssetsResult; import com.fopost.sdk.model.GoogleBidStrategy; import com.fopost.sdk.model.GoogleConversionAction; -import com.fopost.sdk.model.GoogleKeyword; -import com.fopost.sdk.model.GoogleKeywordIdea; import com.fopost.sdk.model.GoogleLocalServicesLead; -import com.fopost.sdk.model.GoogleOptimizationScore; import com.fopost.sdk.model.GoogleQueryResult; -import com.fopost.sdk.model.GoogleRecommendation; -import com.fopost.sdk.model.GoogleSearchTerm; -import com.fopost.sdk.model.GoogleSharedSet; import com.fopost.sdk.param.GoogleAdScheduleParams; import com.fopost.sdk.param.GoogleAdsScope; -import com.fopost.sdk.param.GoogleAssetGroupParams; -import com.fopost.sdk.param.GoogleAssetParams; import com.fopost.sdk.param.GoogleBidStrategyParams; import com.fopost.sdk.param.GoogleConversionParams; -import com.fopost.sdk.param.GoogleKeywordIdeasParams; -import com.fopost.sdk.param.GoogleKeywordParams; -import com.fopost.sdk.param.GoogleNegativeKeywordParams; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Map; /** - * The Google Ads surface no other network has: recommendations, the optimization score, keywords, - * assets, Performance Max asset groups, Local Services leads, conversions, and raw GAQL. + * The Google Ads surface no other network has: bid strategies, the ad schedule, Local Services + * leads, conversions, and raw GAQL. * - *

Campaigns, ad groups, ads, audiences and insights are on {@link AdsResource} and dispatch by - * connection; a connection on another network answers 400 here. Every call needs the {@code ads} - * scope, and anything that changes what a live account serves or bids also needs {@code publish}. + *

Ads, audiences and insights are on {@link AdsResource} and dispatch by connection; a + * connection on another network answers 400 here. Every call needs the {@code ads} scope, and + * anything that changes what a live account serves or bids also needs {@code publish}. * Amounts are in the account's currency, in minor units. * *

{@code
  * var scope = GoogleAdsScope.of(connectionId, "1234567890");
- * for (var recommendation : fopost.googleAds().recommendations(scope)) {
- *     System.out.println(recommendation.type());
+ * for (var strategy : fopost.googleAds().bidStrategies(scope)) {
+ *     System.out.println(strategy.name());
  * }
  * }
*/ @@ -52,103 +37,6 @@ public GoogleAdsResource(ApiClient http) { this.http = http; } - // ── Recommendations ── - - /** Google's own read on what the account should change next. */ - public List recommendations(GoogleAdsScope scope) { - return recommendations(scope, List.of()); - } - - /** {@code types} narrows to those recommendation types, such as {@code KEYWORD}. */ - public List recommendations(GoogleAdsScope scope, List types) { - Map query = scope.toQuery(); - if (!types.isEmpty()) { - query.put("types", String.join(",", types)); - } - return http.convertList( - ApiClient.unwrap(http.get("/v1/ads/google/recommendations", query)), - GoogleRecommendation.class); - } - - /** The account's score and weight, and the score of each live campaign. */ - public GoogleOptimizationScore optimizationScore(GoogleAdsScope scope) { - return http.convert( - ApiClient.unwrap(http.get("/v1/ads/google/optimization-score", scope.toQuery())), - GoogleOptimizationScore.class); - } - - /** - * Applies each one, which changes what the live account serves or bids, and answers how many - * landed. Needs {@code publish} as well as {@code ads}. Each id has to name a recommendation - * on this customer; any other answers 404. - */ - public int applyRecommendations(GoogleAdsScope scope, List ids) { - return counted("/v1/ads/google/recommendations/apply", scope, ids, "applied"); - } - - /** Hides each one so Google stops surfacing it. Needs {@code publish}. */ - public int dismissRecommendations(GoogleAdsScope scope, List ids) { - return counted("/v1/ads/google/recommendations/dismiss", scope, ids, "dismissed"); - } - - // ── Keywords ── - - /** The keywords on the account. */ - public List keywords(GoogleAdsScope scope) { - return keywords(scope, null); - } - - /** The keywords on one ad group. */ - public List keywords(GoogleAdsScope scope, String adGroupId) { - Map query = scope.toQuery(); - if (adGroupId != null) { - query.put("ad_group_id", adGroupId); - } - return http.convertList( - ApiClient.unwrap(http.get("/v1/ads/google/keywords", query)), GoogleKeyword.class); - } - - /** Adds a keyword, which goes live. Needs {@code publish} as well as {@code ads}. */ - public String createKeyword(GoogleKeywordParams.Create params) { - return id(http.post("/v1/ads/google/keywords", params.toMap())); - } - - /** Pauses, resumes or rebids a keyword. Needs {@code publish}. */ - public String updateKeyword(String id, GoogleKeywordParams.Update params) { - return id(http.patch("/v1/ads/google/keywords/" + encode(id), params.toMap())); - } - - /** Removes a keyword. Needs {@code publish} as well as {@code ads}. */ - public void deleteKeyword(String id, GoogleAdsScope scope) { - http.request("DELETE", "/v1/ads/google/keywords/" + encode(id), scope.toMap(), Map.of()); - } - - /** Ideas from seed keywords, a landing page, or both. */ - public List keywordIdeas(GoogleKeywordIdeasParams params) { - return http.convertList( - ApiClient.unwrap(http.post("/v1/ads/google/keyword-ideas", params.toMap())), - GoogleKeywordIdea.class); - } - - /** Historical metrics for keywords you already have. */ - public List keywordMetrics(GoogleAdsScope scope, List keywords) { - Map body = scope.toMap(); - body.put("keywords", keywords); - return http.convertList( - ApiClient.unwrap(http.post("/v1/ads/google/keyword-metrics", body)), - GoogleKeywordIdea.class); - } - - /** What people actually searched, with the metrics each term earned. */ - public List searchTerms(GoogleAdsScope scope, String since, String until) { - Map query = scope.toQuery(); - query.put("since", since); - query.put("until", until); - return http.convertList( - ApiClient.unwrap(http.get("/v1/ads/google/search-terms", query)), - GoogleSearchTerm.class); - } - // ── Bid strategies and ad schedule ── /** The account's portfolio bid strategies. */ @@ -182,108 +70,6 @@ public int setAdSchedule(GoogleAdScheduleParams params) { .asInt(); } - // ── Negative keyword lists ── - - /** The account's negative keyword lists. */ - public List negativeKeywordLists(GoogleAdsScope scope) { - return http.convertList( - ApiClient.unwrap(http.get("/v1/ads/google/negative-keywords", scope.toQuery())), - GoogleSharedSet.class); - } - - /** Creates a negative keyword list. Needs {@code publish} as well as {@code ads}. */ - public String createNegativeKeywordList(GoogleAdsScope scope, String name) { - Map body = scope.toMap(); - body.put("name", name); - return id(http.post("/v1/ads/google/negative-keywords", body)); - } - - /** Adds keywords to a list; answers how many landed. Needs {@code publish}. */ - public int addNegativeKeywords(GoogleNegativeKeywordParams params) { - return ApiClient.unwrap(http.post("/v1/ads/google/negative-keywords/keywords", params.toMap())) - .path("added") - .asInt(); - } - - /** Puts a list on a campaign, which stops it matching those terms. Needs {@code publish}. */ - public void attachNegativeKeywordList( - GoogleAdsScope scope, String sharedSetId, String campaignId) { - Map body = scope.toMap(); - body.put("sharedSetId", sharedSetId); - body.put("campaignId", campaignId); - http.post("/v1/ads/google/negative-keywords/attach", body); - } - - // ── Assets ── - - /** Sitelinks, callouts and snippets, with the links that place each one. */ - public GoogleAssetsResult assets(GoogleAdsScope scope) { - return http.convert( - ApiClient.unwrap(http.get("/v1/ads/google/assets", scope.toQuery())), - GoogleAssetsResult.class); - } - - /** Adds an asset to the library. Needs {@code publish} as well as {@code ads}. */ - public String createAsset(GoogleAssetParams params) { - return id(http.post("/v1/ads/google/assets", params.toMap())); - } - - /** - * Puts an asset under the ads it belongs to, which changes what they render. Attaches to the - * account when {@code campaignId} is null. Needs {@code publish}. - */ - public void attachAsset( - GoogleAdsScope scope, String assetId, String fieldType, String campaignId) { - Map body = scope.toMap(); - body.put("assetId", assetId); - body.put("fieldType", fieldType); - if (campaignId != null) { - body.put("campaignId", campaignId); - } - http.post("/v1/ads/google/assets/attach", body); - } - - /** - * Removes the links that put an asset under an ad; on Google the asset itself is permanent. - * Needs {@code publish} as well as {@code ads}. - */ - public void deleteAsset(String id, GoogleAdsScope scope) { - http.request("DELETE", "/v1/ads/google/assets/" + encode(id), scope.toMap(), Map.of()); - } - - // ── Performance Max asset groups ── - - /** The account's Performance Max asset groups. */ - public List assetGroups(GoogleAdsScope scope) { - return assetGroups(scope, null); - } - - /** One campaign's Performance Max asset groups. */ - public List assetGroups(GoogleAdsScope scope, String campaignId) { - Map query = scope.toQuery(); - if (campaignId != null) { - query.put("campaign_id", campaignId); - } - return http.convertList( - ApiClient.unwrap(http.get("/v1/ads/google/asset-groups", query)), - GoogleAssetGroup.class); - } - - /** Creates an asset group. It starts paused unless the status says otherwise. Needs {@code publish}. */ - public String createAssetGroup(GoogleAssetGroupParams.Create params) { - return id(http.post("/v1/ads/google/asset-groups", params.toMap())); - } - - /** Renames, pauses or resumes an asset group. Needs {@code publish}. */ - public String updateAssetGroup(String id, GoogleAssetGroupParams.Update params) { - return id(http.patch("/v1/ads/google/asset-groups/" + encode(id), params.toMap())); - } - - /** Removes an asset group. Needs {@code publish} as well as {@code ads}. */ - public void deleteAssetGroup(String id, GoogleAdsScope scope) { - http.request("DELETE", "/v1/ads/google/asset-groups/" + encode(id), scope.toMap(), Map.of()); - } - // ── Local Services leads ── /** Leads from Local Services Ads, read live on every call and never stored by FoPost. */ @@ -339,17 +125,7 @@ public GoogleQueryResult query(GoogleAdsScope scope, String query) { ApiClient.unwrap(http.post("/v1/ads/insights/query", body)), GoogleQueryResult.class); } - private int counted(String path, GoogleAdsScope scope, List ids, String key) { - Map body = scope.toMap(); - body.put("ids", ids); - return ApiClient.unwrap(http.post(path, body)).path(key).asInt(); - } - private String id(com.fasterxml.jackson.databind.JsonNode response) { return ApiClient.unwrap(response).path("id").asText(); } - - private static String encode(String id) { - return URLEncoder.encode(id, StandardCharsets.UTF_8); - } } diff --git a/src/test/java/com/fopost/sdk/AdsTest.java b/src/test/java/com/fopost/sdk/AdsTest.java index 3269de4..4e049c1 100644 --- a/src/test/java/com/fopost/sdk/AdsTest.java +++ b/src/test/java/com/fopost/sdk/AdsTest.java @@ -5,9 +5,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import com.fopost.sdk.model.Ad; -import com.fopost.sdk.model.AdAccountTree; -import com.fopost.sdk.model.AdCampaign; -import com.fopost.sdk.model.AdCreative; import com.fopost.sdk.model.AdInsightsReport; import com.fopost.sdk.model.AudiencesResult; import com.fopost.sdk.model.BulkAdStatusResult; @@ -18,13 +15,10 @@ import com.fopost.sdk.param.AdTargetingParams; import com.fopost.sdk.param.BoostPostParams; import com.fopost.sdk.param.BulkAdStatusParams; -import com.fopost.sdk.param.CreateAdCampaignParams; -import com.fopost.sdk.param.CreateAdCreativeParams; import com.fopost.sdk.param.CreateAdParams; import com.fopost.sdk.param.CreateAudienceParams; import com.fopost.sdk.param.CreateLeadFormParams; import com.fopost.sdk.param.LeadsFeedParams; -import com.fopost.sdk.param.UpdateAdCampaignParams; import java.time.Instant; import java.util.List; import org.junit.jupiter.api.Test; @@ -141,58 +135,13 @@ void audiencesTargetingAndLeadsReadTheirQueriesAndBodies() { } @Test - void accountTreeNestsAdSetsAndAdsUnderCampaigns() { + void bulkSetStatusReportsEachObject() { FakeTransport transport = new FakeTransport() - .enqueue(200, """ - {"data":{"adAccountId":"act_123","currency":"USD","workspaceId":"w1", - "campaigns":[{"id":"cmp1","name":"Launch","status":"PAUSED","objective":"OUTCOME_TRAFFIC", - "budgetMinor":null,"budgetType":null, - "adSets":[{"id":"set1","name":"US","campaignId":"cmp1","status":"PAUSED", - "budgetMinor":2000,"budgetType":"daily", - "ads":[{"id":"ad9","name":"A","adSetId":"set1", - "creativeId":"cr1","status":"PAUSED"}]}]}]}}"""); - - AdAccountTree tree = TestSupport.client(transport).ads().accountTree("act_123", "c1", "w1"); - - assertEquals("GET", transport.last().method()); - assertEquals("https://api.fopost.test/v1/ads/accounts/act_123/tree?workspace_id=w1&connection_id=c1", - transport.last().url()); - assertNull(tree.campaigns().get(0).budgetMinor()); - assertEquals(2000L, tree.campaigns().get(0).adSets().get(0).budgetMinor()); - assertEquals("cr1", tree.campaigns().get(0).adSets().get(0).ads().get(0).creativeId()); - } - - @Test - void campaignWritesCarryTheConnectionAndDuplicateReturnsTheCopyId() { - FakeTransport transport = new FakeTransport() - .enqueue(201, "{\"data\":{\"id\":\"cmp1\",\"name\":\"Launch\",\"status\":\"PAUSED\"}}") - .enqueue(200, "{\"data\":{\"id\":\"cmp1\",\"name\":\"Launch\",\"status\":\"ACTIVE\"}}") - .enqueue(201, "{\"data\":{\"id\":\"cmp2\"}}") .enqueue(200, "{\"data\":[{\"id\":\"cmp1\",\"level\":\"campaign\",\"ok\":true,\"error\":null}," + "{\"id\":\"ad9\",\"level\":\"ad\",\"ok\":false,\"error\":\"Not found\"}]}"); FoPost client = TestSupport.client(transport); - AdCampaign created = client.ads().createCampaign( - CreateAdCampaignParams.of("w1", "c1", "act_123", "Launch", "traffic")); - assertEquals("https://api.fopost.test/v1/ads/campaigns", transport.last().url()); - assertEquals( - "{\"workspaceId\":\"w1\",\"connectionId\":\"c1\",\"adAccountId\":\"act_123\",\"name\":\"Launch\"," - + "\"goal\":\"traffic\"}", - transport.lastBody()); - assertEquals("PAUSED", created.status()); - - client.ads().updateCampaign("cmp1", "w1", "c1", UpdateAdCampaignParams.create().status("active")); - assertEquals("PATCH", transport.last().method()); - assertEquals("https://api.fopost.test/v1/ads/campaigns/cmp1?workspace_id=w1&connection_id=c1", - transport.last().url()); - assertEquals("{\"status\":\"active\"}", transport.lastBody()); - - assertEquals("cmp2", client.ads().duplicateCampaign("cmp1", "w1", "c1", false)); - assertEquals("https://api.fopost.test/v1/ads/campaigns/cmp1/duplicate?workspace_id=w1&connection_id=c1", - transport.last().url()); - assertEquals("{\"paused\":false}", transport.lastBody()); - List results = client.ads().bulkSetStatus( BulkAdStatusParams.of("w1", "c1", "paused").campaign("cmp1").ad("ad9")); assertEquals( @@ -257,30 +206,12 @@ void leadsFeedPassesTheCursorBack() { } @Test - void creativesAndAdUrlTagsTravelInTheBody() { + void adUrlTagsTravelInTheBody() { FakeTransport transport = new FakeTransport() - .enqueue(201, "{\"data\":{\"id\":\"cr1\",\"format\":\"carousel\",\"urlTags\":\"utm_source=meta\"}}") - .enqueue(200, "{\"data\":{\"creatives\":[{\"id\":\"cr1\",\"name\":\"Spring\"}],\"workspaceId\":\"w1\"}}") .enqueue(201, "{\"data\":{\"id\":\"ad1\",\"creative\":{\"text\":\"Hi\",\"urlTags\":\"utm_source=meta\"}}}"); FoPost client = TestSupport.client(transport); - AdCreative creative = client.ads().createCreative(CreateAdCreativeParams.of( - "w1", "c1", "act_123", "page1", "Spring", "carousel", "New season") - .urlTags("utm_source=meta") - .card("https://cdn.yourbrand.com/1.jpg") - .card("https://cdn.yourbrand.com/2.jpg", null, "Two", null)); - assertTrue(transport.lastBody().contains("\"urlTags\":\"utm_source=meta\"")); - assertTrue(transport.lastBody().contains( - "\"cards\":[{\"mediaUrl\":\"https://cdn.yourbrand.com/1.jpg\"}," - + "{\"mediaUrl\":\"https://cdn.yourbrand.com/2.jpg\",\"headline\":\"Two\"}]")); - assertEquals("utm_source=meta", creative.urlTags()); - - List creatives = client.ads().creatives("c1", "act_123"); - assertEquals("https://api.fopost.test/v1/ads/creatives?connection_id=c1&ad_account_id=act_123", - transport.last().url()); - assertEquals("Spring", creatives.get(0).name()); - Ad ad = client.ads().create(CreateAdParams.of( "w1", "c1", "act_123", "page1", "Spring", "traffic", AdBudgetParams.daily(1000), AdTargetingParams.create(List.of("US"), 18, 65, "all"), "Hi") diff --git a/src/test/java/com/fopost/sdk/AdsTikTokTest.java b/src/test/java/com/fopost/sdk/AdsTikTokTest.java index d525bd7..0a570db 100644 --- a/src/test/java/com/fopost/sdk/AdsTikTokTest.java +++ b/src/test/java/com/fopost/sdk/AdsTikTokTest.java @@ -9,7 +9,6 @@ import com.fopost.sdk.model.SparkPost; import com.fopost.sdk.param.AdBudgetParams; import com.fopost.sdk.param.AdTargetingParams; -import com.fopost.sdk.param.CreateAdCampaignParams; import com.fopost.sdk.param.CreateAdParams; import com.fopost.sdk.param.UploadConversionsParams; import java.util.List; @@ -41,11 +40,10 @@ void identitiesAndSparkPostsReadTheRightPaths() { } @Test - void sparkPostIdAndSmartPlusTravelInTheBody() { + void sparkPostIdTravelsInTheBody() { FakeTransport transport = new FakeTransport() .enqueue(201, "{\"data\":{\"id\":\"ad1\",\"workspaceId\":\"w1\",\"kind\":\"ad\",\"name\":\"Spark\"," - + "\"goal\":\"traffic\",\"status\":\"paused\"}}") - .enqueue(201, "{\"data\":{\"id\":\"c1\",\"name\":\"Smart\",\"status\":\"PAUSED\"}}"); + + "\"goal\":\"traffic\",\"status\":\"paused\"}}"); FoPost client = TestSupport.client(transport); @@ -62,11 +60,6 @@ void sparkPostIdAndSmartPlusTravelInTheBody() { "") .sparkPostId("item_99")); assertTrue(transport.lastBody().contains("\"sparkPostId\":\"item_99\"")); - - client.ads() - .createCampaign(CreateAdCampaignParams.of("w1", "c1", "7011", "Smart", "traffic") - .smartPlus(true)); - assertTrue(transport.lastBody().contains("\"smartPlus\":true")); } @Test diff --git a/src/test/java/com/fopost/sdk/GoogleAdsTest.java b/src/test/java/com/fopost/sdk/GoogleAdsTest.java index b81c98e..359d9d8 100644 --- a/src/test/java/com/fopost/sdk/GoogleAdsTest.java +++ b/src/test/java/com/fopost/sdk/GoogleAdsTest.java @@ -1,15 +1,12 @@ package com.fopost.sdk; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import com.fopost.sdk.model.GoogleKeyword; -import com.fopost.sdk.model.GoogleOptimizationScore; +import com.fopost.sdk.model.GoogleBidStrategy; import com.fopost.sdk.model.GoogleQueryResult; -import com.fopost.sdk.model.GoogleRecommendation; import com.fopost.sdk.param.GoogleAdsScope; -import com.fopost.sdk.param.GoogleKeywordParams; +import com.fopost.sdk.param.GoogleBidStrategyParams; import java.util.List; import org.junit.jupiter.api.Test; @@ -18,109 +15,40 @@ class GoogleAdsTest { private static final GoogleAdsScope SCOPE = GoogleAdsScope.of("c1", "1234567890"); @Test - void keywordsNameTheConnectionAndTheCustomer() { + void bidStrategiesNameTheConnectionAndTheCustomer() { FakeTransport transport = new FakeTransport() .enqueue(200, """ - {"data":[{"id":"1234567890~keyword~77~99","adGroupId":"1234567890~adGroup~77", - "text":"running shoes","matchType":"EXACT","status":"ENABLED", - "cpcBidMinor":180,"negative":false}]}"""); + {"data":[{"id":"1234567890~biddingStrategy~7","name":"Portfolio CPA", + "type":"TARGET_CPA","status":"ENABLED","campaignCount":2}]}"""); - List keywords = TestSupport.client(transport) - .googleAds() - .keywords(SCOPE, "1234567890~adGroup~77"); + List strategies = TestSupport.client(transport).googleAds().bidStrategies(SCOPE); - assertEquals("running shoes", keywords.get(0).text()); - assertEquals(180L, keywords.get(0).cpcBidMinor()); + assertEquals("Portfolio CPA", strategies.get(0).name()); + assertEquals(2, strategies.get(0).campaignCount()); String url = transport.last().url(); assertTrue(url.contains("connection_id=c1"), url); assertTrue(url.contains("customer_id=1234567890"), url); - assertTrue(url.contains("ad_group_id=1234567890%7EadGroup%7E77"), url); } @Test - void createKeywordSendsTheScopeInACamelCaseBody() { + void createBidStrategySendsTheScopeInACamelCaseBody() { FakeTransport transport = new FakeTransport().enqueue(201, """ - {"data":{"id":"1234567890~keyword~77~99"}}"""); + {"data":{"id":"1234567890~biddingStrategy~7"}}"""); String id = TestSupport.client(transport) .googleAds() - .createKeyword(new GoogleKeywordParams.Create( - GoogleAdsScope.of("c1", "1234567890").workspace("w1"), - "1234567890~adGroup~77", - "running shoes", - "EXACT") - .cpcBidMinor(180)); - - assertEquals("1234567890~keyword~77~99", id); - assertEquals("https://api.fopost.test/v1/ads/google/keywords", transport.last().url()); + .createBidStrategy(new GoogleBidStrategyParams( + GoogleAdsScope.of("c1", "1234567890").workspace("w1"), "Portfolio CPA", "TARGET_CPA") + .targetMinor(500)); + + assertEquals("1234567890~biddingStrategy~7", id); + assertEquals("https://api.fopost.test/v1/ads/google/bid-strategies", transport.last().url()); assertEquals( "{\"workspaceId\":\"w1\",\"connectionId\":\"c1\",\"customerId\":\"1234567890\"," - + "\"adGroupId\":\"1234567890~adGroup~77\",\"text\":\"running shoes\"," - + "\"matchType\":\"EXACT\",\"cpcBidMinor\":180}", + + "\"name\":\"Portfolio CPA\",\"type\":\"TARGET_CPA\",\"targetMinor\":500}", transport.lastBody()); } - @Test - void recommendationsJoinTheTypesFilter() { - FakeTransport transport = new FakeTransport() - .enqueue(200, """ - {"data":[{"id":"customers/1234567890/recommendations/ABC~1","type":"KEYWORD", - "campaignId":"1234567890~campaign~55","adGroupId":null, - "dismissed":false, - "impact":{"baseClicks":10,"potentialClicks":25, - "baseCostMinor":100,"potentialCostMinor":250, - "baseConversions":1,"potentialConversions":3}}]}"""); - - List rows = TestSupport.client(transport) - .googleAds() - .recommendations(SCOPE, List.of("KEYWORD", "TARGET_CPA_OPT_IN")); - - assertEquals("KEYWORD", rows.get(0).type()); - assertEquals(25.0, rows.get(0).impact().potentialClicks()); - assertFalse(rows.get(0).dismissed()); - assertTrue(transport.last().url().contains("types=KEYWORD%2CTARGET_CPA_OPT_IN")); - } - - @Test - void recommendationsOmitTheTypesFilterWhenNoneAreGiven() { - FakeTransport transport = new FakeTransport().enqueue(200, "{\"data\":[]}"); - - TestSupport.client(transport).googleAds().recommendations(SCOPE); - - assertFalse(transport.last().url().contains("types="), transport.last().url()); - } - - @Test - void applyRecommendationsSendsTheIdsAndCountsWhatLanded() { - FakeTransport transport = new FakeTransport().enqueue(200, "{\"data\":{\"applied\":1}}"); - - int applied = TestSupport.client(transport) - .googleAds() - .applyRecommendations( - GoogleAdsScope.of("c1", "1234567890").workspace("w1"), - List.of("customers/1234567890/recommendations/ABC~1")); - - assertEquals(1, applied); - assertEquals( - "https://api.fopost.test/v1/ads/google/recommendations/apply", - transport.last().url()); - assertTrue(transport.lastBody().contains("customers/1234567890/recommendations/ABC~1")); - } - - @Test - void optimizationScoreReadsTheAccountAndItsCampaigns() { - FakeTransport transport = new FakeTransport() - .enqueue(200, """ - {"data":{"score":0.82,"weight":1.0, - "campaigns":[{"id":"1234567890~campaign~55","name":"Search","score":0.75}]}}"""); - - GoogleOptimizationScore score = - TestSupport.client(transport).googleAds().optimizationScore(SCOPE); - - assertEquals(0.82, score.score()); - assertEquals("Search", score.campaigns().get(0).name()); - } - @Test void queryReturnsRowsAsGoogleSendsThem() { FakeTransport transport = new FakeTransport()