@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.
Files changed (206) hide show
  1. package/.eslintrc +10 -2
  2. package/.github/workflows/main.yml +29 -0
  3. package/README.md +29 -0
  4. package/lib/api/DossiersAPI.d.ts +62 -0
  5. package/lib/api/DossiersAPI.js +136 -0
  6. package/lib/api/EvenementsAPI.d.ts +41 -0
  7. package/lib/api/EvenementsAPI.js +90 -0
  8. package/lib/api/NotificationsAPI.d.ts +30 -0
  9. package/lib/api/NotificationsAPI.js +71 -0
  10. package/lib/api/OrganisationAPI.d.ts +19 -0
  11. package/lib/api/OrganisationAPI.js +43 -0
  12. package/lib/api/OrganisationsAPI.d.ts +19 -0
  13. package/lib/api/OrganisationsAPI.js +43 -0
  14. package/lib/api/PEIAPI.d.ts +43 -0
  15. package/lib/api/PEIAPI.js +91 -0
  16. package/lib/api/POIAPI.d.ts +50 -0
  17. package/lib/api/POIAPI.js +106 -0
  18. package/lib/api/PingAPI.d.ts +11 -0
  19. package/lib/api/PingAPI.js +27 -0
  20. package/lib/api/SupportAPI.d.ts +25 -0
  21. package/lib/api/SupportAPI.js +57 -0
  22. package/lib/api/UtilisateursAPI.d.ts +19 -0
  23. package/lib/api/UtilisateursAPI.js +42 -0
  24. package/lib/auth/oauth2.d.ts +19 -0
  25. package/lib/auth/oauth2.js +25 -0
  26. package/lib/client.d.ts +33 -0
  27. package/lib/client.js +97 -0
  28. package/lib/collection.d.ts +42 -0
  29. package/lib/collection.js +52 -0
  30. package/lib/core.d.ts +48 -0
  31. package/lib/core.js +28 -0
  32. package/lib/index.d.ts +15 -1
  33. package/lib/index.js +27 -1
  34. package/lib/metarisc.d.ts +20 -18
  35. package/lib/metarisc.js +36 -27
  36. package/lib/model/AdressePostale.d.ts +10 -0
  37. package/lib/model/AdressePostale.js +2 -0
  38. package/lib/model/AnomalieDECI.d.ts +10 -0
  39. package/lib/model/AnomalieDECI.js +9 -0
  40. package/lib/model/Contact.d.ts +13 -0
  41. package/lib/model/Contact.js +2 -0
  42. package/lib/model/DescriptifTechnique.d.ts +40 -0
  43. package/lib/model/DescriptifTechnique.js +45 -0
  44. package/lib/model/DescriptifTechniqueBase.d.ts +5 -0
  45. package/lib/model/DescriptifTechniqueBase.js +2 -0
  46. package/lib/model/DescriptifTechniqueDECIBase.d.ts +16 -0
  47. package/lib/model/DescriptifTechniqueDECIBase.js +9 -0
  48. package/lib/model/DescriptifTechniquePENA.d.ts +43 -0
  49. package/lib/model/DescriptifTechniquePENA.js +40 -0
  50. package/lib/model/DescriptifTechniquePENAAllOfRealimentation.d.ts +10 -0
  51. package/lib/model/DescriptifTechniquePENAAllOfRealimentation.js +9 -0
  52. package/lib/model/DescriptifTechniquePENAAllOfVolumes.d.ts +4 -0
  53. package/lib/model/DescriptifTechniquePENAAllOfVolumes.js +2 -0
  54. package/lib/model/DescriptifTechniquePIBI.d.ts +31 -0
  55. package/lib/model/DescriptifTechniquePIBI.js +25 -0
  56. package/lib/model/DescriptifTechniquePIBIAllOfPesees.d.ts +6 -0
  57. package/lib/model/DescriptifTechniquePIBIAllOfPesees.js +2 -0
  58. package/lib/model/Document.d.ts +3 -0
  59. package/lib/model/Document.js +2 -0
  60. package/lib/model/Dossier.d.ts +17 -0
  61. package/lib/model/Dossier.js +8 -0
  62. package/lib/model/Email.d.ts +6 -0
  63. package/lib/model/Email.js +2 -0
  64. package/lib/model/Evenement.d.ts +14 -0
  65. package/lib/model/Evenement.js +10 -0
  66. package/lib/model/Feature.d.ts +6 -0
  67. package/lib/model/Feature.js +2 -0
  68. package/lib/model/FeatureGeometry.d.ts +5 -0
  69. package/lib/model/FeatureGeometry.js +2 -0
  70. package/lib/model/GetEvenement404Response.d.ts +6 -0
  71. package/lib/model/GetEvenement404Response.js +2 -0
  72. package/lib/model/GetEvenementDetails404Response.d.ts +6 -0
  73. package/lib/model/GetEvenementDetails404Response.js +2 -0
  74. package/lib/model/GetFeature200Response.d.ts +7 -0
  75. package/lib/model/GetFeature200Response.js +2 -0
  76. package/lib/model/GetFeature200ResponseCrs.d.ts +5 -0
  77. package/lib/model/GetFeature200ResponseCrs.js +2 -0
  78. package/lib/model/GetFeature200ResponseCrsProperties.d.ts +3 -0
  79. package/lib/model/GetFeature200ResponseCrsProperties.js +2 -0
  80. package/lib/model/GetNotification404Response.d.ts +6 -0
  81. package/lib/model/GetNotification404Response.js +2 -0
  82. package/lib/model/Notification.d.ts +12 -0
  83. package/lib/model/Notification.js +2 -0
  84. package/lib/model/Organisation.d.ts +9 -0
  85. package/lib/model/Organisation.js +7 -0
  86. package/lib/model/PEI.d.ts +13 -0
  87. package/lib/model/PEI.js +2 -0
  88. package/lib/model/PEIReferencesExterieuresInner.d.ts +4 -0
  89. package/lib/model/PEIReferencesExterieuresInner.js +2 -0
  90. package/lib/model/POI.d.ts +13 -0
  91. package/lib/model/POI.js +2 -0
  92. package/lib/model/POIReferencesExterieuresInner.d.ts +4 -0
  93. package/lib/model/POIReferencesExterieuresInner.js +2 -0
  94. package/lib/model/PatchPoiRequest.d.ts +3 -0
  95. package/lib/model/PatchPoiRequest.js +2 -0
  96. package/lib/model/PieceJointe.d.ts +7 -0
  97. package/lib/model/PieceJointe.js +2 -0
  98. package/lib/model/Ping200Response.d.ts +3 -0
  99. package/lib/model/Ping200Response.js +2 -0
  100. package/lib/model/PostDossierRequest.d.ts +5 -0
  101. package/lib/model/PostDossierRequest.js +2 -0
  102. package/lib/model/PostEvenementRequest.d.ts +7 -0
  103. package/lib/model/PostEvenementRequest.js +2 -0
  104. package/lib/model/PostNotification400Response.d.ts +6 -0
  105. package/lib/model/PostNotification400Response.js +2 -0
  106. package/lib/model/PostNotification500Response.d.ts +6 -0
  107. package/lib/model/PostNotification500Response.js +2 -0
  108. package/lib/model/PostNotificationRequest.d.ts +9 -0
  109. package/lib/model/PostNotificationRequest.js +2 -0
  110. package/lib/model/PostTicketRequest.d.ts +10 -0
  111. package/lib/model/PostTicketRequest.js +2 -0
  112. package/lib/model/SuiviAdministratif.d.ts +6 -0
  113. package/lib/model/SuiviAdministratif.js +2 -0
  114. package/lib/model/Tag.d.ts +3 -0
  115. package/lib/model/Tag.js +2 -0
  116. package/lib/model/Ticket.d.ts +17 -0
  117. package/lib/model/Ticket.js +12 -0
  118. package/lib/model/Type.d.ts +5 -0
  119. package/lib/model/Type.js +2 -0
  120. package/lib/model/Utilisateur.d.ts +12 -0
  121. package/lib/model/Utilisateur.js +2 -0
  122. package/lib/model/Utilisateur1.d.ts +3 -0
  123. package/lib/model/Utilisateur1.js +2 -0
  124. package/lib/model/Workflow.d.ts +4 -0
  125. package/lib/model/Workflow.js +2 -0
  126. package/lib/model/WorkflowBase.d.ts +14 -0
  127. package/lib/model/WorkflowBase.js +2 -0
  128. package/lib/model/WorkflowDossiersLies.d.ts +4 -0
  129. package/lib/model/WorkflowDossiersLies.js +2 -0
  130. package/lib/model/WorkflowPassageCommissionSecurite.d.ts +4 -0
  131. package/lib/model/WorkflowPassageCommissionSecurite.js +2 -0
  132. package/lib/model/WorkflowRemiseEnServicePEI.d.ts +5 -0
  133. package/lib/model/WorkflowRemiseEnServicePEI.js +2 -0
  134. package/lib/tus.d.ts +7 -0
  135. package/lib/tus.js +43 -0
  136. package/lib/utils.d.ts +8 -0
  137. package/lib/utils.js +21 -0
  138. package/package.json +25 -18
  139. package/src/api/DossiersAPI.ts +155 -0
  140. package/src/api/EvenementsAPI.ts +101 -0
  141. package/src/api/NotificationsAPI.ts +79 -0
  142. package/src/api/OrganisationAPI.ts +46 -0
  143. package/src/api/OrganisationsAPI.ts +46 -0
  144. package/src/api/PEIAPI.ts +103 -0
  145. package/src/api/POIAPI.ts +124 -0
  146. package/src/api/PingAPI.ts +27 -0
  147. package/src/api/SupportAPI.ts +63 -0
  148. package/src/api/UtilisateursAPI.ts +46 -0
  149. package/src/auth/oauth2.ts +28 -0
  150. package/src/client.ts +133 -0
  151. package/src/collection.ts +85 -0
  152. package/src/core.ts +70 -0
  153. package/src/index.ts +22 -1
  154. package/src/metarisc.ts +67 -54
  155. package/src/model/AdressePostale.ts +10 -0
  156. package/src/model/AnomalieDECI.ts +11 -0
  157. package/src/model/Contact.ts +13 -0
  158. package/src/model/DescriptifTechnique.ts +46 -0
  159. package/src/model/DescriptifTechniqueBase.ts +5 -0
  160. package/src/model/DescriptifTechniqueDECIBase.ts +19 -0
  161. package/src/model/DescriptifTechniquePENA.ts +49 -0
  162. package/src/model/DescriptifTechniquePENAAllOfRealimentation.ts +11 -0
  163. package/src/model/DescriptifTechniquePENAAllOfVolumes.ts +4 -0
  164. package/src/model/DescriptifTechniquePIBI.ts +36 -0
  165. package/src/model/DescriptifTechniquePIBIAllOfPesees.ts +6 -0
  166. package/src/model/Document.ts +3 -0
  167. package/src/model/Dossier.ts +19 -0
  168. package/src/model/Email.ts +6 -0
  169. package/src/model/Evenement.ts +15 -0
  170. package/src/model/Feature.ts +7 -0
  171. package/src/model/FeatureGeometry.ts +5 -0
  172. package/src/model/GetEvenement404Response.ts +6 -0
  173. package/src/model/GetEvenementDetails404Response.ts +6 -0
  174. package/src/model/GetFeature200Response.ts +8 -0
  175. package/src/model/GetFeature200ResponseCrs.ts +6 -0
  176. package/src/model/GetFeature200ResponseCrsProperties.ts +3 -0
  177. package/src/model/GetNotification404Response.ts +6 -0
  178. package/src/model/Notification.ts +12 -0
  179. package/src/model/Organisation.ts +10 -0
  180. package/src/model/PEI.ts +14 -0
  181. package/src/model/PEIReferencesExterieuresInner.ts +4 -0
  182. package/src/model/POI.ts +14 -0
  183. package/src/model/POIReferencesExterieuresInner.ts +4 -0
  184. package/src/model/PatchPoiRequest.ts +3 -0
  185. package/src/model/PieceJointe.ts +7 -0
  186. package/src/model/Ping200Response.ts +3 -0
  187. package/src/model/PostDossierRequest.ts +5 -0
  188. package/src/model/PostEvenementRequest.ts +7 -0
  189. package/src/model/PostNotification400Response.ts +6 -0
  190. package/src/model/PostNotification500Response.ts +6 -0
  191. package/src/model/PostNotificationRequest.ts +9 -0
  192. package/src/model/PostTicketRequest.ts +10 -0
  193. package/src/model/SuiviAdministratif.ts +6 -0
  194. package/src/model/Tag.ts +3 -0
  195. package/src/model/Ticket.ts +18 -0
  196. package/src/model/Type.ts +5 -0
  197. package/src/model/Utilisateur.ts +12 -0
  198. package/src/model/Utilisateur1.ts +3 -0
  199. package/src/model/Workflow.ts +5 -0
  200. package/src/model/WorkflowBase.ts +14 -0
  201. package/src/model/WorkflowDossiersLies.ts +5 -0
  202. package/src/model/WorkflowPassageCommissionSecurite.ts +5 -0
  203. package/src/model/WorkflowRemiseEnServicePEI.ts +6 -0
  204. package/src/tus.ts +44 -0
  205. package/src/utils.ts +23 -0
  206. package/tsconfig.json +11 -10
package/lib/tus.js ADDED
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Tus = void 0;
4
+ const core_1 = require("./core");
5
+ const tus_js_client_1 = require("tus-js-client");
6
+ class Tus extends core_1.Core {
7
+ constructor(config, client) {
8
+ super(config, client);
9
+ }
10
+ upload(file, errorFn, chunckFn, successFn) {
11
+ const upload = new tus_js_client_1.Upload(file, {
12
+ endpoint: this.config.metarisc_url + '/resumable-file-uploads/files',
13
+ retryDelays: [0, 3000, 6000, 9000, 12000],
14
+ chunkSize: 1024 * 512,
15
+ metadata: {
16
+ fileName: file.name,
17
+ filetype: file.type,
18
+ },
19
+ headers: {
20
+ Authorization: this.client.getAccessToken() ?? '',
21
+ },
22
+ onError: (error) => {
23
+ errorFn(error);
24
+ },
25
+ onChunkComplete: (chunkSize, bytesAccepted, bytesTotal) => {
26
+ const progress = Math.floor((bytesAccepted * 100) / bytesTotal);
27
+ const url = upload.url;
28
+ chunckFn(url, progress);
29
+ },
30
+ onSuccess: () => {
31
+ successFn();
32
+ },
33
+ });
34
+ upload.start();
35
+ }
36
+ download(fileId) {
37
+ return this.request({
38
+ method: "GET",
39
+ endpoint: "/resumable-file-uploads/files/" + fileId
40
+ });
41
+ }
42
+ }
43
+ exports.Tus = Tus;
package/lib/utils.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ export default class Utils {
2
+ /**
3
+ * Build URL with query params templates
4
+ */
5
+ static constructPath(data: {
6
+ [key: string]: string;
7
+ }, url: string): string;
8
+ }
package/lib/utils.js ADDED
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class Utils {
4
+ /**
5
+ * Build URL with query params templates
6
+ */
7
+ static constructPath(data, url) {
8
+ const r = RegExp('{([^}]*)}', 'g');
9
+ let s = '';
10
+ let idx = 0;
11
+ for (let a; (a = r.exec(url)) !== null;) {
12
+ s += (url.substring(idx, r.lastIndex - a[0].length) + data[a[1]]);
13
+ idx = r.lastIndex;
14
+ }
15
+ if (idx < url.length) {
16
+ s += url.substring(idx, url.length);
17
+ }
18
+ return s;
19
+ }
20
+ }
21
+ exports.default = Utils;
package/package.json CHANGED
@@ -1,20 +1,27 @@
1
1
  {
2
- "name": "@metarisc/metarisc-js",
3
- "main": "lib/index.js",
4
- "types": "lib/index.d.ts",
5
- "version": "0.0.1-alpha.2",
6
- "scripts": {
7
- "lint": "eslint . --ext .ts",
8
- "compile": "tsc"
9
- },
10
- "devDependencies": {
11
- "@types/node": "^18.14.4",
12
- "@typescript-eslint/eslint-plugin": "^5.54.0",
13
- "@typescript-eslint/parser": "^5.54.0",
14
- "eslint": "^8.35.0",
15
- "typescript": "^4.9.5"
16
- },
17
- "dependencies": {
18
- "axios": "^1.4.0"
19
- }
2
+ "name": "@metarisc/metarisc-js",
3
+ "main": "lib/index.js",
4
+ "types": "lib/index.d.ts",
5
+ "version": "0.0.1-alpha.21",
6
+ "scripts": {
7
+ "lint": "eslint . --ext .ts --fix",
8
+ "compile": "tsc",
9
+ "tests": "npm run compile && node tests/index.mjs"
10
+ },
11
+ "devDependencies": {
12
+ "@types/node": "^18.14.4",
13
+ "@typescript-eslint/eslint-plugin": "^6.7.5",
14
+ "@typescript-eslint/parser": "^6.7.5",
15
+ "eslint": "^8.35.0",
16
+ "eslint-plugin-import": "^2.28.1",
17
+ "eslint-plugin-unused-imports": "^3.0.0",
18
+ "typescript": "^4.9.5"
19
+ },
20
+ "dependencies": {
21
+ "axios": "^1.4.0",
22
+ "axios-cache-interceptor": "^1.3.2",
23
+ "axios-oauth-client": "^2.0.4",
24
+ "axios-retry": "^3.5.0",
25
+ "tus-js-client": "^3.1.1"
26
+ }
20
27
  }
@@ -0,0 +1,155 @@
1
+ import { Core, MetariscConfig } from "../core";
2
+ import Utils from "../utils";
3
+ import type { AxiosResponse } from "axios";
4
+ import { Client } from "../client";
5
+ import { Collection } from "../collection";
6
+ import { Dossier } from '../model/Dossier';
7
+ import { PostDossierRequest } from '../model/PostDossierRequest';
8
+ import { Workflow } from '../model/Workflow';
9
+ import { Tag } from '../model/Tag';
10
+ import { Document } from '../model/Document';
11
+
12
+ export class DossiersAPI extends Core {
13
+ constructor(config: MetariscConfig, client?: Client) {
14
+ super(config, client);
15
+ }
16
+
17
+ /**
18
+ * Récupération de l'ensemble des données d'un dossier.
19
+ * @param dossierId Identifiant unique du Dossier
20
+ */
21
+ async getDossier(dossierId: string): Promise<AxiosResponse<Dossier>>
22
+ {
23
+ const pathVariable = { 'dossier_id': dossierId };
24
+ return this.request({
25
+ method: 'GET',
26
+ endpoint: Utils.constructPath(pathVariable, '/dossiers/{dossier_id}'),
27
+ headers: { },
28
+ params: { },
29
+ body: {}
30
+ });
31
+ }
32
+
33
+ /**
34
+ * Récupération des détails d'un workflow.
35
+ * @param dossierId Identifiant unique du Dossier
36
+ * @param workflowId Identifiant unique du Workflow
37
+ */
38
+ async getDossierWorkflowsDetails(dossierId: string, workflowId: string): Promise<AxiosResponse<Workflow>>
39
+ {
40
+ const pathVariable = { 'dossier_id': dossierId, 'workflow_id': workflowId };
41
+ return this.request({
42
+ method: 'GET',
43
+ endpoint: Utils.constructPath(pathVariable, '/dossiers/{dossier_id}/workflows/{workflow_id}'),
44
+ headers: { },
45
+ params: { },
46
+ body: {}
47
+ });
48
+ }
49
+
50
+ /**
51
+ * Récupération de la liste des tags d'un dossier.
52
+ * @param dossierId Identifiant unique du Dossier
53
+ * @param page Numéro de page
54
+ * @param perPage Nombre de résultats demandé
55
+ */
56
+ paginateDossierTags(dossierId: string, page?: number, perPage?: number): Collection<Tag>
57
+ {
58
+ const pathVariable = { 'dossier_id': dossierId };
59
+ return this.collect<Tag>({
60
+ method: 'GET',
61
+ endpoint: Utils.constructPath(pathVariable, '/dossiers/{dossier_id}/tags'),
62
+ headers: { },
63
+ params: { 'page': page?.toString(), 'per_page': perPage?.toString() },
64
+ body: {}
65
+ });
66
+ }
67
+
68
+ /**
69
+ * Liste des documents liés à un workflow.
70
+ * @param dossierId Identifiant unique du Dossier
71
+ * @param workflowId Identifiant unique du Workflow
72
+ * @param page Numéro de page
73
+ * @param perPage Nombre de résultats demandé
74
+ */
75
+ paginateDossierWorkflowDocuments(dossierId: string, workflowId: string, page?: number, perPage?: number): Collection<Document>
76
+ {
77
+ const pathVariable = { 'dossier_id': dossierId, 'workflow_id': workflowId };
78
+ return this.collect<Document>({
79
+ method: 'GET',
80
+ endpoint: Utils.constructPath(pathVariable, '/dossiers/{dossier_id}/workflows/{workflow_id}/documents'),
81
+ headers: { },
82
+ params: { 'page': page?.toString(), 'per_page': perPage?.toString() },
83
+ body: {}
84
+ });
85
+ }
86
+
87
+ /**
88
+ * Récupération de la liste des workflows d'un dossier.
89
+ * @param dossierId Identifiant unique du Dossier
90
+ * @param page Numéro de page
91
+ * @param perPage Nombre de résultats demandé
92
+ */
93
+ paginateDossierWorkflows(dossierId: string, page?: number, perPage?: number): Collection<Workflow>
94
+ {
95
+ const pathVariable = { 'dossier_id': dossierId };
96
+ return this.collect<Workflow>({
97
+ method: 'GET',
98
+ endpoint: Utils.constructPath(pathVariable, '/dossiers/{dossier_id}/workflows'),
99
+ headers: { },
100
+ params: { 'page': page?.toString(), 'per_page': perPage?.toString() },
101
+ body: {}
102
+ });
103
+ }
104
+
105
+ /**
106
+ * Récupération de la liste des dossiers selon des critères de recherche.
107
+ * @param page Numéro de page
108
+ * @param perPage Nombre de résultats demandé
109
+ */
110
+ paginateDossiers(page?: number, perPage?: number): Collection<Dossier>
111
+ {
112
+ const pathVariable = { };
113
+ return this.collect<Dossier>({
114
+ method: 'GET',
115
+ endpoint: Utils.constructPath(pathVariable, '/dossiers'),
116
+ headers: { },
117
+ params: { 'page': page?.toString(), 'per_page': perPage?.toString() },
118
+ body: {}
119
+ });
120
+ }
121
+
122
+ /**
123
+ * TODO : Modification d'un dossier existant.
124
+ * @param dossierId Identifiant unique du Dossier
125
+ * @param dossier
126
+ */
127
+ async patchDossier(dossierId: string, dossier?: Dossier): Promise<AxiosResponse<Dossier>>
128
+ {
129
+ const pathVariable = { 'dossier_id': dossierId };
130
+ return this.request({
131
+ method: 'PATCH',
132
+ endpoint: Utils.constructPath(pathVariable, '/dossiers/{dossier_id}'),
133
+ headers: { },
134
+ params: { },
135
+ body: { 'id': dossier?.id, 'type': dossier?.type, 'description': dossier?.description, 'date_de_creation': dossier?.date_de_creation, 'createur': dossier?.createur, 'application_utilisee': dossier?.application_utilisee, 'statut': dossier?.statut }
136
+ });
137
+ }
138
+
139
+ /**
140
+ * TODO : Création d'un nouveau dossier.
141
+ * @param postDossierRequest
142
+ */
143
+ async postDossier(postDossierRequest?: PostDossierRequest): Promise<AxiosResponse<Dossier>>
144
+ {
145
+ const pathVariable = { };
146
+ return this.request({
147
+ method: 'POST',
148
+ endpoint: Utils.constructPath(pathVariable, '/dossiers'),
149
+ headers: { },
150
+ params: { },
151
+ body: { 'titre': postDossierRequest?.titre, 'description': postDossierRequest?.description, 'workflows': postDossierRequest?.workflows }
152
+ });
153
+ }
154
+
155
+ }
@@ -0,0 +1,101 @@
1
+ import { Core, MetariscConfig } from "../core";
2
+ import Utils from "../utils";
3
+ import type { AxiosResponse } from "axios";
4
+ import { Client } from "../client";
5
+ import { Collection } from "../collection";
6
+ import { Evenement } from '../model/Evenement';
7
+ import { PostEvenementRequest } from '../model/PostEvenementRequest';
8
+ import { Utilisateur } from '../model/Utilisateur';
9
+
10
+ export class EvenementsAPI extends Core {
11
+ constructor(config: MetariscConfig, client?: Client) {
12
+ super(config, client);
13
+ }
14
+
15
+ /**
16
+ * Suppression d'un événement correspondant à l'id donné.
17
+ * @param evenementId Identifiant unique de l'Événement
18
+ */
19
+ async deleteEvenement(evenementId: string): Promise<AxiosResponse<void>>
20
+ {
21
+ const pathVariable = { 'evenement_id': evenementId };
22
+ return this.request({
23
+ method: 'DELETE',
24
+ endpoint: Utils.constructPath(pathVariable, '/evenements/{evenement_id}'),
25
+ headers: { },
26
+ params: { },
27
+ body: {}
28
+ });
29
+ }
30
+
31
+ /**
32
+ * Récupération des détails d'un événement correspondant à l'id donné.
33
+ * @param evenementId Identifiant unique de l'Événement
34
+ * @param evenement
35
+ */
36
+ async getEvenementDetails(evenementId: string, evenement?: Evenement): Promise<AxiosResponse<Evenement>>
37
+ {
38
+ const pathVariable = { 'evenement_id': evenementId };
39
+ return this.request({
40
+ method: 'GET',
41
+ endpoint: Utils.constructPath(pathVariable, '/evenements/{evenement_id}'),
42
+ headers: { },
43
+ params: { },
44
+ body: { 'id': evenement?.id, 'title': evenement?.title, 'type': evenement?.type, 'description': evenement?.description, 'date_debut': evenement?.date_debut, 'date_fin': evenement?.date_fin }
45
+ });
46
+ }
47
+
48
+ /**
49
+ * Récupération d'une liste paginée d'utilisateurs liés à un événement calendaire.
50
+ * @param evenementId Identifiant unique de l'Événement
51
+ * @param page Le numéro de la page.
52
+ * @param perPage Limite le nombre d'objets retournés. La limite est comprise entre 1 et 100, la valeur par défaut étant de 10.
53
+ */
54
+ paginateEvenementUtilisateurs(evenementId: string, page?: number, perPage?: number): Collection<Utilisateur>
55
+ {
56
+ const pathVariable = { 'evenement_id': evenementId };
57
+ return this.collect<Utilisateur>({
58
+ method: 'GET',
59
+ endpoint: Utils.constructPath(pathVariable, '/evenements/{evenement_id}/utilisateurs'),
60
+ headers: { },
61
+ params: { 'page': page?.toString(), 'per_page': perPage?.toString() },
62
+ body: {}
63
+ });
64
+ }
65
+
66
+ /**
67
+ * Récupération des détails de tous les événements calendaires existants.
68
+ * @param page Le numéro de la page.
69
+ * @param perPage Limite le nombre d'objets retournés. La limite est comprise entre 1 et 100, la valeur par défaut étant de 10.
70
+ * @param type Le type d'événement
71
+ * @param period la période (ISO 8601) séparée par un slash (/) pendant laquelle l'événement se déroule. Exemple 2004-12-02T23:00/2005-01-01T12:30
72
+ */
73
+ paginateEvenements(page?: number, perPage?: number, type?: string, period?: string): Collection<Evenement>
74
+ {
75
+ const pathVariable = { };
76
+ return this.collect<Evenement>({
77
+ method: 'GET',
78
+ endpoint: Utils.constructPath(pathVariable, '/evenements'),
79
+ headers: { },
80
+ params: { 'page': page?.toString(), 'per_page': perPage?.toString(), 'type': type, 'period': period },
81
+ body: {}
82
+ });
83
+ }
84
+
85
+ /**
86
+ * TODO : Création d'un événement.
87
+ * @param postEvenementRequest
88
+ */
89
+ async postEvenement(postEvenementRequest?: PostEvenementRequest): Promise<AxiosResponse<Evenement>>
90
+ {
91
+ const pathVariable = { };
92
+ return this.request({
93
+ method: 'POST',
94
+ endpoint: Utils.constructPath(pathVariable, '/evenements'),
95
+ headers: { },
96
+ params: { },
97
+ body: { 'title': postEvenementRequest?.title, 'type': postEvenementRequest?.type, 'description': postEvenementRequest?.description, 'date_debut': postEvenementRequest?.date_debut, 'date_fin': postEvenementRequest?.date_fin }
98
+ });
99
+ }
100
+
101
+ }
@@ -0,0 +1,79 @@
1
+ import { Core, MetariscConfig } from "../core";
2
+ import Utils from "../utils";
3
+ import type { AxiosResponse } from "axios";
4
+ import { Client } from "../client";
5
+ import { Collection } from "../collection";
6
+ import { Notification } from '../model/Notification';
7
+ import { PostNotificationRequest } from '../model/PostNotificationRequest';
8
+
9
+ export class NotificationsAPI extends Core {
10
+ constructor(config: MetariscConfig, client?: Client) {
11
+ super(config, client);
12
+ }
13
+
14
+ /**
15
+ * Suppression d'une notification correspondante à l'id donné.
16
+ * @param notificationId Identifiant unique de la Notification
17
+ */
18
+ async deleteNotification(notificationId: string): Promise<AxiosResponse<void>>
19
+ {
20
+ const pathVariable = { 'notification_id': notificationId };
21
+ return this.request({
22
+ method: 'DELETE',
23
+ endpoint: Utils.constructPath(pathVariable, '/notifications/{notification_id}'),
24
+ headers: { },
25
+ params: { },
26
+ body: {}
27
+ });
28
+ }
29
+
30
+ /**
31
+ * Récupération des détails d'une notification correspondante à l'id donné.
32
+ * @param notificationId Identifiant unique de la Notification
33
+ */
34
+ async getNotification(notificationId: string): Promise<AxiosResponse<Notification>>
35
+ {
36
+ const pathVariable = { 'notification_id': notificationId };
37
+ return this.request({
38
+ method: 'GET',
39
+ endpoint: Utils.constructPath(pathVariable, '/notifications/{notification_id}'),
40
+ headers: { },
41
+ params: { },
42
+ body: {}
43
+ });
44
+ }
45
+
46
+ /**
47
+ * Récupération des détails de toutes les notifications existantes pour l'utilisateur connecté.
48
+ * @param page Numéro de page
49
+ * @param perPage Nombre de résultats demandé
50
+ */
51
+ paginateNotifications(page?: number, perPage?: number): Collection<Notification>
52
+ {
53
+ const pathVariable = { };
54
+ return this.collect<Notification>({
55
+ method: 'GET',
56
+ endpoint: Utils.constructPath(pathVariable, '/notifications'),
57
+ headers: { },
58
+ params: { 'page': page?.toString(), 'per_page': perPage?.toString() },
59
+ body: {}
60
+ });
61
+ }
62
+
63
+ /**
64
+ * Création d'une notification.
65
+ * @param postNotificationRequest
66
+ */
67
+ async postNotification(postNotificationRequest?: PostNotificationRequest): Promise<AxiosResponse<Notification>>
68
+ {
69
+ const pathVariable = { };
70
+ return this.request({
71
+ method: 'POST',
72
+ endpoint: Utils.constructPath(pathVariable, '/notifications'),
73
+ headers: { },
74
+ params: { },
75
+ body: { 'title': postNotificationRequest?.title, 'message': postNotificationRequest?.message, 'contexte': postNotificationRequest?.contexte, 'utilisateur_id': postNotificationRequest?.utilisateur_id }
76
+ });
77
+ }
78
+
79
+ }
@@ -0,0 +1,46 @@
1
+ import { Core, MetariscConfig } from "../core";
2
+ import Utils from "../utils";
3
+ import type { AxiosResponse } from "axios";
4
+ import { Client } from "../client";
5
+ import { Collection } from "../collection";
6
+ import { Organisation } from '../model/Organisation';
7
+
8
+ export class OrganisationAPI extends Core {
9
+ constructor(config: MetariscConfig, client?: Client) {
10
+ super(config, client);
11
+ }
12
+
13
+ /**
14
+ * Récupération des détails d'une organisation.
15
+ * @param orgId ID de l'organisation
16
+ */
17
+ async getOrganisation(orgId: string): Promise<AxiosResponse<Organisation>>
18
+ {
19
+ const pathVariable = { 'org_id': orgId };
20
+ return this.request({
21
+ method: 'GET',
22
+ endpoint: Utils.constructPath(pathVariable, '/organisations/{org_id}'),
23
+ headers: { },
24
+ params: { },
25
+ body: {}
26
+ });
27
+ }
28
+
29
+ /**
30
+ * Liste paginée des organisations.
31
+ * @param page Numéro de page
32
+ * @param perPage Nombre de résultats demandé
33
+ */
34
+ paginateOrganisations(page?: number, perPage?: number): Collection<Organisation>
35
+ {
36
+ const pathVariable = { };
37
+ return this.collect<Organisation>({
38
+ method: 'GET',
39
+ endpoint: Utils.constructPath(pathVariable, '/organisations/'),
40
+ headers: { },
41
+ params: { 'page': page.toString(), 'per_page': perPage.toString() },
42
+ body: {}
43
+ });
44
+ }
45
+
46
+ }
@@ -0,0 +1,46 @@
1
+ import { Core, MetariscConfig } from "../core";
2
+ import Utils from "../utils";
3
+ import type { AxiosResponse } from "axios";
4
+ import { Client } from "../client";
5
+ import { Collection } from "../collection";
6
+ import { Organisation } from '../model/Organisation';
7
+
8
+ export class OrganisationsAPI extends Core {
9
+ constructor(config: MetariscConfig, client?: Client) {
10
+ super(config, client);
11
+ }
12
+
13
+ /**
14
+ * Récupération des détails d'une organisation.
15
+ * @param orgId Identifiant unique de l'Organisation
16
+ */
17
+ async getOrganisation(orgId: string): Promise<AxiosResponse<Organisation>>
18
+ {
19
+ const pathVariable = { 'org_id': orgId };
20
+ return this.request({
21
+ method: 'GET',
22
+ endpoint: Utils.constructPath(pathVariable, '/organisations/{org_id}'),
23
+ headers: { },
24
+ params: { },
25
+ body: {}
26
+ });
27
+ }
28
+
29
+ /**
30
+ * Liste paginée des organisations.
31
+ * @param page Numéro de page
32
+ * @param perPage Nombre de résultats demandé
33
+ */
34
+ paginateOrganisations(page?: number, perPage?: number): Collection<Organisation>
35
+ {
36
+ const pathVariable = { };
37
+ return this.collect<Organisation>({
38
+ method: 'GET',
39
+ endpoint: Utils.constructPath(pathVariable, '/organisations'),
40
+ headers: { },
41
+ params: { 'page': page?.toString(), 'per_page': perPage?.toString() },
42
+ body: {}
43
+ });
44
+ }
45
+
46
+ }
@@ -0,0 +1,103 @@
1
+ import { Core, MetariscConfig } from "../core";
2
+ import Utils from "../utils";
3
+ import type { AxiosResponse } from "axios";
4
+ import { Client } from "../client";
5
+ import { Collection } from "../collection";
6
+ import { PEI } from '../model/PEI';
7
+ import { Contact } from '../model/Contact';
8
+ import { DescriptifTechnique } from '../model/DescriptifTechnique';
9
+ import { PieceJointe } from '../model/PieceJointe';
10
+
11
+ export class PEIAPI extends Core {
12
+ constructor(config: MetariscConfig, client?: Client) {
13
+ super(config, client);
14
+ }
15
+
16
+ /**
17
+ * Récupération de l'ensemble des données d'un PEI.
18
+ * @param peiId Identifiant unique du PEI
19
+ */
20
+ async getPei(peiId: string): Promise<AxiosResponse<PEI>>
21
+ {
22
+ const pathVariable = { 'pei_id': peiId };
23
+ return this.request({
24
+ method: 'GET',
25
+ endpoint: Utils.constructPath(pathVariable, '/pei/{pei_id}'),
26
+ headers: { },
27
+ params: { },
28
+ body: {}
29
+ });
30
+ }
31
+
32
+ /**
33
+ * Récupération de la liste des Points d'Eau Incendie (PEI) selon des critères de recherche.
34
+ * @param page Numéro de page
35
+ * @param perPage Nombre de résultats demandé
36
+ */
37
+ paginatePei(page?: number, perPage?: number): Collection<PEI>
38
+ {
39
+ const pathVariable = { };
40
+ return this.collect<PEI>({
41
+ method: 'GET',
42
+ endpoint: Utils.constructPath(pathVariable, '/pei'),
43
+ headers: { },
44
+ params: { 'page': page?.toString(), 'per_page': perPage?.toString() },
45
+ body: {}
46
+ });
47
+ }
48
+
49
+ /**
50
+ * Récupération de la liste des contacts d'un Point d'Eau Incendie.
51
+ * @param peiId Identifiant unique du PEI
52
+ * @param page Numéro de page
53
+ * @param perPage Nombre de résultats demandé
54
+ */
55
+ paginatePeiContacts(peiId: string, page?: number, perPage?: number): Collection<Contact>
56
+ {
57
+ const pathVariable = { 'pei_id': peiId };
58
+ return this.collect<Contact>({
59
+ method: 'GET',
60
+ endpoint: Utils.constructPath(pathVariable, '/pei/{pei_id}/contacts'),
61
+ headers: { },
62
+ params: { 'page': page?.toString(), 'per_page': perPage?.toString() },
63
+ body: {}
64
+ });
65
+ }
66
+
67
+ /**
68
+ * Récupération de l'historique d'un POI.
69
+ * @param peiId Identifiant unique du PEI
70
+ * @param page Numéro de page
71
+ * @param perPage Nombre de résultats demandé
72
+ */
73
+ paginatePeiHistorique(peiId: string, page?: number, perPage?: number): Collection<DescriptifTechnique>
74
+ {
75
+ const pathVariable = { 'pei_id': peiId };
76
+ return this.collect<DescriptifTechnique>({
77
+ method: 'GET',
78
+ endpoint: Utils.constructPath(pathVariable, '/pei/{pei_id}/historique'),
79
+ headers: { },
80
+ params: { 'page': page?.toString(), 'per_page': perPage?.toString() },
81
+ body: {}
82
+ });
83
+ }
84
+
85
+ /**
86
+ * Récupération de la liste des pièces jointes d'un Point d'Eau Incendie.
87
+ * @param peiId Identifiant unique du PEI
88
+ * @param page Numéro de page
89
+ * @param perPage Nombre de résultats demandé
90
+ */
91
+ paginatePeiPiecesJointes(peiId: string, page?: number, perPage?: number): Collection<PieceJointe>
92
+ {
93
+ const pathVariable = { 'pei_id': peiId };
94
+ return this.collect<PieceJointe>({
95
+ method: 'GET',
96
+ endpoint: Utils.constructPath(pathVariable, '/pei/{pei_id}/pieces_jointes'),
97
+ headers: { },
98
+ params: { 'page': page?.toString(), 'per_page': perPage?.toString() },
99
+ body: {}
100
+ });
101
+ }
102
+
103
+ }