# Wdrożenie endpointu eBay Account Deletion

Serwis compliance (FastAPI + Caddy reverse-proxy z auto-HTTPS) na VPS.

## 1. Rekord DNS

Dodaj rekord **A** w panelu DNS domeny `dgx.dev`:

```
api.agent.dgx.dev  →  <IP_TWOJEGO_VPS>
```

Poczekaj na propagację (sprawdź: `dig api.agent.dgx.dev`).

## 2. Wygeneruj token weryfikacyjny

```bash
python3 -c "import secrets; print(secrets.token_hex(32))"
```

Skopiuj wynik (64 znaki hex).

## 3. Skonfiguruj `.env`

```bash
cp .env.example .env
```

Uzupełnij:

```
EBAY_VERIFICATION_TOKEN=<wygenerowany_token>
EBAY_DELETION_ENDPOINT_URL=https://api.agent.dgx.dev/ebay/deletions
```

## 4. Uruchom serwis

```bash
docker compose up -d --build
```

Caddy automatycznie pobierze certyfikat Let's Encrypt dla `api.agent.dgx.dev`.

## 5. Zweryfikuj działanie

Health check:

```bash
curl https://api.agent.dgx.dev/health
# {"status":"ok"}
```

Challenge test (podstaw swój token):

```bash
curl "https://api.agent.dgx.dev/ebay/deletions?challenge_code=test123"
# {"challengeResponse":"<sha256_hex>"}
```

Weryfikacja hasha ręcznie:

```bash
echo -n "test123<TWOJ_TOKEN>https://api.agent.dgx.dev/ebay/deletions" | sha256sum
```

Oba hashe powinny się zgadzać.

## 6. Rejestracja w panelu eBay

1. Otwórz https://developer.ebay.com → **Alerts & Notifications** (lub **Marketplace Account Deletion**).
2. Wklej URL: `https://api.agent.dgx.dev/ebay/deletions`
3. Wklej token weryfikacyjny (ten sam co w `.env`).
4. Kliknij **Save** / **Send test notification** — eBay wyśle challenge GET, serwis odpowie poprawnym hashem.

## Logi

```bash
docker compose logs -f compliance
```

Każda notyfikacja DELETE loguje `notificationId` i `userId`.
