@unsent/sdk 0.25.3 → 1.0.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/README.md +183 -103
- package/dist/index.d.mts +350 -87
- package/dist/index.d.ts +350 -87
- package/dist/index.js +51 -7
- package/dist/index.mjs +50 -7
- package/package.json +24 -5
package/dist/index.d.ts
CHANGED
|
@@ -36,9 +36,9 @@ interface paths {
|
|
|
36
36
|
"application/json": {
|
|
37
37
|
/**
|
|
38
38
|
* @description The ID of the domain
|
|
39
|
-
* @example
|
|
39
|
+
* @example 0Lleb1FOUnB60jSueJ/mkPId1vrdB68T8/u9tiInsi4=
|
|
40
40
|
*/
|
|
41
|
-
id:
|
|
41
|
+
id: string;
|
|
42
42
|
/**
|
|
43
43
|
* @description The name of the domain
|
|
44
44
|
* @example example.com
|
|
@@ -46,9 +46,9 @@ interface paths {
|
|
|
46
46
|
name: string;
|
|
47
47
|
/**
|
|
48
48
|
* @description The ID of the team
|
|
49
|
-
* @example
|
|
49
|
+
* @example jonVNF8M+EbJObaRAz2XBHnoJ6Add/tazP9lfOiPJ3E=
|
|
50
50
|
*/
|
|
51
|
-
teamId:
|
|
51
|
+
teamId: string;
|
|
52
52
|
/** @enum {string} */
|
|
53
53
|
status: "NOT_STARTED" | "PENDING" | "SUCCESS" | "FAILED" | "TEMPORARY_FAILURE";
|
|
54
54
|
/** @default us-east-1 */
|
|
@@ -133,9 +133,9 @@ interface paths {
|
|
|
133
133
|
"application/json": {
|
|
134
134
|
/**
|
|
135
135
|
* @description The ID of the domain
|
|
136
|
-
* @example
|
|
136
|
+
* @example 0Lleb1FOUnB60jSueJ/mkPId1vrdB68T8/u9tiInsi4=
|
|
137
137
|
*/
|
|
138
|
-
id:
|
|
138
|
+
id: string;
|
|
139
139
|
/**
|
|
140
140
|
* @description The name of the domain
|
|
141
141
|
* @example example.com
|
|
@@ -143,9 +143,9 @@ interface paths {
|
|
|
143
143
|
name: string;
|
|
144
144
|
/**
|
|
145
145
|
* @description The ID of the team
|
|
146
|
-
* @example
|
|
146
|
+
* @example jonVNF8M+EbJObaRAz2XBHnoJ6Add/tazP9lfOiPJ3E=
|
|
147
147
|
*/
|
|
148
|
-
teamId:
|
|
148
|
+
teamId: string;
|
|
149
149
|
/** @enum {string} */
|
|
150
150
|
status: "NOT_STARTED" | "PENDING" | "SUCCESS" | "FAILED" | "TEMPORARY_FAILURE";
|
|
151
151
|
/** @default us-east-1 */
|
|
@@ -223,7 +223,7 @@ interface paths {
|
|
|
223
223
|
query?: never;
|
|
224
224
|
header?: never;
|
|
225
225
|
path: {
|
|
226
|
-
id:
|
|
226
|
+
id: string;
|
|
227
227
|
};
|
|
228
228
|
cookie?: never;
|
|
229
229
|
};
|
|
@@ -283,7 +283,7 @@ interface paths {
|
|
|
283
283
|
query?: never;
|
|
284
284
|
header?: never;
|
|
285
285
|
path: {
|
|
286
|
-
id:
|
|
286
|
+
id: string;
|
|
287
287
|
};
|
|
288
288
|
cookie?: never;
|
|
289
289
|
};
|
|
@@ -298,9 +298,9 @@ interface paths {
|
|
|
298
298
|
"application/json": {
|
|
299
299
|
/**
|
|
300
300
|
* @description The ID of the domain
|
|
301
|
-
* @example
|
|
301
|
+
* @example 0Lleb1FOUnB60jSueJ/mkPId1vrdB68T8/u9tiInsi4=
|
|
302
302
|
*/
|
|
303
|
-
id:
|
|
303
|
+
id: string;
|
|
304
304
|
/**
|
|
305
305
|
* @description The name of the domain
|
|
306
306
|
* @example example.com
|
|
@@ -308,9 +308,9 @@ interface paths {
|
|
|
308
308
|
name: string;
|
|
309
309
|
/**
|
|
310
310
|
* @description The ID of the team
|
|
311
|
-
* @example
|
|
311
|
+
* @example jonVNF8M+EbJObaRAz2XBHnoJ6Add/tazP9lfOiPJ3E=
|
|
312
312
|
*/
|
|
313
|
-
teamId:
|
|
313
|
+
teamId: string;
|
|
314
314
|
/** @enum {string} */
|
|
315
315
|
status: "NOT_STARTED" | "PENDING" | "SUCCESS" | "FAILED" | "TEMPORARY_FAILURE";
|
|
316
316
|
/** @default us-east-1 */
|
|
@@ -376,7 +376,7 @@ interface paths {
|
|
|
376
376
|
query?: never;
|
|
377
377
|
header?: never;
|
|
378
378
|
path: {
|
|
379
|
-
id:
|
|
379
|
+
id: string;
|
|
380
380
|
};
|
|
381
381
|
cookie?: never;
|
|
382
382
|
};
|
|
@@ -389,74 +389,26 @@ interface paths {
|
|
|
389
389
|
};
|
|
390
390
|
content: {
|
|
391
391
|
"application/json": {
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
clickTracking: boolean;
|
|
413
|
-
/** @default false */
|
|
414
|
-
openTracking: boolean;
|
|
415
|
-
publicKey: string;
|
|
416
|
-
dkimStatus?: string | null;
|
|
417
|
-
spfDetails?: string | null;
|
|
418
|
-
createdAt: string;
|
|
419
|
-
updatedAt: string;
|
|
420
|
-
/** @default false */
|
|
421
|
-
dmarcAdded: boolean;
|
|
422
|
-
/** @default false */
|
|
423
|
-
isVerifying: boolean;
|
|
424
|
-
errorMessage?: string | null;
|
|
425
|
-
subdomain?: string | null;
|
|
426
|
-
verificationError?: string | null;
|
|
427
|
-
lastCheckedTime?: string | null;
|
|
428
|
-
dnsRecords: {
|
|
429
|
-
/**
|
|
430
|
-
* @description DNS record type
|
|
431
|
-
* @example TXT
|
|
432
|
-
* @enum {string}
|
|
433
|
-
*/
|
|
434
|
-
type: "MX" | "TXT";
|
|
435
|
-
/**
|
|
436
|
-
* @description DNS record name
|
|
437
|
-
* @example mail
|
|
438
|
-
*/
|
|
439
|
-
name: string;
|
|
440
|
-
/**
|
|
441
|
-
* @description DNS record value
|
|
442
|
-
* @example v=spf1 include:amazonses.com ~all
|
|
443
|
-
*/
|
|
444
|
-
value: string;
|
|
445
|
-
/**
|
|
446
|
-
* @description DNS record TTL
|
|
447
|
-
* @example Auto
|
|
448
|
-
*/
|
|
449
|
-
ttl: string;
|
|
450
|
-
/**
|
|
451
|
-
* @description DNS record priority
|
|
452
|
-
* @example 10
|
|
453
|
-
*/
|
|
454
|
-
priority?: string | null;
|
|
455
|
-
/** @enum {string} */
|
|
456
|
-
status: "NOT_STARTED" | "PENDING" | "SUCCESS" | "FAILED" | "TEMPORARY_FAILURE";
|
|
457
|
-
/** @description Whether the record is recommended */
|
|
458
|
-
recommended?: boolean;
|
|
459
|
-
}[];
|
|
392
|
+
success: boolean;
|
|
393
|
+
message: string;
|
|
394
|
+
};
|
|
395
|
+
};
|
|
396
|
+
};
|
|
397
|
+
/** @description Forbidden - API key doesn't have access */
|
|
398
|
+
403: {
|
|
399
|
+
headers: {
|
|
400
|
+
[name: string]: unknown;
|
|
401
|
+
};
|
|
402
|
+
content?: never;
|
|
403
|
+
};
|
|
404
|
+
/** @description Domain not found */
|
|
405
|
+
404: {
|
|
406
|
+
headers: {
|
|
407
|
+
[name: string]: unknown;
|
|
408
|
+
};
|
|
409
|
+
content: {
|
|
410
|
+
"application/json": {
|
|
411
|
+
error: string;
|
|
460
412
|
};
|
|
461
413
|
};
|
|
462
414
|
};
|
|
@@ -493,7 +445,7 @@ interface paths {
|
|
|
493
445
|
content: {
|
|
494
446
|
"application/json": {
|
|
495
447
|
id: string;
|
|
496
|
-
teamId:
|
|
448
|
+
teamId: string;
|
|
497
449
|
to: string | string[];
|
|
498
450
|
replyTo?: string | string[];
|
|
499
451
|
cc?: string | string[];
|
|
@@ -599,7 +551,7 @@ interface paths {
|
|
|
599
551
|
latestStatus: "SCHEDULED" | "QUEUED" | "SENT" | "DELIVERY_DELAYED" | "BOUNCED" | "REJECTED" | "RENDERING_FAILURE" | "DELIVERED" | "OPENED" | "CLICKED" | "COMPLAINED" | "FAILED" | "CANCELLED" | "SUPPRESSED" | null;
|
|
600
552
|
/** Format: date-time */
|
|
601
553
|
scheduledAt: string | null;
|
|
602
|
-
domainId:
|
|
554
|
+
domainId: string | null;
|
|
603
555
|
}[];
|
|
604
556
|
count: number;
|
|
605
557
|
};
|
|
@@ -1009,6 +961,282 @@ interface paths {
|
|
|
1009
961
|
};
|
|
1010
962
|
trace?: never;
|
|
1011
963
|
};
|
|
964
|
+
"/v1/campaigns": {
|
|
965
|
+
parameters: {
|
|
966
|
+
query?: never;
|
|
967
|
+
header?: never;
|
|
968
|
+
path?: never;
|
|
969
|
+
cookie?: never;
|
|
970
|
+
};
|
|
971
|
+
get?: never;
|
|
972
|
+
put?: never;
|
|
973
|
+
post: {
|
|
974
|
+
parameters: {
|
|
975
|
+
query?: never;
|
|
976
|
+
header?: never;
|
|
977
|
+
path?: never;
|
|
978
|
+
cookie?: never;
|
|
979
|
+
};
|
|
980
|
+
requestBody: {
|
|
981
|
+
content: {
|
|
982
|
+
"application/json": {
|
|
983
|
+
name: string;
|
|
984
|
+
from: string;
|
|
985
|
+
subject: string;
|
|
986
|
+
previewText?: string;
|
|
987
|
+
contactBookId: string;
|
|
988
|
+
content?: string;
|
|
989
|
+
html?: string;
|
|
990
|
+
replyTo?: string | string[];
|
|
991
|
+
cc?: string | string[];
|
|
992
|
+
bcc?: string | string[];
|
|
993
|
+
sendNow?: boolean;
|
|
994
|
+
/** @description Timestamp in ISO 8601 format or natural language (e.g., 'tomorrow 9am', 'next monday 10:30') */
|
|
995
|
+
scheduledAt?: string;
|
|
996
|
+
batchSize?: number;
|
|
997
|
+
};
|
|
998
|
+
};
|
|
999
|
+
};
|
|
1000
|
+
responses: {
|
|
1001
|
+
/** @description Create a campaign */
|
|
1002
|
+
200: {
|
|
1003
|
+
headers: {
|
|
1004
|
+
[name: string]: unknown;
|
|
1005
|
+
};
|
|
1006
|
+
content: {
|
|
1007
|
+
"application/json": {
|
|
1008
|
+
id: string;
|
|
1009
|
+
name: string;
|
|
1010
|
+
from: string;
|
|
1011
|
+
subject: string;
|
|
1012
|
+
previewText: string | null;
|
|
1013
|
+
contactBookId: string | null;
|
|
1014
|
+
html: string | null;
|
|
1015
|
+
content: string | null;
|
|
1016
|
+
status: string;
|
|
1017
|
+
/** Format: date-time */
|
|
1018
|
+
scheduledAt: string | null;
|
|
1019
|
+
batchSize: number;
|
|
1020
|
+
batchWindowMinutes: number;
|
|
1021
|
+
total: number;
|
|
1022
|
+
sent: number;
|
|
1023
|
+
delivered: number;
|
|
1024
|
+
opened: number;
|
|
1025
|
+
clicked: number;
|
|
1026
|
+
unsubscribed: number;
|
|
1027
|
+
bounced: number;
|
|
1028
|
+
hardBounced: number;
|
|
1029
|
+
complained: number;
|
|
1030
|
+
replyTo: string[];
|
|
1031
|
+
cc: string[];
|
|
1032
|
+
bcc: string[];
|
|
1033
|
+
/** Format: date-time */
|
|
1034
|
+
createdAt: string;
|
|
1035
|
+
/** Format: date-time */
|
|
1036
|
+
updatedAt: string;
|
|
1037
|
+
};
|
|
1038
|
+
};
|
|
1039
|
+
};
|
|
1040
|
+
};
|
|
1041
|
+
};
|
|
1042
|
+
delete?: never;
|
|
1043
|
+
options?: never;
|
|
1044
|
+
head?: never;
|
|
1045
|
+
patch?: never;
|
|
1046
|
+
trace?: never;
|
|
1047
|
+
};
|
|
1048
|
+
"/v1/campaigns/{campaignId}": {
|
|
1049
|
+
parameters: {
|
|
1050
|
+
query?: never;
|
|
1051
|
+
header?: never;
|
|
1052
|
+
path?: never;
|
|
1053
|
+
cookie?: never;
|
|
1054
|
+
};
|
|
1055
|
+
get: {
|
|
1056
|
+
parameters: {
|
|
1057
|
+
query?: never;
|
|
1058
|
+
header?: never;
|
|
1059
|
+
path: {
|
|
1060
|
+
campaignId: string;
|
|
1061
|
+
};
|
|
1062
|
+
cookie?: never;
|
|
1063
|
+
};
|
|
1064
|
+
requestBody?: never;
|
|
1065
|
+
responses: {
|
|
1066
|
+
/** @description Get campaign details */
|
|
1067
|
+
200: {
|
|
1068
|
+
headers: {
|
|
1069
|
+
[name: string]: unknown;
|
|
1070
|
+
};
|
|
1071
|
+
content: {
|
|
1072
|
+
"application/json": {
|
|
1073
|
+
id: string;
|
|
1074
|
+
name: string;
|
|
1075
|
+
from: string;
|
|
1076
|
+
subject: string;
|
|
1077
|
+
previewText: string | null;
|
|
1078
|
+
contactBookId: string | null;
|
|
1079
|
+
html: string | null;
|
|
1080
|
+
content: string | null;
|
|
1081
|
+
status: string;
|
|
1082
|
+
/** Format: date-time */
|
|
1083
|
+
scheduledAt: string | null;
|
|
1084
|
+
batchSize: number;
|
|
1085
|
+
batchWindowMinutes: number;
|
|
1086
|
+
total: number;
|
|
1087
|
+
sent: number;
|
|
1088
|
+
delivered: number;
|
|
1089
|
+
opened: number;
|
|
1090
|
+
clicked: number;
|
|
1091
|
+
unsubscribed: number;
|
|
1092
|
+
bounced: number;
|
|
1093
|
+
hardBounced: number;
|
|
1094
|
+
complained: number;
|
|
1095
|
+
replyTo: string[];
|
|
1096
|
+
cc: string[];
|
|
1097
|
+
bcc: string[];
|
|
1098
|
+
/** Format: date-time */
|
|
1099
|
+
createdAt: string;
|
|
1100
|
+
/** Format: date-time */
|
|
1101
|
+
updatedAt: string;
|
|
1102
|
+
};
|
|
1103
|
+
};
|
|
1104
|
+
};
|
|
1105
|
+
};
|
|
1106
|
+
};
|
|
1107
|
+
put?: never;
|
|
1108
|
+
post?: never;
|
|
1109
|
+
delete?: never;
|
|
1110
|
+
options?: never;
|
|
1111
|
+
head?: never;
|
|
1112
|
+
patch?: never;
|
|
1113
|
+
trace?: never;
|
|
1114
|
+
};
|
|
1115
|
+
"/v1/campaigns/{campaignId}/schedule": {
|
|
1116
|
+
parameters: {
|
|
1117
|
+
query?: never;
|
|
1118
|
+
header?: never;
|
|
1119
|
+
path?: never;
|
|
1120
|
+
cookie?: never;
|
|
1121
|
+
};
|
|
1122
|
+
get?: never;
|
|
1123
|
+
put?: never;
|
|
1124
|
+
post: {
|
|
1125
|
+
parameters: {
|
|
1126
|
+
query?: never;
|
|
1127
|
+
header?: never;
|
|
1128
|
+
path: {
|
|
1129
|
+
campaignId: string;
|
|
1130
|
+
};
|
|
1131
|
+
cookie?: never;
|
|
1132
|
+
};
|
|
1133
|
+
requestBody: {
|
|
1134
|
+
content: {
|
|
1135
|
+
"application/json": {
|
|
1136
|
+
/** @description Timestamp in ISO 8601 format or natural language (e.g., 'tomorrow 9am', 'next monday 10:30') */
|
|
1137
|
+
scheduledAt?: string;
|
|
1138
|
+
batchSize?: number;
|
|
1139
|
+
};
|
|
1140
|
+
};
|
|
1141
|
+
};
|
|
1142
|
+
responses: {
|
|
1143
|
+
/** @description Schedule a campaign */
|
|
1144
|
+
200: {
|
|
1145
|
+
headers: {
|
|
1146
|
+
[name: string]: unknown;
|
|
1147
|
+
};
|
|
1148
|
+
content: {
|
|
1149
|
+
"application/json": {
|
|
1150
|
+
success: boolean;
|
|
1151
|
+
};
|
|
1152
|
+
};
|
|
1153
|
+
};
|
|
1154
|
+
};
|
|
1155
|
+
};
|
|
1156
|
+
delete?: never;
|
|
1157
|
+
options?: never;
|
|
1158
|
+
head?: never;
|
|
1159
|
+
patch?: never;
|
|
1160
|
+
trace?: never;
|
|
1161
|
+
};
|
|
1162
|
+
"/v1/campaigns/{campaignId}/pause": {
|
|
1163
|
+
parameters: {
|
|
1164
|
+
query?: never;
|
|
1165
|
+
header?: never;
|
|
1166
|
+
path?: never;
|
|
1167
|
+
cookie?: never;
|
|
1168
|
+
};
|
|
1169
|
+
get?: never;
|
|
1170
|
+
put?: never;
|
|
1171
|
+
post: {
|
|
1172
|
+
parameters: {
|
|
1173
|
+
query?: never;
|
|
1174
|
+
header?: never;
|
|
1175
|
+
path: {
|
|
1176
|
+
campaignId: string;
|
|
1177
|
+
};
|
|
1178
|
+
cookie?: never;
|
|
1179
|
+
};
|
|
1180
|
+
requestBody?: never;
|
|
1181
|
+
responses: {
|
|
1182
|
+
/** @description Pause a campaign */
|
|
1183
|
+
200: {
|
|
1184
|
+
headers: {
|
|
1185
|
+
[name: string]: unknown;
|
|
1186
|
+
};
|
|
1187
|
+
content: {
|
|
1188
|
+
"application/json": {
|
|
1189
|
+
success: boolean;
|
|
1190
|
+
};
|
|
1191
|
+
};
|
|
1192
|
+
};
|
|
1193
|
+
};
|
|
1194
|
+
};
|
|
1195
|
+
delete?: never;
|
|
1196
|
+
options?: never;
|
|
1197
|
+
head?: never;
|
|
1198
|
+
patch?: never;
|
|
1199
|
+
trace?: never;
|
|
1200
|
+
};
|
|
1201
|
+
"/v1/campaigns/{campaignId}/resume": {
|
|
1202
|
+
parameters: {
|
|
1203
|
+
query?: never;
|
|
1204
|
+
header?: never;
|
|
1205
|
+
path?: never;
|
|
1206
|
+
cookie?: never;
|
|
1207
|
+
};
|
|
1208
|
+
get?: never;
|
|
1209
|
+
put?: never;
|
|
1210
|
+
post: {
|
|
1211
|
+
parameters: {
|
|
1212
|
+
query?: never;
|
|
1213
|
+
header?: never;
|
|
1214
|
+
path: {
|
|
1215
|
+
campaignId: string;
|
|
1216
|
+
};
|
|
1217
|
+
cookie?: never;
|
|
1218
|
+
};
|
|
1219
|
+
requestBody?: never;
|
|
1220
|
+
responses: {
|
|
1221
|
+
/** @description Resume a campaign */
|
|
1222
|
+
200: {
|
|
1223
|
+
headers: {
|
|
1224
|
+
[name: string]: unknown;
|
|
1225
|
+
};
|
|
1226
|
+
content: {
|
|
1227
|
+
"application/json": {
|
|
1228
|
+
success: boolean;
|
|
1229
|
+
};
|
|
1230
|
+
};
|
|
1231
|
+
};
|
|
1232
|
+
};
|
|
1233
|
+
};
|
|
1234
|
+
delete?: never;
|
|
1235
|
+
options?: never;
|
|
1236
|
+
head?: never;
|
|
1237
|
+
patch?: never;
|
|
1238
|
+
trace?: never;
|
|
1239
|
+
};
|
|
1012
1240
|
}
|
|
1013
1241
|
|
|
1014
1242
|
type CreateContactPayload = paths["/v1/contactBooks/{contactBookId}/contacts"]["post"]["requestBody"]["content"]["application/json"];
|
|
@@ -1144,12 +1372,47 @@ declare class Domains {
|
|
|
1144
1372
|
delete(id: number): Promise<DeleteDomainResponse>;
|
|
1145
1373
|
}
|
|
1146
1374
|
|
|
1375
|
+
type CreateCampaignPayload = paths["/v1/campaigns"]["post"]["requestBody"]["content"]["application/json"];
|
|
1376
|
+
type CreateCampaignResponseSuccess = paths["/v1/campaigns"]["post"]["responses"]["200"]["content"]["application/json"];
|
|
1377
|
+
type CreateCampaignResponse = {
|
|
1378
|
+
data: CreateCampaignResponseSuccess | null;
|
|
1379
|
+
error: ErrorResponse | null;
|
|
1380
|
+
};
|
|
1381
|
+
type GetCampaignResponseSuccess = paths["/v1/campaigns/{campaignId}"]["get"]["responses"]["200"]["content"]["application/json"];
|
|
1382
|
+
type GetCampaignResponse = {
|
|
1383
|
+
data: GetCampaignResponseSuccess | null;
|
|
1384
|
+
error: ErrorResponse | null;
|
|
1385
|
+
};
|
|
1386
|
+
type ScheduleCampaignPayload = paths["/v1/campaigns/{campaignId}/schedule"]["post"]["requestBody"]["content"]["application/json"];
|
|
1387
|
+
type ScheduleCampaignResponseSuccess = paths["/v1/campaigns/{campaignId}/schedule"]["post"]["responses"]["200"]["content"]["application/json"];
|
|
1388
|
+
type ScheduleCampaignResponse = {
|
|
1389
|
+
data: ScheduleCampaignResponseSuccess | null;
|
|
1390
|
+
error: ErrorResponse | null;
|
|
1391
|
+
};
|
|
1392
|
+
type CampaignActionResponseSuccess = {
|
|
1393
|
+
success: boolean;
|
|
1394
|
+
};
|
|
1395
|
+
type CampaignActionResponse = {
|
|
1396
|
+
data: CampaignActionResponseSuccess | null;
|
|
1397
|
+
error: ErrorResponse | null;
|
|
1398
|
+
};
|
|
1399
|
+
declare class Campaigns {
|
|
1400
|
+
private readonly unsent;
|
|
1401
|
+
constructor(unsent: unsent);
|
|
1402
|
+
create(payload: CreateCampaignPayload): Promise<CreateCampaignResponse>;
|
|
1403
|
+
get(campaignId: string): Promise<GetCampaignResponse>;
|
|
1404
|
+
schedule(campaignId: string, payload: ScheduleCampaignPayload): Promise<ScheduleCampaignResponse>;
|
|
1405
|
+
pause(campaignId: string): Promise<CampaignActionResponse>;
|
|
1406
|
+
resume(campaignId: string): Promise<CampaignActionResponse>;
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1147
1409
|
declare class unsent {
|
|
1148
1410
|
readonly key?: string | undefined;
|
|
1149
1411
|
private readonly headers;
|
|
1150
|
-
readonly emails: Emails;
|
|
1151
1412
|
readonly domains: Domains;
|
|
1413
|
+
readonly emails: Emails;
|
|
1152
1414
|
readonly contacts: Contacts;
|
|
1415
|
+
readonly campaigns: Campaigns;
|
|
1153
1416
|
url: string;
|
|
1154
1417
|
constructor(key?: string | undefined, url?: string);
|
|
1155
1418
|
fetchRequest<T>(path: string, options?: {}): Promise<{
|
|
@@ -1178,4 +1441,4 @@ declare class unsent {
|
|
|
1178
1441
|
}>;
|
|
1179
1442
|
}
|
|
1180
1443
|
|
|
1181
|
-
export { unsent };
|
|
1444
|
+
export { Campaigns as campaigns, unsent };
|
package/dist/index.js
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
campaigns: () => Campaigns,
|
|
23
24
|
unsent: () => unsent
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -162,10 +163,52 @@ var Domains = class {
|
|
|
162
163
|
}
|
|
163
164
|
};
|
|
164
165
|
|
|
166
|
+
// src/campaign.ts
|
|
167
|
+
var Campaigns = class {
|
|
168
|
+
constructor(unsent2) {
|
|
169
|
+
this.unsent = unsent2;
|
|
170
|
+
this.unsent = unsent2;
|
|
171
|
+
}
|
|
172
|
+
async create(payload) {
|
|
173
|
+
const data = await this.unsent.post(
|
|
174
|
+
`/campaigns`,
|
|
175
|
+
payload
|
|
176
|
+
);
|
|
177
|
+
return data;
|
|
178
|
+
}
|
|
179
|
+
async get(campaignId) {
|
|
180
|
+
const data = await this.unsent.get(
|
|
181
|
+
`/campaigns/${campaignId}`
|
|
182
|
+
);
|
|
183
|
+
return data;
|
|
184
|
+
}
|
|
185
|
+
async schedule(campaignId, payload) {
|
|
186
|
+
const data = await this.unsent.post(
|
|
187
|
+
`/campaigns/${campaignId}/schedule`,
|
|
188
|
+
payload
|
|
189
|
+
);
|
|
190
|
+
return data;
|
|
191
|
+
}
|
|
192
|
+
async pause(campaignId) {
|
|
193
|
+
const data = await this.unsent.post(
|
|
194
|
+
`/campaigns/${campaignId}/pause`,
|
|
195
|
+
{}
|
|
196
|
+
);
|
|
197
|
+
return data;
|
|
198
|
+
}
|
|
199
|
+
async resume(campaignId) {
|
|
200
|
+
const data = await this.unsent.post(
|
|
201
|
+
`/campaigns/${campaignId}/resume`,
|
|
202
|
+
{}
|
|
203
|
+
);
|
|
204
|
+
return data;
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
|
|
165
208
|
// src/unsent.ts
|
|
166
|
-
var defaultBaseUrl = "https://
|
|
167
|
-
var baseUrl = `${process?.env?.UNSENT_BASE_URL ?? process?.env?.UNSENT_BASE_URL ?? defaultBaseUrl}/
|
|
168
|
-
function
|
|
209
|
+
var defaultBaseUrl = "https://api.unsent.dev";
|
|
210
|
+
var baseUrl = `${process?.env?.UNSENT_BASE_URL ?? process?.env?.UNSENT_BASE_URL ?? defaultBaseUrl}/v1`;
|
|
211
|
+
function isUnsentErrorResponse(error) {
|
|
169
212
|
return error.error.code !== void 0;
|
|
170
213
|
}
|
|
171
214
|
var unsent = class {
|
|
@@ -173,7 +216,7 @@ var unsent = class {
|
|
|
173
216
|
this.key = key;
|
|
174
217
|
if (!key) {
|
|
175
218
|
if (typeof process !== "undefined" && process.env) {
|
|
176
|
-
this.key = process.env.
|
|
219
|
+
this.key = process.env.UNSENT_API_KEY ?? process.env.UNSENT_API_KEY;
|
|
177
220
|
}
|
|
178
221
|
if (!this.key) {
|
|
179
222
|
throw new Error(
|
|
@@ -190,10 +233,10 @@ var unsent = class {
|
|
|
190
233
|
});
|
|
191
234
|
}
|
|
192
235
|
headers;
|
|
193
|
-
// readonly domains = new Domains(this);
|
|
194
|
-
emails = new Emails(this);
|
|
195
236
|
domains = new Domains(this);
|
|
237
|
+
emails = new Emails(this);
|
|
196
238
|
contacts = new Contacts(this);
|
|
239
|
+
campaigns = new Campaigns(this);
|
|
197
240
|
url = baseUrl;
|
|
198
241
|
async fetchRequest(path, options = {}) {
|
|
199
242
|
const response = await fetch(`${this.url}${path}`, options);
|
|
@@ -204,7 +247,7 @@ var unsent = class {
|
|
|
204
247
|
if (!response.ok) {
|
|
205
248
|
try {
|
|
206
249
|
const resp = await response.json();
|
|
207
|
-
if (
|
|
250
|
+
if (isUnsentErrorResponse(resp)) {
|
|
208
251
|
return { data: null, error: resp };
|
|
209
252
|
}
|
|
210
253
|
return { data: null, error: resp.error };
|
|
@@ -263,5 +306,6 @@ var unsent = class {
|
|
|
263
306
|
};
|
|
264
307
|
// Annotate the CommonJS export names for ESM import in node:
|
|
265
308
|
0 && (module.exports = {
|
|
309
|
+
campaigns,
|
|
266
310
|
unsent
|
|
267
311
|
});
|