@communecter/cocolight-api-client 1.0.22 → 1.0.24

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@communecter/cocolight-api-client",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
4
4
  "description": "Client Axios simplifié pour l'API cocolight",
5
5
  "repository": {
6
6
  "type": "git",
package/src/api/Badge.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { ApiError } from "../error.js";
1
2
  import BaseEntity from "./BaseEntity.js";
2
3
 
3
4
  export class Badge extends BaseEntity {
@@ -25,6 +26,9 @@ export class Badge extends BaseEntity {
25
26
  };
26
27
 
27
28
  async _add(payload) {
29
+ if (!this._calledFromSave) {
30
+ throw new ApiError("utilisation invalide de _add, utilisez save");
31
+ }
28
32
  payload.id = this._newId?.();
29
33
  if (payload.slug) delete payload.slug;
30
34
 
@@ -46,6 +50,10 @@ export class Badge extends BaseEntity {
46
50
  }
47
51
 
48
52
  async _update(payload) {
53
+ // TODO: qui peut modifier un badge ?
54
+ if (!this._calledFromSave) {
55
+ throw new ApiError("utilisation invalide de _update, utilisez save");
56
+ }
49
57
  if (payload.id) delete payload.id;
50
58
  let hasChanged = false;
51
59
 
@@ -67,51 +75,51 @@ export class Badge extends BaseEntity {
67
75
  }
68
76
 
69
77
  async getOrganizations() {
70
- throw new Error(`getOrganizations n'existe pas dans ${this.constructor.name}`);
78
+ throw new ApiError(`getOrganizations n'existe pas dans ${this.constructor.name}`);
71
79
  }
72
80
 
73
81
  async getProjects() {
74
- throw new Error(`getProjects n'existe pas dans ${this.constructor.name}`);
82
+ throw new ApiError(`getProjects n'existe pas dans ${this.constructor.name}`);
75
83
  }
76
84
 
77
85
  async getEvents() {
78
- throw new Error(`getEvents n'existe pas dans ${this.constructor.name}`);
86
+ throw new ApiError(`getEvents n'existe pas dans ${this.constructor.name}`);
79
87
  }
80
88
 
81
89
  async getPois() {
82
- throw new Error(`getPois n'existe pas dans ${this.constructor.name}`);
90
+ throw new ApiError(`getPois n'existe pas dans ${this.constructor.name}`);
83
91
  }
84
92
 
85
93
  async getBadgesIssuer() {
86
- throw new Error(`getBadgesIssuer n'existe pas dans ${this.constructor.name}`);
94
+ throw new ApiError(`getBadgesIssuer n'existe pas dans ${this.constructor.name}`);
87
95
  }
88
96
 
89
97
  async getNews() {
90
- throw new Error(`getNews n'existe pas dans ${this.constructor.name}`);
98
+ throw new ApiError(`getNews n'existe pas dans ${this.constructor.name}`);
91
99
  }
92
100
 
93
101
  async getSubscribers() {
94
- throw new Error(`getSubscribers n'existe pas dans ${this.constructor.name}`);
102
+ throw new ApiError(`getSubscribers n'existe pas dans ${this.constructor.name}`);
95
103
  }
96
104
 
97
105
  async project() {
98
- throw new Error(`project n'existe pas dans ${this.constructor.name}`);
106
+ throw new ApiError(`project n'existe pas dans ${this.constructor.name}`);
99
107
  }
100
108
 
101
109
  async poi() {
102
- throw new Error(`poi n'existe pas dans ${this.constructor.name}`);
110
+ throw new ApiError(`poi n'existe pas dans ${this.constructor.name}`);
103
111
  }
104
112
 
105
113
  async event() {
106
- throw new Error(`event n'existe pas dans ${this.constructor.name}`);
114
+ throw new ApiError(`event n'existe pas dans ${this.constructor.name}`);
107
115
  }
108
116
 
109
117
  async badge() {
110
- throw new Error(`badge n'existe pas dans ${this.constructor.name}`);
118
+ throw new ApiError(`badge n'existe pas dans ${this.constructor.name}`);
111
119
  }
112
120
 
113
121
  async news() {
114
- throw new Error(`news n'existe pas dans ${this.constructor.name}`);
122
+ throw new ApiError(`news n'existe pas dans ${this.constructor.name}`);
115
123
  }
116
124
 
117
125
  }