@metarisc/metarisc-js 0.0.1-alpha.100 → 0.0.1-alpha.102

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.
@@ -45,7 +45,7 @@ export declare class ERPAPI extends Core {
45
45
  /**
46
46
  * Récupération de la liste des Établissements Recevant du Public (ERP) selon des critères de recherche.
47
47
  */
48
- paginateErp(sort?: 'libelle' | '-libelle', libelle?: string, geojson?: string, referencesExterieures?: string | Array<string>, presenceLocauxSommeil?: boolean, typeActivite?: string | Array<string>, avisExploitation?: 'favorable' | 'defavorable', aVisiterEn?: string, siteGeographique?: string, commissionConcernee?: string, categorie?: 1 | 2 | 3 | 4 | 5, erpRattacheA?: string, titulaires?: string): Collection<ERP>;
48
+ paginateErp(sort?: 'libelle' | '-libelle', libelle?: string, geojson?: string, referencesExterieures?: string | Array<string>, presenceLocauxSommeil?: boolean, typeActivite?: string | Array<string>, avisExploitation?: 'favorable' | 'defavorable', aVisiterEn?: string, siteGeographique?: string, commissionConcernee?: string, categorie?: 1 | 2 | 3 | 4 | 5, erpRattacheA?: string, titulaires?: string, genre?: 'cellule' | 'erp'): Collection<ERP>;
49
49
  /**
50
50
  * Récupération de l'historique d'un ERP.
51
51
  */
package/lib/api/ERPAPI.js CHANGED
@@ -113,7 +113,7 @@ class ERPAPI extends core_1.Core {
113
113
  /**
114
114
  * Récupération de la liste des Établissements Recevant du Public (ERP) selon des critères de recherche.
115
115
  */
116
- paginateErp(sort, libelle, geojson, referencesExterieures, presenceLocauxSommeil, typeActivite, avisExploitation, aVisiterEn, siteGeographique, commissionConcernee, categorie, erpRattacheA, titulaires) {
116
+ paginateErp(sort, libelle, geojson, referencesExterieures, presenceLocauxSommeil, typeActivite, avisExploitation, aVisiterEn, siteGeographique, commissionConcernee, categorie, erpRattacheA, titulaires, genre) {
117
117
  const pathVariable = {};
118
118
  return this.collect({
119
119
  method: 'GET',
@@ -131,7 +131,8 @@ class ERPAPI extends core_1.Core {
131
131
  'commission_concernee': commissionConcernee === undefined ? undefined : (new String(commissionConcernee)).toString(),
132
132
  'categorie': categorie === undefined ? undefined : (new String(categorie)).toString(),
133
133
  'erp_rattache_a': erpRattacheA === undefined ? undefined : (new String(erpRattacheA)).toString(),
134
- 'titulaires': titulaires === undefined ? undefined : (new String(titulaires)).toString()
134
+ 'titulaires': titulaires === undefined ? undefined : (new String(titulaires)).toString(),
135
+ 'genre': genre === undefined ? undefined : (new String(genre)).toString()
135
136
  }),
136
137
  transformResponse: [(data) => {
137
138
  const parsedData = JSON.parse(data);
@@ -14,12 +14,14 @@ export type PaginationData = {
14
14
  total_pages: number;
15
15
  };
16
16
  type PaginationRequestConfig = {
17
+ method?: 'GET' | 'POST';
17
18
  headers?: {
18
19
  [name: string]: string | string[];
19
20
  };
20
21
  params?: {
21
22
  [param: string]: string | string[];
22
23
  };
24
+ data?: Record<string, unknown>;
23
25
  endpoint?: string;
24
26
  };
25
27
  export declare class Collection<T> {
package/lib/collection.js CHANGED
@@ -10,14 +10,23 @@ class Collection {
10
10
  * Fetch current page results.
11
11
  */
12
12
  async fetchPage(page, per_page) {
13
+ const paginationParams = {
14
+ page: page.toString(),
15
+ per_page: per_page.toString()
16
+ };
17
+ if (this.config.method === 'POST') {
18
+ return this.client.request({
19
+ method: 'POST',
20
+ endpoint: this.config.endpoint,
21
+ headers: this.config.headers,
22
+ body: { ...this.config.data, ...paginationParams }
23
+ });
24
+ }
13
25
  return this.client.request({
14
26
  method: 'GET',
15
27
  endpoint: this.config.endpoint,
16
28
  headers: this.config.headers,
17
- params: { ...this.config.params, ...{
18
- page: page.toString(),
19
- per_page: per_page.toString()
20
- } }
29
+ params: { ...this.config.params, ...paginationParams }
21
30
  });
22
31
  }
23
32
  /**
package/lib/core.js CHANGED
@@ -22,8 +22,10 @@ class Core {
22
22
  }
23
23
  collect(config) {
24
24
  return new collection_1.Collection(this, {
25
+ method: config.method,
25
26
  endpoint: config.endpoint || "/",
26
27
  params: config.params,
28
+ data: config.body,
27
29
  headers: config.headers
28
30
  });
29
31
  }
@@ -24,8 +24,13 @@ export type ERP = {
24
24
  'titulaires': Array<Utilisateur>;
25
25
  'etablissement_rattache': ERPLie | null;
26
26
  'textes_applicables': Array<TexteApplicable>;
27
+ 'genre': GenreEnum;
27
28
  };
28
29
  export declare enum AvisExploitationEnum {
29
30
  FAVORABLE = "favorable",
30
31
  DEFAVORABLE = "defavorable"
31
32
  }
33
+ export declare enum GenreEnum {
34
+ CELLULE = "cellule",
35
+ ERP = "erp"
36
+ }
package/lib/model/ERP.js CHANGED
@@ -1,8 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AvisExploitationEnum = void 0;
3
+ exports.GenreEnum = exports.AvisExploitationEnum = void 0;
4
4
  var AvisExploitationEnum;
5
5
  (function (AvisExploitationEnum) {
6
6
  AvisExploitationEnum["FAVORABLE"] = "favorable";
7
7
  AvisExploitationEnum["DEFAVORABLE"] = "defavorable";
8
8
  })(AvisExploitationEnum = exports.AvisExploitationEnum || (exports.AvisExploitationEnum = {}));
9
+ var GenreEnum;
10
+ (function (GenreEnum) {
11
+ GenreEnum["CELLULE"] = "cellule";
12
+ GenreEnum["ERP"] = "erp";
13
+ })(GenreEnum = exports.GenreEnum || (exports.GenreEnum = {}));
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@metarisc/metarisc-js",
3
3
  "main": "lib/index.js",
4
4
  "types": "lib/index.d.ts",
5
- "version": "0.0.1-alpha.100",
5
+ "version": "0.0.1-alpha.102",
6
6
  "scripts": {
7
7
  "lint": "eslint . --ext .ts --fix",
8
8
  "compile": "tsc",
package/src/api/ERPAPI.ts CHANGED
@@ -169,7 +169,8 @@ export class ERPAPI extends Core {
169
169
  commissionConcernee? : string,
170
170
  categorie? : 1 | 2 | 3 | 4 | 5,
171
171
  erpRattacheA? : string,
172
- titulaires? : string
172
+ titulaires? : string,
173
+ genre? : 'cellule' | 'erp'
173
174
  ) : Collection<ERP>
174
175
  {
175
176
  const pathVariable = { };
@@ -189,7 +190,8 @@ export class ERPAPI extends Core {
189
190
  'commission_concernee': commissionConcernee === undefined ? undefined : (new String(commissionConcernee)).toString(),
190
191
  'categorie': categorie === undefined ? undefined : (new String(categorie)).toString(),
191
192
  'erp_rattache_a': erpRattacheA === undefined ? undefined : (new String(erpRattacheA)).toString(),
192
- 'titulaires': titulaires === undefined ? undefined : (new String(titulaires)).toString()
193
+ 'titulaires': titulaires === undefined ? undefined : (new String(titulaires)).toString(),
194
+ 'genre': genre === undefined ? undefined : (new String(genre)).toString()
193
195
  }),
194
196
  transformResponse: [(data) => {
195
197
  const parsedData = JSON.parse(data);
package/src/collection.ts CHANGED
@@ -17,9 +17,11 @@ export type PaginationData = {
17
17
  };
18
18
 
19
19
  type PaginationRequestConfig = {
20
- headers ?: {[name: string]: string | string[]};
21
- params ?: {[param: string]: string | string[]};
22
- endpoint ?: string;
20
+ method?: 'GET' | 'POST';
21
+ headers?: {[name: string]: string | string[]};
22
+ params?: {[param: string]: string | string[]};
23
+ data?: Record<string, unknown>;
24
+ endpoint?: string;
23
25
  };
24
26
 
25
27
  export class Collection<T>
@@ -32,16 +34,26 @@ export class Collection<T>
32
34
  /**
33
35
  * Fetch current page results.
34
36
  */
35
- async fetchPage(page : number, per_page : number) : Promise<AxiosResponse<PaginationResults<T>>>
36
- {
37
+ async fetchPage(page: number, per_page: number): Promise<AxiosResponse<PaginationResults<T>>> {
38
+ const paginationParams = {
39
+ page: page.toString(),
40
+ per_page: per_page.toString()
41
+ };
42
+
43
+ if (this.config.method === 'POST') {
44
+ return this.client.request({
45
+ method: 'POST',
46
+ endpoint: this.config.endpoint,
47
+ headers: this.config.headers,
48
+ body: { ...this.config.data, ...paginationParams }
49
+ });
50
+ }
51
+
37
52
  return this.client.request({
38
53
  method: 'GET',
39
54
  endpoint: this.config.endpoint,
40
55
  headers: this.config.headers,
41
- params: { ...this.config.params, ...{
42
- page: page.toString(),
43
- per_page: per_page.toString()
44
- } }
56
+ params: { ...this.config.params, ...paginationParams }
45
57
  });
46
58
  }
47
59
 
package/src/core.ts CHANGED
@@ -48,8 +48,10 @@ export class Core {
48
48
 
49
49
  collect<T>(config: RequestConfig): Collection<T> {
50
50
  return new Collection<T>(this, {
51
+ method: config.method as 'GET' | 'POST',
51
52
  endpoint: config.endpoint || "/",
52
53
  params: config.params,
54
+ data: config.body,
53
55
  headers: config.headers
54
56
  });
55
57
  }
package/src/model/ERP.ts CHANGED
@@ -26,9 +26,15 @@ export type ERP = {
26
26
  'titulaires': Array<Utilisateur>;
27
27
  'etablissement_rattache': ERPLie | null;
28
28
  'textes_applicables': Array<TexteApplicable>;
29
+ 'genre': GenreEnum;
29
30
  };
30
31
 
31
32
  export enum AvisExploitationEnum {
32
33
  FAVORABLE = 'favorable',
33
34
  DEFAVORABLE = 'defavorable'
34
35
  }
36
+
37
+ export enum GenreEnum {
38
+ CELLULE = 'cellule',
39
+ ERP = 'erp'
40
+ }