crisp-api 9.13.0 → 10.0.2
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 +8 -0
- package/README.md +2 -2
- package/dist/crisp.d.ts +167 -0
- package/dist/crisp.js +764 -0
- package/dist/resources/BaseResource.d.ts +15 -0
- package/dist/resources/BaseResource.js +20 -0
- package/dist/resources/BucketURL.d.ts +28 -0
- package/dist/resources/BucketURL.js +29 -0
- package/dist/resources/MediaAnimation.d.ts +14 -0
- package/dist/resources/MediaAnimation.js +32 -0
- package/dist/resources/PluginConnect.d.ts +50 -0
- package/dist/resources/PluginConnect.js +73 -0
- package/dist/resources/PluginSubscription.d.ts +103 -0
- package/dist/resources/PluginSubscription.js +122 -0
- package/dist/resources/WebsiteAnalytics.d.ts +14 -0
- package/dist/resources/WebsiteAnalytics.js +29 -0
- package/dist/resources/WebsiteAvailability.d.ts +31 -0
- package/dist/resources/WebsiteAvailability.js +36 -0
- package/dist/resources/WebsiteBase.d.ts +60 -0
- package/dist/resources/WebsiteBase.js +71 -0
- package/dist/resources/WebsiteBatch.d.ts +52 -0
- package/dist/resources/WebsiteBatch.js +70 -0
- package/dist/resources/WebsiteCampaign.d.ts +199 -0
- package/dist/resources/WebsiteCampaign.js +194 -0
- package/dist/resources/WebsiteConversation.d.ts +701 -0
- package/dist/resources/WebsiteConversation.js +595 -0
- package/dist/resources/WebsiteHelpdesk.d.ts +347 -0
- package/dist/resources/WebsiteHelpdesk.js +587 -0
- package/dist/resources/WebsiteOperator.d.ts +79 -0
- package/dist/resources/WebsiteOperator.js +93 -0
- package/dist/resources/WebsitePeople.d.ts +248 -0
- package/dist/resources/WebsitePeople.js +276 -0
- package/dist/resources/WebsiteSettings.d.ts +159 -0
- package/dist/resources/WebsiteSettings.js +36 -0
- package/dist/resources/WebsiteVerify.d.ts +38 -0
- package/dist/resources/WebsiteVerify.js +50 -0
- package/dist/resources/WebsiteVisitors.d.ts +113 -0
- package/dist/resources/WebsiteVisitors.js +88 -0
- package/dist/resources/index.d.ts +17 -0
- package/dist/resources/index.js +40 -0
- package/dist/services/bucket.d.ts +13 -0
- package/dist/services/bucket.js +28 -0
- package/dist/services/media.d.ts +13 -0
- package/dist/services/media.js +28 -0
- package/dist/services/plugin.d.ts +14 -0
- package/dist/services/plugin.js +30 -0
- package/dist/services/website.d.ts +24 -0
- package/dist/services/website.js +50 -0
- package/eslint.config.mjs +208 -0
- package/lib/crisp.ts +957 -0
- package/lib/resources/BaseResource.ts +29 -0
- package/lib/resources/BucketURL.ts +49 -0
- package/lib/resources/MediaAnimation.ts +34 -0
- package/lib/resources/PluginConnect.ts +128 -0
- package/lib/resources/PluginSubscription.ts +208 -0
- package/lib/resources/WebsiteAnalytics.ts +31 -0
- package/lib/resources/WebsiteAvailability.ts +54 -0
- package/lib/resources/WebsiteBase.ts +108 -0
- package/lib/resources/WebsiteBatch.ts +96 -0
- package/lib/resources/WebsiteCampaign.ts +399 -0
- package/lib/resources/WebsiteConversation.ts +1416 -0
- package/lib/resources/WebsiteHelpdesk.ts +982 -0
- package/lib/resources/WebsiteOperator.ts +161 -0
- package/lib/resources/WebsitePeople.ts +527 -0
- package/lib/resources/WebsiteSettings.ts +192 -0
- package/lib/resources/WebsiteVerify.ts +76 -0
- package/lib/resources/WebsiteVisitors.ts +196 -0
- package/lib/resources/index.ts +25 -0
- package/lib/services/bucket.ts +28 -0
- package/lib/services/media.ts +28 -0
- package/lib/services/plugin.ts +32 -0
- package/lib/services/website.ts +62 -0
- package/package.json +16 -11
- package/tsconfig.json +12 -5
- package/lib/crisp.js +0 -1171
- package/lib/resources/BucketURL.js +0 -34
- package/lib/resources/MediaAnimation.js +0 -41
- package/lib/resources/PluginConnect.js +0 -119
- package/lib/resources/PluginSubscription.js +0 -234
- package/lib/resources/WebsiteAnalytics.js +0 -37
- package/lib/resources/WebsiteAvailability.js +0 -48
- package/lib/resources/WebsiteBase.js +0 -100
- package/lib/resources/WebsiteBatch.js +0 -92
- package/lib/resources/WebsiteCampaign.js +0 -396
- package/lib/resources/WebsiteConversation.js +0 -1261
- package/lib/resources/WebsiteHelpdesk.js +0 -1198
- package/lib/resources/WebsiteOperator.js +0 -167
- package/lib/resources/WebsitePeople.js +0 -516
- package/lib/resources/WebsiteSettings.js +0 -50
- package/lib/resources/WebsiteVerify.js +0 -79
- package/lib/resources/WebsiteVisitors.js +0 -148
- package/lib/services/Bucket.js +0 -28
- package/lib/services/Media.js +0 -28
- package/lib/services/Plugin.js +0 -29
- package/lib/services/Website.js +0 -39
- package/types/crisp.d.ts +0 -151
- package/types/resources/BucketURL.d.ts +0 -15
- package/types/resources/MediaAnimation.d.ts +0 -15
- package/types/resources/PluginConnect.d.ts +0 -15
- package/types/resources/PluginSubscription.d.ts +0 -15
- package/types/resources/WebsiteAnalytics.d.ts +0 -15
- package/types/resources/WebsiteAvailability.d.ts +0 -15
- package/types/resources/WebsiteBase.d.ts +0 -15
- package/types/resources/WebsiteBatch.d.ts +0 -15
- package/types/resources/WebsiteCampaign.d.ts +0 -15
- package/types/resources/WebsiteConversation.d.ts +0 -15
- package/types/resources/WebsiteHelpdesk.d.ts +0 -15
- package/types/resources/WebsiteOperator.d.ts +0 -15
- package/types/resources/WebsitePeople.d.ts +0 -15
- package/types/resources/WebsiteSettings.d.ts +0 -15
- package/types/resources/WebsiteVerify.d.ts +0 -15
- package/types/resources/WebsiteVisitors.d.ts +0 -15
- package/types/services/Bucket.d.ts +0 -14
- package/types/services/Media.d.ts +0 -14
- package/types/services/Plugin.d.ts +0 -14
- package/types/services/Website.d.ts +0 -14
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* node-crisp-api
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2022, Crisp IM SAS
|
|
5
|
+
* Author: Baptiste Jamin <baptiste@crisp.chat>
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**************************************************************************
|
|
9
|
+
* IMPORTS
|
|
10
|
+
***************************************************************************/
|
|
11
|
+
|
|
12
|
+
// PROJECT: MAIN
|
|
13
|
+
import Crisp from "@/crisp";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Crisp Base Resource
|
|
17
|
+
*/
|
|
18
|
+
class BaseResource {
|
|
19
|
+
protected crisp: Crisp;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Constructor
|
|
23
|
+
*/
|
|
24
|
+
constructor(crisp: Crisp) {
|
|
25
|
+
this.crisp = crisp;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default BaseResource;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* node-crisp-api
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2022, Crisp IM SAS
|
|
5
|
+
* Author: Baptiste Jamin <baptiste@crisp.chat>
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**************************************************************************
|
|
9
|
+
* IMPORTS
|
|
10
|
+
***************************************************************************/
|
|
11
|
+
|
|
12
|
+
// PROJECT: RESOURCES
|
|
13
|
+
import BaseResource from "./BaseResource";
|
|
14
|
+
|
|
15
|
+
// BucketURLRequestFile mapping
|
|
16
|
+
export type BucketURLRequestFile = {
|
|
17
|
+
name?: string;
|
|
18
|
+
type?: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// BucketURLRequestResource mapping
|
|
22
|
+
export type BucketURLRequestResource = {
|
|
23
|
+
type?: string;
|
|
24
|
+
id?: string;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// BucketURLRequest mapping
|
|
28
|
+
export type BucketURLRequest = {
|
|
29
|
+
namespace?: string;
|
|
30
|
+
id?: string;
|
|
31
|
+
file?: BucketURLRequestFile;
|
|
32
|
+
resource?: BucketURLRequestResource;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Crisp BucketURL Resource
|
|
37
|
+
*/
|
|
38
|
+
class BucketURL extends BaseResource {
|
|
39
|
+
/**
|
|
40
|
+
* Generate Bucket URL
|
|
41
|
+
*/
|
|
42
|
+
generateBucketURL(data: BucketURLRequest) {
|
|
43
|
+
return this.crisp.post(
|
|
44
|
+
this.crisp.prepareRestUrl(["bucket", "url", "generate"]), null, data
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default BucketURL;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* node-crisp-api
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2022, Crisp IM SAS
|
|
5
|
+
* Author: Valerian Saliou <valerian@valeriansaliou.name>
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**************************************************************************
|
|
9
|
+
* IMPORTS
|
|
10
|
+
***************************************************************************/
|
|
11
|
+
|
|
12
|
+
// PROJECT: RESOURCES
|
|
13
|
+
import BaseResource from "./BaseResource";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Crisp MediaAnimation Resource
|
|
17
|
+
*/
|
|
18
|
+
class MediaAnimation extends BaseResource {
|
|
19
|
+
/**
|
|
20
|
+
* List Animation Medias
|
|
21
|
+
*/
|
|
22
|
+
listAnimationMedias(pageNumber: number, listID: string, searchQuery: object) {
|
|
23
|
+
return this.crisp.get(
|
|
24
|
+
this.crisp.prepareRestUrl(["media", "animation", "list", String(pageNumber)]),
|
|
25
|
+
|
|
26
|
+
{
|
|
27
|
+
list_id: listID,
|
|
28
|
+
search_query: searchQuery
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default MediaAnimation;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* node-crisp-api
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2022, Crisp IM SAS
|
|
5
|
+
* Author: Baptiste Jamin <baptiste@crisp.chat>
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**************************************************************************
|
|
9
|
+
* IMPORTS
|
|
10
|
+
***************************************************************************/
|
|
11
|
+
|
|
12
|
+
// PROJECT: RESOURCES
|
|
13
|
+
import BaseResource from "./BaseResource";
|
|
14
|
+
|
|
15
|
+
// PluginConnectAccount mapping
|
|
16
|
+
export type PluginConnectAccount = {
|
|
17
|
+
plugin_id?: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// PluginConnectAllWebsites mapping
|
|
21
|
+
export type PluginConnectAllWebsites = {
|
|
22
|
+
website_id?: string;
|
|
23
|
+
token?: string;
|
|
24
|
+
settings?: object;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// PluginConnectWebsitesSince mapping
|
|
28
|
+
export type PluginConnectWebsitesSince = {
|
|
29
|
+
website_id?: string;
|
|
30
|
+
token?: string;
|
|
31
|
+
settings?: object;
|
|
32
|
+
difference?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// PluginConnectEndpoints mapping
|
|
36
|
+
export type PluginConnectEndpoints = {
|
|
37
|
+
socket?: PluginConnectEndpointsSocket;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// PluginConnectEndpointsSocket mapping
|
|
41
|
+
export type PluginConnectEndpointsSocket = {
|
|
42
|
+
app?: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Crisp PluginConnect Resource
|
|
47
|
+
*/
|
|
48
|
+
class PluginConnect extends BaseResource {
|
|
49
|
+
/**
|
|
50
|
+
* Get Connect Account
|
|
51
|
+
*/
|
|
52
|
+
getConnectAccount(): Promise<PluginConnectAccount> {
|
|
53
|
+
return this.crisp.get(
|
|
54
|
+
this.crisp.prepareRestUrl(["plugin", "connect", "account"]), {}
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Check Connect Session Validity
|
|
60
|
+
*/
|
|
61
|
+
checkConnectSessionValidity() {
|
|
62
|
+
return this.crisp.head(
|
|
63
|
+
this.crisp.prepareRestUrl(["plugin", "connect", "session"]),
|
|
64
|
+
|
|
65
|
+
{}
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* List All Connect Websites
|
|
71
|
+
*/
|
|
72
|
+
listAllConnectWebsites(
|
|
73
|
+
pageNumber: number, filterConfigured: boolean
|
|
74
|
+
): Promise<PluginConnectAllWebsites> {
|
|
75
|
+
// Generate query
|
|
76
|
+
let query = {
|
|
77
|
+
filter_configured: (
|
|
78
|
+
(filterConfigured === true) ? "1" : "0"
|
|
79
|
+
)
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
return this.crisp.get(
|
|
83
|
+
this.crisp.prepareRestUrl([
|
|
84
|
+
"plugin", "connect", "websites", "all", String(pageNumber)
|
|
85
|
+
]),
|
|
86
|
+
|
|
87
|
+
query
|
|
88
|
+
);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* List Connect Websites Since
|
|
93
|
+
*/
|
|
94
|
+
listConnectWebsitesSince(
|
|
95
|
+
dateSince: string, filterConfigured: boolean
|
|
96
|
+
): Promise<PluginConnectWebsitesSince> {
|
|
97
|
+
// Generate query
|
|
98
|
+
let query = {
|
|
99
|
+
filter_configured: (
|
|
100
|
+
(filterConfigured === true) ? "1" : "0"
|
|
101
|
+
)
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
if (dateSince) {
|
|
105
|
+
// @ts-ignore
|
|
106
|
+
query.date_since = dateSince;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return this.crisp.get(
|
|
110
|
+
this.crisp.prepareRestUrl([
|
|
111
|
+
"plugin", "connect", "websites", "since"
|
|
112
|
+
]),
|
|
113
|
+
|
|
114
|
+
query
|
|
115
|
+
);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Get Connect Endpoints
|
|
120
|
+
*/
|
|
121
|
+
getConnectEndpoints(): Promise<PluginConnectEndpoints> {
|
|
122
|
+
return this.crisp.get(
|
|
123
|
+
this.crisp.prepareRestUrl(["plugin", "connect", "endpoints"]), {}
|
|
124
|
+
);
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export default PluginConnect;
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* node-crisp-api
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2022, Crisp IM SAS
|
|
5
|
+
* Author: Baptiste Jamin <baptiste@crisp.chat>
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**************************************************************************
|
|
9
|
+
* IMPORTS
|
|
10
|
+
***************************************************************************/
|
|
11
|
+
|
|
12
|
+
// PROJECT: RESOURCES
|
|
13
|
+
import BaseResource from "./BaseResource";
|
|
14
|
+
|
|
15
|
+
type PluginSubscription = {
|
|
16
|
+
id?: string;
|
|
17
|
+
urn?: string;
|
|
18
|
+
type?: string;
|
|
19
|
+
category?: string;
|
|
20
|
+
name?: string;
|
|
21
|
+
summary?: string;
|
|
22
|
+
price?: number;
|
|
23
|
+
plans?: PluginSubscriptionPlan[];
|
|
24
|
+
icon?: string;
|
|
25
|
+
website_url?: string;
|
|
26
|
+
contact_url?: string;
|
|
27
|
+
terms_url?: string;
|
|
28
|
+
privacy_url?: string;
|
|
29
|
+
help_url?: string;
|
|
30
|
+
video_url?: string;
|
|
31
|
+
configurable?: boolean;
|
|
32
|
+
since?: string;
|
|
33
|
+
active?: boolean;
|
|
34
|
+
website_id?: string;
|
|
35
|
+
card_id?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
type PluginSubscriptionPlan = {
|
|
39
|
+
id?: string;
|
|
40
|
+
name?: string;
|
|
41
|
+
price?: number;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
type PluginSubscriptionSettings = {
|
|
45
|
+
plugin_id?: string;
|
|
46
|
+
website_id?: string;
|
|
47
|
+
token?: string;
|
|
48
|
+
schema?: object;
|
|
49
|
+
settings?: object;
|
|
50
|
+
settings_form_url?: string;
|
|
51
|
+
callback_url?: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
type PluginSubscriptionChannelForward = {
|
|
55
|
+
namespace?: string;
|
|
56
|
+
identifier?: string;
|
|
57
|
+
payload?: object;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
type PluginSubscriptionEventDispatch = {
|
|
61
|
+
name?: string;
|
|
62
|
+
data?: object;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Crisp PluginSubscription Resource
|
|
67
|
+
*/
|
|
68
|
+
class PluginSubscriptionService extends BaseResource {
|
|
69
|
+
/**
|
|
70
|
+
* List All Active Subscriptions
|
|
71
|
+
*/
|
|
72
|
+
listAllActiveSubscriptions(): Promise<PluginSubscription[]> {
|
|
73
|
+
return this.crisp.get(
|
|
74
|
+
this.crisp.prepareRestUrl(["plugins", "subscription"])
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* List Subscriptions For A Website
|
|
80
|
+
*/
|
|
81
|
+
listSubscriptionsForWebsite(websiteID: string) : Promise<PluginSubscription[]> {
|
|
82
|
+
return this.crisp.get(
|
|
83
|
+
this.crisp.prepareRestUrl(["plugins", "subscription", websiteID])
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Get Subscription Details
|
|
89
|
+
*/
|
|
90
|
+
getSubscriptionDetails(websiteID: string, pluginID: string) : Promise<PluginSubscription> {
|
|
91
|
+
return this.crisp.get(
|
|
92
|
+
this.crisp.prepareRestUrl(["plugins", "subscription", websiteID, pluginID])
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Subscribe Website To Plugin
|
|
98
|
+
*/
|
|
99
|
+
subscribeWebsiteToPlugin(websiteID: string, pluginID: string) {
|
|
100
|
+
return this.crisp.post(
|
|
101
|
+
this.crisp.prepareRestUrl(["plugins", "subscription", websiteID]),
|
|
102
|
+
|
|
103
|
+
null,
|
|
104
|
+
|
|
105
|
+
{
|
|
106
|
+
plugin_id: pluginID
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Unsubscribe Plugin From Website
|
|
113
|
+
*/
|
|
114
|
+
unsubscribePluginFromWebsite(websiteID: string, pluginID: string) {
|
|
115
|
+
return this.crisp.delete(
|
|
116
|
+
this.crisp.prepareRestUrl(["plugins", "subscription", websiteID, pluginID])
|
|
117
|
+
);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Get Subscription Settings
|
|
122
|
+
*/
|
|
123
|
+
getSubscriptionSettings(websiteID: string, pluginID: string) : Promise<PluginSubscriptionSettings> {
|
|
124
|
+
return this.crisp.get(
|
|
125
|
+
this.crisp.prepareRestUrl([
|
|
126
|
+
"plugins", "subscription", websiteID, pluginID, "settings"
|
|
127
|
+
])
|
|
128
|
+
);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Save Subscription Settings
|
|
133
|
+
*/
|
|
134
|
+
saveSubscriptionSettings(websiteID: string, pluginID: string, settings: object) {
|
|
135
|
+
return this.crisp.put(
|
|
136
|
+
this.crisp.prepareRestUrl([
|
|
137
|
+
"plugins", "subscription", websiteID, pluginID, "settings"
|
|
138
|
+
]),
|
|
139
|
+
|
|
140
|
+
null, settings
|
|
141
|
+
);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Update Subscription Settings
|
|
146
|
+
*/
|
|
147
|
+
updateSubscriptionSettings(websiteID: string, pluginID: string, settings: object) {
|
|
148
|
+
return this.crisp.patch(
|
|
149
|
+
this.crisp.prepareRestUrl([
|
|
150
|
+
"plugins", "subscription", websiteID, pluginID, "settings"
|
|
151
|
+
]),
|
|
152
|
+
|
|
153
|
+
null, settings
|
|
154
|
+
);
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Get Plugin Usage Bills
|
|
159
|
+
*/
|
|
160
|
+
getPluginUsageBills(websiteID: string, pluginID: string) {
|
|
161
|
+
return this.crisp.get(
|
|
162
|
+
this.crisp.prepareRestUrl([
|
|
163
|
+
"plugins", "subscription", websiteID, pluginID, "bill", "usage"
|
|
164
|
+
])
|
|
165
|
+
);
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Report Plugin Usage To Bill
|
|
170
|
+
*/
|
|
171
|
+
reportPluginUsageToBill(websiteID: string, pluginID: string, usage: object) {
|
|
172
|
+
return this.crisp.post(
|
|
173
|
+
this.crisp.prepareRestUrl([
|
|
174
|
+
"plugins", "subscription", websiteID, pluginID, "bill", "usage"
|
|
175
|
+
]),
|
|
176
|
+
|
|
177
|
+
null, usage
|
|
178
|
+
);
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Forward Plugin Payload To Channel
|
|
183
|
+
*/
|
|
184
|
+
forwardPluginPayloadToChannel(websiteID: string, pluginID: string, payload: PluginSubscriptionChannelForward) {
|
|
185
|
+
return this.crisp.post(
|
|
186
|
+
this.crisp.prepareRestUrl([
|
|
187
|
+
"plugins", "subscription", websiteID, pluginID, "channel"
|
|
188
|
+
]),
|
|
189
|
+
|
|
190
|
+
null, payload
|
|
191
|
+
);
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Dispatch Plugin Event
|
|
196
|
+
*/
|
|
197
|
+
dispatchPluginEvent(websiteID: string, pluginID: string, payload: PluginSubscriptionEventDispatch) {
|
|
198
|
+
return this.crisp.post(
|
|
199
|
+
this.crisp.prepareRestUrl([
|
|
200
|
+
"plugins", "subscription", websiteID, pluginID, "event"
|
|
201
|
+
]),
|
|
202
|
+
|
|
203
|
+
null, payload
|
|
204
|
+
);
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export default PluginSubscriptionService;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* node-crisp-api
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2022, Crisp IM SAS
|
|
5
|
+
* Author: Valerian Saliou <valerian@valeriansaliou.name>
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**************************************************************************
|
|
9
|
+
* IMPORTS
|
|
10
|
+
***************************************************************************/
|
|
11
|
+
|
|
12
|
+
// PROJECT: RESOURCES
|
|
13
|
+
import BaseResource from "./BaseResource";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Crisp WebsiteAnalytics Resource
|
|
17
|
+
*/
|
|
18
|
+
class WebsiteAnalytics extends BaseResource {
|
|
19
|
+
/**
|
|
20
|
+
* Generate Analytics
|
|
21
|
+
*/
|
|
22
|
+
generateAnalytics(websiteID: string, query: object) {
|
|
23
|
+
return this.crisp.post(
|
|
24
|
+
this.crisp.prepareRestUrl(["website", websiteID, "analytics", "generate"]),
|
|
25
|
+
|
|
26
|
+
null, query
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default WebsiteAnalytics;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* node-crisp-api
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2022, Crisp IM SAS
|
|
5
|
+
* Author: Valerian Saliou <valerian@valeriansaliou.name>
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**************************************************************************
|
|
9
|
+
* IMPORTS
|
|
10
|
+
***************************************************************************/
|
|
11
|
+
|
|
12
|
+
// PROJECT: RESOURCES
|
|
13
|
+
import BaseResource from "./BaseResource";
|
|
14
|
+
|
|
15
|
+
type WebsiteAvailabilityStatus = {
|
|
16
|
+
status?: string;
|
|
17
|
+
since?: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type WebsiteAvailabilityOperator = {
|
|
21
|
+
user_id?: string;
|
|
22
|
+
type?: string;
|
|
23
|
+
time?: WebsiteAvailabilityOperatorTime;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
type WebsiteAvailabilityOperatorTime = {
|
|
27
|
+
for?: number;
|
|
28
|
+
since?: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Crisp WebsiteAvailability Resource
|
|
33
|
+
*/
|
|
34
|
+
class WebsiteAvailability extends BaseResource {
|
|
35
|
+
/**
|
|
36
|
+
* Get Website Availability Status
|
|
37
|
+
*/
|
|
38
|
+
getWebsiteAvailabilityStatus(websiteID: string) : Promise<WebsiteAvailabilityStatus> {
|
|
39
|
+
return this.crisp.get(
|
|
40
|
+
this.crisp.prepareRestUrl(["website", websiteID, "availability", "status"])
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* List Website Operator Availabilities
|
|
46
|
+
*/
|
|
47
|
+
listWebsiteOperatorAvailabilities(websiteID: string) : Promise<WebsiteAvailabilityOperator[]> {
|
|
48
|
+
return this.crisp.get(
|
|
49
|
+
this.crisp.prepareRestUrl(["website", websiteID, "availability", "operators"])
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export default WebsiteAvailability;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* node-crisp-api
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2022, Crisp IM SAS
|
|
5
|
+
* Author: Baptiste Jamin <baptiste@crisp.chat>
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**************************************************************************
|
|
9
|
+
* IMPORTS
|
|
10
|
+
***************************************************************************/
|
|
11
|
+
|
|
12
|
+
// PROJECT: RESOURCES
|
|
13
|
+
import BaseResource from "./BaseResource";
|
|
14
|
+
|
|
15
|
+
// Website mapping
|
|
16
|
+
type Website = {
|
|
17
|
+
website_id?: string;
|
|
18
|
+
name?: string;
|
|
19
|
+
domain?: string;
|
|
20
|
+
logo?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
type WebsiteCreate = {
|
|
24
|
+
name?: string;
|
|
25
|
+
domain?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
type WebsiteRemoveVerify = {
|
|
29
|
+
method?: string;
|
|
30
|
+
secret?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type WebsiteFilter = {
|
|
34
|
+
model?: string;
|
|
35
|
+
criterion?: string;
|
|
36
|
+
operator?: string;
|
|
37
|
+
query?: Record<string, unknown>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Crisp WebsiteBase Resource
|
|
42
|
+
*/
|
|
43
|
+
class WebsiteBase extends BaseResource {
|
|
44
|
+
/**
|
|
45
|
+
* Check If Website Exists
|
|
46
|
+
* @memberof WebsiteBase
|
|
47
|
+
* @public
|
|
48
|
+
* @method checkWebsiteExists
|
|
49
|
+
* @param {string} domain
|
|
50
|
+
* @return {Promise}
|
|
51
|
+
*/
|
|
52
|
+
checkWebsiteExists(domain: string) {
|
|
53
|
+
return this.crisp.head(
|
|
54
|
+
this.crisp.prepareRestUrl(["website"]),
|
|
55
|
+
|
|
56
|
+
{
|
|
57
|
+
domain: domain
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Create Website
|
|
64
|
+
*/
|
|
65
|
+
createWebsite(websiteData: WebsiteCreate) : Promise<Website> {
|
|
66
|
+
return this.crisp.post(
|
|
67
|
+
this.crisp.prepareRestUrl(["website"]), null, websiteData
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Get A Website
|
|
73
|
+
* @memberof WebsiteBase
|
|
74
|
+
* @public
|
|
75
|
+
* @method getWebsite
|
|
76
|
+
* @param {string} websiteID
|
|
77
|
+
* @return {Promise}
|
|
78
|
+
*/
|
|
79
|
+
getWebsite(websiteID: string) : Promise<Website> {
|
|
80
|
+
return this.crisp.get(
|
|
81
|
+
this.crisp.prepareRestUrl(["website", websiteID])
|
|
82
|
+
);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Delete A Website
|
|
87
|
+
*/
|
|
88
|
+
deleteWebsite(websiteID: string, verify: WebsiteRemoveVerify) {
|
|
89
|
+
return this.crisp.delete(
|
|
90
|
+
this.crisp.prepareRestUrl(["website", websiteID]), undefined,
|
|
91
|
+
|
|
92
|
+
{
|
|
93
|
+
verify: verify
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Abort Website Deletion
|
|
100
|
+
*/
|
|
101
|
+
abortWebsiteDeletion(websiteID: string) {
|
|
102
|
+
return this.crisp.delete(
|
|
103
|
+
this.crisp.prepareRestUrl(["website", websiteID, "expunge"])
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export default WebsiteBase;
|