Issue #51: discriminacion y administracion de categorias de productos. - ProductCategoryAdmin con list_display/filtro por active - doc/requests.org: GET/PATCH product_categories, import_from_external, deactivate, activate
186 lines
4.8 KiB
Org Mode
186 lines
4.8 KiB
Org Mode
* Requests
|
|
Ejemplo de request contra la api usando [[https://github.com/federicotdn/verb][verb]]
|
|
|
|
** Autenticación :verb:
|
|
template http://localhost:7000/api
|
|
Content-Type: application/json;
|
|
*** Solicitar token
|
|
post /token/
|
|
|
|
{
|
|
"username": "admin",
|
|
"password": "admin"
|
|
}
|
|
**** respuesta
|
|
#+begin_src json
|
|
{
|
|
"refresh": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTc4MDExNTc0NywiaWF0IjoxNzgwMDI5MzQ3LCJqdGkiOiIxNmVjZGMxZmY4Y2Y0MzA4ODM3ZjM5Y2ZiNjQwNmZiMCIsInVzZXJfaWQiOiIxIn0.wmN-wp3Izv0NrfL_ap_i8eyg29w-foHNrQCCL6HoZWg",
|
|
"access": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzgwMDMxMTQ3LCJpYXQiOjE3ODAwMjkzNDcsImp0aSI6ImQ4ZjE1YTRmODc5NzRjZGViZDEzYzc1ZTU4ZDk3ZjEwIiwidXNlcl9pZCI6IjEifQ.kkQVT2pcYeS_TxlJ6QPU3rNOlZhOv96pyqVEGJI85KA"
|
|
}
|
|
#+end_src
|
|
*** Perfil de usuario
|
|
get /users/me/
|
|
Authorization:Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzgwMDA2MzU4LCJpYXQiOjE3ODAwMDQ1NTgsImp0aSI6IjkwNzY4OGU2MmNlNTQ1M2JiYzU5MTA2MDhmMjY1MmY5IiwidXNlcl9pZCI6IjEifQ.aFls9WyA1VuDeMMUu8t7Pa9CbbLfyvIg9pB9xIxydpU
|
|
**** Respuesta
|
|
#+begin_src json
|
|
{
|
|
"id": 1,
|
|
"username": "admin",
|
|
"email": "admin@admin.org",
|
|
"first_name": "",
|
|
"last_name": "",
|
|
"role": "administrator"
|
|
}
|
|
#+end_src
|
|
*** Renovar token
|
|
post /token/refresh/
|
|
|
|
{
|
|
"refresh": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTc3ODU1Njc5MywiaWF0IjoxNzc4NDcwMzkzLCJqdGkiOiJlMDU0NTVkNWExYzA0YjFkYWZhNWZkNzFkZGM5Mzc1NyIsInVzZXJfaWQiOiIxIn0.wZcbBrGoxDMPjZxI-GR1GTAuRtzU4qaT0rgGS5Oblf4"
|
|
}
|
|
**** response
|
|
#+begin_src json
|
|
{
|
|
"access": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzc4NDcyMjQ5LCJpYXQiOjE3Nzg0NzA0NDksImp0aSI6IjE5YTM0ZDQ5Mzk3ZDQzNGE4NDlkZTgyYzdkNWQyNjQ0IiwidXNlcl9pZCI6IjEifQ.jowmaa5SXKIWpmUGLV0dj9CydYFtuecc7s_RveJvjLA"
|
|
}
|
|
#+end_src
|
|
** Don confiao :verb:
|
|
template http://localhost:7000/don_confiao/api/
|
|
Content-Type: application/json;
|
|
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzgwMDMxMTQ3LCJpYXQiOjE3ODAwMjkzNDcsImp0aSI6ImQ4ZjE1YTRmODc5NzRjZGViZDEzYzc1ZTU4ZDk3ZjEwIiwidXNlcl9pZCI6IjEifQ.kkQVT2pcYeS_TxlJ6QPU3rNOlZhOv96pyqVEGJI85KA
|
|
*** todas las rutas
|
|
get
|
|
**** response
|
|
#+begin_src json
|
|
{
|
|
"sales": "http://localhost:7000/don_confiao/api/sales/",
|
|
"catalog_sales": "http://localhost:7000/don_confiao/api/catalog_sales/",
|
|
"customers": "http://localhost:7000/don_confiao/api/customers/",
|
|
"products": "http://localhost:7000/don_confiao/api/products/",
|
|
"reconciliate_jar": "http://localhost:7000/don_confiao/api/reconciliate_jar/"
|
|
}
|
|
#+end_src
|
|
*** customers
|
|
get customers/
|
|
**** response
|
|
#+begin_src json
|
|
[
|
|
{
|
|
"id": 1,
|
|
"name": "Consumidor Final",
|
|
"address": "",
|
|
"email": "",
|
|
"phone": "",
|
|
"external_id": "2753"
|
|
},
|
|
...
|
|
]
|
|
#+end_src
|
|
*** products
|
|
get products/
|
|
|
|
*** Productos Inactivos
|
|
get products/?active=false
|
|
|
|
*** Productos Activos
|
|
get products/?active=true
|
|
|
|
*** Traer todos los productos
|
|
get products/?active=all
|
|
|
|
*** Inactiva productos
|
|
patch products/1
|
|
|
|
{
|
|
"active": false
|
|
}
|
|
|
|
*** Obtener Ventas por catalogo
|
|
get catalog_sales/
|
|
|
|
**** response
|
|
#+begin_src json
|
|
{
|
|
"id": 6,
|
|
"customer": 1,
|
|
"date": "2024-09-02T00:00:00Z",
|
|
"catalogsaleline_set": [
|
|
{
|
|
"id": 2,
|
|
"catalog_sale": 6,
|
|
"product": 1,
|
|
"unit_price": "3000.00",
|
|
"quantity": "2.00"
|
|
},
|
|
{
|
|
"id": 3,
|
|
"catalog_sale": 6,
|
|
"product": 1,
|
|
"unit_price": "5000.00",
|
|
"quantity": "3.00"
|
|
}
|
|
],
|
|
"total": 21000.0
|
|
}
|
|
|
|
*** Crear una venta por catalogo
|
|
post catalog_sales/
|
|
|
|
{"customer": "1", "date": "2024-09-02", "catalogsaleline_set": [{"product": "1", "quantity": "2", "unit_price": "3000"}, {"product": "1", "quantity": "3", "unit_price": "5000"}]}
|
|
|
|
*** Importar Clientes de Tryton
|
|
post importar_productos_de_tryton
|
|
|
|
{}
|
|
|
|
**** response
|
|
#+begin_src json
|
|
[]
|
|
#+end_src
|
|
|
|
*** Categorías de productos
|
|
La fuente de categorías es Tryton. name y external_id son solo lectura; Don
|
|
Confiao administra description, alternative_name y active.
|
|
|
|
**** Listar categorías
|
|
get product_categories/?active=all
|
|
get product_categories/?active=true
|
|
get product_categories/?active=false
|
|
|
|
**** Actualizar campos administrados por Don Confiao
|
|
patch product_categories/1/
|
|
|
|
#+begin_src json
|
|
{
|
|
"description": "Granos enteros",
|
|
"alternative_name": "Cereales",
|
|
"active": false
|
|
}
|
|
#+end_src
|
|
|
|
**** Importar categorías desde Tryton
|
|
Solo importa las categorías asociadas a productos salables; no borra
|
|
categorías locales. Requiere administrador.
|
|
|
|
post product_categories/import_from_external
|
|
|
|
{}
|
|
|
|
**** Desactivar categorías
|
|
post product_categories/deactivate/
|
|
|
|
#+begin_src json
|
|
{
|
|
"ids": [1, 2]
|
|
}
|
|
#+end_src
|
|
|
|
**** Activación de categorías
|
|
post product_categories/activate/
|
|
|
|
#+begin_src json
|
|
{
|
|
"ids": [1, 2]
|
|
}
|
|
#+end_src
|