Skip to content

Commit

Permalink
feat: ++periodos-letivos (#18)
Browse files Browse the repository at this point in the history
* feat: ++periodos-letivos

* fix: parametros desnecessarios

removidos parametros desnecessários na funcao getPeriodosLetivos

* dumped to v0.8.0
  • Loading branch information
isaacmsl authored Dec 13, 2020
1 parent f777bd9 commit bc5247a
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 3 deletions.
17 changes: 17 additions & 0 deletions __tests__/periodos-letivos.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require('dotenv').config()
import Debug from 'debug'
const debug = new Debug('spec:periodos-letivos')

import { SuapiV2 } from '../src/index'
import { expect } from '@jest/globals'

const { MATRICULA, SENHA } = process.env

test('deve retornar os periodos letivos', async () => {
const authToken: string = await SuapiV2.getAuthToken(String(MATRICULA), String(SENHA))

const periodosLetivos = await SuapiV2.getPeriodosLetivos(authToken)
debug(periodosLetivos)

expect(periodosLetivos).toBeDefined()
})
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "suapi",
"version": "0.7.0",
"version": "0.8.0",
"description": "Wrapper para acesso a API do SUAP versão 2",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
16 changes: 15 additions & 1 deletion src/SuapiV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import ITurmaVirtualLiteV2 from './models/ITurmaVirtualLiteV2'
import ITurmaVirtualV2 from './models/ITurmaVirtualV2'
import IPeriodosHorariosV2 from './models/IPeriodosHorariosV2'
import IHorarioV2 from './models/IHorarioV2'
import IPeriodoLetivo from './models/IPeriodoLetivo'
import IBoletim from './models/IBoletim'

export class SuapiV2 {
public static BASE_URL: string = 'https://suap.ifrn.edu.br/api/v2/'
public static RESOURCES_DADOS_PESSOAIS_URL: string = 'minhas-informacoes/meus-dados/'
public static RESOURCES_TURMAS_VIRTUAIS_URL: string = 'minhas-informacoes/turmas-virtuais'
public static RESOURCES_TURMA_VIRTUAL_URL: string = 'minhas-informacoes/turma-virtual'
public static RESOURCES_PERIODOS_LETIVOS_URL: string = 'minhas-informacoes/meus-periodos-letivos'
public static RESOURCES_BOLETIM_URL: string = 'minhas-informacoes/boletim'

public static PERIODOS_HORARIOS_V2: IPeriodosHorariosV2 = {
Expand Down Expand Up @@ -101,6 +103,18 @@ export class SuapiV2 {
}
}

public static async getPeriodosLetivos(authToken: string): Promise<Array<IPeriodoLetivo>> {
try {
const PERIODOS_LETIVOS_URL = `${SuapiV2.RESOURCES_PERIODOS_LETIVOS_URL}`
return await SuapiV2.getByAuthorization(
PERIODOS_LETIVOS_URL,
authToken
)
} catch (error) {
throw error
}
}

public static async getHorarios(authToken: string, ano: Number = 2020, periodo: Number = 1): Promise<Array<IHorarioV2>> {
try {
const TURMAS_VIRTUAIS_URL = `${SuapiV2.RESOURCES_TURMAS_VIRTUAIS_URL}/${ano}/${periodo}`
Expand Down Expand Up @@ -163,4 +177,4 @@ export class SuapiV2 {

return response.data
}
}
}
4 changes: 4 additions & 0 deletions src/models/IPeriodoLetivo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default interface IPeriodoLetivo {
ano_letivo: number,
periodo_letivo: number
}

0 comments on commit bc5247a

Please sign in to comment.