@trycourier/courier
Advanced tools
Comparing version 2.6.0 to 2.7.0
@@ -8,2 +8,6 @@ # Change Log | ||
## [v2.7.0] - 2021-10-21 | ||
- adds GET /messages/{messageId}/history API | ||
## [v2.6.0] - 2021-10-07 | ||
@@ -169,3 +173,4 @@ | ||
[unreleased]: https://github.com/trycourier/courier-node/compare/v2.6.0...HEAD | ||
[unreleased]: https://github.com/trycourier/courier-node/compare/v2.7.0...HEAD | ||
[v2.7.0]: https://github.com/trycourier/courier-node/compare/v2.6.0...v2.7.0 | ||
[v2.6.0]: https://github.com/trycourier/courier-node/compare/v2.4.0...v2.6.0 | ||
@@ -172,0 +177,0 @@ [v2.4.0]: https://github.com/trycourier/courier-node/compare/v2.3.0...v2.4.0 |
@@ -87,2 +87,15 @@ "use strict"; | ||
}; | ||
var getMessageHistory = function (options) { | ||
return function (messageId) { 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/" + messageId + "/history")]; | ||
case 1: | ||
res = _a.sent(); | ||
return [2 /*return*/, res.data]; | ||
} | ||
}); | ||
}); }; | ||
}; | ||
var getMessages = function (options) { | ||
@@ -119,2 +132,3 @@ return function (params) { return __awaiter(void 0, void 0, void 0, function () { | ||
getMessage: getMessage(options), | ||
getMessageHistory: getMessageHistory(options), | ||
getMessages: getMessages(options), | ||
@@ -121,0 +135,0 @@ getProfile: profile_1.getProfile(options), |
@@ -124,2 +124,69 @@ import { AxiosRequestConfig } from "axios"; | ||
} | ||
export declare type MessageStatus = "CLICKED" | "DELIVERED" | "ENQUEUED" | "FILTERED" | "OPENED" | "SENT" | "SIMULATED" | "UNDELIVERABLE" | "UNMAPPED"; | ||
export declare type MessageHistoryType = MessageStatus | "DELIVERING" | "FILTERED" | "MAPPED" | "PROFILE_LOADED" | "RENDERED"; | ||
export declare type MessageStatusReason = "BOUNCED" | "FAILED" | "FILTERED" | "NO_CHANNELS" | "NO_PROVIDERS" | "OPT_IN_REQUIRED" | "PROVIDER_ERROR" | "UNPUBLISHED" | "UNSUBSCRIBED"; | ||
export declare type MessageStatusReasonCode = "HARD" | "SOFT"; | ||
export interface IMessageHistory<T extends MessageHistoryType> { | ||
ts: number; | ||
type: T; | ||
} | ||
export interface IEnqueuedMessageHistory extends IMessageHistory<"ENQUEUED"> { | ||
data?: string | { | ||
[key: string]: string; | ||
}; | ||
event: string; | ||
profile?: { | ||
[key: string]: any; | ||
}; | ||
override?: { | ||
[key: string]: any; | ||
}; | ||
recipient: string; | ||
} | ||
export interface IMappedMessageHistory extends IMessageHistory<"MAPPED"> { | ||
event_id: string; | ||
notification_id: string; | ||
} | ||
export interface IProfileLoadedMessageHistory extends IMessageHistory<"PROFILE_LOADED"> { | ||
merged_profile?: { | ||
[key: string]: any; | ||
}; | ||
received_profile?: { | ||
[key: string]: any; | ||
}; | ||
stored_profile?: { | ||
[key: string]: any; | ||
}; | ||
} | ||
export interface IRenderedMessageHistory extends IRoutedMessageHistory<"RENDERED"> { | ||
output: { | ||
[key: string]: string; | ||
}; | ||
} | ||
export interface IUndeliverableMessageHistory extends IMessageHistory<"UNDELIVERABLE">, Partial<Omit<IRoutedMessageHistory<"UNDELIVERABLE">, "ts" | "type">> { | ||
reason: MessageStatusReason; | ||
reasonCode?: MessageStatusReasonCode; | ||
} | ||
export declare type RoutedMessageHistoryTypes = Extract<MessageHistoryType, "CLICKED" | "DELIVERED" | "DELIVERING" | "OPENED" | "RENDERED" | "SENT" | "UNDELIVERABLE">; | ||
export interface IRoutedMessageHistory<T extends RoutedMessageHistoryTypes> extends IMessageHistory<T> { | ||
channel: { | ||
id: string; | ||
label?: string; | ||
}; | ||
integration: { | ||
id: string; | ||
provider: string; | ||
}; | ||
} | ||
export interface IDeliveredMessageHistory extends IRoutedMessageHistory<"DELIVERED"> { | ||
reference: { | ||
[key: string]: string; | ||
}; | ||
} | ||
export interface IProviderErrorMessageHistory extends IRoutedMessageHistory<"UNDELIVERABLE"> { | ||
error_message: string; | ||
} | ||
export interface ICourierMessageGetHistoryResponse { | ||
results: Array<IEnqueuedMessageHistory | IMappedMessageHistory | IProfileLoadedMessageHistory | IRenderedMessageHistory | IRoutedMessageHistory<RoutedMessageHistoryTypes> | IDeliveredMessageHistory | IProviderErrorMessageHistory | IUndeliverableMessageHistory>; | ||
} | ||
export interface ICourierProfileDeleteParameters { | ||
@@ -186,2 +253,3 @@ recipientId: string; | ||
getMessage: (messageId: string) => Promise<ICourierMessageGetResponse>; | ||
getMessageHistory: (messageId: string) => Promise<ICourierMessageGetHistoryResponse>; | ||
getMessages: (params?: ICourierMessagesGetParameters) => Promise<ICourierMessagesGetResponse>; | ||
@@ -188,0 +256,0 @@ getProfile: (params: ICourierProfileGetParameters) => Promise<ICourierProfileGetResponse>; |
{ | ||
"name": "@trycourier/courier", | ||
"version": "2.6.0", | ||
"version": "2.7.0", | ||
"description": "A node.js module for communicating with the Courier REST API.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -83,2 +83,10 @@ [![Courier: Your Complete Communication Stack](https://marketing-assets-public.s3.us-west-1.amazonaws.com/github_nodejs.png)](https://courier.com) | ||
// Example: get a message history | ||
const { results } = await courier.getMessageHistory(messageId); | ||
console.log(results); | ||
// Example: get all messages | ||
const { paging, results } = await courier.getMessages(); | ||
console.log(results); | ||
// Example: replace a recipient's profile | ||
@@ -85,0 +93,0 @@ const { status: replaceStatus } = await courier.replaceProfile({ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
90679
1576
422