Skip to content

Commit 440cd15

Browse files
charabarukaydrian
authored andcommitted
add examples of subaccounts resource use (#143)
* add examples of subaccounts resource use * Change "SDK" to "client library" in subaccount examples
1 parent cf092a9 commit 440cd15

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'use strict';
2+
3+
var key = 'YOURAPIKEY'
4+
, SparkPost = require('sparkpost')
5+
, client = new SparkPost(key)
6+
, options = {
7+
name: 'Test Subaccount'
8+
, keyLabel: 'Test Subaccount key'
9+
, keyGrants: [
10+
'smtp/inject'
11+
, 'transmissions/modify'
12+
]
13+
};
14+
15+
client.subaccounts.create(options, function(err, res) {
16+
if (err) {
17+
console.log(err);
18+
} else {
19+
console.log(res);
20+
console.log('Congrats you can use our client library!');
21+
}
22+
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'use strict';
2+
3+
var key = 'YOURAPIKEY'
4+
, SparkPost = require('sparkpost')
5+
, client = new SparkPost(key);
6+
7+
client.subaccounts.all(function(err, res) {
8+
if (err) {
9+
console.log(err);
10+
} else {
11+
console.log(res.body);
12+
console.log('Congrats you can use our client library!');
13+
}
14+
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'use strict';
2+
3+
var key = 'YOURAPIKEY'
4+
, SparkPost = require('sparkpost')
5+
, client = new SparkPost(key);
6+
7+
client.subaccounts.find(123, function(err, res) {
8+
if (err) {
9+
console.log(err);
10+
} else {
11+
console.log(res.body);
12+
console.log('Congrats you can use our client library!');
13+
}
14+
});
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
'use strict';
2+
3+
var key = 'YOURAPIKEY'
4+
, SparkPost = require('sparkpost')
5+
, client = new SparkPost(key)
6+
, options = {
7+
subaccountId: 123
8+
, name: 'Test Subaccount'
9+
, status: 'suspended'
10+
};
11+
12+
client.subaccounts.update(options, function(err, res) {
13+
if (err) {
14+
console.log(err);
15+
} else {
16+
console.log(res.body);
17+
console.log('Congrats you can use our client library!');
18+
}
19+
});

0 commit comments

Comments
 (0)