Clientes
Un cliente representa a una persona que realiza compras en la tienda. Las cuentas de cliente almacenan información de contacto, lo que facilita futuras compras sin necesidad de volver a ingresar sus datos.
Propiedades
| Propiedad | Descripción |
|---|---|
| id | Identificador único del cliente |
| name | Nombre del cliente |
| last_name | Apellido del cliente |
| Correo electrónico | |
| phone | Número de teléfono |
| identification | Número de identificación (DNI, CPF, CNPJ, etc.) |
| identification_type | Tipo de identificación |
| created_at | Fecha de creación (ISO 8601) |
| updated_at | Fecha de última actualización (ISO 8601) |
| note | Notas internas sobre el cliente |
| total_spent | Monto total gastado en la tienda |
| orders_count | Cantidad total de pedidos |
| last_order_id | ID del último pedido |
| last_order_date | Fecha del último pedido |
| accepts_marketing | Indica si acepta comunicaciones de marketing (true o false) |
| address | Dirección principal del cliente |
Endpoints
GET /customers
Obtiene una lista de clientes.
Parámetros de query
| Parámetro | Descripción |
|---|---|
| created_at_min | Filtrar clientes creados después de esta fecha (ISO 8601) |
| created_at_max | Filtrar clientes creados antes de esta fecha (ISO 8601) |
| updated_at_min | Filtrar clientes actualizados después de esta fecha (ISO 8601) |
| updated_at_max | Filtrar clientes actualizados antes de esta fecha (ISO 8601) |
| q | Buscar por nombre, email o identificación |
| page | Número de página |
| per_page | Cantidad de resultados por página |
| since_id | Retorna registros posteriores al ID indicado |
| ids | Lista de IDs separados por coma |
Ejemplo
GET /customers
HTTP/1.1 200 OK
{
"pagination": {
"total": 120,
"page": 1,
"per_page": 50,
"next_page": "https://developers.tiendanegocio.com/v1/customers?page=2&per_page=50"
},
"results": [
{
"id": 25,
"name": "Juan",
"last_name": "Pérez",
"email": "juan@example.com",
"phone": "541112345678",
"identification": "12345678",
"identification_type": "DNI",
"created_at": "2023-01-01T00:00:00.000Z",
"updated_at": "2023-01-02T00:00:00.000Z",
"note": "Cliente VIP",
"total_spent": "0.00",
"orders_count": 0,
"last_order_id": 1,
"last_order_date": "2023-01-01T00:00:00.000Z",
"accepts_marketing": false,
"address": {}
}
]
}
GET /customers/{id}
Obtiene un cliente por ID.
Ejemplo
GET /customers/25
HTTP/1.1 200 OK
{
"id": 25,
"name": "Juan",
"last_name": "Pérez",
"email": "juan@example.com",
"phone": "541112345678",
"identification": "12345678",
"identification_type": "DNI",
"created_at": "2023-01-01T00:00:00.000Z",
"updated_at": "2023-01-02T00:00:00.000Z",
"note": "Cliente VIP",
"total_spent": "0.00",
"orders_count": 0,
"last_order_id": 1,
"last_order_date": "2023-01-01T00:00:00.000Z",
"accepts_marketing": false,
"address": {}
}
POST /customers
Crea un nuevo cliente.
Ejemplo de request
{
"name": "Juan",
"last_name": "Pérez",
"email": "juan@example.com",
"phone": "541112345678",
"password": "123456",
"identification": "12345678",
"identification_type": "DNI",
"note": "Cliente VIP",
"company": "Acme Inc"
}
Respuesta
HTTP/1.1 201 Created
{
"id": 26,
"name": "Juan",
"last_name": "Pérez",
"email": "juan@example.com",
"phone": "541112345678",
"identification": "12345678",
"identification_type": "DNI",
"created_at": "2023-01-01T00:00:00.000Z",
"updated_at": "2023-01-02T00:00:00.000Z",
"note": "Cliente VIP",
"total_spent": "0.00",
"orders_count": 0,
"last_order_id": 1,
"last_order_date": "2023-01-01T00:00:00.000Z",
"accepts_marketing": false,
"address": null
}
PUT /customers/{id}
Actualiza un cliente existente.
Ejemplo
PUT /customers/26
{
"name": "Juan",
"last_name": "Pérez",
"email": "juan@example.com",
"phone": "541112345678",
"password": "123456",
"identification": "12345678",
"identification_type": "DNI",
"note": "Cliente VIP",
"company": "Acme Inc"
}
Respuesta
HTTP/1.1 200 OK
{
"id": 26,
"name": "Juan",
"last_name": "Pérez",
"email": "juan@example.com",
"phone": "541112345678",
"identification": "12345678",
"identification_type": "DNI",
"created_at": "2023-01-01T00:00:00.000Z",
"updated_at": "2023-01-02T00:00:00.000Z",
"note": "Cliente VIP",
"total_spent": "0.00",
"orders_count": 0,
"last_order_id": 1,
"last_order_date": "2023-01-01T00:00:00.000Z",
"accepts_marketing": false,
"address": {}
}
DELETE /customers/{id}
Elimina un cliente.
Ejemplo
DELETE /customers/1