Comparing version 0.0.1 to 0.1.0
28
index.js
@@ -72,2 +72,29 @@ var | ||
}, | ||
createCampaign: function(o,cb) { | ||
if (!o.from_name) cb(new Error('Missing "from_name" parameter'), null); | ||
if (!o.from_email) cb(new Error('Missing "from_email" parameter'), null); | ||
if (!o.reply_to) cb(new Error('Missing "reply_to" parameter'), null); | ||
if (!o.subject) cb(new Error('Missing "subject" parameter'), null); | ||
if (!o.html_text) cb(new Error('Missing "html_text" parameter'), null); | ||
if (o.send_campaign) { | ||
o.send_campign = 1; | ||
if (!o.list_ids) cb(new Error('Missing "list_ids" parameter')); | ||
} | ||
if (!o.send_campign) { | ||
o.send_campign = 0; | ||
if(!o.brand_id) cb(new Error('Missing "brand_id" parameter')); | ||
} | ||
else { | ||
o.api_key = this.apiKey; | ||
this.request('api/campaigns/create.php', o, function(err,response,body){ | ||
if (err) cb(err,null); | ||
else { | ||
var success = ['Campaign created','Campaign created and now sending']; | ||
if (success.indexOf(body) === -1) cb(new Error(body), null); | ||
else cb(null,body); | ||
} | ||
}); | ||
} | ||
}, | ||
request: function(path, params, cb) { | ||
@@ -86,4 +113,5 @@ params.boolean = true; | ||
}; | ||
for (var k in prty) module.exports.prototype[k] = prty[k]; | ||
{ | ||
"name": "sendy-api", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "sendy api for node", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -74,1 +74,22 @@ sendy-api | ||
``` | ||
#### createCampaign | ||
```js | ||
var params = { | ||
from_name: 'Your name', | ||
from_email: 'email@example.com', | ||
reply_to: 'email@example.com', | ||
subject: 'Your Subject', | ||
plain_text: 'Campaign text' // optional | ||
html_text: '<h1>Campaign text</h1>', | ||
send_campaign: 'true' // optional, set to false if you just want to create a draft campaign | ||
list_ids: 'your_list_id' // seperate multiple lists with a comma. Only required if send_campaign parameter is true | ||
brand_id: 'your_brand_id' // only required if send_campaign parameter is false | ||
}; | ||
sendy.createCampaign(params, function(err,result){ | ||
if (err) console.log(err.toString()); | ||
else console.log(result); | ||
}); | ||
``` |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
108
95
6727
4