chore: Remove mail.send helpers with on-behalf-of header#436
Merged
JenniferMah merged 4 commits intosendgrid:mainfrom Sep 24, 2021
Merged
chore: Remove mail.send helpers with on-behalf-of header#436JenniferMah merged 4 commits intosendgrid:mainfrom
JenniferMah merged 4 commits intosendgrid:mainfrom
Conversation
The sendgrid documentation (and my own findings) say that the mail.send endpoint does not support using the `on-behalf-of` header. [Documentation]( https://docs.sendgrid.com/api-reference/how-to-use-the-sendgrid-v3-api/on-behalf-of-subuser ) Providing the `NewSendClientSubuser` in this SDK causes wasted time because it sets the expectation that this is possible when it is not. I also added guards to the `GetRequestSubuser` function to prevent people from using it with the mail.send endpoint.
| // GetRequestSubuser like GetRequest but with On-Behalf of Subuser | ||
| // @return [Request] a default request object | ||
| func GetRequestSubuser(key, endpoint, host, subuser string) rest.Request { | ||
| if strings.Contains(endpoint, "v3/mail/send") { |
Contributor
There was a problem hiding this comment.
Does using the on-behalf-of with this endpoint throw any error at all? I'm not too sure I like hardcoding this into the logic here.
Contributor
Author
There was a problem hiding this comment.
It does not throw an error, it just silently "fails" by ignoring the header and putting the email on the subuser who owns the API key.
Contributor
Author
There was a problem hiding this comment.
(My primary motivation for this change was so that there would be something to test to guard against someone adding this functionality back in)
Contributor
There was a problem hiding this comment.
I am ok with getting rid of NewSendClientSubuser and updating the documentation since that's not really supported but I don't like adding this hardcoded panic.
JenniferMah
approved these changes
Sep 24, 2021
JenniferMah
reviewed
Sep 24, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The sendgrid documentation (and my own findings) say that the mail.send endpoint
does not support using the
on-behalf-ofheader.Documentation
Providing the
NewSendClientSubuserin this SDK causes wasted time because itsets the expectation that this is possible when it is not.
I also added guards to the
GetRequestSubuserfunction to prevent people fromusing it with the mail.send endpoint.
Fixes
A short description of what this PR does.
Checklist