@unboundcx/sdk 4.13.128 → 4.13.130
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/index.js +1 -0
- package/package.json +1 -1
- package/services/journeys/JourneyGoalsService.js +57 -0
- package/services/journeys/JourneyMembersService.js +55 -2
- package/services/journeys/JourneyTypesService.js +53 -0
- package/services/journeys/JourneyWorklistService.js +74 -0
- package/services/journeys/JourneysService.js +115 -109
package/index.js
CHANGED
|
@@ -339,6 +339,7 @@ export { TimeOffService } from './services/schedules/TimeOffService.js';
|
|
|
339
339
|
export { JourneysService } from './services/journeys/JourneysService.js';
|
|
340
340
|
export { JourneyMembersService } from './services/journeys/JourneyMembersService.js';
|
|
341
341
|
export { JourneyDraftService } from './services/journeys/JourneysService.js';
|
|
342
|
+
export { JourneyWorklistService } from './services/journeys/JourneyWorklistService.js';
|
|
342
343
|
export { WorkflowTemplatesService } from './services/workflowTemplates/WorkflowTemplatesService.js';
|
|
343
344
|
export { EmergencyService } from './services/emergency.js';
|
|
344
345
|
export { WebchatService, WebchatWidgetsService } from './services/webchat.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unboundcx/sdk",
|
|
3
|
-
"version": "4.13.
|
|
3
|
+
"version": "4.13.130",
|
|
4
4
|
"description": "Official JavaScript SDK for the Unbound API - A comprehensive toolkit for integrating with Unbound's communication, AI, and data management services",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { internalRequest } from '../../base.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* `sdk.journeys.goals.*` -- journeyGoals generic-object CRUD (no `get`;
|
|
5
|
+
* goals are listed/edited inline on the journey, matching the plan's CRUD
|
|
6
|
+
* surface for this object).
|
|
7
|
+
*/
|
|
8
|
+
export class JourneyGoalsService {
|
|
9
|
+
constructor(sdk) {
|
|
10
|
+
this.sdk = sdk;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {Object} [opts] - sdk.objects.query opts; pass `where: { journeyId }` to scope
|
|
15
|
+
* @returns {Promise<Object>} Query result
|
|
16
|
+
*/
|
|
17
|
+
async list(opts = {}) {
|
|
18
|
+
return await this.sdk.objects.query({ object: 'journeyGoals', ...opts });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @param {Object} body
|
|
23
|
+
* @param {string} body.journeyId
|
|
24
|
+
* @param {string} body.goalType
|
|
25
|
+
* @returns {Promise<Object>} Created journeyGoal
|
|
26
|
+
*/
|
|
27
|
+
async create(body) {
|
|
28
|
+
this.sdk.validateParams(
|
|
29
|
+
{ journeyId: body?.journeyId, goalType: body?.goalType },
|
|
30
|
+
{
|
|
31
|
+
journeyId: { type: 'string', required: true },
|
|
32
|
+
goalType: { type: 'string', required: true },
|
|
33
|
+
},
|
|
34
|
+
);
|
|
35
|
+
return await this.sdk.objects.create({ object: 'journeyGoals', body });
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async update(id, update) {
|
|
39
|
+
this.sdk.validateParams(
|
|
40
|
+
{ id, update },
|
|
41
|
+
{
|
|
42
|
+
id: { type: 'string', required: true },
|
|
43
|
+
update: { type: 'object', required: true },
|
|
44
|
+
},
|
|
45
|
+
);
|
|
46
|
+
return await this.sdk.objects.updateById({
|
|
47
|
+
object: 'journeyGoals',
|
|
48
|
+
id,
|
|
49
|
+
update,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async remove(id) {
|
|
54
|
+
this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
|
|
55
|
+
return await this.sdk.objects.deleteById({ object: 'journeyGoals', id });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -55,6 +55,29 @@ export class JourneyMembersService {
|
|
|
55
55
|
);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
/**
|
|
59
|
+
* URL for the CSV export of the members grid (P6) — same filter / sort
|
|
60
|
+
* params as `list`. The browser downloads it directly (cookie auth); Node
|
|
61
|
+
* callers fetch it with their own token.
|
|
62
|
+
*
|
|
63
|
+
* @param {string} journeyId
|
|
64
|
+
* @param {Object} [opts] same keys as `list` (status, stepKey, ownerUserId, statusReason, search, sort, sortDir)
|
|
65
|
+
* @returns {string} absolute URL
|
|
66
|
+
*/
|
|
67
|
+
exportCsvUrl(journeyId, opts = {}) {
|
|
68
|
+
this.sdk.validateParams(
|
|
69
|
+
{ journeyId },
|
|
70
|
+
{ journeyId: { type: 'string', required: true } },
|
|
71
|
+
);
|
|
72
|
+
const { status, ...rest } = opts;
|
|
73
|
+
const query = pickDefined({
|
|
74
|
+
...rest,
|
|
75
|
+
status: Array.isArray(status) ? status.join(',') : status,
|
|
76
|
+
});
|
|
77
|
+
const qs = new URLSearchParams(query).toString();
|
|
78
|
+
return `${this.sdk.baseURL}/journeys/${journeyId}/members/export.csv${qs ? `?${qs}` : ''}`;
|
|
79
|
+
}
|
|
80
|
+
|
|
58
81
|
/**
|
|
59
82
|
* @param {string} journeyId
|
|
60
83
|
* @param {string} memberId
|
|
@@ -114,9 +137,12 @@ export class JourneyMembersService {
|
|
|
114
137
|
* @param {Object} body
|
|
115
138
|
* @param {'pause'|'resume'|'remove'|'reassign'|'changeChannel'} body.action
|
|
116
139
|
* @param {string[]} [body.ids] - Either ids or filter is required
|
|
117
|
-
* @param {Object} [body.filter]
|
|
140
|
+
* @param {Object} [body.filter] - e.g. `{ ownerUserId }` to target every
|
|
141
|
+
* member currently owned by one rep (P5 "reassign-all-owned-by" is this
|
|
142
|
+
* `action:'reassign'` + `filter:{ownerUserId}` combination -- no
|
|
143
|
+
* dedicated endpoint/method was added).
|
|
118
144
|
* @param {string} [body.reason]
|
|
119
|
-
* @param {string} [body.ownerUserId]
|
|
145
|
+
* @param {string} [body.ownerUserId] - New owner for `action:'reassign'`
|
|
120
146
|
* @param {Object} [body.channels]
|
|
121
147
|
* @returns {Promise<Object>} { results }
|
|
122
148
|
*/
|
|
@@ -186,4 +212,31 @@ export class JourneyMembersService {
|
|
|
186
212
|
{},
|
|
187
213
|
);
|
|
188
214
|
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Context-aware AI draft for a human touch-task step (record, step
|
|
218
|
+
* intent, prior conversation) -- journeys-plan.md §9 P5. Not the final
|
|
219
|
+
* send content; the rep edits/sends from the task itself.
|
|
220
|
+
*
|
|
221
|
+
* @param {string} memberId
|
|
222
|
+
* @param {Object} body
|
|
223
|
+
* @param {string} [body.stepKey]
|
|
224
|
+
* @param {'email'|'sms'} body.channel
|
|
225
|
+
* @returns {Promise<{data: {draft: string, channel: string, stepKey: string}}>}
|
|
226
|
+
*/
|
|
227
|
+
async draft(memberId, body = {}) {
|
|
228
|
+
this.sdk.validateParams(
|
|
229
|
+
{ memberId, channel: body?.channel },
|
|
230
|
+
{
|
|
231
|
+
memberId: { type: 'string', required: true },
|
|
232
|
+
channel: { type: 'string', required: true },
|
|
233
|
+
},
|
|
234
|
+
);
|
|
235
|
+
return await internalRequest(
|
|
236
|
+
this.sdk,
|
|
237
|
+
`/journeys/members/${memberId}/draft`,
|
|
238
|
+
'POST',
|
|
239
|
+
{ body: pickDefined(body) },
|
|
240
|
+
);
|
|
241
|
+
}
|
|
189
242
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { internalRequest } from '../../base.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* `sdk.journeys.types.*` -- journeyTypes generic-object CRUD. `queueId`
|
|
5
|
+
* stays empty until P5.
|
|
6
|
+
*/
|
|
7
|
+
export class JourneyTypesService {
|
|
8
|
+
constructor(sdk) {
|
|
9
|
+
this.sdk = sdk;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async list(opts = {}) {
|
|
13
|
+
return await this.sdk.objects.query({ object: 'journeyTypes', ...opts });
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async get(id) {
|
|
17
|
+
this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
|
|
18
|
+
return await this.sdk.objects.byId({ id });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @param {Object} body
|
|
23
|
+
* @param {string} body.name
|
|
24
|
+
* @returns {Promise<Object>} Created journeyType
|
|
25
|
+
*/
|
|
26
|
+
async create(body) {
|
|
27
|
+
this.sdk.validateParams(
|
|
28
|
+
{ name: body?.name },
|
|
29
|
+
{ name: { type: 'string', required: true } },
|
|
30
|
+
);
|
|
31
|
+
return await this.sdk.objects.create({ object: 'journeyTypes', body });
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async update(id, update) {
|
|
35
|
+
this.sdk.validateParams(
|
|
36
|
+
{ id, update },
|
|
37
|
+
{
|
|
38
|
+
id: { type: 'string', required: true },
|
|
39
|
+
update: { type: 'object', required: true },
|
|
40
|
+
},
|
|
41
|
+
);
|
|
42
|
+
return await this.sdk.objects.updateById({
|
|
43
|
+
object: 'journeyTypes',
|
|
44
|
+
id,
|
|
45
|
+
update,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async remove(id) {
|
|
50
|
+
this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
|
|
51
|
+
return await this.sdk.objects.deleteById({ object: 'journeyTypes', id });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { internalRequest } from '../../base.js';
|
|
2
|
+
|
|
3
|
+
function pickDefined(fields) {
|
|
4
|
+
const body = {};
|
|
5
|
+
for (const [key, value] of Object.entries(fields)) {
|
|
6
|
+
if (value !== undefined) body[key] = value;
|
|
7
|
+
}
|
|
8
|
+
return body;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @typedef {Object} JourneyWorklistTask
|
|
13
|
+
* @property {string} id
|
|
14
|
+
* @property {'journey'} type
|
|
15
|
+
* @property {'worklist'} deliveryMode
|
|
16
|
+
* @property {string|null} dueAt
|
|
17
|
+
* @property {string} journeyMemberId
|
|
18
|
+
* @property {string} journeyId
|
|
19
|
+
* @property {string} journeyStepKey
|
|
20
|
+
* @property {'email'|'sms'|'call'|'other'} journeyStepChannel
|
|
21
|
+
* @property {string|null} preferredWorkerId - Owner, or null for a pool task
|
|
22
|
+
* @property {string|null} engagementSessionId
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Sales work list -- `sdk.journeys.worklist.*` (journeys-plan.md §9, P5).
|
|
27
|
+
* Cross-journey view of a sales rep's (or the pool's) open touch tasks
|
|
28
|
+
* (`tasks.type='journey'`), plus upcoming members from
|
|
29
|
+
* `journeyMembers.nextActionAt`. Requires `users_acct.salesEnabled` for
|
|
30
|
+
* `takeNext` (`list` stays open to ordinary object-read permission, per
|
|
31
|
+
* the P5 contract).
|
|
32
|
+
*
|
|
33
|
+
* @see app1-api src/services/journeys/controllers/worklist.js
|
|
34
|
+
*/
|
|
35
|
+
export class JourneyWorklistService {
|
|
36
|
+
constructor(sdk) {
|
|
37
|
+
this.sdk = sdk;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @param {Object} [opts]
|
|
42
|
+
* @param {'due'|'overdue'|'upcoming'} [opts.bucket]
|
|
43
|
+
* @param {string} [opts.stepType]
|
|
44
|
+
* @param {string} [opts.journeyId]
|
|
45
|
+
* @param {number} [opts.page]
|
|
46
|
+
* @param {number} [opts.pageSize]
|
|
47
|
+
* @returns {Promise<{data: JourneyWorklistTask[]}>}
|
|
48
|
+
*/
|
|
49
|
+
async list(opts = {}) {
|
|
50
|
+
return await internalRequest(this.sdk, '/journeys/worklist', 'GET', {
|
|
51
|
+
query: pickDefined(opts),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Takes the next due task for the caller (owner-or-pool), via the same
|
|
57
|
+
* `transitionTask` path as a manual take (`PUT /tasks/:id
|
|
58
|
+
* {status:'connected', workerId}`) -- not a separate silent-assign path.
|
|
59
|
+
*
|
|
60
|
+
* @param {Object} [filter]
|
|
61
|
+
* @param {string} [filter.stepType]
|
|
62
|
+
* @param {string} [filter.journeyId]
|
|
63
|
+
* @param {string} [filter.taskId] take this exact task (validated server-side: worklist, pending, owner-or-pool)
|
|
64
|
+
* @returns {Promise<{data: JourneyWorklistTask|null}>} null when nothing is due
|
|
65
|
+
*/
|
|
66
|
+
async takeNext(filter = {}) {
|
|
67
|
+
return await internalRequest(
|
|
68
|
+
this.sdk,
|
|
69
|
+
'/journeys/worklist/take-next',
|
|
70
|
+
'POST',
|
|
71
|
+
{ body: pickDefined(filter) },
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { internalRequest } from '../../base.js';
|
|
2
2
|
import { JourneyMembersService } from './JourneyMembersService.js';
|
|
3
3
|
import { JourneyDraftService } from './JourneyDraftService.js';
|
|
4
|
+
import { JourneyWorklistService } from './JourneyWorklistService.js';
|
|
5
|
+
import { JourneyTypesService } from './JourneyTypesService.js';
|
|
6
|
+
import { JourneyGoalsService } from './JourneyGoalsService.js';
|
|
4
7
|
|
|
5
8
|
function pickDefined(fields) {
|
|
6
9
|
const body = {};
|
|
@@ -22,6 +25,30 @@ function pickDefined(fields) {
|
|
|
22
25
|
* and the member-grid/enrol/action/fix/events/stats endpoints are custom
|
|
23
26
|
* routes under `/journeys/`, covered by `members` and `stats`.
|
|
24
27
|
*
|
|
28
|
+
* P5 (journeys-plan.md §8, sales queues + human steps) added fields to
|
|
29
|
+
* several generic objects rather than new endpoints -- no dedicated SDK
|
|
30
|
+
* service exists for these, so they are documented here instead:
|
|
31
|
+
* - `sdk.objects` object `'queues'`: `queueType` ('support'|'sales',
|
|
32
|
+
* default 'support'), `deliveryMode` ('push'|'worklist', default
|
|
33
|
+
* 'push'). A sales queue is auto-created with a journey type
|
|
34
|
+
* (`queueType:'sales', deliveryMode:'worklist'`) and its id is set on
|
|
35
|
+
* `journeyTypes.queueId`.
|
|
36
|
+
* - `sdk.objects` object `'queueDispositions'`: `outcome`
|
|
37
|
+
* ('positive'|'neutral'|'negative'|null), `countsAsConversion`
|
|
38
|
+
* (boolean), `flagsBadContact` (boolean) -- drive a journey member's
|
|
39
|
+
* `converted` / `needsAttention:badContact` transitions when a touch
|
|
40
|
+
* task is given that disposition.
|
|
41
|
+
* - `sdk.objects` object `'users'` (`users_acct`): `salesEnabled`
|
|
42
|
+
* (boolean, default false) -- required (alongside normal object
|
|
43
|
+
* permissions) for journeys build/enrol/member-action/worklist-take
|
|
44
|
+
* endpoints; member-grid reads stay open to object-read permission.
|
|
45
|
+
* - Task rows (`sdk.taskRouter.task.*`, `sdk.journeys.worklist.*`) gain
|
|
46
|
+
* `deliveryMode` ('push'|'worklist'), `dueAt` (ISO datetime|null),
|
|
47
|
+
* `journeyMemberId`, `journeyId`, `journeyStepKey`, `journeyStepChannel`
|
|
48
|
+
* ('email'|'sms'|'call'|'other') on a journey touch task
|
|
49
|
+
* (`type:'journey'`). See `JourneyWorklistService`'s
|
|
50
|
+
* `JourneyWorklistTask` typedef for the full shape.
|
|
51
|
+
*
|
|
25
52
|
* @see app1-api src/services/journeys/routes.js
|
|
26
53
|
*/
|
|
27
54
|
export class JourneysService {
|
|
@@ -31,6 +58,7 @@ export class JourneysService {
|
|
|
31
58
|
this.types = new JourneyTypesService(sdk);
|
|
32
59
|
this.goals = new JourneyGoalsService(sdk);
|
|
33
60
|
this.draft = new JourneyDraftService(sdk);
|
|
61
|
+
this.worklist = new JourneyWorklistService(sdk);
|
|
34
62
|
}
|
|
35
63
|
|
|
36
64
|
/**
|
|
@@ -114,6 +142,87 @@ export class JourneysService {
|
|
|
114
142
|
);
|
|
115
143
|
}
|
|
116
144
|
|
|
145
|
+
/**
|
|
146
|
+
* Per-step funnel (journeys-plan.md §9, P6): entered / outcome split /
|
|
147
|
+
* conversions from journeyMemberEvents. Test members are excluded.
|
|
148
|
+
*
|
|
149
|
+
* @param {string} journeyId
|
|
150
|
+
* @returns {Promise<Object>} { steps: [{ stepKey, type, title, entered, outcomes, conversions }] }
|
|
151
|
+
*/
|
|
152
|
+
async funnel(journeyId) {
|
|
153
|
+
this.sdk.validateParams(
|
|
154
|
+
{ journeyId },
|
|
155
|
+
{ journeyId: { type: 'string', required: true } },
|
|
156
|
+
);
|
|
157
|
+
return await internalRequest(
|
|
158
|
+
this.sdk,
|
|
159
|
+
`/journeys/${journeyId}/funnel`,
|
|
160
|
+
'GET',
|
|
161
|
+
{},
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Journey-level metrics (P6): enrolled, active, needsAttention, repliedPct,
|
|
167
|
+
* convertedPct, bounced, optedOut, timeToConvertMedianSeconds, byStatus.
|
|
168
|
+
*
|
|
169
|
+
* @param {string} journeyId
|
|
170
|
+
* @returns {Promise<Object>}
|
|
171
|
+
*/
|
|
172
|
+
async metrics(journeyId) {
|
|
173
|
+
this.sdk.validateParams(
|
|
174
|
+
{ journeyId },
|
|
175
|
+
{ journeyId: { type: 'string', required: true } },
|
|
176
|
+
);
|
|
177
|
+
return await internalRequest(
|
|
178
|
+
this.sdk,
|
|
179
|
+
`/journeys/${journeyId}/metrics`,
|
|
180
|
+
'GET',
|
|
181
|
+
{},
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Journey-wide activity feed (P6): journeyMemberEvents, newest first.
|
|
187
|
+
*
|
|
188
|
+
* @param {string} journeyId
|
|
189
|
+
* @param {Object} [opts]
|
|
190
|
+
* @param {string} [opts.stepKey]
|
|
191
|
+
* @param {string} [opts.memberId]
|
|
192
|
+
* @param {number} [opts.page]
|
|
193
|
+
* @param {number} [opts.pageSize]
|
|
194
|
+
* @returns {Promise<Object>} { rows, total }
|
|
195
|
+
*/
|
|
196
|
+
async events(journeyId, opts = {}) {
|
|
197
|
+
this.sdk.validateParams(
|
|
198
|
+
{ journeyId },
|
|
199
|
+
{ journeyId: { type: 'string', required: true } },
|
|
200
|
+
);
|
|
201
|
+
return await internalRequest(
|
|
202
|
+
this.sdk,
|
|
203
|
+
`/journeys/${journeyId}/events`,
|
|
204
|
+
'GET',
|
|
205
|
+
{ query: pickDefined(opts) },
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Rep metrics (P6): per owner — due, overdue, doneOnTime,
|
|
211
|
+
* timeToActionMedianSeconds — from touch tasks. Requires salesEnabled.
|
|
212
|
+
*
|
|
213
|
+
* @param {Object} [opts]
|
|
214
|
+
* @param {string} [opts.journeyTypeId]
|
|
215
|
+
* @param {string} [opts.journeyId]
|
|
216
|
+
* @param {string} [opts.from] ISO date-time
|
|
217
|
+
* @param {string} [opts.to] ISO date-time
|
|
218
|
+
* @returns {Promise<Object>} { reps: [{ userId, due, overdue, doneOnTime, timeToActionMedianSeconds }] }
|
|
219
|
+
*/
|
|
220
|
+
async repsMetrics(opts = {}) {
|
|
221
|
+
return await internalRequest(this.sdk, '/journeys/reps/metrics', 'GET', {
|
|
222
|
+
query: pickDefined(opts),
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
|
|
117
226
|
/**
|
|
118
227
|
* No-send dry run: per step, the resolved channel (override -> primary),
|
|
119
228
|
* rendered message, and landing date for a given person (journeys-plan.md
|
|
@@ -204,112 +313,9 @@ export class JourneysService {
|
|
|
204
313
|
}
|
|
205
314
|
}
|
|
206
315
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
this.sdk = sdk;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
async list(opts = {}) {
|
|
217
|
-
return await this.sdk.objects.query({ object: 'journeyTypes', ...opts });
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
async get(id) {
|
|
221
|
-
this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
|
|
222
|
-
return await this.sdk.objects.byId({ id });
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* @param {Object} body
|
|
227
|
-
* @param {string} body.name
|
|
228
|
-
* @returns {Promise<Object>} Created journeyType
|
|
229
|
-
*/
|
|
230
|
-
async create(body) {
|
|
231
|
-
this.sdk.validateParams(
|
|
232
|
-
{ name: body?.name },
|
|
233
|
-
{ name: { type: 'string', required: true } },
|
|
234
|
-
);
|
|
235
|
-
return await this.sdk.objects.create({ object: 'journeyTypes', body });
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
async update(id, update) {
|
|
239
|
-
this.sdk.validateParams(
|
|
240
|
-
{ id, update },
|
|
241
|
-
{
|
|
242
|
-
id: { type: 'string', required: true },
|
|
243
|
-
update: { type: 'object', required: true },
|
|
244
|
-
},
|
|
245
|
-
);
|
|
246
|
-
return await this.sdk.objects.updateById({
|
|
247
|
-
object: 'journeyTypes',
|
|
248
|
-
id,
|
|
249
|
-
update,
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
async remove(id) {
|
|
254
|
-
this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
|
|
255
|
-
return await this.sdk.objects.deleteById({ object: 'journeyTypes', id });
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* `sdk.journeys.goals.*` -- journeyGoals generic-object CRUD (no `get`;
|
|
261
|
-
* goals are listed/edited inline on the journey, matching the plan's CRUD
|
|
262
|
-
* surface for this object).
|
|
263
|
-
*/
|
|
264
|
-
class JourneyGoalsService {
|
|
265
|
-
constructor(sdk) {
|
|
266
|
-
this.sdk = sdk;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
* @param {Object} [opts] - sdk.objects.query opts; pass `where: { journeyId }` to scope
|
|
271
|
-
* @returns {Promise<Object>} Query result
|
|
272
|
-
*/
|
|
273
|
-
async list(opts = {}) {
|
|
274
|
-
return await this.sdk.objects.query({ object: 'journeyGoals', ...opts });
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* @param {Object} body
|
|
279
|
-
* @param {string} body.journeyId
|
|
280
|
-
* @param {string} body.goalType
|
|
281
|
-
* @returns {Promise<Object>} Created journeyGoal
|
|
282
|
-
*/
|
|
283
|
-
async create(body) {
|
|
284
|
-
this.sdk.validateParams(
|
|
285
|
-
{ journeyId: body?.journeyId, goalType: body?.goalType },
|
|
286
|
-
{
|
|
287
|
-
journeyId: { type: 'string', required: true },
|
|
288
|
-
goalType: { type: 'string', required: true },
|
|
289
|
-
},
|
|
290
|
-
);
|
|
291
|
-
return await this.sdk.objects.create({ object: 'journeyGoals', body });
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
async update(id, update) {
|
|
295
|
-
this.sdk.validateParams(
|
|
296
|
-
{ id, update },
|
|
297
|
-
{
|
|
298
|
-
id: { type: 'string', required: true },
|
|
299
|
-
update: { type: 'object', required: true },
|
|
300
|
-
},
|
|
301
|
-
);
|
|
302
|
-
return await this.sdk.objects.updateById({
|
|
303
|
-
object: 'journeyGoals',
|
|
304
|
-
id,
|
|
305
|
-
update,
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
async remove(id) {
|
|
310
|
-
this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
|
|
311
|
-
return await this.sdk.objects.deleteById({ object: 'journeyGoals', id });
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
export { JourneyTypesService, JourneyGoalsService, JourneyDraftService };
|
|
316
|
+
export {
|
|
317
|
+
JourneyTypesService,
|
|
318
|
+
JourneyGoalsService,
|
|
319
|
+
JourneyDraftService,
|
|
320
|
+
JourneyWorklistService,
|
|
321
|
+
};
|