Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Commit

Permalink
'gestionAppels'
Browse files Browse the repository at this point in the history
  • Loading branch information
maelgangloff committed Dec 29, 2020
1 parent 191305b commit 811ab87
Show file tree
Hide file tree
Showing 15 changed files with 427 additions and 2 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Support non-officiel de l'API Kdecole (Mon Bureau Numérique, Skolengo, etc.)
* [.deleteCommunication(id)](#Kdecole+deleteCommunication) ⇒ <code>Promise.&lt;void&gt;</code>
* [.setCommunicationLu(id)](#Kdecole+setCommunicationLu) ⇒ <code>Promise.&lt;void&gt;</code>
* [.sendMessage(id, corpsMessage)](#Kdecole+sendMessage) ⇒ <code>Promise.&lt;void&gt;</code>
* [.gestionAppels()](#Kdecole+gestionAppels) ⇒ <code>Promise.&lt;GestionAppels&gt;</code>
* [.validerAppel(appel)](#Kdecole+validerAppel) ⇒ <code>Promise.&lt;void&gt;</code>
* [.kdecole()](#Kdecole+kdecole)
* _static_
* [.login(login, password)](#Kdecole.login) ⇒ <code>Promise.&lt;string&gt;</code>
Expand Down Expand Up @@ -269,6 +271,28 @@ Envoyer un message sur un fil de discussion

**Example**
```jsconst Kdecole = require('kdecole-api').defaultconst user = new Kdecole(AUTH_TOKEN)user.sendMessage(id, corpsMessage)```
<a name="Kdecole+gestionAppels"></a>

### kdecole.gestionAppels() ⇒ <code>Promise.&lt;GestionAppels&gt;</code>
Retourne les feuilles d'appel.

**Kind**: instance method of [<code>Kdecole</code>](#Kdecole)
**Returns**: <code>Promise.&lt;GestionAppels&gt;</code> - Les feuilles d'appel.
**Example**
```jsconst Kdecole = require('kdecole-api').defaultconst user = new Kdecole(AUTH_TOKEN)user.gestionAppels().then((gestionAppels)=>{ // Votre code })```
<a name="Kdecole+validerAppel"></a>

### kdecole.validerAppel(appel) ⇒ <code>Promise.&lt;void&gt;</code>
Valide l'appel de la classe.

**Kind**: instance method of [<code>Kdecole</code>](#Kdecole)

| Param | Description |
| --- | --- |
| appel | L'appel à valider |

**Example**
```jsconst Kdecole = require('kdecole-api').defaultconst user = new Kdecole(AUTH_TOKEN)const appel = { "idEtab": 10485, "idAppel": 534552, "listeAbsencesAppel": [ { "idEleve": "AAP05567", "type": "absence", "dateDebut": 1609259443000, "dateFin": 1609263043000, "modifiable": true } ]}user.validerAppel(appel)```
<a name="Kdecole+kdecole"></a>

### kdecole.kdecole()
Expand Down
50 changes: 50 additions & 0 deletions src/Kdecole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import axios from 'axios'
import { ContenuActivite } from './entities/Travail/ContenuActivite'
import { ContenuArticle } from './entities/News/ContenuArticle'
import { Communication } from './entities/Messagerie/Communication'
import { GestionAppels } from './entities/Prof/GestionAppels'

interface KdecoleRequest {
service: 'starting'
Expand Down Expand Up @@ -458,6 +459,55 @@ export default class Kdecole {
})
}

/**
* Retourne les feuilles d'appel.
* @return {Promise<GestionAppels>} Les feuilles d'appel.
* @example ```js
* const Kdecole = require('kdecole-api').default
*
* const user = new Kdecole(AUTH_TOKEN)
* user.gestionAppels().then((gestionAppels)=>{
* // Votre code
* })
* ```
*/
public async gestionAppels ():Promise<GestionAppels> {
return new GestionAppels(await this.kdecole({ service: 'gestionAppels' }))
}

/**
* Valide l'appel de la classe.
* @return {Promise<void>}
* @param appel L'appel à valider
* @example ```js
* const Kdecole = require('kdecole-api').default
*
* const user = new Kdecole(AUTH_TOKEN)
* const appel = {
* "idEtab": 10485,
* "idAppel": 534552,
* "listeAbsencesAppel": [
* {
* "idEleve": "AAP05567",
* "type": "absence",
* "dateDebut": 1609259443000,
* "dateFin": 1609263043000,
* "modifiable": true
* }
* ]
* }
* user.validerAppel(appel)
* ```
*/
public async validerAppel (appel: any):Promise<void> {
await this.kdecole({
service: 'gestionAppels',
parameters: `idetablissement/${this.idEtablissement}/valider`,
type: 'put',
data: appel
})
}

/**
* Effectue un premier traitement des données reçues en provenance de l'API et en retourne le résultat
*/
Expand Down
27 changes: 27 additions & 0 deletions src/entities/Prof/AbsenceEleveAppel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export class AbsenceEleveAppel {
public idAbsence: number|undefined
public type: string
public dateDebut: Date
public dateFin: Date
public idMotif: string|undefined
public modifiable: boolean
public idEleve:string|undefined

constructor (absenceEleveAppel:{
idEleve:string|undefined
idAbsence:number|undefined
type:string
dateDebut:number
dateFin:number
idMotif:string|undefined
modifiable:boolean
}) {
this.idAbsence = absenceEleveAppel.idAbsence
this.type = absenceEleveAppel.type
this.dateDebut = new Date(absenceEleveAppel.dateDebut)
this.dateFin = new Date(absenceEleveAppel.dateFin)
this.idMotif = absenceEleveAppel.idMotif
this.modifiable = absenceEleveAppel.modifiable
this.idEleve = absenceEleveAppel.idEleve
}
}
39 changes: 39 additions & 0 deletions src/entities/Prof/Appel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { EleveAppel } from './EleveAppel'

export class Appel {
public isEnCours: boolean
public dateDebut: Date
public dateFin: Date
public idAppel:number
public libelleGroupe:string
public listeElevesAppel:EleveAppel[] = []

constructor (appel:{
isEnCours:boolean
dateDebut:number
dateFin:number
idAppel:number
libelleGroupe:string
listeElevesAppel:{
nomEleve: string
prenomEleve: string
idEleve: string
absenceEleveAppel: {
idEleve:string|undefined
idAbsence:number|undefined
type:string
dateDebut:number
dateFin:number
idMotif:string|undefined
modifiable:boolean
} | undefined
}[]
}) {
this.isEnCours = appel.isEnCours
this.dateDebut = new Date(appel.dateDebut)
this.dateFin = new Date(appel.dateFin)
this.idAppel = appel.idAppel
this.libelleGroupe = appel.libelleGroupe
appel.listeElevesAppel.forEach(eleveAppel => this.listeElevesAppel.push(new EleveAppel(eleveAppel)))
}
}
28 changes: 28 additions & 0 deletions src/entities/Prof/EleveAppel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { AbsenceEleveAppel } from './AbsenceEleveAppel'

export class EleveAppel {
public nomEleve: string
public prenomEleve: string
public idEleve: string
public absenceEleveAppel: AbsenceEleveAppel | undefined

constructor (eleveAppel: {
nomEleve: string
prenomEleve: string
idEleve: string
absenceEleveAppel: {
idEleve:string|undefined
idAbsence:number|undefined
type:string
dateDebut:number
dateFin:number
idMotif:string|undefined
modifiable:boolean
} | undefined
}) {
this.nomEleve = eleveAppel.nomEleve
this.prenomEleve = eleveAppel.prenomEleve
this.idEleve = eleveAppel.idEleve
if (eleveAppel.absenceEleveAppel) this.absenceEleveAppel = new AbsenceEleveAppel(eleveAppel.absenceEleveAppel)
}
}
34 changes: 34 additions & 0 deletions src/entities/Prof/GestionAppels.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Appel } from './Appel'

export class GestionAppels {
public dateDuJour: Date
public listeAppels: Appel[] = []

constructor (gestionAppels: {
dateDuJour: number
listeAppels: {
isEnCours: boolean
dateDebut: number
dateFin: number
idAppel: number
libelleGroupe: string
listeElevesAppel: {
nomEleve: string
prenomEleve: string
idEleve: string
absenceEleveAppel: {
idEleve:string|undefined
idAbsence:number|undefined
type:string
dateDebut:number
dateFin:number
idMotif:string|undefined
modifiable:boolean
} | undefined
}[]
}[]
}) {
this.dateDuJour = new Date(gestionAppels.dateDuJour)
gestionAppels.listeAppels.forEach(appel => this.listeAppels.push(new Appel(appel)))
}
}
4 changes: 2 additions & 2 deletions src/openapi/components/responses/prof/gestionAppels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ properties:
isEnCours:
type: boolean
dateDebut:
type: boolean
type: number
dateFin:
type: boolean
type: number
idAppel:
type: number
libelleGroupe:
Expand Down
41 changes: 41 additions & 0 deletions tests/Prof/GererAppels.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import axios from 'axios'
import {APP_VERSION, BASE_URL} from "../../dist/config.js"
import {GestionAppels} from "../../dist/entities/Prof/GestionAppels"

const Kdecole = require('../../dist/Kdecole.js').default

const authToken = '0AnemIFGvcORx88ESDrvIflY0qRV2ussl0n31tC5Sh2U6xDZJ0E3VrD1RYzrWGX3rYUZK4nI3wLnbxZYQi2sKXMrGbgxIuq2ewjOpRYfWLSP0mLFK3D3CZVu7Ev2s'
const user = new Kdecole(authToken, APP_VERSION, 10485)

jest.mock('axios')
axios.request.mockResolvedValue({
data: require('../fakeData/Prof/fakeGestionAppels.json')
})

describe('Test valider appel', () => {
beforeEach(() => {
axios.mockClear()
})
it('should call the right url and return appels', async () => {
expect(await user.gestionAppels()).toBeInstanceOf(GestionAppels)
expect(axios.request).toBeCalledWith({
"baseURL": BASE_URL,
"data": undefined,
"headers": {"X-Kdecole-Auth": authToken, "X-Kdecole-Vers": APP_VERSION},
"method": "get",
"responseType": "json",
"url": "/gestionAppels/idetablissement/10485/"
})
})
it('should validate appel', async () => {
await user.validerAppel(require('../fakeData/Prof/fakeValiderAppel.json'))
expect(axios.request).toBeCalledWith({
"baseURL": BASE_URL,
"data": require('../fakeData/Prof/fakeValiderAppel.json'),
"headers": {"X-Kdecole-Auth": authToken, "X-Kdecole-Vers": APP_VERSION},
"method": "put",
"responseType": "json",
"url": "/gestionAppels/idetablissement/10485/valider/"
})
})
})
32 changes: 32 additions & 0 deletions tests/fakeData/Prof/fakeGestionAppels.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"dateDuJour": 1609260058,
"listeAppels": [
{
"isEnCours": true,
"dateDebut": 1609260058,
"dateFin": 1609263658,
"idAppel": 524545,
"libelleGroupe": "1ERE1",
"listeElevesAppel": [
{
"nomEleve": "DOE",
"prenomEleve": "John",
"idEleve": "AAP05567",
"absenceEleveAppel": {
"idAbsence": 54542,
"type": "retard",
"dateDebut": 1609260058,
"dateFin": 1609260500,
"idMotif": "Transport scolaire",
"modifiable": true
}
},
{
"nomEleve": "Luc",
"prenomEleve": "DUPONT",
"idEleve": "AAP05568"
}
]
}
]
}
13 changes: 13 additions & 0 deletions tests/fakeData/Prof/fakeValiderAppel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"idEtab": 10485,
"idAppel": 534552,
"listeAbsencesAppel": [
{
"idEleve": "AAP05567",
"type": "absence",
"dateDebut": 1609259443000,
"dateFin": 1609263043000,
"modifiable": true
}
]
}
39 changes: 39 additions & 0 deletions types/Kdecole.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { MessageBoiteReception } from './entities/Messagerie/MessageBoiteRecepti
import { ContenuActivite } from './entities/Travail/ContenuActivite';
import { ContenuArticle } from './entities/News/ContenuArticle';
import { Communication } from './entities/Messagerie/Communication';
import { GestionAppels } from './entities/Prof/GestionAppels';
interface KdecoleRequest {
service: 'starting' | 'actualites' | 'contenuArticle' | 'activation' | 'consulterReleves' | 'consulterAbsences' | 'infoutilisateur' | 'desactivation' | 'calendrier' | 'consulterNotes' | 'messagerie/info' | 'messagerie/boiteReception' | 'messagerie/communication' | 'messagerie/communication/nouvelleParticipation' | 'messagerie/communication/signaler' | 'messagerie/communication/supprimer' | 'messagerie/communication/lu' | 'travailAFaire' | 'contenuActivite' | 'gestionAppels';
parameters?: string;
Expand Down Expand Up @@ -293,6 +294,44 @@ export default class Kdecole {
* ```
*/
sendMessage(id: number, corpsMessage: string): Promise<void>;
/**
* Retourne les feuilles d'appel.
* @return {Promise<GestionAppels>} Les feuilles d'appel.
* @example ```js
* const Kdecole = require('kdecole-api').default
*
* const user = new Kdecole(AUTH_TOKEN)
* user.gestionAppels().then((gestionAppels)=>{
* // Votre code
* })
* ```
*/
gestionAppels(): Promise<GestionAppels>;
/**
* Valide l'appel de la classe.
* @return {Promise<void>}
* @param appel L'appel à valider
* @example ```js
* const Kdecole = require('kdecole-api').default
*
* const user = new Kdecole(AUTH_TOKEN)
* const appel = {
* "idEtab": 10485,
* "idAppel": 534552,
* "listeAbsencesAppel": [
* {
* "idEleve": "AAP05567",
* "type": "absence",
* "dateDebut": 1609259443000,
* "dateFin": 1609263043000,
* "modifiable": true
* }
* ]
* }
* user.validerAppel(appel)
* ```
*/
validerAppel(appel: any): Promise<void>;
/**
* Effectue un premier traitement des données reçues en provenance de l'API et en retourne le résultat
*/
Expand Down
Loading

0 comments on commit 811ab87

Please sign in to comment.