# ActivateListing

## Permission Scope

marketplace

## Overview

ActivateListing makes a listing externally sellable. It verifies that all required internal and external identifiers, item status, channel status, and optional price-linkage prerequisites are satisfied.

## Business Rules

- Only DRAFT or PAUSED listings may be activated.
- Referenced channel and item must both be ACTIVE.
- Required internal and external identifiers must be present.
- If activation depends on pricing linkage, the required price context must be valid.

## Process Flow

```mermaid
flowchart TD
    A[Receive activate request] --> B[Load listing, item, and channel]
    B --> C[Validate identifiers and sellability prerequisites]
    C --> D{Validation passed?}
    D -->|No| E[Return validation error]
    D -->|Yes| F[Set listing status to ACTIVE]
    F --> G[Return activated listing]
```

## External Dependencies

- [getListing](../queries/GetListing.md) - Load listing and current state.
- [getChannel](../queries/GetChannel.md) - Validate target channel status.
- [getApplicableSalesPrice](../queries/GetApplicableSalesPrice.md) - Optional activation-time pricing eligibility check.

## Error Scenarios

- **LISTING_NOT_FOUND**: Referenced listing does not exist.
- **INVALID_LISTING_STATUS**: Listing status does not allow this operation
- **LISTING_IDENTIFIER_REQUIRED**: Required listing identifiers are missing.
- **CHANNEL_OR_ITEM_INACTIVE**: Listing cannot activate because channel or item is inactive.
- **MISSING_PRICE_LINKAGE**: Required pricing linkage is missing for activation.

## Test Cases

- activates a draft listing with valid identifiers
- reactivates a paused listing
- throws when required identifiers are missing
- throws when channel or item is inactive
- throws when required pricing linkage is missing
