Permalink
Browse files

formatting README

  • Loading branch information...
1 parent 3b5f8d6 commit 3f51eaf0c9d7ae9e1781cf5455600eaffc125c81 Prajwal Tuladhar committed Jan 17, 2012
Showing with 97 additions and 77 deletions.
  1. +97 −77 README.md
View
@@ -14,99 +14,119 @@ Examples
--------
### Initialization
- var apiKey = '******',
- apiSecret = '*****',
- sailthru = require('sailthru-client').createSailthruClient(apiKey, apiSecret);
+
+``` js
+var apiKey = '******',
+ apiSecret = '*****',
+ sailthru = require('sailthru-client').createSailthruClient(apiKey, apiSecret);
+```
### Getting version
- var version = require('sailthru-client').VERSION;
+
+``` js
+var version = require('sailthru-client').VERSION;
+```
### Enable / Disable LOgging
- sailthru.enableLogging();
- sailthru.disableLogging();
+``` js
+sailthru.enableLogging();
+sailthru.disableLogging();
+```
### Making POST Request
- var data = {
- email: 'praj@infynyxx.com',
- lists: {
- 'list-a': 1
- }
- };
- sailthru.apiPost('email', data, function(response, err) {
- if (!err) {
- console.log(response);
- } else {
- console.log('Error!');
- console.log(err);'
- }
- });
+
+``` js
+var data = {
+ email: 'praj@infynyxx.com',
+ lists: {
+ 'list-a': 1
+ }
+};
+sailthru.apiPost('email', data, function(response, err) {
+ if (!err) {
+ console.log(response);
+ } else {
+ console.log('Error!');
+ console.log(err);'
+ }
+});
+```
### Making POST Request with multipart (Eg: Job API call with import type)
- // Making import /job API POST call
- // MUltipart call
- var data = {
- job: 'import',
- list: 'test-list',
- file: './emails.txt'
- };
- var multipart_params = ['file']; // this is required to mark file as a multipart upload item'
- sailthru.apiPost('job', data, function(response, err) {
- console.log(response);
- }, multipart_params);
+
+``` js
+// Making import /job API POST call
+// MUltipart call
+var data = {
+ job: 'import',
+ list: 'test-list',
+ file: './emails.txt'
+};
+var multipart_params = ['file']; // this is required to mark file as a multipart upload item'
+sailthru.apiPost('job', data, function(response, err) {
+ console.log(response);
+}, multipart_params);
+```
### Making GET Request
- // Making /send API GET call
- var send_id = 'TE8EZ3-LmosnAgAA';
- sailthru.apiGet('send', {send_id: send_id}, function(response, err) {
- console.log(response);
- });
+``` js
+// Making /send API GET call
+var send_id = 'TE8EZ3-LmosnAgAA';
+sailthru.apiGet('send', {send_id: send_id}, function(response, err) {
+ console.log(response);
+});
+```
### Making DELETE Request
- // /send API DELETE call
- var send_id = 'TE8EZ3-LmosnAgAA';
- sailthru.apiDelete('send', {send_id: send_id}, function(response, err) {
- console.log(response);
- });
+``` js
+// /send API DELETE call
+var send_id = 'TE8EZ3-LmosnAgAA';
+sailthru.apiDelete('send', {send_id: send_id}, function(response, err) {
+ console.log(response);
+});
+```
### [send](http://docs.sailthru.com/api/send)
- //send
- var template = 'my-template',
- email = 'praj@sailthru.com',
- options = {
- 'vars': {
- 'name': 'Prajwal Tuladhar',
- 'address': 'Queens, NY'
- },
- 'options': {
- 'test': 1,
- 'replyto': 'praj@infynyxx.com'
- }
- };
- sailthru.send(template, email, function(response, err) {
- if (err) {
- console.log("Status Code: " + err.statusCode);
- console.log("Error Code: " + err.error);
- console.log("Error Message: " + err.errormsg);
- } else {
- //process output
+``` js
+//send
+var template = 'my-template',
+ email = 'praj@sailthru.com',
+ options = {
+ 'vars': {
+ 'name': 'Prajwal Tuladhar',
+ 'address': 'Queens, NY'
+ },
+ 'options': {
+ 'test': 1,
+ 'replyto': 'praj@infynyxx.com'
}
- }, options);
-
- //multi-send
- var emails = ['praj@sailthru.com', 'ian@sailthru.com', 'will@sailthru.com'],
- template = 'multi-template',
- options = {
- 'options': {
- 'test': 1
- }
- };
- sailthru.multiSend(template, emails, function(response, err) {
- if (err) {
- //Process error
- } else {
- //process JSON output
+ };
+sailthru.send(template, email, function(response, err) {
+ if (err) {
+ console.log("Status Code: " + err.statusCode);
+ console.log("Error Code: " + err.error);
+ console.log("Error Message: " + err.errormsg);
+ } else {
+ //process output
+ }
+}, options);
+
+//multi-send
+var emails = ['praj@sailthru.com', 'ian@sailthru.com', 'will@sailthru.com'],
+ template = 'multi-template',
+ options = {
+ 'options': {
+ 'test': 1
}
- }, options);
+ };
+sailthru.multiSend(template, emails, function(response, err) {
+ if (err) {
+ //Process error
+ } else {
+ //process JSON output
+ }
+}, options);
+```

0 comments on commit 3f51eaf

Please sign in to comment.