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

chore: Remove mail.send helpers with on-behalf-of header #436

Merged
merged 4 commits into from Sep 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -6,3 +6,4 @@ coverage.txt
sendgrid.env
.vscode
prism*
**/.idea/**/*
20 changes: 10 additions & 10 deletions USAGE.md
Expand Up @@ -6000,20 +6000,20 @@ if err != nil {
<a name="on-behalf-of"></a>
# On-Behalf of Subuser

The on-behalf-of header allows you to make calls for a particular subuser through the parent account; this can be useful for automating bulk updates or administering a subuser without changing authentication in your code.
## With Mail Helper Class
The `on-behalf-of` header allows you to make calls for a particular subuser through the parent account. This can be
useful for automating bulk updates or administering a subuser without changing authentication in your code.

```go

client := sendgrid.NewSendClientSubuser(os.Getenv("SENDGRID_API_KEY"), "SUBUSER_USERNAME")

```

## Without Mail Helper Class
## Note
The v3/mail/send endpoint does not support the `on-behalf-of` header. ([Source](
https://docs.sendgrid.com/api-reference/how-to-use-the-sendgrid-v3-api/on-behalf-of-subuser
))

```go

request := sendgrid.GetRequestSubuser(os.Getenv("SENDGRID_API_KEY"), "/v3/mail/send", "https://api.sendgrid.com", "SUBUSER_USERNAME")
request := sendgrid.GetRequestSubuser(
os.Getenv("SENDGRID_API_KEY"), "/v3/tracking_settings/subscription",
"https://api.sendgrid.com", "SUBUSER_USERNAME",
)

```

Expand Down
8 changes: 0 additions & 8 deletions sendgrid.go
Expand Up @@ -47,11 +47,3 @@ func NewSendClient(key string) *Client {
request.Method = "POST"
return &Client{request}
}

// GetRequestSubuser like NewSendClient but with On-Behalf of Subuser
// @return [Client]
func NewSendClientSubuser(key, subuser string) *Client {
request := GetRequestSubuser(key, "/v3/mail/send", "", subuser)
request.Method = "POST"
return &Client{request}
}
5 changes: 0 additions & 5 deletions sendgrid_test.go
Expand Up @@ -84,11 +84,6 @@ func TestGetRequestSubuser(t *testing.T) {
ShouldHaveHeaders(&request, t)
}

func TestNewSendClientSubuser(t *testing.T) {
client := NewSendClientSubuser("API_KEY", "subuserUsername")
ShouldHaveHeaders(&client.Request, t)
}

func getRequest(endpoint string) rest.Request {
return GetRequest("SENDGRID_APIKEY", endpoint, "")
}
Expand Down