-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Standardized action verbs on remaining libraries #184
Conversation
@@ -4,7 +4,8 @@ var key = 'YOURAPIKEY' | |||
, SparkPost = require('sparkpost') | |||
, client = new SparkPost(key); | |||
|
|||
client.transmissions.find('YOUR-TRANsMISSION-KEY') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what a weird typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah... I fixed a lot of weird typos.. like tranmission
@@ -1,33 +1,22 @@ | |||
'use strict'; | |||
|
|||
var api = 'message-events'; | |||
const api = 'message-events'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we dropping node 0.12 support? I think I remember that discussion somewhere, but just wanted to make sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is correct. We are dropping support for 0.10 and 0.12. If they are still using those versions, they can use version 1.x of the library.
messageEvents.search(options, function(err, data) { | ||
Object.keys(options).forEach(function(key) { | ||
expect(client.get.firstCall.args[0].qs).to.have.property(key).and.equal(options[key]); | ||
messageEvents.search(options) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you'll need to return this promise as well to tell mocha to wait for the test, otherwise it will move on before the test completes
if (Array.isArray(opt)) { | ||
expect(firstCallQS).to.have.property(key).and.equal(opt.toString()); | ||
} | ||
messageEvents.search(arroptions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add return
var opt = arroptions[key] | ||
, firstCallQS = client.get.firstCall.args[0].qs; | ||
if (Array.isArray(opt)) { | ||
tests.push(expect(firstCallQS).to.have.property(key).and.equal(opt.toString())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are synchronous expectations, so no need to wrap them in the promise later. Expect will throw an error if the assertion fails, and that will result in a rejected promise since we are inside a then
callback`.
@@ -4,6 +4,18 @@ var key = 'YOURAPIKEY' | |||
, SparkPost = require('sparkpost') | |||
, client = new SparkPost(key); | |||
|
|||
// Promise | |||
client.messageEvents.search({}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
technically this returns 1000 events for the last hour 🤓
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just refactored the example. We can add a comment, change the name of the file, etc. Open to suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And that's not in the API docs.
|
||
// Promise | ||
client.messageEvents.search(searchParams) | ||
.then((err, data) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these promise callbacks shouldn't take an err object :) I just spent a few minutes trying to get this example to work before I realized what was happening
|
||
// Promise | ||
client.messageEvents.search({}) | ||
.then((err, data) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no err argument
|
||
// Promise | ||
client.messageEvents.search(searchParams) | ||
.then((err, data) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no err
lgtm |
This PR should finish and close issue #175.