# `PaperTiger.Router`
[🔗](https://github.com/EnaiaInc/paper_tiger/blob/v1.2.2/lib/paper_tiger/router.ex#L1)

HTTP router for PaperTiger Stripe mock server.

Handles all Stripe API endpoints with DRY macro-based routing.

## Plugs

- `PaperTiger.Plugs.CORS` - Cross-origin requests
- `PaperTiger.Plugs.Auth` - Verifies API key
- `PaperTiger.Plugs.RequestLogger` - Captures inbound request details for test assertions
- `PaperTiger.Plugs.Idempotency` - Prevents duplicate requests
- `PaperTiger.Plugs.UnflattenParams` - Converts card[number] to %{card: %{number: ...}}

## Endpoints

### Stripe API (v1)
- `/v1/customers` - Customer management
- `/v1/subscriptions` - Subscription management
- `/v1/invoices` - Invoice management
- etc. (28 total resource types)

### Config API (testing)
- `POST /_config/webhooks` - Register webhook endpoint
- `DELETE /_config/data` - Flush all data
- `POST /_config/time/advance` - Advance time (manual mode)

## Resource Macro

The `stripe_resource/3` macro generates standard CRUD routes:

    stripe_resource "customers", PaperTiger.Resources.Customer

Generates:
- POST   /v1/customers          -> Customer.create/1
- GET    /v1/customers/:id      -> Customer.retrieve/2
- POST   /v1/customers/:id      -> Customer.update/2
- DELETE /v1/customers/:id      -> Customer.delete/2
- GET    /v1/customers          -> Customer.list/1

With :only / :except support:

    stripe_resource "tokens", PaperTiger.Resources.Token, only: [:create, :retrieve]
    stripe_resource "events", PaperTiger.Resources.Event, except: [:delete]

# `call`

# `init`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
