@trycourier/courier 3.2.0 → 3.5.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/CHANGELOG.md +21 -1
- package/README.md +39 -0
- package/lib/bulk/index.d.ts +3 -0
- package/lib/bulk/index.js +154 -0
- package/lib/bulk/types.d.ts +76 -0
- package/lib/bulk/types.js +2 -0
- package/lib/client.js +13 -40
- package/lib/send/index.d.ts +2 -0
- package/lib/send/index.js +100 -0
- package/lib/send/types.d.ts +308 -0
- package/lib/send/types.js +2 -0
- package/lib/types.d.ts +16 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,22 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased][unreleased]
|
|
7
7
|
|
|
8
|
+
## [v3.5.0] - 2022-02-10
|
|
9
|
+
|
|
10
|
+
- adds type for unroutable status
|
|
11
|
+
|
|
12
|
+
## [v3.4.0] - 2022-01-25
|
|
13
|
+
|
|
14
|
+
- adds support for the send message object in the request body of a `/send` call
|
|
15
|
+
|
|
16
|
+
## [v3.3.0] - 2022-01-25
|
|
17
|
+
|
|
18
|
+
- adds support for bulk processing endpoints
|
|
19
|
+
|
|
20
|
+
## [v3.2.1] - 2022-01-13
|
|
21
|
+
|
|
22
|
+
- Fixes `getMessages` query params
|
|
23
|
+
|
|
8
24
|
## [v3.2.0] - 2021-11-18
|
|
9
25
|
|
|
10
26
|
- adds idempotency expiration support for send and send list endpoints
|
|
@@ -185,7 +201,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
|
185
201
|
|
|
186
202
|
## v1.0.1 - 2019-07-12
|
|
187
203
|
|
|
188
|
-
[unreleased]: https://github.com/trycourier/courier-node/compare/v3.
|
|
204
|
+
[unreleased]: https://github.com/trycourier/courier-node/compare/v3.5.0...HEAD
|
|
205
|
+
[v3.5.0]: https://github.com/trycourier/courier-node/compare/v3.4.0...v3.5.0
|
|
206
|
+
[v3.4.0]: https://github.com/trycourier/courier-node/compare/v3.3.0...v3.4.0
|
|
207
|
+
[v3.3.0]: https://github.com/trycourier/courier-node/compare/v3.2.1...v3.3.0
|
|
208
|
+
[v3.2.1]: https://github.com/trycourier/courier-node/compare/v3.2.0...v3.2.1
|
|
189
209
|
[v3.2.0]: https://github.com/trycourier/courier-node/compare/v3.1.0...v3.2.0
|
|
190
210
|
[v3.1.0]: https://github.com/trycourier/courier-node/compare/v3.0.0...v3.1.0
|
|
191
211
|
[v3.0.0]: https://github.com/trycourier/courier-node/compare/v2.8.0...v3.0.0
|
package/README.md
CHANGED
|
@@ -377,6 +377,45 @@ async function run() {
|
|
|
377
377
|
|
|
378
378
|
// Example: Cancel notification submission
|
|
379
379
|
await courier.notifications.cancelSubmission("notification1", "submission1");
|
|
380
|
+
|
|
381
|
+
// Bulk Processing
|
|
382
|
+
// Example: create a job
|
|
383
|
+
const response = await courier.bulk.createJob({
|
|
384
|
+
message: {
|
|
385
|
+
event: "RR4NDQ7NZ24A8TKPWVBEDGE15E9A",
|
|
386
|
+
},
|
|
387
|
+
});
|
|
388
|
+
console.log(response);
|
|
389
|
+
|
|
390
|
+
// Example: get a job
|
|
391
|
+
const response = await courier.bulk.getJob({
|
|
392
|
+
jobId: "1-61efe386-6ff57552409e311b7a1f371f",
|
|
393
|
+
});
|
|
394
|
+
console.log(response);
|
|
395
|
+
|
|
396
|
+
// Example: Ingest users in a job
|
|
397
|
+
const response = await courier.bulk.ingestUsers({
|
|
398
|
+
jobId: "1-61efe386-6ff57552409e311b7a1f371f",
|
|
399
|
+
users: [
|
|
400
|
+
{
|
|
401
|
+
profile: {
|
|
402
|
+
email: "tejas@courier.com",
|
|
403
|
+
},
|
|
404
|
+
},
|
|
405
|
+
],
|
|
406
|
+
});
|
|
407
|
+
console.log(response);
|
|
408
|
+
|
|
409
|
+
// Example: Run a job
|
|
410
|
+
await courier.bulk.runJob({
|
|
411
|
+
jobId: "1-61efe386-6ff57552409e311b7a1f371f",
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
// Example: Get user details in a job
|
|
415
|
+
const response = await courier.bulk.getJobUsers({
|
|
416
|
+
jobId: "1-61efe386-6ff57552409e311b7a1f371f",
|
|
417
|
+
});
|
|
418
|
+
console.log(response);
|
|
380
419
|
}
|
|
381
420
|
|
|
382
421
|
run();
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.bulk = void 0;
|
|
40
|
+
var createJob = function (options) {
|
|
41
|
+
return function (params, config) { return __awaiter(void 0, void 0, void 0, function () {
|
|
42
|
+
var axiosConfig, res;
|
|
43
|
+
return __generator(this, function (_a) {
|
|
44
|
+
switch (_a.label) {
|
|
45
|
+
case 0:
|
|
46
|
+
axiosConfig = {
|
|
47
|
+
headers: {}
|
|
48
|
+
};
|
|
49
|
+
if (config && config.idempotencyKey) {
|
|
50
|
+
axiosConfig.headers["Idempotency-Key"] = config.idempotencyKey;
|
|
51
|
+
}
|
|
52
|
+
if (config && config.idempotencyExpiry) {
|
|
53
|
+
axiosConfig.headers["x-idempotency-expiration"] =
|
|
54
|
+
config.idempotencyExpiry;
|
|
55
|
+
}
|
|
56
|
+
return [4 /*yield*/, options.httpClient.post("/bulk", {
|
|
57
|
+
message: params.message
|
|
58
|
+
}, axiosConfig)];
|
|
59
|
+
case 1:
|
|
60
|
+
res = _a.sent();
|
|
61
|
+
return [2 /*return*/, res.data];
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}); };
|
|
65
|
+
};
|
|
66
|
+
var ingestUsers = function (options) {
|
|
67
|
+
return function (params, config) { return __awaiter(void 0, void 0, void 0, function () {
|
|
68
|
+
var axiosConfig, res;
|
|
69
|
+
return __generator(this, function (_a) {
|
|
70
|
+
switch (_a.label) {
|
|
71
|
+
case 0:
|
|
72
|
+
axiosConfig = {
|
|
73
|
+
headers: {}
|
|
74
|
+
};
|
|
75
|
+
if (config && config.idempotencyKey) {
|
|
76
|
+
axiosConfig.headers["Idempotency-Key"] = config.idempotencyKey;
|
|
77
|
+
}
|
|
78
|
+
if (config && config.idempotencyExpiry) {
|
|
79
|
+
axiosConfig.headers["x-idempotency-expiration"] =
|
|
80
|
+
config.idempotencyExpiry;
|
|
81
|
+
}
|
|
82
|
+
return [4 /*yield*/, options.httpClient.post("/bulk/" + params.jobId, {
|
|
83
|
+
users: params.users
|
|
84
|
+
}, axiosConfig)];
|
|
85
|
+
case 1:
|
|
86
|
+
res = _a.sent();
|
|
87
|
+
return [2 /*return*/, res.data];
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}); };
|
|
91
|
+
};
|
|
92
|
+
var runJob = function (options) {
|
|
93
|
+
return function (params, config) { return __awaiter(void 0, void 0, void 0, function () {
|
|
94
|
+
var axiosConfig;
|
|
95
|
+
return __generator(this, function (_a) {
|
|
96
|
+
switch (_a.label) {
|
|
97
|
+
case 0:
|
|
98
|
+
axiosConfig = {
|
|
99
|
+
headers: {}
|
|
100
|
+
};
|
|
101
|
+
if (config && config.idempotencyKey) {
|
|
102
|
+
axiosConfig.headers["Idempotency-Key"] = config.idempotencyKey;
|
|
103
|
+
}
|
|
104
|
+
if (config && config.idempotencyExpiry) {
|
|
105
|
+
axiosConfig.headers["x-idempotency-expiration"] =
|
|
106
|
+
config.idempotencyExpiry;
|
|
107
|
+
}
|
|
108
|
+
return [4 /*yield*/, options.httpClient.post("/bulk/" + params.jobId + "/run", {}, axiosConfig)];
|
|
109
|
+
case 1:
|
|
110
|
+
_a.sent();
|
|
111
|
+
return [2 /*return*/];
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}); };
|
|
115
|
+
};
|
|
116
|
+
var getJob = function (options) {
|
|
117
|
+
return function (params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
118
|
+
var res;
|
|
119
|
+
return __generator(this, function (_a) {
|
|
120
|
+
switch (_a.label) {
|
|
121
|
+
case 0: return [4 /*yield*/, options.httpClient.get("/bulk/" + params.jobId)];
|
|
122
|
+
case 1:
|
|
123
|
+
res = _a.sent();
|
|
124
|
+
return [2 /*return*/, res.data];
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}); };
|
|
128
|
+
};
|
|
129
|
+
var getJobUsers = function (options) {
|
|
130
|
+
return function (params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
131
|
+
var res;
|
|
132
|
+
return __generator(this, function (_a) {
|
|
133
|
+
switch (_a.label) {
|
|
134
|
+
case 0: return [4 /*yield*/, options.httpClient.get("/bulk/" + params.jobId + "/users", {
|
|
135
|
+
params: {
|
|
136
|
+
cursor: params.cursor
|
|
137
|
+
}
|
|
138
|
+
})];
|
|
139
|
+
case 1:
|
|
140
|
+
res = _a.sent();
|
|
141
|
+
return [2 /*return*/, res.data];
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}); };
|
|
145
|
+
};
|
|
146
|
+
exports.bulk = function (options) {
|
|
147
|
+
return {
|
|
148
|
+
createJob: createJob(options),
|
|
149
|
+
getJob: getJob(options),
|
|
150
|
+
getJobUsers: getJobUsers(options),
|
|
151
|
+
ingestUsers: ingestUsers(options),
|
|
152
|
+
runJob: runJob(options)
|
|
153
|
+
};
|
|
154
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { IRecipientPreferences } from "../preferences/types";
|
|
2
|
+
export interface IInboundBulkMessage {
|
|
3
|
+
brand?: string;
|
|
4
|
+
data?: object;
|
|
5
|
+
event: string;
|
|
6
|
+
locale?: string;
|
|
7
|
+
override?: object;
|
|
8
|
+
}
|
|
9
|
+
export interface ICourierBulkConfig {
|
|
10
|
+
idempotencyKey?: string;
|
|
11
|
+
idempotencyExpiry?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface ICourierBulkCreateJobParams {
|
|
14
|
+
message: IInboundBulkMessage;
|
|
15
|
+
}
|
|
16
|
+
export interface ICourierBulkCreateJobResponse {
|
|
17
|
+
jobId: string;
|
|
18
|
+
}
|
|
19
|
+
export interface IInboundBulkMessageUser {
|
|
20
|
+
preferences?: IRecipientPreferences;
|
|
21
|
+
profile?: object;
|
|
22
|
+
recipient?: string;
|
|
23
|
+
data?: object;
|
|
24
|
+
}
|
|
25
|
+
export declare type InboundBulkMessageUser = IInboundBulkMessageUser;
|
|
26
|
+
export interface ICourierBulkIngestUsersParams {
|
|
27
|
+
jobId: string;
|
|
28
|
+
users: InboundBulkMessageUser[];
|
|
29
|
+
}
|
|
30
|
+
export interface ICourierBulkIngestError {
|
|
31
|
+
user: any;
|
|
32
|
+
error: any;
|
|
33
|
+
}
|
|
34
|
+
export interface ICourierBulkIngestUsersResponse {
|
|
35
|
+
total: number;
|
|
36
|
+
errors?: ICourierBulkIngestError[];
|
|
37
|
+
}
|
|
38
|
+
export interface ICourierBulkRunJobParams {
|
|
39
|
+
jobId: string;
|
|
40
|
+
}
|
|
41
|
+
export interface ICourierBulkGetJobParams {
|
|
42
|
+
jobId: string;
|
|
43
|
+
}
|
|
44
|
+
export declare type BulkJobStatus = "CREATED" | "PROCESSING" | "COMPLETED" | "ERROR";
|
|
45
|
+
export declare type BulkJobUserStatus = "PENDING" | "ENQUEUED" | "ERROR";
|
|
46
|
+
export interface ICourierBulkGetJobResponse {
|
|
47
|
+
job: {
|
|
48
|
+
definition: IInboundBulkMessage;
|
|
49
|
+
enqueued: number;
|
|
50
|
+
failures: number;
|
|
51
|
+
received: number;
|
|
52
|
+
status: BulkJobStatus;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export interface ICourierBulkGetJobUsersParams {
|
|
56
|
+
jobId: string;
|
|
57
|
+
cursor?: string;
|
|
58
|
+
}
|
|
59
|
+
export interface ICourierBulkMessageUserResponse extends InboundBulkMessageUser {
|
|
60
|
+
status: BulkJobUserStatus;
|
|
61
|
+
messageId?: string;
|
|
62
|
+
}
|
|
63
|
+
export interface ICourierBulkGetJobUsersResponse {
|
|
64
|
+
items: ICourierBulkMessageUserResponse[];
|
|
65
|
+
paging: {
|
|
66
|
+
cursor?: string;
|
|
67
|
+
more: boolean;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export interface ICourierClientBulk {
|
|
71
|
+
createJob: (params: ICourierBulkCreateJobParams, config?: ICourierBulkConfig) => Promise<ICourierBulkCreateJobResponse>;
|
|
72
|
+
ingestUsers: (params: ICourierBulkIngestUsersParams, config?: ICourierBulkConfig) => Promise<ICourierBulkIngestUsersResponse>;
|
|
73
|
+
runJob: (params: ICourierBulkRunJobParams, config?: ICourierBulkConfig) => Promise<void>;
|
|
74
|
+
getJob: (params: ICourierBulkGetJobParams) => Promise<ICourierBulkGetJobResponse>;
|
|
75
|
+
getJobUsers: (params: ICourierBulkGetJobUsersParams) => Promise<ICourierBulkGetJobUsersResponse>;
|
|
76
|
+
}
|
package/lib/client.js
CHANGED
|
@@ -39,42 +39,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
exports.client = void 0;
|
|
40
40
|
var automations_1 = require("./automations");
|
|
41
41
|
var brands_1 = require("./brands");
|
|
42
|
+
var bulk_1 = require("./bulk");
|
|
42
43
|
var lists_1 = require("./lists");
|
|
43
44
|
var notifications_1 = require("./notifications");
|
|
44
45
|
var preferences_1 = require("./preferences");
|
|
45
46
|
var profile_1 = require("./profile");
|
|
46
|
-
var
|
|
47
|
-
return function (params, config) { return __awaiter(void 0, void 0, void 0, function () {
|
|
48
|
-
var axiosConfig, res;
|
|
49
|
-
return __generator(this, function (_a) {
|
|
50
|
-
switch (_a.label) {
|
|
51
|
-
case 0:
|
|
52
|
-
axiosConfig = {
|
|
53
|
-
headers: {}
|
|
54
|
-
};
|
|
55
|
-
if (config && config.idempotencyKey) {
|
|
56
|
-
axiosConfig.headers["Idempotency-Key"] = config.idempotencyKey;
|
|
57
|
-
}
|
|
58
|
-
if (config && config.idempotencyExpiry) {
|
|
59
|
-
axiosConfig.headers["x-idempotency-expiration"] =
|
|
60
|
-
config.idempotencyExpiry;
|
|
61
|
-
}
|
|
62
|
-
return [4 /*yield*/, options.httpClient.post("/send", {
|
|
63
|
-
brand: params.brand,
|
|
64
|
-
data: params.data,
|
|
65
|
-
event: params.eventId,
|
|
66
|
-
override: params.override,
|
|
67
|
-
preferences: params.preferences,
|
|
68
|
-
profile: params.profile,
|
|
69
|
-
recipient: params.recipientId
|
|
70
|
-
}, axiosConfig)];
|
|
71
|
-
case 1:
|
|
72
|
-
res = _a.sent();
|
|
73
|
-
return [2 /*return*/, res.data];
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}); };
|
|
77
|
-
};
|
|
47
|
+
var send_1 = require("./send");
|
|
78
48
|
var getMessage = function (options) {
|
|
79
49
|
return function (messageId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
80
50
|
var res;
|
|
@@ -120,13 +90,15 @@ var getMessages = function (options) {
|
|
|
120
90
|
return __generator(this, function (_a) {
|
|
121
91
|
switch (_a.label) {
|
|
122
92
|
case 0: return [4 /*yield*/, options.httpClient.get("/messages", {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
93
|
+
params: {
|
|
94
|
+
cursor: params === null || params === void 0 ? void 0 : params.cursor,
|
|
95
|
+
event: params === null || params === void 0 ? void 0 : params.eventId,
|
|
96
|
+
list: params === null || params === void 0 ? void 0 : params.listId,
|
|
97
|
+
messageId: params === null || params === void 0 ? void 0 : params.messageId,
|
|
98
|
+
notification: params === null || params === void 0 ? void 0 : params.notificationId,
|
|
99
|
+
recipient: params === null || params === void 0 ? void 0 : params.recipientId,
|
|
100
|
+
status: params === null || params === void 0 ? void 0 : params.status
|
|
101
|
+
}
|
|
130
102
|
})];
|
|
131
103
|
case 1:
|
|
132
104
|
res = _a.sent();
|
|
@@ -139,6 +111,7 @@ exports.client = function (options) {
|
|
|
139
111
|
return {
|
|
140
112
|
addRecipientToLists: profile_1.addRecipientToLists(options),
|
|
141
113
|
automations: automations_1.automations(options),
|
|
114
|
+
bulk: bulk_1.bulk(options),
|
|
142
115
|
createBrand: brands_1.createBrand(options),
|
|
143
116
|
deleteBrand: brands_1.deleteBrand(options),
|
|
144
117
|
deleteProfile: profile_1.deleteProfile(options),
|
|
@@ -157,6 +130,6 @@ exports.client = function (options) {
|
|
|
157
130
|
removeRecipientFromAllLists: profile_1.removeRecipientFromAllLists(options),
|
|
158
131
|
replaceBrand: brands_1.replaceBrand(options),
|
|
159
132
|
replaceProfile: profile_1.replaceProfile(options),
|
|
160
|
-
send: send(options)
|
|
133
|
+
send: send_1.send(options)
|
|
161
134
|
};
|
|
162
135
|
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { ICourierClientConfiguration, ICourierSendConfig, ICourierSendMessageParameters, ICourierSendParameters, SendResponse } from "../types";
|
|
2
|
+
export declare const send: (options: ICourierClientConfiguration) => <T extends ICourierSendParameters | ICourierSendMessageParameters>(params: T, config?: ICourierSendConfig | undefined) => Promise<SendResponse<T>>;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.send = void 0;
|
|
40
|
+
var sendCall = function (options, config, params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
41
|
+
var res;
|
|
42
|
+
return __generator(this, function (_a) {
|
|
43
|
+
switch (_a.label) {
|
|
44
|
+
case 0: return [4 /*yield*/, options.httpClient.post("/send", {
|
|
45
|
+
brand: params.brand,
|
|
46
|
+
data: params.data,
|
|
47
|
+
event: params.eventId,
|
|
48
|
+
override: params.override,
|
|
49
|
+
preferences: params.preferences,
|
|
50
|
+
profile: params.profile,
|
|
51
|
+
recipient: params.recipientId
|
|
52
|
+
}, config)];
|
|
53
|
+
case 1:
|
|
54
|
+
res = _a.sent();
|
|
55
|
+
return [2 /*return*/, res.data];
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}); };
|
|
59
|
+
var sendMessageCall = function (options, config, params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
60
|
+
var res;
|
|
61
|
+
return __generator(this, function (_a) {
|
|
62
|
+
switch (_a.label) {
|
|
63
|
+
case 0: return [4 /*yield*/, options.httpClient.post("/send", {
|
|
64
|
+
message: params.message
|
|
65
|
+
}, config)];
|
|
66
|
+
case 1:
|
|
67
|
+
res = _a.sent();
|
|
68
|
+
return [2 /*return*/, res.data];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}); };
|
|
72
|
+
exports.send = function (options) {
|
|
73
|
+
return function (params, config) { return __awaiter(void 0, void 0, void 0, function () {
|
|
74
|
+
var axiosConfig, v2Response, v1Response;
|
|
75
|
+
return __generator(this, function (_a) {
|
|
76
|
+
switch (_a.label) {
|
|
77
|
+
case 0:
|
|
78
|
+
axiosConfig = {
|
|
79
|
+
headers: {}
|
|
80
|
+
};
|
|
81
|
+
if (config && config.idempotencyKey) {
|
|
82
|
+
axiosConfig.headers["Idempotency-Key"] = config.idempotencyKey;
|
|
83
|
+
}
|
|
84
|
+
if (config && config.idempotencyExpiry) {
|
|
85
|
+
axiosConfig.headers["x-idempotency-expiration"] =
|
|
86
|
+
config.idempotencyExpiry;
|
|
87
|
+
}
|
|
88
|
+
if (!params.message) return [3 /*break*/, 2];
|
|
89
|
+
return [4 /*yield*/, sendMessageCall(options, axiosConfig, params)];
|
|
90
|
+
case 1:
|
|
91
|
+
v2Response = _a.sent();
|
|
92
|
+
return [2 /*return*/, v2Response];
|
|
93
|
+
case 2: return [4 /*yield*/, sendCall(options, axiosConfig, params)];
|
|
94
|
+
case 3:
|
|
95
|
+
v1Response = _a.sent();
|
|
96
|
+
return [2 /*return*/, v1Response];
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}); };
|
|
100
|
+
};
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
export interface IBrandSnippet {
|
|
2
|
+
format: "handlebars";
|
|
3
|
+
name: string;
|
|
4
|
+
value: string;
|
|
5
|
+
}
|
|
6
|
+
export interface IBrandSnippets {
|
|
7
|
+
items: IBrandSnippet[];
|
|
8
|
+
}
|
|
9
|
+
export interface IBrandColors {
|
|
10
|
+
primary?: string;
|
|
11
|
+
secondary?: string;
|
|
12
|
+
tertiary?: string;
|
|
13
|
+
}
|
|
14
|
+
interface IBrandTemplate {
|
|
15
|
+
backgroundColor?: string;
|
|
16
|
+
blocksBackgroundColor?: string;
|
|
17
|
+
enabled: boolean;
|
|
18
|
+
footer?: string;
|
|
19
|
+
head?: string;
|
|
20
|
+
header?: string;
|
|
21
|
+
width?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface IBrandTemplateOverride extends IBrandTemplate {
|
|
24
|
+
mjml?: IBrandTemplate;
|
|
25
|
+
footerBackgroundColor?: string;
|
|
26
|
+
footerFullWidth?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface IBrandSettingsSocialPresence {
|
|
29
|
+
inheritDefault?: boolean;
|
|
30
|
+
facebook?: {
|
|
31
|
+
url: string;
|
|
32
|
+
};
|
|
33
|
+
instagram?: {
|
|
34
|
+
url: string;
|
|
35
|
+
};
|
|
36
|
+
linkedin?: {
|
|
37
|
+
url: string;
|
|
38
|
+
};
|
|
39
|
+
medium?: {
|
|
40
|
+
url: string;
|
|
41
|
+
};
|
|
42
|
+
twitter?: {
|
|
43
|
+
url: string;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export interface IBrandSettingsEmail {
|
|
47
|
+
templateOverride?: IBrandTemplateOverride;
|
|
48
|
+
head?: {
|
|
49
|
+
inheritDefault: boolean;
|
|
50
|
+
content?: string;
|
|
51
|
+
};
|
|
52
|
+
footer?: {
|
|
53
|
+
content?: object;
|
|
54
|
+
inheritDefault?: boolean;
|
|
55
|
+
markdown?: string;
|
|
56
|
+
social?: IBrandSettingsSocialPresence;
|
|
57
|
+
};
|
|
58
|
+
header?: {
|
|
59
|
+
inheritDefault?: boolean;
|
|
60
|
+
barColor?: string;
|
|
61
|
+
logo?: {
|
|
62
|
+
href?: string;
|
|
63
|
+
image?: string;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
export interface IBrandSettingsInApp {
|
|
68
|
+
borderRadius?: string;
|
|
69
|
+
disableMessageIcon?: boolean;
|
|
70
|
+
fontFamily?: string;
|
|
71
|
+
placement?: "top" | "bottom" | "left" | "right";
|
|
72
|
+
widgetBackground?: {
|
|
73
|
+
topColor?: string;
|
|
74
|
+
bottomColor?: string;
|
|
75
|
+
};
|
|
76
|
+
colors?: {
|
|
77
|
+
invertHeader?: boolean;
|
|
78
|
+
invertButtons?: boolean;
|
|
79
|
+
};
|
|
80
|
+
icons?: {
|
|
81
|
+
bell?: string;
|
|
82
|
+
message?: string;
|
|
83
|
+
};
|
|
84
|
+
preferences?: {
|
|
85
|
+
templateIds: string[];
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
export declare type IActionButtonStyle = "button" | "link";
|
|
89
|
+
export declare type IAlignment = "center" | "left" | "right" | "full";
|
|
90
|
+
export interface ElementalContent {
|
|
91
|
+
version: "2022-01-01";
|
|
92
|
+
brand?: any;
|
|
93
|
+
elements: ElementalNode[];
|
|
94
|
+
}
|
|
95
|
+
export declare type ElementalNode = ElementalTextNode | ElementalMetaNode | ElementalChannelNode | ElementalImageNode | ElementalActionNode | ElementalDividerNode | ElementalGroupNode | ElementalQuoteNode;
|
|
96
|
+
export interface ElementalTextNode extends ElementalBaseNode {
|
|
97
|
+
type: "text";
|
|
98
|
+
content: string;
|
|
99
|
+
format?: "markdown";
|
|
100
|
+
locales?: {
|
|
101
|
+
[locale: string]: {
|
|
102
|
+
content: string;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
export interface ElementalMetaNode extends ElementalBaseNode {
|
|
107
|
+
type: "meta";
|
|
108
|
+
title?: string;
|
|
109
|
+
}
|
|
110
|
+
export interface ElementalChannelNode extends ElementalBaseNode {
|
|
111
|
+
type: "channel";
|
|
112
|
+
channel: string;
|
|
113
|
+
elements?: ElementalNode[];
|
|
114
|
+
raw?: {
|
|
115
|
+
[templateName: string]: any;
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
export interface ElementalImageNode extends ElementalBaseNode {
|
|
119
|
+
type: "image";
|
|
120
|
+
src: string;
|
|
121
|
+
href?: string;
|
|
122
|
+
align?: IAlignment;
|
|
123
|
+
altText?: string;
|
|
124
|
+
width?: string;
|
|
125
|
+
}
|
|
126
|
+
export interface ElementalActionNode extends ElementalBaseNode {
|
|
127
|
+
type: "action";
|
|
128
|
+
content: string;
|
|
129
|
+
href: string;
|
|
130
|
+
actionId?: string;
|
|
131
|
+
style?: IActionButtonStyle;
|
|
132
|
+
align?: IAlignment;
|
|
133
|
+
backgroundColor?: string;
|
|
134
|
+
locales?: {
|
|
135
|
+
[locale: string]: {
|
|
136
|
+
content: string;
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
export interface ElementalDividerNode extends ElementalBaseNode {
|
|
141
|
+
type: "divider";
|
|
142
|
+
color?: string;
|
|
143
|
+
}
|
|
144
|
+
export interface ElementalGroupNode extends ElementalBaseNode {
|
|
145
|
+
type: "group";
|
|
146
|
+
elements: ElementalNode[];
|
|
147
|
+
}
|
|
148
|
+
export interface ElementalQuoteNode extends ElementalBaseNode {
|
|
149
|
+
type: "quote";
|
|
150
|
+
content: string;
|
|
151
|
+
align?: IAlignment;
|
|
152
|
+
borderColor?: string;
|
|
153
|
+
textStyle?: "text" | "h1" | "h2" | "subtext";
|
|
154
|
+
locales?: {
|
|
155
|
+
[locale: string]: {
|
|
156
|
+
content: string;
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
interface ElementalBaseNode {
|
|
161
|
+
type: string;
|
|
162
|
+
channels?: string[];
|
|
163
|
+
ref?: string;
|
|
164
|
+
if?: string;
|
|
165
|
+
loop?: string;
|
|
166
|
+
}
|
|
167
|
+
export interface MessageData extends Record<string, any> {
|
|
168
|
+
}
|
|
169
|
+
interface ListRecipient {
|
|
170
|
+
list_id: string;
|
|
171
|
+
pattern?: string;
|
|
172
|
+
}
|
|
173
|
+
export declare type RuleType = "snooze" | "channel_preferences" | "status";
|
|
174
|
+
export interface IRule<T extends RuleType> {
|
|
175
|
+
type: T;
|
|
176
|
+
}
|
|
177
|
+
export interface ISnoozeRule extends IRule<"snooze"> {
|
|
178
|
+
start?: string;
|
|
179
|
+
until: string;
|
|
180
|
+
}
|
|
181
|
+
export declare type Rule = ISnoozeRule;
|
|
182
|
+
export declare type PreferenceStatus = "OPTED_IN" | "OPTED_OUT" | "REQUIRED";
|
|
183
|
+
export declare type ChannelClassification = "direct_message" | "email" | "push";
|
|
184
|
+
export interface IPreference {
|
|
185
|
+
status: PreferenceStatus;
|
|
186
|
+
rules?: Rule[];
|
|
187
|
+
channel_preferences?: Array<{
|
|
188
|
+
channel: ChannelClassification;
|
|
189
|
+
}>;
|
|
190
|
+
source?: "subscription" | "list" | "recipient";
|
|
191
|
+
}
|
|
192
|
+
export interface IPreferences {
|
|
193
|
+
[id: string]: IPreference;
|
|
194
|
+
}
|
|
195
|
+
export interface IProfilePreferences {
|
|
196
|
+
categories?: IPreferences;
|
|
197
|
+
notifications: IPreferences;
|
|
198
|
+
templateId?: string;
|
|
199
|
+
}
|
|
200
|
+
export interface UserRecipient extends Record<string, any> {
|
|
201
|
+
data?: MessageData;
|
|
202
|
+
email?: string;
|
|
203
|
+
locale?: string;
|
|
204
|
+
user_id?: string;
|
|
205
|
+
phone_number?: string;
|
|
206
|
+
preferences?: IProfilePreferences;
|
|
207
|
+
}
|
|
208
|
+
export declare type MessageRecipient = ListRecipient | UserRecipient;
|
|
209
|
+
export interface ElementalContentSugar {
|
|
210
|
+
body?: string;
|
|
211
|
+
title?: string;
|
|
212
|
+
}
|
|
213
|
+
export declare type Content = ElementalContentSugar | ElementalContent;
|
|
214
|
+
export interface BaseMessage {
|
|
215
|
+
to: MessageRecipient | MessageRecipient[];
|
|
216
|
+
data?: MessageData;
|
|
217
|
+
channels?: MessageChannels;
|
|
218
|
+
providers?: MessageProviders;
|
|
219
|
+
routing?: Routing;
|
|
220
|
+
}
|
|
221
|
+
interface TrackingOverride {
|
|
222
|
+
open: boolean;
|
|
223
|
+
}
|
|
224
|
+
export interface MessageProviders {
|
|
225
|
+
[key: string]: {
|
|
226
|
+
override?: Record<string, any>;
|
|
227
|
+
if?: string;
|
|
228
|
+
timeouts?: number;
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
export interface MessageChannelEmailOverride {
|
|
232
|
+
attachments?: Record<string, any>[];
|
|
233
|
+
bcc?: string;
|
|
234
|
+
brand?: {
|
|
235
|
+
snippets?: IBrandSnippets;
|
|
236
|
+
settings?: {
|
|
237
|
+
colors?: IBrandColors;
|
|
238
|
+
email?: IBrandSettingsEmail;
|
|
239
|
+
};
|
|
240
|
+
};
|
|
241
|
+
cc?: string;
|
|
242
|
+
from?: string;
|
|
243
|
+
html?: string;
|
|
244
|
+
reply_to?: string;
|
|
245
|
+
subject?: string;
|
|
246
|
+
text?: string;
|
|
247
|
+
tracking?: TrackingOverride;
|
|
248
|
+
}
|
|
249
|
+
export interface MessageChannelPushOverride {
|
|
250
|
+
body?: string;
|
|
251
|
+
brand?: {
|
|
252
|
+
snippets?: IBrandSnippets;
|
|
253
|
+
settings?: {
|
|
254
|
+
colors?: IBrandColors;
|
|
255
|
+
inapp?: IBrandSettingsInApp;
|
|
256
|
+
};
|
|
257
|
+
};
|
|
258
|
+
click_action?: string;
|
|
259
|
+
data?: Record<string, any>;
|
|
260
|
+
icon?: string;
|
|
261
|
+
title?: string;
|
|
262
|
+
}
|
|
263
|
+
export interface MessageChannels {
|
|
264
|
+
[key: string]: {
|
|
265
|
+
brand_id?: string;
|
|
266
|
+
providers?: string[];
|
|
267
|
+
routing_method?: "all" | "single";
|
|
268
|
+
if?: string;
|
|
269
|
+
timeouts?: {
|
|
270
|
+
provider?: number;
|
|
271
|
+
channel?: number;
|
|
272
|
+
};
|
|
273
|
+
override?: MessageChannelEmailOverride | MessageChannelPushOverride;
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
export interface Routing {
|
|
277
|
+
method: "all" | "single";
|
|
278
|
+
channels: RoutingChannel[];
|
|
279
|
+
}
|
|
280
|
+
export declare type RoutingChannel = RoutingStrategyChannel | RoutingStrategyProvider | string;
|
|
281
|
+
export interface RoutingStrategyChannel<T = Record<string, any>> {
|
|
282
|
+
channel: string;
|
|
283
|
+
config?: T;
|
|
284
|
+
method?: "all" | "single";
|
|
285
|
+
providers?: (RoutingStrategyProvider | string)[];
|
|
286
|
+
if?: string;
|
|
287
|
+
}
|
|
288
|
+
export interface RoutingStrategyProvider<T = Record<string, any>> {
|
|
289
|
+
name: string;
|
|
290
|
+
config?: T;
|
|
291
|
+
if?: string;
|
|
292
|
+
}
|
|
293
|
+
export interface ContentMessageMetadata {
|
|
294
|
+
event?: string;
|
|
295
|
+
}
|
|
296
|
+
export interface ContentMessage extends BaseMessage {
|
|
297
|
+
content: Content;
|
|
298
|
+
metadata?: ContentMessageMetadata;
|
|
299
|
+
}
|
|
300
|
+
export interface TemplateMessage extends BaseMessage {
|
|
301
|
+
brand?: string;
|
|
302
|
+
template: string;
|
|
303
|
+
}
|
|
304
|
+
export declare type Message = ContentMessage | TemplateMessage;
|
|
305
|
+
export interface RequestV2 {
|
|
306
|
+
message: Message;
|
|
307
|
+
}
|
|
308
|
+
export {};
|
package/lib/types.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { AxiosRequestConfig } from "axios";
|
|
2
2
|
import { ICourierClientAutomations } from "./automations/types";
|
|
3
|
+
import { ICourierClientBulk } from "./bulk/types";
|
|
3
4
|
import { ICourierClientLists, ICourierList, ICourierRecipientSubscriptionsResponse } from "./lists/types";
|
|
4
5
|
import { ICourierClientNotifications } from "./notifications/types";
|
|
5
6
|
import { ICourierClientPreferences, IRecipientPreferences } from "./preferences/types";
|
|
7
|
+
import { Message } from "./send/types";
|
|
6
8
|
export declare type HttpMethodClient = <T>(url: string, body?: object, config?: AxiosRequestConfig) => Promise<{
|
|
7
9
|
data: T;
|
|
8
10
|
}>;
|
|
@@ -29,6 +31,9 @@ export interface ICourierSendParameters {
|
|
|
29
31
|
profile?: object;
|
|
30
32
|
override?: object;
|
|
31
33
|
}
|
|
34
|
+
export interface ICourierSendMessageParameters {
|
|
35
|
+
message: Message;
|
|
36
|
+
}
|
|
32
37
|
export interface ICourierSendConfig {
|
|
33
38
|
idempotencyKey?: string;
|
|
34
39
|
idempotencyExpiry?: number;
|
|
@@ -36,6 +41,9 @@ export interface ICourierSendConfig {
|
|
|
36
41
|
export interface ICourierSendResponse {
|
|
37
42
|
messageId: string;
|
|
38
43
|
}
|
|
44
|
+
export interface ICourierSendMessageResponse {
|
|
45
|
+
requestId: string;
|
|
46
|
+
}
|
|
39
47
|
export interface ICourierSendParams {
|
|
40
48
|
event: string;
|
|
41
49
|
data?: object;
|
|
@@ -137,7 +145,7 @@ export interface ICourierMessageGetResponse {
|
|
|
137
145
|
sent?: number;
|
|
138
146
|
status: MessageStatus;
|
|
139
147
|
}
|
|
140
|
-
export declare type MessageStatus = "CLICKED" | "DELIVERED" | "ENQUEUED" | "FILTERED" | "OPENED" | "SENT" | "SIMULATED" | "UNDELIVERABLE" | "UNMAPPED";
|
|
148
|
+
export declare type MessageStatus = "CLICKED" | "DELIVERED" | "ENQUEUED" | "FILTERED" | "OPENED" | "SENT" | "SIMULATED" | "UNDELIVERABLE" | "UNMAPPED" | "UNROUTABLE";
|
|
141
149
|
export declare type MessageHistoryType = MessageStatus | "DELIVERING" | "FILTERED" | "MAPPED" | "PROFILE_LOADED" | "RENDERED";
|
|
142
150
|
export declare type MessageStatusReason = "BOUNCED" | "FAILED" | "FILTERED" | "NO_CHANNELS" | "NO_PROVIDERS" | "OPT_IN_REQUIRED" | "PROVIDER_ERROR" | "UNPUBLISHED" | "UNSUBSCRIBED";
|
|
143
151
|
export declare type MessageStatusReasonCode = "HARD" | "SOFT";
|
|
@@ -178,6 +186,9 @@ export interface IRenderedMessageHistory extends IRoutedMessageHistory<"RENDERED
|
|
|
178
186
|
[key: string]: string;
|
|
179
187
|
};
|
|
180
188
|
}
|
|
189
|
+
export interface IUnroutableMessageHistory extends IMessageHistory<"UNROUTABLE"> {
|
|
190
|
+
reason: MessageStatusReason;
|
|
191
|
+
}
|
|
181
192
|
export interface IUndeliverableMessageHistory extends IMessageHistory<"UNDELIVERABLE">, Partial<Omit<IRoutedMessageHistory<"UNDELIVERABLE">, "ts" | "type">> {
|
|
182
193
|
reason: MessageStatusReason;
|
|
183
194
|
reasonCode?: MessageStatusReasonCode;
|
|
@@ -202,7 +213,7 @@ export interface IProviderErrorMessageHistory extends IRoutedMessageHistory<"UND
|
|
|
202
213
|
error_message: string;
|
|
203
214
|
}
|
|
204
215
|
export interface ICourierMessageGetHistoryResponse {
|
|
205
|
-
results: Array<IEnqueuedMessageHistory | IMappedMessageHistory | IProfileLoadedMessageHistory | IRenderedMessageHistory | IRoutedMessageHistory<RoutedMessageHistoryTypes> | IDeliveredMessageHistory | IProviderErrorMessageHistory | IUndeliverableMessageHistory>;
|
|
216
|
+
results: Array<IEnqueuedMessageHistory | IMappedMessageHistory | IProfileLoadedMessageHistory | IRenderedMessageHistory | IRoutedMessageHistory<RoutedMessageHistoryTypes> | IDeliveredMessageHistory | IProviderErrorMessageHistory | IUndeliverableMessageHistory | IUnroutableMessageHistory>;
|
|
206
217
|
}
|
|
207
218
|
export interface IApiMessageOutputItem {
|
|
208
219
|
channel: string;
|
|
@@ -270,9 +281,11 @@ export interface ICourierBrandGetAllResponse {
|
|
|
270
281
|
paging: ICourierPaging;
|
|
271
282
|
results: ICourierBrand[];
|
|
272
283
|
}
|
|
284
|
+
export declare type SendResponse<T extends ICourierSendParameters | ICourierSendMessageParameters> = T extends ICourierSendParameters ? ICourierSendResponse : ICourierSendMessageResponse;
|
|
273
285
|
export interface ICourierClient {
|
|
274
286
|
addRecipientToLists: (params: ICourierProfileListsPostParameters) => Promise<ICourierProfilePostResponse>;
|
|
275
287
|
automations: ICourierClientAutomations;
|
|
288
|
+
bulk: ICourierClientBulk;
|
|
276
289
|
createBrand: (params: ICourierBrandParameters, config?: ICourierBrandPostConfig) => Promise<ICourierBrand>;
|
|
277
290
|
deleteBrand: (brandId: string) => Promise<void>;
|
|
278
291
|
getBrand: (brandId: string) => Promise<ICourierBrand>;
|
|
@@ -293,6 +306,6 @@ export interface ICourierClient {
|
|
|
293
306
|
removeRecipientFromAllLists: (params: ICourierProfileGetParameters) => Promise<ICourierProfilePostResponse>;
|
|
294
307
|
replaceBrand: (params: ICourierBrandPutParameters) => Promise<ICourierBrand>;
|
|
295
308
|
replaceProfile: (params: ICourierProfilePutParameters) => Promise<ICourierProfilePutResponse>;
|
|
296
|
-
send: (params:
|
|
309
|
+
send: <T extends ICourierSendParameters | ICourierSendMessageParameters>(params: T, config?: ICourierSendConfig) => Promise<SendResponse<T>>;
|
|
297
310
|
}
|
|
298
311
|
export {};
|