sendgrid-nodejs icon indicating copy to clipboard operation
sendgrid-nodejs copied to clipboard

Email Client should be enhanced for instances specific to it's key

Open aimythgit opened this issue 3 years ago • 6 comments

Issue Summary

The email client should allow instances of client as opposed to a singleton to facilitate multiple keys Almost every SaaS provider client has instances and this client too should provide an option while the current simpler one can be used by those who do not have this use case. The whole purpose of a client is for the statefulness else the corresponding stateless REST API can be used directly without the clients.

Code Snippet

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

paste code here

const SgMailClient = require('@sendgrid/mailClient');

const client1 = new SgMailClient();
client1.setApiKey(process.env.SENDGRIDClient1_API_KEY);

const client2 = new SgMailClient();
client2.setApiKey(process.env.SENDGRIDClient2_API_KEY);

// logic for using client 1 or client 2 to send mail

aimythgit avatar Jul 04 '21 22:07 aimythgit