@insignia-education/api-sdk-js 0.15.36 → 0.15.40

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/AGENTS.md CHANGED
@@ -60,6 +60,13 @@ api.users.cashReceivers();
60
60
  2. Register it in `src/api/v1/index.js`
61
61
  3. Write integration tests in `tests/integration/api/v1/resource-name.test.js`
62
62
 
63
+ ## Testing coverage requirements
64
+
65
+ Same pattern as `api`'s endpoint tests (see its `AGENTS.md`), applied per SDK method:
66
+
67
+ - **Missing/malformed params** — call each method with required params omitted and with wrong-format values; confirm the SDK surfaces the API's validation error correctly rather than swallowing it or throwing something unrelated.
68
+ - **Permissions** — exercise each method as every relevant user role (including unauthenticated) against the API and confirm the SDK surfaces 401/403 correctly — not just the happy-path success response for the one role the method was built for.
69
+
63
70
  ## Internationalisation (i18n)
64
71
  The SDK is language-neutral — it must never contain human-readable strings.
65
72
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@insignia-education/api-sdk-js",
3
- "version": "0.15.36",
3
+ "version": "0.15.40",
4
4
  "description": "JavaScript SDK for the Insignia Education API",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -0,0 +1,12 @@
1
+ export default class Admin {
2
+ #client;
3
+
4
+ constructor(client) {
5
+ this.#client = client;
6
+ }
7
+
8
+ /** Paginated list of courses with their currently-active course_dates. */
9
+ courseDates({ page, perPage } = {}) {
10
+ return this.#client.get('/admin/courses/current-dates', { page, per_page: perPage });
11
+ }
12
+ }
@@ -27,6 +27,9 @@ export default class Courses {
27
27
  /** Users enrolled on this course as a teacher (user_courses.teacher = 1). */
28
28
  teachers(courseId) { return this.#client.get(`/courses/${courseId}/teachers`); }
29
29
 
30
+ /** Customer-facing session-credit pricing (no commission fields) for self-checkout. */
31
+ sessionsPricing(courseId) { return this.#client.get(`/courses/${courseId}/sessions/pricing`); }
32
+
30
33
  dates(courseId) {
31
34
  const base = `/courses/${courseId}/dates`;
32
35
  return {
@@ -0,0 +1,10 @@
1
+ export default class Dashboard {
2
+ #client;
3
+
4
+ constructor(client) {
5
+ this.#client = client;
6
+ }
7
+
8
+ /** Which dashboard modules the current user should see: { teacher, education_center, organization }. */
9
+ modules() { return this.#client.get('/dashboard/modules'); }
10
+ }
@@ -0,0 +1,10 @@
1
+ export default class EducationCenter {
2
+ #client;
3
+
4
+ constructor(client) {
5
+ this.#client = client;
6
+ }
7
+
8
+ /** Per-course stats (enrolled count, completion rate, revenue) for courses owned by the current user. */
9
+ coursesStats() { return this.#client.get('/education-center/courses/stats'); }
10
+ }
@@ -0,0 +1,10 @@
1
+ export default class Sales {
2
+ #client;
3
+
4
+ constructor(client) {
5
+ this.#client = client;
6
+ }
7
+
8
+ /** Options for the UTM link generator: courses, session types, active coupons, known utm source/medium/campaign values. */
9
+ utmGeneratorOptions() { return this.#client.get('/sales/utm-generator/options'); }
10
+ }
@@ -42,4 +42,18 @@ export default class Teacher {
42
42
  delete: (id) => this.#client.del(`${base}/${id}`),
43
43
  };
44
44
  }
45
+
46
+ dashboard() {
47
+ const base = '/teacher/dashboard';
48
+ return {
49
+ /** Own scheduled sessions for a given date (YYYY-MM-DD). */
50
+ sessions: (date) => this.#client.get(`${base}/sessions`, { date }),
51
+ /** Ungraded quiz submissions grouped by course, for every course this teacher teaches. */
52
+ ungradedQuizzes: () => this.#client.get(`${base}/quizzes/ungraded`),
53
+ /** Mark a student's attendance (present: true/false) on one of this teacher's own sessions. */
54
+ markAttendance: (sessionId, present) => this.#client.patch(`${base}/sessions/${sessionId}/attendance`, { present }),
55
+ /** Attendance/substitution totals. Pass { from, to } (YYYY-MM-DD) to filter, omit for all-time. */
56
+ stats: ({ from, to } = {}) => this.#client.get(`${base}/stats`, { from, to }),
57
+ };
58
+ }
45
59
  }
@@ -1,4 +1,5 @@
1
1
  import InsigniaApi from '../index.js';
2
+ import Admin from './Admin.js';
2
3
  import Auth from './Auth.js';
3
4
  import Accounts from './Accounts.js';
4
5
  import Categories from './Categories.js';
@@ -10,6 +11,8 @@ import Countries from './Countries.js';
10
11
  import Coupons from './Coupons.js';
11
12
  import Courses from './Courses.js';
12
13
  import Currencies from './Currencies.js';
14
+ import Dashboard from './Dashboard.js';
15
+ import EducationCenter from './EducationCenter.js';
13
16
  import Files from './Files.js';
14
17
  import Forums from './Forums.js';
15
18
  import Hashes from './Hashes.js';
@@ -21,6 +24,7 @@ import Organizations from './Organizations.js';
21
24
  import PaymentMethods from './PaymentMethods.js';
22
25
  import Payments from './Payments.js';
23
26
  import Quizzes from './Quizzes.js';
27
+ import Sales from './Sales.js';
24
28
  import Search from './Search.js';
25
29
  import ShortLinks from './ShortLinks.js';
26
30
  import Surveys from './Surveys.js';
@@ -48,6 +52,7 @@ export default class InsigniaApiV1 extends InsigniaApi {
48
52
  let url = InsigniaApiV1._resolve(baseUrl);
49
53
  super(url);
50
54
 
55
+ this.admin = new Admin(this);
51
56
  this.auth = new Auth(this);
52
57
  this.accounts = new Accounts(this);
53
58
  this.categories = new Categories(this);
@@ -59,6 +64,8 @@ export default class InsigniaApiV1 extends InsigniaApi {
59
64
  this.coupons = new Coupons(this);
60
65
  this.courses = new Courses(this);
61
66
  this.currencies = new Currencies(this);
67
+ this.dashboard = new Dashboard(this);
68
+ this.educationCenter = new EducationCenter(this);
62
69
  this.files = new Files(this);
63
70
  this.forums = new Forums(this);
64
71
  this.hashes = new Hashes(this);
@@ -70,6 +77,7 @@ export default class InsigniaApiV1 extends InsigniaApi {
70
77
  this.paymentMethods = new PaymentMethods(this);
71
78
  this.payments = new Payments(this);
72
79
  this.quizzes = new Quizzes(this);
80
+ this.sales = new Sales(this);
73
81
  this.search = new Search(this);
74
82
  this.shortLinks = new ShortLinks(this);
75
83
  this.surveys = new Surveys(this);