New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@splitmedialabs/supermailer-node

Package Overview
Dependencies
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@splitmedialabs/supermailer-node - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

lib/helpers.js

9

package.json
{
"name": "@splitmedialabs/supermailer-node",
"description": "Node JS library for Supermailer.",
"version": "2.0.0",
"version": "2.0.1",
"license": "MIT",

@@ -14,8 +14,3 @@ "repository": "https://github.com/SplitmediaLabsLimited/supermailer-node",

"scripts": {
"test": "yarn test:recipients && yarn test:data",
"test:data": "jest __tests__/automated/data/*test.js",
"test:recipients": "yarn test:recipients:create && yarn test:recipients:update && yarn test:recipients:delete",
"test:recipients:create": "NODE_TLS_REJECT_UNAUTHORIZED=0 jest __tests__/automated/recipients/create.test.js",
"test:recipients:delete": "NODE_TLS_REJECT_UNAUTHORIZED=0 jest __tests__/automated/recipients/delete.test.js",
"test:recipients:update": "NODE_TLS_REJECT_UNAUTHORIZED=0 jest __tests__/automated/recipients/update.test.js"
"test": "TZ=UTC jest ./test/*"
},

@@ -22,0 +17,0 @@ "dependencies": {

@@ -0,10 +1,10 @@

const { argsValidation } = require('../../lib/helpers');
module.exports = function addBoolean(name, value) {
if (typeof name !== 'string' || name.length < 1 || typeof value !== 'boolean') {
throw new Error(
'Supermailer.data.addBoolean needs two parameters. First one is the name (string) and second one is the value (boolean).'
);
}
argsValidation.call(arguments);
const bool = value;
if (value === null) return (this.attributes[name] = null);
const bool = String(value) === '1' || String(value) === 'true';
this.attributes[name] = bool;

@@ -11,0 +11,0 @@

@@ -1,19 +0,9 @@

const isParseableDate = dateString => !!Date.parse(dateString);
const { argsValidation } = require('../../lib/helpers');
const isSlashFormat = dateString => dateString.includes('/');
module.exports = function addDate(name, value) {
if (typeof name !== 'string' || name.length < 1 || typeof value !== 'string' || value.length < 1) {
throw new Error(
'Supermailer.data.addDate needs two parameters. First one is the name of the attribute (string) and the second one is a date string.'
);
}
argsValidation.call(arguments);
if (isSlashFormat(value)) {
throw new Error("You can't pass a date string with slashes in it.");
}
if (value === null) return (this.attributes[name] = null);
if (!isParseableDate(value)) {
throw new Error('You need to pass a valid date string as the second parameter to Supermailer.data.addDate.');
}
if (value === '') value = new Date();

@@ -20,0 +10,0 @@ const date = new Date(Date.parse(value)).toISOString();

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

const { argsValidation } = require('../../lib/helpers');
module.exports = function addEvent(name) {
if (typeof name !== 'string' || name.length < 1) {
throw new Error('Supermailer.data.addEvent needs a single parameter which is the event name (string).');
throw new Error(
`First parameter passed to ${parentFunctionName} has to be the name of the attribute an has to be of type string.`
);
}

@@ -5,0 +9,0 @@

@@ -1,10 +0,14 @@

module.exports = function addInteger(name, value) {
if (typeof name !== 'string' || name.length < 1 || typeof value !== 'number' || value.length < 1) {
throw new Error(
'Supermailer.data.addInteger needs two parameters. First one is the name (string) and second one is the value (number).'
);
const { argsValidation } = require('../../lib/helpers');
module.exports = function addNumber(name, value) {
argsValidation.call(arguments);
if (value === null) return (this.attributes[name] = null);
const number = Number(value);
if (isNaN(number)) {
throw new Error('The second parameter is a string that cannot be converted into a number.');
}
const number = value;
this.attributes[name] = number;

@@ -11,0 +15,0 @@

@@ -0,10 +1,10 @@

const { argsValidation } = require('../../lib/helpers');
module.exports = function addString(name, value) {
if (typeof name !== 'string' || name.length < 1 || typeof value !== 'string' || value.length < 1) {
throw new Error(
'Supermailer.data.addString needs two parameters. First one is the name (string) and second one is the value (string).'
);
}
argsValidation.call(arguments);
const string = value;
if (value === null) return (this.attributes[name] = null);
const string = String(value);
this.attributes[name] = string;

@@ -11,0 +11,0 @@

@@ -13,9 +13,4 @@ module.exports = async function create() {

try {
const response = await this.api.post(`/api/supermailer/recipients`, payload);
return response.data;
} catch (error) {
console.log(error);
return false;
}
const response = await this.api.post(`/api/supermailer/recipients`, payload);
return response.data;
};
module.exports = async function _delete() {
try {
const response = await this.api.delete(`/api/supermailer/recipients/${this.email}`);
return response.data;
} catch (error) {
console.log(error);
return false;
}
const response = await this.api.delete(`/api/supermailer/recipients/${this.email}`);
return response.data;
};

@@ -9,11 +9,7 @@ const qs = require('query-string');

try {
const payload = { filterBy: JSON.stringify({ email }), page: offset, pageSize: limit };
const query = qs.stringify(payload);
const response = await this.api.get(`/api/supermailer/logs?${query}`);
return response.data.results;
} catch (error) {
console.log(error);
return false;
}
const payload = { filterBy: JSON.stringify({ email }), page: offset, pageSize: limit };
const query = qs.stringify(payload);
const response = await this.api.get(`/api/supermailer/logs?${query}`);
return response.data.results;
};
const get = require('lodash/get');
module.exports = async function read() {
try {
const response = await this.api.get(`/api/supermailer/recipients/${this.email}`);
return get(response, 'data.results[0]', null);
} catch (error) {
console.log(error);
return false;
}
const response = await this.api.get(`/api/supermailer/recipients/${this.email}`);
return get(response, 'data.results[0]', null);
};

@@ -17,9 +17,4 @@ module.exports = async function update() {

try {
const response = await this.api.patch(`/api/supermailer/recipients/${currentEmail}`, payload);
return response.data;
} catch (error) {
console.log(error);
return false;
}
const response = await this.api.patch(`/api/supermailer/recipients/${currentEmail}`, payload);
return response.data;
};
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