@insignia-education/api-sdk-js 0.15.20 → 0.15.22

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.20",
3
+ "version": "0.15.22",
4
4
  "description": "JavaScript SDK for the Insignia Education API",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -24,6 +24,23 @@ export default class Payments {
24
24
  };
25
25
  }
26
26
 
27
+ /**
28
+ * Employee-only: apply or lift a coupon on an existing payment. A coupon
29
+ * only discounts the lines it actually covers — preview() reports which
30
+ * those are (and the resulting discount) without writing anything, and
31
+ * apply() rejects a coupon that matches none of the payment's items.
32
+ * Both apply() and remove() return the reloaded payment with its items.
33
+ */
34
+ coupon(paymentId) {
35
+ const base = `/payments/${paymentId}/coupon`;
36
+ const client = this.#client;
37
+ return {
38
+ preview: (cod) => client.get(`${base}/preview`, { cod }),
39
+ apply: (cod) => client.post(base, { cod }),
40
+ remove: () => client.del(base),
41
+ };
42
+ }
43
+
27
44
  /**
28
45
  * Employee-only: remove/restore any of a payment's line items. Removal is a
29
46
  * soft delete — the line stays visible in the admin panel flagged as removed,
@@ -34,6 +51,14 @@ export default class Payments {
34
51
  const base = `/payments/${paymentId}`;
35
52
  const client = this.#client;
36
53
  return {
54
+ /**
55
+ * Adds a line. `data` carries only identifiers — every price is
56
+ * derived server-side from the selected entity, never sent by the
57
+ * client. By type: courses `{course_id, course_date_id?}`, premiums
58
+ * `{course_premium_id}`, sessions `{course_id, type_id, quantity}`,
59
+ * quizzes `{quiz_id, course_id, quantity}`, taxes `{tax_id}`.
60
+ */
61
+ create: (type, data) => client.put(`${base}/${type}`, data),
37
62
  delete: (type, id) => client.del(`${base}/${type}/${id}`),
38
63
  restore: (type, id) => client.post(`${base}/${type}/${id}/restore`),
39
64
  };