crisp-api 10.3.0 → 10.5.0

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/CHANGELOG.md CHANGED
@@ -1,6 +1,18 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ ## v10.5.0
5
+
6
+ ### New Features
7
+
8
+ * Added support for the `plan:subscription:updated` RTM API event.
9
+
10
+ ## v10.4.0
11
+
12
+ ### New Features
13
+
14
+ * Added now-public `subscription` REST API routes for `CrispClient.plan` prefix.
15
+
4
16
  ## v10.3.0
5
17
 
6
18
  ### New Features
package/EXAMPLES.md CHANGED
@@ -2426,6 +2426,66 @@ CrispClient.plugin.dispatchPluginEvent(websiteID, pluginID, payload);
2426
2426
 
2427
2427
  =========================
2428
2428
 
2429
+ https://docs.crisp.chat/references/rest-api/v1/#list-all-active-plan-subscriptions
2430
+
2431
+ var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
2432
+
2433
+ CrispClient.plan.listAllActiveSubscriptions();
2434
+
2435
+ =========================
2436
+
2437
+ https://docs.crisp.chat/references/rest-api/v1/#get-plan-subscription-for-a-website
2438
+
2439
+ var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
2440
+
2441
+ CrispClient.plan.getPlanSubscriptionForWebsite(websiteID);
2442
+
2443
+ =========================
2444
+
2445
+ https://docs.crisp.chat/references/rest-api/v1/#subscribe-website-to-plan
2446
+
2447
+ var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
2448
+ var planID = "d678dbc1-e49d-47d3-92f2-c436f5b0e4a5";
2449
+
2450
+ CrispClient.plan.subscribeWebsiteToPlan(websiteID, planID);
2451
+
2452
+ =========================
2453
+
2454
+ https://docs.crisp.chat/references/rest-api/v1/#unsubscribe-plan-from-website
2455
+
2456
+ var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
2457
+
2458
+ CrispClient.plan.unsubscribePlanFromWebsite(websiteID);
2459
+
2460
+ =========================
2461
+
2462
+ https://docs.crisp.chat/references/rest-api/v1/#change-bill-period-for-website-plan-subscription
2463
+
2464
+ var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
2465
+ var period = "yearly";
2466
+
2467
+ CrispClient.plan.changeBillPeriodForWebsitePlanSubscription(websiteID, period);
2468
+
2469
+ =========================
2470
+
2471
+ https://docs.crisp.chat/references/rest-api/v1/#check-coupon-availability-for-website-plan-subscription
2472
+
2473
+ var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
2474
+ var code = "CRISP+AWESOME";
2475
+
2476
+ CrispClient.plan.checkCouponAvailabilityForWebsitePlanSubscription(websiteID, code);
2477
+
2478
+ =========================
2479
+
2480
+ https://docs.crisp.chat/references/rest-api/v1/#redeem-coupon-for-website-plan-subscription
2481
+
2482
+ var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
2483
+ var code = "CRISP+AWESOME";
2484
+
2485
+ CrispClient.plan.redeemCouponForWebsitePlanSubscription(websiteID, code);
2486
+
2487
+ =========================
2488
+
2429
2489
  https://docs.crisp.chat/references/rest-api/v1/#list-animation-medias
2430
2490
 
2431
2491
  var listID = "f7fb43da-1cd8-49c1-ade0-9f5b71d034e3";
package/README.md CHANGED
@@ -125,6 +125,14 @@ All methods that you will most likely need when building a Crisp integration are
125
125
  <li><a href="#plugin-subscription">Plugin Subscription</a></li>
126
126
  </ul>
127
127
  </details>
128
+ <details>
129
+ <summary>
130
+ <a href="#plan">Plan</a>
131
+ </summary>
132
+ <ul>
133
+ <li><a href="#plan-subscription">Plan Subscription</a></li>
134
+ </ul>
135
+ </details>
128
136
  <details>
129
137
  <summary>
130
138
  <a href="#media">Media</a>
@@ -3461,6 +3469,96 @@ _👉 Notice: The `peopleID` argument can be an email or the `peopleID`._
3461
3469
  </details>
3462
3470
 
3463
3471
 
3472
+ ### Plan
3473
+
3474
+ * #### **Plan Subscription**
3475
+ * **List All Active Plan Subscriptions** [`user`]: [Reference](https://docs.crisp.chat/references/rest-api/v1/#list-all-active-plan-subscriptions)
3476
+ * `CrispClient.plan.listAllActiveSubscriptions()`
3477
+ * <details>
3478
+ <summary>See Example</summary>
3479
+
3480
+ ```javascript
3481
+ CrispClient.plan.listAllActiveSubscriptions();
3482
+ ```
3483
+ </details>
3484
+
3485
+ * **Get Plan Subscription For A Website** [`user`, `plugin`]: [Reference](https://docs.crisp.chat/references/rest-api/v1/#get-plan-subscription-for-a-website)
3486
+ * `CrispClient.plan.getPlanSubscriptionForWebsite(websiteID)`
3487
+ * <details>
3488
+ <summary>See Example</summary>
3489
+
3490
+ ```javascript
3491
+ var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
3492
+
3493
+ CrispClient.plan.getPlanSubscriptionForWebsite(websiteID);
3494
+ ```
3495
+ </details>
3496
+
3497
+ * **Subscribe Website To Plan** [`user`]: [Reference](https://docs.crisp.chat/references/rest-api/v1/#subscribe-website-to-plan)
3498
+ * `CrispClient.plan.subscribeWebsiteToPlan(websiteID, planID)`
3499
+ * <details>
3500
+ <summary>See Example</summary>
3501
+
3502
+ ```javascript
3503
+ var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
3504
+ var planID = "d678dbc1-e49d-47d3-92f2-c436f5b0e4a5";
3505
+
3506
+ CrispClient.plan.subscribeWebsiteToPlan(websiteID, planID);
3507
+ ```
3508
+ </details>
3509
+
3510
+ * **Unsubscribe Plan From Website** [`user`]: [Reference](https://docs.crisp.chat/references/rest-api/v1/#unsubscribe-plan-from-website)
3511
+ * `CrispClient.plan.unsubscribePlanFromWebsite(websiteID)`
3512
+ * <details>
3513
+ <summary>See Example</summary>
3514
+
3515
+ ```javascript
3516
+ var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
3517
+
3518
+ CrispClient.plan.unsubscribePlanFromWebsite(websiteID);
3519
+ ```
3520
+ </details>
3521
+
3522
+ * **Change Bill Period For Website Plan Subscription** [`user`]: [Reference](https://docs.crisp.chat/references/rest-api/v1/#change-bill-period-for-website-plan-subscription)
3523
+ * `CrispClient.plan.changeBillPeriodForWebsitePlanSubscription(websiteID, period)`
3524
+ * <details>
3525
+ <summary>See Example</summary>
3526
+
3527
+ ```javascript
3528
+ var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
3529
+ var period = "yearly";
3530
+
3531
+ CrispClient.plan.changeBillPeriodForWebsitePlanSubscription(websiteID, period);
3532
+ ```
3533
+ </details>
3534
+
3535
+ * **Check Coupon Availability For Website Plan Subscription** [`user`]: [Reference](https://docs.crisp.chat/references/rest-api/v1/#check-coupon-availability-for-website-plan-subscription)
3536
+ * `CrispClient.plan.checkCouponAvailabilityForWebsitePlanSubscription(websiteID, code)`
3537
+ * <details>
3538
+ <summary>See Example</summary>
3539
+
3540
+ ```javascript
3541
+ var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
3542
+ var code = "CRISP+AWESOME";
3543
+
3544
+ CrispClient.plan.checkCouponAvailabilityForWebsitePlanSubscription(websiteID, code);
3545
+ ```
3546
+ </details>
3547
+
3548
+ * **Redeem Coupon For Website Plan Subscription** [`user`]: [Reference](https://docs.crisp.chat/references/rest-api/v1/#redeem-coupon-for-website-plan-subscription)
3549
+ * `CrispClient.plan.redeemCouponForWebsitePlanSubscription(websiteID, code)`
3550
+ * <details>
3551
+ <summary>See Example</summary>
3552
+
3553
+ ```javascript
3554
+ var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
3555
+ var code = "CRISP+AWESOME";
3556
+
3557
+ CrispClient.plan.redeemCouponForWebsitePlanSubscription(websiteID, code);
3558
+ ```
3559
+ </details>
3560
+
3561
+
3464
3562
  ### Media
3465
3563
 
3466
3564
  * #### **Media Animation**
@@ -3726,3 +3824,7 @@ Available events are listed below:
3726
3824
  * `plugin:event`
3727
3825
  * **Plugin Settings Saved** [`user`, `plugin`]:
3728
3826
  * `plugin:settings:saved`
3827
+
3828
+ * #### **Plan Events**: [Reference](https://docs.crisp.chat/references/rtm-api/v1/#plan-events)
3829
+ * **Plan Subscription Updated** [`user`, `plugin`]:
3830
+ * `plan:subscription:updated`
package/dist/crisp.d.ts CHANGED
@@ -3,6 +3,7 @@ import { Emitter } from "mitt";
3
3
  import { BucketServiceInterface } from "./services/bucket";
4
4
  import { MediaServiceInterface } from "./services/media";
5
5
  import { PluginServiceInterface } from "./services/plugin";
6
+ import { PlanServiceInterface } from "./services/plan";
6
7
  import { WebsiteServiceInterface } from "./services/website";
7
8
  /**************************************************************************
8
9
  * TYPES
@@ -28,6 +29,7 @@ declare class Crisp {
28
29
  bucket: BucketServiceInterface;
29
30
  media: MediaServiceInterface;
30
31
  plugin: PluginServiceInterface;
32
+ plan: PlanServiceInterface;
31
33
  website: WebsiteServiceInterface;
32
34
  /**
33
35
  * @deprecated Use import { RTM_MODES } instead
package/dist/crisp.js CHANGED
@@ -37,6 +37,7 @@ const mitt_1 = __importDefault(require("mitt"));
37
37
  const bucket_1 = __importDefault(require("./services/bucket"));
38
38
  const media_1 = __importDefault(require("./services/media"));
39
39
  const plugin_1 = __importDefault(require("./services/plugin"));
40
+ const plan_1 = __importDefault(require("./services/plan"));
40
41
  const website_1 = __importDefault(require("./services/website"));
41
42
  /**************************************************************************
42
43
  * CONSTANTS
@@ -45,7 +46,7 @@ const AVAILABLE_RTM_MODES = [
45
46
  "websockets",
46
47
  "webhooks"
47
48
  ];
48
- const VERSION = "10.3.0";
49
+ const VERSION = "10.5.0";
49
50
  // Base configuration
50
51
  const DEFAULT_REQUEST_TIMEOUT = 10000;
51
52
  const DEFAULT_SOCKET_TIMEOUT = 10000;
@@ -154,13 +155,16 @@ const DEFAULT_RTM_EVENTS = [
154
155
  // Plugin Events
155
156
  "plugin:channel",
156
157
  "plugin:event",
157
- "plugin:settings:saved"
158
+ "plugin:settings:saved",
159
+ // Plan Events
160
+ "plan:subscription:updated"
158
161
  ];
159
162
  // REST API services
160
163
  const services = {
161
164
  Bucket: bucket_1.default,
162
165
  Media: media_1.default,
163
166
  Plugin: plugin_1.default,
167
+ Plan: plan_1.default,
164
168
  Website: website_1.default
165
169
  };
166
170
  /**************************************************************************
@@ -177,6 +181,7 @@ class Crisp {
177
181
  this.bucket = new bucket_1.default();
178
182
  this.media = new media_1.default();
179
183
  this.plugin = new plugin_1.default();
184
+ this.plan = new plan_1.default();
180
185
  this.website = new website_1.default();
181
186
  this.auth = {
182
187
  tier: "user",
@@ -0,0 +1,87 @@
1
+ /**************************************************************************
2
+ * IMPORTS
3
+ ***************************************************************************/
4
+ import BaseResource from "./BaseResource";
5
+ /**************************************************************************
6
+ * TYPES
7
+ ***************************************************************************/
8
+ export type PlanSubscription = {
9
+ id?: string;
10
+ name?: string;
11
+ price?: number;
12
+ since?: string;
13
+ trialing?: boolean;
14
+ trial_end?: string;
15
+ trial_end_date?: string;
16
+ bill_period?: PlanSubscriptionBillPeriod;
17
+ bill_valid_until?: string;
18
+ active?: boolean;
19
+ sandbox?: boolean;
20
+ website?: PlanSubscriptionWebsite;
21
+ coupon_redeemed?: boolean;
22
+ card_id?: string;
23
+ owner?: PlanSubscriptionOwner;
24
+ };
25
+ export type PlanSubscriptionBillPeriod = "monthly" | "yearly";
26
+ export type PlanSubscriptionWebsite = {
27
+ id?: string;
28
+ name?: string;
29
+ domain?: string;
30
+ logo?: string;
31
+ };
32
+ export type PlanSubscriptionOwner = {
33
+ user_id?: string;
34
+ email?: string;
35
+ first_name?: string;
36
+ last_name?: string;
37
+ };
38
+ export type PlanSubscriptionCoupon = {
39
+ code?: string;
40
+ policy?: PlanSubscriptionCouponPolicy;
41
+ redeem_limit?: number;
42
+ expire_at?: string;
43
+ };
44
+ export type PlanSubscriptionCouponPolicy = {
45
+ rebate_percent?: number;
46
+ trial_days?: number;
47
+ };
48
+ /**************************************************************************
49
+ * CLASSES
50
+ ***************************************************************************/
51
+ /**
52
+ * Crisp PlanSubscription Resource
53
+ */
54
+ declare class PlanSubscriptionService extends BaseResource {
55
+ /**
56
+ * List All Active Plan Subscriptions
57
+ */
58
+ listAllActiveSubscriptions(): Promise<PlanSubscription[]>;
59
+ /**
60
+ * Get Plan Subscription For A Website
61
+ */
62
+ getPlanSubscriptionForWebsite(websiteID: string): Promise<PlanSubscription>;
63
+ /**
64
+ * Subscribe Website To Plan
65
+ */
66
+ subscribeWebsiteToPlan(websiteID: string, planID: string): Promise<any>;
67
+ /**
68
+ * Unsubscribe Plan From Website
69
+ */
70
+ unsubscribePlanFromWebsite(websiteID: string): Promise<any>;
71
+ /**
72
+ * Change Bill Period For Website Plan Subscription
73
+ */
74
+ changeBillPeriodForWebsitePlanSubscription(websiteID: string, period: PlanSubscriptionBillPeriod): Promise<any>;
75
+ /**
76
+ * Check Coupon Availability For Website Plan Subscription
77
+ */
78
+ checkCouponAvailabilityForWebsitePlanSubscription(websiteID: string, code: string): Promise<PlanSubscriptionCoupon>;
79
+ /**
80
+ * Redeem Coupon For Website Plan Subscription
81
+ */
82
+ redeemCouponForWebsitePlanSubscription(websiteID: string, code: string): Promise<any>;
83
+ }
84
+ /**************************************************************************
85
+ * EXPORTS
86
+ ***************************************************************************/
87
+ export default PlanSubscriptionService;
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ /*
3
+ * This file is part of node-crisp-api
4
+ *
5
+ * Copyright (c) 2026 Crisp IM SAS
6
+ * All rights belong to Crisp IM SAS
7
+ */
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ /**************************************************************************
13
+ * IMPORTS
14
+ ***************************************************************************/
15
+ // PROJECT: RESOURCES
16
+ const BaseResource_1 = __importDefault(require("./BaseResource"));
17
+ /**************************************************************************
18
+ * CLASSES
19
+ ***************************************************************************/
20
+ /**
21
+ * Crisp PlanSubscription Resource
22
+ */
23
+ class PlanSubscriptionService extends BaseResource_1.default {
24
+ /**
25
+ * List All Active Plan Subscriptions
26
+ */
27
+ listAllActiveSubscriptions() {
28
+ return this.crisp.get(this.crisp.prepareRestUrl(["plans", "subscription"]));
29
+ }
30
+ ;
31
+ /**
32
+ * Get Plan Subscription For A Website
33
+ */
34
+ getPlanSubscriptionForWebsite(websiteID) {
35
+ return this.crisp.get(this.crisp.prepareRestUrl(["plans", "subscription", websiteID]));
36
+ }
37
+ ;
38
+ /**
39
+ * Subscribe Website To Plan
40
+ */
41
+ subscribeWebsiteToPlan(websiteID, planID) {
42
+ return this.crisp.post(this.crisp.prepareRestUrl(["plans", "subscription", websiteID]), null, {
43
+ plan_id: planID
44
+ });
45
+ }
46
+ ;
47
+ /**
48
+ * Unsubscribe Plan From Website
49
+ */
50
+ unsubscribePlanFromWebsite(websiteID) {
51
+ return this.crisp.delete(this.crisp.prepareRestUrl(["plans", "subscription", websiteID]));
52
+ }
53
+ ;
54
+ /**
55
+ * Change Bill Period For Website Plan Subscription
56
+ */
57
+ changeBillPeriodForWebsitePlanSubscription(websiteID, period) {
58
+ return this.crisp.patch(this.crisp.prepareRestUrl([
59
+ "plans", "subscription", websiteID, "bill", "period"
60
+ ]), null, {
61
+ period
62
+ });
63
+ }
64
+ ;
65
+ /**
66
+ * Check Coupon Availability For Website Plan Subscription
67
+ */
68
+ checkCouponAvailabilityForWebsitePlanSubscription(websiteID, code) {
69
+ return this.crisp.get(this.crisp.prepareRestUrl(["plans", "subscription", websiteID, "coupon"]), {
70
+ code
71
+ });
72
+ }
73
+ ;
74
+ /**
75
+ * Redeem Coupon For Website Plan Subscription
76
+ */
77
+ redeemCouponForWebsitePlanSubscription(websiteID, code) {
78
+ return this.crisp.patch(this.crisp.prepareRestUrl(["plans", "subscription", websiteID, "coupon"]), null, {
79
+ code
80
+ });
81
+ }
82
+ ;
83
+ }
84
+ /**************************************************************************
85
+ * EXPORTS
86
+ ***************************************************************************/
87
+ exports.default = PlanSubscriptionService;
@@ -6,6 +6,7 @@ export * from "./BucketURL";
6
6
  export * from "./MediaAnimation";
7
7
  export * from "./PluginConnect";
8
8
  export * from "./PluginSubscription";
9
+ export * from "./PlanSubscription";
9
10
  export * from "./WebsiteAnalytics";
10
11
  export * from "./WebsiteAvailability";
11
12
  export * from "./WebsiteBase";
@@ -28,6 +28,7 @@ __exportStar(require("./BucketURL"), exports);
28
28
  __exportStar(require("./MediaAnimation"), exports);
29
29
  __exportStar(require("./PluginConnect"), exports);
30
30
  __exportStar(require("./PluginSubscription"), exports);
31
+ __exportStar(require("./PlanSubscription"), exports);
31
32
  __exportStar(require("./WebsiteAnalytics"), exports);
32
33
  __exportStar(require("./WebsiteAvailability"), exports);
33
34
  __exportStar(require("./WebsiteBase"), exports);
@@ -0,0 +1,19 @@
1
+ /**************************************************************************
2
+ * IMPORTS
3
+ ***************************************************************************/
4
+ import PlanSubscription from "../resources/PlanSubscription";
5
+ /**************************************************************************
6
+ * CLASSES
7
+ ***************************************************************************/
8
+ /**
9
+ * Crisp Plan Service
10
+ */
11
+ declare class PlanService {
12
+ __resources: any[];
13
+ }
14
+ /**************************************************************************
15
+ * EXPORTS
16
+ ***************************************************************************/
17
+ export interface PlanServiceInterface extends PlanSubscription {
18
+ }
19
+ export default PlanService;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ /*
3
+ * This file is part of node-crisp-api
4
+ *
5
+ * Copyright (c) 2026 Crisp IM SAS
6
+ * All rights belong to Crisp IM SAS
7
+ */
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ /**************************************************************************
13
+ * IMPORTS
14
+ ***************************************************************************/
15
+ // PROJECT: RESOURCES
16
+ const PlanSubscription_1 = __importDefault(require("../resources/PlanSubscription"));
17
+ /**************************************************************************
18
+ * CLASSES
19
+ ***************************************************************************/
20
+ /**
21
+ * Crisp Plan Service
22
+ */
23
+ class PlanService {
24
+ constructor() {
25
+ /* eslint-disable @typescript-eslint/no-explicit-any */
26
+ this.__resources = [
27
+ PlanSubscription_1.default
28
+ ];
29
+ }
30
+ }
31
+ exports.default = PlanService;
package/lib/crisp.ts CHANGED
@@ -22,6 +22,7 @@ import mitt, { Emitter } from "mitt";
22
22
  import Bucket, { BucketServiceInterface } from "@/services/bucket";
23
23
  import Media, { MediaServiceInterface } from "@/services/media";
24
24
  import Plugin, { PluginServiceInterface } from "@/services/plugin";
25
+ import Plan, { PlanServiceInterface } from "@/services/plan";
25
26
  import Website, { WebsiteServiceInterface } from "@/services/website";
26
27
 
27
28
  /**************************************************************************
@@ -167,7 +168,10 @@ const DEFAULT_RTM_EVENTS = [
167
168
  // Plugin Events
168
169
  "plugin:channel",
169
170
  "plugin:event",
170
- "plugin:settings:saved"
171
+ "plugin:settings:saved",
172
+
173
+ // Plan Events
174
+ "plan:subscription:updated"
171
175
  ];
172
176
 
173
177
  // REST API services
@@ -175,6 +179,7 @@ const services = {
175
179
  Bucket: Bucket,
176
180
  Media: Media,
177
181
  Plugin: Plugin,
182
+ Plan: Plan,
178
183
  Website: Website
179
184
  };
180
185
 
@@ -209,6 +214,10 @@ class Crisp {
209
214
  new Plugin() as unknown as PluginServiceInterface
210
215
  );
211
216
 
217
+ public plan: PlanServiceInterface = (
218
+ new Plan() as unknown as PlanServiceInterface
219
+ );
220
+
212
221
  public website: WebsiteServiceInterface = (
213
222
  new Website() as unknown as WebsiteServiceInterface
214
223
  );
@@ -0,0 +1,171 @@
1
+ /*
2
+ * This file is part of node-crisp-api
3
+ *
4
+ * Copyright (c) 2026 Crisp IM SAS
5
+ * All rights belong to Crisp IM SAS
6
+ */
7
+
8
+ /**************************************************************************
9
+ * IMPORTS
10
+ ***************************************************************************/
11
+
12
+ // PROJECT: RESOURCES
13
+ import BaseResource from "./BaseResource";
14
+
15
+ /**************************************************************************
16
+ * TYPES
17
+ ***************************************************************************/
18
+
19
+ export type PlanSubscription = {
20
+ id?: string;
21
+ name?: string;
22
+ price?: number;
23
+ since?: string;
24
+ trialing?: boolean;
25
+ trial_end?: string;
26
+ trial_end_date?: string;
27
+ bill_period?: PlanSubscriptionBillPeriod;
28
+ bill_valid_until?: string;
29
+ active?: boolean;
30
+ sandbox?: boolean;
31
+ website?: PlanSubscriptionWebsite;
32
+ coupon_redeemed?: boolean;
33
+ card_id?: string;
34
+ owner?: PlanSubscriptionOwner;
35
+ }
36
+
37
+ export type PlanSubscriptionBillPeriod = "monthly" | "yearly";
38
+
39
+ export type PlanSubscriptionWebsite = {
40
+ id?: string;
41
+ name?: string;
42
+ domain?: string;
43
+ logo?: string;
44
+ }
45
+
46
+ export type PlanSubscriptionOwner = {
47
+ user_id?: string;
48
+ email?: string;
49
+ first_name?: string;
50
+ last_name?: string;
51
+ }
52
+
53
+ export type PlanSubscriptionCoupon = {
54
+ code?: string;
55
+ policy?: PlanSubscriptionCouponPolicy;
56
+ redeem_limit?: number;
57
+ expire_at?: string;
58
+ }
59
+
60
+ export type PlanSubscriptionCouponPolicy = {
61
+ rebate_percent?: number;
62
+ trial_days?: number;
63
+ }
64
+
65
+ /**************************************************************************
66
+ * CLASSES
67
+ ***************************************************************************/
68
+
69
+ /**
70
+ * Crisp PlanSubscription Resource
71
+ */
72
+ class PlanSubscriptionService extends BaseResource {
73
+ /**
74
+ * List All Active Plan Subscriptions
75
+ */
76
+ listAllActiveSubscriptions(): Promise<PlanSubscription[]> {
77
+ return this.crisp.get(
78
+ this.crisp.prepareRestUrl(["plans", "subscription"])
79
+ );
80
+ };
81
+
82
+ /**
83
+ * Get Plan Subscription For A Website
84
+ */
85
+ getPlanSubscriptionForWebsite(websiteID: string): Promise<PlanSubscription> {
86
+ return this.crisp.get(
87
+ this.crisp.prepareRestUrl(["plans", "subscription", websiteID])
88
+ );
89
+ };
90
+
91
+ /**
92
+ * Subscribe Website To Plan
93
+ */
94
+ subscribeWebsiteToPlan(websiteID: string, planID: string) {
95
+ return this.crisp.post(
96
+ this.crisp.prepareRestUrl(["plans", "subscription", websiteID]),
97
+
98
+ null,
99
+
100
+ {
101
+ plan_id: planID
102
+ }
103
+ );
104
+ };
105
+
106
+ /**
107
+ * Unsubscribe Plan From Website
108
+ */
109
+ unsubscribePlanFromWebsite(websiteID: string) {
110
+ return this.crisp.delete(
111
+ this.crisp.prepareRestUrl(["plans", "subscription", websiteID])
112
+ );
113
+ };
114
+
115
+ /**
116
+ * Change Bill Period For Website Plan Subscription
117
+ */
118
+ changeBillPeriodForWebsitePlanSubscription(
119
+ websiteID: string,
120
+ period: PlanSubscriptionBillPeriod
121
+ ) {
122
+ return this.crisp.patch(
123
+ this.crisp.prepareRestUrl([
124
+ "plans", "subscription", websiteID, "bill", "period"
125
+ ]),
126
+
127
+ null,
128
+
129
+ {
130
+ period
131
+ }
132
+ );
133
+ };
134
+
135
+ /**
136
+ * Check Coupon Availability For Website Plan Subscription
137
+ */
138
+ checkCouponAvailabilityForWebsitePlanSubscription(
139
+ websiteID: string,
140
+ code: string
141
+ ): Promise<PlanSubscriptionCoupon> {
142
+ return this.crisp.get(
143
+ this.crisp.prepareRestUrl(["plans", "subscription", websiteID, "coupon"]),
144
+
145
+ {
146
+ code
147
+ }
148
+ );
149
+ };
150
+
151
+ /**
152
+ * Redeem Coupon For Website Plan Subscription
153
+ */
154
+ redeemCouponForWebsitePlanSubscription(websiteID: string, code: string) {
155
+ return this.crisp.patch(
156
+ this.crisp.prepareRestUrl(["plans", "subscription", websiteID, "coupon"]),
157
+
158
+ null,
159
+
160
+ {
161
+ code
162
+ }
163
+ );
164
+ };
165
+ }
166
+
167
+ /**************************************************************************
168
+ * EXPORTS
169
+ ***************************************************************************/
170
+
171
+ export default PlanSubscriptionService;
@@ -17,53 +17,53 @@ import BaseResource from "./BaseResource";
17
17
  ***************************************************************************/
18
18
 
19
19
  export type PluginSubscription = {
20
- id?: string;
21
- urn?: string;
22
- type?: string;
23
- category?: string;
24
- name?: string;
25
- summary?: string;
26
- price?: number;
27
- plans?: PluginSubscriptionPlan[];
28
- icon?: string;
29
- website_url?: string;
30
- contact_url?: string;
31
- terms_url?: string;
32
- privacy_url?: string;
33
- help_url?: string;
34
- video_url?: string;
35
- configurable?: boolean;
36
- since?: string;
37
- active?: boolean;
38
- website_id?: string;
39
- card_id?: string;
20
+ id?: string;
21
+ urn?: string;
22
+ type?: string;
23
+ category?: string;
24
+ name?: string;
25
+ summary?: string;
26
+ price?: number;
27
+ plans?: PluginSubscriptionPlan[];
28
+ icon?: string;
29
+ website_url?: string;
30
+ contact_url?: string;
31
+ terms_url?: string;
32
+ privacy_url?: string;
33
+ help_url?: string;
34
+ video_url?: string;
35
+ configurable?: boolean;
36
+ since?: string;
37
+ active?: boolean;
38
+ website_id?: string;
39
+ card_id?: string;
40
40
  }
41
41
 
42
42
  export type PluginSubscriptionPlan = {
43
- id?: string;
44
- name?: string;
45
- price?: number;
43
+ id?: string;
44
+ name?: string;
45
+ price?: number;
46
46
  }
47
47
 
48
48
  export type PluginSubscriptionSettings = {
49
- plugin_id?: string;
50
- website_id?: string;
51
- token?: string;
52
- schema?: object;
53
- settings?: object;
49
+ plugin_id?: string;
50
+ website_id?: string;
51
+ token?: string;
52
+ schema?: object;
53
+ settings?: object;
54
54
  settings_form_url?: string;
55
- callback_url?: string;
55
+ callback_url?: string;
56
56
  }
57
57
 
58
58
  export type PluginSubscriptionChannelForward = {
59
- namespace?: string;
60
- identifier?: string;
61
- payload?: object;
59
+ namespace?: string;
60
+ identifier?: string;
61
+ payload?: object;
62
62
  }
63
63
 
64
64
  export type PluginSubscriptionEventDispatch = {
65
- name?: string;
66
- data?: object;
65
+ name?: string;
66
+ data?: object;
67
67
  }
68
68
 
69
69
  /**************************************************************************
@@ -17,18 +17,18 @@ import BaseResource from "./BaseResource";
17
17
  ***************************************************************************/
18
18
 
19
19
  export type WebsiteAvailabilityStatus = {
20
- status?: string;
21
- since?: number;
20
+ status?: string;
21
+ since?: number;
22
22
  }
23
23
 
24
24
  export type WebsiteAvailabilityOperator = {
25
- user_id?: string;
26
- type?: string;
27
- time?: WebsiteAvailabilityOperatorTime;
25
+ user_id?: string;
26
+ type?: string;
27
+ time?: WebsiteAvailabilityOperatorTime;
28
28
  }
29
29
 
30
30
  export type WebsiteAvailabilityOperatorTime = {
31
- for?: number;
31
+ for?: number;
32
32
  since?: number;
33
33
  }
34
34
 
@@ -17,27 +17,27 @@ import BaseResource from "./BaseResource";
17
17
  ***************************************************************************/
18
18
 
19
19
  export type Website = {
20
- website_id?: string;
21
- name?: string;
22
- domain?: string;
23
- logo?: string;
20
+ website_id?: string;
21
+ name?: string;
22
+ domain?: string;
23
+ logo?: string;
24
24
  }
25
25
 
26
26
  export type WebsiteCreate = {
27
- name?: string;
28
- domain?: string;
27
+ name?: string;
28
+ domain?: string;
29
29
  }
30
30
 
31
31
  export type WebsiteRemoveVerify = {
32
- method?: string;
33
- secret?: string;
32
+ method?: string;
33
+ secret?: string;
34
34
  }
35
35
 
36
36
  export type WebsiteFilter = {
37
- model?: string;
38
- criterion?: string;
39
- operator?: string;
40
- query?: Record<string, unknown>;
37
+ model?: string;
38
+ criterion?: string;
39
+ operator?: string;
40
+ query?: Record<string, unknown>;
41
41
  }
42
42
 
43
43
  /**************************************************************************
@@ -17,13 +17,13 @@ import BaseResource from "./BaseResource";
17
17
  ***************************************************************************/
18
18
 
19
19
  export type WebsiteBatchConversationsOperation = {
20
- inbox_id?: string;
21
- sessions?: string[];
20
+ inbox_id?: string;
21
+ sessions?: string[];
22
22
  }
23
23
 
24
24
  export type WebsiteBatchPeopleOperationInner = {
25
- profiles?: string[];
26
- search?: string;
25
+ profiles?: string[];
26
+ search?: string;
27
27
  }
28
28
 
29
29
  /**************************************************************************
@@ -18,122 +18,122 @@ import { WebsiteFilter } from "./WebsiteBase";
18
18
  ***************************************************************************/
19
19
 
20
20
  export type WebsiteCampaignExcerpt = {
21
- campaign_id?: string;
22
- type?: string;
23
- format?: string;
24
- name?: string;
25
- subject?: string;
26
- tag?: string;
27
- ready?: boolean;
28
- dispatched?: boolean;
29
- running?: boolean;
30
- progress?: number;
31
- targets?: number;
32
- reached?: number;
33
- created_at: number;
34
- updated_at: number;
21
+ campaign_id?: string;
22
+ type?: string;
23
+ format?: string;
24
+ name?: string;
25
+ subject?: string;
26
+ tag?: string;
27
+ ready?: boolean;
28
+ dispatched?: boolean;
29
+ running?: boolean;
30
+ progress?: number;
31
+ targets?: number;
32
+ reached?: number;
33
+ created_at: number;
34
+ updated_at: number;
35
35
  dispatched_at?: number;
36
36
  }
37
37
 
38
38
  export type WebsiteCampaignTemplateExcerpt = {
39
- template_id?: string;
40
- type?: string;
41
- name?: string;
42
- format?: string;
43
- created_at?: number;
44
- updated_at?: number;
39
+ template_id?: string;
40
+ type?: string;
41
+ name?: string;
42
+ format?: string;
43
+ created_at?: number;
44
+ updated_at?: number;
45
45
  }
46
46
 
47
47
  export type WebsiteCampaignTemplateNew = {
48
- template_id?: string;
48
+ template_id?: string;
49
49
  }
50
50
 
51
51
  export interface WebsiteCampaignTemplateItem extends WebsiteCampaignTemplateExcerpt {
52
- content?: string;
52
+ content?: string;
53
53
  }
54
54
 
55
55
  export interface WebsiteCampaignItem extends WebsiteCampaignExcerpt {
56
- sender?: WebsiteCampaignItemSender;
57
- recipients?: WebsiteCampaignItemRecipients;
58
- flow?: WebsiteCampaignItemFlow;
59
- message?: string;
60
- options?: WebsiteCampaignItemOptions;
61
- statistics?: WebsiteCampaignItemStatistics;
56
+ sender?: WebsiteCampaignItemSender;
57
+ recipients?: WebsiteCampaignItemRecipients;
58
+ flow?: WebsiteCampaignItemFlow;
59
+ message?: string;
60
+ options?: WebsiteCampaignItemOptions;
61
+ statistics?: WebsiteCampaignItemStatistics;
62
62
  }
63
63
 
64
64
  export type WebsiteCampaignItemSender = {
65
- user_id?: string;
65
+ user_id?: string;
66
66
  }
67
67
 
68
68
  export type WebsiteCampaignItemRecipients = {
69
- type?: string;
70
- segments?: string[];
71
- people?: string[];
72
- filter?: WebsiteFilter[];
69
+ type?: string;
70
+ segments?: string[];
71
+ people?: string[];
72
+ filter?: WebsiteFilter[];
73
73
  }
74
74
 
75
75
  export type WebsiteCampaignItemFlow = {
76
- launch_event?: string;
77
- assert_filter?: WebsiteFilter[];
78
- assert_delay?: number;
79
- deliver_once?: boolean;
80
- deliver_delay?: number;
76
+ launch_event?: string;
77
+ assert_filter?: WebsiteFilter[];
78
+ assert_delay?: number;
79
+ deliver_once?: boolean;
80
+ deliver_delay?: number;
81
81
  }
82
82
 
83
83
  export type WebsiteCampaignItemOptions = {
84
- deliver_to_chatbox?: boolean;
85
- deliver_to_email?: boolean;
86
- sender_name_website?: boolean;
87
- sender_email_reply?: boolean;
88
- tracking?: boolean;
84
+ deliver_to_chatbox?: boolean;
85
+ deliver_to_email?: boolean;
86
+ sender_name_website?: boolean;
87
+ sender_email_reply?: boolean;
88
+ tracking?: boolean;
89
89
  }
90
90
 
91
91
  export type WebsiteCampaignItemStatistics = {
92
- opened?: number;
93
- clicked?: number;
94
- unsubscribed?: number;
92
+ opened?: number;
93
+ clicked?: number;
94
+ unsubscribed?: number;
95
95
  }
96
96
 
97
97
  export type WebsiteCampaignRecipient = {
98
- people_id?: string;
99
- email?: string;
100
- person?: WebsiteCampaignRecipientPerson;
101
- subscribed?: boolean;
98
+ people_id?: string;
99
+ email?: string;
100
+ person?: WebsiteCampaignRecipientPerson;
101
+ subscribed?: boolean;
102
102
  }
103
103
 
104
104
  export type WebsiteCampaignRecipientPerson = {
105
- nickname?: string;
106
- avatar?: string;
105
+ nickname?: string;
106
+ avatar?: string;
107
107
  }
108
108
 
109
109
  export type WebsiteCampaignStatistic = {
110
- profile?: WebsiteCampaignStatisticProfile;
111
- data?: Record<string, unknown>;
112
- created_at?: number;
113
- updated_at?: number;
110
+ profile?: WebsiteCampaignStatisticProfile;
111
+ data?: Record<string, unknown>;
112
+ created_at?: number;
113
+ updated_at?: number;
114
114
  }
115
115
 
116
116
  export type WebsiteCampaignStatisticProfile = {
117
- people_id?: string;
118
- email?: string;
119
- person?: WebsiteCampaignStatisticProfilePerson;
117
+ people_id?: string;
118
+ email?: string;
119
+ person?: WebsiteCampaignStatisticProfilePerson;
120
120
  }
121
121
 
122
122
  export type WebsiteCampaignStatisticProfilePerson = {
123
- nickname?: string;
124
- avatar?: string;
125
- geolocation?: WebsiteCampaignStatisticProfilePersonGeolocation;
123
+ nickname?: string;
124
+ avatar?: string;
125
+ geolocation?: WebsiteCampaignStatisticProfilePersonGeolocation;
126
126
  }
127
127
 
128
128
  export type WebsiteCampaignStatisticProfilePersonGeolocation = {
129
- country?: string;
130
- region?: string;
131
- city?: string;
132
- coordinates?: WebsiteCampaignStatisticProfilePersonGeolocationCoordinates;
129
+ country?: string;
130
+ region?: string;
131
+ city?: string;
132
+ coordinates?: WebsiteCampaignStatisticProfilePersonGeolocationCoordinates;
133
133
  }
134
134
 
135
135
  export type WebsiteCampaignStatisticProfilePersonGeolocationCoordinates = {
136
- latitude?: number;
136
+ latitude?: number;
137
137
  longitude?: number;
138
138
  }
139
139
 
@@ -398,21 +398,21 @@ export interface ConversationComposeMessageNew {
398
398
  }
399
399
 
400
400
  export interface ConversationSuggestedSegment {
401
- segment?: string;
402
- count?: number;
401
+ segment?: string;
402
+ count?: number;
403
403
  }
404
404
 
405
405
  export interface ConversationSuggestedData {
406
- key?: string;
406
+ key?: string;
407
407
  count?: number;
408
408
  }
409
409
 
410
410
  export interface ConversationSpam {
411
- spam_id?: string;
412
- type?: string;
413
- reason?: string;
414
- metadata?: Record<string, unknown>;
415
- headers?: Record<string, unknown>;
411
+ spam_id?: string;
412
+ type?: string;
413
+ reason?: string;
414
+ metadata?: Record<string, unknown>;
415
+ headers?: Record<string, unknown>;
416
416
  timestamp?: number;
417
417
  }
418
418
 
@@ -14,6 +14,7 @@ export * from "./BucketURL";
14
14
  export * from "./MediaAnimation";
15
15
  export * from "./PluginConnect";
16
16
  export * from "./PluginSubscription";
17
+ export * from "./PlanSubscription";
17
18
  export * from "./WebsiteAnalytics";
18
19
  export * from "./WebsiteAvailability";
19
20
  export * from "./WebsiteBase";
@@ -0,0 +1,36 @@
1
+ /*
2
+ * This file is part of node-crisp-api
3
+ *
4
+ * Copyright (c) 2026 Crisp IM SAS
5
+ * All rights belong to Crisp IM SAS
6
+ */
7
+
8
+ /**************************************************************************
9
+ * IMPORTS
10
+ ***************************************************************************/
11
+
12
+ // PROJECT: RESOURCES
13
+ import PlanSubscription from "@/resources/PlanSubscription";
14
+
15
+ /**************************************************************************
16
+ * CLASSES
17
+ ***************************************************************************/
18
+
19
+ /**
20
+ * Crisp Plan Service
21
+ */
22
+ class PlanService {
23
+ /* eslint-disable @typescript-eslint/no-explicit-any */
24
+ public __resources: any[] = [
25
+ PlanSubscription
26
+ ];
27
+ }
28
+
29
+ /**************************************************************************
30
+ * EXPORTS
31
+ ***************************************************************************/
32
+
33
+ export interface PlanServiceInterface extends PlanSubscription {
34
+ }
35
+
36
+ export default PlanService;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "crisp-api",
3
3
  "description": "Crisp API wrapper for Node - official, maintained by Crisp",
4
- "version": "10.3.0",
4
+ "version": "10.5.0",
5
5
  "homepage": "https://github.com/crisp-im/node-crisp-api",
6
6
  "license": "MIT",
7
7
  "author": {