@insignia-education/api-sdk-js 0.15.68 → 0.15.70
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/Client.js +5 -0
- package/src/api/v1/Users.js +2 -0
- package/tests/client.test.js +17 -0
- package/.env +0 -1
- package/.env.test +0 -5
- package/coverage/clover.xml +0 -1568
- package/coverage/coverage-final.json +0 -46
- package/coverage/lcov-report/Client.js.html +0 -463
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -161
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -210
- package/coverage/lcov-report/src/Client.js.html +0 -463
- package/coverage/lcov-report/src/api/index.html +0 -116
- package/coverage/lcov-report/src/api/index.js.html +0 -127
- package/coverage/lcov-report/src/api/v1/Accounts.js.html +0 -151
- package/coverage/lcov-report/src/api/v1/Admin.js.html +0 -121
- package/coverage/lcov-report/src/api/v1/Auth.js.html +0 -157
- package/coverage/lcov-report/src/api/v1/Categories.js.html +0 -121
- package/coverage/lcov-report/src/api/v1/Changelogs.js.html +0 -118
- package/coverage/lcov-report/src/api/v1/Configs.js.html +0 -121
- package/coverage/lcov-report/src/api/v1/ContactForms.js.html +0 -121
- package/coverage/lcov-report/src/api/v1/ConversationalTopics.js.html +0 -121
- package/coverage/lcov-report/src/api/v1/Countries.js.html +0 -112
- package/coverage/lcov-report/src/api/v1/Coupons.js.html +0 -175
- package/coverage/lcov-report/src/api/v1/Courses.js.html +0 -442
- package/coverage/lcov-report/src/api/v1/Currencies.js.html +0 -118
- package/coverage/lcov-report/src/api/v1/Dashboard.js.html +0 -115
- package/coverage/lcov-report/src/api/v1/EducationCenter.js.html +0 -115
- package/coverage/lcov-report/src/api/v1/Employee.js.html +0 -169
- package/coverage/lcov-report/src/api/v1/Files.js.html +0 -160
- package/coverage/lcov-report/src/api/v1/Forums.js.html +0 -175
- package/coverage/lcov-report/src/api/v1/Hashes.js.html +0 -121
- package/coverage/lcov-report/src/api/v1/Insignias.js.html +0 -121
- package/coverage/lcov-report/src/api/v1/Languages.js.html +0 -121
- package/coverage/lcov-report/src/api/v1/MailBlacklist.js.html +0 -118
- package/coverage/lcov-report/src/api/v1/MailingLists.js.html +0 -127
- package/coverage/lcov-report/src/api/v1/Offers.js.html +0 -142
- package/coverage/lcov-report/src/api/v1/Organizations.js.html +0 -199
- package/coverage/lcov-report/src/api/v1/PaymentMethods.js.html +0 -121
- package/coverage/lcov-report/src/api/v1/Payments.js.html +0 -310
- package/coverage/lcov-report/src/api/v1/Premiums.js.html +0 -121
- package/coverage/lcov-report/src/api/v1/Quizzes.js.html +0 -214
- package/coverage/lcov-report/src/api/v1/Sales.js.html +0 -148
- package/coverage/lcov-report/src/api/v1/Search.js.html +0 -115
- package/coverage/lcov-report/src/api/v1/ShortLinks.js.html +0 -127
- package/coverage/lcov-report/src/api/v1/Surveys.js.html +0 -181
- package/coverage/lcov-report/src/api/v1/Taxes.js.html +0 -121
- package/coverage/lcov-report/src/api/v1/Teacher.js.html +0 -322
- package/coverage/lcov-report/src/api/v1/Telegram.js.html +0 -142
- package/coverage/lcov-report/src/api/v1/TwoFactor.js.html +0 -145
- package/coverage/lcov-report/src/api/v1/UserSessionTypes.js.html +0 -112
- package/coverage/lcov-report/src/api/v1/UserTypes.js.html +0 -121
- package/coverage/lcov-report/src/api/v1/Users.js.html +0 -766
- package/coverage/lcov-report/src/api/v1/Utm.js.html +0 -151
- package/coverage/lcov-report/src/api/v1/Webauthn.js.html +0 -190
- package/coverage/lcov-report/src/api/v1/Zoom.js.html +0 -124
- package/coverage/lcov-report/src/api/v1/index.html +0 -716
- package/coverage/lcov-report/src/api/v1/index.js.html +0 -373
- package/coverage/lcov-report/src/index.html +0 -131
- package/coverage/lcov-report/src/index.js.html +0 -109
- package/coverage/lcov-report/tests/helpers.js.html +0 -145
- package/coverage/lcov-report/tests/index.html +0 -116
- package/coverage/lcov.info +0 -2541
- package/coverage/test-report.html +0 -427
package/package.json
CHANGED
package/src/Client.js
CHANGED
|
@@ -6,6 +6,11 @@ export default class InsigniaClient {
|
|
|
6
6
|
this.#baseUrl = InsigniaClient._resolve(baseUrl);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
/** For building direct links (e.g. a PDF endpoint meant for <a href>/window.open, not a JSON fetch) — see Users.js's payments().invoiceUrl(). */
|
|
10
|
+
get baseUrl() {
|
|
11
|
+
return this.#baseUrl;
|
|
12
|
+
}
|
|
13
|
+
|
|
9
14
|
static _resolve(baseUrl) {
|
|
10
15
|
const envBaseUrl = typeof process !== 'undefined'
|
|
11
16
|
? process.env?.INSIGNIA_EDUCATION_API_BASE_URL ?? null
|
package/src/api/v1/Users.js
CHANGED
|
@@ -108,6 +108,8 @@ export default class Users {
|
|
|
108
108
|
quote: (data) => client.post(`${base}/quote`, data),
|
|
109
109
|
/** Creates a Stripe PaymentIntent for this cart; returns { client_secret, publishable_key, amount } to mount Stripe Elements with. */
|
|
110
110
|
stripeIntent: (data) => client.post(`${base}/stripe/intent`, data),
|
|
111
|
+
/** Direct link to the invoice PDF (application/pdf, inline) — not a fetch: open/href this URL directly, same as support_file. Auth is via the ambient JWT cookie. */
|
|
112
|
+
invoiceUrl: (id) => `${client.baseUrl}${base}/${id}/invoice`,
|
|
111
113
|
};
|
|
112
114
|
}
|
|
113
115
|
|
package/tests/client.test.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import InsigniaClient from '../src/Client.js';
|
|
2
|
+
import Users from '../src/api/v1/Users.js';
|
|
2
3
|
|
|
3
4
|
const BASE = 'http://localhost:8000';
|
|
4
5
|
|
|
@@ -49,6 +50,11 @@ describe('baseUrl resolution', () => {
|
|
|
49
50
|
);
|
|
50
51
|
});
|
|
51
52
|
|
|
53
|
+
test('baseUrl getter exposes the resolved base URL', () => {
|
|
54
|
+
const client = new InsigniaClient('https://custom.example.com/');
|
|
55
|
+
expect(client.baseUrl).toBe('https://custom.example.com');
|
|
56
|
+
});
|
|
57
|
+
|
|
52
58
|
test('falls back to https://insigniaeducation.com when baseUrl is null and env var is not set', async () => {
|
|
53
59
|
global.fetch = mockFetch();
|
|
54
60
|
const client = new InsigniaClient(null);
|
|
@@ -246,3 +252,14 @@ describe('HTTP methods', () => {
|
|
|
246
252
|
expect(result).toBeNull();
|
|
247
253
|
});
|
|
248
254
|
});
|
|
255
|
+
|
|
256
|
+
// ─── payments(userId).invoiceUrl ──────────────────────────────────────────────
|
|
257
|
+
// A direct link, not a fetch — no HTTP call to mock/assert on, just the URL shape.
|
|
258
|
+
|
|
259
|
+
describe('Users.payments(userId).invoiceUrl', () => {
|
|
260
|
+
test('builds a direct link to the invoice endpoint', () => {
|
|
261
|
+
const client = new InsigniaClient(BASE);
|
|
262
|
+
const users = new Users(client);
|
|
263
|
+
expect(users.payments(42).invoiceUrl(7)).toBe(`${BASE}/users/42/payments/7/invoice`);
|
|
264
|
+
});
|
|
265
|
+
});
|
package/.env
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
INSIGNIA_EDUCATION_API_BASE_URL=http://localhost:8000
|