Skip to content
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

Merged
merged 8 commits into from
Nov 1, 2016

Conversation

aydrian
Copy link
Contributor

@aydrian aydrian commented Oct 31, 2016

This PR should finish and close issue #175.

  • Refactored Message Events
  • Refactored Transmissions
  • Updated Subaccounts examples

@@ -4,7 +4,8 @@ var key = 'YOURAPIKEY'
, SparkPost = require('sparkpost')
, client = new SparkPost(key);

client.transmissions.find('YOUR-TRANsMISSION-KEY')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what a weird typo

Copy link
Contributor Author

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';
Copy link
Contributor

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.

Copy link
Contributor Author

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)
Copy link
Contributor

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)
Copy link
Contributor

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()));
Copy link
Contributor

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({})
Copy link
Contributor

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 🤓

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@aydrian aydrian added this to the 2.0.0 Release milestone Nov 1, 2016

// Promise
client.messageEvents.search(searchParams)
.then((err, data) => {
Copy link
Contributor

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) => {
Copy link
Contributor

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) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no err

@colestrode
Copy link
Contributor

lgtm :shipit:

@aydrian aydrian merged commit 6557288 into SparkPost:wip-2.0.0 Nov 1, 2016
@aydrian aydrian deleted the issue-175 branch November 1, 2016 18:55
@aydrian aydrian mentioned this pull request Nov 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants