Home | Escopo e Cronograma | Processo | Design/Mockups | Configuração | Arquitetura | Código | BD | Qualidade | Utilização | Contratos |
---|
Contratos de comunicação back-front
Os contratos são os formatos de mensagem em que ambos os lados concordam em receber, tanto para envio quanto para resposta. Envios para o back podem ser de três tipos, não se limitando a usar somente um:
- Parâmetro de URL (Params): valores passados na URL em formato de path, exemplo:
-
http://ucon.com/students/1/teachers
No exemplo acima, o 1 é um parâmetro de URL
- Parâmetro de Consulta (Query String): valores passados na URL após uma interrogação e separados por &, exemplo:
-
http://ucon.com/students?offset=0&limit=10
No exemplo acima os valores offset e limit são query strings
- Dados do Corpo (Payload): dados enviados no corpo (body) da requisição
POST /login/
Params:
Nenhum parâmetro esperado
Query string:
Nenhuma query string esperada
Payload:
{
email: "str",
password: "str",
isTeacher: 1
}
Responses:
-
204: NO_CONTENT
-
400:
{ status: 400, msg: "Bad request", errors: [ { value: "joao.severo", msg: "Invalid value for \"email\"" } ] }
-
401:
{ status: 401, msg: "Bad request", errors: [ { value: "email/password", msg: "Invalid email or password" } ] }
-
500
{ status: 500, msg: "Internal error occurred", errors: [ { value: Any, msg: "str" } ] }
GET /students/
Params:
Nenhum parâmetro esperado
Query string:
- institution: str = faculdade do aluno
- semester: int = semestre em que o aluno se encontra
- offset: str = início da lista de professores
- limit: str = tamanho da lista retornada
Payload:
Nenhum payload esperado
Responses:
- 200
{ status: 200, msg: "Success", students: [ { id: 11, name: "str", birthday: "2022-04-02T00:00:00.000Z", email: "str", semester: 5, description: "str", lattesURL: "str", course: "str", gender: "str", institution: "str" }, ... ] }
- 400
{ status: 400, msg: "Bad request", errors: [ { value: "", msg: "Invalid value for \"semester\"" } ] }
- 500
{ status: 500, msg: "Internal error occurred", errors: [ { value: Any, msg: "str" } ] }
GET /students/{id}/
Params:
- id: int = id do estudante
Query string:
Nenhuma query string esperada
Payload:
Nenhum payload esperado
Responses:
- 200
{ status: 200, msg: "Success", student: { id: 11, name: "str", birthday: "2022-04-02T00:00:00.000Z", email: "str", semester: 5, description: "str", lattesURL: "str", course: "str", gender: "str", institution: "str" } }
- 400
{ status: 400, msg: "Bad request", errors: [ { value: "", msg: "Invalid value for \"id\"" } ] }
- 404
{ status: 404, msg: "Bad request", errors: [ { value: 10, msg: "Student not found with id=10" } ] }
- 500
{ status: 500, msg: "Internal error occurred", errors: [ { value: Any, msg: "str" } ] }
POST /students/
Params:
Nenhum parâmetro esperado
Query string:
Nenhuma query string esperada
Payload:
{
name: "str",
birthday: "1999-06-11",
email: "str",
semester: 5,
course: "str",
gender: "str",
institution: "str",
password: "str"
}
Responses:
- 201:
{ status: 201, msg: "Success", student: { id: 1, name: "str", birthday: "2022-04-02T00:00:00.000Z", email: "str", semester: 5, lattesURL: "str", course: "str", gender: "str", institution: "str" } }
- 400:
{ status: 400, msg: "Bad request", errors: [ { value: "joao.severo", msg: "Invalid value for \"email\"" } ] }
- 404
{ status: 404, msg: "Bad request", errors: [ { value: 10, msg: "Student not found with id=10" } ] }
- 500
{ status: 500, msg: "Internal error occurred", errors: [ { value: Any, msg: "str" } ] }
PATCH /students/{id}/
Params:
- id: int = id do aluno a alterar parcialmente informações
Query string:
Nenhuma query string esperada
Payload:
{
name: "str",
birthday: "2022-04-02",
email: "[email protected]",
semester: 5,
course: "Engenharia de Software",
gender: "Masculino",
institution: "PUCRS",
description: "str",
password: "str"
}
Responses:
-
204: NO_CONTENT
-
400:
{ status: 400, msg: "Bad request", errors: [ { value: "joao.severo", msg: "Invalid value for \"email\"" } ] }
-
404
{ status: 404, msg: "Bad request", errors: [ { value: 10, msg: "Student not found with id=10" } ] }
-
500
{ status: 500, msg: "Internal error occurred", errors: [ { value: Any, msg: "str" } ] }
GET /teachers/
Params:
Nenhum parâmetro esperado
Query string:
Nenhuma query string esperada
Payload:
Nenhum payload esperado
Responses:
- 200:
{ status: 200, msg: "Success", teachers: [ { id: 10, name: "name", birthday: "2022-04-02T00:00:00.000Z", email: "[email protected]", lattesURL: "http://lattes.cnpq.br/123", hIndex: 10, gender: "str", degrees: [ { course: "Engenharia De Software", institution: "PUCRS", degreeType: "Pós" } ] }, ... ] }
- 400:
{ status: 400, msg: "Bad request", errors: [ { value: "", msg: "Invalid value for \"id\"" } ] }
- 500
{ status: 500, msg: "Internal error occurred", errors: [ { value: Any, msg: "str" } ] }
GET /teachers/{id}/
Params:
- id: int = id do professor que se deseja abrir o perfil
Query string:
Nenhuma query string esperada
Payload:
Nenhum payload esperado
Responses:
- 200:
{ status: 200, msg: "Success", teacher: { id: 10, name: "name", birthday: "2022-04-02T00:00:00.000Z", email: "[email protected]", lattesURL: "http://lattes.cnpq.br/123", hIndex: 10, gender: "str", degrees: [ { course: "Engenharia De Software", institution: "PUCRS", degreeType: "Pós" } ] } }
- 400:
{ status: 400, msg: "Bad request", errors: [ { value: "", msg: "Invalid value for \"id\"" } ] }
- 404
{ status: 404, msg: "Bad request", errors: [ { value: 10, msg: "Student not found with id=10" } ] }
- 500
{ status: 500, msg: "Internal error occurred", errors: [ { value: Any, msg: "str" } ] }
POST /teachers/
Params:
Nenhum parâmetro esperado
Query string:
Nenhuma query string esperada
Payload:
{
email: "[email protected]",
password: "password",
name: "name",
lattesId: 123,
birthday: "2022-04-02",
genderId: 1,
hIndex: 10,
degrees: [
{
institution: "PUCRS",
course: "Engenharia De Software",
degreeTypeId: 1
}
]
}
Responses:
-
201:
{ status: 200, msg: "Success", teacher: { id: 10, name: "name", birthday: "2022-04-02T00:00:00.000Z", email: "[email protected]", lattesURL: "http://lattes.cnpq.br/123", hIndex: 10, gender: "Masculino", degrees: [ { course: "Engenharia De Software", institution: "PUCRS", degreeType: "Pós" } ] } }
-
400:
{ status: 400, msg: "Bad request", errors: [ { value: "joao.severo", msg: "Invalid value for \"email\"" } ] }
-
500
{ status: 500, msg: "Internal error occurred", errors: [ { value: Any, msg: "str" } ] }
GET /degrees/
Params
Nenhum parâmetro esperado
Query string:
Nenhuma query string esperada
Payload
Nenhum payload esperado
Responses:
-
200:
{ status: 200, msg: "Success", degrees: [ { id: 1, name: "Bacharel" }, ... ] }
-
500
{ status: 500, msg: "Internal error occurred", errors: [ { value: Any, msg: "str" } ] }
GET /genders/
Params
Nenhum parâmetro esperado
Query string
Nenhuma query string esperada
Payload
Nenhum payload esperado
Responses:
-
200:
{ status: 200, msg: "Success", genders: [ { id: 1, name: "Masculino" }, ... ] }
-
500
{ status: 500, msg: "Internal error occurred", errors: [ { value: Any, msg: "str" } ] }