@trycourier/courier 4.4.0 → 4.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/lib/accounts/index.js +3 -3
- package/lib/client.js +17 -3
- package/lib/http-client.js +1 -1
- package/lib/types.d.ts +19 -0
- package/package.json +1 -1
package/lib/accounts/index.js
CHANGED
|
@@ -68,8 +68,8 @@ var listAccounts = function (options) {
|
|
|
68
68
|
case 0: return [4 /*yield*/, options.httpClient.get("/accounts", undefined, {
|
|
69
69
|
params: {
|
|
70
70
|
cursor: (listOptions === null || listOptions === void 0 ? void 0 : listOptions.cursor) || "",
|
|
71
|
-
limit: (listOptions === null || listOptions === void 0 ? void 0 : listOptions.limit) || "20"
|
|
72
|
-
}
|
|
71
|
+
limit: (listOptions === null || listOptions === void 0 ? void 0 : listOptions.limit) || "20"
|
|
72
|
+
}
|
|
73
73
|
})];
|
|
74
74
|
case 1:
|
|
75
75
|
response = _a.sent();
|
|
@@ -95,5 +95,5 @@ exports.accounts = function (options) { return ({
|
|
|
95
95
|
delete: deleteAccount(options),
|
|
96
96
|
get: getAccount(options),
|
|
97
97
|
listAccounts: listAccounts(options),
|
|
98
|
-
put: putAccount(options)
|
|
98
|
+
put: putAccount(options)
|
|
99
99
|
}); };
|
package/lib/client.js
CHANGED
|
@@ -49,6 +49,19 @@ var preferences_1 = require("./preferences");
|
|
|
49
49
|
var profile_1 = require("./profile");
|
|
50
50
|
var send_1 = require("./send");
|
|
51
51
|
var token_management_1 = require("./token-management");
|
|
52
|
+
var cancelMessage = function (options) {
|
|
53
|
+
return function (messageId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
54
|
+
var res;
|
|
55
|
+
return __generator(this, function (_a) {
|
|
56
|
+
switch (_a.label) {
|
|
57
|
+
case 0: return [4 /*yield*/, options.httpClient.post("/messages/" + messageId + "/cancel")];
|
|
58
|
+
case 1:
|
|
59
|
+
res = _a.sent();
|
|
60
|
+
return [2 /*return*/, res.data];
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}); };
|
|
64
|
+
};
|
|
52
65
|
var getMessage = function (options) {
|
|
53
66
|
return function (messageId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
54
67
|
var res;
|
|
@@ -102,8 +115,8 @@ var getMessages = function (options) {
|
|
|
102
115
|
notification: params === null || params === void 0 ? void 0 : params.notificationId,
|
|
103
116
|
recipient: params === null || params === void 0 ? void 0 : params.recipientId,
|
|
104
117
|
status: params === null || params === void 0 ? void 0 : params.status,
|
|
105
|
-
tags: params === null || params === void 0 ? void 0 : params.tags
|
|
106
|
-
}
|
|
118
|
+
tags: params === null || params === void 0 ? void 0 : params.tags
|
|
119
|
+
}
|
|
107
120
|
})];
|
|
108
121
|
case 1:
|
|
109
122
|
res = _a.sent();
|
|
@@ -120,6 +133,7 @@ exports.client = function (options) {
|
|
|
120
133
|
auditEvents: audit_events_1.auditEvents(options),
|
|
121
134
|
automations: automations_1.automations(options),
|
|
122
135
|
bulk: bulk_1.bulk(options),
|
|
136
|
+
cancelMessage: cancelMessage(options),
|
|
123
137
|
createBrand: brands_1.createBrand(options),
|
|
124
138
|
deleteBrand: brands_1.deleteBrand(options),
|
|
125
139
|
deleteProfile: profile_1.deleteProfile(options),
|
|
@@ -139,6 +153,6 @@ exports.client = function (options) {
|
|
|
139
153
|
replaceBrand: brands_1.replaceBrand(options),
|
|
140
154
|
replaceProfile: profile_1.replaceProfile(options),
|
|
141
155
|
send: send_1.send(options),
|
|
142
|
-
tokenManagement: token_management_1.tokenManagement(options)
|
|
156
|
+
tokenManagement: token_management_1.tokenManagement(options)
|
|
143
157
|
};
|
|
144
158
|
};
|
package/lib/http-client.js
CHANGED
|
@@ -93,7 +93,7 @@ exports.initHttpClient = function (_a) {
|
|
|
93
93
|
case 0:
|
|
94
94
|
searchParams = String(new URLSearchParams(config === null || config === void 0 ? void 0 : config.params));
|
|
95
95
|
searchQueryString = searchParams && "?" + searchParams;
|
|
96
|
-
fullUrl = encodeURI("" + (baseUrl !== null && baseUrl !== void 0 ? baseUrl :
|
|
96
|
+
fullUrl = encodeURI("" + (baseUrl !== null && baseUrl !== void 0 ? baseUrl : "") + url + searchQueryString);
|
|
97
97
|
contentTypeHeader = body == null ? null : { "Content-Type": "application/json" };
|
|
98
98
|
idempotencyKeyHeader = (config === null || config === void 0 ? void 0 : config.idempotencyKey) ? { "Idempotency-Key": config.idempotencyKey }
|
|
99
99
|
: null;
|
package/lib/types.d.ts
CHANGED
|
@@ -124,6 +124,24 @@ export interface ICourierMessagesGetResponse {
|
|
|
124
124
|
tags?: string[];
|
|
125
125
|
}>;
|
|
126
126
|
}
|
|
127
|
+
export interface ICourierMessageCancelResponse {
|
|
128
|
+
canceledAt: number;
|
|
129
|
+
event: string;
|
|
130
|
+
id: string;
|
|
131
|
+
recipient: string;
|
|
132
|
+
status: string;
|
|
133
|
+
clicked?: number;
|
|
134
|
+
delivered?: number;
|
|
135
|
+
enqueued?: number;
|
|
136
|
+
error?: string;
|
|
137
|
+
jobId?: string;
|
|
138
|
+
listId?: string;
|
|
139
|
+
listMessageId?: string;
|
|
140
|
+
notification?: string;
|
|
141
|
+
opened?: number;
|
|
142
|
+
runId?: string;
|
|
143
|
+
sent?: number;
|
|
144
|
+
}
|
|
127
145
|
export interface ICourierMessageGetResponse {
|
|
128
146
|
clicked?: number;
|
|
129
147
|
delivered?: number;
|
|
@@ -305,6 +323,7 @@ export interface ICourierClient {
|
|
|
305
323
|
auditEvents: ReturnType<typeof auditEvents>;
|
|
306
324
|
automations: ICourierClientAutomations;
|
|
307
325
|
bulk: ICourierClientBulk;
|
|
326
|
+
cancelMessage: (messageId: string) => Promise<ICourierMessageCancelResponse>;
|
|
308
327
|
createBrand: (params: ICourierBrandParameters, config?: ICourierBrandPostConfig) => Promise<ICourierBrand>;
|
|
309
328
|
deleteBrand: (brandId: string) => Promise<void>;
|
|
310
329
|
getBrand: (brandId: string) => Promise<ICourierBrand>;
|