Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

✨ Add ad write operations: create, update, delete (Closes #35)#36

Merged
SamPetherbridge merged 1 commit into
main from
feat/ad-write-operations
Jun 9, 2026
Merged

✨ Add ad write operations: create, update, delete (Closes #35) #36
SamPetherbridge merged 1 commit into
main from
feat/ad-write-operations

Conversation

@SamPetherbridge

@SamPetherbridge SamPetherbridge commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #35 — extends the ads group from read-only (added in #32) to full management. The library already supported ad CRUD via base create/update/delete; this wires it into the CLI with the validation and safety the issue called for.

New commands

  • asa ads create -c <campaign> -a <ad-group> -n <name> [-t <creative-type>] [-p <product-page>] [-s <status>] [--dry-run] [-y]
  • asa ads update <ad-id> -c <campaign> -a <ad-group> [--name ...] [--status ...]
  • asa ads delete <ad-id> -c <campaign> -a <ad-group> [-y]

Design decisions (from #35)

  • Creative-type ↔ product-page validation, client-side, before any API call:
    • CUSTOM_PRODUCT_PAGE requires --product-page
    • DEFAULT_PRODUCT_PAGE rejects --product-page
    • CREATIVE_SET is rejected outright — the AdCreate model exposes no way to attach creative-set assets, so it can't be created through this command (documented in the error).
  • Safety: delete confirms (default No) with --yes to skip; create confirms (default Yes) and supports --dry-run to preview the payload.
  • Discoverability: --product-page ids come from asa product-pages list (cross-referenced in help/errors).

Verification

Because validation and --dry-run run before get_client()/network, the decision logic is testable offline — and is tested:

  • ruff check / ruff format --check
  • mypy --strict (19 files; AdCreate/AdUpdate usage checked against real models)
  • pytest — 16 passed, including 5 new behavioral tests:
    • CREATIVE_SET rejected
    • CUSTOM_PRODUCT_PAGE without --product-page rejected
    • DEFAULT_PRODUCT_PAGE with --product-page rejected
    • valid --dry-run previews payload and exits 0 (no API call)
    • empty update (no --name/--status) rejected

Limitation (honest scope)

Live create/update/delete can't be exercised here (no credentials, and writing real ads would be inappropriate) — same constraint as every other command. What's verified is types, validation, payload construction, and the dry-run path. The first real run against an account is the remaining confidence step, and --dry-run plus the delete confirmation are there to make that safe.

Extend the ads group from read-only to full management:
- asa ads create — create an ad (CUSTOM_PRODUCT_PAGE or DEFAULT_PRODUCT_PAGE)
- asa ads update — change an ad's name and/or status
- asa ads delete — delete an ad (confirmation, --yes to skip)
Creative-type/product-page coupling is validated client-side before any
API call: CUSTOM_PRODUCT_PAGE requires --product-page, DEFAULT_PRODUCT_PAGE
rejects it, and CREATIVE_SET is rejected (asset selection unsupported by
the AdCreate model). create supports --dry-run to preview the payload.
Closes #35.
@SamPetherbridge SamPetherbridge added the enhancement New feature or request label Jun 9, 2026
@SamPetherbridge SamPetherbridge merged commit d6b5643 into main Jun 9, 2026
1 check passed
@SamPetherbridge SamPetherbridge deleted the feat/ad-write-operations branch June 9, 2026 04:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

enhancement New feature or request

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

✨ Add ad/creative write operations (create, update, delete ads)

1 participant

AltStyle によって変換されたページ (->オリジナル) /