| Home | Escopo e Cronograma | Processo | Design/Mockups | Configuração | Arquitetura | Código | BD | Qualidade | Utilização | Contratos | 
|---|
Contratos de comunicação back-front
Descrição
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
 
Sumário
POST /login/
Params:
Nenhum parâmetro esperado
Query string:
Nenhuma query string esperada
Payload:
{
    email: "str",
    password: "str",
    isTeacher: 1
}
Responses:
- 
200:
{ status: 200, msg: "Success", user: { id: 1 } } } - 
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" } ] } 
POST /logoff/
Params:
Nenhum parâmetro esperado
Query string:
Nenhuma query string esperada
Payload:
Nenhum payload esperado
Responses:
- 
204: NO_CONTENT
 - 
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/{id}/follow
Params:
- id: int = id do professor que se deseja abrir o perfil
 
Query string:
Nenhuma query string esperada
Payload:
Nenhum payload esperado
Responses:
- 
204: NO_CONTENT
 - 
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" } ] } 
GET /projects/
Params
Nenhum parâmetro esperado
Query string
Nenhuma query string esperada
Payload
Nenhum payload esperado
Responses
- 
200:
{ status: 200, msg: "Success", projects: [ { id: 1, name: "Projeto Javascript", description: "Descrição do projeto Projeto Javascript", open: true, teacherUserId: 1 }, ... ] } - 
422:
{ status: 422, msg: "Bad request", errors: [ { value: "string", msg: "Invalid value" } ] } - 
500:
{ status: 500, msg: "Internal error occurred", errors: [ { value: Any, msg: "str" } ] } 
POST /projects/
Params
Nenhum parâmetro esperado
Query string
Nenhuma query string esperada
Payload
{ name: "titulo", teacherId: 1, description: "descricao", opportunities: [ { name: "nome vaga", description: "desc vaga" }, { name: "nome 2", description: "desc 2" } ] }
### Responses
- 201:
    ```
    {
        status: 201,
        msg: "Success",
        project: {
            id: 1,
            name: "Projeto Javascript",
            description: "Descrição do projeto Projeto Javascript",
            open: true,
            teacherUserId: 1,
            opportunities: [
                {
                    id: 1,
                    name: "nome vaga",
                    description: "desc vaga",
                    open: true
                },
                {
                    id: 2,
                    name: "nome 2",
                    description: "desc 2",
                    open: true
                }
            ]
        }
    }
    ```
- 422:
{
    status: 422,
    msg: "Bad request",
    errors: [
        {
            value: "string",
            msg: "Invalid value"
        }
     ]
}
```
- 500:
{ status: 500, msg: "Internal error occurred", errors: [ { value: Any, msg: "str" } ] } 
GET /projects/{id}/
Params
ID do projeto
Query string
Nenhuma query string esperada
Payload
Nenhum payload esperado
Responses
- 
200:
{ status: 200, msg: "Success", project: { id: 1, name: "Projeto Javascript", description: "Descrição do projeto Projeto Javascript", open: true, teacherUserId: 1 } } - 
422:
{ status: 422, msg: "Bad request", errors: [ { value: "string", msg: "Invalid value" } ] } - 
500:
{ status: 500, msg: "Internal error occurred", errors: [ { value: Any, msg: "str" } ] } 
GET /projects/{id}/candidates/
Params
ID do projeto
Query string
Nenhuma query string esperada
Payload
Nenhum payload esperado
Responses
- 
200:
{ status: 200, msg: "Success", candidates: [ { id: 2, name: "student", description: "Test student", birthday: "2001-03-27T00:00:00.000Z", semester: 6, email: "[email protected]", lattesURL: "http://lattes.cnpq.br/54321", course: "Engenharia de Software", gender: "Masculino", institution: "PUCRS", appliedOpportunities: [ { matchId: 3, id: 1, type: "junior", description: "Oportunidade de nivel junior no projeto 1", semesterStart: 1, semesterEnd: 2, open: true, projectId: 1 } ] } ] } - 
422:
{ status: 422, msg: "Bad request", errors: [ { value: "string", msg: "Invalid value" } ] } - 
500:
{ status: 500, msg: "Internal error occurred", errors: [ { value: Any, msg: "str" } ] } 
GET /projects/{projectId}/accept/{matchId}
Params
ID do projeto e do match que está pendente
Query string
Nenhuma query string esperada
Payload
Nenhum payload esperado
Responses
- 
200:
{ status: 200, msg: "Success", match: { id: 3, from: "STUDENT", status: "DONE", createdAt: "2022-05-19T01:23:00.410Z", updatedAt: "2022-05-19T01:28:28.794Z", userId: 2, opportunityId: 1 } } - 
422:
{ status: 422, msg: "Bad request", errors: [ { value: "string", msg: "Invalid value" } ] } - 
500:
{ status: 500, msg: "Internal error occurred", errors: [ { value: Any, msg: "str" } ] } 
GET /projects/{projectId}/opportunities/
Params
ID do projeto que possui a oportunidade
Query string
Nenhuma query string esperada
Payload
Nenhum payload esperado
Responses
- 
200:
{ status: 200, msg: "Success", opportunities: [ { id: 1, type: "junior", description: "Oportunidade de nivel junior no projeto 1", semesterStart: 1, semesterEnd: 2, open: true, projectId: 1 } ... ] } - 
422:
{ status: 422, msg: "Bad request", errors: [ { value: "string", msg: "Invalid value" } ] } - 
500:
{ status: 500, msg: "Internal error occurred", errors: [ { value: Any, msg: "str" } ] } 
GET /projects/{projectId}/opportunities/{opportunityId}
Params
ID do projeto que possui a oportunidade e o ID da oportunidade
Query string
Nenhuma query string esperada
Payload
Nenhum payload esperado
Responses
- 
200:
{ status: 200, msg: "Success", opportunity: { id: 1, type: "junior", description: "Oportunidade de nivel junior no projeto 1", semesterStart: 1, semesterEnd: 2, open: true, projectId: 1 } } - 
422:
{ status: 422, msg: "Bad request", errors: [ { value: "string", msg: "Invalid value" } ] } - 
500:
{ status: 500, msg: "Internal error occurred", errors: [ { value: Any, msg: "str" } ] } 
POST /projects/{projectId}/opportunities/{opportunityId}/apply
Params
ID do projeto que possui a oportunidade e o ID da oportunidade
Query string
Nenhuma query string esperada
Payload
Nenhum payload esperado
Responses
- 
200:
{ status: 201, msg: "Success", match: { status: "PENDING", id: 1, from: "STUDENT", userId: 1, opportunityId: 1, updatedAt: "2022-05-19T01:20:33.821Z", createdAt: "2022-05-19T01:20:33.821Z" } } - 
422:
{ status: 422, msg: "Bad request", errors: [ { value: "string", msg: "Invalid value" } ] } - 
500:
{ status: 500, msg: "Internal error occurred", errors: [ { value: Any, msg: "str" } ] } 
GET /courses/
Params
Nenhum parâmetro esperado
Query string
Nenhuma query string esperada
Payload
Nenhum payload esperado
Responses
- 
200:
{ status: 200, msg: "Success", courses: [ { id: 1, name: "Engenharia de Software" } ] } - 
500:
{ status: 500, msg: "Internal error occurred", errors: [ { value: Any, msg: "str" } ] } 
GET /experiences/
Params
Nenhum parâmetro esperado
Query string
- userId: id do usuário que se deseja recuperar as experiências
 
Payload
Nenhum payload esperado
Responses
- 
200:
{ status: 200, msg: "Success", experiences: [ { id: 1, title: "Matador de ratos", description: "Trabalhei dentro do laboratório da PUCRS como matador de ratos" } ] } - 
500:
{ status: 500, msg: "Internal error occurred", errors: [ { value: Any, msg: "str" } ] } 
GET /experiences/{id}
Params
- id: Id da experiencia que se deseja buscar
 
Query string
Nenhuma query string esperada
Payload
Nenhum payload esperado
Responses
- 
200:
{ status: 200, msg: "Success", experience: { id: 1, title: "Matador de ratos", description: "Trabalhei dentro do laboratório da PUCRS como matador de ratos" } } - 
500:
{ status: 500, msg: "Internal error occurred", errors: [ { value: Any, msg: "str" } ] }