@digisglobal/omnivox-sdk 0.6.0 → 0.6.1
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 +15 -10
- package/dist/index.js +15 -10
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -69,6 +69,11 @@ async function parseResponse(res) {
|
|
|
69
69
|
}
|
|
70
70
|
return text ? JSON.parse(text) : void 0;
|
|
71
71
|
}
|
|
72
|
+
async function parseEnvelopedResponse(res) {
|
|
73
|
+
if (NO_BODY_STATUSES.includes(res.status)) return void 0;
|
|
74
|
+
const envelope = await parseResponse(res);
|
|
75
|
+
return envelope.data;
|
|
76
|
+
}
|
|
72
77
|
|
|
73
78
|
// src/auth/auth-me.ts
|
|
74
79
|
function createAuthMeModule(options) {
|
|
@@ -823,7 +828,7 @@ function createTemplatesModule(options) {
|
|
|
823
828
|
const path = getTemplatesControllerAuthorDraftUrl(tenantId, wabaId);
|
|
824
829
|
const url = `${baseUrl}${path}`;
|
|
825
830
|
const res = await fetch(url, buildInit("POST", input));
|
|
826
|
-
return
|
|
831
|
+
return parseEnvelopedResponse(res);
|
|
827
832
|
},
|
|
828
833
|
/**
|
|
829
834
|
* Import all APPROVED templates from the WABA into the system (immediately sendable).
|
|
@@ -833,7 +838,7 @@ function createTemplatesModule(options) {
|
|
|
833
838
|
const path = getTemplatesControllerImportApprovedUrl(tenantId, wabaId);
|
|
834
839
|
const url = `${baseUrl}${path}`;
|
|
835
840
|
const res = await fetch(url, buildInit("POST"));
|
|
836
|
-
return
|
|
841
|
+
return parseEnvelopedResponse(res);
|
|
837
842
|
},
|
|
838
843
|
/**
|
|
839
844
|
* Fork a new DRAFT version from the latest version of a template (update).
|
|
@@ -847,7 +852,7 @@ function createTemplatesModule(options) {
|
|
|
847
852
|
);
|
|
848
853
|
const url = `${baseUrl}${path}`;
|
|
849
854
|
const res = await fetch(url, buildInit("PATCH", input));
|
|
850
|
-
return
|
|
855
|
+
return parseEnvelopedResponse(res);
|
|
851
856
|
},
|
|
852
857
|
/**
|
|
853
858
|
* List all versions and status events for a template in chronological order.
|
|
@@ -861,7 +866,7 @@ function createTemplatesModule(options) {
|
|
|
861
866
|
);
|
|
862
867
|
const url = `${baseUrl}${path}`;
|
|
863
868
|
const res = await fetch(url, buildInit("GET"));
|
|
864
|
-
return
|
|
869
|
+
return parseEnvelopedResponse(res);
|
|
865
870
|
},
|
|
866
871
|
/**
|
|
867
872
|
* Submit a DRAFT template version to Meta for review and approval (DRAFT → PENDING_APPROVAL).
|
|
@@ -875,7 +880,7 @@ function createTemplatesModule(options) {
|
|
|
875
880
|
);
|
|
876
881
|
const url = `${baseUrl}${path}`;
|
|
877
882
|
const res = await fetch(url, buildInit("POST"));
|
|
878
|
-
return
|
|
883
|
+
return parseEnvelopedResponse(res);
|
|
879
884
|
}
|
|
880
885
|
},
|
|
881
886
|
/**
|
|
@@ -890,7 +895,7 @@ function createTemplatesModule(options) {
|
|
|
890
895
|
const path = getEmailTemplatesControllerCreateUrl();
|
|
891
896
|
const url = `${baseUrl}${path}`;
|
|
892
897
|
const res = await fetch(url, buildInit("POST", input));
|
|
893
|
-
return
|
|
898
|
+
return parseEnvelopedResponse(res);
|
|
894
899
|
},
|
|
895
900
|
/**
|
|
896
901
|
* List Email templates for the authenticated tenant (paginated).
|
|
@@ -911,7 +916,7 @@ function createTemplatesModule(options) {
|
|
|
911
916
|
const path = getEmailTemplatesControllerGetByIdUrl(id);
|
|
912
917
|
const url = `${baseUrl}${path}`;
|
|
913
918
|
const res = await fetch(url, buildInit("GET"));
|
|
914
|
-
return
|
|
919
|
+
return parseEnvelopedResponse(res);
|
|
915
920
|
},
|
|
916
921
|
/**
|
|
917
922
|
* Partially update an Email template — name, subject, htmlBody, textBody, and/or variableSchema; omitted fields unchanged.
|
|
@@ -921,7 +926,7 @@ function createTemplatesModule(options) {
|
|
|
921
926
|
const path = getEmailTemplatesControllerPatchUrl(id);
|
|
922
927
|
const url = `${baseUrl}${path}`;
|
|
923
928
|
const res = await fetch(url, buildInit("PATCH", input));
|
|
924
|
-
return
|
|
929
|
+
return parseEnvelopedResponse(res);
|
|
925
930
|
},
|
|
926
931
|
/**
|
|
927
932
|
* Delete an Email template.
|
|
@@ -1095,7 +1100,7 @@ function createWhatsAppBusinessAccountsModule(options) {
|
|
|
1095
1100
|
const path = getWhatsAppBusinessAccountsControllerListUrl(tenantId);
|
|
1096
1101
|
const url = `${baseUrl}${path}`;
|
|
1097
1102
|
const res = await fetch(url, buildInit("GET"));
|
|
1098
|
-
return
|
|
1103
|
+
return parseEnvelopedResponse(res);
|
|
1099
1104
|
},
|
|
1100
1105
|
/**
|
|
1101
1106
|
* Get a single WhatsApp Business Account by its row id.
|
|
@@ -1112,7 +1117,7 @@ function createWhatsAppBusinessAccountsModule(options) {
|
|
|
1112
1117
|
);
|
|
1113
1118
|
const url = `${baseUrl}${path}`;
|
|
1114
1119
|
const res = await fetch(url, buildInit("GET"));
|
|
1115
|
-
return
|
|
1120
|
+
return parseEnvelopedResponse(res);
|
|
1116
1121
|
}
|
|
1117
1122
|
};
|
|
1118
1123
|
}
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,11 @@ async function parseResponse(res) {
|
|
|
26
26
|
}
|
|
27
27
|
return text ? JSON.parse(text) : void 0;
|
|
28
28
|
}
|
|
29
|
+
async function parseEnvelopedResponse(res) {
|
|
30
|
+
if (NO_BODY_STATUSES.includes(res.status)) return void 0;
|
|
31
|
+
const envelope = await parseResponse(res);
|
|
32
|
+
return envelope.data;
|
|
33
|
+
}
|
|
29
34
|
|
|
30
35
|
// src/auth/auth-me.ts
|
|
31
36
|
function createAuthMeModule(options) {
|
|
@@ -780,7 +785,7 @@ function createTemplatesModule(options) {
|
|
|
780
785
|
const path = getTemplatesControllerAuthorDraftUrl(tenantId, wabaId);
|
|
781
786
|
const url = `${baseUrl}${path}`;
|
|
782
787
|
const res = await fetch(url, buildInit("POST", input));
|
|
783
|
-
return
|
|
788
|
+
return parseEnvelopedResponse(res);
|
|
784
789
|
},
|
|
785
790
|
/**
|
|
786
791
|
* Import all APPROVED templates from the WABA into the system (immediately sendable).
|
|
@@ -790,7 +795,7 @@ function createTemplatesModule(options) {
|
|
|
790
795
|
const path = getTemplatesControllerImportApprovedUrl(tenantId, wabaId);
|
|
791
796
|
const url = `${baseUrl}${path}`;
|
|
792
797
|
const res = await fetch(url, buildInit("POST"));
|
|
793
|
-
return
|
|
798
|
+
return parseEnvelopedResponse(res);
|
|
794
799
|
},
|
|
795
800
|
/**
|
|
796
801
|
* Fork a new DRAFT version from the latest version of a template (update).
|
|
@@ -804,7 +809,7 @@ function createTemplatesModule(options) {
|
|
|
804
809
|
);
|
|
805
810
|
const url = `${baseUrl}${path}`;
|
|
806
811
|
const res = await fetch(url, buildInit("PATCH", input));
|
|
807
|
-
return
|
|
812
|
+
return parseEnvelopedResponse(res);
|
|
808
813
|
},
|
|
809
814
|
/**
|
|
810
815
|
* List all versions and status events for a template in chronological order.
|
|
@@ -818,7 +823,7 @@ function createTemplatesModule(options) {
|
|
|
818
823
|
);
|
|
819
824
|
const url = `${baseUrl}${path}`;
|
|
820
825
|
const res = await fetch(url, buildInit("GET"));
|
|
821
|
-
return
|
|
826
|
+
return parseEnvelopedResponse(res);
|
|
822
827
|
},
|
|
823
828
|
/**
|
|
824
829
|
* Submit a DRAFT template version to Meta for review and approval (DRAFT → PENDING_APPROVAL).
|
|
@@ -832,7 +837,7 @@ function createTemplatesModule(options) {
|
|
|
832
837
|
);
|
|
833
838
|
const url = `${baseUrl}${path}`;
|
|
834
839
|
const res = await fetch(url, buildInit("POST"));
|
|
835
|
-
return
|
|
840
|
+
return parseEnvelopedResponse(res);
|
|
836
841
|
}
|
|
837
842
|
},
|
|
838
843
|
/**
|
|
@@ -847,7 +852,7 @@ function createTemplatesModule(options) {
|
|
|
847
852
|
const path = getEmailTemplatesControllerCreateUrl();
|
|
848
853
|
const url = `${baseUrl}${path}`;
|
|
849
854
|
const res = await fetch(url, buildInit("POST", input));
|
|
850
|
-
return
|
|
855
|
+
return parseEnvelopedResponse(res);
|
|
851
856
|
},
|
|
852
857
|
/**
|
|
853
858
|
* List Email templates for the authenticated tenant (paginated).
|
|
@@ -868,7 +873,7 @@ function createTemplatesModule(options) {
|
|
|
868
873
|
const path = getEmailTemplatesControllerGetByIdUrl(id);
|
|
869
874
|
const url = `${baseUrl}${path}`;
|
|
870
875
|
const res = await fetch(url, buildInit("GET"));
|
|
871
|
-
return
|
|
876
|
+
return parseEnvelopedResponse(res);
|
|
872
877
|
},
|
|
873
878
|
/**
|
|
874
879
|
* Partially update an Email template — name, subject, htmlBody, textBody, and/or variableSchema; omitted fields unchanged.
|
|
@@ -878,7 +883,7 @@ function createTemplatesModule(options) {
|
|
|
878
883
|
const path = getEmailTemplatesControllerPatchUrl(id);
|
|
879
884
|
const url = `${baseUrl}${path}`;
|
|
880
885
|
const res = await fetch(url, buildInit("PATCH", input));
|
|
881
|
-
return
|
|
886
|
+
return parseEnvelopedResponse(res);
|
|
882
887
|
},
|
|
883
888
|
/**
|
|
884
889
|
* Delete an Email template.
|
|
@@ -1052,7 +1057,7 @@ function createWhatsAppBusinessAccountsModule(options) {
|
|
|
1052
1057
|
const path = getWhatsAppBusinessAccountsControllerListUrl(tenantId);
|
|
1053
1058
|
const url = `${baseUrl}${path}`;
|
|
1054
1059
|
const res = await fetch(url, buildInit("GET"));
|
|
1055
|
-
return
|
|
1060
|
+
return parseEnvelopedResponse(res);
|
|
1056
1061
|
},
|
|
1057
1062
|
/**
|
|
1058
1063
|
* Get a single WhatsApp Business Account by its row id.
|
|
@@ -1069,7 +1074,7 @@ function createWhatsAppBusinessAccountsModule(options) {
|
|
|
1069
1074
|
);
|
|
1070
1075
|
const url = `${baseUrl}${path}`;
|
|
1071
1076
|
const res = await fetch(url, buildInit("GET"));
|
|
1072
|
-
return
|
|
1077
|
+
return parseEnvelopedResponse(res);
|
|
1073
1078
|
}
|
|
1074
1079
|
};
|
|
1075
1080
|
}
|