crisp-api 9.13.0 → 10.0.3
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 +12 -0
- package/README.md +2 -2
- package/dist/crisp.d.ts +179 -0
- package/dist/crisp.js +773 -0
- package/dist/resources/BaseResource.d.ts +21 -0
- package/dist/resources/BaseResource.js +26 -0
- package/dist/resources/BucketURL.d.ts +37 -0
- package/dist/resources/BucketURL.js +35 -0
- package/dist/resources/MediaAnimation.d.ts +20 -0
- package/dist/resources/MediaAnimation.js +40 -0
- package/dist/resources/PluginConnect.d.ts +59 -0
- package/dist/resources/PluginConnect.js +79 -0
- package/dist/resources/PluginSubscription.d.ts +112 -0
- package/dist/resources/PluginSubscription.js +130 -0
- package/dist/resources/WebsiteAnalytics.d.ts +20 -0
- package/dist/resources/WebsiteAnalytics.js +37 -0
- package/dist/resources/WebsiteAvailability.d.ts +40 -0
- package/dist/resources/WebsiteAvailability.js +46 -0
- package/dist/resources/WebsiteBase.d.ts +69 -0
- package/dist/resources/WebsiteBase.js +77 -0
- package/dist/resources/WebsiteBatch.d.ts +61 -0
- package/dist/resources/WebsiteBatch.js +76 -0
- package/dist/resources/WebsiteCampaign.d.ts +208 -0
- package/dist/resources/WebsiteCampaign.js +201 -0
- package/dist/resources/WebsiteConversation.d.ts +710 -0
- package/dist/resources/WebsiteConversation.js +607 -0
- package/dist/resources/WebsiteHelpdesk.d.ts +356 -0
- package/dist/resources/WebsiteHelpdesk.js +593 -0
- package/dist/resources/WebsiteOperator.d.ts +88 -0
- package/dist/resources/WebsiteOperator.js +99 -0
- package/dist/resources/WebsitePeople.d.ts +257 -0
- package/dist/resources/WebsitePeople.js +282 -0
- package/dist/resources/WebsiteSettings.d.ts +168 -0
- package/dist/resources/WebsiteSettings.js +42 -0
- package/dist/resources/WebsiteVerify.d.ts +47 -0
- package/dist/resources/WebsiteVerify.js +56 -0
- package/dist/resources/WebsiteVisitors.d.ts +122 -0
- package/dist/resources/WebsiteVisitors.js +98 -0
- package/dist/resources/index.d.ts +20 -0
- package/dist/resources/index.js +42 -0
- package/dist/services/bucket.d.ts +19 -0
- package/dist/services/bucket.js +31 -0
- package/dist/services/media.d.ts +19 -0
- package/dist/services/media.js +31 -0
- package/dist/services/plugin.d.ts +20 -0
- package/dist/services/plugin.js +33 -0
- package/dist/services/website.d.ts +30 -0
- package/dist/services/website.js +53 -0
- package/eslint.config.mjs +208 -0
- package/lib/crisp.ts +1006 -0
- package/lib/resources/BaseResource.ts +37 -0
- package/lib/resources/BucketURL.ts +58 -0
- package/lib/resources/MediaAnimation.ts +44 -0
- package/lib/resources/PluginConnect.ts +135 -0
- package/lib/resources/PluginSubscription.ts +236 -0
- package/lib/resources/WebsiteAnalytics.ts +41 -0
- package/lib/resources/WebsiteAvailability.ts +74 -0
- package/lib/resources/WebsiteBase.ts +119 -0
- package/lib/resources/WebsiteBatch.ts +116 -0
- package/lib/resources/WebsiteCampaign.ts +432 -0
- package/lib/resources/WebsiteConversation.ts +1507 -0
- package/lib/resources/WebsiteHelpdesk.ts +1024 -0
- package/lib/resources/WebsiteOperator.ts +183 -0
- package/lib/resources/WebsitePeople.ts +568 -0
- package/lib/resources/WebsiteSettings.ts +207 -0
- package/lib/resources/WebsiteVerify.ts +90 -0
- package/lib/resources/WebsiteVisitors.ts +219 -0
- package/lib/resources/index.ts +28 -0
- package/lib/services/bucket.ts +36 -0
- package/lib/services/media.ts +36 -0
- package/lib/services/plugin.ts +40 -0
- package/lib/services/website.ts +70 -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,119 @@
|
|
|
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
|
+
/**************************************************************************
|
|
16
|
+
* TYPES
|
|
17
|
+
***************************************************************************/
|
|
18
|
+
|
|
19
|
+
type Website = {
|
|
20
|
+
website_id?: string;
|
|
21
|
+
name?: string;
|
|
22
|
+
domain?: string;
|
|
23
|
+
logo?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
type WebsiteCreate = {
|
|
27
|
+
name?: string;
|
|
28
|
+
domain?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
type WebsiteRemoveVerify = {
|
|
32
|
+
method?: string;
|
|
33
|
+
secret?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type WebsiteFilter = {
|
|
37
|
+
model?: string;
|
|
38
|
+
criterion?: string;
|
|
39
|
+
operator?: string;
|
|
40
|
+
query?: Record<string, unknown>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**************************************************************************
|
|
44
|
+
* CLASSES
|
|
45
|
+
***************************************************************************/
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Crisp WebsiteBase Resource
|
|
49
|
+
*/
|
|
50
|
+
class WebsiteBase extends BaseResource {
|
|
51
|
+
/**
|
|
52
|
+
* Check If Website Exists
|
|
53
|
+
* @memberof WebsiteBase
|
|
54
|
+
* @public
|
|
55
|
+
* @method checkWebsiteExists
|
|
56
|
+
* @param {string} domain
|
|
57
|
+
* @return {Promise}
|
|
58
|
+
*/
|
|
59
|
+
checkWebsiteExists(domain: string) {
|
|
60
|
+
return this.crisp.head(
|
|
61
|
+
this.crisp.prepareRestUrl(["website"]),
|
|
62
|
+
|
|
63
|
+
{
|
|
64
|
+
domain: domain
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Create Website
|
|
71
|
+
*/
|
|
72
|
+
createWebsite(websiteData: WebsiteCreate): Promise<Website> {
|
|
73
|
+
return this.crisp.post(
|
|
74
|
+
this.crisp.prepareRestUrl(["website"]), null, websiteData
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Get A Website
|
|
80
|
+
* @memberof WebsiteBase
|
|
81
|
+
* @public
|
|
82
|
+
* @method getWebsite
|
|
83
|
+
* @param {string} websiteID
|
|
84
|
+
* @return {Promise}
|
|
85
|
+
*/
|
|
86
|
+
getWebsite(websiteID: string): Promise<Website> {
|
|
87
|
+
return this.crisp.get(
|
|
88
|
+
this.crisp.prepareRestUrl(["website", websiteID])
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Delete A Website
|
|
94
|
+
*/
|
|
95
|
+
deleteWebsite(websiteID: string, verify: WebsiteRemoveVerify) {
|
|
96
|
+
return this.crisp.delete(
|
|
97
|
+
this.crisp.prepareRestUrl(["website", websiteID]), undefined,
|
|
98
|
+
|
|
99
|
+
{
|
|
100
|
+
verify: verify
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Abort Website Deletion
|
|
107
|
+
*/
|
|
108
|
+
abortWebsiteDeletion(websiteID: string) {
|
|
109
|
+
return this.crisp.delete(
|
|
110
|
+
this.crisp.prepareRestUrl(["website", websiteID, "expunge"])
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**************************************************************************
|
|
116
|
+
* EXPORTS
|
|
117
|
+
***************************************************************************/
|
|
118
|
+
|
|
119
|
+
export default WebsiteBase;
|
|
@@ -0,0 +1,116 @@
|
|
|
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
|
+
* TYPES
|
|
17
|
+
***************************************************************************/
|
|
18
|
+
|
|
19
|
+
type WebsiteBatchConversationsOperation = {
|
|
20
|
+
inbox_id?: string;
|
|
21
|
+
sessions?: string[];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
type WebsiteBatchPeopleOperationInner = {
|
|
25
|
+
profiles?: string[];
|
|
26
|
+
search?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**************************************************************************
|
|
30
|
+
* CLASSES
|
|
31
|
+
***************************************************************************/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Crisp WebsiteBatch Resource
|
|
35
|
+
*/
|
|
36
|
+
class WebsiteBatch extends BaseResource {
|
|
37
|
+
/**
|
|
38
|
+
* Batch Resolve Conversations
|
|
39
|
+
*/
|
|
40
|
+
batchResolveConversations(
|
|
41
|
+
websiteID: string, operation: WebsiteBatchConversationsOperation
|
|
42
|
+
) {
|
|
43
|
+
return this.crisp.patch(
|
|
44
|
+
this.crisp.prepareRestUrl(["website", websiteID, "batch", "resolve"]),
|
|
45
|
+
|
|
46
|
+
null, operation
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Batch Read Conversations
|
|
52
|
+
* @memberof WebsiteBatch
|
|
53
|
+
* @public
|
|
54
|
+
* @method batchReadConversations
|
|
55
|
+
* @param {string} websiteID
|
|
56
|
+
* @param {object} operation
|
|
57
|
+
* @return {Promise}
|
|
58
|
+
*/
|
|
59
|
+
batchReadConversations(
|
|
60
|
+
websiteID: string, operation: WebsiteBatchConversationsOperation
|
|
61
|
+
) {
|
|
62
|
+
return this.crisp.patch(
|
|
63
|
+
this.crisp.prepareRestUrl(["website", websiteID, "batch", "read"]),
|
|
64
|
+
|
|
65
|
+
null, operation
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Batch Remove Conversations
|
|
71
|
+
* @memberof WebsiteBatch
|
|
72
|
+
* @public
|
|
73
|
+
* @method batchRemoveConversations
|
|
74
|
+
* @param {string} websiteID
|
|
75
|
+
* @param {object} operation
|
|
76
|
+
* @return {Promise}
|
|
77
|
+
*/
|
|
78
|
+
batchRemoveConversations(
|
|
79
|
+
websiteID: string, operation: WebsiteBatchConversationsOperation
|
|
80
|
+
) {
|
|
81
|
+
return this.crisp.patch(
|
|
82
|
+
this.crisp.prepareRestUrl(["website", websiteID, "batch", "remove"]),
|
|
83
|
+
|
|
84
|
+
null, operation
|
|
85
|
+
);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Batch Remove People
|
|
90
|
+
* @memberof WebsiteBatch
|
|
91
|
+
* @public
|
|
92
|
+
* @method batchRemovePeople
|
|
93
|
+
* @param {string} websiteID
|
|
94
|
+
* @param {object} people
|
|
95
|
+
* @return {Promise}
|
|
96
|
+
*/
|
|
97
|
+
batchRemovePeople(
|
|
98
|
+
websiteID: string, people: WebsiteBatchPeopleOperationInner
|
|
99
|
+
) {
|
|
100
|
+
return this.crisp.patch(
|
|
101
|
+
this.crisp.prepareRestUrl(["website", websiteID, "batch", "remove"]),
|
|
102
|
+
|
|
103
|
+
null,
|
|
104
|
+
|
|
105
|
+
{
|
|
106
|
+
people: people
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**************************************************************************
|
|
113
|
+
* EXPORTS
|
|
114
|
+
***************************************************************************/
|
|
115
|
+
|
|
116
|
+
export default WebsiteBatch;
|
|
@@ -0,0 +1,432 @@
|
|
|
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
|
+
import { WebsiteFilter } from "./WebsiteBase";
|
|
15
|
+
|
|
16
|
+
/**************************************************************************
|
|
17
|
+
* TYPES
|
|
18
|
+
***************************************************************************/
|
|
19
|
+
|
|
20
|
+
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;
|
|
35
|
+
dispatched_at?: number;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
type WebsiteCampaignTemplateExcerpt = {
|
|
39
|
+
template_id?: string;
|
|
40
|
+
type?: string;
|
|
41
|
+
name?: string;
|
|
42
|
+
format?: string;
|
|
43
|
+
created_at?: number;
|
|
44
|
+
updated_at?: number;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
type WebsiteCampaignTemplateNew = {
|
|
48
|
+
template_id?: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
interface WebsiteCampaignTemplateItem extends WebsiteCampaignTemplateExcerpt {
|
|
52
|
+
content?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
interface WebsiteCampaignItem extends WebsiteCampaignExcerpt {
|
|
56
|
+
sender?: WebsiteCampaignItemSender;
|
|
57
|
+
recipients?: WebsiteCampaignItemRecipients;
|
|
58
|
+
flow?: WebsiteCampaignItemFlow;
|
|
59
|
+
message?: string;
|
|
60
|
+
options?: WebsiteCampaignItemOptions;
|
|
61
|
+
statistics?: WebsiteCampaignItemStatistics;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
type WebsiteCampaignItemSender = {
|
|
65
|
+
user_id?: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
type WebsiteCampaignItemRecipients = {
|
|
69
|
+
type?: string;
|
|
70
|
+
segments?: string[];
|
|
71
|
+
people?: string[];
|
|
72
|
+
filter?: WebsiteFilter[];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
type WebsiteCampaignItemFlow = {
|
|
76
|
+
launch_event?: string;
|
|
77
|
+
assert_filter?: WebsiteFilter[];
|
|
78
|
+
assert_delay?: number;
|
|
79
|
+
deliver_once?: boolean;
|
|
80
|
+
deliver_delay?: number;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
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;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
type WebsiteCampaignItemStatistics = {
|
|
92
|
+
opened?: number;
|
|
93
|
+
clicked?: number;
|
|
94
|
+
unsubscribed?: number;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
type WebsiteCampaignRecipient = {
|
|
98
|
+
people_id?: string;
|
|
99
|
+
email?: string;
|
|
100
|
+
person?: WebsiteCampaignRecipientPerson;
|
|
101
|
+
subscribed?: boolean;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
type WebsiteCampaignRecipientPerson = {
|
|
105
|
+
nickname?: string;
|
|
106
|
+
avatar?: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
type WebsiteCampaignStatistic = {
|
|
110
|
+
profile?: WebsiteCampaignStatisticProfile;
|
|
111
|
+
data?: Record<string, unknown>;
|
|
112
|
+
created_at?: number;
|
|
113
|
+
updated_at?: number;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
type WebsiteCampaignStatisticProfile = {
|
|
117
|
+
people_id?: string;
|
|
118
|
+
email?: string;
|
|
119
|
+
person?: WebsiteCampaignStatisticProfilePerson;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
type WebsiteCampaignStatisticProfilePerson = {
|
|
123
|
+
nickname?: string;
|
|
124
|
+
avatar?: string;
|
|
125
|
+
geolocation?: WebsiteCampaignStatisticProfilePersonGeolocation;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
type WebsiteCampaignStatisticProfilePersonGeolocation = {
|
|
129
|
+
country?: string;
|
|
130
|
+
region?: string;
|
|
131
|
+
city?: string;
|
|
132
|
+
coordinates?: WebsiteCampaignStatisticProfilePersonGeolocationCoordinates;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
type WebsiteCampaignStatisticProfilePersonGeolocationCoordinates = {
|
|
136
|
+
latitude?: number;
|
|
137
|
+
longitude?: number;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**************************************************************************
|
|
141
|
+
* CLASSES
|
|
142
|
+
***************************************************************************/
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Crisp WebsiteCampaign Resource
|
|
146
|
+
*/
|
|
147
|
+
class WebsiteCampaign extends BaseResource {
|
|
148
|
+
/**
|
|
149
|
+
* List Campaigns
|
|
150
|
+
*/
|
|
151
|
+
listCampaigns(
|
|
152
|
+
websiteID: string, pageNumber: number = 1
|
|
153
|
+
): Promise<WebsiteCampaignExcerpt[]> {
|
|
154
|
+
return this.crisp.get(
|
|
155
|
+
this.crisp.prepareRestUrl([
|
|
156
|
+
"website", websiteID, "campaigns", "list", String(pageNumber)
|
|
157
|
+
])
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* List Campaign Tags
|
|
163
|
+
*/
|
|
164
|
+
listCampaignTags(websiteID: string): Promise<string[]> {
|
|
165
|
+
return this.crisp.get(
|
|
166
|
+
this.crisp.prepareRestUrl(["website", websiteID, "campaigns", "tags"])
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* List Campaign Templates
|
|
172
|
+
*/
|
|
173
|
+
listCampaignTemplates(
|
|
174
|
+
websiteID: string, pageNumber: number = 1
|
|
175
|
+
): Promise<WebsiteCampaignTemplateExcerpt[]> {
|
|
176
|
+
return this.crisp.get(
|
|
177
|
+
this.crisp.prepareRestUrl([
|
|
178
|
+
"website", websiteID, "campaigns", "templates", String(pageNumber)
|
|
179
|
+
])
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Create A New Campaign Template
|
|
185
|
+
*/
|
|
186
|
+
createNewCampaignTemplate(
|
|
187
|
+
websiteID: string, templateFormat: string, templateName: string
|
|
188
|
+
): Promise<WebsiteCampaignTemplateNew> {
|
|
189
|
+
return this.crisp.post(
|
|
190
|
+
this.crisp.prepareRestUrl(["website", websiteID, "campaigns", "template"]),
|
|
191
|
+
|
|
192
|
+
null,
|
|
193
|
+
|
|
194
|
+
{
|
|
195
|
+
format: templateFormat,
|
|
196
|
+
name: templateName
|
|
197
|
+
}
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Check If Campaign Template Exists
|
|
203
|
+
*/
|
|
204
|
+
checkCampaignTemplateExists(websiteID: string, templateID: string) {
|
|
205
|
+
return this.crisp.head(
|
|
206
|
+
this.crisp.prepareRestUrl([
|
|
207
|
+
"website", websiteID, "campaigns", "template", templateID
|
|
208
|
+
])
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Get A Campaign Template
|
|
214
|
+
*/
|
|
215
|
+
getCampaignTemplate(
|
|
216
|
+
websiteID: string, templateID: string
|
|
217
|
+
): Promise<WebsiteCampaignTemplateItem> {
|
|
218
|
+
return this.crisp.get(
|
|
219
|
+
this.crisp.prepareRestUrl([
|
|
220
|
+
"website", websiteID, "campaigns", "template", templateID
|
|
221
|
+
])
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Save A Campaign Template
|
|
227
|
+
*/
|
|
228
|
+
saveCampaignTemplate(
|
|
229
|
+
websiteID: string, templateID: string, template: WebsiteCampaignTemplateItem
|
|
230
|
+
) {
|
|
231
|
+
return this.crisp.put(
|
|
232
|
+
this.crisp.prepareRestUrl([
|
|
233
|
+
"website", websiteID, "campaigns", "template", templateID
|
|
234
|
+
]),
|
|
235
|
+
|
|
236
|
+
null, template
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Update A Campaign Template
|
|
242
|
+
*/
|
|
243
|
+
updateCampaignTemplate(
|
|
244
|
+
websiteID: string, templateID: string, template: WebsiteCampaignTemplateItem
|
|
245
|
+
) {
|
|
246
|
+
return this.crisp.patch(
|
|
247
|
+
this.crisp.prepareRestUrl([
|
|
248
|
+
"website", websiteID, "campaigns", "template", templateID
|
|
249
|
+
]),
|
|
250
|
+
|
|
251
|
+
null, template
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Remove A Campaign Template
|
|
257
|
+
*/
|
|
258
|
+
removeCampaignTemplate(websiteID: string, templateID: string) {
|
|
259
|
+
return this.crisp.delete(
|
|
260
|
+
this.crisp.prepareRestUrl([
|
|
261
|
+
"website", websiteID, "campaigns", "template", templateID
|
|
262
|
+
])
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Create A New Campaign
|
|
268
|
+
*/
|
|
269
|
+
createNewCampaign(
|
|
270
|
+
websiteID: string, campaignType: string, campaignName: string
|
|
271
|
+
) {
|
|
272
|
+
return this.crisp.post(
|
|
273
|
+
this.crisp.prepareRestUrl(["website", websiteID, "campaign"]),
|
|
274
|
+
|
|
275
|
+
null,
|
|
276
|
+
|
|
277
|
+
{
|
|
278
|
+
type: campaignType,
|
|
279
|
+
name: campaignName
|
|
280
|
+
}
|
|
281
|
+
);
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Check If Campaign Exists
|
|
286
|
+
*/
|
|
287
|
+
checkCampaignExists(websiteID: string, campaignID: string) {
|
|
288
|
+
return this.crisp.head(
|
|
289
|
+
this.crisp.prepareRestUrl(["website", websiteID, "campaign", campaignID])
|
|
290
|
+
);
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Get A Campaign
|
|
295
|
+
*/
|
|
296
|
+
getCampaign(
|
|
297
|
+
websiteID: string, campaignID: string
|
|
298
|
+
): Promise<WebsiteCampaignItem> {
|
|
299
|
+
return this.crisp.get(
|
|
300
|
+
this.crisp.prepareRestUrl(["website", websiteID, "campaign", campaignID])
|
|
301
|
+
);
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Save A Campaign
|
|
306
|
+
*/
|
|
307
|
+
saveCampaign(
|
|
308
|
+
websiteID: string, campaignID: string, campaign: WebsiteCampaignItem
|
|
309
|
+
) {
|
|
310
|
+
return this.crisp.put(
|
|
311
|
+
this.crisp.prepareRestUrl(["website", websiteID, "campaign", campaignID]),
|
|
312
|
+
|
|
313
|
+
null, campaign
|
|
314
|
+
);
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Update A Campaign
|
|
319
|
+
*/
|
|
320
|
+
updateCampaign(
|
|
321
|
+
websiteID: string, campaignID: string, campaign: WebsiteCampaignItem
|
|
322
|
+
) {
|
|
323
|
+
return this.crisp.patch(
|
|
324
|
+
this.crisp.prepareRestUrl(["website", websiteID, "campaign", campaignID]),
|
|
325
|
+
|
|
326
|
+
null, campaign
|
|
327
|
+
);
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Remove A Campaign
|
|
332
|
+
*/
|
|
333
|
+
removeCampaign(websiteID: string, campaignID: string) {
|
|
334
|
+
return this.crisp.delete(
|
|
335
|
+
this.crisp.prepareRestUrl(["website", websiteID, "campaign", campaignID])
|
|
336
|
+
);
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Dispatch A Campaign
|
|
341
|
+
* @return {Promise}
|
|
342
|
+
*/
|
|
343
|
+
dispatchCampaign(websiteID: string, campaignID: string) {
|
|
344
|
+
return this.crisp.post(
|
|
345
|
+
this.crisp.prepareRestUrl([
|
|
346
|
+
"website", websiteID, "campaign", campaignID, "dispatch"
|
|
347
|
+
]),
|
|
348
|
+
|
|
349
|
+
null,
|
|
350
|
+
null
|
|
351
|
+
);
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Resume A Campaign
|
|
356
|
+
*/
|
|
357
|
+
resumeCampaign(websiteID: string, campaignID: string) {
|
|
358
|
+
return this.crisp.post(
|
|
359
|
+
this.crisp.prepareRestUrl([
|
|
360
|
+
"website", websiteID, "campaign", campaignID, "resume"
|
|
361
|
+
]),
|
|
362
|
+
|
|
363
|
+
null,
|
|
364
|
+
null
|
|
365
|
+
);
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Pause A Campaign
|
|
370
|
+
*/
|
|
371
|
+
pauseCampaign(websiteID: string, campaignID: string) {
|
|
372
|
+
return this.crisp.post(
|
|
373
|
+
this.crisp.prepareRestUrl([
|
|
374
|
+
"website", websiteID, "campaign", campaignID, "pause"
|
|
375
|
+
]),
|
|
376
|
+
|
|
377
|
+
null,
|
|
378
|
+
null
|
|
379
|
+
);
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Test A Campaign
|
|
384
|
+
*/
|
|
385
|
+
testCampaign(websiteID: string, campaignID: string) {
|
|
386
|
+
return this.crisp.post(
|
|
387
|
+
this.crisp.prepareRestUrl([
|
|
388
|
+
"website", websiteID, "campaign", campaignID, "test"
|
|
389
|
+
]),
|
|
390
|
+
|
|
391
|
+
null,
|
|
392
|
+
null
|
|
393
|
+
);
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* List Campaign Recipients
|
|
398
|
+
*/
|
|
399
|
+
listCampaignRecipients(
|
|
400
|
+
websiteID: string, campaignID: string, pageNumber: number = 1
|
|
401
|
+
): Promise<WebsiteCampaignRecipient[]> {
|
|
402
|
+
return this.crisp.get(
|
|
403
|
+
this.crisp.prepareRestUrl([
|
|
404
|
+
"website", websiteID, "campaign", campaignID, "recipients",
|
|
405
|
+
String(pageNumber)
|
|
406
|
+
])
|
|
407
|
+
);
|
|
408
|
+
};
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* List Campaign Statistics
|
|
412
|
+
*/
|
|
413
|
+
listCampaignStatistics(
|
|
414
|
+
websiteID: string,
|
|
415
|
+
campaignID: string,
|
|
416
|
+
action: string,
|
|
417
|
+
pageNumber: number = 1
|
|
418
|
+
): Promise<WebsiteCampaignStatistic[]> {
|
|
419
|
+
return this.crisp.get(
|
|
420
|
+
this.crisp.prepareRestUrl([
|
|
421
|
+
"website", websiteID, "campaign", campaignID, "statistics", action,
|
|
422
|
+
String(pageNumber)
|
|
423
|
+
])
|
|
424
|
+
);
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/**************************************************************************
|
|
429
|
+
* EXPORTS
|
|
430
|
+
***************************************************************************/
|
|
431
|
+
|
|
432
|
+
export default WebsiteCampaign;
|