@metarisc/metarisc-js 0.0.1-alpha.2 → 0.0.1-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +10 -2
- package/.github/workflows/main.yml +29 -0
- package/README.md +29 -0
- package/lib/api/DossiersAPI.d.ts +62 -0
- package/lib/api/DossiersAPI.js +136 -0
- package/lib/api/EvenementsAPI.d.ts +41 -0
- package/lib/api/EvenementsAPI.js +90 -0
- package/lib/api/NotificationsAPI.d.ts +30 -0
- package/lib/api/NotificationsAPI.js +71 -0
- package/lib/api/OrganisationAPI.d.ts +19 -0
- package/lib/api/OrganisationAPI.js +43 -0
- package/lib/api/OrganisationsAPI.d.ts +19 -0
- package/lib/api/OrganisationsAPI.js +43 -0
- package/lib/api/PEIAPI.d.ts +43 -0
- package/lib/api/PEIAPI.js +91 -0
- package/lib/api/POIAPI.d.ts +50 -0
- package/lib/api/POIAPI.js +106 -0
- package/lib/api/PingAPI.d.ts +11 -0
- package/lib/api/PingAPI.js +27 -0
- package/lib/api/SupportAPI.d.ts +25 -0
- package/lib/api/SupportAPI.js +57 -0
- package/lib/api/UtilisateursAPI.d.ts +19 -0
- package/lib/api/UtilisateursAPI.js +42 -0
- package/lib/auth/oauth2.d.ts +19 -0
- package/lib/auth/oauth2.js +25 -0
- package/lib/client.d.ts +33 -0
- package/lib/client.js +97 -0
- package/lib/collection.d.ts +42 -0
- package/lib/collection.js +52 -0
- package/lib/core.d.ts +48 -0
- package/lib/core.js +28 -0
- package/lib/index.d.ts +15 -1
- package/lib/index.js +27 -1
- package/lib/metarisc.d.ts +20 -18
- package/lib/metarisc.js +36 -27
- package/lib/model/AdressePostale.d.ts +10 -0
- package/lib/model/AdressePostale.js +2 -0
- package/lib/model/AnomalieDECI.d.ts +10 -0
- package/lib/model/AnomalieDECI.js +9 -0
- package/lib/model/Contact.d.ts +13 -0
- package/lib/model/Contact.js +2 -0
- package/lib/model/DescriptifTechnique.d.ts +40 -0
- package/lib/model/DescriptifTechnique.js +45 -0
- package/lib/model/DescriptifTechniqueBase.d.ts +5 -0
- package/lib/model/DescriptifTechniqueBase.js +2 -0
- package/lib/model/DescriptifTechniqueDECIBase.d.ts +16 -0
- package/lib/model/DescriptifTechniqueDECIBase.js +9 -0
- package/lib/model/DescriptifTechniquePENA.d.ts +43 -0
- package/lib/model/DescriptifTechniquePENA.js +40 -0
- package/lib/model/DescriptifTechniquePENAAllOfRealimentation.d.ts +10 -0
- package/lib/model/DescriptifTechniquePENAAllOfRealimentation.js +9 -0
- package/lib/model/DescriptifTechniquePENAAllOfVolumes.d.ts +4 -0
- package/lib/model/DescriptifTechniquePENAAllOfVolumes.js +2 -0
- package/lib/model/DescriptifTechniquePIBI.d.ts +31 -0
- package/lib/model/DescriptifTechniquePIBI.js +25 -0
- package/lib/model/DescriptifTechniquePIBIAllOfPesees.d.ts +6 -0
- package/lib/model/DescriptifTechniquePIBIAllOfPesees.js +2 -0
- package/lib/model/Document.d.ts +3 -0
- package/lib/model/Document.js +2 -0
- package/lib/model/Dossier.d.ts +17 -0
- package/lib/model/Dossier.js +8 -0
- package/lib/model/Email.d.ts +6 -0
- package/lib/model/Email.js +2 -0
- package/lib/model/Evenement.d.ts +14 -0
- package/lib/model/Evenement.js +10 -0
- package/lib/model/Feature.d.ts +6 -0
- package/lib/model/Feature.js +2 -0
- package/lib/model/FeatureGeometry.d.ts +5 -0
- package/lib/model/FeatureGeometry.js +2 -0
- package/lib/model/GetEvenement404Response.d.ts +6 -0
- package/lib/model/GetEvenement404Response.js +2 -0
- package/lib/model/GetEvenementDetails404Response.d.ts +6 -0
- package/lib/model/GetEvenementDetails404Response.js +2 -0
- package/lib/model/GetFeature200Response.d.ts +7 -0
- package/lib/model/GetFeature200Response.js +2 -0
- package/lib/model/GetFeature200ResponseCrs.d.ts +5 -0
- package/lib/model/GetFeature200ResponseCrs.js +2 -0
- package/lib/model/GetFeature200ResponseCrsProperties.d.ts +3 -0
- package/lib/model/GetFeature200ResponseCrsProperties.js +2 -0
- package/lib/model/GetNotification404Response.d.ts +6 -0
- package/lib/model/GetNotification404Response.js +2 -0
- package/lib/model/Notification.d.ts +12 -0
- package/lib/model/Notification.js +2 -0
- package/lib/model/Organisation.d.ts +9 -0
- package/lib/model/Organisation.js +7 -0
- package/lib/model/PEI.d.ts +13 -0
- package/lib/model/PEI.js +2 -0
- package/lib/model/PEIReferencesExterieuresInner.d.ts +4 -0
- package/lib/model/PEIReferencesExterieuresInner.js +2 -0
- package/lib/model/POI.d.ts +13 -0
- package/lib/model/POI.js +2 -0
- package/lib/model/POIReferencesExterieuresInner.d.ts +4 -0
- package/lib/model/POIReferencesExterieuresInner.js +2 -0
- package/lib/model/PatchPoiRequest.d.ts +3 -0
- package/lib/model/PatchPoiRequest.js +2 -0
- package/lib/model/PieceJointe.d.ts +7 -0
- package/lib/model/PieceJointe.js +2 -0
- package/lib/model/Ping200Response.d.ts +3 -0
- package/lib/model/Ping200Response.js +2 -0
- package/lib/model/PostDossierRequest.d.ts +5 -0
- package/lib/model/PostDossierRequest.js +2 -0
- package/lib/model/PostEvenementRequest.d.ts +7 -0
- package/lib/model/PostEvenementRequest.js +2 -0
- package/lib/model/PostNotification400Response.d.ts +6 -0
- package/lib/model/PostNotification400Response.js +2 -0
- package/lib/model/PostNotification500Response.d.ts +6 -0
- package/lib/model/PostNotification500Response.js +2 -0
- package/lib/model/PostNotificationRequest.d.ts +9 -0
- package/lib/model/PostNotificationRequest.js +2 -0
- package/lib/model/PostTicketRequest.d.ts +10 -0
- package/lib/model/PostTicketRequest.js +2 -0
- package/lib/model/SuiviAdministratif.d.ts +6 -0
- package/lib/model/SuiviAdministratif.js +2 -0
- package/lib/model/Tag.d.ts +3 -0
- package/lib/model/Tag.js +2 -0
- package/lib/model/Ticket.d.ts +17 -0
- package/lib/model/Ticket.js +12 -0
- package/lib/model/Type.d.ts +5 -0
- package/lib/model/Type.js +2 -0
- package/lib/model/Utilisateur.d.ts +12 -0
- package/lib/model/Utilisateur.js +2 -0
- package/lib/model/Utilisateur1.d.ts +3 -0
- package/lib/model/Utilisateur1.js +2 -0
- package/lib/model/Workflow.d.ts +4 -0
- package/lib/model/Workflow.js +2 -0
- package/lib/model/WorkflowBase.d.ts +14 -0
- package/lib/model/WorkflowBase.js +2 -0
- package/lib/model/WorkflowDossiersLies.d.ts +4 -0
- package/lib/model/WorkflowDossiersLies.js +2 -0
- package/lib/model/WorkflowPassageCommissionSecurite.d.ts +4 -0
- package/lib/model/WorkflowPassageCommissionSecurite.js +2 -0
- package/lib/model/WorkflowRemiseEnServicePEI.d.ts +5 -0
- package/lib/model/WorkflowRemiseEnServicePEI.js +2 -0
- package/lib/tus.d.ts +7 -0
- package/lib/tus.js +43 -0
- package/lib/utils.d.ts +8 -0
- package/lib/utils.js +21 -0
- package/package.json +25 -18
- package/src/api/DossiersAPI.ts +155 -0
- package/src/api/EvenementsAPI.ts +101 -0
- package/src/api/NotificationsAPI.ts +79 -0
- package/src/api/OrganisationAPI.ts +46 -0
- package/src/api/OrganisationsAPI.ts +46 -0
- package/src/api/PEIAPI.ts +103 -0
- package/src/api/POIAPI.ts +124 -0
- package/src/api/PingAPI.ts +27 -0
- package/src/api/SupportAPI.ts +63 -0
- package/src/api/UtilisateursAPI.ts +46 -0
- package/src/auth/oauth2.ts +28 -0
- package/src/client.ts +133 -0
- package/src/collection.ts +85 -0
- package/src/core.ts +70 -0
- package/src/index.ts +22 -1
- package/src/metarisc.ts +67 -54
- package/src/model/AdressePostale.ts +10 -0
- package/src/model/AnomalieDECI.ts +11 -0
- package/src/model/Contact.ts +13 -0
- package/src/model/DescriptifTechnique.ts +46 -0
- package/src/model/DescriptifTechniqueBase.ts +5 -0
- package/src/model/DescriptifTechniqueDECIBase.ts +19 -0
- package/src/model/DescriptifTechniquePENA.ts +49 -0
- package/src/model/DescriptifTechniquePENAAllOfRealimentation.ts +11 -0
- package/src/model/DescriptifTechniquePENAAllOfVolumes.ts +4 -0
- package/src/model/DescriptifTechniquePIBI.ts +36 -0
- package/src/model/DescriptifTechniquePIBIAllOfPesees.ts +6 -0
- package/src/model/Document.ts +3 -0
- package/src/model/Dossier.ts +19 -0
- package/src/model/Email.ts +6 -0
- package/src/model/Evenement.ts +15 -0
- package/src/model/Feature.ts +7 -0
- package/src/model/FeatureGeometry.ts +5 -0
- package/src/model/GetEvenement404Response.ts +6 -0
- package/src/model/GetEvenementDetails404Response.ts +6 -0
- package/src/model/GetFeature200Response.ts +8 -0
- package/src/model/GetFeature200ResponseCrs.ts +6 -0
- package/src/model/GetFeature200ResponseCrsProperties.ts +3 -0
- package/src/model/GetNotification404Response.ts +6 -0
- package/src/model/Notification.ts +12 -0
- package/src/model/Organisation.ts +10 -0
- package/src/model/PEI.ts +14 -0
- package/src/model/PEIReferencesExterieuresInner.ts +4 -0
- package/src/model/POI.ts +14 -0
- package/src/model/POIReferencesExterieuresInner.ts +4 -0
- package/src/model/PatchPoiRequest.ts +3 -0
- package/src/model/PieceJointe.ts +7 -0
- package/src/model/Ping200Response.ts +3 -0
- package/src/model/PostDossierRequest.ts +5 -0
- package/src/model/PostEvenementRequest.ts +7 -0
- package/src/model/PostNotification400Response.ts +6 -0
- package/src/model/PostNotification500Response.ts +6 -0
- package/src/model/PostNotificationRequest.ts +9 -0
- package/src/model/PostTicketRequest.ts +10 -0
- package/src/model/SuiviAdministratif.ts +6 -0
- package/src/model/Tag.ts +3 -0
- package/src/model/Ticket.ts +18 -0
- package/src/model/Type.ts +5 -0
- package/src/model/Utilisateur.ts +12 -0
- package/src/model/Utilisateur1.ts +3 -0
- package/src/model/Workflow.ts +5 -0
- package/src/model/WorkflowBase.ts +14 -0
- package/src/model/WorkflowDossiersLies.ts +5 -0
- package/src/model/WorkflowPassageCommissionSecurite.ts +5 -0
- package/src/model/WorkflowRemiseEnServicePEI.ts +6 -0
- package/src/tus.ts +44 -0
- package/src/utils.ts +23 -0
- package/tsconfig.json +11 -10
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Core, MetariscConfig } from "../core";
|
|
2
|
+
import type { AxiosResponse } from "axios";
|
|
3
|
+
import { Client } from "../client";
|
|
4
|
+
import { Collection } from "../collection";
|
|
5
|
+
import { PEI } from '../model/PEI';
|
|
6
|
+
import { Contact } from '../model/Contact';
|
|
7
|
+
import { DescriptifTechnique } from '../model/DescriptifTechnique';
|
|
8
|
+
import { PieceJointe } from '../model/PieceJointe';
|
|
9
|
+
export declare class PEIAPI extends Core {
|
|
10
|
+
constructor(config: MetariscConfig, client?: Client);
|
|
11
|
+
/**
|
|
12
|
+
* Récupération de l'ensemble des données d'un PEI.
|
|
13
|
+
* @param peiId Identifiant unique du PEI
|
|
14
|
+
*/
|
|
15
|
+
getPei(peiId: string): Promise<AxiosResponse<PEI>>;
|
|
16
|
+
/**
|
|
17
|
+
* Récupération de la liste des Points d'Eau Incendie (PEI) selon des critères de recherche.
|
|
18
|
+
* @param page Numéro de page
|
|
19
|
+
* @param perPage Nombre de résultats demandé
|
|
20
|
+
*/
|
|
21
|
+
paginatePei(page?: number, perPage?: number): Collection<PEI>;
|
|
22
|
+
/**
|
|
23
|
+
* Récupération de la liste des contacts d'un Point d'Eau Incendie.
|
|
24
|
+
* @param peiId Identifiant unique du PEI
|
|
25
|
+
* @param page Numéro de page
|
|
26
|
+
* @param perPage Nombre de résultats demandé
|
|
27
|
+
*/
|
|
28
|
+
paginatePeiContacts(peiId: string, page?: number, perPage?: number): Collection<Contact>;
|
|
29
|
+
/**
|
|
30
|
+
* Récupération de l'historique d'un POI.
|
|
31
|
+
* @param peiId Identifiant unique du PEI
|
|
32
|
+
* @param page Numéro de page
|
|
33
|
+
* @param perPage Nombre de résultats demandé
|
|
34
|
+
*/
|
|
35
|
+
paginatePeiHistorique(peiId: string, page?: number, perPage?: number): Collection<DescriptifTechnique>;
|
|
36
|
+
/**
|
|
37
|
+
* Récupération de la liste des pièces jointes d'un Point d'Eau Incendie.
|
|
38
|
+
* @param peiId Identifiant unique du PEI
|
|
39
|
+
* @param page Numéro de page
|
|
40
|
+
* @param perPage Nombre de résultats demandé
|
|
41
|
+
*/
|
|
42
|
+
paginatePeiPiecesJointes(peiId: string, page?: number, perPage?: number): Collection<PieceJointe>;
|
|
43
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PEIAPI = void 0;
|
|
7
|
+
const core_1 = require("../core");
|
|
8
|
+
const utils_1 = __importDefault(require("../utils"));
|
|
9
|
+
class PEIAPI extends core_1.Core {
|
|
10
|
+
constructor(config, client) {
|
|
11
|
+
super(config, client);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Récupération de l'ensemble des données d'un PEI.
|
|
15
|
+
* @param peiId Identifiant unique du PEI
|
|
16
|
+
*/
|
|
17
|
+
async getPei(peiId) {
|
|
18
|
+
const pathVariable = { 'pei_id': peiId };
|
|
19
|
+
return this.request({
|
|
20
|
+
method: 'GET',
|
|
21
|
+
endpoint: utils_1.default.constructPath(pathVariable, '/pei/{pei_id}'),
|
|
22
|
+
headers: {},
|
|
23
|
+
params: {},
|
|
24
|
+
body: {}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Récupération de la liste des Points d'Eau Incendie (PEI) selon des critères de recherche.
|
|
29
|
+
* @param page Numéro de page
|
|
30
|
+
* @param perPage Nombre de résultats demandé
|
|
31
|
+
*/
|
|
32
|
+
paginatePei(page, perPage) {
|
|
33
|
+
const pathVariable = {};
|
|
34
|
+
return this.collect({
|
|
35
|
+
method: 'GET',
|
|
36
|
+
endpoint: utils_1.default.constructPath(pathVariable, '/pei'),
|
|
37
|
+
headers: {},
|
|
38
|
+
params: { 'page': page?.toString(), 'per_page': perPage?.toString() },
|
|
39
|
+
body: {}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Récupération de la liste des contacts d'un Point d'Eau Incendie.
|
|
44
|
+
* @param peiId Identifiant unique du PEI
|
|
45
|
+
* @param page Numéro de page
|
|
46
|
+
* @param perPage Nombre de résultats demandé
|
|
47
|
+
*/
|
|
48
|
+
paginatePeiContacts(peiId, page, perPage) {
|
|
49
|
+
const pathVariable = { 'pei_id': peiId };
|
|
50
|
+
return this.collect({
|
|
51
|
+
method: 'GET',
|
|
52
|
+
endpoint: utils_1.default.constructPath(pathVariable, '/pei/{pei_id}/contacts'),
|
|
53
|
+
headers: {},
|
|
54
|
+
params: { 'page': page?.toString(), 'per_page': perPage?.toString() },
|
|
55
|
+
body: {}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Récupération de l'historique d'un POI.
|
|
60
|
+
* @param peiId Identifiant unique du PEI
|
|
61
|
+
* @param page Numéro de page
|
|
62
|
+
* @param perPage Nombre de résultats demandé
|
|
63
|
+
*/
|
|
64
|
+
paginatePeiHistorique(peiId, page, perPage) {
|
|
65
|
+
const pathVariable = { 'pei_id': peiId };
|
|
66
|
+
return this.collect({
|
|
67
|
+
method: 'GET',
|
|
68
|
+
endpoint: utils_1.default.constructPath(pathVariable, '/pei/{pei_id}/historique'),
|
|
69
|
+
headers: {},
|
|
70
|
+
params: { 'page': page?.toString(), 'per_page': perPage?.toString() },
|
|
71
|
+
body: {}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Récupération de la liste des pièces jointes d'un Point d'Eau Incendie.
|
|
76
|
+
* @param peiId Identifiant unique du PEI
|
|
77
|
+
* @param page Numéro de page
|
|
78
|
+
* @param perPage Nombre de résultats demandé
|
|
79
|
+
*/
|
|
80
|
+
paginatePeiPiecesJointes(peiId, page, perPage) {
|
|
81
|
+
const pathVariable = { 'pei_id': peiId };
|
|
82
|
+
return this.collect({
|
|
83
|
+
method: 'GET',
|
|
84
|
+
endpoint: utils_1.default.constructPath(pathVariable, '/pei/{pei_id}/pieces_jointes'),
|
|
85
|
+
headers: {},
|
|
86
|
+
params: { 'page': page?.toString(), 'per_page': perPage?.toString() },
|
|
87
|
+
body: {}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.PEIAPI = PEIAPI;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Core, MetariscConfig } from "../core";
|
|
2
|
+
import type { AxiosResponse } from "axios";
|
|
3
|
+
import { Client } from "../client";
|
|
4
|
+
import { Collection } from "../collection";
|
|
5
|
+
import { POI } from '../model/POI';
|
|
6
|
+
import { PatchPoiRequest } from '../model/PatchPoiRequest';
|
|
7
|
+
import { Contact } from '../model/Contact';
|
|
8
|
+
import { DescriptifTechnique } from '../model/DescriptifTechnique';
|
|
9
|
+
import { PieceJointe } from '../model/PieceJointe';
|
|
10
|
+
export declare class POIAPI extends Core {
|
|
11
|
+
constructor(config: MetariscConfig, client?: Client);
|
|
12
|
+
/**
|
|
13
|
+
* Récupération de l'ensemble des données d'un POI.
|
|
14
|
+
* @param poiId ID du POI
|
|
15
|
+
*/
|
|
16
|
+
getPoi(poiId: string): Promise<AxiosResponse<POI>>;
|
|
17
|
+
/**
|
|
18
|
+
* Récupération de la liste des contacts d'un POI.
|
|
19
|
+
* @param poiId ID du POI
|
|
20
|
+
* @param page Numéro de page
|
|
21
|
+
* @param perPage Nombre de résultats demandé
|
|
22
|
+
*/
|
|
23
|
+
paginateContacts(poiId: string, page?: number, perPage?: number): Collection<Contact>;
|
|
24
|
+
/**
|
|
25
|
+
* Récupération de l'historique d'un POI.
|
|
26
|
+
* @param poiId ID du POI
|
|
27
|
+
* @param page Numéro de page
|
|
28
|
+
* @param perPage Nombre de résultats demandé
|
|
29
|
+
*/
|
|
30
|
+
paginateHistorique(poiId: string, page?: number, perPage?: number): Collection<DescriptifTechnique>;
|
|
31
|
+
/**
|
|
32
|
+
* Récupération de la liste des pièces jointes d'un POI.
|
|
33
|
+
* @param poiId ID du POI
|
|
34
|
+
* @param page Numéro de page
|
|
35
|
+
* @param perPage Nombre de résultats demandé
|
|
36
|
+
*/
|
|
37
|
+
paginatePiecesJointes(poiId: string, page?: number, perPage?: number): Collection<PieceJointe>;
|
|
38
|
+
/**
|
|
39
|
+
* Récupération de la liste des POI selon des critères de recherche.
|
|
40
|
+
* @param page Numéro de page
|
|
41
|
+
* @param perPage Nombre de résultats demandé
|
|
42
|
+
*/
|
|
43
|
+
paginatePoi(page?: number, perPage?: number): Collection<POI>;
|
|
44
|
+
/**
|
|
45
|
+
* Modifier un POI existant.
|
|
46
|
+
* @param poiId ID du POI
|
|
47
|
+
* @param patchPoiRequest
|
|
48
|
+
*/
|
|
49
|
+
patchPoi(poiId: string, patchPoiRequest?: PatchPoiRequest): Promise<AxiosResponse<POI>>;
|
|
50
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.POIAPI = void 0;
|
|
7
|
+
const core_1 = require("../core");
|
|
8
|
+
const utils_1 = __importDefault(require("../utils"));
|
|
9
|
+
class POIAPI extends core_1.Core {
|
|
10
|
+
constructor(config, client) {
|
|
11
|
+
super(config, client);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Récupération de l'ensemble des données d'un POI.
|
|
15
|
+
* @param poiId ID du POI
|
|
16
|
+
*/
|
|
17
|
+
async getPoi(poiId) {
|
|
18
|
+
const pathVariable = { 'poi_id': poiId };
|
|
19
|
+
return this.request({
|
|
20
|
+
method: 'GET',
|
|
21
|
+
endpoint: utils_1.default.constructPath(pathVariable, '/poi/{poi_id}'),
|
|
22
|
+
headers: {},
|
|
23
|
+
params: {},
|
|
24
|
+
body: {}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Récupération de la liste des contacts d'un POI.
|
|
29
|
+
* @param poiId ID du POI
|
|
30
|
+
* @param page Numéro de page
|
|
31
|
+
* @param perPage Nombre de résultats demandé
|
|
32
|
+
*/
|
|
33
|
+
paginateContacts(poiId, page, perPage) {
|
|
34
|
+
const pathVariable = { 'poi_id': poiId };
|
|
35
|
+
return this.collect({
|
|
36
|
+
method: 'GET',
|
|
37
|
+
endpoint: utils_1.default.constructPath(pathVariable, '/poi/{poi_id}/contacts'),
|
|
38
|
+
headers: {},
|
|
39
|
+
params: { 'page': page.toString(), 'per_page': perPage.toString() },
|
|
40
|
+
body: {}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Récupération de l'historique d'un POI.
|
|
45
|
+
* @param poiId ID du POI
|
|
46
|
+
* @param page Numéro de page
|
|
47
|
+
* @param perPage Nombre de résultats demandé
|
|
48
|
+
*/
|
|
49
|
+
paginateHistorique(poiId, page, perPage) {
|
|
50
|
+
const pathVariable = { 'poi_id': poiId };
|
|
51
|
+
return this.collect({
|
|
52
|
+
method: 'GET',
|
|
53
|
+
endpoint: utils_1.default.constructPath(pathVariable, '/poi/{poi_id}/historique'),
|
|
54
|
+
headers: {},
|
|
55
|
+
params: { 'page': page.toString(), 'per_page': perPage.toString() },
|
|
56
|
+
body: {}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Récupération de la liste des pièces jointes d'un POI.
|
|
61
|
+
* @param poiId ID du POI
|
|
62
|
+
* @param page Numéro de page
|
|
63
|
+
* @param perPage Nombre de résultats demandé
|
|
64
|
+
*/
|
|
65
|
+
paginatePiecesJointes(poiId, page, perPage) {
|
|
66
|
+
const pathVariable = { 'poi_id': poiId };
|
|
67
|
+
return this.collect({
|
|
68
|
+
method: 'GET',
|
|
69
|
+
endpoint: utils_1.default.constructPath(pathVariable, '/poi/{poi_id}/pieces_jointes'),
|
|
70
|
+
headers: {},
|
|
71
|
+
params: { 'page': page.toString(), 'per_page': perPage.toString() },
|
|
72
|
+
body: {}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Récupération de la liste des POI selon des critères de recherche.
|
|
77
|
+
* @param page Numéro de page
|
|
78
|
+
* @param perPage Nombre de résultats demandé
|
|
79
|
+
*/
|
|
80
|
+
paginatePoi(page, perPage) {
|
|
81
|
+
const pathVariable = {};
|
|
82
|
+
return this.collect({
|
|
83
|
+
method: 'GET',
|
|
84
|
+
endpoint: utils_1.default.constructPath(pathVariable, '/poi/'),
|
|
85
|
+
headers: {},
|
|
86
|
+
params: { 'page': page.toString(), 'per_page': perPage.toString() },
|
|
87
|
+
body: {}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Modifier un POI existant.
|
|
92
|
+
* @param poiId ID du POI
|
|
93
|
+
* @param patchPoiRequest
|
|
94
|
+
*/
|
|
95
|
+
async patchPoi(poiId, patchPoiRequest) {
|
|
96
|
+
const pathVariable = { 'poi_id': poiId };
|
|
97
|
+
return this.request({
|
|
98
|
+
method: 'PATCH',
|
|
99
|
+
endpoint: utils_1.default.constructPath(pathVariable, '/poi/{poi_id}'),
|
|
100
|
+
headers: {},
|
|
101
|
+
params: {},
|
|
102
|
+
body: { 'test': patchPoiRequest?.test }
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
exports.POIAPI = POIAPI;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Core, MetariscConfig } from "../core";
|
|
2
|
+
import type { AxiosResponse } from "axios";
|
|
3
|
+
import { Client } from "../client";
|
|
4
|
+
import { Ping200Response } from '../model/Ping200Response';
|
|
5
|
+
export declare class PingAPI extends Core {
|
|
6
|
+
constructor(config: MetariscConfig, client?: Client);
|
|
7
|
+
/**
|
|
8
|
+
* Permet de s'assurer que le service Metarisc est en ligne. Ping ... Pong !
|
|
9
|
+
*/
|
|
10
|
+
ping(): Promise<AxiosResponse<Ping200Response>>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PingAPI = void 0;
|
|
7
|
+
const core_1 = require("../core");
|
|
8
|
+
const utils_1 = __importDefault(require("../utils"));
|
|
9
|
+
class PingAPI extends core_1.Core {
|
|
10
|
+
constructor(config, client) {
|
|
11
|
+
super(config, client);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Permet de s'assurer que le service Metarisc est en ligne. Ping ... Pong !
|
|
15
|
+
*/
|
|
16
|
+
async ping() {
|
|
17
|
+
const pathVariable = {};
|
|
18
|
+
return this.request({
|
|
19
|
+
method: 'GET',
|
|
20
|
+
endpoint: utils_1.default.constructPath(pathVariable, '/ping'),
|
|
21
|
+
headers: {},
|
|
22
|
+
params: {},
|
|
23
|
+
body: {}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.PingAPI = PingAPI;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Core, MetariscConfig } from "../core";
|
|
2
|
+
import type { AxiosResponse } from "axios";
|
|
3
|
+
import { Client } from "../client";
|
|
4
|
+
import { Collection } from "../collection";
|
|
5
|
+
import { PostTicketRequest } from '../model/PostTicketRequest';
|
|
6
|
+
import { Ticket } from '../model/Ticket';
|
|
7
|
+
export declare class SupportAPI extends Core {
|
|
8
|
+
constructor(config: MetariscConfig, client?: Client);
|
|
9
|
+
/**
|
|
10
|
+
* Récupération des détails du ticket
|
|
11
|
+
* @param ticketId ID du ticket
|
|
12
|
+
*/
|
|
13
|
+
getTicket(ticketId: string): Promise<AxiosResponse<Ticket>>;
|
|
14
|
+
/**
|
|
15
|
+
* Récupération de la liste des tickets de support.
|
|
16
|
+
* @param page Numéro de page
|
|
17
|
+
* @param perPage Nombre de résultats demandé
|
|
18
|
+
*/
|
|
19
|
+
paginateTickets(page?: number, perPage?: number): Collection<Ticket>;
|
|
20
|
+
/**
|
|
21
|
+
* Création d'un nouveau ticket de support.
|
|
22
|
+
* @param postTicketRequest
|
|
23
|
+
*/
|
|
24
|
+
postTicket(postTicketRequest?: PostTicketRequest): Promise<AxiosResponse<Ticket>>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SupportAPI = void 0;
|
|
7
|
+
const core_1 = require("../core");
|
|
8
|
+
const utils_1 = __importDefault(require("../utils"));
|
|
9
|
+
class SupportAPI extends core_1.Core {
|
|
10
|
+
constructor(config, client) {
|
|
11
|
+
super(config, client);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Récupération des détails du ticket
|
|
15
|
+
* @param ticketId ID du ticket
|
|
16
|
+
*/
|
|
17
|
+
async getTicket(ticketId) {
|
|
18
|
+
const pathVariable = { 'ticket_id': ticketId };
|
|
19
|
+
return this.request({
|
|
20
|
+
method: 'GET',
|
|
21
|
+
endpoint: utils_1.default.constructPath(pathVariable, '/support/{ticket_id}'),
|
|
22
|
+
headers: {},
|
|
23
|
+
params: {},
|
|
24
|
+
body: {}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Récupération de la liste des tickets de support.
|
|
29
|
+
* @param page Numéro de page
|
|
30
|
+
* @param perPage Nombre de résultats demandé
|
|
31
|
+
*/
|
|
32
|
+
paginateTickets(page, perPage) {
|
|
33
|
+
const pathVariable = {};
|
|
34
|
+
return this.collect({
|
|
35
|
+
method: 'GET',
|
|
36
|
+
endpoint: utils_1.default.constructPath(pathVariable, '/support/'),
|
|
37
|
+
headers: {},
|
|
38
|
+
params: { 'page': page.toString(), 'per_page': perPage.toString() },
|
|
39
|
+
body: {}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Création d'un nouveau ticket de support.
|
|
44
|
+
* @param postTicketRequest
|
|
45
|
+
*/
|
|
46
|
+
async postTicket(postTicketRequest) {
|
|
47
|
+
const pathVariable = {};
|
|
48
|
+
return this.request({
|
|
49
|
+
method: 'POST',
|
|
50
|
+
endpoint: utils_1.default.constructPath(pathVariable, '/support/'),
|
|
51
|
+
headers: {},
|
|
52
|
+
params: {},
|
|
53
|
+
body: { 'subject': postTicketRequest?.subject, 'description': postTicketRequest?.description }
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.SupportAPI = SupportAPI;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Core, MetariscConfig } from "../core";
|
|
2
|
+
import type { AxiosResponse } from "axios";
|
|
3
|
+
import { Client } from "../client";
|
|
4
|
+
import { Collection } from "../collection";
|
|
5
|
+
import { Utilisateur } from '../model/Utilisateur';
|
|
6
|
+
import { Email } from '../model/Email';
|
|
7
|
+
export declare class UtilisateursAPI extends Core {
|
|
8
|
+
constructor(config: MetariscConfig, client?: Client);
|
|
9
|
+
/**
|
|
10
|
+
* L'utilisateur connecté retourné par ce point de terminaison utilise le token d'accès généré par le service OpenID Connect afin de le lier à une identité connue de Metarisc. Si l'utilisateur est inconnu une erreur est retournée.
|
|
11
|
+
*/
|
|
12
|
+
getUtilisateursMoi(): Promise<AxiosResponse<Utilisateur>>;
|
|
13
|
+
/**
|
|
14
|
+
* Liste toutes les adresses mail de l'utilisateur connecté, y compris les adresses non publiquement accessibles.
|
|
15
|
+
* @param page Numéro de page
|
|
16
|
+
* @param perPage Nombre de résultats demandé
|
|
17
|
+
*/
|
|
18
|
+
paginateMoiEmails(page?: number, perPage?: number): Collection<Email>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.UtilisateursAPI = void 0;
|
|
7
|
+
const core_1 = require("../core");
|
|
8
|
+
const utils_1 = __importDefault(require("../utils"));
|
|
9
|
+
class UtilisateursAPI extends core_1.Core {
|
|
10
|
+
constructor(config, client) {
|
|
11
|
+
super(config, client);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* L'utilisateur connecté retourné par ce point de terminaison utilise le token d'accès généré par le service OpenID Connect afin de le lier à une identité connue de Metarisc. Si l'utilisateur est inconnu une erreur est retournée.
|
|
15
|
+
*/
|
|
16
|
+
async getUtilisateursMoi() {
|
|
17
|
+
const pathVariable = {};
|
|
18
|
+
return this.request({
|
|
19
|
+
method: 'GET',
|
|
20
|
+
endpoint: utils_1.default.constructPath(pathVariable, '/utilisateurs/@moi'),
|
|
21
|
+
headers: {},
|
|
22
|
+
params: {},
|
|
23
|
+
body: {}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Liste toutes les adresses mail de l'utilisateur connecté, y compris les adresses non publiquement accessibles.
|
|
28
|
+
* @param page Numéro de page
|
|
29
|
+
* @param perPage Nombre de résultats demandé
|
|
30
|
+
*/
|
|
31
|
+
paginateMoiEmails(page, perPage) {
|
|
32
|
+
const pathVariable = {};
|
|
33
|
+
return this.collect({
|
|
34
|
+
method: 'GET',
|
|
35
|
+
endpoint: utils_1.default.constructPath(pathVariable, '/utilisateurs/@moi/emails'),
|
|
36
|
+
headers: {},
|
|
37
|
+
params: { 'page': page?.toString(), 'per_page': perPage?.toString() },
|
|
38
|
+
body: {}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.UtilisateursAPI = UtilisateursAPI;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { OAuth2Options } from "../core";
|
|
2
|
+
export declare class OAuth2 {
|
|
3
|
+
static AUTHORIZATION_URL: string;
|
|
4
|
+
static ACCESS_TOKEN_URL: string;
|
|
5
|
+
/**
|
|
6
|
+
* Utilisation d'OAuth2 pour récupérer un access token utilisable dans Metarisc.
|
|
7
|
+
*
|
|
8
|
+
* La configuration doit contenir au moins :
|
|
9
|
+
* - CLIENT_ID (Le client_id de l'application inscrite sur Metarisc ID pour communiquer avec Metarisc)
|
|
10
|
+
* - CLIENT_SECRET (Le client_secret de l'application inscrite sur Metarisc ID pour communiquer avec Metarisc)
|
|
11
|
+
*
|
|
12
|
+
* La configuration peut contenir aussi :
|
|
13
|
+
* - ACCESS_TOKEN_URL
|
|
14
|
+
**/
|
|
15
|
+
/**
|
|
16
|
+
* OAuth2 Authorize URL Generator helper.
|
|
17
|
+
*/
|
|
18
|
+
static authorizeUrl(options: OAuth2Options): string;
|
|
19
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OAuth2 = void 0;
|
|
4
|
+
class OAuth2 {
|
|
5
|
+
/**
|
|
6
|
+
* Utilisation d'OAuth2 pour récupérer un access token utilisable dans Metarisc.
|
|
7
|
+
*
|
|
8
|
+
* La configuration doit contenir au moins :
|
|
9
|
+
* - CLIENT_ID (Le client_id de l'application inscrite sur Metarisc ID pour communiquer avec Metarisc)
|
|
10
|
+
* - CLIENT_SECRET (Le client_secret de l'application inscrite sur Metarisc ID pour communiquer avec Metarisc)
|
|
11
|
+
*
|
|
12
|
+
* La configuration peut contenir aussi :
|
|
13
|
+
* - ACCESS_TOKEN_URL
|
|
14
|
+
**/
|
|
15
|
+
/**
|
|
16
|
+
* OAuth2 Authorize URL Generator helper.
|
|
17
|
+
*/
|
|
18
|
+
static authorizeUrl(options) {
|
|
19
|
+
const params = new URLSearchParams(options);
|
|
20
|
+
return OAuth2.AUTHORIZATION_URL + '?' + params.toString();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.OAuth2 = OAuth2;
|
|
24
|
+
OAuth2.AUTHORIZATION_URL = 'https://lemur-17.cloud-iam.com/auth/realms/metariscoidc/protocol/openid-connect/auth';
|
|
25
|
+
OAuth2.ACCESS_TOKEN_URL = 'https://lemur-17.cloud-iam.com/auth/realms/metariscoidc/protocol/openid-connect/token';
|
package/lib/client.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AxiosResponse } from "axios";
|
|
2
|
+
import { GrantResponse, MetariscConfig, OAuth2Options } from './core';
|
|
3
|
+
interface RequestConfig {
|
|
4
|
+
body?: any;
|
|
5
|
+
headers?: {
|
|
6
|
+
[name: string]: string | string[];
|
|
7
|
+
};
|
|
8
|
+
params?: {
|
|
9
|
+
[param: string]: string | string[];
|
|
10
|
+
};
|
|
11
|
+
endpoint?: string;
|
|
12
|
+
method?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare enum AuthMethod {
|
|
15
|
+
CLIENT_CREDENTIALS = 0,
|
|
16
|
+
AUTHORIZATION_CODE = 1
|
|
17
|
+
}
|
|
18
|
+
export declare class Client {
|
|
19
|
+
private axios;
|
|
20
|
+
private access_token;
|
|
21
|
+
constructor(config: MetariscConfig);
|
|
22
|
+
authenticate(auth_method: AuthMethod, options: OAuth2Options): Promise<GrantResponse>;
|
|
23
|
+
request<T>(config: RequestConfig): Promise<AxiosResponse<T>>;
|
|
24
|
+
getAuthorizationCode(options: OAuth2Options): Promise<GrantResponse>;
|
|
25
|
+
getClientCredentials(options: OAuth2Options): Promise<GrantResponse>;
|
|
26
|
+
setAccessToken(access_token: string): void;
|
|
27
|
+
getAccessToken(): string;
|
|
28
|
+
/**
|
|
29
|
+
* Retourne les headers HTTP par défauts devant être présents dans toutes les requêtes Metarisc.
|
|
30
|
+
*/
|
|
31
|
+
private getDefaultHeaders;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
package/lib/client.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Client = exports.AuthMethod = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const axios_retry_1 = __importDefault(require("axios-retry"));
|
|
9
|
+
const axios_oauth_client_1 = __importDefault(require("axios-oauth-client"));
|
|
10
|
+
const oauth2_1 = require("./auth/oauth2");
|
|
11
|
+
const axios_cache_interceptor_1 = require("axios-cache-interceptor");
|
|
12
|
+
var AuthMethod;
|
|
13
|
+
(function (AuthMethod) {
|
|
14
|
+
AuthMethod[AuthMethod["CLIENT_CREDENTIALS"] = 0] = "CLIENT_CREDENTIALS";
|
|
15
|
+
AuthMethod[AuthMethod["AUTHORIZATION_CODE"] = 1] = "AUTHORIZATION_CODE";
|
|
16
|
+
})(AuthMethod = exports.AuthMethod || (exports.AuthMethod = {}));
|
|
17
|
+
class Client {
|
|
18
|
+
constructor(config) {
|
|
19
|
+
this.axios = axios_1.default.create({
|
|
20
|
+
baseURL: config.metarisc_url ?? 'https://api.metarisc.fr/',
|
|
21
|
+
'headers': {
|
|
22
|
+
'common': this.getDefaultHeaders()
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
// Axios Interceptors
|
|
26
|
+
// Request interceptors are FILO (First In Last Out)
|
|
27
|
+
// Response interceptors are FIFO (First In First Out)
|
|
28
|
+
// Axios interceptor : Enable HTTP Caching
|
|
29
|
+
// When combining axios-cache-interceptors with other interceptors, you may encounter some inconsistences.
|
|
30
|
+
// See : https://github.com/arthurfiorette/axios-cache-interceptor/issues/449#issuecomment-1370327566
|
|
31
|
+
this.axios = (0, axios_cache_interceptor_1.setupCache)(this.axios);
|
|
32
|
+
// Axios interceptor : Retry strategy
|
|
33
|
+
(0, axios_retry_1.default)(this.axios, {
|
|
34
|
+
retries: 3,
|
|
35
|
+
retryDelay: axios_retry_1.default.exponentialDelay
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
async authenticate(auth_method, options) {
|
|
39
|
+
let result;
|
|
40
|
+
switch (auth_method) {
|
|
41
|
+
case AuthMethod.AUTHORIZATION_CODE:
|
|
42
|
+
result = await this.getAuthorizationCode(options);
|
|
43
|
+
break;
|
|
44
|
+
case AuthMethod.CLIENT_CREDENTIALS:
|
|
45
|
+
result = await this.getClientCredentials(options);
|
|
46
|
+
break;
|
|
47
|
+
default:
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (result) {
|
|
51
|
+
const token = result.token_type + ' ' + result.access_token;
|
|
52
|
+
this.setAccessToken(token);
|
|
53
|
+
}
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
async request(config) {
|
|
57
|
+
config.headers['Authorization'] = this.getAccessToken();
|
|
58
|
+
return this.axios.request({
|
|
59
|
+
method: config.method || 'GET',
|
|
60
|
+
url: config.endpoint || '/',
|
|
61
|
+
params: config.params,
|
|
62
|
+
data: config.body,
|
|
63
|
+
headers: config.headers
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
async getAuthorizationCode(options) {
|
|
67
|
+
const fn = axios_oauth_client_1.default.authorizationCode(axios_1.default.create(), oauth2_1.OAuth2.ACCESS_TOKEN_URL, options.client_id ?? '', options.client_secret ?? '', options.redirect_uri ?? '', options.code ?? '', options.scope ?? '');
|
|
68
|
+
return await fn(options.code ?? '', options.scope ?? '');
|
|
69
|
+
}
|
|
70
|
+
async getClientCredentials(options) {
|
|
71
|
+
const fn = axios_oauth_client_1.default.clientCredentials(axios_1.default.create(), oauth2_1.OAuth2.ACCESS_TOKEN_URL, options.client_id ?? '', options.client_secret ?? '');
|
|
72
|
+
return await fn(options.scope ?? '');
|
|
73
|
+
}
|
|
74
|
+
setAccessToken(access_token) {
|
|
75
|
+
this.access_token = access_token;
|
|
76
|
+
this.axios.interceptors.request.use(function (config) {
|
|
77
|
+
config.headers['Authorization'] = access_token;
|
|
78
|
+
return config;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
getAccessToken() {
|
|
82
|
+
return this.access_token;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Retourne les headers HTTP par défauts devant être présents dans toutes les requêtes Metarisc.
|
|
86
|
+
*/
|
|
87
|
+
getDefaultHeaders() {
|
|
88
|
+
const headers = {};
|
|
89
|
+
// UA Headers
|
|
90
|
+
headers['User-Agent'] = 'MetariscJs/dev'; // Format User-Agent (https://www.rfc-editor.org/rfc/rfc9110#name-user-agent)
|
|
91
|
+
headers['Metarisc-User-Agent'] = JSON.stringify({
|
|
92
|
+
'lang': 'js'
|
|
93
|
+
});
|
|
94
|
+
return headers;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.Client = Client;
|