Skip to content

Commit

Permalink
chore: Remove mail.send helpers with on-behalf-of header (#436)
Browse files Browse the repository at this point in the history
Co-authored-by: Jennifer Mah <42650198+JenniferMah@users.noreply.github.com>
  • Loading branch information
bjohnson-va and JenniferMah committed Sep 24, 2021
1 parent 7d25f1d commit 332b5e2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 23 deletions.
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

0 comments on commit 332b5e2

Please sign in to comment.