adloop 0.38.0__tar.gz → 0.38.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {adloop-0.38.0 → adloop-0.38.2}/PKG-INFO +1 -1
- {adloop-0.38.0 → adloop-0.38.2}/pyproject.toml +1 -1
- {adloop-0.38.0 → adloop-0.38.2}/pyproject.toml.orig +1 -1
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/ads/assets.py +51 -2
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/ads/pmax.py +4 -3
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/ads/read.py +39 -18
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/ads/write.py +12 -1
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/rules/adloop.md +1 -1
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/server.py +3 -1
- {adloop-0.38.0 → adloop-0.38.2}/README.md +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/__init__.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/__main__.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/_mcp_patches.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/ads/__init__.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/ads/ai_max.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/ads/audiences.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/ads/brands.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/ads/campaign_settings.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/ads/client.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/ads/conversion_actions.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/ads/currency.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/ads/custom_conversion_goals.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/ads/enums.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/ads/forecast.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/ads/gaql.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/ads/image_fetch.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/ads/recommendation_subscriptions.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/ads/recommendations.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/ads/shopping.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/ads/snippet_headers.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/ads/validate_only.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/auth.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/cli.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/config.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/crossref.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/diagnostics.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/ga4/__init__.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/ga4/client.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/ga4/reports.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/ga4/tracking.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/ga4/write.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/gsc/__init__.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/gsc/client.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/gsc/reports.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/gtm/__init__.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/gtm/client.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/gtm/entities.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/gtm/read.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/gtm/write.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/merchant/__init__.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/merchant/client.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/merchant/read.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/pagespeed.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/reddit/__init__.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/reddit/auth.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/reddit/client.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/reddit/read.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/reddit/schedule.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/reddit/write.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/rules/__init__.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/rules/commands/analyze-performance.md +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/rules/commands/budget-plan.md +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/rules/commands/create-ad.md +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/rules/commands/create-campaign.md +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/rules/commands/diagnose-tracking.md +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/rules/commands/optimize-campaign.md +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/rules_install.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/runtime.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/safety/__init__.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/safety/approval.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/safety/approval_card.html +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/safety/audit.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/safety/guards.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/safety/preview.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/tracking.py +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/upload_card.html +0 -0
- {adloop-0.38.0 → adloop-0.38.2}/src/adloop/uploads.py +0 -0
|
@@ -320,6 +320,35 @@ def draft_business_name_asset(
|
|
|
320
320
|
return preview
|
|
321
321
|
|
|
322
322
|
|
|
323
|
+
def _account_logo_refusal(config: AdLoopConfig, customer_id: str, new_logos: int) -> str:
|
|
324
|
+
"""Why the account cannot take ``new_logos`` more business logos, or "".
|
|
325
|
+
|
|
326
|
+
Google allows one enabled account-level business logo and answers a
|
|
327
|
+
second only at the dry run, with RESOURCE_LIMIT
|
|
328
|
+
(ENABLED_FAVICON_ASSET_LINKS_PER_CUSTOMER). Say it at the draft instead,
|
|
329
|
+
with the link to remove.
|
|
330
|
+
"""
|
|
331
|
+
from adloop.ads.gaql import execute_query
|
|
332
|
+
|
|
333
|
+
if not new_logos:
|
|
334
|
+
return ""
|
|
335
|
+
if new_logos > 1:
|
|
336
|
+
return f"Google allows one business logo per account; this draft links {new_logos}."
|
|
337
|
+
rows = execute_query(config, customer_id, (
|
|
338
|
+
"SELECT asset.id, asset.name FROM customer_asset "
|
|
339
|
+
"WHERE customer_asset.field_type = 'BUSINESS_LOGO' AND customer_asset.status = 'ENABLED'"))
|
|
340
|
+
if not rows:
|
|
341
|
+
return ""
|
|
342
|
+
asset_id = rows[0].get("asset.id")
|
|
343
|
+
name = rows[0].get("asset.name")
|
|
344
|
+
current = f"asset {asset_id} '{name}'" if name else f"asset {asset_id}"
|
|
345
|
+
return (
|
|
346
|
+
f"The account already has a business logo ({current}), and Google allows one per "
|
|
347
|
+
"account. To replace it, remove its account link first with remove_entity("
|
|
348
|
+
f'entity_type="customer_asset", entity_id="{asset_id}~BUSINESS_LOGO"), then draft again.'
|
|
349
|
+
)
|
|
350
|
+
|
|
351
|
+
|
|
323
352
|
def link_asset_to_customer(
|
|
324
353
|
config: AdLoopConfig,
|
|
325
354
|
*,
|
|
@@ -376,6 +405,12 @@ def link_asset_to_customer(
|
|
|
376
405
|
)
|
|
377
406
|
elif row.get("asset.name"):
|
|
378
407
|
link["asset_name"] = row["asset.name"]
|
|
408
|
+
if not errors:
|
|
409
|
+
refusal = _account_logo_refusal(
|
|
410
|
+
config, customer_id, sum(link["field_type"] == "BUSINESS_LOGO" for link in validated)
|
|
411
|
+
)
|
|
412
|
+
if refusal:
|
|
413
|
+
errors.append(refusal)
|
|
379
414
|
if errors:
|
|
380
415
|
return {"error": "Validation failed", "details": errors}
|
|
381
416
|
|
|
@@ -1636,22 +1671,36 @@ def _apply_update_promotion(client, cid: str, changes: dict) -> dict:
|
|
|
1636
1671
|
if "final_url" in changed:
|
|
1637
1672
|
asset.final_urls.append(promo["final_url"])
|
|
1638
1673
|
paths.append("final_urls")
|
|
1674
|
+
# Google refuses a mask that names a message field it is given a value
|
|
1675
|
+
# for (FIELD_HAS_SUBFIELDS): a Money that is set is masked by its
|
|
1676
|
+
# leaves. An unset field may still be masked whole, which clears it,
|
|
1677
|
+
# and the replaced member of a oneof (discount, trigger) has to be
|
|
1678
|
+
# cleared that way: Google does not drop it on its own
|
|
1679
|
+
# (PROMOTION_CANNOT_SET_PERCENT_OFF_AND_MONEY_AMOUNT_OFF).
|
|
1639
1680
|
if changed.keys() & {"money_off", "percent_off", "currency_code"}:
|
|
1640
1681
|
if promo["percent_off"]:
|
|
1641
1682
|
p.percent_off = round(float(promo["percent_off"]) * 10_000)
|
|
1642
1683
|
paths.append("promotion_asset.percent_off")
|
|
1684
|
+
if before.get("money_off"):
|
|
1685
|
+
paths.append("promotion_asset.money_amount_off")
|
|
1643
1686
|
else:
|
|
1644
1687
|
p.money_amount_off.amount_micros = _micros(promo["money_off"])
|
|
1645
1688
|
p.money_amount_off.currency_code = promo["currency_code"]
|
|
1646
|
-
paths
|
|
1689
|
+
paths += [f"promotion_asset.money_amount_off.{f}" for f in ("amount_micros", "currency_code")]
|
|
1690
|
+
if before.get("percent_off"):
|
|
1691
|
+
paths.append("promotion_asset.percent_off")
|
|
1647
1692
|
if changed.keys() & {"promotion_code", "orders_over_amount", "currency_code"}:
|
|
1648
1693
|
if promo["promotion_code"]:
|
|
1649
1694
|
p.promotion_code = promo["promotion_code"]
|
|
1650
1695
|
paths.append("promotion_asset.promotion_code")
|
|
1696
|
+
if before.get("orders_over_amount"):
|
|
1697
|
+
paths.append("promotion_asset.orders_over_amount")
|
|
1651
1698
|
elif promo["orders_over_amount"]:
|
|
1652
1699
|
p.orders_over_amount.amount_micros = _micros(promo["orders_over_amount"])
|
|
1653
1700
|
p.orders_over_amount.currency_code = promo["currency_code"]
|
|
1654
|
-
paths
|
|
1701
|
+
paths += [f"promotion_asset.orders_over_amount.{f}" for f in ("amount_micros", "currency_code")]
|
|
1702
|
+
if before.get("promotion_code"):
|
|
1703
|
+
paths.append("promotion_asset.promotion_code")
|
|
1655
1704
|
else: # cleared: the masked, unset field is removed
|
|
1656
1705
|
paths += [f"promotion_asset.{f}" for f in ("promotion_code", "orders_over_amount") if before.get(f)]
|
|
1657
1706
|
for field, enum in (("occasion", "PromotionExtensionOccasionEnum"),
|
|
@@ -17,7 +17,7 @@ from __future__ import annotations
|
|
|
17
17
|
from typing import TYPE_CHECKING, Any
|
|
18
18
|
|
|
19
19
|
from adloop.ads.currency import get_currency_code
|
|
20
|
-
from adloop.ads.read import _date_clause, _enrich_cost_fields
|
|
20
|
+
from adloop.ads.read import _date_clause, _drop_idle_removed, _enrich_cost_fields
|
|
21
21
|
|
|
22
22
|
if TYPE_CHECKING:
|
|
23
23
|
from adloop.config import AdLoopConfig
|
|
@@ -750,12 +750,13 @@ def get_pmax_performance(
|
|
|
750
750
|
segments.ad_network_type
|
|
751
751
|
FROM campaign
|
|
752
752
|
WHERE campaign.advertising_channel_type = 'PERFORMANCE_MAX'
|
|
753
|
-
AND campaign.status != 'REMOVED'
|
|
754
753
|
{date_clause}
|
|
755
754
|
ORDER BY metrics.cost_micros DESC
|
|
756
755
|
"""
|
|
757
756
|
|
|
758
|
-
campaigns =
|
|
757
|
+
campaigns = _drop_idle_removed(
|
|
758
|
+
execute_query(config, customer_id, campaign_query), "campaign.status"
|
|
759
|
+
)
|
|
759
760
|
currency_code = get_currency_code(config, customer_id)
|
|
760
761
|
_enrich_cost_fields(campaigns, currency_code)
|
|
761
762
|
|
|
@@ -71,6 +71,7 @@ def get_campaign_performance(
|
|
|
71
71
|
from adloop.ads.gaql import execute_query
|
|
72
72
|
|
|
73
73
|
date_clause = _date_clause(date_range_start, date_range_end)
|
|
74
|
+
where = date_clause.removeprefix("AND ")
|
|
74
75
|
|
|
75
76
|
query = f"""
|
|
76
77
|
SELECT campaign.id, campaign.name, campaign.status,
|
|
@@ -79,12 +80,13 @@ def get_campaign_performance(
|
|
|
79
80
|
metrics.conversions, metrics.conversions_value,
|
|
80
81
|
metrics.ctr, metrics.average_cpc
|
|
81
82
|
FROM campaign
|
|
82
|
-
WHERE
|
|
83
|
-
{date_clause}
|
|
83
|
+
WHERE {where}
|
|
84
84
|
ORDER BY metrics.cost_micros DESC
|
|
85
85
|
"""
|
|
86
86
|
|
|
87
|
-
rows =
|
|
87
|
+
rows = _drop_idle_removed(
|
|
88
|
+
execute_query(config, customer_id, query), "campaign.status"
|
|
89
|
+
)
|
|
88
90
|
currency_code = get_currency_code(config, customer_id)
|
|
89
91
|
_enrich_cost_fields(rows, currency_code)
|
|
90
92
|
share_error = _attach_impression_share(config, customer_id, rows, date_clause)
|
|
@@ -199,8 +201,7 @@ def _attach_impression_share(
|
|
|
199
201
|
SELECT campaign.id, metrics.impressions,
|
|
200
202
|
{", ".join(_IMPRESSION_SHARE_FIELDS)}
|
|
201
203
|
FROM campaign
|
|
202
|
-
WHERE campaign.
|
|
203
|
-
AND campaign.advertising_channel_type IN ({channels})
|
|
204
|
+
WHERE campaign.advertising_channel_type IN ({channels})
|
|
204
205
|
{date_clause}
|
|
205
206
|
"""
|
|
206
207
|
|
|
@@ -273,7 +274,7 @@ def get_ad_performance(
|
|
|
273
274
|
"""Get ad-level performance data including headlines, descriptions, and metrics."""
|
|
274
275
|
from adloop.ads.gaql import execute_query
|
|
275
276
|
|
|
276
|
-
|
|
277
|
+
where = _date_clause(date_range_start, date_range_end).removeprefix("AND ")
|
|
277
278
|
|
|
278
279
|
query = f"""
|
|
279
280
|
SELECT campaign.name, campaign.id, ad_group.name, ad_group.id,
|
|
@@ -288,12 +289,13 @@ def get_ad_performance(
|
|
|
288
289
|
metrics.impressions, metrics.clicks, metrics.ctr,
|
|
289
290
|
metrics.conversions, metrics.cost_micros
|
|
290
291
|
FROM ad_group_ad
|
|
291
|
-
WHERE
|
|
292
|
-
{date_clause}
|
|
292
|
+
WHERE {where}
|
|
293
293
|
ORDER BY metrics.cost_micros DESC
|
|
294
294
|
"""
|
|
295
295
|
|
|
296
|
-
rows =
|
|
296
|
+
rows = _drop_idle_removed(
|
|
297
|
+
execute_query(config, customer_id, query), "ad_group_ad.status"
|
|
298
|
+
)
|
|
297
299
|
currency_code = get_currency_code(config, customer_id)
|
|
298
300
|
_enrich_cost_fields(rows, currency_code)
|
|
299
301
|
for r in rows:
|
|
@@ -467,10 +469,11 @@ def get_keyword_performance(
|
|
|
467
469
|
"""Get keyword metrics including quality scores and competitive data."""
|
|
468
470
|
from adloop.ads.gaql import execute_query
|
|
469
471
|
|
|
470
|
-
|
|
472
|
+
where = _date_clause(date_range_start, date_range_end).removeprefix("AND ")
|
|
471
473
|
|
|
472
474
|
query = f"""
|
|
473
475
|
SELECT campaign.name, ad_group.name,
|
|
476
|
+
ad_group_criterion.status,
|
|
474
477
|
ad_group_criterion.keyword.text,
|
|
475
478
|
ad_group_criterion.keyword.match_type,
|
|
476
479
|
ad_group_criterion.quality_info.quality_score,
|
|
@@ -478,12 +481,13 @@ def get_keyword_performance(
|
|
|
478
481
|
metrics.average_cpc, metrics.cost_micros,
|
|
479
482
|
metrics.conversions
|
|
480
483
|
FROM keyword_view
|
|
481
|
-
WHERE
|
|
482
|
-
{date_clause}
|
|
484
|
+
WHERE {where}
|
|
483
485
|
ORDER BY metrics.cost_micros DESC
|
|
484
486
|
"""
|
|
485
487
|
|
|
486
|
-
rows =
|
|
488
|
+
rows = _drop_idle_removed(
|
|
489
|
+
execute_query(config, customer_id, query), "ad_group_criterion.status"
|
|
490
|
+
)
|
|
487
491
|
currency_code = get_currency_code(config, customer_id)
|
|
488
492
|
_enrich_cost_fields(rows, currency_code)
|
|
489
493
|
|
|
@@ -940,14 +944,14 @@ def get_audience_performance(
|
|
|
940
944
|
"""Get audience segment performance metrics (remarketing, in-market, affinity, demographics)."""
|
|
941
945
|
from adloop.ads.gaql import execute_query
|
|
942
946
|
|
|
943
|
-
|
|
947
|
+
where = _date_clause(date_range_start, date_range_end).removeprefix("AND ")
|
|
944
948
|
|
|
945
949
|
campaign_filter = ""
|
|
946
950
|
if campaign_id:
|
|
947
951
|
campaign_filter = f"AND campaign.id = {campaign_id}"
|
|
948
952
|
|
|
949
953
|
query = f"""
|
|
950
|
-
SELECT campaign.id, campaign.name,
|
|
954
|
+
SELECT campaign.id, campaign.name, campaign.status,
|
|
951
955
|
campaign.advertising_channel_type,
|
|
952
956
|
ad_group.id, ad_group.name,
|
|
953
957
|
ad_group_criterion.display_name,
|
|
@@ -955,14 +959,15 @@ def get_audience_performance(
|
|
|
955
959
|
metrics.impressions, metrics.clicks, metrics.cost_micros,
|
|
956
960
|
metrics.conversions, metrics.ctr, metrics.average_cpc
|
|
957
961
|
FROM ad_group_audience_view
|
|
958
|
-
WHERE
|
|
959
|
-
{date_clause}
|
|
962
|
+
WHERE {where}
|
|
960
963
|
{campaign_filter}
|
|
961
964
|
ORDER BY metrics.cost_micros DESC
|
|
962
965
|
LIMIT 200
|
|
963
966
|
"""
|
|
964
967
|
|
|
965
|
-
rows =
|
|
968
|
+
rows = _drop_idle_removed(
|
|
969
|
+
execute_query(config, customer_id, query), "campaign.status"
|
|
970
|
+
)
|
|
966
971
|
currency_code = get_currency_code(config, customer_id)
|
|
967
972
|
_enrich_cost_fields(rows, currency_code)
|
|
968
973
|
|
|
@@ -1360,6 +1365,22 @@ def _improvement(base: float, potential: float) -> float | None:
|
|
|
1360
1365
|
return round(potential - base, 4)
|
|
1361
1366
|
|
|
1362
1367
|
|
|
1368
|
+
def _drop_idle_removed(rows: list[dict], status_field: str) -> list[dict]:
|
|
1369
|
+
"""Drop REMOVED rows that had no impressions in the period.
|
|
1370
|
+
|
|
1371
|
+
Date-ranged reports cannot filter on status in GAQL: status is today's,
|
|
1372
|
+
metrics are the period's, so a status predicate hides spend from anything
|
|
1373
|
+
removed since. GAQL has no OR, and ``metrics.impressions > 0`` alone would
|
|
1374
|
+
also hide enabled entities with no impressions, which people look for.
|
|
1375
|
+
Rows without a status field are kept.
|
|
1376
|
+
"""
|
|
1377
|
+
return [
|
|
1378
|
+
r for r in rows
|
|
1379
|
+
if str(r.get(status_field)) != "REMOVED"
|
|
1380
|
+
or (r.get("metrics.impressions") or 0) > 0
|
|
1381
|
+
]
|
|
1382
|
+
|
|
1383
|
+
|
|
1363
1384
|
def _date_clause(start: str, end: str) -> str:
|
|
1364
1385
|
"""Build a GAQL date WHERE fragment."""
|
|
1365
1386
|
if start and end:
|
|
@@ -2605,7 +2605,12 @@ def draft_image_assets(
|
|
|
2605
2605
|
explicit (``scope="account"``) and takes BUSINESS_LOGO only, named in
|
|
2606
2606
|
``field_types``: one entry per image, in the order uploads, paths, URLs.
|
|
2607
2607
|
"""
|
|
2608
|
-
from adloop.ads.assets import
|
|
2608
|
+
from adloop.ads.assets import (
|
|
2609
|
+
_account_logo_refusal,
|
|
2610
|
+
_account_scope_warning,
|
|
2611
|
+
resolve_scope,
|
|
2612
|
+
scope_entity,
|
|
2613
|
+
)
|
|
2609
2614
|
from adloop.runtime import deployment_mode
|
|
2610
2615
|
from adloop.safety.guards import SafetyViolation, check_blocked_operation
|
|
2611
2616
|
from adloop.safety.preview import ChangePlan, store_plan
|
|
@@ -2634,6 +2639,12 @@ def draft_image_assets(
|
|
|
2634
2639
|
errors.extend(image_errors)
|
|
2635
2640
|
if not errors:
|
|
2636
2641
|
errors.extend(_assign_image_field_types(validated_images, scope, field_types))
|
|
2642
|
+
if not errors and scope == "account":
|
|
2643
|
+
refusal = _account_logo_refusal(
|
|
2644
|
+
config, customer_id, sum(image["field_type"] == "BUSINESS_LOGO" for image in validated_images)
|
|
2645
|
+
)
|
|
2646
|
+
if refusal:
|
|
2647
|
+
errors.append(refusal)
|
|
2637
2648
|
if errors:
|
|
2638
2649
|
return {"error": "Validation failed", "details": errors}
|
|
2639
2650
|
|
|
@@ -299,7 +299,7 @@ Conversions that happen offline (a sales call, a lead that turned into a deal) g
|
|
|
299
299
|
| `draft_promotion` | Create a promotion asset ("20% off winter tyres") for an ad group, a campaign or the account | `promotion_target` (≤20), `final_url`, `language_code` (REQUIRED), `money_off` or `percent_off`; optional `promotion_code` (≤15) or `orders_over_amount`, `occasion`, `discount_modifier` UP_TO, dates, `ad_schedule` (hours it shows); amounts in the account currency unless `currency_code` |
|
|
300
300
|
| `update_promotion` | Edit a promotion IN PLACE; fields not passed stay | `asset_id` plus the fields to change; `money_off`/`percent_off` and `promotion_code`/`orders_over_amount` replace each other; `ad_schedule` replaces its schedule; `clear_fields` removes optional ones (incl. `ad_schedule`) |
|
|
301
301
|
| `draft_price_asset` | Create a price asset (3-8 offerings) for an ad group, a campaign or the account | `offerings` [{header ≤25, description ≤25, price, final_url, unit}], `price_type`, `language_code` (both REQUIRED); `price_qualifier` FROM/UP_TO/AVERAGE optional; account currency unless `currency_code` |
|
|
302
|
-
| `draft_image_assets` | Create image assets for a campaign from local files, public image URLs or uploads (does NOT publish); a business logo can also go on the account | `campaign_id` or `scope="account"`, `field_types` (one per image: AD_IMAGE, the campaign default, or BUSINESS_LOGO; account level takes BUSINESS_LOGO only), `image_paths` (local PNG/JPEG/GIF files; not on a hosted server), `image_urls` (public http(s) image links, ≤5120 KB; re-checked at apply — if the image changed since the preview, draft again) and/or `upload_ids` (`up_...` from `upload_images` / `list_uploads`) |
|
|
302
|
+
| `draft_image_assets` | Create image assets for a campaign from local files, public image URLs or uploads (does NOT publish); a business logo can also go on the account | `campaign_id` or `scope="account"`, `field_types` (one per image: AD_IMAGE, the campaign default, or BUSINESS_LOGO; account level takes BUSINESS_LOGO only, one per account: to replace it, remove the current link with `remove_entity` first; the draft names it), `image_paths` (local PNG/JPEG/GIF files; not on a hosted server), `image_urls` (public http(s) image links, ≤5120 KB; re-checked at apply — if the image changed since the preview, draft again) and/or `upload_ids` (`up_...` from `upload_images` / `list_uploads`) |
|
|
303
303
|
| `draft_sitelinks` | Create sitelink extensions for a campaign or the account (does NOT publish) | `campaign_id` or `scope="account"`, `sitelinks` list of {link_text ≤25 chars, final_url, description1 ≤35 chars, description2 ≤35 chars} |
|
|
304
304
|
| `draft_keywords` | Propose keyword additions (does NOT add) | Each keyword needs `text` and `match_type` (EXACT/PHRASE/BROAD) |
|
|
305
305
|
| `add_negative_keywords` | Propose negative keywords directly on a campaign (does NOT add) | `campaign_id`, keyword list, `match_type` |
|
|
@@ -5055,7 +5055,9 @@ def draft_image_assets(
|
|
|
5055
5055
|
no public URL.
|
|
5056
5056
|
scope: Empty follows campaign_id. "account" links the images
|
|
5057
5057
|
account-wide, which Google allows for BUSINESS_LOGO only and which
|
|
5058
|
-
is never inferred from an empty campaign_id.
|
|
5058
|
+
is never inferred from an empty campaign_id. An account takes one
|
|
5059
|
+
business logo: while one is linked, the draft is refused and
|
|
5060
|
+
names the link to remove first.
|
|
5059
5061
|
field_types: One per image, in the order upload_ids, image_paths,
|
|
5060
5062
|
image_urls: AD_IMAGE (campaign links; the default) or BUSINESS_LOGO
|
|
5061
5063
|
(campaign or account links). Required with scope="account".
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|