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

paubox-node

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

paubox-node - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

146

lib/service/apiHelper.js
"use strict";
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var axios = require("axios");
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
var apiHelper = function () {
function apiHelper() {
_classCallCheck(this, apiHelper);
}
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
_createClass(apiHelper, [{
key: "callToAPIByPost",
value: function callToAPIByPost(baseUrl, apiUrl, authHeader, reqBody) {
var apiHeaders = {
Authorization: "" + authHeader,
"Content-type": "application/json"
};
var axios = require("axios");
var axiosInstance = axios.create({
baseURL: baseUrl,
headers: apiHeaders
});
var apiHelper =
/*#__PURE__*/
function () {
function apiHelper() {
_classCallCheck(this, apiHelper);
}
return axiosInstance({ method: "POST", url: apiUrl, data: reqBody, headers: apiHeaders }).then(function (response) {
return response.data;
}).catch(function (error) {
if (error.response) {
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
if (error.response.status == 500) return error.message;else return error.response.data;
} else if (error.request) {
// The request was made but no response was received
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
// http.ClientRequest in node.js
return error.request;
} else {
// Something happened in setting up the request that triggered an Error
return error.message;
}
});
_createClass(apiHelper, [{
key: "callToAPIByPost",
value: function callToAPIByPost(baseUrl, apiUrl, authHeader, reqBody) {
var apiHeaders = {
Authorization: "".concat(authHeader),
"Content-type": "application/json"
};
var axiosInstance = axios.create({
baseURL: baseUrl,
headers: apiHeaders
});
return axiosInstance({
method: "POST",
url: apiUrl,
data: reqBody,
headers: apiHeaders
}).then(function (response) {
return response.data;
})["catch"](function (error) {
if (error.response) {
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
if (error.response.status == 500) return error.message;else return error.response.data;
} else if (error.request) {
// The request was made but no response was received
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
// http.ClientRequest in node.js
return error.request;
} else {
// Something happened in setting up the request that triggered an Error
return error.message;
}
}, {
key: "callToAPIByGet",
value: function callToAPIByGet(baseUrl, apiUrl, authHeader) {
var apiHeaders = {
Authorization: "" + authHeader,
"Content-type": "application/json"
};
var axiosInstance = axios.create({
baseURL: baseUrl,
headers: apiHeaders
});
return axiosInstance({ method: "GET", url: apiUrl, data: null }).then(function (response) {
return response.data;
}).catch(function (error) {
if (error.response) {
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
if (error.response.status == 500) return error.message;else return error.response.data;
} else if (error.request) {
// The request was made but no response was received
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
// http.ClientRequest in node.js
return error.request;
} else {
// Something happened in setting up the request that triggered an Error
return error.message;
}
});
});
}
}, {
key: "callToAPIByGet",
value: function callToAPIByGet(baseUrl, apiUrl, authHeader) {
var apiHeaders = {
Authorization: "".concat(authHeader),
"Content-type": "application/json"
};
var axiosInstance = axios.create({
baseURL: baseUrl,
headers: apiHeaders
});
return axiosInstance({
method: "GET",
url: apiUrl,
data: null
}).then(function (response) {
return response.data;
})["catch"](function (error) {
if (error.response) {
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
if (error.response.status == 500) return error.message;else return error.response.data;
} else if (error.request) {
// The request was made but no response was received
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
// http.ClientRequest in node.js
return error.request;
} else {
// Something happened in setting up the request that triggered an Error
return error.message;
}
}]);
});
}
}]);
return apiHelper;
return apiHelper;
}();
module.exports = function () {
return new apiHelper();
return new apiHelper();
};
"use strict";
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var apiHelper = require("./apiHelper.js");
var _getAuthheader = Symbol('getAuthheader');
var _convertMsgObjtoJSONReqObj = Symbol('convertMsgObjtoJSONReqObj');
var _returnForceSecureNotificationValue = Symbol('returnForceSecureNotificationValue');
var emailService = function () {
var emailService =
/*#__PURE__*/
function () {
function emailService(config) {

@@ -24,5 +31,7 @@ _classCallCheck(this, emailService);

}
if (!config.apiUsername) {
throw new Error("apiUsername is missing.");
}
this.apiKey = config.apiKey;

@@ -34,8 +43,6 @@ this.apiUser = config.apiUsername;

this.version = "v1";
this.baseURL = this.protocol + "//" + this.host + "/" + this.version + "/" + this.apiUser + "/";
}
this.baseURL = "".concat(this.protocol, "//").concat(this.host, "/").concat(this.version, "/").concat(this.apiUser, "/");
} // private methods
// private methods
_createClass(emailService, [{

@@ -51,2 +58,3 @@ key: _getAuthheader,

var forceSecureNotificationValue = null;
if (forceSecureNotification == null || forceSecureNotification == "") {

@@ -56,2 +64,3 @@ return null;

forceSecureNotificationValue = forceSecureNotification.trim().toLowerCase();
if (forceSecureNotificationValue == "true") {

@@ -75,15 +84,12 @@ return true;

var base64EncodedHtmlText = null;
headers.subject = msg.subject;
headers.from = msg.from;
headers["reply-to"] = msg.reply_to;
content["text/plain"] = msg.plaintext; //base 64 encoding html text
content["text/plain"] = msg.plaintext;
//base 64 encoding html text
if (msg.htmltext != null && msg.htmltext != "") {
base64EncodedHtmlText = Buffer.from(msg.htmltext).toString('base64');
}
content["text/html"] = base64EncodedHtmlText;
message.recipients = msg.to;

@@ -98,2 +104,3 @@ message.cc = msg.cc;

var forceSecureNotificationValue = this[_returnForceSecureNotificationValue](msg.forceSecureNotification);
if (forceSecureNotificationValue != null) {

@@ -105,12 +112,8 @@ message.forceSecureNotification = forceSecureNotificationValue;

reqObjectJSON.data = data;
return JSON.stringify(reqObjectJSON);
}
} // public methods
// public methods
}, {
key: "getEmailDisposition",
value: function getEmailDisposition(sourceTrackingId) {
try {

@@ -121,2 +124,3 @@ var apiHelperService = apiHelper();

var apiResponse = response;
if (apiResponse.data == null && apiResponse.sourceTrackingId == null && apiResponse.errors == null) {

@@ -144,4 +148,4 @@ throw apiResponse;

try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
if (!_iteratorNormalCompletion && _iterator["return"] != null) {
_iterator["return"]();
}

@@ -155,2 +159,3 @@ } finally {

}
return apiResponse;

@@ -165,6 +170,5 @@ });

value: function sendMessage(msg) {
try {
var reqObject = this[_convertMsgObjtoJSONReqObj](msg);
var reqObject = this[_convertMsgObjtoJSONReqObj](msg);
var apiHelperService = apiHelper();

@@ -174,5 +178,7 @@ var apiUrl = "/messages";

var apiResponse = response;
if (apiResponse.data == null && apiResponse.sourceTrackingId == null && apiResponse.errors == null) {
throw apiResponse;
}
return apiResponse;

@@ -179,0 +185,0 @@ });

{
"name": "paubox-node",
"version": "1.2.1",
"version": "1.2.2",
"description": "A Node.js module for the Paubox Transactional Email API.",

@@ -16,4 +16,5 @@ "main": "index.js",

"devDependencies": {
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.7.0",
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"chai": "^4.2.0",

@@ -20,0 +21,0 @@ "eslint": "^5.15.2",

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