Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adding more examples

    POST and Multipart POST Example
    GET and DELETE Example
  • Loading branch information...
commit 4daaafd7de61f715870e40e536360790f350117e 1 parent 5f0c3b5
@infynyxx infynyxx authored
Showing with 53 additions and 2 deletions.
  1. +49 −0 README.md
  2. +2 −2 lib/sailthru.js
  3. +2 −0  src/sailthru.coffee
View
49 README.md
@@ -19,6 +19,55 @@ Examples
apiSecret = '*****',
sailthru = require('sailthru-client').createSailthruClient(apiKey, apiSecret);
+### Enable / Disable LOgging
+
+ 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);'
+ }
+ });
+
+### 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);
+
+
+### 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);
+ });
+
+### 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);
+ });
+
### [send](http://docs.sailthru.com/api/send)
//send
View
4 lib/sailthru.js
@@ -122,10 +122,10 @@
return this.request._api_request(_url.href + action, json_payload, method, callback);
};
SailthruClient.prototype.enableLogging = function() {
- return LOGGING = true;
+ LOGGING = true;
};
SailthruClient.prototype.disableLogging = function() {
- return LOGGING = false;
+ LOGGING = false;
};
SailthruClient.prototype.apiGet = function(action, data, callback) {
return this._apiRequest(action, data, 'GET', callback);
View
2  src/sailthru.coffee
@@ -100,9 +100,11 @@ class SailthruClient
enableLogging: ->
LOGGING = true
+ return
disableLogging: ->
LOGGING = false
+ return
# Native API methods: GET< DELETE and POST
apiGet: (action, data, callback) ->
Please sign in to comment.
Something went wrong with that request. Please try again.