crisp-api 10.0.2 → 10.0.4
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 +6 -2
- package/dist/crisp.d.ts +41 -29
- package/dist/crisp.js +43 -34
- package/dist/resources/BaseResource.d.ts +6 -0
- package/dist/resources/BaseResource.js +6 -0
- package/dist/resources/BucketURL.d.ts +9 -0
- package/dist/resources/BucketURL.js +6 -0
- package/dist/resources/MediaAnimation.d.ts +6 -0
- package/dist/resources/MediaAnimation.js +9 -1
- package/dist/resources/PluginConnect.d.ts +9 -0
- package/dist/resources/PluginConnect.js +6 -0
- package/dist/resources/PluginSubscription.d.ts +9 -0
- package/dist/resources/PluginSubscription.js +9 -1
- package/dist/resources/WebsiteAnalytics.d.ts +6 -0
- package/dist/resources/WebsiteAnalytics.js +9 -1
- package/dist/resources/WebsiteAvailability.d.ts +9 -0
- package/dist/resources/WebsiteAvailability.js +12 -2
- package/dist/resources/WebsiteBase.d.ts +9 -0
- package/dist/resources/WebsiteBase.js +6 -0
- package/dist/resources/WebsiteBatch.d.ts +9 -0
- package/dist/resources/WebsiteBatch.js +6 -0
- package/dist/resources/WebsiteCampaign.d.ts +9 -0
- package/dist/resources/WebsiteCampaign.js +8 -1
- package/dist/resources/WebsiteConversation.d.ts +9 -0
- package/dist/resources/WebsiteConversation.js +15 -3
- package/dist/resources/WebsiteHelpdesk.d.ts +15 -2
- package/dist/resources/WebsiteHelpdesk.js +6 -0
- package/dist/resources/WebsiteOperator.d.ts +9 -0
- package/dist/resources/WebsiteOperator.js +6 -0
- package/dist/resources/WebsitePeople.d.ts +9 -0
- package/dist/resources/WebsitePeople.js +6 -0
- package/dist/resources/WebsiteSettings.d.ts +9 -0
- package/dist/resources/WebsiteSettings.js +6 -0
- package/dist/resources/WebsiteVerify.d.ts +9 -0
- package/dist/resources/WebsiteVerify.js +6 -0
- package/dist/resources/WebsiteVisitors.d.ts +9 -0
- package/dist/resources/WebsiteVisitors.js +12 -2
- package/dist/resources/index.d.ts +3 -0
- package/dist/resources/index.js +3 -1
- package/dist/services/bucket.d.ts +6 -0
- package/dist/services/bucket.js +3 -0
- package/dist/services/media.d.ts +6 -0
- package/dist/services/media.js +3 -0
- package/dist/services/plugin.d.ts +6 -0
- package/dist/services/plugin.js +3 -0
- package/dist/services/website.d.ts +6 -0
- package/dist/services/website.js +3 -0
- package/lib/crisp.ts +123 -74
- package/lib/resources/BaseResource.ts +8 -0
- package/lib/resources/BucketURL.ts +12 -3
- package/lib/resources/MediaAnimation.ts +11 -1
- package/lib/resources/PluginConnect.ts +12 -5
- package/lib/resources/PluginSubscription.ts +36 -8
- package/lib/resources/WebsiteAnalytics.ts +11 -1
- package/lib/resources/WebsiteAvailability.ts +24 -4
- package/lib/resources/WebsiteBase.ts +14 -3
- package/lib/resources/WebsiteBatch.ts +24 -4
- package/lib/resources/WebsiteCampaign.ts +49 -16
- package/lib/resources/WebsiteConversation.ts +136 -45
- package/lib/resources/WebsiteHelpdesk.ts +81 -34
- package/lib/resources/WebsiteOperator.ts +28 -6
- package/lib/resources/WebsitePeople.ts +60 -19
- package/lib/resources/WebsiteSettings.ts +17 -2
- package/lib/resources/WebsiteVerify.ts +17 -3
- package/lib/resources/WebsiteVisitors.ts +32 -9
- package/lib/resources/index.ts +4 -1
- package/lib/services/bucket.ts +8 -0
- package/lib/services/media.ts +8 -0
- package/lib/services/plugin.ts +8 -0
- package/lib/services/website.ts +8 -0
- package/package.json +1 -1
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
// PROJECT: RESOURCES
|
|
13
13
|
import BaseResource from "./BaseResource";
|
|
14
14
|
|
|
15
|
+
/**************************************************************************
|
|
16
|
+
* CLASSES
|
|
17
|
+
***************************************************************************/
|
|
18
|
+
|
|
15
19
|
/**
|
|
16
20
|
* Crisp MediaAnimation Resource
|
|
17
21
|
*/
|
|
@@ -21,7 +25,9 @@ class MediaAnimation extends BaseResource {
|
|
|
21
25
|
*/
|
|
22
26
|
listAnimationMedias(pageNumber: number, listID: string, searchQuery: object) {
|
|
23
27
|
return this.crisp.get(
|
|
24
|
-
this.crisp.prepareRestUrl([
|
|
28
|
+
this.crisp.prepareRestUrl([
|
|
29
|
+
"media", "animation", "list", String(pageNumber)
|
|
30
|
+
]),
|
|
25
31
|
|
|
26
32
|
{
|
|
27
33
|
list_id: listID,
|
|
@@ -31,4 +37,8 @@ class MediaAnimation extends BaseResource {
|
|
|
31
37
|
};
|
|
32
38
|
}
|
|
33
39
|
|
|
40
|
+
/**************************************************************************
|
|
41
|
+
* EXPORTS
|
|
42
|
+
***************************************************************************/
|
|
43
|
+
|
|
34
44
|
export default MediaAnimation;
|
|
@@ -12,19 +12,20 @@
|
|
|
12
12
|
// PROJECT: RESOURCES
|
|
13
13
|
import BaseResource from "./BaseResource";
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
/**************************************************************************
|
|
16
|
+
* TYPES
|
|
17
|
+
***************************************************************************/
|
|
18
|
+
|
|
16
19
|
export type PluginConnectAccount = {
|
|
17
20
|
plugin_id?: string;
|
|
18
21
|
};
|
|
19
22
|
|
|
20
|
-
// PluginConnectAllWebsites mapping
|
|
21
23
|
export type PluginConnectAllWebsites = {
|
|
22
24
|
website_id?: string;
|
|
23
25
|
token?: string;
|
|
24
26
|
settings?: object;
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
// PluginConnectWebsitesSince mapping
|
|
28
29
|
export type PluginConnectWebsitesSince = {
|
|
29
30
|
website_id?: string;
|
|
30
31
|
token?: string;
|
|
@@ -32,16 +33,18 @@ export type PluginConnectWebsitesSince = {
|
|
|
32
33
|
difference?: string;
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
// PluginConnectEndpoints mapping
|
|
36
36
|
export type PluginConnectEndpoints = {
|
|
37
37
|
socket?: PluginConnectEndpointsSocket;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
// PluginConnectEndpointsSocket mapping
|
|
41
40
|
export type PluginConnectEndpointsSocket = {
|
|
42
41
|
app?: string;
|
|
43
42
|
}
|
|
44
43
|
|
|
44
|
+
/**************************************************************************
|
|
45
|
+
* CLASSES
|
|
46
|
+
***************************************************************************/
|
|
47
|
+
|
|
45
48
|
/**
|
|
46
49
|
* Crisp PluginConnect Resource
|
|
47
50
|
*/
|
|
@@ -125,4 +128,8 @@ class PluginConnect extends BaseResource {
|
|
|
125
128
|
};
|
|
126
129
|
}
|
|
127
130
|
|
|
131
|
+
/**************************************************************************
|
|
132
|
+
* EXPORTS
|
|
133
|
+
***************************************************************************/
|
|
134
|
+
|
|
128
135
|
export default PluginConnect;
|
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
// PROJECT: RESOURCES
|
|
13
13
|
import BaseResource from "./BaseResource";
|
|
14
14
|
|
|
15
|
+
/**************************************************************************
|
|
16
|
+
* TYPES
|
|
17
|
+
***************************************************************************/
|
|
18
|
+
|
|
15
19
|
type PluginSubscription = {
|
|
16
20
|
id?: string;
|
|
17
21
|
urn?: string;
|
|
@@ -62,6 +66,10 @@ type PluginSubscriptionEventDispatch = {
|
|
|
62
66
|
data?: object;
|
|
63
67
|
}
|
|
64
68
|
|
|
69
|
+
/**************************************************************************
|
|
70
|
+
* CLASSES
|
|
71
|
+
***************************************************************************/
|
|
72
|
+
|
|
65
73
|
/**
|
|
66
74
|
* Crisp PluginSubscription Resource
|
|
67
75
|
*/
|
|
@@ -78,7 +86,9 @@ class PluginSubscriptionService extends BaseResource {
|
|
|
78
86
|
/**
|
|
79
87
|
* List Subscriptions For A Website
|
|
80
88
|
*/
|
|
81
|
-
listSubscriptionsForWebsite(
|
|
89
|
+
listSubscriptionsForWebsite(
|
|
90
|
+
websiteID: string
|
|
91
|
+
): Promise<PluginSubscription[]> {
|
|
82
92
|
return this.crisp.get(
|
|
83
93
|
this.crisp.prepareRestUrl(["plugins", "subscription", websiteID])
|
|
84
94
|
);
|
|
@@ -87,7 +97,9 @@ class PluginSubscriptionService extends BaseResource {
|
|
|
87
97
|
/**
|
|
88
98
|
* Get Subscription Details
|
|
89
99
|
*/
|
|
90
|
-
getSubscriptionDetails(
|
|
100
|
+
getSubscriptionDetails(
|
|
101
|
+
websiteID: string, pluginID: string
|
|
102
|
+
): Promise<PluginSubscription> {
|
|
91
103
|
return this.crisp.get(
|
|
92
104
|
this.crisp.prepareRestUrl(["plugins", "subscription", websiteID, pluginID])
|
|
93
105
|
);
|
|
@@ -113,14 +125,18 @@ class PluginSubscriptionService extends BaseResource {
|
|
|
113
125
|
*/
|
|
114
126
|
unsubscribePluginFromWebsite(websiteID: string, pluginID: string) {
|
|
115
127
|
return this.crisp.delete(
|
|
116
|
-
this.crisp.prepareRestUrl([
|
|
128
|
+
this.crisp.prepareRestUrl([
|
|
129
|
+
"plugins", "subscription", websiteID, pluginID
|
|
130
|
+
])
|
|
117
131
|
);
|
|
118
132
|
};
|
|
119
133
|
|
|
120
134
|
/**
|
|
121
135
|
* Get Subscription Settings
|
|
122
136
|
*/
|
|
123
|
-
getSubscriptionSettings(
|
|
137
|
+
getSubscriptionSettings(
|
|
138
|
+
websiteID: string, pluginID: string
|
|
139
|
+
): Promise<PluginSubscriptionSettings> {
|
|
124
140
|
return this.crisp.get(
|
|
125
141
|
this.crisp.prepareRestUrl([
|
|
126
142
|
"plugins", "subscription", websiteID, pluginID, "settings"
|
|
@@ -131,7 +147,9 @@ class PluginSubscriptionService extends BaseResource {
|
|
|
131
147
|
/**
|
|
132
148
|
* Save Subscription Settings
|
|
133
149
|
*/
|
|
134
|
-
saveSubscriptionSettings(
|
|
150
|
+
saveSubscriptionSettings(
|
|
151
|
+
websiteID: string, pluginID: string, settings: object
|
|
152
|
+
) {
|
|
135
153
|
return this.crisp.put(
|
|
136
154
|
this.crisp.prepareRestUrl([
|
|
137
155
|
"plugins", "subscription", websiteID, pluginID, "settings"
|
|
@@ -144,7 +162,9 @@ class PluginSubscriptionService extends BaseResource {
|
|
|
144
162
|
/**
|
|
145
163
|
* Update Subscription Settings
|
|
146
164
|
*/
|
|
147
|
-
updateSubscriptionSettings(
|
|
165
|
+
updateSubscriptionSettings(
|
|
166
|
+
websiteID: string, pluginID: string, settings: object
|
|
167
|
+
) {
|
|
148
168
|
return this.crisp.patch(
|
|
149
169
|
this.crisp.prepareRestUrl([
|
|
150
170
|
"plugins", "subscription", websiteID, pluginID, "settings"
|
|
@@ -181,7 +201,9 @@ class PluginSubscriptionService extends BaseResource {
|
|
|
181
201
|
/**
|
|
182
202
|
* Forward Plugin Payload To Channel
|
|
183
203
|
*/
|
|
184
|
-
forwardPluginPayloadToChannel(
|
|
204
|
+
forwardPluginPayloadToChannel(
|
|
205
|
+
websiteID: string, pluginID: string, payload: PluginSubscriptionChannelForward
|
|
206
|
+
) {
|
|
185
207
|
return this.crisp.post(
|
|
186
208
|
this.crisp.prepareRestUrl([
|
|
187
209
|
"plugins", "subscription", websiteID, pluginID, "channel"
|
|
@@ -194,7 +216,9 @@ class PluginSubscriptionService extends BaseResource {
|
|
|
194
216
|
/**
|
|
195
217
|
* Dispatch Plugin Event
|
|
196
218
|
*/
|
|
197
|
-
dispatchPluginEvent(
|
|
219
|
+
dispatchPluginEvent(
|
|
220
|
+
websiteID: string, pluginID: string, payload: PluginSubscriptionEventDispatch
|
|
221
|
+
) {
|
|
198
222
|
return this.crisp.post(
|
|
199
223
|
this.crisp.prepareRestUrl([
|
|
200
224
|
"plugins", "subscription", websiteID, pluginID, "event"
|
|
@@ -205,4 +229,8 @@ class PluginSubscriptionService extends BaseResource {
|
|
|
205
229
|
};
|
|
206
230
|
}
|
|
207
231
|
|
|
232
|
+
/**************************************************************************
|
|
233
|
+
* EXPORTS
|
|
234
|
+
***************************************************************************/
|
|
235
|
+
|
|
208
236
|
export default PluginSubscriptionService;
|
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
// PROJECT: RESOURCES
|
|
13
13
|
import BaseResource from "./BaseResource";
|
|
14
14
|
|
|
15
|
+
/**************************************************************************
|
|
16
|
+
* CLASSES
|
|
17
|
+
***************************************************************************/
|
|
18
|
+
|
|
15
19
|
/**
|
|
16
20
|
* Crisp WebsiteAnalytics Resource
|
|
17
21
|
*/
|
|
@@ -21,11 +25,17 @@ class WebsiteAnalytics extends BaseResource {
|
|
|
21
25
|
*/
|
|
22
26
|
generateAnalytics(websiteID: string, query: object) {
|
|
23
27
|
return this.crisp.post(
|
|
24
|
-
this.crisp.prepareRestUrl([
|
|
28
|
+
this.crisp.prepareRestUrl([
|
|
29
|
+
"website", websiteID, "analytics", "generate"
|
|
30
|
+
]),
|
|
25
31
|
|
|
26
32
|
null, query
|
|
27
33
|
);
|
|
28
34
|
};
|
|
29
35
|
}
|
|
30
36
|
|
|
37
|
+
/**************************************************************************
|
|
38
|
+
* EXPORTS
|
|
39
|
+
***************************************************************************/
|
|
40
|
+
|
|
31
41
|
export default WebsiteAnalytics;
|
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
// PROJECT: RESOURCES
|
|
13
13
|
import BaseResource from "./BaseResource";
|
|
14
14
|
|
|
15
|
+
/**************************************************************************
|
|
16
|
+
* TYPES
|
|
17
|
+
***************************************************************************/
|
|
18
|
+
|
|
15
19
|
type WebsiteAvailabilityStatus = {
|
|
16
20
|
status?: string;
|
|
17
21
|
since?: number;
|
|
@@ -28,6 +32,10 @@ type WebsiteAvailabilityOperatorTime = {
|
|
|
28
32
|
since?: number;
|
|
29
33
|
}
|
|
30
34
|
|
|
35
|
+
/**************************************************************************
|
|
36
|
+
* CLASSES
|
|
37
|
+
***************************************************************************/
|
|
38
|
+
|
|
31
39
|
/**
|
|
32
40
|
* Crisp WebsiteAvailability Resource
|
|
33
41
|
*/
|
|
@@ -35,20 +43,32 @@ class WebsiteAvailability extends BaseResource {
|
|
|
35
43
|
/**
|
|
36
44
|
* Get Website Availability Status
|
|
37
45
|
*/
|
|
38
|
-
getWebsiteAvailabilityStatus(
|
|
46
|
+
getWebsiteAvailabilityStatus(
|
|
47
|
+
websiteID: string
|
|
48
|
+
): Promise<WebsiteAvailabilityStatus> {
|
|
39
49
|
return this.crisp.get(
|
|
40
|
-
this.crisp.prepareRestUrl([
|
|
50
|
+
this.crisp.prepareRestUrl([
|
|
51
|
+
"website", websiteID, "availability", "status"
|
|
52
|
+
])
|
|
41
53
|
);
|
|
42
54
|
};
|
|
43
55
|
|
|
44
56
|
/**
|
|
45
57
|
* List Website Operator Availabilities
|
|
46
58
|
*/
|
|
47
|
-
listWebsiteOperatorAvailabilities(
|
|
59
|
+
listWebsiteOperatorAvailabilities(
|
|
60
|
+
websiteID: string
|
|
61
|
+
): Promise<WebsiteAvailabilityOperator[]> {
|
|
48
62
|
return this.crisp.get(
|
|
49
|
-
this.crisp.prepareRestUrl([
|
|
63
|
+
this.crisp.prepareRestUrl([
|
|
64
|
+
"website", websiteID, "availability", "operators"
|
|
65
|
+
])
|
|
50
66
|
);
|
|
51
67
|
};
|
|
52
68
|
}
|
|
53
69
|
|
|
70
|
+
/**************************************************************************
|
|
71
|
+
* EXPORTS
|
|
72
|
+
***************************************************************************/
|
|
73
|
+
|
|
54
74
|
export default WebsiteAvailability;
|
|
@@ -12,7 +12,10 @@
|
|
|
12
12
|
// PROJECT: RESOURCES
|
|
13
13
|
import BaseResource from "./BaseResource";
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
/**************************************************************************
|
|
16
|
+
* TYPES
|
|
17
|
+
***************************************************************************/
|
|
18
|
+
|
|
16
19
|
type Website = {
|
|
17
20
|
website_id?: string;
|
|
18
21
|
name?: string;
|
|
@@ -37,6 +40,10 @@ export type WebsiteFilter = {
|
|
|
37
40
|
query?: Record<string, unknown>;
|
|
38
41
|
}
|
|
39
42
|
|
|
43
|
+
/**************************************************************************
|
|
44
|
+
* CLASSES
|
|
45
|
+
***************************************************************************/
|
|
46
|
+
|
|
40
47
|
/**
|
|
41
48
|
* Crisp WebsiteBase Resource
|
|
42
49
|
*/
|
|
@@ -62,7 +69,7 @@ class WebsiteBase extends BaseResource {
|
|
|
62
69
|
/**
|
|
63
70
|
* Create Website
|
|
64
71
|
*/
|
|
65
|
-
createWebsite(websiteData: WebsiteCreate)
|
|
72
|
+
createWebsite(websiteData: WebsiteCreate): Promise<Website> {
|
|
66
73
|
return this.crisp.post(
|
|
67
74
|
this.crisp.prepareRestUrl(["website"]), null, websiteData
|
|
68
75
|
);
|
|
@@ -76,7 +83,7 @@ class WebsiteBase extends BaseResource {
|
|
|
76
83
|
* @param {string} websiteID
|
|
77
84
|
* @return {Promise}
|
|
78
85
|
*/
|
|
79
|
-
getWebsite(websiteID: string)
|
|
86
|
+
getWebsite(websiteID: string): Promise<Website> {
|
|
80
87
|
return this.crisp.get(
|
|
81
88
|
this.crisp.prepareRestUrl(["website", websiteID])
|
|
82
89
|
);
|
|
@@ -105,4 +112,8 @@ class WebsiteBase extends BaseResource {
|
|
|
105
112
|
};
|
|
106
113
|
}
|
|
107
114
|
|
|
115
|
+
/**************************************************************************
|
|
116
|
+
* EXPORTS
|
|
117
|
+
***************************************************************************/
|
|
118
|
+
|
|
108
119
|
export default WebsiteBase;
|
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
// PROJECT: RESOURCES
|
|
13
13
|
import BaseResource from "./BaseResource";
|
|
14
14
|
|
|
15
|
+
/**************************************************************************
|
|
16
|
+
* TYPES
|
|
17
|
+
***************************************************************************/
|
|
18
|
+
|
|
15
19
|
type WebsiteBatchConversationsOperation = {
|
|
16
20
|
inbox_id?: string;
|
|
17
21
|
sessions?: string[];
|
|
@@ -22,6 +26,10 @@ type WebsiteBatchPeopleOperationInner = {
|
|
|
22
26
|
search?: string;
|
|
23
27
|
}
|
|
24
28
|
|
|
29
|
+
/**************************************************************************
|
|
30
|
+
* CLASSES
|
|
31
|
+
***************************************************************************/
|
|
32
|
+
|
|
25
33
|
/**
|
|
26
34
|
* Crisp WebsiteBatch Resource
|
|
27
35
|
*/
|
|
@@ -29,7 +37,9 @@ class WebsiteBatch extends BaseResource {
|
|
|
29
37
|
/**
|
|
30
38
|
* Batch Resolve Conversations
|
|
31
39
|
*/
|
|
32
|
-
batchResolveConversations(
|
|
40
|
+
batchResolveConversations(
|
|
41
|
+
websiteID: string, operation: WebsiteBatchConversationsOperation
|
|
42
|
+
) {
|
|
33
43
|
return this.crisp.patch(
|
|
34
44
|
this.crisp.prepareRestUrl(["website", websiteID, "batch", "resolve"]),
|
|
35
45
|
|
|
@@ -46,7 +56,9 @@ class WebsiteBatch extends BaseResource {
|
|
|
46
56
|
* @param {object} operation
|
|
47
57
|
* @return {Promise}
|
|
48
58
|
*/
|
|
49
|
-
batchReadConversations(
|
|
59
|
+
batchReadConversations(
|
|
60
|
+
websiteID: string, operation: WebsiteBatchConversationsOperation
|
|
61
|
+
) {
|
|
50
62
|
return this.crisp.patch(
|
|
51
63
|
this.crisp.prepareRestUrl(["website", websiteID, "batch", "read"]),
|
|
52
64
|
|
|
@@ -63,7 +75,9 @@ class WebsiteBatch extends BaseResource {
|
|
|
63
75
|
* @param {object} operation
|
|
64
76
|
* @return {Promise}
|
|
65
77
|
*/
|
|
66
|
-
batchRemoveConversations(
|
|
78
|
+
batchRemoveConversations(
|
|
79
|
+
websiteID: string, operation: WebsiteBatchConversationsOperation
|
|
80
|
+
) {
|
|
67
81
|
return this.crisp.patch(
|
|
68
82
|
this.crisp.prepareRestUrl(["website", websiteID, "batch", "remove"]),
|
|
69
83
|
|
|
@@ -80,7 +94,9 @@ class WebsiteBatch extends BaseResource {
|
|
|
80
94
|
* @param {object} people
|
|
81
95
|
* @return {Promise}
|
|
82
96
|
*/
|
|
83
|
-
batchRemovePeople(
|
|
97
|
+
batchRemovePeople(
|
|
98
|
+
websiteID: string, people: WebsiteBatchPeopleOperationInner
|
|
99
|
+
) {
|
|
84
100
|
return this.crisp.patch(
|
|
85
101
|
this.crisp.prepareRestUrl(["website", websiteID, "batch", "remove"]),
|
|
86
102
|
|
|
@@ -93,4 +109,8 @@ class WebsiteBatch extends BaseResource {
|
|
|
93
109
|
};
|
|
94
110
|
}
|
|
95
111
|
|
|
112
|
+
/**************************************************************************
|
|
113
|
+
* EXPORTS
|
|
114
|
+
***************************************************************************/
|
|
115
|
+
|
|
96
116
|
export default WebsiteBatch;
|
|
@@ -13,7 +13,10 @@
|
|
|
13
13
|
import BaseResource from "./BaseResource";
|
|
14
14
|
import { WebsiteFilter } from "./WebsiteBase";
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
/**************************************************************************
|
|
17
|
+
* TYPES
|
|
18
|
+
***************************************************************************/
|
|
19
|
+
|
|
17
20
|
type WebsiteCampaignExcerpt = {
|
|
18
21
|
campaign_id?: string;
|
|
19
22
|
type?: string;
|
|
@@ -62,7 +65,6 @@ type WebsiteCampaignItemSender = {
|
|
|
62
65
|
user_id?: string;
|
|
63
66
|
}
|
|
64
67
|
|
|
65
|
-
// WebsiteCampaignItemRecipients mapping
|
|
66
68
|
type WebsiteCampaignItemRecipients = {
|
|
67
69
|
type?: string;
|
|
68
70
|
segments?: string[];
|
|
@@ -135,6 +137,10 @@ type WebsiteCampaignStatisticProfilePersonGeolocationCoordinates = {
|
|
|
135
137
|
longitude?: number;
|
|
136
138
|
}
|
|
137
139
|
|
|
140
|
+
/**************************************************************************
|
|
141
|
+
* CLASSES
|
|
142
|
+
***************************************************************************/
|
|
143
|
+
|
|
138
144
|
/**
|
|
139
145
|
* Crisp WebsiteCampaign Resource
|
|
140
146
|
*/
|
|
@@ -142,7 +148,9 @@ class WebsiteCampaign extends BaseResource {
|
|
|
142
148
|
/**
|
|
143
149
|
* List Campaigns
|
|
144
150
|
*/
|
|
145
|
-
listCampaigns(
|
|
151
|
+
listCampaigns(
|
|
152
|
+
websiteID: string, pageNumber: number = 1
|
|
153
|
+
): Promise<WebsiteCampaignExcerpt[]> {
|
|
146
154
|
return this.crisp.get(
|
|
147
155
|
this.crisp.prepareRestUrl([
|
|
148
156
|
"website", websiteID, "campaigns", "list", String(pageNumber)
|
|
@@ -153,7 +161,7 @@ class WebsiteCampaign extends BaseResource {
|
|
|
153
161
|
/**
|
|
154
162
|
* List Campaign Tags
|
|
155
163
|
*/
|
|
156
|
-
listCampaignTags(websiteID: string)
|
|
164
|
+
listCampaignTags(websiteID: string): Promise<string[]> {
|
|
157
165
|
return this.crisp.get(
|
|
158
166
|
this.crisp.prepareRestUrl(["website", websiteID, "campaigns", "tags"])
|
|
159
167
|
);
|
|
@@ -162,7 +170,9 @@ class WebsiteCampaign extends BaseResource {
|
|
|
162
170
|
/**
|
|
163
171
|
* List Campaign Templates
|
|
164
172
|
*/
|
|
165
|
-
listCampaignTemplates(
|
|
173
|
+
listCampaignTemplates(
|
|
174
|
+
websiteID: string, pageNumber: number = 1
|
|
175
|
+
): Promise<WebsiteCampaignTemplateExcerpt[]> {
|
|
166
176
|
return this.crisp.get(
|
|
167
177
|
this.crisp.prepareRestUrl([
|
|
168
178
|
"website", websiteID, "campaigns", "templates", String(pageNumber)
|
|
@@ -173,7 +183,9 @@ class WebsiteCampaign extends BaseResource {
|
|
|
173
183
|
/**
|
|
174
184
|
* Create A New Campaign Template
|
|
175
185
|
*/
|
|
176
|
-
createNewCampaignTemplate(
|
|
186
|
+
createNewCampaignTemplate(
|
|
187
|
+
websiteID: string, templateFormat: string, templateName: string
|
|
188
|
+
): Promise<WebsiteCampaignTemplateNew> {
|
|
177
189
|
return this.crisp.post(
|
|
178
190
|
this.crisp.prepareRestUrl(["website", websiteID, "campaigns", "template"]),
|
|
179
191
|
|
|
@@ -200,7 +212,9 @@ class WebsiteCampaign extends BaseResource {
|
|
|
200
212
|
/**
|
|
201
213
|
* Get A Campaign Template
|
|
202
214
|
*/
|
|
203
|
-
getCampaignTemplate(
|
|
215
|
+
getCampaignTemplate(
|
|
216
|
+
websiteID: string, templateID: string
|
|
217
|
+
): Promise<WebsiteCampaignTemplateItem> {
|
|
204
218
|
return this.crisp.get(
|
|
205
219
|
this.crisp.prepareRestUrl([
|
|
206
220
|
"website", websiteID, "campaigns", "template", templateID
|
|
@@ -211,7 +225,9 @@ class WebsiteCampaign extends BaseResource {
|
|
|
211
225
|
/**
|
|
212
226
|
* Save A Campaign Template
|
|
213
227
|
*/
|
|
214
|
-
saveCampaignTemplate(
|
|
228
|
+
saveCampaignTemplate(
|
|
229
|
+
websiteID: string, templateID: string, template: WebsiteCampaignTemplateItem
|
|
230
|
+
) {
|
|
215
231
|
return this.crisp.put(
|
|
216
232
|
this.crisp.prepareRestUrl([
|
|
217
233
|
"website", websiteID, "campaigns", "template", templateID
|
|
@@ -224,7 +240,9 @@ class WebsiteCampaign extends BaseResource {
|
|
|
224
240
|
/**
|
|
225
241
|
* Update A Campaign Template
|
|
226
242
|
*/
|
|
227
|
-
updateCampaignTemplate(
|
|
243
|
+
updateCampaignTemplate(
|
|
244
|
+
websiteID: string, templateID: string, template: WebsiteCampaignTemplateItem
|
|
245
|
+
) {
|
|
228
246
|
return this.crisp.patch(
|
|
229
247
|
this.crisp.prepareRestUrl([
|
|
230
248
|
"website", websiteID, "campaigns", "template", templateID
|
|
@@ -248,7 +266,9 @@ class WebsiteCampaign extends BaseResource {
|
|
|
248
266
|
/**
|
|
249
267
|
* Create A New Campaign
|
|
250
268
|
*/
|
|
251
|
-
createNewCampaign(
|
|
269
|
+
createNewCampaign(
|
|
270
|
+
websiteID: string, campaignType: string, campaignName: string
|
|
271
|
+
) {
|
|
252
272
|
return this.crisp.post(
|
|
253
273
|
this.crisp.prepareRestUrl(["website", websiteID, "campaign"]),
|
|
254
274
|
|
|
@@ -273,7 +293,9 @@ class WebsiteCampaign extends BaseResource {
|
|
|
273
293
|
/**
|
|
274
294
|
* Get A Campaign
|
|
275
295
|
*/
|
|
276
|
-
getCampaign(
|
|
296
|
+
getCampaign(
|
|
297
|
+
websiteID: string, campaignID: string
|
|
298
|
+
): Promise<WebsiteCampaignItem> {
|
|
277
299
|
return this.crisp.get(
|
|
278
300
|
this.crisp.prepareRestUrl(["website", websiteID, "campaign", campaignID])
|
|
279
301
|
);
|
|
@@ -282,7 +304,9 @@ class WebsiteCampaign extends BaseResource {
|
|
|
282
304
|
/**
|
|
283
305
|
* Save A Campaign
|
|
284
306
|
*/
|
|
285
|
-
saveCampaign(
|
|
307
|
+
saveCampaign(
|
|
308
|
+
websiteID: string, campaignID: string, campaign: WebsiteCampaignItem
|
|
309
|
+
) {
|
|
286
310
|
return this.crisp.put(
|
|
287
311
|
this.crisp.prepareRestUrl(["website", websiteID, "campaign", campaignID]),
|
|
288
312
|
|
|
@@ -293,7 +317,9 @@ class WebsiteCampaign extends BaseResource {
|
|
|
293
317
|
/**
|
|
294
318
|
* Update A Campaign
|
|
295
319
|
*/
|
|
296
|
-
updateCampaign(
|
|
320
|
+
updateCampaign(
|
|
321
|
+
websiteID: string, campaignID: string, campaign: WebsiteCampaignItem
|
|
322
|
+
) {
|
|
297
323
|
return this.crisp.patch(
|
|
298
324
|
this.crisp.prepareRestUrl(["website", websiteID, "campaign", campaignID]),
|
|
299
325
|
|
|
@@ -370,10 +396,13 @@ class WebsiteCampaign extends BaseResource {
|
|
|
370
396
|
/**
|
|
371
397
|
* List Campaign Recipients
|
|
372
398
|
*/
|
|
373
|
-
listCampaignRecipients(
|
|
399
|
+
listCampaignRecipients(
|
|
400
|
+
websiteID: string, campaignID: string, pageNumber: number = 1
|
|
401
|
+
): Promise<WebsiteCampaignRecipient[]> {
|
|
374
402
|
return this.crisp.get(
|
|
375
403
|
this.crisp.prepareRestUrl([
|
|
376
|
-
"website", websiteID, "campaign", campaignID, "recipients",
|
|
404
|
+
"website", websiteID, "campaign", campaignID, "recipients",
|
|
405
|
+
String(pageNumber)
|
|
377
406
|
])
|
|
378
407
|
);
|
|
379
408
|
};
|
|
@@ -386,7 +415,7 @@ class WebsiteCampaign extends BaseResource {
|
|
|
386
415
|
campaignID: string,
|
|
387
416
|
action: string,
|
|
388
417
|
pageNumber: number = 1
|
|
389
|
-
)
|
|
418
|
+
): Promise<WebsiteCampaignStatistic[]> {
|
|
390
419
|
return this.crisp.get(
|
|
391
420
|
this.crisp.prepareRestUrl([
|
|
392
421
|
"website", websiteID, "campaign", campaignID, "statistics", action,
|
|
@@ -396,4 +425,8 @@ class WebsiteCampaign extends BaseResource {
|
|
|
396
425
|
};
|
|
397
426
|
}
|
|
398
427
|
|
|
428
|
+
/**************************************************************************
|
|
429
|
+
* EXPORTS
|
|
430
|
+
***************************************************************************/
|
|
431
|
+
|
|
399
432
|
export default WebsiteCampaign;
|