nodemailer-unione-transport
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -5,3 +5,3 @@ { | ||
"description": "A transport module to use with nodemailer to leverage UniOne's REST API (http://www.unisender.com/?a=opencart)", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "type": "git", |
@@ -0,0 +0,0 @@ nodemailer-unione-transport |
@@ -15,3 +15,3 @@ 'use strict'; | ||
*/ | ||
function Unione(options) { | ||
function UnioneTransport(options) { | ||
options = options || {}; | ||
@@ -34,3 +34,3 @@ | ||
UnioneTransport.prototype.send = function (mail, callback) { | ||
this.sendMessage(mail, callback); | ||
this.sendMail(mail.data, callback); | ||
}; | ||
@@ -42,3 +42,3 @@ | ||
*/ | ||
UnioneTransport.prototype.sendMessage = function (mail, callback) { | ||
UnioneTransport.prototype.sendMail = function (mail, callback) { | ||
this.callUnioneAPI('/ru/transactional/api/v1/email/send.json', mail, (function (err, res) { | ||
@@ -48,7 +48,15 @@ if (err) { | ||
} | ||
try { | ||
var response = JSON.parse(res.body); | ||
} | ||
catch(err) { | ||
return typeof callback === 'function' && callback(new Error('UniOne Error: non-JSON response')); | ||
} | ||
/** | ||
* @todo Обработка статуса отправки письма от UniOne | ||
* Обработка статуса отправки письма от UniOne | ||
*/ | ||
console.log(res); | ||
callback(err, res); | ||
if (response.status == 'error') { | ||
return typeof callback === 'function' && callback(new Error('UniOne Error: '+response.message)); | ||
} | ||
return typeof callback === 'function' && callback(null, response); | ||
}).bind(this)); | ||
@@ -64,8 +72,7 @@ }; | ||
} | ||
request({ | ||
method: 'post', | ||
url: url, | ||
form: json | ||
form: JSON.stringify(json) | ||
}, callback); | ||
} |
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
7417
5
64