[GH-ISSUE #470] Parity: IAP offer code generation endpoints (custom codes + one-time use batches) #135

Closed
opened 2026-02-26 21:33:41 +03:00 by kerem · 3 comments
Owner

Originally created by @rudrankriyam on GitHub (Feb 10, 2026).
Original GitHub issue: https://github.com/rudrankriyam/App-Store-Connect-CLI/issues/470

Overview

Add missing creation/generation operations for in-app purchase offer code code resources.

Scope (OpenAPI resources)

  • POST /v1/inAppPurchaseOfferCodeCustomCodes
  • POST /v1/inAppPurchaseOfferCodeOneTimeUseCodes

Current state

Current CLI support already includes read/update surfaces for these resources (list/get, and patch where applicable), but create/generate endpoints are not exposed.

Proposed CLI

Custom (vanity) codes

  • asc iap offer-codes custom-codes create --offer-code-id "OFFER_CODE_ID" --custom-code "HOLIDAY2026"

One-time use code batches

  • asc iap offer-codes one-time-codes create --offer-code-id "OFFER_CODE_ID" --quantity 100 --expiration-date "2026-12-31"

Examples:

  • asc iap offer-codes custom-codes create --offer-code-id "OFFER_CODE_ID" --custom-code "SUMMER26"
  • asc iap offer-codes one-time-codes create --offer-code-id "OFFER_CODE_ID" --quantity 500 --expiration-date "2026-09-30"

Flag patterns

Common: --offer-code-id, --output, --pretty

Additional:

  • custom codes: --custom-code
  • one-time batches: --quantity, --expiration-date (or exact OpenAPI-required field names)

Validation rules:

  • required IDs + required create attributes
  • quantity positive integer
  • expiration date format validation

Detailed TODO

  • Add request/attribute types for both create endpoints in internal/asc IAP offer code types.
  • Add client methods in internal/asc/client_iap_subresources.go:
    • create custom code
    • create one-time use code batch
  • Add CLI subcommands in internal/cli/iap/offer_code_codes.go:
    • custom-codes create
    • one-time-codes create
  • Wire help text/examples and keep command naming aligned with existing offer-code groups.

Acceptance criteria

  • Custom IAP offer code creation works via CLI.
  • One-time use batch generation works via CLI.
  • Responses print correctly in default JSON and optional table/markdown outputs.
  • make format, make lint, and make test pass.

Tests

  • HTTP client tests for both POST endpoints with payload assertions.
  • cmdtests for required flags and invalid values.
  • cmdtests for successful create flows and output behavior.

Implementation notes

  • Keep this consistent with existing subscription offer code command patterns where possible.
  • Maintain explicit flags and non-interactive behavior.

References

  • docs/openapi/paths.txt
  • docs/openapi/latest.json
  • internal/asc/client_iap_subresources.go
  • internal/cli/iap/offer_code_codes.go
Originally created by @rudrankriyam on GitHub (Feb 10, 2026). Original GitHub issue: https://github.com/rudrankriyam/App-Store-Connect-CLI/issues/470 # Overview Add missing creation/generation operations for in-app purchase offer code code resources. # Scope (OpenAPI resources) - `POST /v1/inAppPurchaseOfferCodeCustomCodes` - `POST /v1/inAppPurchaseOfferCodeOneTimeUseCodes` # Current state Current CLI support already includes read/update surfaces for these resources (list/get, and patch where applicable), but create/generate endpoints are not exposed. # Proposed CLI ## Custom (vanity) codes - `asc iap offer-codes custom-codes create --offer-code-id "OFFER_CODE_ID" --custom-code "HOLIDAY2026"` ## One-time use code batches - `asc iap offer-codes one-time-codes create --offer-code-id "OFFER_CODE_ID" --quantity 100 --expiration-date "2026-12-31"` Examples: - `asc iap offer-codes custom-codes create --offer-code-id "OFFER_CODE_ID" --custom-code "SUMMER26"` - `asc iap offer-codes one-time-codes create --offer-code-id "OFFER_CODE_ID" --quantity 500 --expiration-date "2026-09-30"` # Flag patterns Common: `--offer-code-id`, `--output`, `--pretty` Additional: - custom codes: `--custom-code` - one-time batches: `--quantity`, `--expiration-date` (or exact OpenAPI-required field names) Validation rules: - required IDs + required create attributes - `quantity` positive integer - expiration date format validation # Detailed TODO - [ ] Add request/attribute types for both create endpoints in `internal/asc` IAP offer code types. - [ ] Add client methods in `internal/asc/client_iap_subresources.go`: - [ ] create custom code - [ ] create one-time use code batch - [ ] Add CLI subcommands in `internal/cli/iap/offer_code_codes.go`: - [ ] `custom-codes create` - [ ] `one-time-codes create` - [ ] Wire help text/examples and keep command naming aligned with existing offer-code groups. # Acceptance criteria - [ ] Custom IAP offer code creation works via CLI. - [ ] One-time use batch generation works via CLI. - [ ] Responses print correctly in default JSON and optional table/markdown outputs. - [ ] `make format`, `make lint`, and `make test` pass. # Tests - [ ] HTTP client tests for both POST endpoints with payload assertions. - [ ] cmdtests for required flags and invalid values. - [ ] cmdtests for successful create flows and output behavior. # Implementation notes - Keep this consistent with existing subscription offer code command patterns where possible. - Maintain explicit flags and non-interactive behavior. # References - `docs/openapi/paths.txt` - `docs/openapi/latest.json` - `internal/asc/client_iap_subresources.go` - `internal/cli/iap/offer_code_codes.go`
kerem closed this issue 2026-02-26 21:33:41 +03:00
Author
Owner

@rudrankriyam commented on GitHub (Feb 10, 2026):

@cursor Please implement this issue end-to-end.

What to build

Add creation/generation support for IAP offer-code code resources.

Endpoints to add

  • POST /v1/inAppPurchaseOfferCodeCustomCodes
  • POST /v1/inAppPurchaseOfferCodeOneTimeUseCodes

Implementation plan

  1. Types (internal/asc)
  • Add create request/attributes for:
    • IAP offer code custom code
    • IAP offer code one-time use code batch
  • Include required relationships to inAppPurchaseOfferCodes.
  1. Client methods (internal/asc/client_iap_subresources.go)
  • CreateInAppPurchaseOfferCodeCustomCode(...)
  • CreateInAppPurchaseOfferCodeOneTimeUseCode(...)
  • Use exact POST routes above and return parsed response objects.
  1. CLI subcommands (internal/cli/iap/offer_code_codes.go)
  • Add:
    • asc iap offer-codes custom-codes create --offer-code-id ... --custom-code ...
    • asc iap offer-codes one-time-codes create --offer-code-id ... --quantity ... --expiration-date ...
  • Validation:
    • required --offer-code-id
    • custom-codes create requires --custom-code
    • one-time-codes create requires positive --quantity
    • validate expiration date format before request
  • Keep output/pretty flags aligned with existing commands.
  1. Help/examples
  • Update long help examples in the custom-codes and one-time-codes groups.

New tests to write

A) Client HTTP tests (internal/asc/client_http_test.go)

  • TestCreateInAppPurchaseOfferCodeCustomCode_UsesPostPath
  • TestCreateInAppPurchaseOfferCodeOneTimeUseCode_UsesPostPath

For each test assert:

  • HTTP method POST
  • exact route path
  • request body type + relationships + required attrs

B) CLI cmdtests (new file)

  • internal/cli/cmdtest/iap_offer_code_code_generation_test.go

Cases to include:

  • custom-codes create missing --offer-code-id -> usage error
  • custom-codes create missing --custom-code -> usage error
  • one-time-codes create missing --offer-code-id -> usage error
  • one-time-codes create invalid --quantity (0, negative, non-integer) -> usage error
  • one-time-codes create invalid --expiration-date -> usage error
  • success create custom code
  • success create one-time batch

C) Output behavior test

  • Ensure success responses render correctly with default JSON and --pretty.

How to test locally

Run exactly:

  • make format
  • make lint
  • make test

Targeted tests:

  • go test ./internal/asc -run 'CreateInAppPurchaseOfferCode(CustomCode|OneTimeUseCode)'
  • go test ./internal/cli/cmdtest -run 'iap_offer_code_code_generation'

Done criteria

  • Both POST endpoints are accessible via CLI create commands.
  • Validation and payload structure are covered by tests.
  • All checks pass (format, lint, test).
<!-- gh-comment-id:3877922551 --> @rudrankriyam commented on GitHub (Feb 10, 2026): @cursor Please implement this issue end-to-end. ## What to build Add creation/generation support for IAP offer-code code resources. ### Endpoints to add - `POST /v1/inAppPurchaseOfferCodeCustomCodes` - `POST /v1/inAppPurchaseOfferCodeOneTimeUseCodes` ## Implementation plan 1. **Types (`internal/asc`)** - Add create request/attributes for: - IAP offer code custom code - IAP offer code one-time use code batch - Include required relationships to `inAppPurchaseOfferCodes`. 2. **Client methods (`internal/asc/client_iap_subresources.go`)** - `CreateInAppPurchaseOfferCodeCustomCode(...)` - `CreateInAppPurchaseOfferCodeOneTimeUseCode(...)` - Use exact POST routes above and return parsed response objects. 3. **CLI subcommands (`internal/cli/iap/offer_code_codes.go`)** - Add: - `asc iap offer-codes custom-codes create --offer-code-id ... --custom-code ...` - `asc iap offer-codes one-time-codes create --offer-code-id ... --quantity ... --expiration-date ...` - Validation: - required `--offer-code-id` - custom-codes create requires `--custom-code` - one-time-codes create requires positive `--quantity` - validate expiration date format before request - Keep output/pretty flags aligned with existing commands. 4. **Help/examples** - Update long help examples in the custom-codes and one-time-codes groups. ## New tests to write ### A) Client HTTP tests (`internal/asc/client_http_test.go`) - `TestCreateInAppPurchaseOfferCodeCustomCode_UsesPostPath` - `TestCreateInAppPurchaseOfferCodeOneTimeUseCode_UsesPostPath` For each test assert: - HTTP method POST - exact route path - request body type + relationships + required attrs ### B) CLI cmdtests (new file) - `internal/cli/cmdtest/iap_offer_code_code_generation_test.go` Cases to include: - custom-codes create missing `--offer-code-id` -> usage error - custom-codes create missing `--custom-code` -> usage error - one-time-codes create missing `--offer-code-id` -> usage error - one-time-codes create invalid `--quantity` (`0`, negative, non-integer) -> usage error - one-time-codes create invalid `--expiration-date` -> usage error - success create custom code - success create one-time batch ### C) Output behavior test - Ensure success responses render correctly with default JSON and `--pretty`. ## How to test locally Run exactly: - `make format` - `make lint` - `make test` Targeted tests: - `go test ./internal/asc -run 'CreateInAppPurchaseOfferCode(CustomCode|OneTimeUseCode)'` - `go test ./internal/cli/cmdtest -run 'iap_offer_code_code_generation'` ## Done criteria - Both POST endpoints are accessible via CLI create commands. - Validation and payload structure are covered by tests. - All checks pass (`format`, `lint`, `test`).
Author
Owner

@cursor[bot] commented on GitHub (Feb 10, 2026):

Here's a summary of what I implemented:

Types (internal/asc/iap_resources.go)

  • Added InAppPurchaseOfferCodeCustomCodeCreateRequest with attributes (customCode, numberOfCodes, optional expirationDate) and relationship to inAppPurchaseOfferCodes
  • Added InAppPurchaseOfferCodeOneTimeUseCodeCreateRequest with attributes (numberOfCodes, expirationDate) and relationship to inAppPurchaseOfferCodes

Client methods (internal/asc/client_iap_subresources.go)

  • CreateInAppPurchaseOfferCodeCustomCode -- POST to /v1/inAppPurchaseOfferCodeCustomCodes
  • CreateInAppPurchaseOfferCodeOneTimeUseCode -- POST to /v1/inAppPurchaseOfferCodeOneTimeUseCodes

CLI subcommands (internal/cli/iap/offer_code_codes.go)

  • asc iap offer-codes custom-codes create --offer-code-id ... --custom-code ... --quantity ... [--expiration-date ...] [--output ...] [--pretty]
  • asc iap offer-codes one-time-codes create --offer-code-id ... --quantity ... --expiration-date ... [--output ...] [--pretty]
  • Validation: required flags, positive quantity, date format validation
  • Help text and examples updated for both command groups

Tests

  • 2 client HTTP tests asserting POST method, exact paths, payload types, relationships, and attributes
  • 12 CLI cmdtests covering: missing required flags, invalid quantity (zero/negative), invalid/missing expiration date, successful create flows with JSON output parsing, and pretty-print JSON output
  • All tests pass: make format, make lint, make test all green

View PR

Open in Cursor Open in Web

<!-- gh-comment-id:3877923144 --> @cursor[bot] commented on GitHub (Feb 10, 2026): Here's a summary of what I implemented: **Types (`internal/asc/iap_resources.go`)** - Added `InAppPurchaseOfferCodeCustomCodeCreateRequest` with attributes (`customCode`, `numberOfCodes`, optional `expirationDate`) and relationship to `inAppPurchaseOfferCodes` - Added `InAppPurchaseOfferCodeOneTimeUseCodeCreateRequest` with attributes (`numberOfCodes`, `expirationDate`) and relationship to `inAppPurchaseOfferCodes` **Client methods (`internal/asc/client_iap_subresources.go`)** - `CreateInAppPurchaseOfferCodeCustomCode` -- POST to `/v1/inAppPurchaseOfferCodeCustomCodes` - `CreateInAppPurchaseOfferCodeOneTimeUseCode` -- POST to `/v1/inAppPurchaseOfferCodeOneTimeUseCodes` **CLI subcommands (`internal/cli/iap/offer_code_codes.go`)** - `asc iap offer-codes custom-codes create --offer-code-id ... --custom-code ... --quantity ... [--expiration-date ...] [--output ...] [--pretty]` - `asc iap offer-codes one-time-codes create --offer-code-id ... --quantity ... --expiration-date ... [--output ...] [--pretty]` - Validation: required flags, positive quantity, date format validation - Help text and examples updated for both command groups **Tests** - 2 client HTTP tests asserting POST method, exact paths, payload types, relationships, and attributes - 12 CLI cmdtests covering: missing required flags, invalid quantity (zero/negative), invalid/missing expiration date, successful create flows with JSON output parsing, and pretty-print JSON output - All tests pass: `make format`, `make lint`, `make test` all green <p><a href="https://github.com/rudrankriyam/App-Store-Connect-CLI/pull/472"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/view-pr-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/view-pr-light.png"><img alt="View PR" width="86" height="28" src="https://cursor.com/assets/images/view-pr-light.png"></picture></a></p> <p><a href="https://cursor.com/background-agent?bcId=bc-bf2d7232-0e1a-44ba-9aad-22e9d1c2f577"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?id=bc-bf2d7232-0e1a-44ba-9aad-22e9d1c2f577"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a></p>
Author
Owner

@rudrankriyam commented on GitHub (Feb 10, 2026):

Implemented and merged in #472.
IAP offer code generation parity is now covered (custom codes plus one-time use batches), including validation and API error-path tests.
Closing as complete.

<!-- gh-comment-id:3878644947 --> @rudrankriyam commented on GitHub (Feb 10, 2026): Implemented and merged in #472. IAP offer code generation parity is now covered (custom codes plus one-time use batches), including validation and API error-path tests. Closing as complete.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/App-Store-Connect-CLI#135
No description provided.