@unboundcx/sdk 4.13.120 → 4.13.122
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/README.md +0 -7
- package/index.js +4 -0
- package/package.json +1 -1
- package/services/messaging/EmailTemplatesService.js +10 -2
- package/services/messaging/SmsService.js +0 -3
- package/services/messaging.js +0 -2
- package/services/schedules/SchedulesService.js +232 -0
- package/services/schedules/TimeOffService.js +131 -0
- package/services/messaging/SmsTemplatesService.js +0 -125
package/README.md
CHANGED
|
@@ -297,13 +297,6 @@ await api.messaging.email.send({
|
|
|
297
297
|
htmlBody: '<h1>Hello World!</h1>',
|
|
298
298
|
});
|
|
299
299
|
|
|
300
|
-
// Templates
|
|
301
|
-
await api.messaging.sms.templates.create({
|
|
302
|
-
name: 'welcome',
|
|
303
|
-
message: 'Welcome {{name}}!',
|
|
304
|
-
variables: { name: 'string' },
|
|
305
|
-
});
|
|
306
|
-
|
|
307
300
|
// Campaign Management
|
|
308
301
|
await api.messaging.campaigns.tollFree.create({
|
|
309
302
|
companyName: 'Acme Corp',
|
package/index.js
CHANGED
|
@@ -23,6 +23,7 @@ import { DealRegistrationsService } from './services/dealRegistrations.js';
|
|
|
23
23
|
import { SipEndpointsService } from './services/sipEndpoints.js';
|
|
24
24
|
import { RingGroupsService } from './services/ringGroups.js';
|
|
25
25
|
import { LineGroupsService } from './services/lineGroups.js';
|
|
26
|
+
import { SchedulesService } from './services/schedules/SchedulesService.js';
|
|
26
27
|
import { EmergencyService } from './services/emergency.js';
|
|
27
28
|
import { WebchatService } from './services/webchat.js';
|
|
28
29
|
import { CobrowseService } from './services/cobrowse.js';
|
|
@@ -125,6 +126,7 @@ class UnboundSDK extends BaseSDK {
|
|
|
125
126
|
this.sipEndpoints = new SipEndpointsService(this);
|
|
126
127
|
this.ringGroups = new RingGroupsService(this);
|
|
127
128
|
this.lineGroups = new LineGroupsService(this);
|
|
129
|
+
this.schedules = new SchedulesService(this);
|
|
128
130
|
this.emergency = new EmergencyService(this);
|
|
129
131
|
this.webchat = new WebchatService(this);
|
|
130
132
|
this.cobrowse = new CobrowseService(this);
|
|
@@ -328,6 +330,8 @@ export { DealRegistrationsService } from './services/dealRegistrations.js';
|
|
|
328
330
|
export { SipEndpointsService } from './services/sipEndpoints.js';
|
|
329
331
|
export { RingGroupsService } from './services/ringGroups.js';
|
|
330
332
|
export { LineGroupsService } from './services/lineGroups.js';
|
|
333
|
+
export { SchedulesService } from './services/schedules/SchedulesService.js';
|
|
334
|
+
export { TimeOffService } from './services/schedules/TimeOffService.js';
|
|
331
335
|
export { EmergencyService } from './services/emergency.js';
|
|
332
336
|
export { WebchatService, WebchatWidgetsService } from './services/webchat.js';
|
|
333
337
|
export { CobrowseService, CobrowseVisitorService } from './services/cobrowse.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unboundcx/sdk",
|
|
3
|
-
"version": "4.13.
|
|
3
|
+
"version": "4.13.122",
|
|
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",
|
|
@@ -22,6 +22,7 @@ export class EmailTemplatesService {
|
|
|
22
22
|
* @param {string} [params.text] - Plain text template body
|
|
23
23
|
* @param {Object} [params.design] - Block-tree design JSON (compiled server-side)
|
|
24
24
|
* @param {string} [params.appearance] - `client` or `marketing` (immutable after create)
|
|
25
|
+
* @param {string} [params.emailType] - `marketing` | `sales` | `transactional` (defaults to `marketing`; separate from `appearance`)
|
|
25
26
|
* @param {boolean} [params.allowOneOff] - Usable as a one-off / compose send
|
|
26
27
|
* @param {boolean} [params.allowCampaign] - Usable in campaigns / journeys
|
|
27
28
|
* @param {string} [params.brandKitId] - Brand kit to apply
|
|
@@ -57,6 +58,7 @@ export class EmailTemplatesService {
|
|
|
57
58
|
variables,
|
|
58
59
|
design,
|
|
59
60
|
appearance,
|
|
61
|
+
emailType,
|
|
60
62
|
allowOneOff,
|
|
61
63
|
allowCampaign,
|
|
62
64
|
brandKitId,
|
|
@@ -72,6 +74,7 @@ export class EmailTemplatesService {
|
|
|
72
74
|
variables: { type: 'array', required: false },
|
|
73
75
|
design: { type: 'object', required: false },
|
|
74
76
|
appearance: { type: 'string', required: false },
|
|
77
|
+
emailType: { type: 'string', required: false },
|
|
75
78
|
allowOneOff: { type: 'boolean', required: false },
|
|
76
79
|
allowCampaign: { type: 'boolean', required: false },
|
|
77
80
|
brandKitId: { type: 'string', required: false },
|
|
@@ -88,6 +91,7 @@ export class EmailTemplatesService {
|
|
|
88
91
|
variables,
|
|
89
92
|
design,
|
|
90
93
|
appearance,
|
|
94
|
+
emailType,
|
|
91
95
|
allowOneOff,
|
|
92
96
|
allowCampaign,
|
|
93
97
|
brandKitId,
|
|
@@ -95,7 +99,7 @@ export class EmailTemplatesService {
|
|
|
95
99
|
}),
|
|
96
100
|
};
|
|
97
101
|
|
|
98
|
-
const result = await internalRequest(this.sdk,
|
|
102
|
+
const result = await internalRequest(this.sdk,
|
|
99
103
|
'/messaging/email/template',
|
|
100
104
|
'POST',
|
|
101
105
|
options,
|
|
@@ -114,6 +118,7 @@ export class EmailTemplatesService {
|
|
|
114
118
|
* @param {string} [params.text] - Plain text template body
|
|
115
119
|
* @param {Object} [params.design] - Block-tree design JSON (compiled server-side)
|
|
116
120
|
* @param {string} [params.appearance] - Usually omit; immutable after create
|
|
121
|
+
* @param {string} [params.emailType] - `marketing` | `sales` | `transactional` (not immutable)
|
|
117
122
|
* @param {boolean} [params.allowOneOff] - Usable as a one-off / compose send
|
|
118
123
|
* @param {boolean} [params.allowCampaign] - Usable in campaigns / journeys
|
|
119
124
|
* @param {string} [params.brandKitId] - Brand kit to apply
|
|
@@ -147,6 +152,7 @@ export class EmailTemplatesService {
|
|
|
147
152
|
variables,
|
|
148
153
|
design,
|
|
149
154
|
appearance,
|
|
155
|
+
emailType,
|
|
150
156
|
allowOneOff,
|
|
151
157
|
allowCampaign,
|
|
152
158
|
brandKitId,
|
|
@@ -164,6 +170,7 @@ export class EmailTemplatesService {
|
|
|
164
170
|
variables: { type: 'array', required: false },
|
|
165
171
|
design: { type: 'object', required: false },
|
|
166
172
|
appearance: { type: 'string', required: false },
|
|
173
|
+
emailType: { type: 'string', required: false },
|
|
167
174
|
allowOneOff: { type: 'boolean', required: false },
|
|
168
175
|
allowCampaign: { type: 'boolean', required: false },
|
|
169
176
|
brandKitId: { type: 'string', required: false },
|
|
@@ -180,6 +187,7 @@ export class EmailTemplatesService {
|
|
|
180
187
|
variables,
|
|
181
188
|
design,
|
|
182
189
|
appearance,
|
|
190
|
+
emailType,
|
|
183
191
|
allowOneOff,
|
|
184
192
|
allowCampaign,
|
|
185
193
|
brandKitId,
|
|
@@ -187,7 +195,7 @@ export class EmailTemplatesService {
|
|
|
187
195
|
}),
|
|
188
196
|
};
|
|
189
197
|
|
|
190
|
-
const result = await internalRequest(this.sdk,
|
|
198
|
+
const result = await internalRequest(this.sdk,
|
|
191
199
|
`/messaging/email/template/${id}`,
|
|
192
200
|
'PUT',
|
|
193
201
|
options,
|
package/services/messaging.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// Import all extracted services
|
|
2
2
|
import { MessagingService } from './messaging/MessagingService.js';
|
|
3
3
|
import { SmsService } from './messaging/SmsService.js';
|
|
4
|
-
import { SmsTemplatesService } from './messaging/SmsTemplatesService.js';
|
|
5
4
|
import { EmailService } from './messaging/EmailService.js';
|
|
6
5
|
import { EmailTemplatesService } from './messaging/EmailTemplatesService.js';
|
|
7
6
|
import { EmailDomainsService } from './messaging/EmailDomainsService.js';
|
|
@@ -20,7 +19,6 @@ import { EmailSuppressionService } from './messaging/EmailSuppressionService.js'
|
|
|
20
19
|
export {
|
|
21
20
|
MessagingService,
|
|
22
21
|
SmsService,
|
|
23
|
-
SmsTemplatesService,
|
|
24
22
|
EmailService,
|
|
25
23
|
EmailTemplatesService,
|
|
26
24
|
EmailDomainsService,
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { internalRequest } from '../../base.js';
|
|
2
|
+
import { TimeOffService } from './TimeOffService.js';
|
|
3
|
+
|
|
4
|
+
function pickDefined(fields) {
|
|
5
|
+
const body = {};
|
|
6
|
+
for (const [key, value] of Object.entries(fields)) {
|
|
7
|
+
if (value !== undefined) body[key] = value;
|
|
8
|
+
}
|
|
9
|
+
return body;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Resolve/open query params a caller may pass to narrow which schedule is
|
|
13
|
+
// evaluated: a specific scheduleId (ignores assignment resolution), or a
|
|
14
|
+
// queueId/userId to resolve via assignments (journeys-plan.md §5).
|
|
15
|
+
function resolveQuery({ queueId, userId, scheduleId } = {}) {
|
|
16
|
+
return pickDefined({ queueId, userId, scheduleId });
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Schedules (working hours, closures, assignments, time off) --
|
|
21
|
+
* journeys-plan.md §5. CRUD, assignments, holiday sets, time off, and the
|
|
22
|
+
* resolve/isOpen/nextOpen/simulate endpoints that evaluate a resolved
|
|
23
|
+
* schedule. `sdk.schedules.*`.
|
|
24
|
+
*
|
|
25
|
+
* @see app1-api src/services/schedules/routes.js
|
|
26
|
+
*/
|
|
27
|
+
export class SchedulesService {
|
|
28
|
+
constructor(sdk) {
|
|
29
|
+
this.sdk = sdk;
|
|
30
|
+
this.timeOff = new TimeOffService(sdk);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @returns {Promise<Array>} Schedules (summary rows, no nested windows/closures)
|
|
35
|
+
*/
|
|
36
|
+
async list() {
|
|
37
|
+
return await internalRequest(this.sdk, '/schedules', 'GET', {});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @param {string} id
|
|
42
|
+
* @returns {Promise<Object>} Schedule with nested windows, closures, usedBy
|
|
43
|
+
*/
|
|
44
|
+
async get(id) {
|
|
45
|
+
this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
|
|
46
|
+
return await internalRequest(this.sdk, `/schedules/${id}`, 'GET', {});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @param {Object} body
|
|
51
|
+
* @param {string} body.name
|
|
52
|
+
* @param {string} [body.timezone]
|
|
53
|
+
* @param {boolean} [body.isAccountDefault]
|
|
54
|
+
* @param {Array<Object>} [body.windows] - {dayOfWeek, startTime, endTime}
|
|
55
|
+
* @param {Array<Object>} [body.closures] - {name, kind, config, partialDay?}
|
|
56
|
+
* @returns {Promise<Object>} Created schedule (with nested windows/closures)
|
|
57
|
+
*/
|
|
58
|
+
async create(body) {
|
|
59
|
+
this.sdk.validateParams(
|
|
60
|
+
{ name: body?.name },
|
|
61
|
+
{ name: { type: 'string', required: true } },
|
|
62
|
+
);
|
|
63
|
+
return await internalRequest(this.sdk, '/schedules', 'POST', {
|
|
64
|
+
body: pickDefined(body),
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Full replace-on-update: passing `windows`/`closures` replaces the
|
|
70
|
+
* schedule's entire set (not a merge/patch of individual rows).
|
|
71
|
+
*
|
|
72
|
+
* @param {string} id
|
|
73
|
+
* @param {Object} body - name?, timezone?, isAccountDefault?, windows?, closures?
|
|
74
|
+
* @returns {Promise<Object>} Updated schedule
|
|
75
|
+
*/
|
|
76
|
+
async update(id, body) {
|
|
77
|
+
this.sdk.validateParams(
|
|
78
|
+
{ id, body },
|
|
79
|
+
{
|
|
80
|
+
id: { type: 'string', required: true },
|
|
81
|
+
body: { type: 'object', required: true },
|
|
82
|
+
},
|
|
83
|
+
);
|
|
84
|
+
return await internalRequest(this.sdk, `/schedules/${id}`, 'PATCH', {
|
|
85
|
+
body: pickDefined(body),
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @param {string} id
|
|
91
|
+
* @returns {Promise<Object>} { id, deleted: true } -- 409s while assigned
|
|
92
|
+
*/
|
|
93
|
+
async remove(id) {
|
|
94
|
+
this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
|
|
95
|
+
return await internalRequest(this.sdk, `/schedules/${id}`, 'DELETE', {});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Set (replace) the one active assignment for a target. A target has at
|
|
100
|
+
* most one schedule at a time.
|
|
101
|
+
*
|
|
102
|
+
* @param {string} id - Schedule id
|
|
103
|
+
* @param {Object} params
|
|
104
|
+
* @param {'account'|'group'|'queue'|'user'} params.targetType
|
|
105
|
+
* @param {string} [params.targetId] - Required unless targetType is 'account'
|
|
106
|
+
* @returns {Promise<Object>} The assignment row
|
|
107
|
+
*/
|
|
108
|
+
async setAssignment(id, { targetType, targetId } = {}) {
|
|
109
|
+
this.sdk.validateParams(
|
|
110
|
+
{ id, targetType },
|
|
111
|
+
{
|
|
112
|
+
id: { type: 'string', required: true },
|
|
113
|
+
targetType: { type: 'string', required: true },
|
|
114
|
+
},
|
|
115
|
+
);
|
|
116
|
+
return await internalRequest(
|
|
117
|
+
this.sdk,
|
|
118
|
+
`/schedules/${id}/assignments`,
|
|
119
|
+
'POST',
|
|
120
|
+
{ body: pickDefined({ targetType, targetId }) },
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* @param {string} id - Schedule id
|
|
126
|
+
* @param {string} assignmentId
|
|
127
|
+
* @returns {Promise<Object>} { id, deleted: true }
|
|
128
|
+
*/
|
|
129
|
+
async clearAssignment(id, assignmentId) {
|
|
130
|
+
this.sdk.validateParams(
|
|
131
|
+
{ id, assignmentId },
|
|
132
|
+
{
|
|
133
|
+
id: { type: 'string', required: true },
|
|
134
|
+
assignmentId: { type: 'string', required: true },
|
|
135
|
+
},
|
|
136
|
+
);
|
|
137
|
+
return await internalRequest(
|
|
138
|
+
this.sdk,
|
|
139
|
+
`/schedules/${id}/assignments/${assignmentId}`,
|
|
140
|
+
'DELETE',
|
|
141
|
+
{},
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Every live assignment pointing at this schedule (account/group/queue/user).
|
|
147
|
+
*
|
|
148
|
+
* @param {string} id
|
|
149
|
+
* @returns {Promise<Array>} Assignment rows
|
|
150
|
+
*/
|
|
151
|
+
async usedBy(id) {
|
|
152
|
+
this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
|
|
153
|
+
return await internalRequest(this.sdk, `/schedules/${id}/usedBy`, 'GET', {});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* @returns {Promise<Array>} Holiday sets, one row per {country, key}
|
|
158
|
+
*/
|
|
159
|
+
async listHolidaySets() {
|
|
160
|
+
return await internalRequest(this.sdk, '/schedules/holidaySets', 'GET', {});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Resolve the effective schedule for a target: user assignment -> queue
|
|
165
|
+
* assignment -> account default, with additive closures. Pass
|
|
166
|
+
* `scheduleId` to resolve a specific schedule directly (ignores
|
|
167
|
+
* assignment resolution; used by "simulate" against the schedule being
|
|
168
|
+
* edited).
|
|
169
|
+
*
|
|
170
|
+
* @param {Object} [params]
|
|
171
|
+
* @param {string} [params.queueId]
|
|
172
|
+
* @param {string} [params.userId]
|
|
173
|
+
* @param {string} [params.scheduleId]
|
|
174
|
+
* @returns {Promise<Object>} Resolved schedule { timezone, windows, closures, source, flagged }
|
|
175
|
+
*/
|
|
176
|
+
async resolve(params = {}) {
|
|
177
|
+
return await internalRequest(this.sdk, '/schedules/resolve', 'GET', {
|
|
178
|
+
query: resolveQuery(params),
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* @param {Object} [params]
|
|
184
|
+
* @param {string} [params.queueId]
|
|
185
|
+
* @param {string} [params.userId]
|
|
186
|
+
* @param {string} [params.scheduleId]
|
|
187
|
+
* @param {string} [params.at] - ISO datetime; defaults to now
|
|
188
|
+
* @returns {Promise<Object>} { open, flagged }
|
|
189
|
+
*/
|
|
190
|
+
async isOpen(params = {}) {
|
|
191
|
+
const { at, ...rest } = params;
|
|
192
|
+
return await internalRequest(this.sdk, '/schedules/isOpen', 'GET', {
|
|
193
|
+
query: pickDefined({ ...resolveQuery(rest), at }),
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* @param {Object} [params]
|
|
199
|
+
* @param {string} [params.queueId]
|
|
200
|
+
* @param {string} [params.userId]
|
|
201
|
+
* @param {string} [params.scheduleId]
|
|
202
|
+
* @param {string} [params.at] - ISO datetime; defaults to now
|
|
203
|
+
* @returns {Promise<Object>} { nextOpen, flagged }
|
|
204
|
+
*/
|
|
205
|
+
async nextOpen(params = {}) {
|
|
206
|
+
const { at, ...rest } = params;
|
|
207
|
+
return await internalRequest(this.sdk, '/schedules/nextOpen', 'GET', {
|
|
208
|
+
query: pickDefined({ ...resolveQuery(rest), at }),
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Simulate a resolved schedule: open/nextOpen at a point in time, plus
|
|
214
|
+
* optional addBusinessTime (pass `amount`+`unit`) and/or an `open` check
|
|
215
|
+
* across a `range` of ISO timestamps.
|
|
216
|
+
*
|
|
217
|
+
* @param {Object} [body]
|
|
218
|
+
* @param {string} [body.queueId]
|
|
219
|
+
* @param {string} [body.userId]
|
|
220
|
+
* @param {string} [body.scheduleId]
|
|
221
|
+
* @param {string} [body.at] - ISO datetime; defaults to now
|
|
222
|
+
* @param {number} [body.amount]
|
|
223
|
+
* @param {'minutes'|'hours'|'days'} [body.unit]
|
|
224
|
+
* @param {string[]} [body.range] - ISO datetimes to check open/closed for
|
|
225
|
+
* @returns {Promise<Object>} { resolved, open, nextOpen, addBusinessTime?, range? }
|
|
226
|
+
*/
|
|
227
|
+
async simulate(body = {}) {
|
|
228
|
+
return await internalRequest(this.sdk, '/schedules/simulate', 'POST', {
|
|
229
|
+
body: pickDefined(body),
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
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
|
+
* userTimeOff CRUD -- self + manager-for-direct-reports.
|
|
13
|
+
* `sdk.schedules.timeOff.*` (journeys-plan.md §5).
|
|
14
|
+
*
|
|
15
|
+
* @see app1-api src/services/schedules/controllers/timeOff.js
|
|
16
|
+
*/
|
|
17
|
+
export class TimeOffService {
|
|
18
|
+
constructor(sdk) {
|
|
19
|
+
this.sdk = sdk;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* List time off rows. Omit `userId` for your own rows; pass it to look
|
|
24
|
+
* up a direct report's (manager-only, 403 otherwise).
|
|
25
|
+
*
|
|
26
|
+
* @param {Object} [params]
|
|
27
|
+
* @param {string} [params.userId]
|
|
28
|
+
* @returns {Promise<Array>} Time off rows
|
|
29
|
+
*/
|
|
30
|
+
async list(params = {}) {
|
|
31
|
+
const { userId } = params;
|
|
32
|
+
const query = userId ? { userId } : {};
|
|
33
|
+
return await internalRequest(this.sdk, '/schedules/timeOff', 'GET', {
|
|
34
|
+
query,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Manager "Team time off" view -- every active direct report's rows.
|
|
40
|
+
*
|
|
41
|
+
* @returns {Promise<Array>} Time off rows for all direct reports
|
|
42
|
+
*/
|
|
43
|
+
async listTeam() {
|
|
44
|
+
return await internalRequest(
|
|
45
|
+
this.sdk,
|
|
46
|
+
'/schedules/timeOff/team',
|
|
47
|
+
'GET',
|
|
48
|
+
{},
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Create a time off row. `userId` defaults to the caller; a manager may
|
|
54
|
+
* pass a direct report's userId.
|
|
55
|
+
*
|
|
56
|
+
* @param {Object} body
|
|
57
|
+
* @param {string} [body.userId]
|
|
58
|
+
* @param {string} body.startAt
|
|
59
|
+
* @param {string} body.endAt
|
|
60
|
+
* @param {string} [body.kind] - vacation|sick|other (default vacation)
|
|
61
|
+
* @param {string} [body.note]
|
|
62
|
+
* @param {string} [body.backupUserId]
|
|
63
|
+
* @returns {Promise<Object>} Created row
|
|
64
|
+
*/
|
|
65
|
+
async create(body) {
|
|
66
|
+
this.sdk.validateParams(
|
|
67
|
+
{ startAt: body?.startAt, endAt: body?.endAt },
|
|
68
|
+
{
|
|
69
|
+
startAt: { type: 'string', required: true },
|
|
70
|
+
endAt: { type: 'string', required: true },
|
|
71
|
+
},
|
|
72
|
+
);
|
|
73
|
+
return await internalRequest(this.sdk, '/schedules/timeOff', 'POST', {
|
|
74
|
+
body: pickDefined(body),
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @param {string} id
|
|
80
|
+
* @param {Object} body - startAt?, endAt?, kind?, note?, backupUserId?
|
|
81
|
+
* @returns {Promise<Object>} Updated row
|
|
82
|
+
*/
|
|
83
|
+
async update(id, body) {
|
|
84
|
+
this.sdk.validateParams(
|
|
85
|
+
{ id, body },
|
|
86
|
+
{
|
|
87
|
+
id: { type: 'string', required: true },
|
|
88
|
+
body: { type: 'object', required: true },
|
|
89
|
+
},
|
|
90
|
+
);
|
|
91
|
+
return await internalRequest(
|
|
92
|
+
this.sdk,
|
|
93
|
+
`/schedules/timeOff/${id}`,
|
|
94
|
+
'PATCH',
|
|
95
|
+
{ body: pickDefined(body) },
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @param {string} id
|
|
101
|
+
* @returns {Promise<Object>} { id, deleted: true }
|
|
102
|
+
*/
|
|
103
|
+
async remove(id) {
|
|
104
|
+
this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
|
|
105
|
+
return await internalRequest(
|
|
106
|
+
this.sdk,
|
|
107
|
+
`/schedules/timeOff/${id}`,
|
|
108
|
+
'DELETE',
|
|
109
|
+
{},
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* @param {string} userId
|
|
115
|
+
* @param {string} [at] - ISO datetime; defaults to now server-side
|
|
116
|
+
* @returns {Promise<Object>} { away: boolean }
|
|
117
|
+
*/
|
|
118
|
+
async isUserAway(userId, at) {
|
|
119
|
+
this.sdk.validateParams(
|
|
120
|
+
{ userId },
|
|
121
|
+
{ userId: { type: 'string', required: true } },
|
|
122
|
+
);
|
|
123
|
+
const query = at ? { userId, at } : { userId };
|
|
124
|
+
return await internalRequest(
|
|
125
|
+
this.sdk,
|
|
126
|
+
'/schedules/timeOff/isUserAway',
|
|
127
|
+
'GET',
|
|
128
|
+
{ query },
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { internalRequest } from '../../base.js';
|
|
2
|
-
export class SmsTemplatesService {
|
|
3
|
-
constructor(sdk) {
|
|
4
|
-
this.sdk = sdk;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Create SMS template
|
|
9
|
-
* @param {Object} params - Template parameters
|
|
10
|
-
* @param {string} params.name - Template name (required)
|
|
11
|
-
* @param {string} params.message - Template message (required)
|
|
12
|
-
* @param {Object} [params.variables] - Template variables
|
|
13
|
-
* @returns {Promise<Object>} Created template details
|
|
14
|
-
*/
|
|
15
|
-
async create({ name, message, variables }) {
|
|
16
|
-
this.sdk.validateParams(
|
|
17
|
-
{ name, message },
|
|
18
|
-
{
|
|
19
|
-
name: { type: 'string', required: true },
|
|
20
|
-
message: { type: 'string', required: true },
|
|
21
|
-
variables: { type: 'object', required: false },
|
|
22
|
-
},
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
const templateData = { name, message };
|
|
26
|
-
if (variables) templateData.variables = variables;
|
|
27
|
-
|
|
28
|
-
const options = {
|
|
29
|
-
body: templateData,
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const result = await internalRequest(this.sdk,
|
|
33
|
-
'/messaging/sms/templates',
|
|
34
|
-
'POST',
|
|
35
|
-
options,
|
|
36
|
-
);
|
|
37
|
-
return result;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Update SMS template
|
|
42
|
-
* @param {string} id - Template ID
|
|
43
|
-
* @param {Object} params - Update parameters
|
|
44
|
-
* @param {string} [params.name] - Template name
|
|
45
|
-
* @param {string} [params.message] - Template message
|
|
46
|
-
* @param {Object} [params.variables] - Template variables
|
|
47
|
-
* @returns {Promise<Object>} Updated template details
|
|
48
|
-
*/
|
|
49
|
-
async update(id, { name, message, variables }) {
|
|
50
|
-
this.sdk.validateParams(
|
|
51
|
-
{ id },
|
|
52
|
-
{
|
|
53
|
-
id: { type: 'string', required: true },
|
|
54
|
-
name: { type: 'string', required: false },
|
|
55
|
-
message: { type: 'string', required: false },
|
|
56
|
-
variables: { type: 'object', required: false },
|
|
57
|
-
},
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
const updateData = {};
|
|
61
|
-
if (name) updateData.name = name;
|
|
62
|
-
if (message) updateData.message = message;
|
|
63
|
-
if (variables) updateData.variables = variables;
|
|
64
|
-
|
|
65
|
-
const options = {
|
|
66
|
-
body: updateData,
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const result = await internalRequest(this.sdk,
|
|
70
|
-
`/messaging/sms/templates/${id}`,
|
|
71
|
-
'PUT',
|
|
72
|
-
options,
|
|
73
|
-
);
|
|
74
|
-
return result;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Delete SMS template
|
|
79
|
-
* @param {string} id - Template ID
|
|
80
|
-
* @returns {Promise<Object>} Deletion result
|
|
81
|
-
*/
|
|
82
|
-
async delete(id) {
|
|
83
|
-
this.sdk.validateParams(
|
|
84
|
-
{ id },
|
|
85
|
-
{
|
|
86
|
-
id: { type: 'string', required: true },
|
|
87
|
-
},
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
const result = await internalRequest(this.sdk,
|
|
91
|
-
`/messaging/sms/templates/${id}`,
|
|
92
|
-
'DELETE',
|
|
93
|
-
);
|
|
94
|
-
return result;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Get SMS template by ID
|
|
99
|
-
* @param {string} id - Template ID
|
|
100
|
-
* @returns {Promise<Object>} Template details
|
|
101
|
-
*/
|
|
102
|
-
async get(id) {
|
|
103
|
-
this.sdk.validateParams(
|
|
104
|
-
{ id },
|
|
105
|
-
{
|
|
106
|
-
id: { type: 'string', required: true },
|
|
107
|
-
},
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
const result = await internalRequest(this.sdk,
|
|
111
|
-
`/messaging/sms/templates/${id}`,
|
|
112
|
-
'GET',
|
|
113
|
-
);
|
|
114
|
-
return result;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* List all SMS templates
|
|
119
|
-
* @returns {Promise<Array>} List of templates
|
|
120
|
-
*/
|
|
121
|
-
async list() {
|
|
122
|
-
const result = await internalRequest(this.sdk, '/messaging/sms/templates', 'GET');
|
|
123
|
-
return result;
|
|
124
|
-
}
|
|
125
|
-
}
|