Skip to content

Commit

Permalink
add examples of subaccounts resource use (#143)
Browse files Browse the repository at this point in the history
* add examples of subaccounts resource use

* Change "SDK" to "client library" in subaccount examples
  • Loading branch information
coldacid authored and aydrian committed Apr 27, 2016
1 parent cf092a9 commit 440cd15
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
22 changes: 22 additions & 0 deletions examples/subaccounts/create_subaccount.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

var key = 'YOURAPIKEY'
, SparkPost = require('sparkpost')
, client = new SparkPost(key)
, options = {
name: 'Test Subaccount'
, keyLabel: 'Test Subaccount key'
, keyGrants: [
'smtp/inject'
, 'transmissions/modify'
]
};

client.subaccounts.create(options, function(err, res) {
if (err) {
console.log(err);
} else {
console.log(res);
console.log('Congrats you can use our client library!');
}
});
14 changes: 14 additions & 0 deletions examples/subaccounts/get_all_subaccounts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

var key = 'YOURAPIKEY'
, SparkPost = require('sparkpost')
, client = new SparkPost(key);

client.subaccounts.all(function(err, res) {
if (err) {
console.log(err);
} else {
console.log(res.body);
console.log('Congrats you can use our client library!');
}
});
14 changes: 14 additions & 0 deletions examples/subaccounts/get_subaccount.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

var key = 'YOURAPIKEY'
, SparkPost = require('sparkpost')
, client = new SparkPost(key);

client.subaccounts.find(123, function(err, res) {
if (err) {
console.log(err);
} else {
console.log(res.body);
console.log('Congrats you can use our client library!');
}
});
19 changes: 19 additions & 0 deletions examples/subaccounts/update_subaccount.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use strict';

var key = 'YOURAPIKEY'
, SparkPost = require('sparkpost')
, client = new SparkPost(key)
, options = {
subaccountId: 123
, name: 'Test Subaccount'
, status: 'suspended'
};

client.subaccounts.update(options, function(err, res) {
if (err) {
console.log(err);
} else {
console.log(res.body);
console.log('Congrats you can use our client library!');
}
});

0 comments on commit 440cd15

Please sign in to comment.