@insignia-education/api-sdk-js 0.24.4 → 0.25.2

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/README.md CHANGED
@@ -276,6 +276,30 @@ await v1.organizations.create(data);
276
276
  await v1.organizations.edit(1, data);
277
277
  ```
278
278
 
279
+ ### Games
280
+
281
+ ```js
282
+ await v1.games.get(); // paginated: get(null, { search, page, perPage })
283
+ await v1.games.get(1);
284
+ await v1.games.create({ title: 'Quiz night', type: 'kahoot' }); // type: kahoot | jeopardy
285
+ await v1.games.edit(1, { status: 'lobby' }); // draft | lobby | in_progress | finished
286
+ await v1.games.delete(1);
287
+ await v1.games.restore(1);
288
+ await v1.games.players(1);
289
+ await v1.games.join(1);
290
+ await v1.games.removePlayer(1, 5);
291
+ await v1.games.regenerateShare(1); // new share_token; old link stops working
292
+ await v1.games.shared(token).get(); // public — no login needed
293
+ await v1.games.shared(token).join(); // logged-in user
294
+ await v1.games.shared(token).guestJoin('Ana'); // non-logged user, needs allow_guests; returns guest_token
295
+ await v1.games.shared(token).guestQuestions(guestToken);
296
+ await v1.games.questions(1).get();
297
+ await v1.games.questions(1).create(data);
298
+ await v1.games.questions(1).edit(2, { enabled: false });
299
+ await v1.games.questions(1).delete(2);
300
+ await v1.games.questions(1).restore(2);
301
+ ```
302
+
279
303
  ### Quizzes
280
304
 
281
305
  ```js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@insignia-education/api-sdk-js",
3
- "version": "0.24.4",
3
+ "version": "0.25.2",
4
4
  "description": "JavaScript SDK for the Insignia Education API",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -226,6 +226,14 @@ export default class Admin {
226
226
  return this.#client.get('/admin/actions/status', { limit });
227
227
  }
228
228
 
229
+ /**
230
+ * One repo's slice of actionsStatus() — `{ available, runs, pull_requests, ... }` — so the
231
+ * dashboard can request every repo in parallel rather than waiting on the combined call.
232
+ */
233
+ actionsRepoStatus(repo, { limit } = {}) {
234
+ return this.#client.get(`/admin/actions/${repo}/status`, { limit });
235
+ }
236
+
229
237
  /**
230
238
  * One workflow run's jobs, each with its own steps — lets the dashboard show a run's
231
239
  * breakdown inline instead of linking out to GitHub. Resolves `{ available: false }`
@@ -0,0 +1,69 @@
1
+ export default class Games {
2
+ #client;
3
+
4
+ constructor(client) {
5
+ this.#client = client;
6
+ }
7
+
8
+ /**
9
+ * With no id: paginated list of the games the authenticated user hosts or plays in
10
+ * (admins get every game). Pass search/page/perPage to filter and page it.
11
+ * Write methods (create/edit/delete/restore) are teacher+ and, except for admins, host-only.
12
+ */
13
+ get(id = null, { search = null, page = null, perPage = null } = {}) {
14
+ if (id) return this.#client.get(`/games/${id}`);
15
+ return this.#client.get('/games', { search, page, per_page: perPage ?? 15 });
16
+ }
17
+ /** `data`: `{ title, type }` — type is `kahoot` or `jeopardy`. The creator becomes the host. */
18
+ create(data) { return this.#client.put('/games', data); }
19
+ /** `data`: `{ title?, status?, allow_guests? }` — `allow_guests` lets non-logged users join through the share link; status is `draft`, `lobby`, `in_progress` or `finished`. */
20
+ edit(id, data) { return this.#client.patch(`/games/${id}`, data); }
21
+ delete(id) { return this.#client.del(`/games/${id}`); }
22
+ /** Undoes delete() — brings a soft-deleted game back. */
23
+ restore(id) { return this.#client.post(`/games/${id}/restore`); }
24
+
25
+ /** Host and players of a game. */
26
+ players(id) { return this.#client.get(`/games/${id}/players`); }
27
+ /** Takes a seat as a player — only while the game's status is `lobby`. */
28
+ join(id) { return this.#client.post(`/games/${id}/join`); }
29
+ /** Host/admin only; hosts themselves can't be removed. */
30
+ removePlayer(id, userId) { return this.#client.del(`/games/${id}/players/${userId}`); }
31
+
32
+ /** Host/admin only. Issues a new share token — the old link stops working; anyone already seated keeps their seat. */
33
+ regenerateShare(id) { return this.#client.post(`/games/${id}/share/regenerate`); }
34
+
35
+ /**
36
+ * Share-link endpoints, keyed by the `share_token` only the host/admin sees on get(id).
37
+ * `get` is public (no login): `{ id, title, type, status, allow_guests }`. `join` is for a logged-in
38
+ * user. `guestJoin(name)` seats a non-logged user (host must have enabled `allow_guests`) and returns
39
+ * a `guest_token`, which `guestQuestions(guestToken)` then needs to read the enabled questions.
40
+ */
41
+ shared(token) {
42
+ const client = this.#client;
43
+ const base = `/games/shared/${token}`;
44
+ return {
45
+ get: () => client.get(base),
46
+ join: () => client.post(`${base}/join`),
47
+ guestJoin: (name) => client.post(`${base}/guest`, { name }),
48
+ guestQuestions: (guestToken) => client.get(`${base}/questions`, { guest_token: guestToken }),
49
+ };
50
+ }
51
+
52
+ /**
53
+ * Hosts/admins get every question (answers included); players only the enabled ones,
54
+ * without answers. Kahoot data: `{ question, options: [{ text, is_correct }], points?, time_limit? }`;
55
+ * Jeopardy data: `{ question, category, answer, points? }`. `enabled` toggles a question on/off.
56
+ */
57
+ questions(gameId) {
58
+ const client = this.#client;
59
+ const base = `/games/${gameId}/questions`;
60
+ return {
61
+ get: () => client.get(base),
62
+ create: (data) => client.put(base, data),
63
+ edit: (id, data) => client.patch(`${base}/${id}`, data),
64
+ delete: (id) => client.del(`${base}/${id}`),
65
+ /** Undoes delete() — brings a soft-deleted question back. */
66
+ restore: (id) => client.post(`${base}/${id}/restore`),
67
+ };
68
+ }
69
+ }
@@ -17,6 +17,7 @@ import Dashboard from './Dashboard.js';
17
17
  import EducationCenter from './EducationCenter.js';
18
18
  import Employee from './Employee.js';
19
19
  import Files from './Files.js';
20
+ import Games from './Games.js';
20
21
  import Forums from './Forums.js';
21
22
  import Hashes from './Hashes.js';
22
23
  import Insignias from './Insignias.js';
@@ -88,6 +89,7 @@ export default class InsigniaApiV1 extends InsigniaApi {
88
89
  this.organizations = new Organizations(this);
89
90
  this.paymentMethods = new PaymentMethods(this);
90
91
  this.payments = new Payments(this);
92
+ this.games = new Games(this);
91
93
  this.quizzes = new Quizzes(this);
92
94
  this.sales = new Sales(this);
93
95
  this.search = new Search(this);