-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Gilson Paulino edited this page Oct 27, 2019
·
11 revisions
Endpoins usados para o cadastro de novos usuários e autenticação
Todos os endpoints precisa de autenticação. Basta enviar o
access token
retornado nesse endpoint conforme o modelo abaixo:
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNTc0ODAwMzE5LCJqdGkiOiI3MDQxMjkxMTRhZGI0YzE5ODhjN2RiNzY2MjcyYTBlNiIsInVzZXJfaWQiOiI2MGQ3NGU3Ni0zMzBhLTQxN2YtODdmMC00YTQ5MDJjMGE4ZmYifQ.aPDJfX55FBiUPP5J85DWp9xPYxTaSYUGLIZat8AAC6I
-
POST:
/token
- Payload:
{
"email": "[email protected]",
"password": "minhasenha"
}
- Response:
Retorna os tokens para as próximas requisições
{
"refresh": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTU3MjI5NDcxOSwianRpIjoiMDBlNTZjNzcxOWEwNDQwMWEwNjcyODZhNTI1M2E3ZjciLCJ1c2VyX2lkIjoiNjBkNzRlNzYtMzMwYS00MTdmLTg3ZjAtNGE0OTAyYzBhOGZmIn0.kXaCaPgW7YlKTEBuja-tV8yWincmIiONeCvUHBAekgA",
"access": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNTc0ODAwMzE5LCJqdGkiOiI3MDQxMjkxMTRhZGI0YzE5ODhjN2RiNzY2MjcyYTBlNiIsInVzZXJfaWQiOiI2MGQ3NGU3Ni0zMzBhLTQxN2YtODdmMC00YTQ5MDJjMGE4ZmYifQ.aPDJfX55FBiUPP5J85DWp9xPYxTaSYUGLIZat8AAC6I"
}
-
POST:
/token/refresh
- Payload:
{
"refresh": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTU3MjI5NDcxOSwianRpIjoiMDBlNTZjNzcxOWEwNDQwMWEwNjcyODZhNTI1M2E3ZjciLCJ1c2VyX2lkIjoiNjBkNzRlNzYtMzMwYS00MTdmLTg3ZjAtNGE0OTAyYzBhOGZmIn0.kXaCaPgW7YlKTEBuja-tV8yWincmIiONeCvUHBAekgA"
}
- Response:
Retorna o token
access
atualizado
{
"access": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNTc0ODAwMzE5LCJqdGkiOiI3MDQxMjkxMTRhZGI0YzE5ODhjN2RiNzY2MjcyYTBlNiIsInVzZXJfaWQiOiI2MGQ3NGU3Ni0zMzBhLTQxN2YtODdmMC00YTQ5MDJjMGE4ZmYifQ.aPDJfX55FBiUPP5J85DWp9xPYxTaSYUGLIZat8AAC6I"
}
-
POST:
/simauth/users/
- Payload:
{
"email": "[email protected]",
"password": "123456",
"name": "Teste User",
"is_superuser": true
}
- Response:
{
"id": "90f17e3a-feed-47f3-8a34-869c7112c1b0",
"email": "[email protected]",
"name": "Teste User",
"is_superuser": true
}
-
PATCH:
/simauth/users/{id}/
- Payload:
{
"name": "User Teste 2",
"is_superuser": false
}
- Response:
{
"id": "90f17e3a-feed-47f3-8a34-869c7112c1b0",
"email": "[email protected]",
"name": "User Teste 2",
"is_superuser": false
}
-
GET:
/simauth/users/{id}
- Response:
{
"id": "90f17e3a-feed-47f3-8a34-869c7112c1b0",
"email": "[email protected]",
"name": "Gilson Paulino",
"is_superuser": true
}
-
GET:
/simauth/users
- Response:
{
"count": 8,
"next": null,
"previous": null,
"results": [
{
"id": "60d74e76-330a-417f-87f0-4a4902c0a8ff",
"email": "[email protected]",
"name": "Teste User",
"is_superuser": true
},
{
"id": "ce8f42be-c949-4c1d-b6a0-5e715ad5a9f9",
"email": "[email protected]",
"name": "Teste User 1",
"is_superuser": false
},
{...}
]
}
-
DELETE:
/simauth/users/{id}
- Response:
Retorno
204 No Content
O módulo capital refere-se ao core do sistema onde é possível cadastrar CapitalUser, herança de usuários do sistema e Salary, movimentação de salários do usuário.
-
POST:
/capital/users/
- Payload:
{
"email": "[email protected]",
"name": "User Teste",
"cpf": "12345678901",
"birth_date": "1984-10-27"
}
- Response:
{
"id": "d216dfac-42e0-4053-a104-a06be8fb1412",
"email": "[email protected]",
"name": "User Teste",
"cpf": "12345678901",
"birth_date": "1984-10-27",
"avg_salary": 0,
"avg_discount": 0,
"max_salary": 0,
"min_salary": 0
}
-
PATCH:
/capital/users/{id}/
- Payload:
{
"cpf": "12345678902"
}
- Response:
{
"id": "d216dfac-42e0-4053-a104-a06be8fb1412",
"email": "[email protected]",
"name": "User Teste",
"cpf": "12345678902",
"birth_date": "1984-10-27",
"avg_salary": 0,
"avg_discount": 0,
"max_salary": 0,
"min_salary": 0
}
-
GET:
/capital/users/{id}
- Response:
{
"id": "d216dfac-42e0-4053-a104-a06be8fb1412",
"email": "[email protected]",
"name": "User Teste",
"cpf": "12345678902",
"birth_date": "1984-10-27",
"avg_salary": 0,
"avg_discount": 0,
"max_salary": 0,
"min_salary": 0
}
-
GET:
/capital/users
- Response:
{
"count": 5,
"next": null,
"previous": null,
"results": [
{
"id": "4b23860e-072b-4f33-be5d-c3a2e4f05118",
"email": "[email protected]",
"name": "User Teste",
"cpf": "12345678901",
"birth_date": "1984-10-27",
"avg_salary": 3050.3,
"avg_discount": 260.6,
"max_salary": 3050.3,
"min_salary": 3050.3
},
{
"id": "fa7fcfb8-b314-4e23-b3c7-345ddb4ae5a7",
"email": "[email protected]",
"name": "User Teste 1",
"cpf": "12345678901",
"birth_date": "1983-10-27",
"avg_salary": 0,
"avg_discount": 0,
"max_salary": 0,
"min_salary": 0
},
{...}
]
}
-
DELETE:
/capital/users/{id}
- Response:
Retorno
204 No Content
É necessário o ID de um Usuário Capital para adicionar um salário
-
POST:
/capital/salaries/
- Payload:
{
"capital_user": "4b23860e-072b-4f33-be5d-c3a2e4f05118",
"salary_date": "2019-11-02",
"salary_value": "3050.30",
"salary_discount": "260.60"
}
- Response:
{
"id": 2,
"cpf": "12345678901",
"salary_date": "2019-11-02",
"salary_value": "3050.30",
"salary_discount": "260.60",
"created_at": "2019-10-27T15:55:28.611385-03:00",
"capital_user": "4b23860e-072b-4f33-be5d-c3a2e4f05118"
}
-
PATCH:
/capital/salaries/{id}/
- Payload:
{
"salary_date": "2019-11-03"
}
- Response:
{
"id": 2,
"cpf": "12345678901",
"salary_date": "2019-11-03",
"salary_value": "3050.30",
"salary_discount": "260.60",
"created_at": "2019-10-27T15:55:28.611385-03:00",
"capital_user": "4b23860e-072b-4f33-be5d-c3a2e4f05118"
}
-
GET:
/capital/salaries/{id}
- Response:
{
"id": 2,
"cpf": "12345678901",
"salary_date": "2019-11-03",
"salary_value": "3050.30",
"salary_discount": "260.60",
"created_at": "2019-10-27T15:55:28.611385-03:00",
"capital_user": "4b23860e-072b-4f33-be5d-c3a2e4f05118"
}
-
GET:
/capital/salaries
- É possível filtrar salários passando o parâmetro
?search=temo_para_filtrar
. O filtro levará os camposcpf
,name
eemail
. - Também é possível ordenar os dados passando o parâmetro
?ordering=campo_para_ordenar
. É possível ordenar pelos campossalary_date
ecapital_user__name
.
- É possível filtrar salários passando o parâmetro
- Response:
{
"count": 3,
"next": null,
"previous": null,
"results": [
{
"id": 2,
"cpf": "12345678901",
"salary_date": "2019-11-03",
"salary_value": "3050.30",
"salary_discount": "260.60",
"created_at": "2019-10-27T15:55:28.611385-03:00",
"capital_user": "4b23860e-072b-4f33-be5d-c3a2e4f05118"
},
{...}
]
}
-
DELETE:
/capital/salaries/{id}
- Response:
Retorno
204 No Content