Skip to content

Commit

Permalink
Version Bump v3.0.4: Update docs, unit tests and examples to include …
Browse files Browse the repository at this point in the history
…Sender ID
  • Loading branch information
thinkingserious committed Jul 12, 2016
1 parent da5517e commit 6af4061
Show file tree
Hide file tree
Showing 24 changed files with 703 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Change Log
All notable changes to this project will be documented in this file.

## [3.0.4] - 2016-07-12
### Added
- Update docs, unit tests and examples to include Sender ID
### Fixed
- Missing example query params for the examples

## [3.0.3] - 2016-07-08
### Fixed
- [Can't disable subscription tracking #68](https://github.com/sendgrid/sendgrid-go/issues/68)
Expand Down
169 changes: 168 additions & 1 deletion USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ host := "https://api.sendgrid.com"
* [MAILBOX PROVIDERS](#mailbox_providers)
* [PARTNER SETTINGS](#partner_settings)
* [SCOPES](#scopes)
* [SENDERS](#senders)
* [STATS](#stats)
* [SUBUSERS](#subusers)
* [SUPPRESSION](#suppression)
Expand Down Expand Up @@ -1920,7 +1921,6 @@ The contactdb is a database of your contacts for [SendGrid Marketing Campaigns](
request := sendgrid.GetRequest(apiKey, "/v3/contactdb/recipients/search", host)
request.Method = "GET"
queryParams := make(map[string]string)
queryParams["%7Bfield_name%7D"] = "test_string"
queryParams["{field_name}"] = "test_string"
request.QueryParams = queryParams
response, err := sendgrid.API(request)
Expand Down Expand Up @@ -3498,6 +3498,173 @@ if err != nil {
}
```

<a name="senders"></a>
# SENDERS

## Create a Sender Identity

**This endpoint allows you to create a new sender identity.**

*You may create up to 100 unique sender identities.*

Sender Identities are required to be verified before use. If your domain has been whitelabeled it will auto verify on creation. Otherwise an email will be sent to the `from.email`.

### POST /senders

```go
request := sendgrid.GetRequest(apiKey, "/v3/senders", host)
request.Method = "POST"
request.Body = []byte(` {
"address": "123 Elm St.",
"address_2": "Apt. 456",
"city": "Denver",
"country": "United States",
"from": {
"email": "[email protected]",
"name": "Example INC"
},
"nickname": "My Sender ID",
"reply_to": {
"email": "[email protected]",
"name": "Example INC"
},
"state": "Colorado",
"zip": "80202"
}`)
response, err := sendgrid.API(request)
if err != nil {
fmt.Println(err)
} else {
fmt.Println(response.StatusCode)
fmt.Println(response.Body)
fmt.Println(response.Headers)
}
```

## Get all Sender Identities

**This endpoint allows you to retrieve a list of all sender identities that have been created for your account.**

Sender Identities are required to be verified before use. If your domain has been whitelabeled it will auto verify on creation. Otherwise an email will be sent to the `from.email`.

### GET /senders

```go
request := sendgrid.GetRequest(apiKey, "/v3/senders", host)
request.Method = "GET"
response, err := sendgrid.API(request)
if err != nil {
fmt.Println(err)
} else {
fmt.Println(response.StatusCode)
fmt.Println(response.Body)
fmt.Println(response.Headers)
}
```

## Update a Sender Identity

**This endpoint allows you to update a sender identity.**

Updates to `from.email` require re-verification. If your domain has been whitelabeled it will auto verify on creation. Otherwise an email will be sent to the `from.email`.

Partial updates are allowed, but fields that are marked as "required" in the POST (create) endpoint must not be nil if that field is included in the PATCH request.

### PATCH /senders/{sender_id}

```go
request := sendgrid.GetRequest(apiKey, "/v3/senders/{sender_id}", host)
request.Method = "PATCH"
request.Body = []byte(` {
"address": "123 Elm St.",
"address_2": "Apt. 456",
"city": "Denver",
"country": "United States",
"from": {
"email": "[email protected]",
"name": "Example INC"
},
"nickname": "My Sender ID",
"reply_to": {
"email": "[email protected]",
"name": "Example INC"
},
"state": "Colorado",
"zip": "80202"
}`)
response, err := sendgrid.API(request)
if err != nil {
fmt.Println(err)
} else {
fmt.Println(response.StatusCode)
fmt.Println(response.Body)
fmt.Println(response.Headers)
}
```

## View a Sender Identity

**This endpoint allows you to retrieve a specific sender identity.**

Sender Identities are required to be verified before use. If your domain has been whitelabeled it will auto verify on creation. Otherwise an email will be sent to the `from.email`.

### GET /senders/{sender_id}

```go
request := sendgrid.GetRequest(apiKey, "/v3/senders/{sender_id}", host)
request.Method = "GET"
response, err := sendgrid.API(request)
if err != nil {
fmt.Println(err)
} else {
fmt.Println(response.StatusCode)
fmt.Println(response.Body)
fmt.Println(response.Headers)
}
```

## Delete a Sender Identity

**This endoint allows you to delete one of your sender identities.**

Sender Identities are required to be verified before use. If your domain has been whitelabeled it will auto verify on creation. Otherwise an email will be sent to the `from.email`.

### DELETE /senders/{sender_id}

```go
request := sendgrid.GetRequest(apiKey, "/v3/senders/{sender_id}", host)
request.Method = "DELETE"
response, err := sendgrid.API(request)
if err != nil {
fmt.Println(err)
} else {
fmt.Println(response.StatusCode)
fmt.Println(response.Body)
fmt.Println(response.Headers)
}
```

## Resend Sender Identity Verification

**This enpdoint allows you to resend a sender identity verification email.**

Sender Identities are required to be verified before use. If your domain has been whitelabeled it will auto verify on creation. Otherwise an email will be sent to the `from.email`.

### POST /senders/{sender_id}/resend_verification

```go
request := sendgrid.GetRequest(apiKey, "/v3/senders/{sender_id}/resend_verification", host)
request.Method = "POST"
response, err := sendgrid.API(request)
if err != nil {
fmt.Println(err)
} else {
fmt.Println(response.StatusCode)
fmt.Println(response.Body)
fmt.Println(response.Headers)
}
```

<a name="stats"></a>
# STATS

Expand Down
3 changes: 3 additions & 0 deletions examples/accesssettings/accesssettings.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ func Retrieveallrecentaccessattempts() {
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/access_settings/activity", host)
request.Method = "GET"
queryParams := make(map[string]string)
queryParams["limit"] = "1"
request.QueryParams = queryParams
response, err := sendgrid.API(request)
if err != nil {
fmt.Println(err)
Expand Down
3 changes: 3 additions & 0 deletions examples/apikeys/apikeys.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ func RetrieveallAPIKeysbelongingtotheauthenticateduser() {
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/api_keys", host)
request.Method = "GET"
queryParams := make(map[string]string)
queryParams["limit"] = "1"
request.QueryParams = queryParams
response, err := sendgrid.API(request)
if err != nil {
fmt.Println(err)
Expand Down
3 changes: 3 additions & 0 deletions examples/asm/asm.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ func Retrieveinformationaboutmultiplesuppressiongroups() {
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/asm/groups", host)
request.Method = "GET"
queryParams := make(map[string]string)
queryParams["id"] = "1"
request.QueryParams = queryParams
response, err := sendgrid.API(request)
if err != nil {
fmt.Println(err)
Expand Down
8 changes: 8 additions & 0 deletions examples/browsers/browsers.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ func Retrieveemailstatisticsbybrowser() {
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/browsers/stats", host)
request.Method = "GET"
queryParams := make(map[string]string)
queryParams["end_date"] = "2016-04-01"
queryParams["aggregated_by"] = "day"
queryParams["browsers"] = "test_string"
queryParams["limit"] = "test_string"
queryParams["offset"] = "test_string"
queryParams["start_date"] = "2016-01-01"
request.QueryParams = queryParams
response, err := sendgrid.API(request)
if err != nil {
fmt.Println(err)
Expand Down
4 changes: 4 additions & 0 deletions examples/campaigns/campaigns.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ func RetrieveallCampaigns() {
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/campaigns", host)
request.Method = "GET"
queryParams := make(map[string]string)
queryParams["limit"] = "1"
queryParams["offset"] = "1"
request.QueryParams = queryParams
response, err := sendgrid.API(request)
if err != nil {
fmt.Println(err)
Expand Down
22 changes: 22 additions & 0 deletions examples/categories/categories.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ func Retrieveallcategories() {
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/categories", host)
request.Method = "GET"
queryParams := make(map[string]string)
queryParams["category"] = "test_string"
queryParams["limit"] = "1"
queryParams["offset"] = "1"
request.QueryParams = queryParams
response, err := sendgrid.API(request)
if err != nil {
fmt.Println(err)
Expand All @@ -34,6 +39,14 @@ func RetrieveEmailStatisticsforCategories() {
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/categories/stats", host)
request.Method = "GET"
queryParams := make(map[string]string)
queryParams["end_date"] = "2016-04-01"
queryParams["aggregated_by"] = "day"
queryParams["limit"] = "1"
queryParams["offset"] = "1"
queryParams["start_date"] = "2016-01-01"
queryParams["categories"] = "test_string"
request.QueryParams = queryParams
response, err := sendgrid.API(request)
if err != nil {
fmt.Println(err)
Expand All @@ -53,6 +66,15 @@ func Retrievesumsofemailstatsforeachcategory() {
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/categories/stats/sums", host)
request.Method = "GET"
queryParams := make(map[string]string)
queryParams["end_date"] = "2016-04-01"
queryParams["aggregated_by"] = "day"
queryParams["limit"] = "1"
queryParams["sort_by_metric"] = "test_string"
queryParams["offset"] = "1"
queryParams["start_date"] = "2016-01-01"
queryParams["sort_by_direction"] = "asc"
request.QueryParams = queryParams
response, err := sendgrid.API(request)
if err != nil {
fmt.Println(err)
Expand Down
10 changes: 10 additions & 0 deletions examples/clients/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ func Retrieveemailstatisticsbyclienttype() {
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/clients/stats", host)
request.Method = "GET"
queryParams := make(map[string]string)
queryParams["aggregated_by"] = "day"
queryParams["start_date"] = "2016-01-01"
queryParams["end_date"] = "2016-04-01"
request.QueryParams = queryParams
response, err := sendgrid.API(request)
if err != nil {
fmt.Println(err)
Expand All @@ -34,6 +39,11 @@ func Retrievestatsbyaspecificclienttype() {
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/clients/{client_type}/stats", host)
request.Method = "GET"
queryParams := make(map[string]string)
queryParams["aggregated_by"] = "day"
queryParams["start_date"] = "2016-01-01"
queryParams["end_date"] = "2016-04-01"
request.QueryParams = queryParams
response, err := sendgrid.API(request)
if err != nil {
fmt.Println(err)
Expand Down
Loading

0 comments on commit 6af4061

Please sign in to comment.