Skip to content
Sergio Infante edited this page May 5, 2016 · 27 revisions

Backend Belatrix AllStars

This document is under construction.

Endpoints reference

Authentication

/api/auth/password/

  • Method: POST
  • Parameters: new_password=XXXX&re_new_password=XXXX&current_password=ZZZZ (need token)
  • Expected result: User password changed
  • Example:

curl -X POST http://localhost:8000/api/auth/password/ --data 'new_password=foo&re_new_password=foo&current_password=bar' -H 'Authorization: Token bd7a47429f4008d72a50ef419b8b600cfb973f35'

Documentation

/api/docs/

  • Expected result: Swagger API Documentation (web browser)

Swagger API

Employee

/api/employee/authenticate/

  • Method: POST
  • Parameters: username=usuario&password=clave
  • Expected result: Authentication flow, return token and user_id
  • Example:

curl -X POST -d "username=usuario&password=clave" http://localhost:8000/api/employee/authenticate/

/api/employee/create/

  • Method: POST
  • Parameters: email=[email protected]
  • Expected result: User created.
  • Example:

curl -X POST http://localhost:8000/api/employee/create/ -d "[email protected]"

/api/employee/list/

  • Method: GET
  • Expected result: Employee complete list
  • Example:

curl -X GET http://localhost:8000/api/employee/list/

/api/employee/role/list/

  • Method: GET
  • Expected result: Employee complete role list
  • Example:

curl -X GET http://localhost:8000/api/employee/role/list/

/api/employee/location/list/

  • Method: GET
  • Expected result: Employee complete location list
  • Example:

curl -X GET http://localhost:8000/api/employee/location/list/

/api/employee/list/top/{kind}/{quantity}/

  • Method: GET
  • Header: Authorization(Token <token_number>)
  • Parameters: {kind}(level, top), {quantity}(number of results)
  • Expected result: Employee top level or top score list
  • Example:

curl -X GET http://localhost:8000/api/employee/top/level/1/ -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'

/api/employee/{employee_id}/

  • Method: GET
  • Parameters: {employee_id}(employee primary key or id)
  • Expected result: Employee detail
  • Example:

curl -X GET http://localhost:8000/api/employee/1/

/api/employee/{employee_id}/activate/

  • Method: PATCH
  • Parameters: {employee_id}(employee primary key or id)
  • Expected result: Employee is_active set to True
  • Example:

curl -X PATCH http://localhost:8000/api/employee/1/activate/

/api/employee/{employee_id}/avatar/

  • Method: GET
  • Parameters: {employee_id}(employee primary key or id)
  • Expected result: Employee avatar
  • Example:

curl -X GET http://localhost:8000/api/employee/1/avatar/

/api/employee/{employee_id}/category/list/

  • Method: GET
  • Parameters: {employee_id}(employee primary key or id)
  • Expected result: Categories allowed to give stars from employees.
  • Example:

curl -X GET http://localhost:8000/api/employee/1/category/list/

/api/employee/{employee_id}/deactivate/

  • Method: PATCH
  • Parameters: {employee_id}(employee primary key or id)
  • Expected result: Employee is_active set to False
  • Example:

curl -X PATCH http://localhost:8000/api/employee/1/deactivate/

/api/employee/search/{search_term}/

  • Method: GET
  • Parameters: {search_term}
  • Expected result: Employee list using search term.
  • Example:

curl -X GET http://localhost:8000/api/employee/search/luis/

Category

/api/category/{category_id}/subcategory/list/

  • Method: GET
  • Parameters: {category_id}(category primary key or id)
  • Expected result: Subcategory list of Categories.
  • Example:

curl -X GET http://localhost:8000/api/category/1/subcategory/list/

/api/category/list/

  • Method: GET
  • Expected result: Category list
  • Example:

curl -X GET http://localhost:8000/api/category/list/

/api/category/subcategory/{subcategory_id}/

  • Method: GET
  • Expected result: Subcategory details, including list of categories.
  • Example:

curl -X GET http://localhost:8000/api/category/subcategory/1/

Stars

/api/stars/{employee_id}/list/

  • Method: GET
  • Parameters: {employee_id}(employee primary key or id)
  • Expected result: Employee stars list.
  • Example:

curl -X GET http://localhost:8000/api/stars/1/list/

/api/stars/{employee_id}/give/star/to/{employee_id}/

  • Method: POST
  • Parameters: {employee_id}(employee primary key or id), comment=comentario&subcategory_id=1
  • Expected result: Employee give star to Employee by Id and save comments and subcategory.
  • Example:

curl -X POST -d "comment=comentario&subcategory=1" http://localhost:8000/api/stars/1/give/star/to/2/

/api/stars/{employee_id}/subcategory/list/

  • Method: GET
  • Parameters: {employee_id}(employee primary key or id)
  • Expected result: Employee stars list grouped by subcategories.
  • Example:

curl -X GET http://localhost:8000/api/stars/2/subcategory/list/

/api/stars/{employee_id}/subcategory/{subcategory_id}/list/

  • Method: GET
  • Parameters: {employee_id}(employee primary key or id), {subcategory_id}(subcategory primary key or id)
  • Expected result: Employee stars detailed list by subcategory.
  • Example:

curl -X GET http://localhost:8000/api/stars/2/subcategory/3/list/

/api/stars/{star_id}/

  • Method: GET
  • Parameters: {star_id}(star primary key or id)
  • Expected result: star detail
  • Example:

curl -X GET http://localhost:8000/api/stars/5/

/api/stars/top/{top_number}/{kind}/{id}/

  • Method: GET
  • Parameters: {top_number}(quantity of results), {kind}(category or subcategory), {id}(category or subcategory id)
  • Expected result: Top list of employee stars (quantity) by category or subcategory
  • Example of top 5 in category 1:

curl -X GET http://localhost:8000/api/stars/top/5/category/1/