Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@trycourier/courier

Package Overview
Dependencies
Maintainers
1
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@trycourier/courier - npm Package Compare versions

Comparing version 1.0.4 to 1.1.0

lib/types.d.ts

20

lib/client.d.ts

@@ -1,19 +0,7 @@

declare type HttpPostClient = <T>(url: string, body?: object) => Promise<{
data: T;
}>;
export interface ICourierClientConfiguration {
httpPostClient: HttpPostClient;
}
export interface ICourierSendParameters {
eventId: string;
recipientId: string;
data?: object;
profile?: object;
}
export interface ICourierSendResponse {
messageId: string;
}
import { ICourierClientConfiguration, ICourierProfileGetParameters, ICourierProfileGetResponse, ICourierProfilePostParameters, ICourierProfilePostResponse, ICourierProfilePutParameters, ICourierProfilePutResponse, ICourierSendParameters, ICourierSendResponse } from "./types";
export declare const client: (options: ICourierClientConfiguration) => {
getProfile: (params: ICourierProfileGetParameters) => Promise<ICourierProfileGetResponse>;
mergeProfile: (params: ICourierProfilePostParameters) => Promise<ICourierProfilePostResponse>;
replaceProfile: (params: ICourierProfilePutParameters) => Promise<ICourierProfilePutResponse>;
send: (params: ICourierSendParameters) => Promise<ICourierSendResponse>;
};
export {};

81

lib/client.js

@@ -39,21 +39,70 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var send = function (options) {
return function (params) { return __awaiter(_this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, options.httpClient.post("/send", {
data: params.data,
event: params.eventId,
profile: params.profile,
recipient: params.recipientId
})];
case 1:
res = _a.sent();
return [2 /*return*/, res.data];
}
});
}); };
};
var replaceProfile = function (options) {
return function (params) { return __awaiter(_this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, options.httpClient.put("/profiles/" + params.profileId, {
profile: params.profile
})];
case 1:
res = _a.sent();
return [2 /*return*/, res.data];
}
});
}); };
};
var mergeProfile = function (options) {
return function (params) { return __awaiter(_this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, options.httpClient.post("/profiles/" + params.profileId, {
profile: params.profile
})];
case 1:
res = _a.sent();
return [2 /*return*/, res.data];
}
});
}); };
};
var getProfile = function (options) {
return function (params) { return __awaiter(_this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, options.httpClient.get("/profiles/" + params.profileId)];
case 1:
res = _a.sent();
return [2 /*return*/, res.data];
}
});
}); };
};
exports.client = function (options) {
return {
send: function (params) { return __awaiter(_this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, options.httpPostClient("/send", {
data: params.data,
event: params.eventId,
profile: params.profile,
recipient: params.recipientId
})];
case 1:
res = _a.sent();
return [2 /*return*/, res.data];
}
});
}); }
getProfile: getProfile(options),
mergeProfile: mergeProfile(options),
replaceProfile: replaceProfile(options),
send: send(options)
};
};

@@ -1,8 +0,8 @@

export interface ICourierClientOptions {
baseUrl?: string;
authenticationCode: string;
}
import { ICourierClientOptions } from "./types";
declare const _default: (options: ICourierClientOptions) => {
send: (params: import("./client").ICourierSendParameters) => Promise<import("./client").ICourierSendResponse>;
getProfile: (params: import("./types").ICourierProfileGetParameters) => Promise<import("./types").ICourierProfileGetResponse>;
mergeProfile: (params: import("./types").ICourierProfilePostParameters) => Promise<import("./types").ICourierProfilePostResponse>;
replaceProfile: (params: import("./types").ICourierProfilePutParameters) => Promise<import("./types").ICourierProfilePutResponse>;
send: (params: import("./types").ICourierSendParameters) => Promise<import("./types").ICourierSendResponse>;
};
export default _default;

@@ -16,5 +16,5 @@ "use strict";

var courier = client_1.client({
httpPostClient: axiosInstance.post
httpClient: axiosInstance
});
return courier;
});
{
"name": "@trycourier/courier",
"version": "1.0.4",
"version": "1.1.0",
"description": "A node.js module for communicating with the Courier REST API.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -16,7 +16,8 @@ # `@trycourier/courier`

const { send } = CourierClient({ authenticationCode: "<AUTH_CODE>" });
const courier = CourierClient({ authenticationCode: "<AUTH_CODE>" });
async function run () {
const { messageId } = await send({
// Example: send a message
const { messageId } = await courier.send({
eventId: "<EVENT_ID>",

@@ -27,5 +28,28 @@ recipientId: "<RECIPIENT_ID>",

});
console.log(messageId);
// Example: replace a recipient's profile
const replaceRes = await courier.replaceProfile({
profileId: "<PROFILE_ID>",
profile: {
email: "example@example.com"
}
});
console.log(replaceRes.status);
// Example: merge into a recipient's profile
const mergeRes = await courier.mergeProfile({
profileId: "<PROFILE_ID>",
profile: {
"sms": "555-555-5555"
}
});
console.log(mergeRes.status);
// Example: get a recipient's profile
const { profile } = await courier.getProfile({
profileId: "<PROFILE_ID>"
});
console.log(profile);
};

@@ -32,0 +56,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc