Skip to content

Conversation

@suda
Copy link
Contributor

@suda suda commented May 19, 2020

No description provided.

@suda suda requested a review from busticated May 19, 2020 18:08
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.4%) to 40.757% when pulling 52e1763 on features/support-headers into ac9909f on master.

return api.changeUserPassword({ auth: 'X', currentPassword: 'blabla', password: 'blabla2', invalidateTokens: true })
.then((results) => {
results.should.eql({
results.should.match({
Copy link
Contributor

Choose a reason for hiding this comment

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

i'd rather be confident in exactly what we're sending in and should's .match() behavior strikes me as a bit too clever (docs). was .eql() causing issues?

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, i see - .match() is already being used in a bunch of places... 🤷‍♂️

for (const key of Object.keys(headers)) {
req.set(key, headers[key]);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

i think you could just do:

if (headers){
    req.set(headers);
}

(docs)

}
if (query) {
req.query(query);
}
Copy link
Contributor

@busticated busticated May 19, 2020

Choose a reason for hiding this comment

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

comparing to #115 which closely duplicates this functionality, i see a couple of key differences:

  1. i refactored all the base http methods (.get(), .put(), etc) to accept an object instead of individual params as i find more than 3 fn args unwieldy
  2. i tried to clean up .createWebhook() as it has always accepted a headers object and thus conflicted with the new headers arg / prop (see here)
  3. i made .downloadFile() use uri instead of url for uniformity

one downside of my approach is that it definitely represents a breaking change so a bump from 8 to 9 is warranted.

i'm on the fence... i'm not sure how disruptive it'd be to go with my refactor as the appeal of the lib isn't its base http methods... but if i had to pick i guess i'd go with my approach if only because of item 2 in my list above. not a super-strongly held position though.

Copy link
Contributor

Choose a reason for hiding this comment

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

actually, there's another even bigger difference between this and #115 - the later extends every high-level method (e.g. .sendOtp(), .createCustomer(), etc) to optionally accept headers which is think is useful (perhaps necessary?)

so, eesh... yeah, another point in favor of adopting #115 i guess. sorry for the churn, let's chat about how best to divide an conquer 👍

@busticated
Copy link
Contributor

busticated commented May 20, 2020

@suda ok, per #119 (comment) i went ahead and rebased #115 and ported your changes over to another PR (#121 ) which currently targets the feature/headers branch.

if all that looks good, i say we ship it (first merge #115 branch to master then rebase #121, retarget to master, merge, and release v9.0.0).

sorry again for the churn / weirdness on all this 🙏❤️

@suda suda closed this May 20, 2020
@suda suda deleted the features/support-headers branch May 20, 2020 12:33
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.

4 participants