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

mailerlite

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mailerlite - npm Package Compare versions

Comparing version

to
0.4.0

test/client.js

32

api/campaigns.js

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

'use strict';
'use strict'
module.exports = Campaigns;
module.exports = Campaigns

@@ -20,4 +20,4 @@ /**

page: page
});
};
})
}

@@ -29,4 +29,4 @@ /**

this.getDetails = (id) => {
return client.Get(`/campaigns/${id}`);
};
return client.Get(`/campaigns/${id}`)
}

@@ -43,4 +43,4 @@ /**

page: page
});
};
})
}

@@ -57,4 +57,4 @@ /**

page: page
});
};
})
}

@@ -71,4 +71,4 @@ /**

page: page
});
};
})
}

@@ -85,4 +85,4 @@ /**

page: page
});
};
})
}

@@ -99,4 +99,4 @@ /**

page: page
});
};
})
}
}

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

'use strict';
'use strict'
module.exports = Lists;
module.exports = Lists

@@ -10,3 +10,3 @@ /**

*/
function Lists(client) {
function Lists (client) {
/**

@@ -21,4 +21,4 @@ * Returns all lists you have in your account. Also basic summary for each list including the ID.

page: page
});
};
})
}

@@ -30,4 +30,4 @@ /**

this.getDetails = (id) => {
return client.Get(`/lists/${id}`);
};
return client.Get(`/lists/${id}`)
}

@@ -42,4 +42,4 @@ /**

name: name
});
};
})
}

@@ -54,4 +54,4 @@ /**

name: name
});
};
})
}

@@ -63,4 +63,4 @@ /**

this.removeList = (id) => {
return client.Delete(`/lists/${id}/`);
};
return client.Delete(`/lists/${id}/`)
}

@@ -77,4 +77,4 @@ /**

page: page
});
};
})
}

@@ -91,4 +91,4 @@ /**

page: page
});
};
})
}

@@ -105,4 +105,4 @@ /**

page: page
});
};
})
}
}

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

'use strict';
'use strict'
module.exports = Subscribers;
module.exports = Subscribers

@@ -26,4 +26,4 @@ /**

resubscribe: resubscribe ? 1 : 0
});
};
})
}

@@ -42,4 +42,4 @@ /**

resubscribe: resubscribe ? 1 : 0
});
};
})
}

@@ -55,4 +55,4 @@ /**

history: history
});
};
})
}

@@ -67,4 +67,4 @@ /**

email: email
});
};
})
}

@@ -78,4 +78,4 @@ /**

email: email
});
};
})
}
}
{
"url": "https://app.mailerlite.com/api/v1"
}

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

'use strict';
'use strict'
/* Load RESTful client wrapper. */
var Client = require('./lib/client');
var Campaigns = require('./api/campaigns');
var Lists = require('./api/lists');
var Subscribers = require('./api/subscribers');
var Client = require('./lib/client')
var Campaigns = require('./api/campaigns')
var Lists = require('./api/lists')
var Subscribers = require('./api/subscribers')

@@ -14,12 +14,12 @@ /**

*/
function MailerLite(apiKey) {
var client = new Client(apiKey);
function MailerLite (apiKey) {
var client = new Client(apiKey)
/* Register submodules. */
this.Campaigns = new Campaigns(client);
this.Lists = new Lists(client);
this.Subscribers = new Subscribers(client);
this.Campaigns = new Campaigns(client)
this.Lists = new Lists(client)
this.Subscribers = new Subscribers(client)
}
/* Export the library. */
module.exports = MailerLite;
module.exports = MailerLite

@@ -0,0 +0,0 @@ {

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

'use strict';
'use strict'
/* Load Request module. */
var request = require('request');
var request = require('request')
/* Load static config. */
var config = require('../config');
var config = require('../config')

@@ -15,13 +15,13 @@ /**

function Client (apiKey) {
this.ApiKey = apiKey || process.env.MAILERLITE_API_KEY;
this.ApiKey = apiKey || process.env.MAILERLITE_API_KEY
/* Generates the call URL. */
var makeUrl = (method) => {
return `${config.url}${method}?apiKey=${this.ApiKey}`;
};
return `${config.url}${method}?apiKey=${this.ApiKey}`
}
/* Generic request method. */
var makeRequest = (verb, method, parameters) => {
let uri = makeUrl(method);
let uri = makeUrl(method)
let promise = new Promise((resolve, reject) => {

@@ -32,28 +32,28 @@ /* Prepare callback for request. */

if (err) {
reject(err);
reject(err)
} else {
let data = JSON.parse(body);
let data = JSON.parse(body)
/* Caught a data error. */
if (data && data.error) {
reject(data.error);
reject(data.error)
} else {
/* Resolved successfully. */
resolve(data);
resolve(data)
}
}
};
}
/* Send callback to request. */
request[verb](uri, parameters, cb);
});
request[verb](uri, parameters, cb)
})
/* Returns a promise. */
return promise;
};
return promise
}
/* GET method. */
this.Get = (method, parameters) => {
return makeRequest('get', method, parameters);
};
return makeRequest('get', method, parameters)
}

@@ -64,12 +64,12 @@ /* POST method. */

form: parameters
});
};
})
}
/* DELETE method. */
this.Delete = (method) => {
return makeRequest('del', method);
};
return makeRequest('del', method)
}
}
/* Export the submodule. */
module.exports = Client;
module.exports = Client
{
"name": "mailerlite",
"version": "0.3.1",
"version": "0.4.0",
"description": "Node.js wrapper for MailerLite API.",
"main": "index.js",
"scripts": {
"make:docs": "node node_modules/jsdoc/jsdoc -c jsdoc.json . -R README.md -d .docs",
"make:docs": "jsdoc -c jsdoc.json . -R README.md -d .docs",
"deploy:docs": "bash deploy.sh",
"test": "npm run test:mocha && npm run test:lint",
"test:lint": "node node_modules/eslint/bin/eslint .",
"test:mocha": "node node_modules/mocha/bin/mocha --timeout 5000"
"test": "npm run test:coveralls && npm run test:lint",
"test:lint": "standard",
"test:mocha": "mocha --timeout 10000",
"test:istanbul": "istanbul cover _mocha --report lcovonly -- -R spec --timeout 10000",
"test:coveralls": "npm run test:istanbul && cat ./coverage/lcov.info | coveralls"
},

@@ -29,6 +31,8 @@ "repository": {

"devDependencies": {
"eslint": "^1.7.3",
"coveralls": "^2.11.8",
"expect.js": "^0.3.1",
"istanbul": "^0.4.2",
"jsdoc": "^3.4.0",
"mocha": "^2.3.3"
"mocha": "^2.3.3",
"standard": "^6.0.7"
},

@@ -35,0 +39,0 @@ "dependencies": {

@@ -6,2 +6,3 @@ # MailerLite SDK for Node.js

[![Travis Build][travis-image]][travis-url]
[![Travis Build][coveralls-image]][coveralls-url]

@@ -47,1 +48,4 @@ Node.js wrapper for MailerLite API.

[travis-image]: https://api.travis-ci.org/fmoliveira/mailerlite-sdk-nodejs.svg
[coveralls-url]: https://coveralls.io/github/fmoliveira/mailerlite-sdk-nodejs?branch=master
[coveralls-image]: https://coveralls.io/repos/github/fmoliveira/mailerlite-sdk-nodejs/badge.svg?branch=master

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

'use strict';
/* global describe, it */
var expect = require('expect.js');
'use strict'
var MailerLite = require('..');
var ML = new MailerLite();
var expect = require('expect.js')
const LIST_NAME = 'Mocha Test';
var MailerLite = require('..')
var ML = new MailerLite()
const LIST_NAME = 'Mocha Test'
const LIST_RENAME = 'Mocha Test After Rename'
describe('Lists', () => {

@@ -14,8 +17,9 @@ it('should return an array', (done) => {

.then((data) => {
expect(data).not.to.be(undefined);
expect(data).to.have.property('Results');
expect(data.Results).to.be.an('array');
done();
});
});
expect(data).to.have.property('Page')
expect(data.Page).to.be.equal(1)
expect(data).to.have.property('Results')
expect(data.Results).to.be.an('array')
done()
})
})

@@ -25,10 +29,114 @@ it('should create a list and immediately remove it', (done) => {

.then((data) => {
expect(data.id).to.be.above(0);
expect(data.name).to.be.equal(LIST_NAME);
return ML.Lists.removeList(data.id);
expect(data.id).to.be.above(0)
expect(data.name).to.be.equal(LIST_NAME)
return ML.Lists.removeList(data.id)
})
.then(() => {
done();
});
});
});
done()
})
})
it('should create a list, get its details and remove it', (done) => {
ML.Lists.addList(LIST_NAME)
.then((data) => ML.Lists.getDetails(data.id))
.then((data) => {
expect(data.id).to.be.above(0)
expect(data.name).to.be.equal(LIST_NAME)
return ML.Lists.removeList(data.id)
})
.then(() => {
done()
})
})
it('should check if all expected list details were retrieved', (done) => {
ML.Lists.addList(LIST_NAME)
.then((data) => ML.Lists.getDetails(data.id))
.then((data) => {
expect(data.id).to.be.above(0)
expect(data).to.have.property('name')
expect(data).to.have.property('date')
expect(data).to.have.property('updated')
expect(data).to.have.property('total')
expect(data).to.have.property('unsubscribed')
expect(data).to.have.property('bounced')
return ML.Lists.removeList(data.id)
})
.then(() => {
done()
})
})
it('should create a list, rename it, check if renamed, and remove it', (done) => {
ML.Lists.addList(LIST_NAME)
.then((data) => ML.Lists.updateList(data.id, LIST_RENAME))
.then((data) => {
expect(data.id).to.be.above(0)
expect(data.name).to.be.equal(LIST_RENAME)
return ML.Lists.removeList(data.id)
})
.then(() => {
done()
})
})
it('should return no active subscribers for a new list', (done) => {
let list_id = 0
ML.Lists.addList(LIST_NAME)
.then((data) => {
list_id = data.id
return ML.Lists.getActiveSubscribers(list_id)
})
.then((data) => {
expect(data).to.have.property('Page')
expect(data.Page).to.be.equal(1)
expect(data).to.have.property('Results')
expect(data.Results).to.be.an('array')
return ML.Lists.removeList(list_id)
})
.then(() => {
done()
})
})
it('should return no unsubscribed subscribers for a new list', (done) => {
let list_id = 0
ML.Lists.addList(LIST_NAME)
.then((data) => {
list_id = data.id
return ML.Lists.getUnsubscribedSubscribers(list_id)
})
.then((data) => {
expect(data).to.have.property('Page')
expect(data.Page).to.be.equal(1)
expect(data).to.have.property('Results')
expect(data.Results).to.be.an('array')
return ML.Lists.removeList(list_id)
})
.then(() => {
done()
})
})
it('should return no bounced subscribers for a new list', (done) => {
let list_id = 0
ML.Lists.addList(LIST_NAME)
.then((data) => {
list_id = data.id
return ML.Lists.getBouncedSubscribers(list_id)
})
.then((data) => {
expect(data).to.have.property('Page')
expect(data.Page).to.be.equal(1)
expect(data).to.have.property('Results')
expect(data.Results).to.be.an('array')
return ML.Lists.removeList(list_id)
})
.then(() => {
done()
})
})
})

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet