@trycourier/courier
Advanced tools
Comparing version 2.4.0 to 2.6.0
@@ -8,2 +8,8 @@ # Change Log | ||
## [v2.6.0] - 2021-10-07 | ||
- Add support for DELETE /profiles/{recipient_id} (#58) | ||
- adds GET /messages API | ||
- adds idempotencyKey support in automations client | ||
## [v2.4.0] - 2021-08-23 | ||
@@ -163,3 +169,4 @@ | ||
[unreleased]: https://github.com/trycourier/courier-node/compare/v2.4.0...HEAD | ||
[unreleased]: https://github.com/trycourier/courier-node/compare/v2.6.0...HEAD | ||
[v2.6.0]: https://github.com/trycourier/courier-node/compare/v2.4.0...v2.6.0 | ||
[v2.4.0]: https://github.com/trycourier/courier-node/compare/v2.3.0...v2.4.0 | ||
@@ -166,0 +173,0 @@ [v2.3.0]: https://github.com/trycourier/courier-node/compare/v2.2.0...v2.3.0 |
@@ -41,14 +41,25 @@ "use strict"; | ||
var invokeAdHocAutomation = function (options) { | ||
return function (params) { return __awaiter(void 0, void 0, void 0, function () { | ||
var res; | ||
return function (params, config) { return __awaiter(void 0, void 0, void 0, function () { | ||
var axiosConfig, res; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, options.httpClient.post("/automations/invoke", { | ||
automation: params.automation, | ||
brand: params.brand, | ||
data: params.data, | ||
profile: params.profile, | ||
recipient: params.recipient, | ||
template: params.template | ||
})]; | ||
case 0: | ||
axiosConfig = { | ||
headers: {} | ||
}; | ||
if (config && config.idempotencyKey) { | ||
axiosConfig.headers["Idempotency-Key"] = config.idempotencyKey; | ||
} | ||
if (config && config.idempotencyExpiry) { | ||
axiosConfig.headers["x-idempotency-expiration"] = | ||
config.idempotencyExpiry; | ||
} | ||
return [4 /*yield*/, options.httpClient.post("/automations/invoke", { | ||
automation: params.automation, | ||
brand: params.brand, | ||
data: params.data, | ||
profile: params.profile, | ||
recipient: params.recipient, | ||
template: params.template | ||
}, axiosConfig)]; | ||
case 1: | ||
@@ -62,13 +73,22 @@ res = _a.sent(); | ||
var invokeAutomationTemplate = function (options) { | ||
return function (params) { return __awaiter(void 0, void 0, void 0, function () { | ||
var res; | ||
return function (params, config) { return __awaiter(void 0, void 0, void 0, function () { | ||
var axiosConfig, res; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, options.httpClient.post("/automations/" + params.templateId + "/invoke", { | ||
brand: params.brand, | ||
data: params.data, | ||
profile: params.profile, | ||
recipient: params.recipient, | ||
template: params.template | ||
})]; | ||
case 0: | ||
axiosConfig = { | ||
headers: {} | ||
}; | ||
if (config && config.idempotencyKey) { | ||
axiosConfig.headers["Idempotency-Key"] = config.idempotencyKey; | ||
axiosConfig.headers["x-idempotency-expiration"] = | ||
config.idempotencyExpiry; | ||
} | ||
return [4 /*yield*/, options.httpClient.post("/automations/" + params.templateId + "/invoke", { | ||
brand: params.brand, | ||
data: params.data, | ||
profile: params.profile, | ||
recipient: params.recipient, | ||
template: params.template | ||
}, axiosConfig)]; | ||
case 1: | ||
@@ -75,0 +95,0 @@ res = _a.sent(); |
@@ -55,2 +55,6 @@ export declare type AutomationStepAction = "cancel" | "delay" | "send" | "send-list" | "update-profile"; | ||
} | ||
export interface ICourierAutomationConfig { | ||
idempotencyKey?: string; | ||
idempotencyExpiry?: number; | ||
} | ||
export interface ICourierAutomationInvokeTemplateParams extends ICourierAutomationInvokeParams { | ||
@@ -63,4 +67,4 @@ templateId: string; | ||
export interface ICourierClientAutomations { | ||
invokeAdHocAutomation: (params: ICourierAutomationAdHocInvokeParams) => Promise<ICourierAutomationInvokeResponse>; | ||
invokeAutomationTemplate: (params: ICourierAutomationInvokeTemplateParams) => Promise<ICourierAutomationInvokeResponse>; | ||
invokeAdHocAutomation: (params: ICourierAutomationAdHocInvokeParams, config?: ICourierAutomationConfig) => Promise<ICourierAutomationInvokeResponse>; | ||
invokeAutomationTemplate: (params: ICourierAutomationInvokeTemplateParams, config?: ICourierAutomationConfig) => Promise<ICourierAutomationInvokeResponse>; | ||
} |
@@ -87,2 +87,23 @@ "use strict"; | ||
}; | ||
var getMessages = function (options) { | ||
return function (params) { return __awaiter(void 0, void 0, void 0, function () { | ||
var res; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, options.httpClient.get("/messages", { | ||
cursor: params === null || params === void 0 ? void 0 : params.cursor, | ||
event: params === null || params === void 0 ? void 0 : params.eventId, | ||
list: params === null || params === void 0 ? void 0 : params.listId, | ||
messageId: params === null || params === void 0 ? void 0 : params.messageId, | ||
notification: params === null || params === void 0 ? void 0 : params.notificationId, | ||
recipient: params === null || params === void 0 ? void 0 : params.recipientId, | ||
status: params === null || params === void 0 ? void 0 : params.status | ||
})]; | ||
case 1: | ||
res = _a.sent(); | ||
return [2 /*return*/, res.data]; | ||
} | ||
}); | ||
}); }; | ||
}; | ||
exports.client = function (options) { | ||
@@ -94,5 +115,7 @@ return { | ||
deleteBrand: brands_1.deleteBrand(options), | ||
deleteProfile: profile_1.deleteProfile(options), | ||
getBrand: brands_1.getBrand(options), | ||
getBrands: brands_1.getBrands(options), | ||
getMessage: getMessage(options), | ||
getMessages: getMessages(options), | ||
getProfile: profile_1.getProfile(options), | ||
@@ -99,0 +122,0 @@ getRecipientSubscriptions: profile_1.getRecipientSubscriptions(options), |
import { ICourierList } from "./lists/types"; | ||
import { ICourierClientConfiguration, ICourierProfileGetParameters, ICourierProfileGetResponse, ICourierProfileListsPostParameters, ICourierProfilePostConfig, ICourierProfilePostParameters, ICourierProfilePostResponse, ICourierProfilePutParameters, ICourierProfilePutResponse } from "./types"; | ||
import { ICourierClientConfiguration, ICourierProfileDeleteParameters, ICourierProfileGetParameters, ICourierProfileGetResponse, ICourierProfileListsPostParameters, ICourierProfilePostConfig, ICourierProfilePostParameters, ICourierProfilePostResponse, ICourierProfilePutParameters, ICourierProfilePutResponse } from "./types"; | ||
export declare const replaceProfile: (options: ICourierClientConfiguration) => (params: ICourierProfilePutParameters) => Promise<ICourierProfilePutResponse>; | ||
export declare const mergeProfile: (options: ICourierClientConfiguration) => (params: ICourierProfilePostParameters, config?: ICourierProfilePostConfig | undefined) => Promise<ICourierProfilePostResponse>; | ||
export declare const getProfile: (options: ICourierClientConfiguration) => (params: ICourierProfileGetParameters) => Promise<ICourierProfileGetResponse>; | ||
export declare const deleteProfile: (options: ICourierClientConfiguration) => (params: ICourierProfileDeleteParameters) => Promise<void>; | ||
export declare const getRecipientSubscriptions: (options: ICourierClientConfiguration) => (params: ICourierProfileGetParameters) => Promise<ICourierList[]>; | ||
export declare const addRecipientToLists: (options: ICourierClientConfiguration) => (params: ICourierProfileListsPostParameters) => Promise<ICourierProfilePostResponse>; | ||
export declare const removeRecipientFromAllLists: (options: ICourierClientConfiguration) => (params: ICourierProfileGetParameters) => Promise<ICourierProfilePostResponse>; |
@@ -39,3 +39,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.removeRecipientFromAllLists = exports.addRecipientToLists = exports.getRecipientSubscriptions = exports.getProfile = exports.mergeProfile = exports.replaceProfile = void 0; | ||
exports.removeRecipientFromAllLists = exports.addRecipientToLists = exports.getRecipientSubscriptions = exports.deleteProfile = exports.getProfile = exports.mergeProfile = exports.replaceProfile = void 0; | ||
exports.replaceProfile = function (options) { | ||
@@ -91,2 +91,14 @@ return function (params) { return __awaiter(void 0, void 0, void 0, function () { | ||
}; | ||
exports.deleteProfile = function (options) { | ||
return function (params) { return __awaiter(void 0, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, options.httpClient.delete("/profiles/" + params.recipientId)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }; | ||
}; | ||
exports.getRecipientSubscriptions = function (options) { | ||
@@ -93,0 +105,0 @@ return function (params) { return __awaiter(void 0, void 0, void 0, function () { |
@@ -82,2 +82,23 @@ import { AxiosRequestConfig } from "axios"; | ||
} | ||
export interface ICourierMessagesGetParameters { | ||
cursor?: string; | ||
eventId?: string; | ||
listId?: string; | ||
messageId?: string; | ||
notificationId?: string; | ||
recipientId?: string; | ||
status?: string | string[]; | ||
} | ||
export interface ICourierMessagesGetResponse { | ||
paging: ICourierPaging; | ||
results: Array<{ | ||
enqueued?: number; | ||
event?: string; | ||
id: string; | ||
notification?: string; | ||
recipient: string; | ||
sent?: number; | ||
status: string; | ||
}>; | ||
} | ||
export interface ICourierMessageGetResponse { | ||
@@ -104,2 +125,5 @@ enqueued?: number; | ||
} | ||
export interface ICourierProfileDeleteParameters { | ||
recipientId: string; | ||
} | ||
interface ICourierBrandSettings { | ||
@@ -163,3 +187,5 @@ colors?: { | ||
getMessage: (messageId: string) => Promise<ICourierMessageGetResponse>; | ||
getMessages: (params?: ICourierMessagesGetParameters) => Promise<ICourierMessagesGetResponse>; | ||
getProfile: (params: ICourierProfileGetParameters) => Promise<ICourierProfileGetResponse>; | ||
deleteProfile: (params: ICourierProfileDeleteParameters) => Promise<void>; | ||
getRecipientSubscriptions: (params: ICourierProfileGetParameters) => Promise<ICourierList[]>; | ||
@@ -166,0 +192,0 @@ lists: ICourierClientLists; |
{ | ||
"name": "@trycourier/courier", | ||
"version": "2.4.0", | ||
"version": "2.6.0", | ||
"description": "A node.js module for communicating with the Courier REST API.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
86969
1494