docs(api): add Set Default Address endpoint documentation
PATCH /api/customer/addresses/:addressId/default — sets isDefault=true on the target address and false on all others. Documents id field now present in address_book entries, isDefault behavior, and example payload.
This commit is contained in:
@@ -188,7 +188,62 @@ data:image/webp;base64,<base64data>
|
||||
| `NO_FIELDS` | 400 | Nenhum campo reconhecido no body |
|
||||
| `CUSTOMER_NOT_FOUND` | 404 | — |
|
||||
|
||||
### 5. List Favorite Stores
|
||||
### 5. Set Default Address
|
||||
**PATCH** `/api/customer/addresses/:addressId/default`
|
||||
|
||||
**Headers:**
|
||||
|
||||
- `Authorization: Bearer <JWT_Token>`
|
||||
- `Atomenta-Token: 550e8400-e29b-41d4-a716-44665544000a`
|
||||
|
||||
**Notes:**
|
||||
|
||||
- Define um endereço como padrão pelo seu `id`.
|
||||
- Define `isDefault: true` no endereço alvo e `isDefault: false` em todos os outros.
|
||||
- O `id` de cada endereço é retornado no campo `address_book` do perfil (`GET /api/customer/profile`).
|
||||
- Ao salvar um endereço via `PATCH /api/customer/profile`, o backend gera automaticamente um `id` UUID caso o endereço não possua um.
|
||||
- Se nenhum endereço tiver `isDefault: true`, o primeiro do array é tratado como padrão.
|
||||
|
||||
**Response 200:**
|
||||
|
||||
```json
|
||||
{
|
||||
"error": false,
|
||||
"code": "ADDRESS_DEFAULT_SET"
|
||||
}
|
||||
```
|
||||
|
||||
**Erros:**
|
||||
|
||||
| Código | HTTP | Descrição |
|
||||
|---|---|---|
|
||||
| `ADDRESS_NOT_FOUND` | 404 | Nenhum endereço com esse `id` no `address_book` |
|
||||
| `CUSTOMER_NOT_FOUND` | 404 | — |
|
||||
|
||||
**Exemplo de `address_book` no perfil (com `id` e `isDefault`):**
|
||||
|
||||
```json
|
||||
"address_book": [
|
||||
{
|
||||
"id": "a1b2c3d4-...",
|
||||
"label": "Casa",
|
||||
"type": "residential",
|
||||
"address": "Estrada Vicinal Nene Moro",
|
||||
"number": "SN",
|
||||
"neighborhood": "Curtume",
|
||||
"city": "Aguaí",
|
||||
"state": "SP",
|
||||
"zipCode": "13868070",
|
||||
"country": "Brasil",
|
||||
"lat_long": [-22.06743, -46.98018],
|
||||
"isDefault": true
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 6. List Favorite Stores
|
||||
**GET** `/api/customer/favorites`
|
||||
|
||||
**Headers:**
|
||||
|
||||
Reference in New Issue
Block a user