@insignia-education/api-sdk-js 0.15.82 → 0.15.84

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": "@insignia-education/api-sdk-js",
3
- "version": "0.15.82",
3
+ "version": "0.15.84",
4
4
  "description": "JavaScript SDK for the Insignia Education API",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -9,4 +9,51 @@ export default class Admin {
9
9
  courseDates({ page, perPage } = {}) {
10
10
  return this.#client.get('/admin/courses/current-dates', { page, per_page: perPage });
11
11
  }
12
+
13
+ /** Date-range sales report: totals by status (pending/approved/rejected), and the same split by course, payment method and currency. */
14
+ statisticsSales({ fromDate, toDate } = {}) {
15
+ return this.#client.get('/admin/statistics/sales', { from_date: fromDate, to_date: toDate });
16
+ }
17
+
18
+ /** Paginated sales-report rows for a date range, with optional course/seller/payment-method/currency filters. */
19
+ reportsSales({ fromDate, toDate, courseId, sellerId, paymentMethodId, currencyId, page, perPage } = {}) {
20
+ return this.#client.get('/admin/reports/sales', {
21
+ from_date: fromDate, to_date: toDate,
22
+ course_id: courseId, seller_id: sellerId, payment_method_id: paymentMethodId, currency_id: currencyId,
23
+ page, per_page: perPage,
24
+ });
25
+ }
26
+
27
+ /** Sellers with at least one attributed payment — options for the sales report's seller filter. */
28
+ reportsSalesSellers() { return this.#client.get('/admin/reports/sales/sellers'); }
29
+
30
+ /** Direct download link for the sales report (format: 'csv' | 'xlsx') — open with <a href>, not fetch (cookie-authenticated, same convention as Users.js's invoiceUrl). */
31
+ reportsSalesExportUrl({ fromDate, toDate, courseId, sellerId, paymentMethodId, currencyId, format = 'csv' } = {}) {
32
+ return Admin.#buildUrl(this.#client.baseUrl, '/admin/reports/sales/export', {
33
+ from_date: fromDate, to_date: toDate,
34
+ course_id: courseId, seller_id: sellerId, payment_method_id: paymentMethodId, currency_id: currencyId,
35
+ format,
36
+ });
37
+ }
38
+
39
+ /** Paginated completed-courses report rows for a date range, with an optional course filter. */
40
+ reportsCompletedCourses({ fromDate, toDate, courseId, page, perPage } = {}) {
41
+ return this.#client.get('/admin/reports/completed-courses', {
42
+ from_date: fromDate, to_date: toDate, course_id: courseId, page, per_page: perPage,
43
+ });
44
+ }
45
+
46
+ /** Direct download link for the completed-courses report (format: 'csv' | 'xlsx'). */
47
+ reportsCompletedCoursesExportUrl({ fromDate, toDate, courseId, format = 'csv' } = {}) {
48
+ return Admin.#buildUrl(this.#client.baseUrl, '/admin/reports/completed-courses/export', {
49
+ from_date: fromDate, to_date: toDate, course_id: courseId, format,
50
+ });
51
+ }
52
+
53
+ static #buildUrl(baseUrl, path, params) {
54
+ const qs = new URLSearchParams(
55
+ Object.entries(params).filter(([, v]) => v !== undefined && v !== null && v !== '')
56
+ ).toString();
57
+ return `${baseUrl}${path}${qs ? `?${qs}` : ''}`;
58
+ }
12
59
  }