Skip to content

Commit

Permalink
Merge branch 'feat/qualif-host'
Browse files Browse the repository at this point in the history
  • Loading branch information
maelgangloff committed Dec 16, 2023
2 parents 3aa8d04 + d44fb9d commit 28eeace
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ Un wiki est disponible, celui-ci rassemble davantage d'informations sur le fonct
* [.refreshToken(triggerListener)](#Skolengo+refreshToken)
* _static_
* [.revokeToken(oidClient, token)](#Skolengo.revokeToken)
* [.getAppCurrentConfig()](#Skolengo.getAppCurrentConfig)
* [.searchSchool(filter, limit, offset)](#Skolengo.searchSchool)
* [.getAppCurrentConfig(httpConfig)](#Skolengo.getAppCurrentConfig)
* [.searchSchool(filter, limit, offset, httpConfig)](#Skolengo.searchSchool)
* [.getOIDClient(school, redirectUri)](#Skolengo.getOIDClient)
* [.fromConfigObject(config, skolengoConfig)](#Skolengo.fromConfigObject)

Expand Down Expand Up @@ -635,10 +635,15 @@ Révoquer un jeton

<a name="Skolengo.getAppCurrentConfig"></a>

### Skolengo.getAppCurrentConfig()
### Skolengo.getAppCurrentConfig(httpConfig)
Configuration actuelle de l'application mobile (dernière version déployée, dernière version supportée, ...)

**Kind**: static method of [<code>Skolengo</code>](#Skolengo)

| Param | Type | Description |
| --- | --- | --- |
| httpConfig | <code>AxiosRequestConfig</code> \| <code>undefined</code> | Configuration facultative du client HTTP |

**Example**
```js
const {Skolengo} = require('scolengo-api')
Expand All @@ -650,7 +655,7 @@ Skolengo.getAppCurrentConfig().then(config => {
```
<a name="Skolengo.searchSchool"></a>

### Skolengo.searchSchool(filter, limit, offset)
### Skolengo.searchSchool(filter, limit, offset, httpConfig)
Rechercher un établissement scolaire

**Kind**: static method of [<code>Skolengo</code>](#Skolengo)
Expand All @@ -660,6 +665,7 @@ Rechercher un établissement scolaire
| filter | <code>SchoolFilter</code> | | Le filtre de recherche |
| limit | <code>number</code> | <code>10</code> | Limite |
| offset | <code>number</code> | <code>0</code> | Offset |
| httpConfig | <code>AxiosRequestConfig</code> \| <code>undefined</code> | | Configuration facultative du client HTTP |

**Example**
```js
Expand Down
15 changes: 9 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class Skolengo {
this.school = school
this.tokenSet = tokenSet
this.config = {
httpClient: config?.httpClient ?? axios.create(),
httpClient: config?.httpClient ?? axios.create({ baseURL: BASE_URL }),
onTokenRefresh: config?.onTokenRefresh ?? (() => {}),
handlePronoteError: config?.handlePronoteError ?? false
}
Expand All @@ -118,6 +118,7 @@ export class Skolengo {

/**
* Configuration actuelle de l'application mobile (dernière version déployée, dernière version supportée, ...)
* @param {AxiosRequestConfig|undefined} httpConfig Configuration facultative du client HTTP
* @example ```js
* const {Skolengo} = require('scolengo-api')
*
Expand All @@ -128,12 +129,13 @@ export class Skolengo {
* ```
* @async
*/
public static async getAppCurrentConfig (): Promise<AppCurrentConfig> {
public static async getAppCurrentConfig (httpConfig?: AxiosRequestConfig): Promise<AppCurrentConfig> {
return deserialize((await axios.request<DocumentObject>({
baseURL: BASE_URL,
url: '/sko-app-configs/current',
method: 'get',
responseType: 'json'
responseType: 'json',
...httpConfig
})).data) as AppCurrentConfig
}

Expand All @@ -142,6 +144,7 @@ export class Skolengo {
* @param {SchoolFilter} filter Le filtre de recherche
* @param {number} limit Limite
* @param {number} offset Offset
* @param {AxiosRequestConfig|undefined} httpConfig Configuration facultative du client HTTP
* @example ```js
* const {Skolengo} = require('scolengo-api')
*
Expand All @@ -158,7 +161,7 @@ export class Skolengo {
* ```
* @async
*/
public static async searchSchool (filter: SchoolFilter, limit = 10, offset = 0): Promise<School[]> {
public static async searchSchool (filter: SchoolFilter, limit = 10, offset = 0, httpConfig?: AxiosRequestConfig): Promise<School[]> {
return deserialize((await axios.request<DocumentObject>({
baseURL: BASE_URL,
url: '/schools',
Expand All @@ -170,7 +173,8 @@ export class Skolengo {
offset
},
filter
}
},
...httpConfig
})).data) as School[]
}

Expand Down Expand Up @@ -1057,7 +1061,6 @@ export class Skolengo {
private async request<T = any, R = AxiosResponse<T>, D = any> (config: AxiosRequestConfig): Promise<R> {
const axiosConfig: AxiosRequestConfig = {
...config,
baseURL: BASE_URL,
withCredentials: true,
headers: {
Authorization: `Bearer ${this.tokenSet.access_token as string}`,
Expand Down

0 comments on commit 28eeace

Please sign in to comment.