
## Bloomreach Tier Discount API

Resolve a customer's loyalty tier into a specific discount code based on their Bloomreach (Exponea) profile.

### Endpoint

```
POST /api/bloomreach/tier-discount
```

#### Headers

| Header | Required | Description |
|--------|----------|-------------|
| `Content-Type` | ✅ | Must be `application/json` |
| `X-Store-Name` | ✅ | Store name from the `stores` table |

#### Request Body

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `email` | string | ✅ | Customer's email address |

**Example Body:**

```json
{
  "email": "user@example.com"
}
```

#### cURL Example

```bash
curl -X POST https://your-domain.com/api/bloomreach/tier-discount \
  -H "Content-Type: application/json" \
  -H "X-Store-Name: watsons-uae" \
  -d '{
    "email": "user@example.com"
  }'
```

#### Successful Response (200 OK)

```json
{
  "success": true,
  "message": "Tier discount resolved successfully.",
  "data": {
    "discount_code": "GOLD15"
  }
}
```

#### Error Responses

| Status | Message | Description |
|--------|---------|-------------|
| 404 | No discount code available for this customer tier. | Returned if the customer has no tier or an unmapped tier. |
| 422 | Validation Error | Returned if the email is missing or invalid. |
| 503 | Bloomreach credentials not configured. | Returned if the store lacks Bloomreach API keys. |

#### Logic Mapping
| Tier Value | Discount Code |
|------------|---------------|
| `silver` | `SILVER10` |
| `gold` | `GOLD15` |
| `platinum` | `PLATINUM20` |

---

