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

Allow method chaining in @sendgrid/mail #682

Closed
reichert621 opened this issue Apr 29, 2018 · 3 comments · Fixed by #712
Closed

Allow method chaining in @sendgrid/mail #682

reichert621 opened this issue Apr 29, 2018 · 3 comments · Fixed by #712
Labels
difficulty: medium fix is medium in difficulty type: community enhancement feature request not on Twilio's roadmap

Comments

@reichert621
Copy link

Issue Summary

Very minor, but it would be nice to allow method chaining in the MailService of @sendgrid/mail so that setting the API key could be handled on one line:

const mailer = require('@sendgrid/mail').setApiKey(process.env.SENDGRID_API_KEY);

// vs

const mailer = require('@sendgrid/mail');

mailer.setApiKey(process.env.SENDGRID_API_KEY);

This is all it would require as far as I can tell:

class MailService {
  // ...

  setClient(client) {
    this.client = client;

    return this; // TODO (optional, but good for consistency)
  }

  setApiKey(apiKey) {
    this.client.setApiKey(apiKey);

    return this; // TODO
  }

  setSubstitutionWrappers(left, right) {
    // ...

    return this; // TODO (optional, but good for consistency)
  }

  // ...
}

(It looks like this pattern is used here in @sendgrid/client https://github.com/sendgrid/sendgrid-nodejs/blob/master/packages/client/src/classes/client.js#L53-L67 as well.)

Steps to Reproduce

  1. Install @sendgrid/mail
  2. Set the API key

Technical details:

  • sendgrid-nodejs version ^6.2.1
@thinkingserious thinkingserious added type: community enhancement feature request not on Twilio's roadmap status: help wanted requesting help from the community difficulty: easy fix is easy in difficulty up-for-grabs labels May 2, 2018
@thinkingserious
Copy link
Contributor

Thanks for the suggestion @reichert621!

I've added this to our backlog for consideration.

Please feel free to submit a PR as well :)

@AllUsernamesHaveBeenTaken
Copy link

AllUsernamesHaveBeenTaken commented Oct 4, 2018

Hello, can I handle this one? Thank you!

@thinkingserious thinkingserious added status: work in progress Twilio or the community is in the process of implementing difficulty: medium fix is medium in difficulty and removed difficulty: easy fix is easy in difficulty good first issue status: help wanted requesting help from the community labels Oct 11, 2018
@thinkingserious
Copy link
Contributor

Thank you @AllUsernamesHaveBeenTaken! It's all yours.

@childish-sambino childish-sambino removed the status: work in progress Twilio or the community is in the process of implementing label Oct 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: medium fix is medium in difficulty type: community enhancement feature request not on Twilio's roadmap
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants