From f5ac3549582a96d0e22ad952b5eb3d1fb9436cad Mon Sep 17 00:00:00 2001 From: scottmotte Date: Mon, 30 Dec 2013 15:12:31 -0800 Subject: [PATCH] use jsonString --- README.md | 8 ++++---- lib/main.js | 6 +++--- test/main.js | 24 ++++++++++++------------ 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index d21c3e4..7e91f3b 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ var header = smtpapi.Header(); header.addTo('you@youremail.com'); header.setUniqueArgs({cow: 'chicken'}); -var smtpapi_header_string = header.toJsonString(); +var smtpapi_header_string = header.jsonString(); ``` See [this](http://sendgrid.com/docs/API_Reference/SMTP_API/) for more information on the available X-SMTPAPI custom handling instructions. @@ -47,14 +47,14 @@ var smtpapi = require('smtpapi'); var header = new smtpapi.Header(); ``` -### toJsonString +### jsonString This gives you back the stringified json formatted X-SMTPAPI header. Use this with your [smtp client](https://github.com/andris9/simplesmtp) of choice. ```javascript var smtpapi = require('smtpapi'); var header = new smtpapi.Header(); -header.toJsonString(); +header.jsonString(); ``` ### addTo @@ -172,7 +172,7 @@ header.addTo('you@youremail.com'); header.setUniqueArgs({cow: 'chicken'}); // Add the smtpapi header to the general headers -var headers = { 'x-smtpapi': header.toJsonString() }; +var headers = { 'x-smtpapi': header.jsonString() }; // Use nodemailer to send the email var settings = { diff --git a/lib/main.js b/lib/main.js index 40b61a0..9028cc0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -20,8 +20,8 @@ Header.prototype.addTo = function(to) { } }; -Header.prototype.setTos = function(to) { - this.to = to; +Header.prototype.setTos = function(tos) { + this.to = tos; }; Header.prototype.addSubstitution = function(key, val) { @@ -104,7 +104,7 @@ Header.prototype.toJson = function() { return data; }; -Header.prototype.toJsonString = function() { +Header.prototype.jsonString = function() { var json = JSON.stringify(this.toJson()); return json; diff --git a/test/main.js b/test/main.js index 7bd08cf..92f028d 100644 --- a/test/main.js +++ b/test/main.js @@ -14,31 +14,31 @@ describe('smtapi', function() { }); describe('.Header', function() { - it('has a toJsonString method', function() { + it('has a jsonString method', function() { var header = new smtpapi.Header(); - header.toJsonString().should.eql('{}'); + header.jsonString().should.eql('{}'); }); it('addTo', function() { var header = new smtpapi.Header(); header.addTo('addTo@mailinator.com'); - header.toJsonString().should.eql('{"to":["addTo@mailinator.com"]}'); + header.jsonString().should.eql('{"to":["addTo@mailinator.com"]}'); }); it('addSubstitution', function() { var header = new smtpapi.Header(); header.addSubstitution('sub', 'val'); - header.toJsonString().should.eql('{"sub":{"sub":["val"]}}'); + header.jsonString().should.eql('{"sub":{"sub":["val"]}}'); }); it('setUniqueArgs', function() { var header = new smtpapi.Header(); header.setUniqueArgs({set_unique_argument_key: 'set_unique_argument_value'}); - header.toJsonString().should.eql('{"unique_args":{"set_unique_argument_key":"set_unique_argument_value"}}'); + header.jsonString().should.eql('{"unique_args":{"set_unique_argument_key":"set_unique_argument_value"}}'); }); it('addUniqueArg', function() { @@ -46,14 +46,14 @@ describe('smtapi', function() { header.addUniqueArg({add_unique_argument_key: 'add_unique_argument_value'}); header.addUniqueArg({add_unique_argument_key_2: 'add_unique_argument_value_2'}); - header.toJsonString().should.eql('{"unique_args":{"add_unique_argument_key":"add_unique_argument_value","add_unique_argument_key_2":"add_unique_argument_value_2"}}'); + header.jsonString().should.eql('{"unique_args":{"add_unique_argument_key":"add_unique_argument_value","add_unique_argument_key_2":"add_unique_argument_value_2"}}'); }); it('setCategories', function() { var header = new smtpapi.Header(); header.setCategories(['setCategory']); - header.toJsonString().should.eql('{"category":["setCategory"]}'); + header.jsonString().should.eql('{"category":["setCategory"]}'); }); it('addCategory', function() { @@ -61,14 +61,14 @@ describe('smtapi', function() { header.addCategory('addCategory'); header.addCategory('addCategory2'); - header.toJsonString().should.eql('{"category":["addCategory","addCategory2"]}'); + header.jsonString().should.eql('{"category":["addCategory","addCategory2"]}'); }); it('setSections', function() { var header = new smtpapi.Header(); header.setSections({'set_section_key': 'set_section_value'}); - header.toJsonString().should.eql('{"section":{"set_section_key":"set_section_value"}}'); + header.jsonString().should.eql('{"section":{"set_section_key":"set_section_value"}}'); }); it('addSection', function() { @@ -76,7 +76,7 @@ describe('smtapi', function() { header.addSection({'set_section_key': 'set_section_value'}); header.addSection({'set_section_key_2': 'set_section_value_2'}); - header.toJsonString().should.eql('{"section":{"set_section_key":"set_section_value","set_section_key_2":"set_section_value_2"}}'); + header.jsonString().should.eql('{"section":{"set_section_key":"set_section_value","set_section_key_2":"set_section_value_2"}}'); }); it('setFilters', function() { @@ -92,14 +92,14 @@ describe('smtapi', function() { } header.setFilters(filter); - header.toJsonString().should.eql('{"filters":{"footer":{"setting":{"enable":1,"text/plain":"You can haz footers!"}}}}'); + header.jsonString().should.eql('{"filters":{"footer":{"setting":{"enable":1,"text/plain":"You can haz footers!"}}}}'); }); it('addFilter', function() { var header = new smtpapi.Header(); header.addFilter('footer', 'text/html', 'boo'); - header.toJsonString().should.eql('{"filters":{"footer":{"settings":{"text/html":"boo"}}}}'); + header.jsonString().should.eql('{"filters":{"footer":{"settings":{"text/html":"boo"}}}}'); }); });