# Introducción
Presentamos documentación oficial de las APIs ComeS con la finalidad de ser usada por el equipo técnico de la empresa y otros colaboradores interesados en el desarrollo de servicios que requieran conexión a los datos manejados.
# Respuestas API
[ToC]
## :rocket: API_STORE
### User
* #### Get User by Email
```https
GET /api/v1/user/${user_email}
```
| Parameter | Type | Description |
| :-------- | :------- | :------------------------- |
| `user_email` | `string` | **Requerido**. Email de usuario a buscar |
```json=
// Response Status 200 Ok
{
"user": {
"email": "test.comes@gmail.com",
"name": "Test Arket",
"auth_id": "auth_id_testing",
"role": {
"role": "administrador"
},
"store": {
"ID_store": "1",
"name": "Arket Emporio Vegano",
"bussines_name": "FRANK MARCELO KETTERER TORRES",
"phone": "56941063903",
"rut": "12918110-9",
"store_direction": [
{
"ID_store_direction": "cl3bqhcnj0000qwv1tewn0ywi",
"country": null,
"code_country": "CHL",
"region": "Region Metropolitana de Santiago",
"sub_region": "Santiago",
"municipality": "Santiago",
"street": "Paseo Huerfanos, Santiago",
"number": "18",
"label": "Paseo Huerfanos, Santiago, Region Metropolitana de Santiago, Chile",
"local_or_office": "Local 1",
"reference": "",
"latitude": "-18.4727991",
"longitude": "-70.29000649"
}…
]
}
}
}
```
Si el usuario indicado no existe:
```json=
// Response Status 400 Bad Request
{
"message": "Usuario no registrado",
"emailSearched": "dont.exist@gmail.com"
}
```
* #### Post User
```https
POST /api/v1/user
```
| Body | Type | Description |
| :-------- | :------- | :------------------------- |
| `data` | `object` | **Requerido**. Contiende objeto `user`, `store`, `storeCategory` y `producer`
El objeto `user` contiene las siguiente propiedades
| User | Type | Description |
| :-------- | :------- | :------------------------- |
|email | `string` | **Requerido**. Email del usuario|
|name | `string` | **Requerido**. Nombre del usuario|
|ID_role | `string` | Por defecto setear en 2 (?)|
|auth_id | `string` | ID entregado por `AWS cognito`|
El objeto `store` contiene las siguientes propiedades
| Store | Type | Description |
| :-------- | :------- | :------------------------- |
|rut |`string` |Rut tienda o persona natural|
|name |`string` |Nombre tienda o persona natural|
|bussines_name |`string` |Razon social o persona natual|
|phone |`string` |Numero telefono|
|email |`string` |Email de tienda o persona natual |
|contact_name |`string` |Nombre contacto |
|isCompany |`boolean` |True = es tienda o False = es persona natural|
|isActive |`boolean` |True = activo o False = inactivo|
|isDeleted |`boolean` |True = Eliminado o False = No eliminado |
|created_at |`string` |Fecha de creacion |
|modified_at |`string` |Fecha de modificacion|
|update_by_user |`string` |ID usuario quien modifico|
La propiedad `storeCategory` es un arreglo de objetos que contiene el `ID_categories_store` de la nueva store. **Esta propiedad no es requerida**, si no se especifica, no se agregara el registro en `store_category`
| StoreCategory | type | Description |
| -------- | -------- | -------- |
| ID_categories_store |`string` | ID de categorias de tiendas |
```json=
// Request body
{
"data": {
"user": {
"email": "correo.prueba@gmail.com",
"name": "jhon Doe",
"ID_role": "2",
"auth_id": "f975e792-de52-4f7f-b615-aaaaaaaaaaaa"
},
"store": {
"rut": "191639804-4",
"name": "jhon Doe",
"bussines_name": "Miel Gibson",
"phone": "56912345678",
"email": "mielgibson@gmail.com",
"contact_name": "jhon Doe",
"isCompany": true,
"isActive": false,
"isDeleted": false,
"created_at": "2022-05-31T15:59:55.735Z",
"modified_at": "2022-05-31T15:59:55.735Z",
"update_by_user": "1"
},
"storeCategory": [
{ "ID_categories_store": "5" },
{ "ID_categories_store": "6" },
{ "ID_categories_store": "4" }
],
"producer": {}
}
}
```
```json=
// Response Status 201
{
"message": "Usuario creado con exito",
"user": {
"ID_user": "cl3x73wrz0014isv1oqnfr4jr",
"email": "nuevo.usuario@gmail.com",
"name": "Nombre del usuario",
"auth_id": "f975e792-de52-4f7f-b615-aaaaaaaaaaaa", // entregado por cognito
"ID_role": "2",
"ID_store": "cl3x73wrz0015isv1k0cujt74", // id de la nueva tienda
"ID_producer": null // por ahora solo usuarios para tienda o persona natual.
}
}
```
Si no se especifican datos de tienda (`store`)
```json=
// Response Status 201
{
"message": "Usuario creado con exito",
"user": {
"ID_user": "cl3x853b800022kv1fo6vd61s",
"email": "nuevo.usuario@gmail.com",
"name": "Nombre del usuario",
"auth_id": "f975e792-de52-4f7f-b615-aaaaaaaaaaaa",
"ID_role": "2",
"ID_store": null, // ← no se agrega la store
"ID_producer": null
}
}
```
Si no se indican los datos requeridos o los unicos ya existen en BD
```json=
// Response Status 403 Forbidden
{
"error": [
{
"msg": "Campo email es requerido",
"param": "data.user.email",
"location": "body"
},
{
"msg": "Campo email no puede ser vacio",
"param": "data.user.email",
"location": "body"
},
{
"msg": "Campo email debe ser un texto",
"param": "data.user.email",
"location": "body"
},
{
"value": "correo.prueba@gmail.com",
"msg": "Email de usuario ya existe. Email debe ser unico",
"param": "data.user.email",
"location": "body"
},
{
"msg": "Campo nombre usuario es requerido",
"param": "data.user.name",
"location": "body"
},
{
"msg": "Campo nombre usuario no puede ser vacio",
"param": "data.user.name",
"location": "body"
},
{
"msg": "Campo nombre usuario debe ser un texto",
"param": "data.user.name",
"location": "body"
},
{
"value": "77254529-0",
"msg": "No se ha podido ingresar la tienda. Tienda rut: 77254529-0 ya existe",
"param": "data.store.rut",
"location": "body"
}
]
}
```
### Store
* #### Post Store
```http
POST /api/v1/stores
```
| Body |Type | Description |
| :-------- | :------- | :-------------------------------- |
|rut |`string` |**Requerido**. Rut tienda o persona natural|
|name |`string` |**Requerido**. Nombre tienda o persona natural|
|bussines_name |`string` |**Requerido**. Razon social o persona natual|
|phone |`string` |**Requerido**. Numero telefono|
|email |`string` |**Requerido**. Email de tienda o persona natual |
|contact_name |`string` |Nombre contacto |
|work_position |`string` |Cargo (?)|
|isCompany |`boolean` |**Requerido**. True = es tienda o False = es persona natural|
|isActive |`boolean` |**Requerido**. True = activo o False = inactivo|
|isDeleted |`boolean` |**Requerido**. True = Eliminado o False = No eliminado |
|created_at |`string` |**Requerido**. Fecha de creacion |
|modified_at |`string` |**Requerido**. Fecha de modificacion|
|update_by_user |`string` |ID usuario quien modifico|
```json=
// Request body
{
"rut": "11111111-4",
"name": "Nombre Tienda", // o nombre persona natural
"bussines_name": "Razon social",// o mismo nombre si es persona natual
"phone": "56912345678",
"email": "mielgibson@gmail.com",
"contact_name": "nombre contacto",
"isCompany": true,
"isActive": false,
"isDeleted": false,
"created_at": "2022-05-31T15:59:55.735Z",
"modified_at": "2022-05-31T15:59:55.735Z",
"update_by_user": "1"
}
```
```json=
// Response Status 201 Ok
{
"message": "Se ha ingresado la nueva tienda",
"store": {
"ID_store": "cl3ujjk7t0000r8v1e8ojwtl6",
"rut": "11111111-4",
"name": "Nombre Tienda",
"bussines_name": "Razon social",
"phone": "56912345678",
"email": "mielgibson@gmail.com",
"contact_name": "nombre contacto",
"work_position": null,
"isActive": false,
"isDeleted": false,
"isCompany": true,
"created_at": "2022-05-31T15:59:55.735Z",
"modified_at": "2022-05-31T15:59:55.735Z",
"update_by_user": "1"
}
}
```
Si no se indican datos requeridos
```json=
// Response Status 401 Forbidden
{
"error": [
{
"msg": "Campo rut es requerido",
"param": "rut",
"location": "body"
},
{
"msg": "Campo rut no puede ser vacio",
"param": "rut",
"location": "body"
},
{
"msg": "Campo rut debe ser un texto",
"param": "rut",
"location": "body"
},
{
"msg": "Campo nombre es requerido",
"param": "name",
"location": "body"
},
{
"msg": "Campo nombre no puede ser vacio",
"param": "name",
"location": "body"
},
{
"msg": "Campo nombre debe ser un texto",
"param": "name",
"location": "body"
},
{
"msg": "Campo razon social es requerido",
"param": "bussines_name",
"location": "body"
}…
]
}
```
* #### Get Store
```http
GET /api/v1/stores
```
| Parameter | Type | Description |
| :-------- | :------- | :-------------------------------- |
| none | none | none |
```json=
// Response Status 200 Ok
{
"data": [
{
"ID_store": "1",
"rut": "12918110-9",
"name": "Arket Emporio Vegano",
"bussines_name": "FRANK MARCELO KETTERER TORRES",
"phone": "56941063903",
"email": "fketteret@gmail.com",
"contact_name": null,
"work_position": null,
"isActive": true,
"isDeleted": false,
"created_at": "2022-04-27T15:59:55.735Z",
"modified_at": "2022-04-27T15:59:55.735Z",
"update_by_user": "1"
},
{
"ID_store": "10",
"rut": "77254529-0",
"name": "Aloha poke bowl",
"bussines_name": "ALOHA POKE BOWL SPA",
"phone": "56944313614",
"email": "carlamardonesmunoz@gmail.com",
"contact_name": null,
"work_position": null,
"isActive": true,
"isDeleted": false,
"created_at": "2022-04-27T15:59:55.735Z",
"modified_at": "2022-04-27T15:59:55.735Z",
"update_by_user": "1"
}…
]
}
```
* #### Get Store By ID store
```http
GET /api/v1/stores/${ID_store}
```
| Parameter | Type | Description |
| :-------- | :------- | :-------------------------------- |
| ID_store | string | ID de tienda a buscar |
```json=
// Response Status 200 Ok
{
"store": {
"ID_store": "1",
"rut": "12918110-9",
"name": "Arket Emporio Vegano",
"bussines_name": "FRANK MARCELO KETTERER TORRES",
"phone": "56911111111",
"email": "fketteret@gmail.com",
"contact_name": null,
"work_position": null,
"isActive": true,
"isDeleted": false,
"created_at": "2022-04-27T15:59:55.735Z",
"modified_at": "2022-04-27T15:59:55.735Z",
"update_by_user": "1"
}
}
```
Si la el ID tienda indicada no existe:
```json=
// Response Status XXX
{
"message": "No se ha encontrado la tienda",
"data": null
}
```
* #### Get Store by Rut
```http
GET /api/v1/stores/rut/${rut}
```
| Parameter | Type | Description |
| :-------- | :------- | :-------------------------------- |
| rut | string | Rut de tienda a buscar |
```json=
// Response Status 200 Ok
{
"store": {
"ID_store": "21",
"rut": "77251286-4",
"name": "Kuy",
"bussines_name": "COMERCIAL SANTA PAULA LIMITADA",
"phone": "56964739007",
"email": "perillon3@hotmail.com",
"contact_name": null,
"work_position": null,
"isActive": true,
"isDeleted": false,
"isCompany": true,
"created_at": "2022-04-27T15:59:55.735Z",
"modified_at": "2022-04-27T15:59:55.735Z",
"update_by_user": "1"
}
}
```
Si no encuentra tienda devolvera el objeto `store` **null**
```json=
// Response Status 200 Ok
{
"store": null
}
```
* #### Get Store Ranking
```http
GET /api/v1/stores/ranking
```
El endpoint puede o no resivir los siguientes `query parameters`:
| Qry Parameter | Examples | Description |
| :-------- | :------- | :-------------------------------- |
| `skip` |`skip=0` |omite la cantidad indicada|
| `take` |`take=40` |toma la cantidad indicada desde el skip|
| `categories` |`categories=Frutas, Mermeladas y manjares` |Nombre de la categoria separados por coma (,)|
| `region` |`region=Región Del Bio Bio`|nombre de la region (como este en BD)|
|`q`|`q=comes`|valor ingresado en la barra de busqueda|
Devuelve las tiendas no particulares con minimo de una compra en los ultimos 60 dias ordenadas por compras a mas productores
```json=
// Response Status 200 Ok
{
"ranking": [
{
"ID_store": "25",
"rut": "76683371-3",
"name": "ComeS Emporio",
"bussines_name": "ComeS SPA",
"phone": "56939579093",
"email": "finanzas@comeschile.cl",
"web": null,
"contact_name": null,
"store_image": [],
"social_network": [],
"store_category": [],
"store_direction": [
{
"ID_store_direction": "cl1xnl17w302730gpc9ikxge71",
"country": "Chile",
"code_country": "CHL",
"region": null,
"sub_region": "Los Ángeles",
"municipality": "Los Ángeles",
"street": "Avenida Almirante La Torre ",
"number": "0470",
"local_or_office": null,
"label": "Avenida almirante la torre 470, Los Ángeles, Chile",
"reference": "",
"latitude": null,
"longitude": null
}
],
"isActive": true,
"isDeleted": false,
"isCompany": true,
"created_at": "2022-05-02T21:16:09.018Z",
"modified_at": "2022-05-02T21:16:09.018Z",
"_countProducer": 4 // Cantidad de productores diferentes
}
],
"count": 1 // Cantidad de tiendas
}
```
Si no hay tienda en el rankin devolvera el siguiente objeto
```json=
// Response Status 400 Ok
{
"message": "No hay tiendas disponibles",
"ranking": [],
}
```
### Store Category
* #### Get Store Category
```http
GET /api/v1/store/category
```
| Parameter | Type | Description |
| :-------- | :------- | :-------------------------------- |
| none | none | none |
```json=
// Response Status 200 Ok
{
"storeCategories": [
{
"ID_categories_store": "1",
"category": "Comida rápida ",
"description": "Ofrece diversas comidas y bebidas para consumo en el establecimiento o delivery, no necesariamente son productos saludables en la carta que ofrecen."
},
{
"ID_categories_store": "2",
"category": "Minimarket ",
"description": "Tienda no especializada que no necesariamente tiene a la venta productos saludables."
},
{
"ID_categories_store": "3",
"category": "Restaurant",
"description": "Ofrece diversas comidas y bebidas para su consumo en el establecimiento. "
}…
]
}
```
### Store Direction
* #### Post Store Direction
```http
POST /api/v1/store/direction
```
| Body | Type | Description |
| :-------- | :------- | :-------------------------------- |
| `code_country` | `string` | Codigo pais **ISO 3166-1 alfa-3** |
| `region` | `string` | Region de pais |
| `sub_region` | `string` | Region secundaria |
| `municipality` | `string` | Municipalidad |
| `street` | `string` | Calle |
| `number` | `string` | Enumeracion |
| `local_or_office` | `string` | Local o Oficina |
| `label` | `string` | Direccion concatenenada |
| `reference` | `string` | Referencia |
| `latitude` | `double` | Latitud |
| `longitude` | `double` | Longitud |
| `ID_store` | `string` | ID tienda |
```json=
// Request body
{
"code_country": "CHL",
"region": "Región Metropolitana de Santiago",
"sub_region": "Santiago",
"municipality": "Puente Alto",
"street": "Pasaje Ejemplo",
"number": "111",
"local_or_office": "Local 1",
"label": "Pasaje Ejemplo 1111, Puente Alto, Santiago, Región Metropolitana de Santiago, CHL",
"reference": "Antepenultima casa del lado derecho",
"latitude": -33.333333333333333,
"longitude": -77.77777777777777,
"ID_store": "2"
}
```
```json=
// Response Status 201 Created
{
"message": "Direccion de tienda ingresada con exito",
"storeDirection": {
"ID_store_direction": "cl3olqor5000960v157ryc1ns",
"country": "Chile",
"code_country": "CHL",
"region": "Región Metropolitana de Santiago",
"sub_region": "Santiago",
"municipality": "Puente Alto",
"street": "Pasaje Ejemplo",
"number": "111",
"local_or_office": "Local 1",
"label": "Pasaje Ejemplo 1111, Puente Alto, Santiago, Región Metropolitana de Santiago, CHL",
"reference": "Antepenultima casa del lado derecho",
"latitude": "-33.33333333",
"longitude": "-77.77777778",
"ID_store": "2"
}
}
```
Si la direccion a ingresar ya esta asociada a la tienda:
```json=
// Response Status 400 Bad Request
{
"message": "Direccion ingresada ya esta registrada",
"direction": "Pasaje Ejemplo #111, Puente Alto, Santiago"
}
```
* #### Get Store Direction
```http
GET /api/v1/store/direction
```
| Parameter | Type | Description |
| :-------- | :------- | :-------------------------------- |
| none | none | none |
```json=
{
"data": [
{
"ID_store_direction": "1",
"country": null,
"code_country": null,
"region": null,
"sub_region": null,
"municipality": null,
"street": "San Martín",
"number": "710",
"local_or_office": null,
"label": null,
"reference": null,
"latitude": null,
"longitude": null,
"ID_store": "1"
},
{
"ID_store_direction": "2",
"country": null,
"code_country": null,
"region": null,
"sub_region": null,
"municipality": null,
"street": "O’higgins",
"number": "1285",
"local_or_office": null,
"label": null,
"reference": null,
"latitude": null,
"longitude": null,
"ID_store": "2"
}…
]
}
```
* #### Get Store Direction By ID Store
```https
GET /api/v1/store/direction/${ID_store}
```
| Parameter | Type | Description |
| :-------- | :------- | :-------------------------------- |
| ID_store | string | ID tienda |
```json=
// Response Status 200 Ok
{
"data": [
{
"ID_store_direction": "1",
"country": null,
"code_country": null,
"region": null,
"sub_region": null,
"municipality": null,
"street": "San Martín",
"number": "710",
"local_or_office": null,
"label": null,
"reference": null,
"latitude": null,
"longitude": null,
"ID_store": "1"
},
{
"ID_store_direction": "cl12b30t200111qph1pfg6clh",
"country": null,
"code_country": null,
"region": null,
"sub_region": null,
"municipality": null,
"street": "Prueba 1",
"number": "1234",
"local_or_office": null,
"label": null,
"reference": "",
"latitude": null,
"longitude": null,
"ID_store": "1"
}…
]
}
```
Si no se encuentra la direccion de tienda buscada:
```json=
// Response Status XXX Bad Request
{
"data": [],
"message": "No se han encontrado direcciones para la tienda indicada"
}
```
* #### Get Regions
```http
GET /api/v1/regions
```
| Params | Type | Description |
| :-------- | :------- | :-------------------------------- |
| none | none | none |
```json=
// Response Status 200 Ok
{
"regions": [
{
"ID_store_direction": "1",
"region": null,
"sub_region": "Concepción"
},
{
"ID_store_direction": "cl1xxmumk321640gpcwi5seawm",
"region": "Bío Bío",
"sub_region": "Concepción"
},
{
"ID_store_direction": "cl3sx2v226503hrpckc9f5i2t",
"region": "Bíobío",
"sub_region": "Bío-Bío"
},
{
"ID_store_direction": "cl3u90y4814081hrpcucnjqmes",
"region": "Maule",
"sub_region": "Curicó"
},
{
"ID_store_direction": "cl59wtwba416594gepctcl8zt9e",
"region": "Región Metropolitana de Santiago",
"sub_region": "Santiago"
}
]
}
```
En caso de no haber regiones disponibles
```json=
// Response Status 400 Bad request
{
"message": "No se encontraron regiones",
}
```
### Order
* #### Post Order Note
```http
POST /api/v1/order
```
| Body | Type | Description |
| :-------- | :------- | :-------------------------------- |
| `number` | `int` | Numero de orden |
| `neto` | `int` | Neto de la orden |
| `iva` | `int` | Iva de la orden |
| `total` | `int` | Total |
| `total_order` | `int` | |
| `type_discount` | `int` | |
| `discount` | `int` | Descuento |
| `comment_by_order` | `string` | Comentario para orden |
| `created_by` | `string` | Email de usuario responsable de la creacion |
| `ID_store` | `string` | ID tienda |
| `ID_order_status` | `string` | ID estado de la orden |
| `ID_store_direction` | `string` | ID direccion asociada a la tienda |
| `details` | `array` | Arreglo de objetos con detalles de orden. El objeto debe contener `qty`, `unit_price`, `sub_total` y `ID_product`|
| `modification_date` | `datetime`| Fecha de modificacion |
| `creation_date` | `datetime`| Fecha de creacion |
```json=
// Request body
{
"number": 18,
"neto": 156723,
"iva": 29777,
"total": 186500,
"total_order": 186500,
"type_discount": null,
"discount": null,
"comment_by_order": "asda",
"created_by": "usuario.comes@gmail.com",
"ID_store": "1",
"ID_order_status": "1",
"ID_store_direction": "cl12b5d8u00181qph70p3a7vm",
"details": [
{
"qty": 1,
"unit_price": 83500,
"sub_total": 83500,
"ID_product": "1"
},
{
"qty": 1,
"unit_price": 103000,
"sub_total": 103000,
"ID_product": "10"
}
],
"modification_date": "2022-03-24T20:21:03.120Z",
"creation_date": "2022-03-24T20:21:03.120Z"
}
```
```json=
// Response Status 201 Created
{
"message": "Pedido ingresado con exito",
"orderNote": {
"ID_order_note": "cl3otxt3j009360v12zre52ct",
"creation_date": "2022-03-24T20:21:03.000Z",
"created_by": "user.comes@gmail.com",
"modification_date": "2022-03-24T20:21:03.000Z",
"modificated_by": null,
"number": 18,
"neto": 156723,
"iva": 29777,
"total": 186500,
"type_discount": null,
"discount": null,
"total_order": 186500,
"comment_by_order": "asda",
"order_status": {
"ID_order_status": "1",
"status": "Recibido"
},
"store": {
"name": "Arket Emporio Vegano",
"bussines_name": "FRANK MARCELO KETTERER TORRES",
"rut": "12918110-9",
"email": "arket@gmail.com",
"phone": "56941063903"
},
"store_direction": {
"country": null,
"code_country": null,
"region": null,
"sub_region": null,
"municipality": null,
"street": "Prueba 2",
"number": "1234",
"label": null,
"local_or_office": null,
"reference": "",
"latitude": null,
"longitude": null
}
},
"detailOrderNotes": [
{
"ID_detail_order_note": "cl3otxt52009960v1fthwlz9h",
"qty": 1,
"unit_price": 83500,
"sub_total": 83500,
"comment_by_product": null,
"product": {
"ID_product": "1",
"sku": null,
"name": "Kombucha té blanco lavanda beterraga 330 cc",
"image": [
{
"ID_image": "1",
"file_image": "MKVioleta.jpg",
"name_image": "Kombucha Violeta",
"alt": "kombucha lavanda"
}
],
"producer": {
"ID_producer": "1",
"brand_name": "Moksha Kombucha"
}
},
"ID_order_note": "cl3otxt3j009360v12zre52ct"
},
{
"ID_detail_order_note": "cl3otxt52010060v1ktz0iv4e",
"qty": 1,
"unit_price": 103000,
"sub_total": 103000,
"comment_by_product": null,
"product": {
"ID_product": "10",
"sku": null,
"name": "Agua saborizada maqui berry 500 ml",
"image": [
{
"ID_image": "10",
"file_image": "aguamaquiberry500.jpg",
"name_image": "Agua Saborizada maqui berry 500",
"alt": "agua-saborizada-maqui-berry-500-ml"
}
],
"producer": {
"ID_producer": "2",
"brand_name": "SabroChile"
}
},
"ID_order_note": "cl3otxt3j009360v12zre52ct"
}
],
"detailCount": 2
}
```
Si numero de orden a ingresar ya existe en la base de datos:
```json=
// Response Status 400 Bad Request
{
"message": "No se ha podido ingresar el pedido. Numero debe ser unico"
}
```
* #### Get Last Order
```http
GET /api/v1/last/order
```
| Parameter | Type | Description |
| :-------- | :------- | :-------------------------------- |
| none | none | none |
```json=
// Response Status 200 Ok
{
"lastNumber": 18
}
```
* #### Get Order Status
```http
GET /api/v1/order/status
```
| Parameter | Type | Description |
| :-------- | :------- | :-------------------------------- |
| none | none | none |
```json=
//Response Status 200 Ok
{
"data": [
{
"ID_order_status": "0",
"status": "Borrador"
},
{
"ID_order_status": "1",
"status": "Recibido"
},
{
"ID_order_status": "2",
"status": "En Preparación"
},
{
"ID_order_status": "3",
"status": "Completado"
},
{
"ID_order_status": "4",
"status": "Cancelado"
}
]
}
```
* #### Get Order By ID Order
```http
GET /api/v1/order/${ID_order}
```
| Parameter | Type | Description |
| :-------- | :------- | :-------------------------------- |
| `ID_order`|`string` | ID de orden |
```json=
// Response Status 200 Ok
{
"orderNote": {
"ID_order_note": "cl3m0kqhe0091f0v1btfl0oy0",
"creation_date": "2022-05-25T20:03:36.000Z",
"created_by": null,
"modification_date": "2022-05-25T20:03:36.000Z",
"modificated_by": "matiasbarrera.comes@gmail.com",
"number": null,
"neto": 70168,
"iva": 13332,
"total": 83500,
"type_discount": null,
"discount": null,
"total_order": 83500,
"comment_by_order": "",
"order_status": {
"ID_order_status": "0",
"status": "Borrador"
},
"store": {
"name": "Arket Emporio Vegano",
"bussines_name": "FRANK MARCELO KETTERER TORRES",
"rut": "12918110-9",
"email": "fketteret@gmail.com",
"phone": "56941063903"
},
"store_direction": {
"country": null,
"code_country": null,
"region": null,
"sub_region": null,
"municipality": null,
"street": "San Martín",
"number": "710",
"label": null,
"local_or_office": null,
"reference": null,
"latitude": null,
"longitude": null
}
},
"detailOrderNotes": [
{
"ID_detail_order_note": "cl3m0kqjw0097f0v10y18ek2p",
"qty": 1,
"unit_price": 83500,
"sub_total": 83500,
"comment_by_product": null,
"product": {
"ID_product": "90",
"sku": null,
"name": "Caja mix 30 unidades de pastas 180-200 g ",
"image": [],
"producer": {
"ID_producer": "7",
"brand_name": "De La Casa"
}
},
"ID_order_note": "cl3m0kqhe0091f0v1btfl0oy0"
}
],
"productCount": 1
}
```
* #### Get All Order
```http
GET /api/v1/order
```
| Parameter | Type | Description |
| :-------- | :------- | :-------------------------------- |
| none | none | none |
```json=
// Response Status 200 Ok
{
"data": [
{
"orderNote": {
"ID_order_note": "cl3d7dzu50052n0v1a6t652g5",
"creation_date": "2022-03-07T18:13:52.000Z",
"modification_date": "2022-03-07T18:13:52.000Z",
"number": null,
"neto": 0,
"iva": 0,
"total": 0,
"type_discount": null,
"discount": null,
"total_order": 0,
"comment_by_order": "esto es un comentario de ejemplo 5",
"order_status": {
"ID_order_status": "1",
"status": "Recibido"
},
"store": {
"name": "Arket Emporio Vegano",
"bussines_name": "FRANK MARCELO KETTERER TORRES",
"rut": "12918110-9"
},
"store_direction": {
"country": null,
"code_country": null,
"region": null,
"sub_region": null,
"municipality": null,
"street": "San Martín",
"number": "710",
"label": null,
"local_or_office": null,
"reference": null,
"latitude": null,
"longitude": null
}
},
"detailOrderNote": []
},
{
"orderNote": {
"ID_order_note": "cl3c4o8ub0002pgv178d90y3w",
"creation_date": "2022-05-18T22:00:37.000Z",
"modification_date": "2022-05-18T22:00:37.000Z",
"number": null,
"neto": 70168,
"iva": 13332,
"total": 83500,
"type_discount": null,
"discount": null,
"total_order": 83500,
"comment_by_order": "",
"order_status": {
"ID_order_status": "0",
"status": "Borrador"
},
"store": {
"name": "Arket Emporio Vegano",
"bussines_name": "FRANK MARCELO KETTERER TORRES",
"rut": "12918110-9"
},
"store_direction": {
"country": "Chile",
"code_country": "CHL",
"region": "Región Metropolitana de Santiago",
"sub_region": "Santiago",
"municipality": "Quilicura",
"street": "Pasaje Los Maories",
"number": "0171",
"label": "Pasaje Los Maories 0171, Quilicura, Santiago, Región Metropolitana de Santiago, 8700000, CHL",
"local_or_office": "Casa",
"reference": "Casa celeste",
"latitude": "-33.36060999",
"longitude": "-70.72049998"
}
},
"detailOrderNote": []
}…
]
}
```
* #### Update status order note
```http
PATCH /api/v1/order/{ID_order_note}
```
| Parameter | Type | Description |
| :-------- | :------- | :-------------------------------- |
| ID_order_note | `string` | none |
| Body | Type | Description |
| :-------- | :------- | :-------------------------------- |
| ID_order_status | `string` | ID del nuevo estado |
```json=
// Request
// PATCH: /api/v1/order/cl3c5uvo30124lgv15tzih61q
// BODY:
{
"ID_order_status": "2",
"modificated_by" : "usuario.comes@gmail.com"
}
```
```json=
// Response status 200 Ok
{
"message": "Estado de la orden ID: cl3c5uvo30124lgv15tzih61q actualizada",
"newStatus": {
"ID_order_status": "2",
"status": "En Preparación"
},
"updOrderNote": {
"ID_order_note": "cl3c5uvo30124lgv15tzih61q",
"number": null,
"creation_date": "2022-03-07T18:13:52.000Z",
"created_by": null,
"modification_date": "2022-08-04T14:51:03.000Z",
"modificated_by": "usuario.comes@gmail.com"
}
}
```
Si no existe el estado en la BD
```json=
// Request
// PATCH /api/v1/order/cl3c5uvo30124lgv15tzih61q
// BODY:
{
"ID_order_status": "6",
"modificated_by" : "usuario.comes@gmail"
}
```
```json=
// Response status 400 Bad Request
{
"message": "No se ha podido actualizar el estado de la orden ID: cl3c5uvo30124lgv15tzih61q",
"error": "Estado de orden con ID: 6 no existe",
"orderStatus": null
}
```
### Producer 🔧🔨🛠
* #### Get Producer
```http
GET /api/v1/producer
```
### Category 🔧🔨🛠
### Product 🔧🔨🛠
## :rocket: API_PRODUCER
### Producer
* #### Get Producers
```http
GET /api/v1/producers
```
El endpoint puede o no resivir los siguientes `query parameters`:
| Qry Parameter | Examples | Description |
| :-------- | :------- | :-------------------------------- |
| `skip` |`skip=0` |omite la cantidad indicada|
| `take` |`take=40` |toma la cantidad indicada desde el skip|
| `isActive` | `isActive=true\false` |true para productores activos o false para productores inactivos|
| `categories` |`categories=Frutas, Mermeladas y manjares` |Nombre de la categoria separados por coma (,)|
| `categoryTypes` |`categoryTypes=Frescos, agroprocesados`|Nombre del typo de categoria separados por coma
| `region` |`region=Región Del Bio Bio`|nombre de la region (como este en BD)|
|`q`|`q=frescos`|valor ingresado en la barra de busqueda|
Ejemplo:
```http
GET /api/v1/producers?skip=0&take=40&categories=["1"]&categoryTypes=["2"]&isActive=true
```
```json=
// Response Status 200 Ok
{
"data": [
{
"ID_producer": "cl4n9laap0110r7pifxb8ut2s",
"brand_name": "dffsf",
"rut": "43434",
"additional_info": "",
"web": "",
"isActive": true,
"isPublished": true,
"isDeleted": false,
"contact": [
{
"name": "prueba222",
"phone": "32323232",
"email": "qq@live.cl"
}
],
"files": [
{
"ID_files": "cl4n9laap0115r7pi456bk971",
"file_name": "422dd6ed-2cc8-42c3-8288-8c5e63be07d6-Copia de foto-home.jpg"
}
],
"direction": [
{
"ID_direction": "cl4n9laap0113r7pi7ljuth4o",
"label": "Santiago, Región Metropolitana de Santiago, CHL",
"country": "Chile",
"region": "Región Metropolitana de Santiago",
"sub_region": "Santiago",
"municipality": "Santiago",
"street": null,
"number": null,
"latitud": "-33.43722",
"longitud": "-70.65002"
}
],
"producer_category": [
{
"ID_producer_category": "cl4n9laaq0119r7pikw6luvs3",
"category": {
"ID_category": "1",
"category": "Aceites, sales y condimentos",
"category_type": {
"ID_category_type": "2",
"type": "agroprocesados"
}
}
}
]
},
{
"ID_producer": "cl4na669e0173r7pi59llqik4",
"brand_name": "dsdsa",
"rut": "232313",
"additional_info": "",
"web": "",
"isActive": true,
"isPublished": true,
"isDeleted": false,
"contact": [
{
"name": "prueba222",
"phone": "32323232",
"email": "qq@live.cl"
}
],
"files": [
{
"ID_files": "cl4na669f0178r7pi9dcvosv2",
"file_name": "3d7be894-ec9f-4cb6-b3a0-f981c5367dba-Copia de foto-home.jpg"
}
],
"direction": [
{
"ID_direction": "cl4na669e0176r7piyrh6vnct",
"label": "Santïag, Kleerkopersstraat 53, 1000, Brussel, BEL",
"country": null,
"region": "Brussel",
"sub_region": "Brussel",
"municipality": "Brussel",
"street": null,
"number": null,
"latitud": "50.84928",
"longitud": "4.35295"
}
],
"producer_category": [
{
"ID_producer_category": "cl4na669f0183r7pihbvb4n80",
"category": {
"ID_category": "1",
"category": "Aceites, sales y condimentos",
"category_type": {
"ID_category_type": "2",
"type": "agroprocesados"
}
}
}
]
}
],
"producerCount": 2
}
```
Si no se encuentran productores
```json=
// Response Status 400 Bad request
{
"producerCount": 0,
"message": "No hay productores disponibles"
}
```
* #### Get Producers
```http
GET /api/v1/producer/${rut}
```
| Params | Type | Description |
| :-------- | :------- | :-------------------------------- |
| rut | string | rut del productor |
Si rut no existe
```json=
// Response Status 200 ok
{
"message": "Rut no registrado",
"exists": false,
"rutTyped": "111111"
}
```
Si rut existe
```json=
// Response status 400 Bad Request
{
"message": "Rut ya existe en la BD",
"exists": true,
"rutTyped": "191639804"
}
```
### Direction
* #### Get Regions
```http
GET /api/v1/regions
```
| Params | Type | Description |
| :-------- | :------- | :-------------------------------- |
| none | none | none |
```json=
// Response Status 200 Ok
{
"regions": [
{
"ID_direction": "cl4n294x800121kv165l63h9q",
"region": "Región Del Bio Bio"
},
{
"ID_direction": "cl4n2ai690012jsv1mr1t8x9l",
"region": "Región Metropolitana de Santiago"
},
{
"ID_direction": "cl4ptfs4d5342ukv184jsqvz6",
"region": "Region de Arica y Parinacota"
}
]
}
```
En caso de no haber regiones disponibles
```json=
// Response Status 400 Bad request
{
"message": "No se encontraron regiones",
}
```
### Request producer
* #### Post Request producer
```http
POST /api/v1/request/producer
```
| Body | Type | Description |
| :-------- | :------- | :-------------------------------- |
| `name` | `string` | **Requerido** Nombre de quien hace la solicitud |
| `phone` | `string` | **Requerido** Telefono de quien hace la solicitud |
| `email` | `string` | **Requerido** Email de quien hace la solicitud |
| `message` | `string` | **Requerido** Mensaje para el productor |
| `created_at` | `datetime` | **Requerido** Fecha y hora de la solicitud |
```json=
// Request body
{
"name": "Jhon Doe",
"phone" :"9332244556",
"email" : "jhon.deo@hotmail.com",
"message": "Hola, me interesan tus productos.",
"created_at": "2022-06-15T20:55:44.705Z",
"ID_producer": "cl4n294x800091kv1phy56tl9"
}
```
```json=
// Response Status 200 Ok
{
"message": "Registro de solicitud ingresado correctamente",
"requestProducer": {
"ID_request_producer": "cl4zuyztt0002u0v1pv9gh0sg",
"name": "Jhon Doe",
"phone": "9332244556",
"email": "jhon.deo@hotmail.com",
"message": "Hola, me interesan tus productos.",
"created_at": "2022-06-15T20:55:45.000Z",
"ID_producer": "cl4n294x800091kv1phy56tl9"
}
}
```
Si no se indican los datos requeridos
```json=
// Response Status 400 Bad request
{
"error": [
{
"msg": "Campo nombre es requerido",
"param": "name",
"location": "body"
},
{
"msg": "Campo telefono es requerido",
"param": "phone",
"location": "body"
},
{
"msg": "Campo email es requerido",
"param": "email",
"location": "body"
},
{
"msg": "Campo mensaje es requerido",
"param": "message",
"location": "body"
},
{
"msg": "Campo fecha de creacion es requerido",
"param": "created_at",
"location": "body"
},
{
"msg": "Campo ID de productor es requerido",
"param": "ID_producer",
"location": "body"
}
]
}
```