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

sparkpost

Package Overview
Dependencies
Maintainers
4
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sparkpost - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

.idea/dictionaries/ahoward.xml

68

ajh_test.js
// NODE SDK Test Key
// e2e1b620ff9cf2db919d3c40160c4851d445d454
/*
var key = 'e2e1b620ff9cf2db919d3c40160c4851d445d454'//'YOURAPIKEY'
, SparkPost = require('../../lib/sparkpost')//require('sparkpost')
*/
var SparkPost = require('./lib/sparkpost'),
client = new SparkPost('e2e1b620ff9cf2db919d3c40160c4851d445d454');
var key = 'a09759fb7b8c81cb8878acb7b1aa8b91ff6a6e2d'
, SparkPost = require('./lib/sparkpost')
, sparky = new SparkPost(key)
, nock = require('nock');
nock('https://api.sparkpost.com')
.post('/api/v1/transmissions')
.reply(422);
sparky.transmissions.send({
transmissionBody: {
content: {
//from: 'testing@sparkpostbox.com',
subject: 'Oh hey!',
html:'<html><body><h1>Hi John!</h1><p>Jack just shared graph with you</p><p><a href="https://some.url.here/blablabla">View here</a></p></body></html>'
},
recipients: [
{address: 'aydrian@sparkpost.com'}
]
}
}, function(err, res) {
if (err) {
console.log('Whoops! Something went wrong');
console.log(err);
console.log(res.body)
} else {
console.log('Woohoo! You just sent your first mailing!');
}
});
/*client.relayWebhooks.update(options, function(err, res) {
if (err) {
console.log(err);
} else {
console.log(res.request);
console.log(res.body);
}
});*/
/*client.relayWebhooks.all(function(err, res) {
if (err) {
console.log(err);
} else {
console.log(res.body);
}
});
client.templates.all(function(err, res) {
if (err) {
console.log(err);
} else {
console.log(res.body);
}
});*/
/*var SparkPost = require('./lib/sparkpost'),
client = new SparkPost('e2e1b620ff9cf2db919d3c40160c4851d445d454');*/
/*client.sendingDomains.all(function(err, res) {

@@ -59,3 +111,3 @@ if (err) {

};*/
/*
var txBody = {

@@ -123,1 +175,3 @@ "options": {

*/
## Change Log
### v1.3.0 (2016/04/01)
- [#129](https://github.com/SparkPost/node-sparkpost/pull/129) Added support for subaccounts (@coldacid)
- [#126](https://github.com/SparkPost/node-sparkpost/pull/126) body might be undefined (@mstdokumaci)
- [#121](https://github.com/SparkPost/node-sparkpost/pull/121) Added support for Relay Webhooks (@aydrian)
- [#119](https://github.com/SparkPost/node-sparkpost/pull/119) Added support for inbound domains (@aydrian)
- [#118](https://github.com/SparkPost/node-sparkpost/pull/118) Added support for deleting a sending domain (@aydrian)
- [#115](https://github.com/SparkPost/node-sparkpost/pull/115) ReadMe "Hello World" Example (@JimTheMan)
### v1.2.0 (2016/03/14)

@@ -4,0 +12,0 @@ - [#109](https://github.com/SparkPost/node-sparkpost/pull/109) README updates (@aydrian)

@@ -24,2 +24,6 @@ # Sending Domains

* `callback` - see all function
* **delete(domain, callback)**
Delete an existing sending domain
* `domain` - the name of the domain you want to delete **required**
* `callback` - see all function
* **verify(options, callback)**

@@ -26,0 +30,0 @@ Validate the specified verification field types for a sending domain

@@ -10,2 +10,3 @@ 'use strict';

* - update: updates an existing sending domain
* - delete: deletes an existing sending domain
* - verify: validates specified verification field types on a sending domain

@@ -17,3 +18,3 @@ * - all: retreives a list of sending domains

return {
var sendingDomains = {
all: function (callback) { //list

@@ -86,2 +87,18 @@ var options = {

},
delete: function(domain, callback) {
if (typeof domain === 'function') {
callback = domain;
domain = null;
}
if (!domain) {
callback(new Error('domain is required'));
return;
}
var options = {
uri: api + '/' + domain
};
client.delete(options, callback);
},
verify: function (options, callback) {

@@ -106,2 +123,4 @@ options = options || {};

};
return sendingDomains;
};

5

lib/sparkpost.js

@@ -58,3 +58,6 @@ 'use strict';

this.inboundDomains = require('./inboundDomains')(this);
this.messageEvents = require('./messageEvents')(this);
this.recipientLists = require('./recipientLists')(this);
this.relayWebhooks = require('./relayWebhooks')(this);
this.sendingDomains = require('./sendingDomains')(this);

@@ -65,3 +68,2 @@ this.suppressionList = require('./suppressionList')(this);

this.webhooks = require('./webhooks')(this);
this.messageEvents = require('./messageEvents')(this);
};

@@ -100,2 +102,3 @@

} else if(invalidCodeRegex.test(res.statusCode)) {
body = body || {};
err = new Error(res.statusMessage);

@@ -102,0 +105,0 @@ err.name = 'SparkPostError';

{
"name": "sparkpost",
"version": "1.2.0",
"version": "1.3.0",
"description": "A Node.js wrapper for interfacing with your favorite SparkPost APIs",

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

@@ -104,8 +104,39 @@ <a href="https://www.sparkpost.com"><img src="https://www.sparkpost.com/sites/default/files/attachments/SparkPost_Logo_2-Color_Gray-Orange_RGB.svg" width="200px"/></a>

## Send An Email "Hello World" Example
Below is an example of how to send a simple email. Sending an email is known as a *transmission*. By using the send method on the transmissions service that's available from the SparkPost object you instatiate you can pass in a *transmissionBody* object with all the information relevant to the email being sent. The send method also takes a callback method that will let you know if the email was sent successful and if not information about the error that ocurred.
```javascript
var SparkPost = require('sparkpost');
var sp = new SparkPost('<YOUR API KEY>');
sp.transmissions.send({
transmissionBody: {
content: {
from: 'testing@sparkpostbox.com',
subject: 'Hello, World!',
html:'<html><body><p>Testing SparkPost - the world\'s most awesomest email service!</p></body></html>'
},
recipients: [
{address: '<YOUR EMAIL ADDRESS>'}
]
}
}, function(err, res) {
if (err) {
console.log('Whoops! Something went wrong');
console.log(err);
} else {
console.log('Woohoo! You just sent your first mailing!');
}
});
```
## SparkPost API Resources Supported in Node Client Library
Click on the desired API to see usage and more information
* [Inbound Domains](/docs/resources/inboundDomains.md) - `client.inboundDomains` ([examples](/examples/inboundDomains))
* [Message Events](/docs/resources/messageEvents.md) - `client.messageEvents` ([examples](/examples/messageEvents))
* [Recipient Lists](/docs/resources/recipientLists.md) - `client.recipientLists` ([examples](/examples/recipientLists))
* [Relay Webhooks](/docs/resources/relayWebhooks.md) - `client.relayWebhooks` ([examples](/examples/relayWebhooks))
* [Sending Domains](/docs/resources/sendingDomains.md) - `client.sendingDomains` ([examples](/examples/sendingDomains))
* [Subaccounts](/docs/resources/subaccounts.md) - `client.subaccounts` ([examples](/examples/subaccounts))
* [Suppression List](/docs/resources/suppressionList.md) - `client.suppressionList` ([examples](/examples/suppressionList))

@@ -112,0 +143,0 @@ * [Templates](/docs/resources/templates.md) - `client.templates` ([examples](/examples/templates))

@@ -15,3 +15,4 @@ var chai = require('chai')

post: sinon.stub().yields(),
put: sinon.stub().yields()
put: sinon.stub().yields(),
delete: sinon.stub().yields()
};

@@ -130,2 +131,27 @@

describe('delete Method', function() {
it('should call client delete method with the appropriate uri', function(done) {
sendingDomains.delete('test', function(err, data) {
expect(client.delete.firstCall.args[0].uri).to.equal('sending-domains/test');
done();
});
});
it('should throw an error if domain is null', function(done) {
sendingDomains.delete(null, function(err) {
expect(err.message).to.equal('domain is required');
expect(client.delete).not.to.have.been.called;
done();
});
});
it('should throw an error if domain is missing', function(done) {
sendingDomains.delete(function(err) {
expect(err.message).to.equal('domain is required');
expect(client.delete).not.to.have.been.called;
done();
});
});
});
describe('verify Method', function() {

@@ -132,0 +158,0 @@ it('should call client post method with the appropriate uri', function(done) {

@@ -152,2 +152,24 @@ var chai = require('chai')

it('should return an error if statusCode not 2XX and there is no body', function(done) {
// simulate a timeout
nock('https://api.sparkpost.com')
.post('/api/v1/post/test/fail')
.reply(422);
var options = {
method: 'POST'
, uri: 'post/test/fail'
};
client.request(options, function(err, data) {
expect(data).to.be.defined;
expect(err).to.be.defined;
expect(err.errors).to.be.undefined;
// finish async test
done();
});
});
it('should use a full URI if provided', function(done) {

@@ -198,3 +220,3 @@ nock('https://test.sparkpost.com')

expect(data.body).to.equal(TEST_MESSAGE + TEST_MESSAGE);
// finish async test

@@ -201,0 +223,0 @@ done();

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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