-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add examples of subaccounts resource use (#143)
* add examples of subaccounts resource use * Change "SDK" to "client library" in subaccount examples
- Loading branch information
Showing
4 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!'); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!'); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!'); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!'); | ||
} | ||
}); |