@digisglobal/omnivox-sdk 0.7.0 → 0.9.0
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/dist/index.cjs +151 -33
- package/dist/index.d.cts +216 -43
- package/dist/index.d.ts +216 -43
- package/dist/index.js +151 -33
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -183,9 +183,15 @@ var getChannelsControllerVerifyUrl = (id, channelId) => {
|
|
|
183
183
|
var getWhatsAppBusinessAccountsControllerListUrl = (id) => {
|
|
184
184
|
return `/api/v1/tenants/${id}/whatsapp-business-accounts`;
|
|
185
185
|
};
|
|
186
|
+
var getWhatsAppBusinessAccountsControllerCreateUrl = (id) => {
|
|
187
|
+
return `/api/v1/tenants/${id}/whatsapp-business-accounts`;
|
|
188
|
+
};
|
|
186
189
|
var getWhatsAppBusinessAccountsControllerFindOneUrl = (id, wabaRowId) => {
|
|
187
190
|
return `/api/v1/tenants/${id}/whatsapp-business-accounts/${wabaRowId}`;
|
|
188
191
|
};
|
|
192
|
+
var getWhatsAppBusinessAccountsControllerUpdateNameUrl = (id, wabaRowId) => {
|
|
193
|
+
return `/api/v1/tenants/${id}/whatsapp-business-accounts/${wabaRowId}`;
|
|
194
|
+
};
|
|
189
195
|
var getAgentsControllerCreateUrl = () => {
|
|
190
196
|
return `/api/v1/agents`;
|
|
191
197
|
};
|
|
@@ -205,12 +211,25 @@ var getAgentsControllerFindOneUrl = (id) => {
|
|
|
205
211
|
var getTemplatesControllerAuthorDraftUrl = (id, wabaId) => {
|
|
206
212
|
return `/api/v1/tenants/${id}/whatsapp-business-accounts/${wabaId}/templates`;
|
|
207
213
|
};
|
|
214
|
+
var getTemplatesControllerListUrl = (id, wabaId, params) => {
|
|
215
|
+
const normalizedParams = new URLSearchParams();
|
|
216
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
217
|
+
if (value !== void 0) {
|
|
218
|
+
normalizedParams.append(key, value === null ? "null" : String(value));
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
const stringifiedParams = normalizedParams.toString();
|
|
222
|
+
return stringifiedParams.length > 0 ? `/api/v1/tenants/${id}/whatsapp-business-accounts/${wabaId}/templates?${stringifiedParams}` : `/api/v1/tenants/${id}/whatsapp-business-accounts/${wabaId}/templates`;
|
|
223
|
+
};
|
|
208
224
|
var getTemplatesControllerImportApprovedUrl = (id, wabaId) => {
|
|
209
225
|
return `/api/v1/tenants/${id}/whatsapp-business-accounts/${wabaId}/templates/import`;
|
|
210
226
|
};
|
|
211
227
|
var getTemplatesControllerForkDraftUrl = (id, wabaId, templateId) => {
|
|
212
228
|
return `/api/v1/tenants/${id}/whatsapp-business-accounts/${wabaId}/templates/${templateId}`;
|
|
213
229
|
};
|
|
230
|
+
var getTemplatesControllerGetByIdUrl = (id, wabaId, templateId) => {
|
|
231
|
+
return `/api/v1/tenants/${id}/whatsapp-business-accounts/${wabaId}/templates/${templateId}`;
|
|
232
|
+
};
|
|
214
233
|
var getTemplatesControllerGetHistoryUrl = (id, wabaId, templateId) => {
|
|
215
234
|
return `/api/v1/tenants/${id}/whatsapp-business-accounts/${wabaId}/templates/${templateId}/history`;
|
|
216
235
|
};
|
|
@@ -258,6 +277,9 @@ var getCannedResponsesControllerPatchUrl = (id) => {
|
|
|
258
277
|
var getCannedResponsesControllerDeleteUrl = (id) => {
|
|
259
278
|
return `/api/v1/canned-responses/${id}`;
|
|
260
279
|
};
|
|
280
|
+
var getCannedResponsesControllerDuplicateUrl = (id) => {
|
|
281
|
+
return `/api/v1/canned-responses/${id}/duplicate`;
|
|
282
|
+
};
|
|
261
283
|
var getAttachmentsControllerUploadUrl = () => {
|
|
262
284
|
return `/api/v1/attachments`;
|
|
263
285
|
};
|
|
@@ -356,7 +378,7 @@ function createTenantsModule(options) {
|
|
|
356
378
|
url,
|
|
357
379
|
buildInit("POST", { body: JSON.stringify(body) })
|
|
358
380
|
);
|
|
359
|
-
return
|
|
381
|
+
return parseEnvelopedResponse(res);
|
|
360
382
|
},
|
|
361
383
|
/**
|
|
362
384
|
* Revoke an existing API key immediately.
|
|
@@ -366,7 +388,7 @@ function createTenantsModule(options) {
|
|
|
366
388
|
const path = getApiKeysControllerRevokeUrl(tenantId, keyId);
|
|
367
389
|
const url = `${baseUrl}${path}`;
|
|
368
390
|
const res = await fetch(url, buildInit("DELETE"));
|
|
369
|
-
return
|
|
391
|
+
return parseEnvelopedResponse(res);
|
|
370
392
|
}
|
|
371
393
|
}
|
|
372
394
|
};
|
|
@@ -395,7 +417,7 @@ function createAgentsModule(options) {
|
|
|
395
417
|
const path = getAgentsControllerCreateUrl();
|
|
396
418
|
const url = `${baseUrl}${path}`;
|
|
397
419
|
const res = await fetch(url, buildInit("POST", input));
|
|
398
|
-
return
|
|
420
|
+
return parseEnvelopedResponse(res);
|
|
399
421
|
},
|
|
400
422
|
/**
|
|
401
423
|
* List agents for the authenticated tenant (paginated, sorted deterministically).
|
|
@@ -417,7 +439,7 @@ function createAgentsModule(options) {
|
|
|
417
439
|
const path = getAgentsControllerFindOneUrl(id);
|
|
418
440
|
const url = `${baseUrl}${path}`;
|
|
419
441
|
const res = await fetch(url, buildInit("GET"));
|
|
420
|
-
return
|
|
442
|
+
return parseEnvelopedResponse(res);
|
|
421
443
|
}
|
|
422
444
|
};
|
|
423
445
|
}
|
|
@@ -447,7 +469,7 @@ function createChannelsModule(options) {
|
|
|
447
469
|
const path = getChannelsControllerCreateUrl(tenantId);
|
|
448
470
|
const url = `${baseUrl}${path}`;
|
|
449
471
|
const res = await fetch(url, buildInit("POST", body));
|
|
450
|
-
return
|
|
472
|
+
return parseEnvelopedResponse(res);
|
|
451
473
|
},
|
|
452
474
|
/**
|
|
453
475
|
* Get a single channel by id (config + name/status/isDefault/type +
|
|
@@ -458,7 +480,7 @@ function createChannelsModule(options) {
|
|
|
458
480
|
const path = getChannelsControllerFindOneUrl(tenantId, channelId);
|
|
459
481
|
const url = `${baseUrl}${path}`;
|
|
460
482
|
const res = await fetch(url, buildInit("GET"));
|
|
461
|
-
return
|
|
483
|
+
return parseEnvelopedResponse(res);
|
|
462
484
|
},
|
|
463
485
|
/**
|
|
464
486
|
* Update a channel (name/status/isDefault/config; Email may rotate secret).
|
|
@@ -468,7 +490,7 @@ function createChannelsModule(options) {
|
|
|
468
490
|
const path = getChannelsControllerUpdateUrl(tenantId, channelId);
|
|
469
491
|
const url = `${baseUrl}${path}`;
|
|
470
492
|
const res = await fetch(url, buildInit("PATCH", body));
|
|
471
|
-
return
|
|
493
|
+
return parseEnvelopedResponse(res);
|
|
472
494
|
},
|
|
473
495
|
/**
|
|
474
496
|
* Verify a channel through its adapter; on success sets lastVerifiedAt.
|
|
@@ -506,7 +528,7 @@ function createContactsModule(options) {
|
|
|
506
528
|
const path = getContactsControllerCreateUrl();
|
|
507
529
|
const url = `${baseUrl}${path}`;
|
|
508
530
|
const res = await fetch(url, buildInit("POST", input));
|
|
509
|
-
return
|
|
531
|
+
return parseEnvelopedResponse(res);
|
|
510
532
|
},
|
|
511
533
|
/**
|
|
512
534
|
* Search contacts by display name or raw identifier.
|
|
@@ -533,7 +555,7 @@ function createContactsModule(options) {
|
|
|
533
555
|
const path = getContactsControllerGetDetailUrl(id);
|
|
534
556
|
const url = `${baseUrl}${path}`;
|
|
535
557
|
const res = await fetch(url, buildInit("GET"));
|
|
536
|
-
return
|
|
558
|
+
return parseEnvelopedResponse(res);
|
|
537
559
|
},
|
|
538
560
|
/**
|
|
539
561
|
* Return the tenant's tag catalog and custom-field definitions.
|
|
@@ -543,7 +565,7 @@ function createContactsModule(options) {
|
|
|
543
565
|
const path = getContactsControllerGetMetadataUrl();
|
|
544
566
|
const url = `${baseUrl}${path}`;
|
|
545
567
|
const res = await fetch(url, buildInit("GET"));
|
|
546
|
-
return
|
|
568
|
+
return parseEnvelopedResponse(res);
|
|
547
569
|
},
|
|
548
570
|
/**
|
|
549
571
|
* Partially update a contact.
|
|
@@ -553,7 +575,7 @@ function createContactsModule(options) {
|
|
|
553
575
|
const path = getContactsControllerPatchUrl(id);
|
|
554
576
|
const url = `${baseUrl}${path}`;
|
|
555
577
|
const res = await fetch(url, buildInit("PATCH", input));
|
|
556
|
-
return
|
|
578
|
+
return parseEnvelopedResponse(res);
|
|
557
579
|
},
|
|
558
580
|
/**
|
|
559
581
|
* Add a channel identity to an existing contact.
|
|
@@ -563,7 +585,7 @@ function createContactsModule(options) {
|
|
|
563
585
|
const path = getContactsControllerAddIdentityUrl(id);
|
|
564
586
|
const url = `${baseUrl}${path}`;
|
|
565
587
|
const res = await fetch(url, buildInit("POST", input));
|
|
566
|
-
return
|
|
588
|
+
return parseEnvelopedResponse(res);
|
|
567
589
|
}
|
|
568
590
|
};
|
|
569
591
|
}
|
|
@@ -592,7 +614,7 @@ function createConversationsModule(options) {
|
|
|
592
614
|
const path = getConversationsControllerReopenOrCreateUrl();
|
|
593
615
|
const url = `${baseUrl}${path}`;
|
|
594
616
|
const res = await fetch(url, buildInit("POST", input));
|
|
595
|
-
return
|
|
617
|
+
return parseEnvelopedResponse(res);
|
|
596
618
|
},
|
|
597
619
|
/**
|
|
598
620
|
* List conversations with optional filters (paginated, sorted deterministically).
|
|
@@ -620,7 +642,7 @@ function createConversationsModule(options) {
|
|
|
620
642
|
const path = getConversationsControllerUpdateStatusUrl(id);
|
|
621
643
|
const url = `${baseUrl}${path}`;
|
|
622
644
|
const res = await fetch(url, buildInit("PATCH", input));
|
|
623
|
-
return
|
|
645
|
+
return parseEnvelopedResponse(res);
|
|
624
646
|
},
|
|
625
647
|
/**
|
|
626
648
|
* Assign a conversation to an agent.
|
|
@@ -630,7 +652,7 @@ function createConversationsModule(options) {
|
|
|
630
652
|
const path = getConversationsControllerAssignUrl(id);
|
|
631
653
|
const url = `${baseUrl}${path}`;
|
|
632
654
|
const res = await fetch(url, buildInit("PATCH", input));
|
|
633
|
-
return
|
|
655
|
+
return parseEnvelopedResponse(res);
|
|
634
656
|
},
|
|
635
657
|
/**
|
|
636
658
|
* List lobby entries awaiting pickup (paginated, sorted by receivedAt DESC).
|
|
@@ -652,18 +674,18 @@ function createConversationsModule(options) {
|
|
|
652
674
|
const path = getConversationsControllerFindOneUrl(id);
|
|
653
675
|
const url = `${baseUrl}${path}`;
|
|
654
676
|
const res = await fetch(url, buildInit("GET"));
|
|
655
|
-
return
|
|
677
|
+
return parseEnvelopedResponse(res);
|
|
656
678
|
},
|
|
657
679
|
/**
|
|
658
680
|
* Pick up a lobby entry (atomic 4-step transaction).
|
|
659
|
-
* Returns the resulting conversation.
|
|
681
|
+
* Returns the resulting conversation + entry ids.
|
|
660
682
|
* Calls POST /api/v1/conversations/lobby/:entryId/pickup.
|
|
661
683
|
*/
|
|
662
684
|
async pickup(entryId, input) {
|
|
663
685
|
const path = getConversationsControllerPickupLobbyEntryUrl(entryId);
|
|
664
686
|
const url = `${baseUrl}${path}`;
|
|
665
687
|
const res = await fetch(url, buildInit("POST", input));
|
|
666
|
-
return
|
|
688
|
+
return parseEnvelopedResponse(res);
|
|
667
689
|
},
|
|
668
690
|
/**
|
|
669
691
|
* List APPROVED + SENDABLE WhatsApp templates eligible to re-open an
|
|
@@ -675,7 +697,7 @@ function createConversationsModule(options) {
|
|
|
675
697
|
const path = getConversationsControllerGetWhatsAppRecoveryOptionsUrl(id);
|
|
676
698
|
const url = `${baseUrl}${path}`;
|
|
677
699
|
const res = await fetch(url, buildInit("GET"));
|
|
678
|
-
return
|
|
700
|
+
return parseEnvelopedResponse(res);
|
|
679
701
|
}
|
|
680
702
|
};
|
|
681
703
|
}
|
|
@@ -703,7 +725,7 @@ function createMessagesModule(options) {
|
|
|
703
725
|
const path = getMessagesControllerSendUrl();
|
|
704
726
|
const url = `${baseUrl}${path}`;
|
|
705
727
|
const res = await fetch(url, buildInit("POST", input));
|
|
706
|
-
return
|
|
728
|
+
return parseEnvelopedResponse(res);
|
|
707
729
|
},
|
|
708
730
|
/**
|
|
709
731
|
* List messages in a conversation (newest first, paginated).
|
|
@@ -731,7 +753,7 @@ function createMessagesModule(options) {
|
|
|
731
753
|
const path = getMessagesControllerGetByIdUrl(id);
|
|
732
754
|
const url = `${baseUrl}${path}`;
|
|
733
755
|
const res = await fetch(url, buildInit("GET"));
|
|
734
|
-
return
|
|
756
|
+
return parseEnvelopedResponse(res);
|
|
735
757
|
},
|
|
736
758
|
/**
|
|
737
759
|
* Soft-delete a message (sets deletedAt; row preserved).
|
|
@@ -753,7 +775,7 @@ function createMessagesModule(options) {
|
|
|
753
775
|
const path = getMessagesControllerSendTemplateUrl();
|
|
754
776
|
const url = `${baseUrl}${path}`;
|
|
755
777
|
const res = await fetch(url, buildInit("POST", input));
|
|
756
|
-
return
|
|
778
|
+
return parseEnvelopedResponse(res);
|
|
757
779
|
}
|
|
758
780
|
};
|
|
759
781
|
}
|
|
@@ -777,6 +799,38 @@ function createTemplatesModule(options) {
|
|
|
777
799
|
* WhatsApp template submodule — WABA-scoped operations.
|
|
778
800
|
*/
|
|
779
801
|
whatsapp: {
|
|
802
|
+
/**
|
|
803
|
+
* List a WhatsApp Business Account's templates (paginated, optionally status-filtered and name-searchable).
|
|
804
|
+
* Calls GET /api/v1/tenants/:id/whatsapp-business-accounts/:wabaId/templates.
|
|
805
|
+
*/
|
|
806
|
+
async list(tenantId, wabaId, opts) {
|
|
807
|
+
const { page, pageSize } = buildPageParams(opts);
|
|
808
|
+
const path = getTemplatesControllerListUrl(tenantId, wabaId, {
|
|
809
|
+
page,
|
|
810
|
+
pageSize,
|
|
811
|
+
...opts.status ? { status: opts.status } : {},
|
|
812
|
+
...opts.q ? { q: opts.q } : {}
|
|
813
|
+
});
|
|
814
|
+
const url = `${baseUrl}${path}`;
|
|
815
|
+
const res = await fetch(url, buildInit("GET"));
|
|
816
|
+
return parseResponse(res);
|
|
817
|
+
},
|
|
818
|
+
/**
|
|
819
|
+
* Get a single template together with its current (latest) version.
|
|
820
|
+
* Language/status and other version-scoped fields are nested under
|
|
821
|
+
* `currentVersion` — not at the top level (see WhatsAppTemplateDetail).
|
|
822
|
+
* Calls GET /api/v1/tenants/:id/whatsapp-business-accounts/:wabaId/templates/:templateId.
|
|
823
|
+
*/
|
|
824
|
+
async getById(tenantId, wabaId, templateId) {
|
|
825
|
+
const path = getTemplatesControllerGetByIdUrl(
|
|
826
|
+
tenantId,
|
|
827
|
+
wabaId,
|
|
828
|
+
templateId
|
|
829
|
+
);
|
|
830
|
+
const url = `${baseUrl}${path}`;
|
|
831
|
+
const res = await fetch(url, buildInit("GET"));
|
|
832
|
+
return parseEnvelopedResponse(res);
|
|
833
|
+
},
|
|
780
834
|
/**
|
|
781
835
|
* Author a new DRAFT template (version 1) under a WhatsApp Business Account.
|
|
782
836
|
* Calls POST /api/v1/tenants/:id/whatsapp-business-accounts/:wabaId/templates.
|
|
@@ -812,7 +866,11 @@ function createTemplatesModule(options) {
|
|
|
812
866
|
return parseEnvelopedResponse(res);
|
|
813
867
|
},
|
|
814
868
|
/**
|
|
815
|
-
*
|
|
869
|
+
* Get the full version + status-event history for a template.
|
|
870
|
+
*
|
|
871
|
+
* Returns a single OBJECT (see WhatsAppTemplateHistory) — template-level
|
|
872
|
+
* fields plus a `versions` array ordered by versionNumber ascending, each
|
|
873
|
+
* version carrying its own `statusEvents`. NOT a flat array of events.
|
|
816
874
|
* Calls GET /api/v1/tenants/:id/whatsapp-business-accounts/:wabaId/templates/:templateId/history.
|
|
817
875
|
*/
|
|
818
876
|
async history(tenantId, wabaId, templateId) {
|
|
@@ -860,7 +918,11 @@ function createTemplatesModule(options) {
|
|
|
860
918
|
*/
|
|
861
919
|
async list(opts) {
|
|
862
920
|
const { page, pageSize } = buildPageParams(opts);
|
|
863
|
-
const path = getEmailTemplatesControllerListUrl({
|
|
921
|
+
const path = getEmailTemplatesControllerListUrl({
|
|
922
|
+
page,
|
|
923
|
+
pageSize,
|
|
924
|
+
...opts.q ? { q: opts.q } : {}
|
|
925
|
+
});
|
|
864
926
|
const url = `${baseUrl}${path}`;
|
|
865
927
|
const res = await fetch(url, buildInit("GET"));
|
|
866
928
|
return parseResponse(res);
|
|
@@ -923,7 +985,12 @@ function createCannedResponsesModule(options) {
|
|
|
923
985
|
*/
|
|
924
986
|
async list(opts) {
|
|
925
987
|
const { page, pageSize } = buildPageParams(opts);
|
|
926
|
-
const path = getCannedResponsesControllerListUrl({
|
|
988
|
+
const path = getCannedResponsesControllerListUrl({
|
|
989
|
+
page,
|
|
990
|
+
pageSize,
|
|
991
|
+
...opts.category ? { category: opts.category } : {},
|
|
992
|
+
...opts.channel ? { channel: opts.channel } : {}
|
|
993
|
+
});
|
|
927
994
|
const url = `${baseUrl}${path}`;
|
|
928
995
|
const res = await fetch(url, buildInit("GET"));
|
|
929
996
|
return parseResponse(res);
|
|
@@ -938,7 +1005,9 @@ function createCannedResponsesModule(options) {
|
|
|
938
1005
|
const path = getCannedResponsesControllerListUrl({
|
|
939
1006
|
page,
|
|
940
1007
|
pageSize,
|
|
941
|
-
q: opts.q
|
|
1008
|
+
q: opts.q,
|
|
1009
|
+
...opts.category ? { category: opts.category } : {},
|
|
1010
|
+
...opts.channel ? { channel: opts.channel } : {}
|
|
942
1011
|
});
|
|
943
1012
|
const url = `${baseUrl}${path}`;
|
|
944
1013
|
const res = await fetch(url, buildInit("GET"));
|
|
@@ -952,17 +1021,17 @@ function createCannedResponsesModule(options) {
|
|
|
952
1021
|
const path = getCannedResponsesControllerCreateUrl();
|
|
953
1022
|
const url = `${baseUrl}${path}`;
|
|
954
1023
|
const res = await fetch(url, buildInit("POST", input));
|
|
955
|
-
return
|
|
1024
|
+
return parseEnvelopedResponse(res);
|
|
956
1025
|
},
|
|
957
1026
|
/**
|
|
958
|
-
* Partially update a canned response — title,
|
|
1027
|
+
* Partially update a canned response — title, shortcut, category, channel, and/or body.
|
|
959
1028
|
* Calls PATCH /api/v1/canned-responses/:id.
|
|
960
1029
|
*/
|
|
961
1030
|
async update(id, input) {
|
|
962
1031
|
const path = getCannedResponsesControllerPatchUrl(id);
|
|
963
1032
|
const url = `${baseUrl}${path}`;
|
|
964
1033
|
const res = await fetch(url, buildInit("PATCH", input));
|
|
965
|
-
return
|
|
1034
|
+
return parseEnvelopedResponse(res);
|
|
966
1035
|
},
|
|
967
1036
|
/**
|
|
968
1037
|
* Delete a canned response by id.
|
|
@@ -975,6 +1044,16 @@ function createCannedResponsesModule(options) {
|
|
|
975
1044
|
if (!res.ok) {
|
|
976
1045
|
return parseResponse(res);
|
|
977
1046
|
}
|
|
1047
|
+
},
|
|
1048
|
+
/**
|
|
1049
|
+
* Duplicate a canned response. The server generates a unique title and
|
|
1050
|
+
* shortcut. Calls POST /api/v1/canned-responses/:id/duplicate.
|
|
1051
|
+
*/
|
|
1052
|
+
async duplicate(id) {
|
|
1053
|
+
const path = getCannedResponsesControllerDuplicateUrl(id);
|
|
1054
|
+
const url = `${baseUrl}${path}`;
|
|
1055
|
+
const res = await fetch(url, buildInit("POST"));
|
|
1056
|
+
return parseEnvelopedResponse(res);
|
|
978
1057
|
}
|
|
979
1058
|
};
|
|
980
1059
|
}
|
|
@@ -1007,7 +1086,7 @@ function createAttachmentsModule(options) {
|
|
|
1007
1086
|
},
|
|
1008
1087
|
body: form
|
|
1009
1088
|
});
|
|
1010
|
-
return
|
|
1089
|
+
return parseEnvelopedResponse(res);
|
|
1011
1090
|
},
|
|
1012
1091
|
/**
|
|
1013
1092
|
* Get a short-lived presigned download URL for a stored attachment.
|
|
@@ -1025,7 +1104,7 @@ function createAttachmentsModule(options) {
|
|
|
1025
1104
|
...options.getHeaders()
|
|
1026
1105
|
}
|
|
1027
1106
|
});
|
|
1028
|
-
return
|
|
1107
|
+
return parseEnvelopedResponse(res);
|
|
1029
1108
|
}
|
|
1030
1109
|
};
|
|
1031
1110
|
}
|
|
@@ -1033,14 +1112,15 @@ function createAttachmentsModule(options) {
|
|
|
1033
1112
|
// src/whatsapp-business-accounts/whatsapp-business-accounts.ts
|
|
1034
1113
|
function createWhatsAppBusinessAccountsModule(options) {
|
|
1035
1114
|
const baseUrl = options.baseUrl;
|
|
1036
|
-
function buildInit(method) {
|
|
1115
|
+
function buildInit(method, body) {
|
|
1037
1116
|
return {
|
|
1038
1117
|
method,
|
|
1039
1118
|
credentials: options.getCredentials(),
|
|
1040
1119
|
headers: {
|
|
1041
1120
|
"Content-Type": "application/json",
|
|
1042
1121
|
...options.getHeaders()
|
|
1043
|
-
}
|
|
1122
|
+
},
|
|
1123
|
+
...body !== void 0 ? { body: JSON.stringify(body) } : {}
|
|
1044
1124
|
};
|
|
1045
1125
|
}
|
|
1046
1126
|
return {
|
|
@@ -1075,6 +1155,44 @@ function createWhatsAppBusinessAccountsModule(options) {
|
|
|
1075
1155
|
const url = `${baseUrl}${path}`;
|
|
1076
1156
|
const res = await fetch(url, buildInit("GET"));
|
|
1077
1157
|
return parseEnvelopedResponse(res);
|
|
1158
|
+
},
|
|
1159
|
+
/**
|
|
1160
|
+
* Create a WhatsApp Business Account — writes the secret to the
|
|
1161
|
+
* SecretsProvider and the non-secret row to the DB; returns the
|
|
1162
|
+
* non-secret view (no `secretRef` exposed).
|
|
1163
|
+
* Calls POST /api/v1/tenants/:id/whatsapp-business-accounts.
|
|
1164
|
+
*
|
|
1165
|
+
* @example
|
|
1166
|
+
* const waba = await sdk.whatsappBusinessAccounts.create('ten_acmecorp', {
|
|
1167
|
+
* wabaId: '123456789012345',
|
|
1168
|
+
* name: 'Acme WhatsApp',
|
|
1169
|
+
* secret: { accessToken, appSecret, webhookVerifyToken },
|
|
1170
|
+
* })
|
|
1171
|
+
*/
|
|
1172
|
+
async create(tenantId, body) {
|
|
1173
|
+
const path = getWhatsAppBusinessAccountsControllerCreateUrl(tenantId);
|
|
1174
|
+
const url = `${baseUrl}${path}`;
|
|
1175
|
+
const res = await fetch(url, buildInit("POST", body));
|
|
1176
|
+
return parseEnvelopedResponse(res);
|
|
1177
|
+
},
|
|
1178
|
+
/**
|
|
1179
|
+
* Rename a WhatsApp Business Account (name only — secret material is
|
|
1180
|
+
* immutable through this endpoint).
|
|
1181
|
+
* Calls PATCH /api/v1/tenants/:id/whatsapp-business-accounts/:wabaRowId.
|
|
1182
|
+
*
|
|
1183
|
+
* @example
|
|
1184
|
+
* await sdk.whatsappBusinessAccounts.update('ten_acmecorp', 'waba_row_001', {
|
|
1185
|
+
* name: 'Renamed WhatsApp',
|
|
1186
|
+
* })
|
|
1187
|
+
*/
|
|
1188
|
+
async update(tenantId, wabaRowId, body) {
|
|
1189
|
+
const path = getWhatsAppBusinessAccountsControllerUpdateNameUrl(
|
|
1190
|
+
tenantId,
|
|
1191
|
+
wabaRowId
|
|
1192
|
+
);
|
|
1193
|
+
const url = `${baseUrl}${path}`;
|
|
1194
|
+
const res = await fetch(url, buildInit("PATCH", body));
|
|
1195
|
+
return parseEnvelopedResponse(res);
|
|
1078
1196
|
}
|
|
1079
1197
|
};
|
|
1080
1198
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digisglobal/omnivox-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"scripts": {
|
|
39
39
|
"codegen": "orval --config orval.config.ts && prettier --write src/_generated",
|
|
40
40
|
"build": "tsup",
|
|
41
|
+
"dev": "tsup --watch",
|
|
41
42
|
"typecheck": "tsc --noEmit",
|
|
42
43
|
"test": "vitest run",
|
|
43
44
|
"lint": "eslint .",
|