Skip to content

Commit

Permalink
Updated sending domains verbs, tests, docs, and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonrhodes committed Sep 6, 2016
1 parent feed164 commit 45760da
Show file tree
Hide file tree
Showing 11 changed files with 151 additions and 191 deletions.
69 changes: 20 additions & 49 deletions docs/resources/sendingDomains.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,63 +2,34 @@

This library provides easy access to the [Sending Domains](https://developers.sparkpost.com/api/sending-domains) Resource.

*Note: All methods return promises and accept an optional last argument callback. [Read about how we handle callbacks and promises](/docs/async.md).*

## Methods
* **all([callback]) &rarr; `{Promise}`**<br />
* **list()**<br />
List an overview of all sending domains in the account.
* `callback` - executed after task is completed if provided*
* standard `callback(err, data)`
* `err` - any error that occurred
* `data` - full response from request client
* **find(domain[, callback]) &rarr; `{Promise}`**<br />

* **get(domain)**<br />
Retrieve a sending domain by its domain name
* `domain` - the name of the domain you want to look up **required**
* `callback` - see all function
* **create(sendingDomain[, callback]) &rarr; `{Promise}`**<br />
* `domain` - the domain you want to look up **required**

* **create(createOpts)**<br />
Create a new sending domain
* `sendingDomain` - an object of [sending domain attributes](https://developers.sparkpost.com/api/sending-domains#header-sending-domain-attributes) **required**
* `callback` - see all function
* **update(sendingDomain[, callback]) &rarr; `{Promise}`**<br />
* `createOpts` - a hash of [sending domain attributes](https://developers.sparkpost.com/api/sending-domains#header-sending-domain-attributes) **required**

* **update(domain, updateOpts)**<br />
Update an existing sending domain
* `sendingDomain` - an object of [sending domain attributes](https://developers.sparkpost.com/api/sending-domains#header-sending-domain-attributes) **required**
* `callback` - see all function
* **delete(domain[, callback]) &rarr; `{Promise}`**<br />
* `domain` - the domain you want to update **required**
* `updateOpts` - a hash of [sending domain attributes](https://developers.sparkpost.com/api/sending-domains#header-sending-domain-attributes) **required**

* **delete(domain)**<br />
Delete an existing sending domain
* `domain` - the name of the domain you want to delete **required**
* `callback` - see all function
* **verify(options[, callback]) &rarr; `{Promise}`**<br />
* `domain` - the domain you want to delete **required**

* **verify(domain[, options])**<br />
Validate the specified verification field types for a sending domain
* `domain` - the domain you want to verify **required**
* `options` - an object of [verify attributes](https://developers.sparkpost.com/api/sending-domains#header-verify-attributes)
* `options.domain` - the name of the domain you want to verify **required**

*callback is optional because all methods return a Promise.

## Examples

```javascript
var SparkPost = require('sparkpost')
, client = new SparkPost('YOUR_API_KEY');

client.sendingDomains.all()
.then(data => {
console.log('Woohoo! It worked!');
console.log(data);
})
.catch(err => {
console.log('Whoops! Something went wrong');
console.log(err);
});

// Using a callback
client.sendingDomains.all(function(err, data) {
if(err) {
console.log('Whoops! Something went wrong');
console.log(err);
} else {
console.log('Woohoo! It worked!');
console.log(data);
}
});

```

Check out all the examples provided [here](/examples/sendingDomains).
Visit our examples section to see all of [our sending domains resource examples](/examples/sendingDomains).
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
var key = 'YOURAPIKEY'
, SparkPost = require('sparkpost')
, client = new SparkPost(key)
, sendingDomain = {
, createOpts = {
domain: 'example1.com',
dkim: {
'private': 'MIICXgIBAAKBgQC+W6scd3XWwvC/hPRksfDYFi3ztgyS9OSqnnjtNQeDdTSD1DRx/xFar2wjmzxp2+SnJ5pspaF77VZveN3P/HVmXZVghr3asoV9WBx/uW1nDIUxU35L4juXiTwsMAbgMyh3NqIKTNKyMDy4P8vpEhtH1iv/BrwMdBjHDVCycB8WnwIDAQABAoGBAITb3BCRPBi5lGhHdn+1RgC7cjUQEbSb4eFHm+ULRwQ0UIPWHwiVWtptZ09usHq989fKp1g/PfcNzm8c78uTS6gCxfECweFCRK6EdO6cCCr1cfWvmBdSjzYhODUdQeyWZi2ozqd0FhGWoV4VHseh4iLj36DzleTLtOZj3FhAo1WJAkEA68T+KkGeDyWwvttYtuSiQCCTrXYAWTQnkIUxduCp7Ap6tVeIDn3TaXTj74UbEgaNgLhjG4bX//fdeDW6PaK9YwJBAM6xJmwHLPMgwNVjiz3u/6fhY3kaZTWcxtMkXCjh1QE82KzDwqyrCg7EFjTtFysSHCAZxXZMcivGl4TZLHnydJUCQQCx16+M+mAatuiCnvxlQUMuMiSTNK6Amzm45u9v53nlZeY3weYMYFdHdfe1pebMiwrT7MI9clKebz6svYJVmdtXAkApDAc8VuR3WB7TgdRKNWdyGJGfoD1PO1ZE4iinOcoKV+IT1UCY99Kkgg6C7j62n/8T5OpRBvd5eBPpHxP1F9BNAkEA5Nf2VO9lcTetksHdIeKK+F7sio6UZn0Rv7iUo3ALrN1D1cGfWIh2dj3ko1iSreyNVSwGW0ePP27qDmU+u6/Y1g==',
Expand All @@ -13,7 +13,8 @@ var key = 'YOURAPIKEY'
}
};

client.sendingDomains.create(sendingDomain)
// Promise
client.sendingDomains.create(createOpts)
.then(data => {
console.log('Congrats you can use our client library!');
console.log(data);
Expand All @@ -23,8 +24,8 @@ client.sendingDomains.create(sendingDomain)
console.log(err);
});

// Using a callback
client.sendingDomains.create(sendingDomain, function(err, data) {
// Callback
client.sendingDomains.create(createOpts, function(err, data) {
if (err) {
console.log('Whoops! Something went wrong');
console.log(err);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var key = 'YOURAPIKEY'
, SparkPost = require('sparkpost')
, client = new SparkPost(key);

// Promise
client.sendingDomains.delete('example1.com')
.then(data => {
console.log('Congrats you can use our client library!');
Expand All @@ -14,7 +15,7 @@ client.sendingDomains.delete('example1.com')
console.log(err);
});

// Using a callback
// Callback
client.sendingDomains.delete('example1.com', function(err, data) {
if (err) {
console.log('Whoops! Something went wrong');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ var key = 'YOURAPIKEY'
, SparkPost = require('sparkpost')
, client = new SparkPost(key);

client.sendingDomains.find('example1.com')
// Promise
client.sendingDomains.get('example1.com')
.then(data => {
console.log('Congrats you can use our client library!');
console.log(data);
Expand All @@ -14,8 +15,8 @@ client.sendingDomains.find('example1.com')
console.log(err);
});

// Using a callback
client.sendingDomains.find('example1.com', function(err, data) {
// Callback
client.sendingDomains.get('example1.com', function(err, data) {
if (err) {
console.log('Whoops! Something went wrong');
console.log(err);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ var key = 'YOURAPIKEY'
, SparkPost = require('sparkpost')
, client = new SparkPost(key);

client.sendingDomains.all()
// Promise
client.sendingDomains.list()
.then(data => {
console.log('Congrats you can use our client library!');
console.log(data);
Expand All @@ -14,8 +15,8 @@ client.sendingDomains.all()
console.log(err);
});

// Using a callback
client.sendingDomains.all(function(err, data) {
// Callback
client.sendingDomains.list(function(err, data) {
if (err) {
console.log('Whoops! Something went wrong');
console.log(err);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
var key = 'YOURAPIKEY'
, SparkPost = require('sparkpost')
, client = new SparkPost(key)
, sendingDomain = {
domain: 'example1.com',
, updateOpts = {
dkim: {
'private': 'MIICXgIBAAKBgQC+W6scd3XWwvC/hPRksfDYFi3ztgyS9OSqnnjtNQeDdTSD1DRx/xFar2wjmzxp2+SnJ5pspaF77VZveN3P/HVmXZVghr3asoV9WBx/uW1nDIUxU35L4juXiTwsMAbgMyh3NqIKTNKyMDy4P8vpEhtH1iv/BrwMdBjHDVCycB8WnwIDAQABAoGBAITb3BCRPBi5lGhHdn+1RgC7cjUQEbSb4eFHm+ULRwQ0UIPWHwiVWtptZ09usHq989fKp1g/PfcNzm8c78uTS6gCxfECweFCRK6EdO6cCCr1cfWvmBdSjzYhODUdQeyWZi2ozqd0FhGWoV4VHseh4iLj36DzleTLtOZj3FhAo1WJAkEA68T+KkGeDyWwvttYtuSiQCCTrXYAWTQnkIUxduCp7Ap6tVeIDn3TaXTj74UbEgaNgLhjG4bX//fdeDW6PaK9YwJBAM6xJmwHLPMgwNVjiz3u/6fhY3kaZTWcxtMkXCjh1QE82KzDwqyrCg7EFjTtFysSHCAZxXZMcivGl4TZLHnydJUCQQCx16+M+mAatuiCnvxlQUMuMiSTNK6Amzm45u9v53nlZeY3weYMYFdHdfe1pebMiwrT7MI9clKebz6svYJVmdtXAkApDAc8VuR3WB7TgdRKNWdyGJGfoD1PO1ZE4iinOcoKV+IT1UCY99Kkgg6C7j62n/8T5OpRBvd5eBPpHxP1F9BNAkEA5Nf2VO9lcTetksHdIeKK+F7sio6UZn0Rv7iUo3ALrN1D1cGfWIh2dj3ko1iSreyNVSwGW0ePP27qDmU+u6/Y1g==',
'public': 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC+W6scd3XWwvC/hPRksfDYFi3ztgyS9OSqnnjtNQeDdTSD1DRx/xFar2wjmzxp2+SnJ5pspaF77VZveN3P/HVmXZVghr3asoV9WBx/uW1nDIUxU35L4juXiTwsMAbgMyh3NqIKTNKyMDy4P8vpEhtH1iv/BrwMdBjHDVCycB8WnwIDAQAB',
Expand All @@ -13,7 +12,7 @@ var key = 'YOURAPIKEY'
}
};

client.sendingDomains.update(sendingDomain)
client.sendingDomains.update('example1.com', updateOpts)
.then(data => {
console.log('Congrats you can use our client library!');
console.log(data);
Expand All @@ -24,7 +23,7 @@ client.sendingDomains.update(sendingDomain)
});

// Using a callback
client.sendingDomains.update(sendingDomain, function(err, data) {
client.sendingDomains.update('example1.com', updateOpts, function(err, data) {
if (err) {
console.log('Whoops! Something went wrong');
console.log(err);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ var key = 'YOURAPIKEY'
, SparkPost = require('sparkpost')
, client = new SparkPost(key)
, options = {
domain: 'example1.com',
dkim_verify: true,
spf_verify: true,
abuse_at_verify: true,
postmaster_at_verify: true
};

client.sendingDomains.verify(options)
// Promise
client.sendingDomains.verify('example1.com', options)
.then(data => {
console.log('Congrats you can use our client library!');
console.log(data);
Expand All @@ -21,8 +21,8 @@ client.sendingDomains.verify(options)
console.log(err);
});

// Using a callback
client.sendingDomains.verify(options, function(err, data) {
// Callback
client.sendingDomains.verify('example1.com', options, function(err, data) {
if (err) {
console.log('Whoops! Something went wrong');
console.log(err);
Expand Down
30 changes: 0 additions & 30 deletions examples/sendingDomains/verify_sendingDomain_dkim_only.js

This file was deleted.

30 changes: 0 additions & 30 deletions examples/sendingDomains/verify_sendingDomain_spf_only.js

This file was deleted.

Loading

0 comments on commit 45760da

Please sign in to comment.