@wats/graph 0.3.26 → 0.3.27
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 +1 -1
- package/dist/endpoints/businessManagement.d.ts +372 -1
- package/dist/endpoints/businessManagement.js +775 -5
- package/dist/endpoints/calling.d.ts +41 -1
- package/dist/endpoints/calling.js +100 -2
- package/dist/endpoints/flows/dataChannel.d.ts +139 -0
- package/dist/endpoints/flows/dataChannel.js +252 -0
- package/dist/endpoints/flows/flowDsl.d.ts +306 -0
- package/dist/endpoints/flows/flowDsl.js +610 -0
- package/dist/endpoints/flows/flowMediaUpload.d.ts +102 -0
- package/dist/endpoints/flows/flowMediaUpload.js +188 -0
- package/dist/endpoints/flows/index.d.ts +9 -1
- package/dist/endpoints/flows/index.js +70 -0
- package/dist/endpoints/flows/metricsMigration.d.ts +36 -0
- package/dist/endpoints/flows/metricsMigration.js +207 -0
- package/dist/endpoints/flows/types.d.ts +145 -0
- package/dist/endpoints/flows/types.js +14 -0
- package/dist/endpoints/flows.d.ts +2 -2
- package/dist/endpoints/flows.js +49 -1
- package/dist/endpoints/messages/builders-interactive.d.ts +9 -1
- package/dist/endpoints/messages/builders-interactive.js +49 -0
- package/dist/endpoints/messages/builders-template.d.ts +2 -1
- package/dist/endpoints/messages/builders-template.js +53 -2
- package/dist/endpoints/messages/deepLinks.d.ts +12 -0
- package/dist/endpoints/messages/deepLinks.js +38 -0
- package/dist/endpoints/messages/index.d.ts +4 -3
- package/dist/endpoints/messages/index.js +13 -2
- package/dist/endpoints/messages/types.d.ts +26 -3
- package/dist/endpoints/messages/validation.d.ts +7 -0
- package/dist/endpoints/messages/validation.js +12 -0
- package/dist/endpoints/oauth.d.ts +57 -0
- package/dist/endpoints/oauth.js +116 -0
- package/dist/endpoints/templates/advanced.d.ts +280 -0
- package/dist/endpoints/templates/advanced.js +519 -0
- package/dist/endpoints/templates/builders.js +21 -1
- package/dist/endpoints/templates/index.d.ts +2 -0
- package/dist/endpoints/templates/index.js +15 -0
- package/dist/endpoints/templates/shared.js +7 -1
- package/dist/endpoints/templates/types.d.ts +17 -2
- package/dist/endpoints/templates.d.ts +2 -1
- package/dist/endpoints/templates.js +14 -1
- package/dist/endpoints/wabaEndpoints.d.ts +4 -4
- package/dist/endpoints/wabaEndpoints.js +56 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/nodeMedia.d.ts +57 -0
- package/dist/nodeMedia.js +178 -0
- package/dist/subclients/phoneNumberClient.d.ts +92 -2
- package/dist/subclients/phoneNumberClient.js +133 -1
- package/dist/subclients/wabaClient.d.ts +82 -2
- package/dist/subclients/wabaClient.js +102 -2
- package/package.json +9 -11
|
@@ -23,6 +23,7 @@ const MAX_RECIPIENT_DIGITS = 15;
|
|
|
23
23
|
const MAX_DISPLAY_NAME_LENGTH = 128;
|
|
24
24
|
const MAX_OBA_TEXT_LENGTH = 2048;
|
|
25
25
|
const MAX_OBA_URL_LENGTH = 2048;
|
|
26
|
+
const MAX_CALLBACK_VERIFY_TOKEN_LENGTH = 256;
|
|
26
27
|
const MAX_OBA_SUPPORTING_LINKS = 10;
|
|
27
28
|
const MIN_OBA_SUPPORTING_LINKS = 5;
|
|
28
29
|
const MAX_BUSINESS_PROFILE_TEXT_LENGTH = 1024;
|
|
@@ -30,6 +31,9 @@ const MAX_BUSINESS_PROFILE_EMAIL_LENGTH = 320;
|
|
|
30
31
|
const MAX_BUSINESS_PROFILE_WEBSITES = 2;
|
|
31
32
|
const MAX_BUSINESS_PROFILE_WEBSITE_LENGTH = 2048;
|
|
32
33
|
const MAX_PROFILE_PICTURE_HANDLE_LENGTH = 1024;
|
|
34
|
+
const MAX_QR_PREFILLED_MESSAGE_LENGTH = 140;
|
|
35
|
+
const MAX_QR_CODE_LENGTH = 512;
|
|
36
|
+
const QR_IMAGE_FORMAT_VALUES = new Set(["SVG", "PNG"]);
|
|
33
37
|
function validationError(message, cause) {
|
|
34
38
|
return new GraphRequestValidationError(message, cause);
|
|
35
39
|
}
|
|
@@ -163,6 +167,108 @@ function assertBoundedPlainString(value, fieldName, helperName, maxLength) {
|
|
|
163
167
|
const out = assertQueryString(value, fieldName, helperName, maxLength);
|
|
164
168
|
return out;
|
|
165
169
|
}
|
|
170
|
+
const CODE_METHOD_VALUES = new Set(["SMS", "VOICE"]);
|
|
171
|
+
function assertCodeMethod(value, helperName) {
|
|
172
|
+
const str = assertQueryString(value, "codeMethod", helperName, 16).toUpperCase();
|
|
173
|
+
if (!CODE_METHOD_VALUES.has(str)) {
|
|
174
|
+
throw validationError(`Invalid ${helperName} input: codeMethod must be one of SMS, VOICE.`);
|
|
175
|
+
}
|
|
176
|
+
return str;
|
|
177
|
+
}
|
|
178
|
+
function assertLanguage(value, helperName) {
|
|
179
|
+
const str = assertQueryString(value, "language", helperName, 8).toLowerCase();
|
|
180
|
+
if (!/^[a-z]{2}$/u.test(str)) {
|
|
181
|
+
throw validationError(`Invalid ${helperName} input: language must be a 2-letter language code.`);
|
|
182
|
+
}
|
|
183
|
+
return str;
|
|
184
|
+
}
|
|
185
|
+
function assertVerificationCode(value, helperName) {
|
|
186
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
187
|
+
throw validationError(`Invalid ${helperName} input: code must be a non-empty string.`);
|
|
188
|
+
}
|
|
189
|
+
for (let index = 0;index < value.length; index += 1) {
|
|
190
|
+
const code = value.charCodeAt(index);
|
|
191
|
+
if (code < 32 || code === 127) {
|
|
192
|
+
throw validationError(`Invalid ${helperName} input: code must not contain control characters.`);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
if (!/^\d{1,32}$/u.test(value)) {
|
|
196
|
+
throw validationError(`Invalid ${helperName} input: code must be 1-32 digits.`);
|
|
197
|
+
}
|
|
198
|
+
return value;
|
|
199
|
+
}
|
|
200
|
+
function assertCountryCode(value, helperName) {
|
|
201
|
+
const str = assertQueryString(value, "countryCode", helperName, 6);
|
|
202
|
+
if (!/^\d{1,6}$/u.test(str)) {
|
|
203
|
+
throw validationError(`Invalid ${helperName} input: countryCode must be 1-6 digits.`);
|
|
204
|
+
}
|
|
205
|
+
return str;
|
|
206
|
+
}
|
|
207
|
+
function assertNationalPhoneNumber(value, helperName) {
|
|
208
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
209
|
+
throw validationError(`Invalid ${helperName} input: phoneNumber must be a non-empty digits string.`);
|
|
210
|
+
}
|
|
211
|
+
for (let index = 0;index < value.length; index += 1) {
|
|
212
|
+
const code = value.charCodeAt(index);
|
|
213
|
+
if (code < 32 || code === 127) {
|
|
214
|
+
throw validationError(`Invalid ${helperName} input: phoneNumber must not contain control characters.`);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (!/^\d{1,15}$/u.test(value)) {
|
|
218
|
+
throw validationError(`Invalid ${helperName} input: phoneNumber must be 1-15 digits.`);
|
|
219
|
+
}
|
|
220
|
+
return value;
|
|
221
|
+
}
|
|
222
|
+
function assertPin(value, helperName) {
|
|
223
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
224
|
+
throw validationError(`Invalid ${helperName} input: pin must be a non-empty string.`);
|
|
225
|
+
}
|
|
226
|
+
for (let index = 0;index < value.length; index += 1) {
|
|
227
|
+
const code = value.charCodeAt(index);
|
|
228
|
+
if (code < 32 || code === 127) {
|
|
229
|
+
throw validationError(`Invalid ${helperName} input: pin must not contain control characters.`);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (!/^\d{6}$/u.test(value)) {
|
|
233
|
+
throw validationError(`Invalid ${helperName} input: pin must be exactly 6 digits.`);
|
|
234
|
+
}
|
|
235
|
+
return value;
|
|
236
|
+
}
|
|
237
|
+
function assertDataLocalizationRegion(value, helperName) {
|
|
238
|
+
const str = assertBoundedPlainString(value, "dataLocalizationRegion", helperName, 2).toUpperCase();
|
|
239
|
+
if (!/^[A-Z]{2}$/u.test(str)) {
|
|
240
|
+
throw validationError(`Invalid ${helperName} input: dataLocalizationRegion must be an ISO 3166-1 alpha-2 country code.`);
|
|
241
|
+
}
|
|
242
|
+
return str;
|
|
243
|
+
}
|
|
244
|
+
function assertQrCodeId(value, helperName) {
|
|
245
|
+
if (typeof value === "string" && value.length > 0 && value.trim().length === 0) {
|
|
246
|
+
throw validationError(`Invalid ${helperName} input: code must be non-empty.`);
|
|
247
|
+
}
|
|
248
|
+
return assertRepeatedlyDecodedSafePathId(value, {
|
|
249
|
+
helperName,
|
|
250
|
+
fieldName: "code",
|
|
251
|
+
maxLength: MAX_QR_CODE_LENGTH,
|
|
252
|
+
maxDecodeRounds: MAX_PERCENT_DECODE_ROUNDS
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
function assertQrPrefilledMessage(value, helperName) {
|
|
256
|
+
const str = assertBoundedPlainString(value, "prefilledMessage", helperName, MAX_QR_PREFILLED_MESSAGE_LENGTH);
|
|
257
|
+
if (str.length === 0) {
|
|
258
|
+
throw validationError(`Invalid ${helperName} input: prefilledMessage must be a non-empty string.`);
|
|
259
|
+
}
|
|
260
|
+
return str;
|
|
261
|
+
}
|
|
262
|
+
function assertQrImageFormat(value, helperName) {
|
|
263
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
264
|
+
throw validationError(`Invalid ${helperName} input: generateQrImage must be one of SVG, PNG.`);
|
|
265
|
+
}
|
|
266
|
+
const upper = value.toUpperCase();
|
|
267
|
+
if (!QR_IMAGE_FORMAT_VALUES.has(upper)) {
|
|
268
|
+
throw validationError(`Invalid ${helperName} input: generateQrImage must be one of SVG, PNG.`);
|
|
269
|
+
}
|
|
270
|
+
return upper;
|
|
271
|
+
}
|
|
166
272
|
function assertHttpUrl(value, fieldName, helperName) {
|
|
167
273
|
const raw = assertBoundedPlainString(value, fieldName, helperName, MAX_OBA_URL_LENGTH);
|
|
168
274
|
let parsed;
|
|
@@ -176,6 +282,29 @@ function assertHttpUrl(value, fieldName, helperName) {
|
|
|
176
282
|
}
|
|
177
283
|
return raw;
|
|
178
284
|
}
|
|
285
|
+
function assertHttpsCallbackUrl(value, helperName) {
|
|
286
|
+
const raw = assertHttpUrl(value, "overrideCallbackUri", helperName);
|
|
287
|
+
const parsed = new URL(raw);
|
|
288
|
+
if (parsed.protocol !== "https:") {
|
|
289
|
+
throw validationError(`Invalid ${helperName} input: overrideCallbackUri must be an https URL.`);
|
|
290
|
+
}
|
|
291
|
+
return raw;
|
|
292
|
+
}
|
|
293
|
+
function assertCallbackVerifyToken(value, helperName) {
|
|
294
|
+
if (typeof value !== "string" || value.length === 0 || value.trim().length === 0) {
|
|
295
|
+
throw validationError(`Invalid ${helperName} input: verifyToken must be a non-empty string.`);
|
|
296
|
+
}
|
|
297
|
+
for (let index = 0;index < value.length; index += 1) {
|
|
298
|
+
const code = value.charCodeAt(index);
|
|
299
|
+
if (code < 32 || code === 127) {
|
|
300
|
+
throw validationError(`Invalid ${helperName} input: verifyToken must not contain control characters.`);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
if (value.length > MAX_CALLBACK_VERIFY_TOKEN_LENGTH) {
|
|
304
|
+
throw validationError(`Invalid ${helperName} input: verifyToken length must not exceed ${MAX_CALLBACK_VERIFY_TOKEN_LENGTH}.`);
|
|
305
|
+
}
|
|
306
|
+
return value;
|
|
307
|
+
}
|
|
179
308
|
function optionalBoundedString(record, key, helperName) {
|
|
180
309
|
const value = ownDataValue(record, key, helperName, false);
|
|
181
310
|
if (value === undefined)
|
|
@@ -220,6 +349,189 @@ function sanitizeStorageConfiguration(value, helperName) {
|
|
|
220
349
|
}
|
|
221
350
|
return out;
|
|
222
351
|
}
|
|
352
|
+
const MAX_SIP_SERVERS = 3;
|
|
353
|
+
const MAX_WEEKLY_OPERATING_HOURS_PER_DAY = 2;
|
|
354
|
+
const MAX_HOLIDAY_SCHEDULE_ENTRIES = 20;
|
|
355
|
+
const MAX_RESTRICT_COUNTRIES = 64;
|
|
356
|
+
const MAX_URI_USER_PARAM_KEYS = 32;
|
|
357
|
+
const MAX_HOSTNAME_LENGTH = 253;
|
|
358
|
+
const MAX_TIMEZONE_LENGTH = 64;
|
|
359
|
+
const MAX_PORT = 65535;
|
|
360
|
+
const CALLING_STATUS_VALUES = new Set(["ENABLED", "DISABLED"]);
|
|
361
|
+
const CALL_ICON_VISIBILITY_VALUES = new Set(["DEFAULT", "DISABLE_ALL"]);
|
|
362
|
+
const DAY_OF_WEEK_VALUES = new Set(["MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY", "SUNDAY"]);
|
|
363
|
+
const HHMM_PATTERN = /^([01]\d|2[0-3])[0-5]\d$/u;
|
|
364
|
+
const DATE_PATTERN = /^\d{4}-\d{2}-\d{2}$/u;
|
|
365
|
+
function assertCallingEnum(value, allowed, fieldName, helperName) {
|
|
366
|
+
const str = assertQueryString(value, fieldName, helperName, 64).toUpperCase();
|
|
367
|
+
if (!allowed.has(str)) {
|
|
368
|
+
throw validationError(`Invalid ${helperName} input: ${fieldName} must be one of ${[...allowed].join(", ")}.`);
|
|
369
|
+
}
|
|
370
|
+
return str;
|
|
371
|
+
}
|
|
372
|
+
function assertHhmm(value, fieldName, helperName) {
|
|
373
|
+
const str = assertQueryString(value, fieldName, helperName, 4);
|
|
374
|
+
if (!HHMM_PATTERN.test(str)) {
|
|
375
|
+
throw validationError(`Invalid ${helperName} input: ${fieldName} must be a 24h "HHMM" string.`);
|
|
376
|
+
}
|
|
377
|
+
return str;
|
|
378
|
+
}
|
|
379
|
+
function assertPort(value, fieldName, helperName) {
|
|
380
|
+
if (typeof value !== "number" || !Number.isInteger(value) || value < 0 || value > MAX_PORT) {
|
|
381
|
+
throw validationError(`Invalid ${helperName} input: ${fieldName} must be an integer between 0 and ${MAX_PORT}.`);
|
|
382
|
+
}
|
|
383
|
+
return value;
|
|
384
|
+
}
|
|
385
|
+
function sanitizeCallingArray(value, path, helperName, maxLength) {
|
|
386
|
+
return assertDenseDataArray(value, {
|
|
387
|
+
helperName,
|
|
388
|
+
path,
|
|
389
|
+
maxLength,
|
|
390
|
+
invalidTypeMessage: `Invalid ${helperName} input: ${path} must be an array.`,
|
|
391
|
+
invalidLengthMessage: `Invalid ${helperName} input: ${path} must contain at most ${maxLength} entries.`,
|
|
392
|
+
sparseArrayMessage: `Invalid ${helperName} input: ${path} must not contain sparse array holes.`,
|
|
393
|
+
unsafePrototypeKeyMessage: `Invalid ${helperName} input: ${path} contains an unsafe prototype key.`,
|
|
394
|
+
unsupportedPropertyMessage: `Invalid ${helperName} input: ${path} contains unsupported properties.`
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
function sanitizeRequestUriUserParams(value, path, helperName) {
|
|
398
|
+
const record = assertPlainRecord(value, helperName, path);
|
|
399
|
+
const out = {};
|
|
400
|
+
const keys = Object.keys(record);
|
|
401
|
+
if (keys.length > MAX_URI_USER_PARAM_KEYS) {
|
|
402
|
+
throw validationError(`Invalid ${helperName} input: ${path} must contain at most ${MAX_URI_USER_PARAM_KEYS} keys.`);
|
|
403
|
+
}
|
|
404
|
+
for (const key of keys) {
|
|
405
|
+
const nested = ownDataValue(record, key, helperName, false);
|
|
406
|
+
out[key] = assertQueryString(nested, `${path}.${key}`, helperName, 256);
|
|
407
|
+
}
|
|
408
|
+
return out;
|
|
409
|
+
}
|
|
410
|
+
function sanitizeSipServer(value, path, helperName) {
|
|
411
|
+
const record = assertPlainRecord(value, helperName, path);
|
|
412
|
+
const out = {
|
|
413
|
+
hostname: assertQueryString(ownDataValue(record, "hostname", helperName, true), `${path}.hostname`, helperName, MAX_HOSTNAME_LENGTH)
|
|
414
|
+
};
|
|
415
|
+
const port = ownDataValue(record, "port", helperName, false);
|
|
416
|
+
if (port !== undefined)
|
|
417
|
+
out.port = assertPort(port, `${path}.port`, helperName);
|
|
418
|
+
const requestUriUserParams = ownDataValue(record, "requestUriUserParams", helperName, false);
|
|
419
|
+
if (requestUriUserParams !== undefined) {
|
|
420
|
+
out.request_uri_user_params = sanitizeRequestUriUserParams(requestUriUserParams, `${path}.requestUriUserParams`, helperName);
|
|
421
|
+
}
|
|
422
|
+
return out;
|
|
423
|
+
}
|
|
424
|
+
function sanitizeSip(value, helperName) {
|
|
425
|
+
const path = "calling.sip";
|
|
426
|
+
const record = assertPlainRecord(value, helperName, "calling.sip");
|
|
427
|
+
const out = {};
|
|
428
|
+
const status = ownDataValue(record, "status", helperName, false);
|
|
429
|
+
if (status !== undefined)
|
|
430
|
+
out.status = assertCallingEnum(status, CALLING_STATUS_VALUES, "calling.sip.status", helperName);
|
|
431
|
+
const servers = ownDataValue(record, "servers", helperName, false);
|
|
432
|
+
if (servers !== undefined) {
|
|
433
|
+
const items = sanitizeCallingArray(servers, "calling.sip.servers", helperName, MAX_SIP_SERVERS);
|
|
434
|
+
out.servers = items.map((item, index) => sanitizeSipServer(item, `calling.sip.servers[${index}]`, helperName));
|
|
435
|
+
}
|
|
436
|
+
return out;
|
|
437
|
+
}
|
|
438
|
+
function sanitizeWeeklyOperatingHours(value, helperName) {
|
|
439
|
+
const path = "calling.callHours.weeklyOperatingHours";
|
|
440
|
+
const items = assertDenseDataArray(value, {
|
|
441
|
+
helperName,
|
|
442
|
+
path: "calling.callHours.weeklyOperatingHours",
|
|
443
|
+
invalidTypeMessage: `Invalid ${helperName} input: calling.callHours.weeklyOperatingHours must be an array.`,
|
|
444
|
+
sparseArrayMessage: `Invalid ${helperName} input: calling.callHours.weeklyOperatingHours must not contain sparse array holes.`,
|
|
445
|
+
unsafePrototypeKeyMessage: `Invalid ${helperName} input: calling.callHours.weeklyOperatingHours contains an unsafe prototype key.`,
|
|
446
|
+
unsupportedPropertyMessage: `Invalid ${helperName} input: calling.callHours.weeklyOperatingHours contains unsupported properties.`
|
|
447
|
+
});
|
|
448
|
+
const perDay = new Map;
|
|
449
|
+
return items.map((item, index) => {
|
|
450
|
+
const entryPath = `calling.callHours.weeklyOperatingHours[${index}]`;
|
|
451
|
+
const record = assertPlainRecord(item, helperName, entryPath);
|
|
452
|
+
const day = assertCallingEnum(ownDataValue(record, "dayOfWeek", helperName, true), DAY_OF_WEEK_VALUES, `${entryPath}.dayOfWeek`, helperName);
|
|
453
|
+
const count = (perDay.get(day) ?? 0) + 1;
|
|
454
|
+
perDay.set(day, count);
|
|
455
|
+
if (count > MAX_WEEKLY_OPERATING_HOURS_PER_DAY) {
|
|
456
|
+
throw validationError(`Invalid ${helperName} input: calling.callHours.weeklyOperatingHours must contain at most ${MAX_WEEKLY_OPERATING_HOURS_PER_DAY} entries per day.`);
|
|
457
|
+
}
|
|
458
|
+
return {
|
|
459
|
+
day_of_week: day,
|
|
460
|
+
open_time: assertHhmm(ownDataValue(record, "openTime", helperName, true), `${entryPath}.openTime`, helperName),
|
|
461
|
+
close_time: assertHhmm(ownDataValue(record, "closeTime", helperName, true), `${entryPath}.closeTime`, helperName)
|
|
462
|
+
};
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
function sanitizeHolidaySchedule(value, helperName) {
|
|
466
|
+
const path = "calling.callHours.holidaySchedule";
|
|
467
|
+
const items = sanitizeCallingArray(value, "calling.callHours.holidaySchedule", helperName, MAX_HOLIDAY_SCHEDULE_ENTRIES);
|
|
468
|
+
return items.map((item, index) => {
|
|
469
|
+
const entryPath = `calling.callHours.holidaySchedule[${index}]`;
|
|
470
|
+
const record = assertPlainRecord(item, helperName, entryPath);
|
|
471
|
+
const date = assertQueryString(ownDataValue(record, "date", helperName, true), `${entryPath}.date`, helperName, 10);
|
|
472
|
+
if (!DATE_PATTERN.test(date)) {
|
|
473
|
+
throw validationError(`Invalid ${helperName} input: ${entryPath}.date must be a "YYYY-MM-DD" string.`);
|
|
474
|
+
}
|
|
475
|
+
return {
|
|
476
|
+
date,
|
|
477
|
+
start_time: assertHhmm(ownDataValue(record, "startTime", helperName, true), `${entryPath}.startTime`, helperName),
|
|
478
|
+
end_time: assertHhmm(ownDataValue(record, "endTime", helperName, true), `${entryPath}.endTime`, helperName)
|
|
479
|
+
};
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
function sanitizeCallHours(value, helperName) {
|
|
483
|
+
const path = "calling.callHours";
|
|
484
|
+
const record = assertPlainRecord(value, helperName, "calling.callHours");
|
|
485
|
+
const out = {};
|
|
486
|
+
const status = ownDataValue(record, "status", helperName, false);
|
|
487
|
+
if (status !== undefined)
|
|
488
|
+
out.status = assertCallingEnum(status, CALLING_STATUS_VALUES, "calling.callHours.status", helperName);
|
|
489
|
+
const timezoneId = ownDataValue(record, "timezoneId", helperName, false);
|
|
490
|
+
if (timezoneId !== undefined)
|
|
491
|
+
out.timezone_id = assertQueryString(timezoneId, "calling.callHours.timezoneId", helperName, MAX_TIMEZONE_LENGTH);
|
|
492
|
+
const weekly = ownDataValue(record, "weeklyOperatingHours", helperName, false);
|
|
493
|
+
if (weekly !== undefined)
|
|
494
|
+
out.weekly_operating_hours = sanitizeWeeklyOperatingHours(weekly, helperName);
|
|
495
|
+
const holiday = ownDataValue(record, "holidaySchedule", helperName, false);
|
|
496
|
+
if (holiday !== undefined)
|
|
497
|
+
out.holiday_schedule = sanitizeHolidaySchedule(holiday, helperName);
|
|
498
|
+
return out;
|
|
499
|
+
}
|
|
500
|
+
function sanitizeCallIcons(value, helperName) {
|
|
501
|
+
const path = "calling.callIcons";
|
|
502
|
+
const record = assertPlainRecord(value, helperName, "calling.callIcons");
|
|
503
|
+
const out = {};
|
|
504
|
+
const restrict = ownDataValue(record, "restrictToUserCountries", helperName, false);
|
|
505
|
+
if (restrict !== undefined) {
|
|
506
|
+
const items = sanitizeCallingArray(restrict, "calling.callIcons.restrictToUserCountries", helperName, MAX_RESTRICT_COUNTRIES);
|
|
507
|
+
out.restrict_to_user_countries = items.map((item, index) => assertQueryString(item, `calling.callIcons.restrictToUserCountries[${index}]`, helperName, 8));
|
|
508
|
+
}
|
|
509
|
+
return out;
|
|
510
|
+
}
|
|
511
|
+
function sanitizeCalling(value, helperName) {
|
|
512
|
+
const path = "calling";
|
|
513
|
+
const record = assertPlainRecord(value, helperName, "calling");
|
|
514
|
+
const out = {};
|
|
515
|
+
const status = ownDataValue(record, "status", helperName, false);
|
|
516
|
+
if (status !== undefined)
|
|
517
|
+
out.status = assertCallingEnum(status, CALLING_STATUS_VALUES, "calling.status", helperName);
|
|
518
|
+
const callIconVisibility = ownDataValue(record, "callIconVisibility", helperName, false);
|
|
519
|
+
if (callIconVisibility !== undefined)
|
|
520
|
+
out.call_icon_visibility = assertCallingEnum(callIconVisibility, CALL_ICON_VISIBILITY_VALUES, "calling.callIconVisibility", helperName);
|
|
521
|
+
const callIcons = ownDataValue(record, "callIcons", helperName, false);
|
|
522
|
+
if (callIcons !== undefined)
|
|
523
|
+
out.call_icons = sanitizeCallIcons(callIcons, helperName);
|
|
524
|
+
const callHours = ownDataValue(record, "callHours", helperName, false);
|
|
525
|
+
if (callHours !== undefined)
|
|
526
|
+
out.call_hours = sanitizeCallHours(callHours, helperName);
|
|
527
|
+
const callbackPermissionStatus = ownDataValue(record, "callbackPermissionStatus", helperName, false);
|
|
528
|
+
if (callbackPermissionStatus !== undefined)
|
|
529
|
+
out.callback_permission_status = assertCallingEnum(callbackPermissionStatus, CALLING_STATUS_VALUES, "calling.callbackPermissionStatus", helperName);
|
|
530
|
+
const sip = ownDataValue(record, "sip", helperName, false);
|
|
531
|
+
if (sip !== undefined)
|
|
532
|
+
out.sip = sanitizeSip(sip, helperName);
|
|
533
|
+
return out;
|
|
534
|
+
}
|
|
223
535
|
export function buildUpdatePhoneNumberSettingsBody(input) {
|
|
224
536
|
const helperName = "updatePhoneNumberSettings";
|
|
225
537
|
const record = assertPlainRecord(input, "updatePhoneNumberSettings");
|
|
@@ -227,10 +539,16 @@ export function buildUpdatePhoneNumberSettingsBody(input) {
|
|
|
227
539
|
throw validationError("Invalid updatePhoneNumberSettings input: dataLocalizationRegion is not supported; use storageConfiguration.");
|
|
228
540
|
}
|
|
229
541
|
const storageConfiguration = ownDataValue(record, "storageConfiguration", "updatePhoneNumberSettings", false);
|
|
230
|
-
|
|
231
|
-
|
|
542
|
+
const calling = ownDataValue(record, "calling", "updatePhoneNumberSettings", false);
|
|
543
|
+
if (storageConfiguration === undefined && calling === undefined) {
|
|
544
|
+
throw validationError("Invalid updatePhoneNumberSettings input: at least one of storageConfiguration or calling is required.");
|
|
232
545
|
}
|
|
233
|
-
|
|
546
|
+
const body = {};
|
|
547
|
+
if (storageConfiguration !== undefined)
|
|
548
|
+
body.storage_configuration = sanitizeStorageConfiguration(storageConfiguration, "updatePhoneNumberSettings");
|
|
549
|
+
if (calling !== undefined)
|
|
550
|
+
body.calling = sanitizeCalling(calling, "updatePhoneNumberSettings");
|
|
551
|
+
return body;
|
|
234
552
|
}
|
|
235
553
|
export function normalizeUpdatePhoneNumberSettingsParams(input) {
|
|
236
554
|
const helperName = "updatePhoneNumberSettings";
|
|
@@ -251,6 +569,24 @@ export function normalizeListSubscribedAppsParams(input) {
|
|
|
251
569
|
const record = assertPlainRecord(input, "listSubscribedApps");
|
|
252
570
|
return { wabaId: assertPathId(ownDataValue(record, "wabaId", "listSubscribedApps", true), "wabaId", "listSubscribedApps") };
|
|
253
571
|
}
|
|
572
|
+
export function normalizeSetWabaCallbackOverrideParams(input) {
|
|
573
|
+
const helperName = "setWabaCallbackOverride";
|
|
574
|
+
const record = assertPlainRecord(input, "setWabaCallbackOverride");
|
|
575
|
+
return { wabaId: assertPathId(ownDataValue(record, "wabaId", "setWabaCallbackOverride", true), "wabaId", "setWabaCallbackOverride") };
|
|
576
|
+
}
|
|
577
|
+
export function normalizeClearWabaCallbackOverrideParams(input) {
|
|
578
|
+
const helperName = "clearWabaCallbackOverride";
|
|
579
|
+
const record = assertPlainRecord(input, "clearWabaCallbackOverride");
|
|
580
|
+
return { wabaId: assertPathId(ownDataValue(record, "wabaId", "clearWabaCallbackOverride", true), "wabaId", "clearWabaCallbackOverride") };
|
|
581
|
+
}
|
|
582
|
+
export function buildWabaCallbackOverrideBody(input) {
|
|
583
|
+
const helperName = "setWabaCallbackOverride";
|
|
584
|
+
const record = assertPlainRecord(input, "setWabaCallbackOverride");
|
|
585
|
+
return {
|
|
586
|
+
override_callback_uri: assertHttpsCallbackUrl(ownDataValue(record, "overrideCallbackUri", "setWabaCallbackOverride", true), "setWabaCallbackOverride"),
|
|
587
|
+
verify_token: assertCallbackVerifyToken(ownDataValue(record, "verifyToken", "setWabaCallbackOverride", true), "setWabaCallbackOverride")
|
|
588
|
+
};
|
|
589
|
+
}
|
|
254
590
|
export function normalizeListPhoneNumbersParams(input) {
|
|
255
591
|
const helperName = "listPhoneNumbers";
|
|
256
592
|
const record = assertPlainRecord(input, "listPhoneNumbers");
|
|
@@ -369,6 +705,135 @@ export function normalizeDisplayNameReviewParams(input) {
|
|
|
369
705
|
const record = assertPlainRecord(input, "submitDisplayNameForReview");
|
|
370
706
|
return { phoneNumberId: assertPathId(ownDataValue(record, "phoneNumberId", "submitDisplayNameForReview", true), "phoneNumberId", "submitDisplayNameForReview") };
|
|
371
707
|
}
|
|
708
|
+
export function buildCreatePhoneNumberBody(input) {
|
|
709
|
+
const helperName = "createPhoneNumber";
|
|
710
|
+
const record = assertPlainRecord(input, "createPhoneNumber");
|
|
711
|
+
return {
|
|
712
|
+
country_code: assertCountryCode(ownDataValue(record, "countryCode", "createPhoneNumber", true), "createPhoneNumber"),
|
|
713
|
+
phone_number: assertNationalPhoneNumber(ownDataValue(record, "phoneNumber", "createPhoneNumber", true), "createPhoneNumber"),
|
|
714
|
+
verified_name: assertBoundedPlainString(ownDataValue(record, "verifiedName", "createPhoneNumber", true), "verifiedName", "createPhoneNumber", MAX_DISPLAY_NAME_LENGTH)
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
export function normalizeCreatePhoneNumberParams(input) {
|
|
718
|
+
const helperName = "createPhoneNumber";
|
|
719
|
+
const record = assertPlainRecord(input, "createPhoneNumber");
|
|
720
|
+
return { wabaId: assertPathId(ownDataValue(record, "wabaId", "createPhoneNumber", true), "wabaId", "createPhoneNumber") };
|
|
721
|
+
}
|
|
722
|
+
export function normalizeRequestVerificationCodeParams(input) {
|
|
723
|
+
const helperName = "requestVerificationCode";
|
|
724
|
+
const record = assertPlainRecord(input, "requestVerificationCode");
|
|
725
|
+
return {
|
|
726
|
+
phoneNumberId: assertPathId(ownDataValue(record, "phoneNumberId", "requestVerificationCode", true), "phoneNumberId", "requestVerificationCode"),
|
|
727
|
+
code_method: assertCodeMethod(ownDataValue(record, "codeMethod", "requestVerificationCode", true), "requestVerificationCode"),
|
|
728
|
+
language: assertLanguage(ownDataValue(record, "language", "requestVerificationCode", true), "requestVerificationCode")
|
|
729
|
+
};
|
|
730
|
+
}
|
|
731
|
+
export function normalizeVerifyPhoneNumberParams(input) {
|
|
732
|
+
const helperName = "verifyPhoneNumber";
|
|
733
|
+
const record = assertPlainRecord(input, "verifyPhoneNumber");
|
|
734
|
+
return {
|
|
735
|
+
phoneNumberId: assertPathId(ownDataValue(record, "phoneNumberId", "verifyPhoneNumber", true), "phoneNumberId", "verifyPhoneNumber"),
|
|
736
|
+
code: assertVerificationCode(ownDataValue(record, "code", "verifyPhoneNumber", true), "verifyPhoneNumber")
|
|
737
|
+
};
|
|
738
|
+
}
|
|
739
|
+
export function buildRegisterPhoneNumberBody(input) {
|
|
740
|
+
const helperName = "registerPhoneNumber";
|
|
741
|
+
const record = assertPlainRecord(input, "registerPhoneNumber");
|
|
742
|
+
const out = {
|
|
743
|
+
messaging_product: "whatsapp",
|
|
744
|
+
pin: assertPin(ownDataValue(record, "pin", "registerPhoneNumber", true), "registerPhoneNumber")
|
|
745
|
+
};
|
|
746
|
+
const dataLocalizationRegion = ownDataValue(record, "dataLocalizationRegion", "registerPhoneNumber", false);
|
|
747
|
+
if (dataLocalizationRegion !== undefined) {
|
|
748
|
+
out.data_localization_region = assertDataLocalizationRegion(dataLocalizationRegion, "registerPhoneNumber");
|
|
749
|
+
}
|
|
750
|
+
return out;
|
|
751
|
+
}
|
|
752
|
+
export function normalizeRegisterPhoneNumberParams(input) {
|
|
753
|
+
const helperName = "registerPhoneNumber";
|
|
754
|
+
const record = assertPlainRecord(input, "registerPhoneNumber");
|
|
755
|
+
return { phoneNumberId: assertPathId(ownDataValue(record, "phoneNumberId", "registerPhoneNumber", true), "phoneNumberId", "registerPhoneNumber") };
|
|
756
|
+
}
|
|
757
|
+
export function normalizeDeregisterPhoneNumberParams(input) {
|
|
758
|
+
const helperName = "deregisterPhoneNumber";
|
|
759
|
+
const record = assertPlainRecord(input, "deregisterPhoneNumber");
|
|
760
|
+
return { phoneNumberId: assertPathId(ownDataValue(record, "phoneNumberId", "deregisterPhoneNumber", true), "phoneNumberId", "deregisterPhoneNumber") };
|
|
761
|
+
}
|
|
762
|
+
export function buildSetTwoStepVerificationPinBody(input) {
|
|
763
|
+
const helperName = "setTwoStepVerificationPin";
|
|
764
|
+
const record = assertPlainRecord(input, "setTwoStepVerificationPin");
|
|
765
|
+
return {
|
|
766
|
+
two_step_verification: {
|
|
767
|
+
pin: assertPin(ownDataValue(record, "pin", "setTwoStepVerificationPin", true), "setTwoStepVerificationPin")
|
|
768
|
+
}
|
|
769
|
+
};
|
|
770
|
+
}
|
|
771
|
+
export function normalizeSetTwoStepVerificationPinParams(input) {
|
|
772
|
+
const helperName = "setTwoStepVerificationPin";
|
|
773
|
+
const record = assertPlainRecord(input, "setTwoStepVerificationPin");
|
|
774
|
+
return { phoneNumberId: assertPathId(ownDataValue(record, "phoneNumberId", "setTwoStepVerificationPin", true), "phoneNumberId", "setTwoStepVerificationPin") };
|
|
775
|
+
}
|
|
776
|
+
export function normalizeCreateQrCodeParams(input) {
|
|
777
|
+
const helperName = "createQrCode";
|
|
778
|
+
const record = assertPlainRecord(input, "createQrCode");
|
|
779
|
+
return { phoneNumberId: assertPathId(ownDataValue(record, "phoneNumberId", "createQrCode", true), "phoneNumberId", "createQrCode") };
|
|
780
|
+
}
|
|
781
|
+
export function buildCreateQrCodeBody(input) {
|
|
782
|
+
const helperName = "createQrCode";
|
|
783
|
+
const record = assertPlainRecord(input, "createQrCode");
|
|
784
|
+
return {
|
|
785
|
+
prefilled_message: assertQrPrefilledMessage(ownDataValue(record, "prefilledMessage", "createQrCode", true), "createQrCode"),
|
|
786
|
+
generate_qr_image: assertQrImageFormat(ownDataValue(record, "generateQrImage", "createQrCode", true), "createQrCode")
|
|
787
|
+
};
|
|
788
|
+
}
|
|
789
|
+
export function normalizeListQrCodesParams(input) {
|
|
790
|
+
const helperName = "listQrCodes";
|
|
791
|
+
const record = assertPlainRecord(input, "listQrCodes");
|
|
792
|
+
const out = { phoneNumberId: assertPathId(ownDataValue(record, "phoneNumberId", "listQrCodes", true), "phoneNumberId", "listQrCodes") };
|
|
793
|
+
const fields = optionalFields(record, "listQrCodes");
|
|
794
|
+
if (fields !== undefined)
|
|
795
|
+
out.fields = fields;
|
|
796
|
+
const before = optionalQueryString(record, "before", "listQrCodes");
|
|
797
|
+
if (before !== undefined)
|
|
798
|
+
out.before = before;
|
|
799
|
+
const after = optionalQueryString(record, "after", "listQrCodes");
|
|
800
|
+
if (after !== undefined)
|
|
801
|
+
out.after = after;
|
|
802
|
+
return out;
|
|
803
|
+
}
|
|
804
|
+
export function normalizeGetQrCodeParams(input) {
|
|
805
|
+
const helperName = "getQrCode";
|
|
806
|
+
const record = assertPlainRecord(input, "getQrCode");
|
|
807
|
+
const out = {
|
|
808
|
+
phoneNumberId: assertPathId(ownDataValue(record, "phoneNumberId", "getQrCode", true), "phoneNumberId", "getQrCode"),
|
|
809
|
+
code: assertQrCodeId(ownDataValue(record, "code", "getQrCode", true), "getQrCode")
|
|
810
|
+
};
|
|
811
|
+
const fields = optionalFields(record, "getQrCode");
|
|
812
|
+
if (fields !== undefined)
|
|
813
|
+
out.fields = fields;
|
|
814
|
+
return out;
|
|
815
|
+
}
|
|
816
|
+
export function normalizeUpdateQrCodeParams(input) {
|
|
817
|
+
const helperName = "updateQrCode";
|
|
818
|
+
const record = assertPlainRecord(input, "updateQrCode");
|
|
819
|
+
return { phoneNumberId: assertPathId(ownDataValue(record, "phoneNumberId", "updateQrCode", true), "phoneNumberId", "updateQrCode") };
|
|
820
|
+
}
|
|
821
|
+
export function buildUpdateQrCodeBody(input) {
|
|
822
|
+
const helperName = "updateQrCode";
|
|
823
|
+
const record = assertPlainRecord(input, "updateQrCode");
|
|
824
|
+
return {
|
|
825
|
+
code: assertQrCodeId(ownDataValue(record, "code", "updateQrCode", true), "updateQrCode"),
|
|
826
|
+
prefilled_message: assertQrPrefilledMessage(ownDataValue(record, "prefilledMessage", "updateQrCode", true), "updateQrCode")
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
export function normalizeDeleteQrCodeParams(input) {
|
|
830
|
+
const helperName = "deleteQrCode";
|
|
831
|
+
const record = assertPlainRecord(input, "deleteQrCode");
|
|
832
|
+
return {
|
|
833
|
+
phoneNumberId: assertPathId(ownDataValue(record, "phoneNumberId", "deleteQrCode", true), "phoneNumberId", "deleteQrCode"),
|
|
834
|
+
code: assertQrCodeId(ownDataValue(record, "code", "deleteQrCode", true), "deleteQrCode")
|
|
835
|
+
};
|
|
836
|
+
}
|
|
372
837
|
export function normalizeBusinessProfileParams(input) {
|
|
373
838
|
const helperName = "getBusinessProfile";
|
|
374
839
|
const record = assertPlainRecord(input, "getBusinessProfile");
|
|
@@ -518,6 +983,18 @@ const listSubscribedAppsRaw = defineEndpoint({
|
|
|
518
983
|
pathTemplate: "/{wabaId}/subscribed_apps",
|
|
519
984
|
params: { wabaId: { in: "path", required: true } }
|
|
520
985
|
});
|
|
986
|
+
const setWabaCallbackOverrideRaw = defineEndpoint({
|
|
987
|
+
method: "POST",
|
|
988
|
+
pathTemplate: "/{wabaId}/subscribed_apps",
|
|
989
|
+
params: { wabaId: { in: "path", required: true } },
|
|
990
|
+
bodyContentType: "application/json",
|
|
991
|
+
buildBody: buildWabaCallbackOverrideBody
|
|
992
|
+
});
|
|
993
|
+
const clearWabaCallbackOverrideRaw = defineEndpoint({
|
|
994
|
+
method: "POST",
|
|
995
|
+
pathTemplate: "/{wabaId}/subscribed_apps",
|
|
996
|
+
params: { wabaId: { in: "path", required: true } }
|
|
997
|
+
});
|
|
521
998
|
const getPhoneNumberInfoRaw = defineEndpoint({
|
|
522
999
|
method: "GET",
|
|
523
1000
|
pathTemplate: "/{phoneNumberId}",
|
|
@@ -601,21 +1078,270 @@ const updateCommerceSettingsRaw = defineEndpoint({
|
|
|
601
1078
|
bodyContentType: "application/json",
|
|
602
1079
|
buildBody: buildUpdateCommerceSettingsBody
|
|
603
1080
|
});
|
|
1081
|
+
const MAX_BUSINESS_PUBLIC_KEY_LENGTH = 4096;
|
|
1082
|
+
const PEM_BEGIN_MARKER = "-----BEGIN PUBLIC KEY-----";
|
|
1083
|
+
const PEM_END_MARKER = "-----END PUBLIC KEY-----";
|
|
1084
|
+
export function assertBusinessPublicKey(value, helperName) {
|
|
1085
|
+
if (typeof value !== "string") {
|
|
1086
|
+
throw validationError(`Invalid ${helperName} input: businessPublicKey must be a non-empty PEM string.`);
|
|
1087
|
+
}
|
|
1088
|
+
if (value.length === 0 || value.trim().length === 0) {
|
|
1089
|
+
throw validationError(`Invalid ${helperName} input: businessPublicKey must be a non-empty PEM string.`);
|
|
1090
|
+
}
|
|
1091
|
+
if (value.includes("\x00")) {
|
|
1092
|
+
throw validationError(`Invalid ${helperName} input: businessPublicKey must not contain NUL characters.`);
|
|
1093
|
+
}
|
|
1094
|
+
if (value.includes("\r")) {
|
|
1095
|
+
throw validationError(`Invalid ${helperName} input: businessPublicKey must not contain CR characters.`);
|
|
1096
|
+
}
|
|
1097
|
+
if (value.length > MAX_BUSINESS_PUBLIC_KEY_LENGTH) {
|
|
1098
|
+
throw validationError(`Invalid ${helperName} input: businessPublicKey length must not exceed ${MAX_BUSINESS_PUBLIC_KEY_LENGTH} characters.`);
|
|
1099
|
+
}
|
|
1100
|
+
if (!value.includes(PEM_BEGIN_MARKER)) {
|
|
1101
|
+
throw validationError(`Invalid ${helperName} input: businessPublicKey must include the "${PEM_BEGIN_MARKER}" armor marker.`);
|
|
1102
|
+
}
|
|
1103
|
+
if (!value.includes(PEM_END_MARKER)) {
|
|
1104
|
+
throw validationError(`Invalid ${helperName} input: businessPublicKey must include the "${PEM_END_MARKER}" armor marker.`);
|
|
1105
|
+
}
|
|
1106
|
+
return value;
|
|
1107
|
+
}
|
|
1108
|
+
export function normalizeGetBusinessPublicKeyParams(input) {
|
|
1109
|
+
const helperName = "getBusinessPublicKey";
|
|
1110
|
+
const record = assertPlainRecord(input, "getBusinessPublicKey");
|
|
1111
|
+
const out = { phoneNumberId: assertPathId(ownDataValue(record, "phoneNumberId", "getBusinessPublicKey", true), "phoneNumberId", "getBusinessPublicKey") };
|
|
1112
|
+
const fields = optionalFields(record, "getBusinessPublicKey");
|
|
1113
|
+
if (fields !== undefined)
|
|
1114
|
+
out.fields = fields;
|
|
1115
|
+
return out;
|
|
1116
|
+
}
|
|
1117
|
+
export function normalizeSetBusinessPublicKeyParams(input) {
|
|
1118
|
+
const helperName = "setBusinessPublicKey";
|
|
1119
|
+
const record = assertPlainRecord(input, "setBusinessPublicKey");
|
|
1120
|
+
return { phoneNumberId: assertPathId(ownDataValue(record, "phoneNumberId", "setBusinessPublicKey", true), "phoneNumberId", "setBusinessPublicKey") };
|
|
1121
|
+
}
|
|
1122
|
+
export function buildSetBusinessPublicKeyBody(input) {
|
|
1123
|
+
const helperName = "setBusinessPublicKey";
|
|
1124
|
+
const record = assertPlainRecord(input, "setBusinessPublicKey");
|
|
1125
|
+
const businessPublicKey = assertBusinessPublicKey(ownDataValue(record, "businessPublicKey", "setBusinessPublicKey", true), "setBusinessPublicKey");
|
|
1126
|
+
const params = new URLSearchParams;
|
|
1127
|
+
params.set("business_public_key", businessPublicKey);
|
|
1128
|
+
return params;
|
|
1129
|
+
}
|
|
1130
|
+
function isResponseRecord(value) {
|
|
1131
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1132
|
+
}
|
|
1133
|
+
function normalizeHealthStatusEntity(value) {
|
|
1134
|
+
if (!isResponseRecord(value))
|
|
1135
|
+
return value;
|
|
1136
|
+
const out = { ...value };
|
|
1137
|
+
if (typeof value.entity_type === "string") {
|
|
1138
|
+
out.entityType = value.entity_type;
|
|
1139
|
+
delete out.entity_type;
|
|
1140
|
+
}
|
|
1141
|
+
if (typeof value.can_receive_call_sip === "boolean") {
|
|
1142
|
+
out.canReceiveCallSip = value.can_receive_call_sip;
|
|
1143
|
+
delete out.can_receive_call_sip;
|
|
1144
|
+
}
|
|
1145
|
+
return out;
|
|
1146
|
+
}
|
|
1147
|
+
function normalizeWabaHealthStatus(value) {
|
|
1148
|
+
if (!isResponseRecord(value))
|
|
1149
|
+
return;
|
|
1150
|
+
const out = { ...value };
|
|
1151
|
+
if (typeof value.can_receive_call_sip === "boolean") {
|
|
1152
|
+
out.canReceiveCallSip = value.can_receive_call_sip;
|
|
1153
|
+
delete out.can_receive_call_sip;
|
|
1154
|
+
}
|
|
1155
|
+
if (Array.isArray(value.entities)) {
|
|
1156
|
+
out.entities = value.entities.map(normalizeHealthStatusEntity);
|
|
1157
|
+
}
|
|
1158
|
+
return out;
|
|
1159
|
+
}
|
|
1160
|
+
function normalizeWabaInfoResponse(response) {
|
|
1161
|
+
if (!isResponseRecord(response))
|
|
1162
|
+
return response;
|
|
1163
|
+
const out = { ...response };
|
|
1164
|
+
const healthStatus = normalizeWabaHealthStatus(response.health_status);
|
|
1165
|
+
if (healthStatus !== undefined)
|
|
1166
|
+
out.healthStatus = healthStatus;
|
|
1167
|
+
delete out.health_status;
|
|
1168
|
+
return out;
|
|
1169
|
+
}
|
|
1170
|
+
function normalizeSipServerSettings(value) {
|
|
1171
|
+
if (!isResponseRecord(value))
|
|
1172
|
+
return value;
|
|
1173
|
+
const out = { ...value };
|
|
1174
|
+
if (isResponseRecord(value.request_uri_user_params)) {
|
|
1175
|
+
out.requestUriUserParams = value.request_uri_user_params;
|
|
1176
|
+
delete out.request_uri_user_params;
|
|
1177
|
+
}
|
|
1178
|
+
if (typeof value.sip_user_password === "string") {
|
|
1179
|
+
out.sipUserPassword = value.sip_user_password;
|
|
1180
|
+
delete out.sip_user_password;
|
|
1181
|
+
}
|
|
1182
|
+
if (typeof value.app_id === "number") {
|
|
1183
|
+
out.appId = value.app_id;
|
|
1184
|
+
delete out.app_id;
|
|
1185
|
+
}
|
|
1186
|
+
return out;
|
|
1187
|
+
}
|
|
1188
|
+
function normalizeCallingSettingsResponseEntry(value) {
|
|
1189
|
+
if (!isResponseRecord(value))
|
|
1190
|
+
return value;
|
|
1191
|
+
const out = { ...value };
|
|
1192
|
+
const calling = value.calling;
|
|
1193
|
+
if (isResponseRecord(calling)) {
|
|
1194
|
+
const callingOut = { ...calling };
|
|
1195
|
+
const sip = calling.sip;
|
|
1196
|
+
if (isResponseRecord(sip)) {
|
|
1197
|
+
const sipOut = { ...sip };
|
|
1198
|
+
if (Array.isArray(sip.servers)) {
|
|
1199
|
+
sipOut.servers = sip.servers.map(normalizeSipServerSettings);
|
|
1200
|
+
}
|
|
1201
|
+
callingOut.sip = sipOut;
|
|
1202
|
+
}
|
|
1203
|
+
out.calling = callingOut;
|
|
1204
|
+
}
|
|
1205
|
+
return out;
|
|
1206
|
+
}
|
|
1207
|
+
function normalizePhoneNumberSettingsResponse(response) {
|
|
1208
|
+
if (!isResponseRecord(response))
|
|
1209
|
+
return response;
|
|
1210
|
+
const out = { ...response };
|
|
1211
|
+
if (Array.isArray(response.data)) {
|
|
1212
|
+
out.data = response.data.map(normalizeCallingSettingsResponseEntry);
|
|
1213
|
+
}
|
|
1214
|
+
return out;
|
|
1215
|
+
}
|
|
1216
|
+
const getBusinessPublicKeyRaw = defineEndpoint({
|
|
1217
|
+
method: "GET",
|
|
1218
|
+
pathTemplate: "/{phoneNumberId}/whatsapp_business_encryption",
|
|
1219
|
+
params: { phoneNumberId: { in: "path", required: true }, fields: { in: "query" } }
|
|
1220
|
+
});
|
|
1221
|
+
const setBusinessPublicKeyRaw = defineEndpoint({
|
|
1222
|
+
method: "POST",
|
|
1223
|
+
pathTemplate: "/{phoneNumberId}/whatsapp_business_encryption",
|
|
1224
|
+
params: { phoneNumberId: { in: "path", required: true } },
|
|
1225
|
+
bodyContentType: "application/x-www-form-urlencoded",
|
|
1226
|
+
buildBody: buildSetBusinessPublicKeyBody
|
|
1227
|
+
});
|
|
1228
|
+
export const getBusinessPublicKey = Object.assign(async function getBusinessPublicKey(client, params, body, opts) {
|
|
1229
|
+
assertNoBody(body, "getBusinessPublicKey");
|
|
1230
|
+
return getBusinessPublicKeyRaw(client, normalizeGetBusinessPublicKeyParams(params), undefined, sanitizeBusinessManagementOptions(opts, "getBusinessPublicKey"));
|
|
1231
|
+
}, { definition: getBusinessPublicKeyRaw.definition });
|
|
1232
|
+
export const setBusinessPublicKey = Object.assign(async function setBusinessPublicKey(client, params, body, opts) {
|
|
1233
|
+
assertNoBody(body, "setBusinessPublicKey");
|
|
1234
|
+
return setBusinessPublicKeyRaw(client, normalizeSetBusinessPublicKeyParams(params), params, sanitizeBusinessManagementOptions(opts, "setBusinessPublicKey"));
|
|
1235
|
+
}, { definition: setBusinessPublicKeyRaw.definition });
|
|
1236
|
+
const createPhoneNumberRaw = defineEndpoint({
|
|
1237
|
+
method: "POST",
|
|
1238
|
+
pathTemplate: "/{wabaId}/phone_numbers",
|
|
1239
|
+
params: { wabaId: { in: "path", required: true } },
|
|
1240
|
+
bodyContentType: "application/json",
|
|
1241
|
+
buildBody: buildCreatePhoneNumberBody
|
|
1242
|
+
});
|
|
1243
|
+
const requestVerificationCodeRaw = defineEndpoint({
|
|
1244
|
+
method: "POST",
|
|
1245
|
+
pathTemplate: "/{phoneNumberId}/request_code",
|
|
1246
|
+
params: {
|
|
1247
|
+
phoneNumberId: { in: "path", required: true },
|
|
1248
|
+
code_method: { in: "query" },
|
|
1249
|
+
language: { in: "query" }
|
|
1250
|
+
}
|
|
1251
|
+
});
|
|
1252
|
+
const verifyPhoneNumberRaw = defineEndpoint({
|
|
1253
|
+
method: "POST",
|
|
1254
|
+
pathTemplate: "/{phoneNumberId}/verify_code",
|
|
1255
|
+
params: {
|
|
1256
|
+
phoneNumberId: { in: "path", required: true },
|
|
1257
|
+
code: { in: "query" }
|
|
1258
|
+
}
|
|
1259
|
+
});
|
|
1260
|
+
const registerPhoneNumberRaw = defineEndpoint({
|
|
1261
|
+
method: "POST",
|
|
1262
|
+
pathTemplate: "/{phoneNumberId}/register",
|
|
1263
|
+
params: { phoneNumberId: { in: "path", required: true } },
|
|
1264
|
+
bodyContentType: "application/json",
|
|
1265
|
+
buildBody: buildRegisterPhoneNumberBody
|
|
1266
|
+
});
|
|
1267
|
+
const deregisterPhoneNumberRaw = defineEndpoint({
|
|
1268
|
+
method: "POST",
|
|
1269
|
+
pathTemplate: "/{phoneNumberId}/deregister",
|
|
1270
|
+
params: { phoneNumberId: { in: "path", required: true } }
|
|
1271
|
+
});
|
|
1272
|
+
const setTwoStepVerificationPinRaw = defineEndpoint({
|
|
1273
|
+
method: "POST",
|
|
1274
|
+
pathTemplate: "/{phoneNumberId}",
|
|
1275
|
+
params: { phoneNumberId: { in: "path", required: true } },
|
|
1276
|
+
bodyContentType: "application/json",
|
|
1277
|
+
buildBody: buildSetTwoStepVerificationPinBody
|
|
1278
|
+
});
|
|
1279
|
+
const createQrCodeRaw = defineEndpoint({
|
|
1280
|
+
method: "POST",
|
|
1281
|
+
pathTemplate: "/{phoneNumberId}/message_qrdls",
|
|
1282
|
+
params: { phoneNumberId: { in: "path", required: true } },
|
|
1283
|
+
bodyContentType: "application/json",
|
|
1284
|
+
buildBody: buildCreateQrCodeBody
|
|
1285
|
+
});
|
|
1286
|
+
const listQrCodesRaw = defineEndpoint({
|
|
1287
|
+
method: "GET",
|
|
1288
|
+
pathTemplate: "/{phoneNumberId}/message_qrdls",
|
|
1289
|
+
params: {
|
|
1290
|
+
phoneNumberId: { in: "path", required: true },
|
|
1291
|
+
fields: { in: "query" },
|
|
1292
|
+
before: { in: "query" },
|
|
1293
|
+
after: { in: "query" }
|
|
1294
|
+
}
|
|
1295
|
+
});
|
|
1296
|
+
const getQrCodeRaw = defineEndpoint({
|
|
1297
|
+
method: "GET",
|
|
1298
|
+
pathTemplate: "/{phoneNumberId}/message_qrdls/{code}",
|
|
1299
|
+
params: {
|
|
1300
|
+
phoneNumberId: { in: "path", required: true },
|
|
1301
|
+
code: { in: "path", required: true },
|
|
1302
|
+
fields: { in: "query" }
|
|
1303
|
+
}
|
|
1304
|
+
});
|
|
1305
|
+
const updateQrCodeRaw = defineEndpoint({
|
|
1306
|
+
method: "POST",
|
|
1307
|
+
pathTemplate: "/{phoneNumberId}/message_qrdls",
|
|
1308
|
+
params: { phoneNumberId: { in: "path", required: true } },
|
|
1309
|
+
bodyContentType: "application/json",
|
|
1310
|
+
buildBody: buildUpdateQrCodeBody
|
|
1311
|
+
});
|
|
1312
|
+
const deleteQrCodeRaw = defineEndpoint({
|
|
1313
|
+
method: "DELETE",
|
|
1314
|
+
pathTemplate: "/{phoneNumberId}/message_qrdls/{code}",
|
|
1315
|
+
params: {
|
|
1316
|
+
phoneNumberId: { in: "path", required: true },
|
|
1317
|
+
code: { in: "path", required: true }
|
|
1318
|
+
}
|
|
1319
|
+
});
|
|
604
1320
|
export const getWabaInfo = Object.assign(async function getWabaInfo(client, params, body, opts) {
|
|
605
1321
|
assertNoBody(body, "getWabaInfo");
|
|
606
|
-
|
|
1322
|
+
const response = await getWabaInfoRaw(client, normalizeWabaInfoParams(params), undefined, sanitizeBusinessManagementOptions(opts, "getWabaInfo"));
|
|
1323
|
+
return normalizeWabaInfoResponse(response);
|
|
607
1324
|
}, { definition: getWabaInfoRaw.definition });
|
|
608
1325
|
export const listSubscribedApps = Object.assign(async function listSubscribedApps(client, params, body, opts) {
|
|
609
1326
|
assertNoBody(body, "listSubscribedApps");
|
|
610
1327
|
return listSubscribedAppsRaw(client, normalizeListSubscribedAppsParams(params), undefined, sanitizeBusinessManagementOptions(opts, "listSubscribedApps"));
|
|
611
1328
|
}, { definition: listSubscribedAppsRaw.definition });
|
|
1329
|
+
export const setWabaCallbackOverride = Object.assign(async function setWabaCallbackOverride(client, params, body, opts) {
|
|
1330
|
+
assertNoBody(body, "setWabaCallbackOverride");
|
|
1331
|
+
return setWabaCallbackOverrideRaw(client, normalizeSetWabaCallbackOverrideParams(params), params, sanitizeBusinessManagementOptions(opts, "setWabaCallbackOverride"));
|
|
1332
|
+
}, { definition: setWabaCallbackOverrideRaw.definition });
|
|
1333
|
+
export const clearWabaCallbackOverride = Object.assign(async function clearWabaCallbackOverride(client, params, body, opts) {
|
|
1334
|
+
assertNoBody(body, "clearWabaCallbackOverride");
|
|
1335
|
+
return clearWabaCallbackOverrideRaw(client, normalizeClearWabaCallbackOverrideParams(params), undefined, sanitizeBusinessManagementOptions(opts, "clearWabaCallbackOverride"));
|
|
1336
|
+
}, { definition: clearWabaCallbackOverrideRaw.definition });
|
|
612
1337
|
export const getPhoneNumberInfo = Object.assign(async function getPhoneNumberInfo(client, params, body, opts) {
|
|
613
1338
|
assertNoBody(body, "getPhoneNumberInfo");
|
|
614
1339
|
return getPhoneNumberInfoRaw(client, normalizePhoneNumberInfoParams(params), undefined, sanitizeBusinessManagementOptions(opts, "getPhoneNumberInfo"));
|
|
615
1340
|
}, { definition: getPhoneNumberInfoRaw.definition });
|
|
616
1341
|
export const getPhoneNumberSettings = Object.assign(async function getPhoneNumberSettings(client, params, body, opts) {
|
|
617
1342
|
assertNoBody(body, "getPhoneNumberSettings");
|
|
618
|
-
|
|
1343
|
+
const response = await getPhoneNumberSettingsRaw(client, normalizePhoneNumberSettingsParams(params), undefined, sanitizeBusinessManagementOptions(opts, "getPhoneNumberSettings"));
|
|
1344
|
+
return normalizePhoneNumberSettingsResponse(response);
|
|
619
1345
|
}, { definition: getPhoneNumberSettingsRaw.definition });
|
|
620
1346
|
export const updatePhoneNumberSettings = Object.assign(async function updatePhoneNumberSettings(client, params, body, opts) {
|
|
621
1347
|
assertNoBody(body, "updatePhoneNumberSettings");
|
|
@@ -661,3 +1387,47 @@ export const updateCommerceSettings = Object.assign(async function updateCommerc
|
|
|
661
1387
|
assertNoBody(body, "updateCommerceSettings");
|
|
662
1388
|
return updateCommerceSettingsRaw(client, normalizeUpdateCommerceSettingsParams(params), params, sanitizeBusinessManagementOptions(opts, "updateCommerceSettings"));
|
|
663
1389
|
}, { definition: updateCommerceSettingsRaw.definition });
|
|
1390
|
+
export const createPhoneNumber = Object.assign(async function createPhoneNumber(client, params, body, opts) {
|
|
1391
|
+
assertNoBody(body, "createPhoneNumber");
|
|
1392
|
+
return createPhoneNumberRaw(client, normalizeCreatePhoneNumberParams(params), params, sanitizeBusinessManagementOptions(opts, "createPhoneNumber"));
|
|
1393
|
+
}, { definition: createPhoneNumberRaw.definition });
|
|
1394
|
+
export const requestVerificationCode = Object.assign(async function requestVerificationCode(client, params, body, opts) {
|
|
1395
|
+
assertNoBody(body, "requestVerificationCode");
|
|
1396
|
+
return requestVerificationCodeRaw(client, normalizeRequestVerificationCodeParams(params), undefined, sanitizeBusinessManagementOptions(opts, "requestVerificationCode"));
|
|
1397
|
+
}, { definition: requestVerificationCodeRaw.definition });
|
|
1398
|
+
export const verifyPhoneNumber = Object.assign(async function verifyPhoneNumber(client, params, body, opts) {
|
|
1399
|
+
assertNoBody(body, "verifyPhoneNumber");
|
|
1400
|
+
return verifyPhoneNumberRaw(client, normalizeVerifyPhoneNumberParams(params), undefined, sanitizeBusinessManagementOptions(opts, "verifyPhoneNumber"));
|
|
1401
|
+
}, { definition: verifyPhoneNumberRaw.definition });
|
|
1402
|
+
export const registerPhoneNumber = Object.assign(async function registerPhoneNumber(client, params, body, opts) {
|
|
1403
|
+
assertNoBody(body, "registerPhoneNumber");
|
|
1404
|
+
return registerPhoneNumberRaw(client, normalizeRegisterPhoneNumberParams(params), params, sanitizeBusinessManagementOptions(opts, "registerPhoneNumber"));
|
|
1405
|
+
}, { definition: registerPhoneNumberRaw.definition });
|
|
1406
|
+
export const deregisterPhoneNumber = Object.assign(async function deregisterPhoneNumber(client, params, body, opts) {
|
|
1407
|
+
assertNoBody(body, "deregisterPhoneNumber");
|
|
1408
|
+
return deregisterPhoneNumberRaw(client, normalizeDeregisterPhoneNumberParams(params), undefined, sanitizeBusinessManagementOptions(opts, "deregisterPhoneNumber"));
|
|
1409
|
+
}, { definition: deregisterPhoneNumberRaw.definition });
|
|
1410
|
+
export const setTwoStepVerificationPin = Object.assign(async function setTwoStepVerificationPin(client, params, body, opts) {
|
|
1411
|
+
assertNoBody(body, "setTwoStepVerificationPin");
|
|
1412
|
+
return setTwoStepVerificationPinRaw(client, normalizeSetTwoStepVerificationPinParams(params), params, sanitizeBusinessManagementOptions(opts, "setTwoStepVerificationPin"));
|
|
1413
|
+
}, { definition: setTwoStepVerificationPinRaw.definition });
|
|
1414
|
+
export const createQrCode = Object.assign(async function createQrCode(client, params, body, opts) {
|
|
1415
|
+
assertNoBody(body, "createQrCode");
|
|
1416
|
+
return createQrCodeRaw(client, normalizeCreateQrCodeParams(params), params, sanitizeBusinessManagementOptions(opts, "createQrCode"));
|
|
1417
|
+
}, { definition: createQrCodeRaw.definition });
|
|
1418
|
+
export const listQrCodes = Object.assign(async function listQrCodes(client, params, body, opts) {
|
|
1419
|
+
assertNoBody(body, "listQrCodes");
|
|
1420
|
+
return listQrCodesRaw(client, normalizeListQrCodesParams(params), undefined, sanitizeBusinessManagementOptions(opts, "listQrCodes"));
|
|
1421
|
+
}, { definition: listQrCodesRaw.definition });
|
|
1422
|
+
export const getQrCode = Object.assign(async function getQrCode(client, params, body, opts) {
|
|
1423
|
+
assertNoBody(body, "getQrCode");
|
|
1424
|
+
return getQrCodeRaw(client, normalizeGetQrCodeParams(params), undefined, sanitizeBusinessManagementOptions(opts, "getQrCode"));
|
|
1425
|
+
}, { definition: getQrCodeRaw.definition });
|
|
1426
|
+
export const updateQrCode = Object.assign(async function updateQrCode(client, params, body, opts) {
|
|
1427
|
+
assertNoBody(body, "updateQrCode");
|
|
1428
|
+
return updateQrCodeRaw(client, normalizeUpdateQrCodeParams(params), params, sanitizeBusinessManagementOptions(opts, "updateQrCode"));
|
|
1429
|
+
}, { definition: updateQrCodeRaw.definition });
|
|
1430
|
+
export const deleteQrCode = Object.assign(async function deleteQrCode(client, params, body, opts) {
|
|
1431
|
+
assertNoBody(body, "deleteQrCode");
|
|
1432
|
+
return deleteQrCodeRaw(client, normalizeDeleteQrCodeParams(params), undefined, sanitizeBusinessManagementOptions(opts, "deleteQrCode"));
|
|
1433
|
+
}, { definition: deleteQrCodeRaw.definition });
|