@insignia-education/api-sdk-js 0.15.83 → 0.15.85
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 +1 -1
- package/src/api/v1/Admin.js +42 -0
- package/src/api/v1/Users.js +6 -1
package/package.json
CHANGED
package/src/api/v1/Admin.js
CHANGED
|
@@ -14,4 +14,46 @@ export default class Admin {
|
|
|
14
14
|
statisticsSales({ fromDate, toDate } = {}) {
|
|
15
15
|
return this.#client.get('/admin/statistics/sales', { from_date: fromDate, to_date: toDate });
|
|
16
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
|
+
}
|
|
17
59
|
}
|
package/src/api/v1/Users.js
CHANGED
|
@@ -89,7 +89,12 @@ export default class Users {
|
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
/**
|
|
92
|
+
/**
|
|
93
|
+
* get() accepts an optional { courseId } filter to narrow to a single course.
|
|
94
|
+
* A row's recording_url_video/recording_url_audio are only populated once Zoom's
|
|
95
|
+
* recording is archived AND this user's UserCourse.recording_view allows it for that
|
|
96
|
+
* course (staff always see it) — null otherwise, even if a recording exists.
|
|
97
|
+
*/
|
|
93
98
|
sessions(userId) {
|
|
94
99
|
const base = `/users/${userId}/sessions`;
|
|
95
100
|
const client = this.#client;
|