<style>
span.method {
color: white;
padding: 6px 8px;
border-radius: 4px;
margin-right: 12px;
}
.get { background-color: green; }
.post { background-color: orange; }
.delete { background-color: firebrick; }
.patch { background-color: navy; }
.model { display: flex; align-items: center; color: #333;}
.model .icon {
width: 24px;
height: 24px;
margin-right: 4px;
background-size: contain;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' aria-hidden='true' role='img' class='icon' width='32' height='32' preserveAspectRatio='xMidYMid meet' viewBox='0 0 24 24'%3E%3Cg fill='none' stroke='%23333' stroke-linecap='round' stroke-linejoin='round' stroke-width='2'%3E%3Cpath d='M8 8h8v8H8z'%3E%3C/path%3E%3Crect width='16' height='16' x='4' y='4' rx='2'%3E%3C/rect%3E%3Cpath d='m16 16l3.3 3.3M16 8l3.3-3.3M8 8L4.7 4.7M8 16l-3.3 3.3'%3E%3C/path%3E%3C/g%3E%3C/svg%3E");
}
.partial { font-size: 12px; padding: 2px 6px; border-radius: 4px; background: #eee; margin-right: 8px;}
details .collapse {
background: #f1f1f1;
padding: 8px;
border-radius: 6px;
display: flex;
}
</style>
# Procurement API
## Endpoints
### List procurement items
<strong><span class="method get">GET</span> <code>/procurement-item</code></strong>
#### Query Params
```yaml=
limit?: number = 100
offset?: number = 0
since?: Date = null
until?: Date = null
id_shopper?: string
```
#### Response
<details>
<summary>
<code>200</code> Procurement items successfully fetched
</summary>
> The contents of the fetched procurement items
<a href="#ProcurementItem" class="model">
<span class="partial">List of</span>
<div class="icon"></div>
<strong>Procurement Item</strong>
</a>
</details>
---
### Get a procurement item
<strong><span class="method get">GET</span> <code>/procurement-item/:id</code></strong>
#### Path params
`id` → The ID of the procurement item to be fetched
#### Response
<details>
<summary>
<code>200</code> Procurement item successfully found
</summary>
> The contents of the fetched procurement item
<a href="#ProcurementItem" class="model">
<div class="icon"></div>
<strong>Procurement Item</strong>
</a>
</details>
<details>
<summary>
<code>404</code> Procurement item not found
</summary>
```json
{
"error": true,
"message": "Resource not found",
"code": "ERR_RESOURCE_NOT_FOUND"
}
```
</details>
---
### Create a procurement item
<strong><span class="method post">POST</span> <code>/procurement-item</code></strong>
#### Request body
<details>
<summary>Add a single item</summary>
<div class="collapse">
<a href="#ProcurementItem" class="model">
<div class="icon"></div>
<strong>Procurement Item</strong>
</a>
</div>
</details>
<details style="margin-top: 6px">
<summary>Add multiple items</summary>
<div class="collapse">
<a href="#ProcurementItem" class="model">
<span class="partial">List of</span>
<div class="icon"></div>
<strong>Procurement Item</strong>
</a>
</div>
</details>
#### Response
<details>
<summary>
<code>200</code> Procurement item successfully created
</summary>
> The contents of the created procurement items
<a href="#ProcurementItem" class="model">
<span class="partial">List of</span>
<div class="icon"></div>
<strong>Procurement Item</strong>
</a>
</details>
<details>
<summary>
<code>400</code> Request body malformed
</summary>
> The structure of the request payload is incorrect
```json
{
"error": true,
"message": "Request body malformed",
"details": {
"missing": ["field"],
"invalid": ["field"],
},
"code": "ERR_REQUEST_BODY_MALFORMED"
}
```
</details>
---
### Update a procurement item
<strong><span class="method patch">PATCH</span> <code>/procurement-item/:id</code></strong>
#### Path params
`id` → The ID of the procurement item to be updated
#### Request body
<a href="#ProcurementItem" class="model">
<span class="partial">Partial</span>
<div class="icon"></div>
<strong>Procurement Item</strong>
</a>
#### Response
<details>
<summary>
<code>200</code> Procurement item successfully updated
</summary>
> The contents of the updated procurement item
<a href="#ProcurementItem" class="model">
<div class="icon"></div>
<strong>Procurement Item</strong>
</a>
</details>
<details>
<summary>
<code>400</code> Request body malformed
</summary>
> The structure of the request payload is incorrect
```json
{
"error": true,
"message": "Request body malformed",
"details": {
"missing": ["field"],
"invalid": ["field"],
},
"code": "ERR_REQUEST_BODY_MALFORMED"
}
```
</details>
<details>
<summary>
<code>404</code> Procurement item not found
</summary>
```json
{
"error": true,
"message": "Resource not found",
"code": "ERR_RESOURCE_NOT_FOUND"
}
```
</details>
---
### Delete a procurement item
<strong><span class="method delete">DELETE</span> <code>/procurement-item/:id</code></strong>
#### Path params
`id` → The ID of the procurement item to be deleted
#### Response
<details>
<summary>
<code>200</code> Procurement item successfully deleted
</summary>
> The contents of the deleted item
<a href="#ProcurementItem" class="model">
<div class="icon"></div>
<strong>Procurement Item</strong>
</a>
</details>
<details>
<summary>
<code>404</code> Procurement item not found
</summary>
```json
{
"error": true,
"message": "Resource not found",
"code": "ERR_RESOURCE_NOT_FOUND"
}
```
</details>
---
### List procurement buy events
<strong><span class="method get">GET</span> <code>/procurement-buy-event</code></strong>
#### Query Params
```yaml=
limit?: number = 100
offset?: number = 0
since?: Date = null
until?: Date = null
id_procurement_item?: string
```
#### Response
<details>
<summary>
<code>200</code> Procurement buy events successfully fetched
</summary>
> The contents of the fetched procurement buy events
<a href="#ProcurementBuyEvent" class="model">
<span class="partial">List of</span>
<div class="icon"></div>
<strong>Procurement Buy Event</strong>
</a>
</details>
---
### Get a procurement item
<strong><span class="method get">GET</span> <code>/procurement-buy-event/:id</code></strong>
#### Path params
`id` → The ID of the procurement buy event to be fetched
#### Response
<details>
<summary>
<code>200</code> Procurement buy event successfully found
</summary>
> The contents of the fetched procurement buy event
<a href="#ProcurementBuyEvent" class="model">
<div class="icon"></div>
<strong>Procurement Buy Event</strong>
</a>
</details>
<details>
<summary>
<code>404</code> Procurement item not found
</summary>
```json
{
"error": true,
"message": "Resource not found",
"code": "ERR_RESOURCE_NOT_FOUND"
}
```
</details>
---
### Create a procurement buy event
<strong><span class="method post">POST</span> <code>/procurement-buy-event</code></strong>
#### Request body
<details>
<summary>Add a single buy event</summary>
<div class="collapse">
<a href="#ProcurementBuyEvent" class="model">
<div class="icon"></div>
<strong>Procurement Buy Event</strong>
</a>
</div>
</details>
<details style="margin-top: 6px">
<summary>Add multiple buy events</summary>
<div class="collapse">
<a href="#ProcurementBuyEvent" class="model">
<span class="partial">List of</span>
<div class="icon"></div>
<strong>Procurement Buy Event</strong>
</a>
</div>
</details>
#### Response
<details>
<summary>
<code>200</code> Procurement buy event successfully created
</summary>
> The contents of the created procurement buy events
<a href="#ProcurementBuyEvent" class="model">
<span class="partial">List of</span>
<div class="icon"></div>
<strong>Procurement Buy Event</strong>
</a>
</details>
<details>
<summary>
<code>400</code> Request body malformed
</summary>
> The structure of the request payload is incorrect
```json
{
"error": true,
"message": "Request body malformed",
"details": {
"missing": ["field"],
"invalid": ["field"],
},
"code": "ERR_REQUEST_BODY_MALFORMED"
}
```
</details>
---
### Update a procurement buy event
<strong><span class="method patch">PATCH</span> <code>/procurement-buy-event/:id</code></strong>
#### Path params
`id` → The ID of the procurement buy event to be updated
#### Request body
<a href="#ProcurementBuyEvent" class="model">
<span class="partial">Partial</span>
<div class="icon"></div>
<strong>Procurement Buy Event</strong>
</a>
#### Response
<details>
<summary>
<code>200</code> Procurement buy event successfully updated
</summary>
> The contents of the updated procurement buy event
<a href="#ProcurementBuyEvent" class="model">
<div class="icon"></div>
<strong>Procurement Buy Event</strong>
</a>
</details>
<details>
<summary>
<code>400</code> Request body malformed
</summary>
> The structure of the request payload is incorrect
```json
{
"error": true,
"message": "Request body malformed",
"details": {
"missing": ["field"],
"invalid": ["field"],
},
"code": "ERR_REQUEST_BODY_MALFORMED"
}
```
</details>
<details>
<summary>
<code>404</code> Procurement buy event not found
</summary>
```json
{
"error": true,
"message": "Resource not found",
"code": "ERR_RESOURCE_NOT_FOUND"
}
```
</details>
---
### Delete a procurement buy event
<strong><span class="method delete">DELETE</span> <code>/procurement-buy-event/:id</code></strong>
#### Path params
`id` → The ID of the procurement buy event to be deleted
#### Response
<details>
<summary>
<code>200</code> Procurement buy event successfully deleted
</summary>
> The contents of the deleted buy event
<a href="#ProcurementBuyEvent" class="model">
<div class="icon"></div>
<strong>Procurement Buy Event</strong>
</a>
</details>
<details>
<summary>
<code>404</code> Procurement buy event not found
</summary>
```json
{
"error": true,
"message": "Resource not found",
"code": "ERR_RESOURCE_NOT_FOUND"
}
```
</details>
## Models
### ProcurementItem
```yaml
id: UUID
updated_at: Date
created_at: Date
deleted_at: Date
id_shopper: UUID
id_raw_product: UUID
id_quality_type: UUID
id_maturation_type: UUID
id_provider: UUID
total_units: Numeric
total_weight: Numeric
total_boxes: Numeric
total_units_in_stock: Numeric
total_weight_in_stock: Numeric
total_boxes_in_stock: Numeric
tags: JSONB
```
### ProcurementBuyEvent
```yaml
id: UUID
updated_at: Date
created_at: Date
deleted_at: Date | NULL
id_procurement_item: UUID
price: Number # In cents
units: Number
weight: Number
boxes: Number
```