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