diff --git a/examples/accesssettings/accesssettings.go b/examples/accesssettings/accesssettings.go index f5589762..8e11da63 100644 --- a/examples/accesssettings/accesssettings.go +++ b/examples/accesssettings/accesssettings.go @@ -2,15 +2,14 @@ package main import ( "fmt" - "github.com/sendgrid/sendgrid-go" "log" "os" + + "github.com/sendgrid/sendgrid-go" ) -/////////////////////////////////////////////////// -// Retrieve all recent access attempts +// Retrieveallrecentaccessattempts Retrieve all recent access attempts // GET /access_settings/activity - func Retrieveallrecentaccessattempts() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -29,10 +28,8 @@ func Retrieveallrecentaccessattempts() { } } -/////////////////////////////////////////////////// -// Add one or more IPs to the whitelist +// AddoneormoreIPstothewhitelist Add one or more IPs to the whitelist // POST /access_settings/whitelist - func AddoneormoreIPstothewhitelist() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -42,10 +39,10 @@ func AddoneormoreIPstothewhitelist() { "ips": [ { "ip": "192.168.1.1" - }, + }, { "ip": "192.*.*.*" - }, + }, { "ip": "192.168.1.3/32" } @@ -61,10 +58,8 @@ func AddoneormoreIPstothewhitelist() { } } -/////////////////////////////////////////////////// -// Retrieve a list of currently whitelisted IPs +// RetrievealistofcurrentlywhitelistedIPs Retrieve a list of currently whitelisted IPs // GET /access_settings/whitelist - func RetrievealistofcurrentlywhitelistedIPs() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -80,10 +75,8 @@ func RetrievealistofcurrentlywhitelistedIPs() { } } -/////////////////////////////////////////////////// -// Remove one or more IPs from the whitelist +// RemoveoneormoreIPsfromthewhitelist Remove one or more IPs from the whitelist // DELETE /access_settings/whitelist - func RemoveoneormoreIPsfromthewhitelist() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -91,8 +84,8 @@ func RemoveoneormoreIPsfromthewhitelist() { request.Method = "DELETE" request.Body = []byte(` { "ids": [ - 1, - 2, + 1, + 2, 3 ] }`) @@ -106,10 +99,8 @@ func RemoveoneormoreIPsfromthewhitelist() { } } -/////////////////////////////////////////////////// -// Retrieve a specific whitelisted IP +// RetrieveaspecificwhitelistedIP Retrieve a specific whitelisted IP // GET /access_settings/whitelist/{rule_id} - func RetrieveaspecificwhitelistedIP() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -125,10 +116,8 @@ func RetrieveaspecificwhitelistedIP() { } } -/////////////////////////////////////////////////// -// Remove a specific IP from the whitelist +// RemoveaspecificIPfromthewhitelist Remove a specific IP from the whitelist // DELETE /access_settings/whitelist/{rule_id} - func RemoveaspecificIPfromthewhitelist() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" diff --git a/examples/alerts/alerts.go b/examples/alerts/alerts.go index b2d59bad..132123a5 100644 --- a/examples/alerts/alerts.go +++ b/examples/alerts/alerts.go @@ -2,23 +2,22 @@ package main import ( "fmt" - "github.com/sendgrid/sendgrid-go" "log" "os" + + "github.com/sendgrid/sendgrid-go" ) -/////////////////////////////////////////////////// -// Create a new Alert +// CreateanewAlert Create a new Alert // POST /alerts - func CreateanewAlert() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/alerts", host) request.Method = "POST" request.Body = []byte(` { - "email_to": "example@example.com", - "frequency": "daily", + "email_to": "example@example.com", + "frequency": "daily", "type": "stats_notification" }`) response, err := sendgrid.API(request) @@ -31,10 +30,8 @@ func CreateanewAlert() { } } -/////////////////////////////////////////////////// -// Retrieve all alerts +// Retrieveallalerts Retrieve all alerts // GET /alerts - func Retrieveallalerts() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -50,10 +47,8 @@ func Retrieveallalerts() { } } -/////////////////////////////////////////////////// -// Update an alert +// Updateanalert Update an alert // PATCH /alerts/{alert_id} - func Updateanalert() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -72,10 +67,8 @@ func Updateanalert() { } } -/////////////////////////////////////////////////// -// Retrieve a specific alert +// Retrieveaspecificalert Retrieve a specific alert // GET /alerts/{alert_id} - func Retrieveaspecificalert() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -91,10 +84,8 @@ func Retrieveaspecificalert() { } } -/////////////////////////////////////////////////// -// Delete an alert +// Deleteanalert Delete an alert // DELETE /alerts/{alert_id} - func Deleteanalert() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" diff --git a/examples/apikeys/apikeys.go b/examples/apikeys/apikeys.go index 33b082e6..5320e091 100644 --- a/examples/apikeys/apikeys.go +++ b/examples/apikeys/apikeys.go @@ -2,26 +2,25 @@ package main import ( "fmt" - "github.com/sendgrid/sendgrid-go" "log" "os" + + "github.com/sendgrid/sendgrid-go" ) -/////////////////////////////////////////////////// -// Create API keys +// CreateAPIkeys Create API keys // POST /api_keys - func CreateAPIkeys() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/api_keys", host) request.Method = "POST" request.Body = []byte(` { - "name": "My API Key", - "sample": "data", + "name": "My API Key", + "sample": "data", "scopes": [ - "mail.send", - "alerts.create", + "mail.send", + "alerts.create", "alerts.read" ] }`) @@ -35,10 +34,8 @@ func CreateAPIkeys() { } } -/////////////////////////////////////////////////// -// Retrieve all API Keys belonging to the authenticated user +// RetrieveallAPIKeysbelongingtotheauthenticateduser Retrieve all API Keys belonging to the authenticated user // GET /api_keys - func RetrieveallAPIKeysbelongingtotheauthenticateduser() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -57,19 +54,17 @@ func RetrieveallAPIKeysbelongingtotheauthenticateduser() { } } -/////////////////////////////////////////////////// -// Update the name & scopes of an API Key +// UpdatethenamescopesofanAPIKey Update the name & scopes of an API Key // PUT /api_keys/{api_key_id} - func UpdatethenamescopesofanAPIKey() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/api_keys/{api_key_id}", host) request.Method = "PUT" request.Body = []byte(` { - "name": "A New Hope", + "name": "A New Hope", "scopes": [ - "user.profile.read", + "user.profile.read", "user.profile.update" ] }`) @@ -83,10 +78,8 @@ func UpdatethenamescopesofanAPIKey() { } } -/////////////////////////////////////////////////// -// Update API keys +// UpdateAPIkeys Update API keys // PATCH /api_keys/{api_key_id} - func UpdateAPIkeys() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -105,10 +98,8 @@ func UpdateAPIkeys() { } } -/////////////////////////////////////////////////// -// Retrieve an existing API Key +// RetrieveanexistingAPIKey Retrieve an existing API Key // GET /api_keys/{api_key_id} - func RetrieveanexistingAPIKey() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -124,10 +115,8 @@ func RetrieveanexistingAPIKey() { } } -/////////////////////////////////////////////////// -// Delete API keys +// DeleteAPIkeys Delete API keys // DELETE /api_keys/{api_key_id} - func DeleteAPIkeys() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" diff --git a/examples/asm/asm.go b/examples/asm/asm.go index 187c5ce9..cad31434 100644 --- a/examples/asm/asm.go +++ b/examples/asm/asm.go @@ -2,23 +2,22 @@ package main import ( "fmt" - "github.com/sendgrid/sendgrid-go" "log" "os" + + "github.com/sendgrid/sendgrid-go" ) -/////////////////////////////////////////////////// -// Create a new suppression group +// Createanewsuppressiongroup Create a new suppression group // POST /asm/groups - func Createanewsuppressiongroup() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/asm/groups", host) request.Method = "POST" request.Body = []byte(` { - "description": "Suggestions for products our users might like.", - "is_default": true, + "description": "Suggestions for products our users might like.", + "is_default": true, "name": "Product Suggestions" }`) response, err := sendgrid.API(request) @@ -31,10 +30,8 @@ func Createanewsuppressiongroup() { } } -/////////////////////////////////////////////////// -// Retrieve information about multiple suppression groups +// Retrieveinformationaboutmultiplesuppressiongroups Retrieve information about multiple suppression groups // GET /asm/groups - func Retrieveinformationaboutmultiplesuppressiongroups() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -53,18 +50,16 @@ func Retrieveinformationaboutmultiplesuppressiongroups() { } } -/////////////////////////////////////////////////// -// Update a suppression group. +// Updateasuppressiongroup Update a suppression group. // PATCH /asm/groups/{group_id} - func Updateasuppressiongroup() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/asm/groups/{group_id}", host) request.Method = "PATCH" request.Body = []byte(` { - "description": "Suggestions for items our users might like.", - "id": 103, + "description": "Suggestions for items our users might like.", + "id": 103, "name": "Item Suggestions" }`) response, err := sendgrid.API(request) @@ -77,10 +72,8 @@ func Updateasuppressiongroup() { } } -/////////////////////////////////////////////////// -// Get information on a single suppression group. +// Getinformationonasinglesuppressiongroup Get information on a single suppression group. // GET /asm/groups/{group_id} - func Getinformationonasinglesuppressiongroup() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -96,10 +89,8 @@ func Getinformationonasinglesuppressiongroup() { } } -/////////////////////////////////////////////////// -// Delete a suppression group. +// Deleteasuppressiongroup Delete a suppression group. // DELETE /asm/groups/{group_id} - func Deleteasuppressiongroup() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -115,10 +106,8 @@ func Deleteasuppressiongroup() { } } -/////////////////////////////////////////////////// -// Add suppressions to a suppression group +// Addsuppressionstoasuppressiongroup Add suppressions to a suppression group // POST /asm/groups/{group_id}/suppressions - func Addsuppressionstoasuppressiongroup() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -126,7 +115,7 @@ func Addsuppressionstoasuppressiongroup() { request.Method = "POST" request.Body = []byte(` { "recipient_emails": [ - "test1@example.com", + "test1@example.com", "test2@example.com" ] }`) @@ -140,10 +129,8 @@ func Addsuppressionstoasuppressiongroup() { } } -/////////////////////////////////////////////////// -// Retrieve all suppressions for a suppression group +// Retrieveallsuppressionsforasuppressiongroup Retrieve all suppressions for a suppression group // GET /asm/groups/{group_id}/suppressions - func Retrieveallsuppressionsforasuppressiongroup() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -159,10 +146,8 @@ func Retrieveallsuppressionsforasuppressiongroup() { } } -/////////////////////////////////////////////////// -// Search for suppressions within a group +// Searchforsuppressionswithinagroup Search for suppressions within a group // POST /asm/groups/{group_id}/suppressions/search - func Searchforsuppressionswithinagroup() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -170,8 +155,8 @@ func Searchforsuppressionswithinagroup() { request.Method = "POST" request.Body = []byte(` { "recipient_emails": [ - "exists1@example.com", - "exists2@example.com", + "exists1@example.com", + "exists2@example.com", "doesnotexists@example.com" ] }`) @@ -185,10 +170,8 @@ func Searchforsuppressionswithinagroup() { } } -/////////////////////////////////////////////////// -// Delete a suppression from a suppression group +// Deleteasuppressionfromasuppressiongroup Delete a suppression from a suppression group // DELETE /asm/groups/{group_id}/suppressions/{email} - func Deleteasuppressionfromasuppressiongroup() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -204,10 +187,8 @@ func Deleteasuppressionfromasuppressiongroup() { } } -/////////////////////////////////////////////////// -// Retrieve all suppressions +// Retrieveallsuppressions Retrieve all suppressions // GET /asm/suppressions - func Retrieveallsuppressions() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -223,10 +204,8 @@ func Retrieveallsuppressions() { } } -/////////////////////////////////////////////////// -// Add recipient addresses to the global suppression group. +// Addrecipientaddressestotheglobalsuppressiongroup Add recipient addresses to the global suppression group. // POST /asm/suppressions/global - func Addrecipientaddressestotheglobalsuppressiongroup() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -234,7 +213,7 @@ func Addrecipientaddressestotheglobalsuppressiongroup() { request.Method = "POST" request.Body = []byte(` { "recipient_emails": [ - "test1@example.com", + "test1@example.com", "test2@example.com" ] }`) @@ -248,10 +227,8 @@ func Addrecipientaddressestotheglobalsuppressiongroup() { } } -/////////////////////////////////////////////////// -// Retrieve a Global Suppression +// RetrieveaGlobalSuppression Retrieve a Global Suppression // GET /asm/suppressions/global/{email} - func RetrieveaGlobalSuppression() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -267,10 +244,8 @@ func RetrieveaGlobalSuppression() { } } -/////////////////////////////////////////////////// -// Delete a Global Suppression +// DeleteaGlobalSuppression Delete a Global Suppression // DELETE /asm/suppressions/global/{email} - func DeleteaGlobalSuppression() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -286,10 +261,8 @@ func DeleteaGlobalSuppression() { } } -/////////////////////////////////////////////////// -// Retrieve all suppression groups for an email address +// Retrieveallsuppressiongroupsforanemailaddress Retrieve all suppression groups for an email address // GET /asm/suppressions/{email} - func Retrieveallsuppressiongroupsforanemailaddress() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" diff --git a/examples/browsers/browsers.go b/examples/browsers/browsers.go index c26a895f..55e1514a 100644 --- a/examples/browsers/browsers.go +++ b/examples/browsers/browsers.go @@ -2,15 +2,15 @@ package main import ( "fmt" - "github.com/sendgrid/sendgrid-go" "log" "os" + + "github.com/sendgrid/sendgrid-go" ) -/////////////////////////////////////////////////// -// Retrieve email statistics by browser. -// GET /browsers/stats +// Retrieveemailstatisticsbybrowser Retrieve email statistics by browser. +// GET /browsers/stats func Retrieveemailstatisticsbybrowser() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" diff --git a/examples/campaigns/campaigns.go b/examples/campaigns/campaigns.go index 908ba443..83e1f7dc 100644 --- a/examples/campaigns/campaigns.go +++ b/examples/campaigns/campaigns.go @@ -2,15 +2,14 @@ package main import ( "fmt" - "github.com/sendgrid/sendgrid-go" "log" "os" + + "github.com/sendgrid/sendgrid-go" ) -/////////////////////////////////////////////////// -// Create a Campaign +// CreateaCampaign Create a Campaign // POST /campaigns - func CreateaCampaign() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -19,21 +18,21 @@ func CreateaCampaign() { request.Body = []byte(` { "categories": [ "spring line" - ], - "custom_unsubscribe_url": "", - "html_content": "
Check out our spring line!
", - "ip_pool": "marketing", + ], + "custom_unsubscribe_url": "", + "html_content": "Check out our spring line!
", + "ip_pool": "marketing", "list_ids": [ - 110, + 110, 124 - ], - "plain_content": "Check out our spring line!", + ], + "plain_content": "Check out our spring line!", "segment_ids": [ 110 - ], - "sender_id": 124451, - "subject": "New Products for Spring!", - "suppression_group_id": 42, + ], + "sender_id": 124451, + "subject": "New Products for Spring!", + "suppression_group_id": 42, "title": "March Newsletter" }`) response, err := sendgrid.API(request) @@ -46,10 +45,8 @@ func CreateaCampaign() { } } -/////////////////////////////////////////////////// -// Retrieve all Campaigns +// RetrieveallCampaigns Retrieve all Campaigns // GET /campaigns - func RetrieveallCampaigns() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -69,10 +66,8 @@ func RetrieveallCampaigns() { } } -/////////////////////////////////////////////////// -// Update a Campaign +// UpdateaCampaign Update a Campaign // PATCH /campaigns/{campaign_id} - func UpdateaCampaign() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -81,10 +76,10 @@ func UpdateaCampaign() { request.Body = []byte(` { "categories": [ "summer line" - ], - "html_content": "Check out our summer line!
", - "plain_content": "Check out our summer line!", - "subject": "New Products for Summer!", + ], + "html_content": "Check out our summer line!
", + "plain_content": "Check out our summer line!", + "subject": "New Products for Summer!", "title": "May Newsletter" }`) response, err := sendgrid.API(request) @@ -97,10 +92,8 @@ func UpdateaCampaign() { } } -/////////////////////////////////////////////////// -// Retrieve a single campaign +// Retrieveasinglecampaign Retrieve a single campaign // GET /campaigns/{campaign_id} - func Retrieveasinglecampaign() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -116,10 +109,8 @@ func Retrieveasinglecampaign() { } } -/////////////////////////////////////////////////// -// Delete a Campaign +// DeleteaCampaign Delete a Campaign // DELETE /campaigns/{campaign_id} - func DeleteaCampaign() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -135,10 +126,8 @@ func DeleteaCampaign() { } } -/////////////////////////////////////////////////// -// Update a Scheduled Campaign +// UpdateaScheduledCampaign Update a Scheduled Campaign // PATCH /campaigns/{campaign_id}/schedules - func UpdateaScheduledCampaign() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -157,10 +146,8 @@ func UpdateaScheduledCampaign() { } } -/////////////////////////////////////////////////// -// Schedule a Campaign +// ScheduleaCampaign Schedule a Campaign // POST /campaigns/{campaign_id}/schedules - func ScheduleaCampaign() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -179,10 +166,8 @@ func ScheduleaCampaign() { } } -/////////////////////////////////////////////////// -// View Scheduled Time of a Campaign +// ViewScheduledTimeofaCampaign View Scheduled Time of a Campaign // GET /campaigns/{campaign_id}/schedules - func ViewScheduledTimeofaCampaign() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -198,10 +183,8 @@ func ViewScheduledTimeofaCampaign() { } } -/////////////////////////////////////////////////// -// Unschedule a Scheduled Campaign +// UnscheduleaScheduledCampaign Unschedule a Scheduled Campaign // DELETE /campaigns/{campaign_id}/schedules - func UnscheduleaScheduledCampaign() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -217,10 +200,8 @@ func UnscheduleaScheduledCampaign() { } } -/////////////////////////////////////////////////// -// Send a Campaign +// SendaCampaign Send a Campaign // POST /campaigns/{campaign_id}/schedules/now - func SendaCampaign() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -236,10 +217,8 @@ func SendaCampaign() { } } -/////////////////////////////////////////////////// -// Send a Test Campaign +// SendaTestCampaign Send a Test Campaign // POST /campaigns/{campaign_id}/schedules/test - func SendaTestCampaign() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" diff --git a/examples/categories/categories.go b/examples/categories/categories.go index 22ccb63b..1c5a6dc9 100644 --- a/examples/categories/categories.go +++ b/examples/categories/categories.go @@ -2,15 +2,14 @@ package main import ( "fmt" - "github.com/sendgrid/sendgrid-go" "log" "os" + + "github.com/sendgrid/sendgrid-go" ) -/////////////////////////////////////////////////// -// Retrieve all categories +// Retrieveallcategories Retrieves all categories // GET /categories - func Retrieveallcategories() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -31,10 +30,8 @@ func Retrieveallcategories() { } } -/////////////////////////////////////////////////// -// Retrieve Email Statistics for Categories +// RetrieveEmailStatisticsforCategories Retrieves Email Statistics for Categories // GET /categories/stats - func RetrieveEmailStatisticsforCategories() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -58,10 +55,8 @@ func RetrieveEmailStatisticsforCategories() { } } -/////////////////////////////////////////////////// -// Retrieve sums of email stats for each category [Needs: Stats object defined, has category ID?] +// Retrievesumsofemailstatsforeachcategory Retrieves sums of email stats for each category [Needs: Stats object defined, has category ID?] // GET /categories/stats/sums - func Retrievesumsofemailstatsforeachcategory() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" diff --git a/examples/clients/clients.go b/examples/clients/clients.go index 38335af9..38301124 100644 --- a/examples/clients/clients.go +++ b/examples/clients/clients.go @@ -2,15 +2,14 @@ package main import ( "fmt" - "github.com/sendgrid/sendgrid-go" "log" "os" + + "github.com/sendgrid/sendgrid-go" ) -/////////////////////////////////////////////////// -// Retrieve email statistics by client type. +// Retrieveemailstatisticsbyclienttype Retrieve email statistics by client type. // GET /clients/stats - func Retrieveemailstatisticsbyclienttype() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -31,10 +30,8 @@ func Retrieveemailstatisticsbyclienttype() { } } -/////////////////////////////////////////////////// -// Retrieve stats by a specific client type. +// Retrievestatsbyaspecificclienttype Retrieve stats by a specific client type. // GET /clients/{client_type}/stats - func Retrievestatsbyaspecificclienttype() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" diff --git a/examples/contactdb/contactdb.go b/examples/contactdb/contactdb.go index c3a67c00..0ed1fdbe 100644 --- a/examples/contactdb/contactdb.go +++ b/examples/contactdb/contactdb.go @@ -2,22 +2,21 @@ package main import ( "fmt" - "github.com/sendgrid/sendgrid-go" "log" "os" + + "github.com/sendgrid/sendgrid-go" ) -/////////////////////////////////////////////////// -// Create a Custom Field +// CreateaCustomField Create a Custom Field // POST /contactdb/custom_fields - func CreateaCustomField() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/contactdb/custom_fields", host) request.Method = "POST" request.Body = []byte(` { - "name": "pet", + "name": "pet", "type": "text" }`) response, err := sendgrid.API(request) @@ -30,10 +29,8 @@ func CreateaCustomField() { } } -/////////////////////////////////////////////////// -// Retrieve all custom fields +// Retrieveallcustomfields Retrieve all custom fields // GET /contactdb/custom_fields - func Retrieveallcustomfields() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -49,10 +46,9 @@ func Retrieveallcustomfields() { } } -/////////////////////////////////////////////////// -// Retrieve a Custom Field -// GET /contactdb/custom_fields/{custom_field_id} +// RetrieveaCustomField Retrieve a Custom Field +// GET /contactdb/custom_fields/{custom_field_id} func RetrieveaCustomField() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -68,10 +64,9 @@ func RetrieveaCustomField() { } } -/////////////////////////////////////////////////// -// Delete a Custom Field -// DELETE /contactdb/custom_fields/{custom_field_id} +// DeleteaCustomField Delete a Custom Field +// DELETE /contactdb/custom_fields/{custom_field_id} func DeleteaCustomField() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -87,10 +82,9 @@ func DeleteaCustomField() { } } -/////////////////////////////////////////////////// -// Create a List -// POST /contactdb/lists +// CreateaList Create a List +// POST /contactdb/lists func CreateaList() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -109,10 +103,8 @@ func CreateaList() { } } -/////////////////////////////////////////////////// -// Retrieve all lists +// Retrievealllists Retrieve all lists // GET /contactdb/lists - func Retrievealllists() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -128,19 +120,18 @@ func Retrievealllists() { } } -/////////////////////////////////////////////////// -// Delete Multiple lists -// DELETE /contactdb/lists +// DeleteMultiplelists Delete Multiple lists +// DELETE /contactdb/lists func DeleteMultiplelists() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/contactdb/lists", host) request.Method = "DELETE" request.Body = []byte(` [ - 1, - 2, - 3, + 1, + 2, + 3, 4 ]`) response, err := sendgrid.API(request) @@ -153,10 +144,8 @@ func DeleteMultiplelists() { } } -/////////////////////////////////////////////////// -// Update a List +// UpdateaList Update a List // PATCH /contactdb/lists/{list_id} - func UpdateaList() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -178,10 +167,9 @@ func UpdateaList() { } } -/////////////////////////////////////////////////// -// Retrieve a single list -// GET /contactdb/lists/{list_id} +// Retrieveasinglelist Retrieve a single list +// GET /contactdb/lists/{list_id} func Retrieveasinglelist() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -200,10 +188,9 @@ func Retrieveasinglelist() { } } -/////////////////////////////////////////////////// -// Delete a List -// DELETE /contactdb/lists/{list_id} +// DeleteaList Delete a List +// DELETE /contactdb/lists/{list_id} func DeleteaList() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -222,17 +209,15 @@ func DeleteaList() { } } -/////////////////////////////////////////////////// -// Add Multiple Recipients to a List +// AddMultipleRecipientstoaList Add Multiple Recipients to a List // POST /contactdb/lists/{list_id}/recipients - func AddMultipleRecipientstoaList() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/contactdb/lists/{list_id}/recipients", host) request.Method = "POST" request.Body = []byte(` [ - "recipient_id1", + "recipient_id1", "recipient_id2" ]`) response, err := sendgrid.API(request) @@ -245,10 +230,8 @@ func AddMultipleRecipientstoaList() { } } -/////////////////////////////////////////////////// -// Retrieve all recipients on a List +// RetrieveallrecipientsonaList Retrieve all recipients on a List // GET /contactdb/lists/{list_id}/recipients - func RetrieveallrecipientsonaList() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -269,10 +252,8 @@ func RetrieveallrecipientsonaList() { } } -/////////////////////////////////////////////////// -// Add a Single Recipient to a List +// AddaSingleRecipienttoaList Add a Single Recipient to a List // POST /contactdb/lists/{list_id}/recipients/{recipient_id} - func AddaSingleRecipienttoaList() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -288,10 +269,8 @@ func AddaSingleRecipienttoaList() { } } -/////////////////////////////////////////////////// -// Delete a Single Recipient from a Single List +// DeleteaSingleRecipientfromaSingleList Delete a Single Recipient from a Single List // DELETE /contactdb/lists/{list_id}/recipients/{recipient_id} - func DeleteaSingleRecipientfromaSingleList() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -311,10 +290,8 @@ func DeleteaSingleRecipientfromaSingleList() { } } -/////////////////////////////////////////////////// -// Update Recipient +// UpdateRecipient Update Recipient // PATCH /contactdb/recipients - func UpdateRecipient() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -322,8 +299,8 @@ func UpdateRecipient() { request.Method = "PATCH" request.Body = []byte(` [ { - "email": "jones@example.com", - "first_name": "Guy", + "email": "jones@example.com", + "first_name": "Guy", "last_name": "Jones" } ]`) @@ -337,10 +314,8 @@ func UpdateRecipient() { } } -/////////////////////////////////////////////////// -// Add recipients +// Addrecipients Add recipients // POST /contactdb/recipients - func Addrecipients() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -348,15 +323,15 @@ func Addrecipients() { request.Method = "POST" request.Body = []byte(` [ { - "age": 25, - "email": "example@example.com", - "first_name": "", + "age": 25, + "email": "example@example.com", + "first_name": "", "last_name": "User" - }, + }, { - "age": 25, - "email": "example2@example.com", - "first_name": "Example", + "age": 25, + "email": "example2@example.com", + "first_name": "Example", "last_name": "User" } ]`) @@ -370,10 +345,8 @@ func Addrecipients() { } } -/////////////////////////////////////////////////// -// Retrieve recipients +// Retrieverecipients Retrieve recipients // GET /contactdb/recipients - func Retrieverecipients() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -393,17 +366,15 @@ func Retrieverecipients() { } } -/////////////////////////////////////////////////// -// Delete Recipient +// DeleteRecipient Delete Recipient // DELETE /contactdb/recipients - func DeleteRecipient() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/contactdb/recipients", host) request.Method = "DELETE" request.Body = []byte(` [ - "recipient_id1", + "recipient_id1", "recipient_id2" ]`) response, err := sendgrid.API(request) @@ -416,10 +387,8 @@ func DeleteRecipient() { } } -/////////////////////////////////////////////////// -// Retrieve the count of billable recipients +// Retrievethecountofbillablerecipients Retrieve the count of billable recipients // GET /contactdb/recipients/billable_count - func Retrievethecountofbillablerecipients() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -435,10 +404,8 @@ func Retrievethecountofbillablerecipients() { } } -/////////////////////////////////////////////////// -// Retrieve a Count of Recipients +// RetrieveaCountofRecipients Retrieve a Count of Recipients // GET /contactdb/recipients/count - func RetrieveaCountofRecipients() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -454,10 +421,8 @@ func RetrieveaCountofRecipients() { } } -/////////////////////////////////////////////////// -// Retrieve recipients matching search criteria +// Retrieverecipientsmatchingsearchcriteria Retrieve recipients matching search criteria // GET /contactdb/recipients/search - func Retrieverecipientsmatchingsearchcriteria() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -476,10 +441,8 @@ func Retrieverecipientsmatchingsearchcriteria() { } } -/////////////////////////////////////////////////// -// Retrieve a single recipient +// Retrieveasinglerecipient Retrieve a single recipient // GET /contactdb/recipients/{recipient_id} - func Retrieveasinglerecipient() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -495,10 +458,8 @@ func Retrieveasinglerecipient() { } } -/////////////////////////////////////////////////// -// Delete a Recipient +// DeleteaRecipient Delete a Recipient // DELETE /contactdb/recipients/{recipient_id} - func DeleteaRecipient() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -514,10 +475,8 @@ func DeleteaRecipient() { } } -/////////////////////////////////////////////////// -// Retrieve the lists that a recipient is on +// Retrievetheliststhatarecipientison Retrieve the lists that a recipient is on // GET /contactdb/recipients/{recipient_id}/lists - func Retrievetheliststhatarecipientison() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -533,10 +492,8 @@ func Retrievetheliststhatarecipientison() { } } -/////////////////////////////////////////////////// -// Retrieve reserved fields +// Retrievereservedfields Retrieve reserved fields // GET /contactdb/reserved_fields - func Retrievereservedfields() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -552,10 +509,8 @@ func Retrievereservedfields() { } } -/////////////////////////////////////////////////// -// Create a Segment +// CreateaSegment Create a Segment // POST /contactdb/segments - func CreateaSegment() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -564,25 +519,25 @@ func CreateaSegment() { request.Body = []byte(` { "conditions": [ { - "and_or": "", - "field": "last_name", - "operator": "eq", + "and_or": "", + "field": "last_name", + "operator": "eq", "value": "Miller" - }, + }, { - "and_or": "and", - "field": "last_clicked", - "operator": "gt", + "and_or": "and", + "field": "last_clicked", + "operator": "gt", "value": "01/02/2015" - }, + }, { - "and_or": "or", - "field": "clicks.campaign_identifier", - "operator": "eq", + "and_or": "or", + "field": "clicks.campaign_identifier", + "operator": "eq", "value": "513" } - ], - "list_id": 4, + ], + "list_id": 4, "name": "Last Name Miller" }`) response, err := sendgrid.API(request) @@ -595,10 +550,8 @@ func CreateaSegment() { } } -/////////////////////////////////////////////////// -// Retrieve all segments +// Retrieveallsegments Retrieve all segments // GET /contactdb/segments - func Retrieveallsegments() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -614,10 +567,8 @@ func Retrieveallsegments() { } } -/////////////////////////////////////////////////// -// Update a segment +// Updateasegment Update a segment // PATCH /contactdb/segments/{segment_id} - func Updateasegment() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -626,13 +577,13 @@ func Updateasegment() { request.Body = []byte(` { "conditions": [ { - "and_or": "", - "field": "last_name", - "operator": "eq", + "and_or": "", + "field": "last_name", + "operator": "eq", "value": "Miller" } - ], - "list_id": 5, + ], + "list_id": 5, "name": "The Millers" }`) queryParams := make(map[string]string) @@ -648,10 +599,8 @@ func Updateasegment() { } } -/////////////////////////////////////////////////// -// Retrieve a segment +// Retrieveasegment Retrieve a segment // GET /contactdb/segments/{segment_id} - func Retrieveasegment() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -670,10 +619,8 @@ func Retrieveasegment() { } } -/////////////////////////////////////////////////// -// Delete a segment +// Deleteasegment Delete a segment // DELETE /contactdb/segments/{segment_id} - func Deleteasegment() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -692,10 +639,8 @@ func Deleteasegment() { } } -/////////////////////////////////////////////////// -// Retrieve recipients on a segment +// Retrieverecipientsonasegment Retrieve recipients on a segment // GET /contactdb/segments/{segment_id}/recipients - func Retrieverecipientsonasegment() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" diff --git a/examples/devices/devices.go b/examples/devices/devices.go index 8dc3b854..35b2b433 100644 --- a/examples/devices/devices.go +++ b/examples/devices/devices.go @@ -2,15 +2,14 @@ package main import ( "fmt" - "github.com/sendgrid/sendgrid-go" "log" "os" + + "github.com/sendgrid/sendgrid-go" ) -/////////////////////////////////////////////////// -// Retrieve email statistics by device type. +// Retrieveemailstatisticsbydevicetype Retrieves email statistics by device type. // GET /devices/stats - func Retrieveemailstatisticsbydevicetype() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" diff --git a/examples/geo/geo.go b/examples/geo/geo.go index 3351fd4c..2e48ea86 100644 --- a/examples/geo/geo.go +++ b/examples/geo/geo.go @@ -2,15 +2,14 @@ package main import ( "fmt" - "github.com/sendgrid/sendgrid-go" "log" "os" + + "github.com/sendgrid/sendgrid-go" ) -/////////////////////////////////////////////////// -// Retrieve email statistics by country and state/province. +// Retrieveemailstatisticsbycountryandstateprovince Retrieve email statistics by country and state/province. // GET /geo/stats - func Retrieveemailstatisticsbycountryandstateprovince() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" diff --git a/examples/ips/ips.go b/examples/ips/ips.go index 5b38134b..c6dc286a 100644 --- a/examples/ips/ips.go +++ b/examples/ips/ips.go @@ -2,15 +2,14 @@ package main import ( "fmt" - "github.com/sendgrid/sendgrid-go" "log" "os" + + "github.com/sendgrid/sendgrid-go" ) -/////////////////////////////////////////////////// -// Retrieve all IP addresses +// RetrieveallIPaddresses Retrieve all IP addresses // GET /ips - func RetrieveallIPaddresses() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -33,10 +32,8 @@ func RetrieveallIPaddresses() { } } -/////////////////////////////////////////////////// -// Retrieve all assigned IPs +// RetrieveallassignedIPs Retrieve all assigned IPs // GET /ips/assigned - func RetrieveallassignedIPs() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -52,10 +49,8 @@ func RetrieveallassignedIPs() { } } -/////////////////////////////////////////////////// -// Create an IP pool. +// CreateanIPpool Create an IP pool. // POST /ips/pools - func CreateanIPpool() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -74,10 +69,8 @@ func CreateanIPpool() { } } -/////////////////////////////////////////////////// -// Retrieve all IP pools. +// RetrieveallIPpools Retrieve all IP pools. // GET /ips/pools - func RetrieveallIPpools() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -93,10 +86,8 @@ func RetrieveallIPpools() { } } -/////////////////////////////////////////////////// -// Update an IP pools name. +// UpdateanIPpoolsname Update an IP pools name. // PUT /ips/pools/{pool_name} - func UpdateanIPpoolsname() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -115,10 +106,8 @@ func UpdateanIPpoolsname() { } } -/////////////////////////////////////////////////// -// Retrieve all IPs in a specified pool. +// RetrieveallIPsinaspecifiedpool Retrieve all IPs in a specified pool. // GET /ips/pools/{pool_name} - func RetrieveallIPsinaspecifiedpool() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -134,10 +123,8 @@ func RetrieveallIPsinaspecifiedpool() { } } -/////////////////////////////////////////////////// -// Delete an IP pool. +// DeleteanIPpool Delete an IP pool. // DELETE /ips/pools/{pool_name} - func DeleteanIPpool() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -153,10 +140,8 @@ func DeleteanIPpool() { } } -/////////////////////////////////////////////////// -// Add an IP address to a pool +// AddanIPaddresstoapool Add an IP address to a pool // POST /ips/pools/{pool_name}/ips - func AddanIPaddresstoapool() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -175,10 +160,8 @@ func AddanIPaddresstoapool() { } } -/////////////////////////////////////////////////// -// Remove an IP address from a pool. +// RemoveanIPaddressfromapool Remove an IP address from a pool. // DELETE /ips/pools/{pool_name}/ips/{ip} - func RemoveanIPaddressfromapool() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -194,10 +177,8 @@ func RemoveanIPaddressfromapool() { } } -/////////////////////////////////////////////////// -// Add an IP to warmup +// AddanIPtowarmup Add an IP to warmup // POST /ips/warmup - func AddanIPtowarmup() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -216,10 +197,8 @@ func AddanIPtowarmup() { } } -/////////////////////////////////////////////////// -// Retrieve all IPs currently in warmup +// RetrieveallIPscurrentlyinwarmup Retrieve all IPs currently in warmup // GET /ips/warmup - func RetrieveallIPscurrentlyinwarmup() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -235,10 +214,8 @@ func RetrieveallIPscurrentlyinwarmup() { } } -/////////////////////////////////////////////////// -// Retrieve warmup status for a specific IP address +// RetrievewarmupstatusforaspecificIPaddress Retrieve warmup status for a specific IP address // GET /ips/warmup/{ip_address} - func RetrievewarmupstatusforaspecificIPaddress() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -254,10 +231,8 @@ func RetrievewarmupstatusforaspecificIPaddress() { } } -/////////////////////////////////////////////////// -// Remove an IP from warmup +// RemoveanIPfromwarmup Remove an IP from warmup // DELETE /ips/warmup/{ip_address} - func RemoveanIPfromwarmup() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -273,10 +248,8 @@ func RemoveanIPfromwarmup() { } } -/////////////////////////////////////////////////// -// Retrieve all IP pools an IP address belongs to +// RetrieveallIPpoolsanIPaddressbelongsto Retrieve all IP pools an IP address belongs to // GET /ips/{ip_address} - func RetrieveallIPpoolsanIPaddressbelongsto() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" diff --git a/examples/mail/mail.go b/examples/mail/mail.go index 9fc2cda7..fdbddd23 100644 --- a/examples/mail/mail.go +++ b/examples/mail/mail.go @@ -2,15 +2,14 @@ package main import ( "fmt" - "github.com/sendgrid/sendgrid-go" "log" "os" + + "github.com/sendgrid/sendgrid-go" ) -/////////////////////////////////////////////////// -// Create a batch ID +// CreateabatchID creates a batch ID // POST /mail/batch - func CreateabatchID() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -26,10 +25,8 @@ func CreateabatchID() { } } -/////////////////////////////////////////////////// -// Validate batch ID +// ValidatebatchID Validates batch ID // GET /mail/batch/{batch_id} - func ValidatebatchID() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -57,138 +54,138 @@ func v3MailSend() { request.Method = "POST" request.Body = []byte(` { "asm": { - "group_id": 1, + "group_id": 1, "groups_to_display": [ - 1, - 2, + 1, + 2, 3 ] - }, + }, "attachments": [ { - "content": "[BASE64 encoded content block here]", - "content_id": "ii_139db99fdb5c3704", - "disposition": "inline", - "filename": "file1.jpg", - "name": "file1", + "content": "[BASE64 encoded content block here]", + "content_id": "ii_139db99fdb5c3704", + "disposition": "inline", + "filename": "file1.jpg", + "name": "file1", "type": "jpg" } - ], - "batch_id": "[YOUR BATCH ID GOES HERE]", + ], + "batch_id": "[YOUR BATCH ID GOES HERE]", "categories": [ - "category1", + "category1", "category2" - ], + ], "content": [ { - "type": "text/html", + "type": "text/html", "value": "Hello, world!
" } - ], + ], "custom_args": { - "New Argument 1": "New Value 1", - "activationAttempt": "1", + "New Argument 1": "New Value 1", + "activationAttempt": "1", "customerAccountNumber": "[CUSTOMER ACCOUNT NUMBER GOES HERE]" - }, + }, "from": { - "email": "sam.smith@example.com", + "email": "sam.smith@example.com", "name": "Sam Smith" - }, - "headers": {}, - "ip_pool_name": "[YOUR POOL NAME GOES HERE]", + }, + "headers": {}, + "ip_pool_name": "[YOUR POOL NAME GOES HERE]", "mail_settings": { "bcc": { - "email": "ben.doe@example.com", + "email": "ben.doe@example.com", "enable": true - }, + }, "bypass_list_management": { "enable": true - }, + }, "footer": { - "enable": true, - "html": "ThanksThe SendGrid Team
", + "enable": true, + "html": "ThanksThe SendGrid Team
", "text": "Thanks,/n The SendGrid Team" - }, + }, "sandbox_mode": { "enable": false - }, + }, "spam_check": { - "enable": true, - "post_to_url": "http://example.com/compliance", + "enable": true, + "post_to_url": "http://example.com/compliance", "threshold": 3 } - }, + }, "personalizations": [ { "bcc": [ { - "email": "sam.doe@example.com", + "email": "sam.doe@example.com", "name": "Sam Doe" } - ], + ], "cc": [ { - "email": "jane.doe@example.com", + "email": "jane.doe@example.com", "name": "Jane Doe" } - ], + ], "custom_args": { - "New Argument 1": "New Value 1", - "activationAttempt": "1", + "New Argument 1": "New Value 1", + "activationAttempt": "1", "customerAccountNumber": "[CUSTOMER ACCOUNT NUMBER GOES HERE]" - }, + }, "headers": { - "X-Accept-Language": "en", + "X-Accept-Language": "en", "X-Mailer": "MyApp" - }, - "send_at": 1409348513, - "subject": "Hello, World!", + }, + "send_at": 1409348513, + "subject": "Hello, World!", "substitutions": { - "id": "substitutions", + "id": "substitutions", "type": "object" - }, + }, "to": [ { - "email": "john.doe@example.com", + "email": "john.doe@example.com", "name": "John Doe" } ] } - ], + ], "reply_to": { - "email": "sam.smith@example.com", + "email": "sam.smith@example.com", "name": "Sam Smith" - }, + }, "sections": { "section": { - ":sectionName1": "section 1 text", + ":sectionName1": "section 1 text", ":sectionName2": "section 2 text" } - }, - "send_at": 1409348513, - "subject": "Hello, World!", - "template_id": "[YOUR TEMPLATE ID GOES HERE]", + }, + "send_at": 1409348513, + "subject": "Hello, World!", + "template_id": "[YOUR TEMPLATE ID GOES HERE]", "tracking_settings": { "click_tracking": { - "enable": true, + "enable": true, "enable_text": true - }, + }, "ganalytics": { - "enable": true, - "utm_campaign": "[NAME OF YOUR REFERRER SOURCE]", - "utm_content": "[USE THIS SPACE TO DIFFERENTIATE YOUR EMAIL FROM ADS]", - "utm_medium": "[NAME OF YOUR MARKETING MEDIUM e.g. email]", - "utm_name": "[NAME OF YOUR CAMPAIGN]", + "enable": true, + "utm_campaign": "[NAME OF YOUR REFERRER SOURCE]", + "utm_content": "[USE THIS SPACE TO DIFFERENTIATE YOUR EMAIL FROM ADS]", + "utm_medium": "[NAME OF YOUR MARKETING MEDIUM e.g. email]", + "utm_name": "[NAME OF YOUR CAMPAIGN]", "utm_term": "[IDENTIFY PAID KEYWORDS HERE]" - }, + }, "open_tracking": { - "enable": true, + "enable": true, "substitution_tag": "%opentrack" - }, + }, "subscription_tracking": { - "enable": true, - "html": "If you would like to unsubscribe and stop receiving these emails <% clickhere %>.", - "substitution_tag": "<%click here%>", + "enable": true, + "html": "If you would like to unsubscribe and stop receiving these emails <% clickhere %>.", + "substitution_tag": "<%click here%>", "text": "If you would like to unsubscribe and stop receiveing these emails <% click here %>." } } diff --git a/examples/mailboxproviders/mailboxproviders.go b/examples/mailboxproviders/mailboxproviders.go index 7910ab20..1dc102cc 100644 --- a/examples/mailboxproviders/mailboxproviders.go +++ b/examples/mailboxproviders/mailboxproviders.go @@ -2,15 +2,14 @@ package main import ( "fmt" - "github.com/sendgrid/sendgrid-go" "log" "os" + + "github.com/sendgrid/sendgrid-go" ) -/////////////////////////////////////////////////// -// Retrieve email statistics by mailbox provider. +// Retrieveemailstatisticsbymailboxprovider Retrieve email statistics by mailbox provider. // GET /mailbox_providers/stats - func Retrieveemailstatisticsbymailboxprovider() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" diff --git a/examples/mailsettings/mailsettings.go b/examples/mailsettings/mailsettings.go index 1fffdd76..4419ce8a 100644 --- a/examples/mailsettings/mailsettings.go +++ b/examples/mailsettings/mailsettings.go @@ -2,15 +2,14 @@ package main import ( "fmt" - "github.com/sendgrid/sendgrid-go" "log" "os" + + "github.com/sendgrid/sendgrid-go" ) -/////////////////////////////////////////////////// -// Retrieve all mail settings +// Retrieveallmailsettings Retrieves all mail settings // GET /mail_settings - func Retrieveallmailsettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -30,19 +29,17 @@ func Retrieveallmailsettings() { } } -/////////////////////////////////////////////////// -// Update address whitelist mail settings +// Updateaddresswhitelistmailsettings Update address whitelist mail settings // PATCH /mail_settings/address_whitelist - func Updateaddresswhitelistmailsettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/mail_settings/address_whitelist", host) request.Method = "PATCH" request.Body = []byte(` { - "enabled": true, + "enabled": true, "list": [ - "email1@example.com", + "email1@example.com", "example.com" ] }`) @@ -56,10 +53,8 @@ func Updateaddresswhitelistmailsettings() { } } -/////////////////////////////////////////////////// -// Retrieve address whitelist mail settings +// Retrieveaddresswhitelistmailsettings Retrieve address whitelist mail settings // GET /mail_settings/address_whitelist - func Retrieveaddresswhitelistmailsettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -75,17 +70,15 @@ func Retrieveaddresswhitelistmailsettings() { } } -/////////////////////////////////////////////////// -// Update BCC mail settings +// UpdateBCCmailsettings Update BCC mail settings // PATCH /mail_settings/bcc - func UpdateBCCmailsettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/mail_settings/bcc", host) request.Method = "PATCH" request.Body = []byte(` { - "email": "email@example.com", + "email": "email@example.com", "enabled": false }`) response, err := sendgrid.API(request) @@ -98,10 +91,8 @@ func UpdateBCCmailsettings() { } } -/////////////////////////////////////////////////// -// Retrieve all BCC mail settings +// RetrieveallBCCmailsettings Retrieve all BCC mail settings // GET /mail_settings/bcc - func RetrieveallBCCmailsettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -117,18 +108,16 @@ func RetrieveallBCCmailsettings() { } } -/////////////////////////////////////////////////// -// Update bounce purge mail settings +// Updatebouncepurgemailsettings Update bounce purge mail settings // PATCH /mail_settings/bounce_purge - func Updatebouncepurgemailsettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/mail_settings/bounce_purge", host) request.Method = "PATCH" request.Body = []byte(` { - "enabled": true, - "hard_bounces": 5, + "enabled": true, + "hard_bounces": 5, "soft_bounces": 5 }`) response, err := sendgrid.API(request) @@ -141,10 +130,8 @@ func Updatebouncepurgemailsettings() { } } -/////////////////////////////////////////////////// -// Retrieve bounce purge mail settings +// Retrievebouncepurgemailsettings Retrieve bounce purge mail settings // GET /mail_settings/bounce_purge - func Retrievebouncepurgemailsettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -160,18 +147,16 @@ func Retrievebouncepurgemailsettings() { } } -/////////////////////////////////////////////////// -// Update footer mail settings +// Updatefootermailsettings Updates footer mail settings // PATCH /mail_settings/footer - func Updatefootermailsettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/mail_settings/footer", host) request.Method = "PATCH" request.Body = []byte(` { - "enabled": true, - "html_content": "...", + "enabled": true, + "html_content": "...", "plain_content": "..." }`) response, err := sendgrid.API(request) @@ -184,10 +169,8 @@ func Updatefootermailsettings() { } } -/////////////////////////////////////////////////// -// Retrieve footer mail settings +// Retrievefootermailsettings Retrieve footer mail settings // GET /mail_settings/footer - func Retrievefootermailsettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -203,17 +186,15 @@ func Retrievefootermailsettings() { } } -/////////////////////////////////////////////////// -// Update forward bounce mail settings +// Updateforwardbouncemailsettings Update forward bounce mail settings // PATCH /mail_settings/forward_bounce - func Updateforwardbouncemailsettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/mail_settings/forward_bounce", host) request.Method = "PATCH" request.Body = []byte(` { - "email": "example@example.com", + "email": "example@example.com", "enabled": true }`) response, err := sendgrid.API(request) @@ -226,10 +207,8 @@ func Updateforwardbouncemailsettings() { } } -/////////////////////////////////////////////////// -// Retrieve forward bounce mail settings +// Retrieveforwardbouncemailsettings Retrieve forward bounce mail settings // GET /mail_settings/forward_bounce - func Retrieveforwardbouncemailsettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -245,17 +224,15 @@ func Retrieveforwardbouncemailsettings() { } } -/////////////////////////////////////////////////// -// Update forward spam mail settings +// Updateforwardspammailsettings Update forward spam mail settings // PATCH /mail_settings/forward_spam - func Updateforwardspammailsettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/mail_settings/forward_spam", host) request.Method = "PATCH" request.Body = []byte(` { - "email": "", + "email": "", "enabled": false }`) response, err := sendgrid.API(request) @@ -268,10 +245,8 @@ func Updateforwardspammailsettings() { } } -/////////////////////////////////////////////////// -// Retrieve forward spam mail settings +// Retrieveforwardspammailsettings Retrieve forward spam mail settings // GET /mail_settings/forward_spam - func Retrieveforwardspammailsettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -287,10 +262,8 @@ func Retrieveforwardspammailsettings() { } } -/////////////////////////////////////////////////// -// Update plain content mail settings +// Updateplaincontentmailsettings Update plain content mail settings // PATCH /mail_settings/plain_content - func Updateplaincontentmailsettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -309,10 +282,8 @@ func Updateplaincontentmailsettings() { } } -/////////////////////////////////////////////////// -// Retrieve plain content mail settings +// Retrieveplaincontentmailsettings Retrieve plain content mail settings // GET /mail_settings/plain_content - func Retrieveplaincontentmailsettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -328,18 +299,16 @@ func Retrieveplaincontentmailsettings() { } } -/////////////////////////////////////////////////// -// Update spam check mail settings +// Updatespamcheckmailsettings Update spam check mail settings // PATCH /mail_settings/spam_check - func Updatespamcheckmailsettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/mail_settings/spam_check", host) request.Method = "PATCH" request.Body = []byte(` { - "enabled": true, - "max_score": 5, + "enabled": true, + "max_score": 5, "url": "url" }`) response, err := sendgrid.API(request) @@ -352,10 +321,8 @@ func Updatespamcheckmailsettings() { } } -/////////////////////////////////////////////////// -// Retrieve spam check mail settings +// Retrievespamcheckmailsettings Retrieve spam check mail settings // GET /mail_settings/spam_check - func Retrievespamcheckmailsettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -371,17 +338,15 @@ func Retrievespamcheckmailsettings() { } } -/////////////////////////////////////////////////// -// Update template mail settings +// Updatetemplatemailsettings Update template mail settings // PATCH /mail_settings/template - func Updatetemplatemailsettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/mail_settings/template", host) request.Method = "PATCH" request.Body = []byte(` { - "enabled": true, + "enabled": true, "html_content": "<% body %>" }`) response, err := sendgrid.API(request) @@ -394,10 +359,8 @@ func Updatetemplatemailsettings() { } } -/////////////////////////////////////////////////// -// Retrieve legacy template mail settings +// Retrievelegacytemplatemailsettings Retrieves legacy template mail settings // GET /mail_settings/template - func Retrievelegacytemplatemailsettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" diff --git a/examples/partnersettings/partnersettings.go b/examples/partnersettings/partnersettings.go index d080f0c9..d0431721 100644 --- a/examples/partnersettings/partnersettings.go +++ b/examples/partnersettings/partnersettings.go @@ -2,15 +2,14 @@ package main import ( "fmt" - "github.com/sendgrid/sendgrid-go" "log" "os" + + "github.com/sendgrid/sendgrid-go" ) -/////////////////////////////////////////////////// -// Returns a list of all partner settings. +// Returnsalistofallpartnersettings Returns a list of all partner settings. // GET /partner_settings - func Returnsalistofallpartnersettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -30,18 +29,16 @@ func Returnsalistofallpartnersettings() { } } -/////////////////////////////////////////////////// -// Updates New Relic partner settings. +// UpdatesNewRelicpartnersettings Updates New Relic partner settings. // PATCH /partner_settings/new_relic - func UpdatesNewRelicpartnersettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/partner_settings/new_relic", host) request.Method = "PATCH" request.Body = []byte(` { - "enable_subuser_statistics": true, - "enabled": true, + "enable_subuser_statistics": true, + "enabled": true, "license_key": "" }`) response, err := sendgrid.API(request) @@ -54,10 +51,8 @@ func UpdatesNewRelicpartnersettings() { } } -/////////////////////////////////////////////////// -// Returns all New Relic partner settings. +// ReturnsallNewRelicpartnersettings Returns all New Relic partner settings. // GET /partner_settings/new_relic - func ReturnsallNewRelicpartnersettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" diff --git a/examples/scopes/scopes.go b/examples/scopes/scopes.go index d8e6573e..3cb409b9 100644 --- a/examples/scopes/scopes.go +++ b/examples/scopes/scopes.go @@ -2,15 +2,14 @@ package main import ( "fmt" - "github.com/sendgrid/sendgrid-go" "log" "os" + + "github.com/sendgrid/sendgrid-go" ) -/////////////////////////////////////////////////// -// Retrieve a list of scopes for which this user has access. +// Retrievealistofscopesforwhichthisuserhasaccess Retrieve a list of scopes for which this user has access. // GET /scopes - func Retrievealistofscopesforwhichthisuserhasaccess() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" diff --git a/examples/senders/senders.go b/examples/senders/senders.go index 687c52ba..cda5617c 100644 --- a/examples/senders/senders.go +++ b/examples/senders/senders.go @@ -2,35 +2,34 @@ package main import ( "fmt" - "github.com/sendgrid/sendgrid-go" "log" "os" + + "github.com/sendgrid/sendgrid-go" ) -/////////////////////////////////////////////////// -// Create a Sender Identity +// CreateaSenderIdentity Creates a Sender Identity // POST /senders - func CreateaSenderIdentity() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" 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", + "address": "123 Elm St.", + "address_2": "Apt. 456", + "city": "Denver", + "country": "United States", "from": { - "email": "from@example.com", + "email": "from@example.com", "name": "Example INC" - }, - "nickname": "My Sender ID", + }, + "nickname": "My Sender ID", "reply_to": { - "email": "replyto@example.com", + "email": "replyto@example.com", "name": "Example INC" - }, - "state": "Colorado", + }, + "state": "Colorado", "zip": "80202" }`) response, err := sendgrid.API(request) @@ -43,10 +42,8 @@ func CreateaSenderIdentity() { } } -/////////////////////////////////////////////////// -// Get all Sender Identities +// GetallSenderIdentities Gets all Sender Identities // GET /senders - func GetallSenderIdentities() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -62,30 +59,28 @@ func GetallSenderIdentities() { } } -/////////////////////////////////////////////////// -// Update a Sender Identity +// UpdateaSenderIdentity Updates a Sender Identity // PATCH /senders/{sender_id} - func UpdateaSenderIdentity() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" 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", + "address": "123 Elm St.", + "address_2": "Apt. 456", + "city": "Denver", + "country": "United States", "from": { - "email": "from@example.com", + "email": "from@example.com", "name": "Example INC" - }, - "nickname": "My Sender ID", + }, + "nickname": "My Sender ID", "reply_to": { - "email": "replyto@example.com", + "email": "replyto@example.com", "name": "Example INC" - }, - "state": "Colorado", + }, + "state": "Colorado", "zip": "80202" }`) response, err := sendgrid.API(request) @@ -98,10 +93,8 @@ func UpdateaSenderIdentity() { } } -/////////////////////////////////////////////////// -// View a Sender Identity +// ViewaSenderIdentity Views a Sender Identity // GET /senders/{sender_id} - func ViewaSenderIdentity() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -117,10 +110,8 @@ func ViewaSenderIdentity() { } } -/////////////////////////////////////////////////// -// Delete a Sender Identity +// DeleteaSenderIdentity Deletes a Sender Identity // DELETE /senders/{sender_id} - func DeleteaSenderIdentity() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -136,10 +127,8 @@ func DeleteaSenderIdentity() { } } -/////////////////////////////////////////////////// -// Resend Sender Identity Verification +// ResendSenderIdentityVerification Resend Sender Identity Verification // POST /senders/{sender_id}/resend_verification - func ResendSenderIdentityVerification() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" diff --git a/examples/stats/stats.go b/examples/stats/stats.go index 7cdeedbc..71cfce5a 100644 --- a/examples/stats/stats.go +++ b/examples/stats/stats.go @@ -2,15 +2,14 @@ package main import ( "fmt" - "github.com/sendgrid/sendgrid-go" "log" "os" + + "github.com/sendgrid/sendgrid-go" ) -/////////////////////////////////////////////////// -// Retrieve global email statistics +// Retrieveglobalemailstatistics Retrieve global email statistics // GET /stats - func Retrieveglobalemailstatistics() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" diff --git a/examples/subusers/subusers.go b/examples/subusers/subusers.go index 22b3eb87..fcf95a5a 100644 --- a/examples/subusers/subusers.go +++ b/examples/subusers/subusers.go @@ -2,27 +2,26 @@ package main import ( "fmt" - "github.com/sendgrid/sendgrid-go" "log" "os" + + "github.com/sendgrid/sendgrid-go" ) -/////////////////////////////////////////////////// -// Create Subuser +// CreateSubuser Create Subuser // POST /subusers - func CreateSubuser() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/subusers", host) request.Method = "POST" request.Body = []byte(` { - "email": "John@example.com", + "email": "John@example.com", "ips": [ - "1.1.1.1", + "1.1.1.1", "2.2.2.2" - ], - "password": "johns_password", + ], + "password": "johns_password", "username": "John@example.com" }`) response, err := sendgrid.API(request) @@ -35,10 +34,8 @@ func CreateSubuser() { } } -/////////////////////////////////////////////////// -// List all Subusers +// ListallSubusers List all Subusers // GET /subusers - func ListallSubusers() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -59,10 +56,8 @@ func ListallSubusers() { } } -/////////////////////////////////////////////////// -// Retrieve Subuser Reputations +// RetrieveSubuserReputations Retrieve Subuser Reputations // GET /subusers/reputations - func RetrieveSubuserReputations() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -81,10 +76,8 @@ func RetrieveSubuserReputations() { } } -/////////////////////////////////////////////////// -// Retrieve email statistics for your subusers. +// Retrieveemailstatisticsforyoursubusers Retrieve email statistics for your subusers. // GET /subusers/stats - func Retrieveemailstatisticsforyoursubusers() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -108,10 +101,8 @@ func Retrieveemailstatisticsforyoursubusers() { } } -/////////////////////////////////////////////////// -// Retrieve monthly stats for all subusers +// Retrievemonthlystatsforallsubusers Retrieve monthly stats for all subusers // GET /subusers/stats/monthly - func Retrievemonthlystatsforallsubusers() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -135,10 +126,8 @@ func Retrievemonthlystatsforallsubusers() { } } -/////////////////////////////////////////////////// -// Retrieve the totals for each email statistic metric for all subusers. +// Retrievethetotalsforeachemailstatisticmetricforallsubusers Retrieve the totals for each email statistic metric for all subusers. // GET /subusers/stats/sums - func Retrievethetotalsforeachemailstatisticmetricforallsubusers() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -163,10 +152,8 @@ func Retrievethetotalsforeachemailstatisticmetricforallsubusers() { } } -/////////////////////////////////////////////////// -// Enable/disable a subuser +// Enabledisableasubuser Enable/disable a subuser // PATCH /subusers/{subuser_name} - func Enabledisableasubuser() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -185,10 +172,8 @@ func Enabledisableasubuser() { } } -/////////////////////////////////////////////////// -// Delete a subuser +// Deleteasubuser Delete a subuser // DELETE /subusers/{subuser_name} - func Deleteasubuser() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -204,10 +189,8 @@ func Deleteasubuser() { } } -/////////////////////////////////////////////////// -// Update IPs assigned to a subuser +// UpdateIPsassignedtoasubuser Update IPs assigned to a subuser // PUT /subusers/{subuser_name}/ips - func UpdateIPsassignedtoasubuser() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -226,17 +209,15 @@ func UpdateIPsassignedtoasubuser() { } } -/////////////////////////////////////////////////// -// Update Monitor Settings for a subuser +// UpdateMonitorSettingsforasubuser Update Monitor Settings for a subuser // PUT /subusers/{subuser_name}/monitor - func UpdateMonitorSettingsforasubuser() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/subusers/{subuser_name}/monitor", host) request.Method = "PUT" request.Body = []byte(` { - "email": "example@example.com", + "email": "example@example.com", "frequency": 500 }`) response, err := sendgrid.API(request) @@ -249,17 +230,15 @@ func UpdateMonitorSettingsforasubuser() { } } -/////////////////////////////////////////////////// -// Create monitor settings +// Createmonitorsettings Create monitor settings // POST /subusers/{subuser_name}/monitor - func Createmonitorsettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/subusers/{subuser_name}/monitor", host) request.Method = "POST" request.Body = []byte(` { - "email": "example@example.com", + "email": "example@example.com", "frequency": 50000 }`) response, err := sendgrid.API(request) @@ -272,10 +251,8 @@ func Createmonitorsettings() { } } -/////////////////////////////////////////////////// -// Retrieve monitor settings for a subuser +// Retrievemonitorsettingsforasubuser Retrieve monitor settings for a subuser // GET /subusers/{subuser_name}/monitor - func Retrievemonitorsettingsforasubuser() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -291,10 +268,8 @@ func Retrievemonitorsettingsforasubuser() { } } -/////////////////////////////////////////////////// -// Delete monitor settings +// Deletemonitorsettings Delete monitor settings // DELETE /subusers/{subuser_name}/monitor - func Deletemonitorsettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -310,10 +285,8 @@ func Deletemonitorsettings() { } } -/////////////////////////////////////////////////// -// Retrieve the monthly email statistics for a single subuser +// Retrievethemonthlyemailstatisticsforasinglesubuser Retrieve the monthly email statistics for a single subuser // GET /subusers/{subuser_name}/stats/monthly - func Retrievethemonthlyemailstatisticsforasinglesubuser() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" diff --git a/examples/suppression/suppression.go b/examples/suppression/suppression.go index 007518d0..90ddc176 100644 --- a/examples/suppression/suppression.go +++ b/examples/suppression/suppression.go @@ -2,15 +2,14 @@ package main import ( "fmt" - "github.com/sendgrid/sendgrid-go" "log" "os" + + "github.com/sendgrid/sendgrid-go" ) -/////////////////////////////////////////////////// -// Retrieve all blocks +// Retrieveallblocks Retrieve all blocks // GET /suppression/blocks - func Retrieveallblocks() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -32,19 +31,17 @@ func Retrieveallblocks() { } } -/////////////////////////////////////////////////// -// Delete blocks +// Deleteblocks Delete blocks // DELETE /suppression/blocks - func Deleteblocks() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/suppression/blocks", host) request.Method = "DELETE" request.Body = []byte(` { - "delete_all": false, + "delete_all": false, "emails": [ - "example1@example.com", + "example1@example.com", "example2@example.com" ] }`) @@ -58,10 +55,8 @@ func Deleteblocks() { } } -/////////////////////////////////////////////////// -// Retrieve a specific block +// Retrieveaspecificblock Retrieve a specific block // GET /suppression/blocks/{email} - func Retrieveaspecificblock() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -77,10 +72,8 @@ func Retrieveaspecificblock() { } } -/////////////////////////////////////////////////// -// Delete a specific block +// Deleteaspecificblock Delete a specific block // DELETE /suppression/blocks/{email} - func Deleteaspecificblock() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -96,10 +89,8 @@ func Deleteaspecificblock() { } } -/////////////////////////////////////////////////// -// Retrieve all bounces +// Retrieveallbounces Retrieve all bounces // GET /suppression/bounces - func Retrieveallbounces() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -119,19 +110,17 @@ func Retrieveallbounces() { } } -/////////////////////////////////////////////////// -// Delete bounces +// Deletebounces Delete bounces // DELETE /suppression/bounces - func Deletebounces() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/suppression/bounces", host) request.Method = "DELETE" request.Body = []byte(` { - "delete_all": true, + "delete_all": true, "emails": [ - "example@example.com", + "example@example.com", "example2@example.com" ] }`) @@ -145,10 +134,8 @@ func Deletebounces() { } } -/////////////////////////////////////////////////// -// Retrieve a Bounce +// RetrieveaBounce Retrieve a Bounce // GET /suppression/bounces/{email} - func RetrieveaBounce() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -164,10 +151,8 @@ func RetrieveaBounce() { } } -/////////////////////////////////////////////////// -// Delete a bounce +// Deleteabounce Delete a bounce // DELETE /suppression/bounces/{email} - func Deleteabounce() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -186,10 +171,8 @@ func Deleteabounce() { } } -/////////////////////////////////////////////////// -// Retrieve all invalid emails +// Retrieveallinvalidemails Retrieve all invalid emails // GET /suppression/invalid_emails - func Retrieveallinvalidemails() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -211,19 +194,17 @@ func Retrieveallinvalidemails() { } } -/////////////////////////////////////////////////// -// Delete invalid emails +// Deleteinvalidemails Delete invalid emails // DELETE /suppression/invalid_emails - func Deleteinvalidemails() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/suppression/invalid_emails", host) request.Method = "DELETE" request.Body = []byte(` { - "delete_all": false, + "delete_all": false, "emails": [ - "example1@example.com", + "example1@example.com", "example2@example.com" ] }`) @@ -237,10 +218,8 @@ func Deleteinvalidemails() { } } -/////////////////////////////////////////////////// -// Retrieve a specific invalid email +// Retrieveaspecificinvalidemail Retrieve a specific invalid email // GET /suppression/invalid_emails/{email} - func Retrieveaspecificinvalidemail() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -256,10 +235,8 @@ func Retrieveaspecificinvalidemail() { } } -/////////////////////////////////////////////////// -// Delete a specific invalid email +// Deleteaspecificinvalidemail Delete a specific invalid email // DELETE /suppression/invalid_emails/{email} - func Deleteaspecificinvalidemail() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -275,10 +252,8 @@ func Deleteaspecificinvalidemail() { } } -/////////////////////////////////////////////////// -// Retrieve a specific spam report +// Retrieveaspecificspamreport Retrieve a specific spam report // GET /suppression/spam_report/{email} - func Retrieveaspecificspamreport() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -294,10 +269,8 @@ func Retrieveaspecificspamreport() { } } -/////////////////////////////////////////////////// -// Delete a specific spam report +// Deleteaspecificspamreport Delete a specific spam report // DELETE /suppression/spam_report/{email} - func Deleteaspecificspamreport() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -313,10 +286,8 @@ func Deleteaspecificspamreport() { } } -/////////////////////////////////////////////////// -// Retrieve all spam reports +// Retrieveallspamreports Retrieve all spam reports // GET /suppression/spam_reports - func Retrieveallspamreports() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -338,19 +309,17 @@ func Retrieveallspamreports() { } } -/////////////////////////////////////////////////// -// Delete spam reports +// Deletespamreports Delete spam reports // DELETE /suppression/spam_reports - func Deletespamreports() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/suppression/spam_reports", host) request.Method = "DELETE" request.Body = []byte(` { - "delete_all": false, + "delete_all": false, "emails": [ - "example1@example.com", + "example1@example.com", "example2@example.com" ] }`) @@ -364,10 +333,8 @@ func Deletespamreports() { } } -/////////////////////////////////////////////////// -// Retrieve all global suppressions +// Retrieveallglobalsuppressions Retrieve all global suppressions // GET /suppression/unsubscribes - func Retrieveallglobalsuppressions() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" diff --git a/examples/templates/templates.go b/examples/templates/templates.go index ce8375c0..e2ee747e 100644 --- a/examples/templates/templates.go +++ b/examples/templates/templates.go @@ -2,15 +2,14 @@ package main import ( "fmt" - "github.com/sendgrid/sendgrid-go" "log" "os" + + "github.com/sendgrid/sendgrid-go" ) -/////////////////////////////////////////////////// -// Create a transactional template. +// Createatransactionaltemplate Create a transactional template. // POST /templates - func Createatransactionaltemplate() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -29,10 +28,8 @@ func Createatransactionaltemplate() { } } -/////////////////////////////////////////////////// -// Retrieve all transactional templates. +// Retrievealltransactionaltemplates Retrieve all transactional templates. // GET /templates - func Retrievealltransactionaltemplates() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -48,10 +45,8 @@ func Retrievealltransactionaltemplates() { } } -/////////////////////////////////////////////////// -// Edit a transactional template. +// Editatransactionaltemplate Edit a transactional template. // PATCH /templates/{template_id} - func Editatransactionaltemplate() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -70,10 +65,8 @@ func Editatransactionaltemplate() { } } -/////////////////////////////////////////////////// -// Retrieve a single transactional template. +// Retrieveasingletransactionaltemplate Retrieve a single transactional template. // GET /templates/{template_id} - func Retrieveasingletransactionaltemplate() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -89,10 +82,8 @@ func Retrieveasingletransactionaltemplate() { } } -/////////////////////////////////////////////////// -// Delete a template. +// Deleteatemplate Delete a template. // DELETE /templates/{template_id} - func Deleteatemplate() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -108,21 +99,19 @@ func Deleteatemplate() { } } -/////////////////////////////////////////////////// -// Create a new transactional template version. +// Createanewtransactionaltemplateversion Create a new transactional template version. // POST /templates/{template_id}/versions - func Createanewtransactionaltemplateversion() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/templates/{template_id}/versions", host) request.Method = "POST" request.Body = []byte(` { - "active": 1, - "html_content": "<%body%>", - "name": "example_version_name", - "plain_content": "<%body%>", - "subject": "<%subject%>", + "active": 1, + "html_content": "<%body%>", + "name": "example_version_name", + "plain_content": "<%body%>", + "subject": "<%subject%>", "template_id": "ddb96bbc-9b92-425e-8979-99464621b543" }`) response, err := sendgrid.API(request) @@ -135,20 +124,18 @@ func Createanewtransactionaltemplateversion() { } } -/////////////////////////////////////////////////// -// Edit a transactional template version. +// Editatransactionaltemplateversion Edit a transactional template version. // PATCH /templates/{template_id}/versions/{version_id} - func Editatransactionaltemplateversion() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/templates/{template_id}/versions/{version_id}", host) request.Method = "PATCH" request.Body = []byte(` { - "active": 1, - "html_content": "<%body%>", - "name": "updated_example_name", - "plain_content": "<%body%>", + "active": 1, + "html_content": "<%body%>", + "name": "updated_example_name", + "plain_content": "<%body%>", "subject": "<%subject%>" }`) response, err := sendgrid.API(request) @@ -161,10 +148,8 @@ func Editatransactionaltemplateversion() { } } -/////////////////////////////////////////////////// -// Retrieve a specific transactional template version. +// Retrieveaspecifictransactionaltemplateversion Retrieve a specific transactional template version. // GET /templates/{template_id}/versions/{version_id} - func Retrieveaspecifictransactionaltemplateversion() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -180,10 +165,8 @@ func Retrieveaspecifictransactionaltemplateversion() { } } -/////////////////////////////////////////////////// -// Delete a transactional template version. +// Deleteatransactionaltemplateversion Delete a transactional template version. // DELETE /templates/{template_id}/versions/{version_id} - func Deleteatransactionaltemplateversion() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -199,10 +182,8 @@ func Deleteatransactionaltemplateversion() { } } -/////////////////////////////////////////////////// -// Activate a transactional template version. +// Activateatransactionaltemplateversion Activate a transactional template version. // POST /templates/{template_id}/versions/{version_id}/activate - func Activateatransactionaltemplateversion() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" diff --git a/examples/trackingsettings/trackingsettings.go b/examples/trackingsettings/trackingsettings.go index a510f698..5584e798 100644 --- a/examples/trackingsettings/trackingsettings.go +++ b/examples/trackingsettings/trackingsettings.go @@ -2,15 +2,14 @@ package main import ( "fmt" - "github.com/sendgrid/sendgrid-go" "log" "os" + + "github.com/sendgrid/sendgrid-go" ) -/////////////////////////////////////////////////// -// Retrieve Tracking Settings +// RetrieveTrackingSettings Retrieve Tracking Settings // GET /tracking_settings - func RetrieveTrackingSettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -30,10 +29,8 @@ func RetrieveTrackingSettings() { } } -/////////////////////////////////////////////////// -// Update Click Tracking Settings +// UpdateClickTrackingSettings Update Click Tracking Settings // PATCH /tracking_settings/click - func UpdateClickTrackingSettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -52,10 +49,8 @@ func UpdateClickTrackingSettings() { } } -/////////////////////////////////////////////////// -// Retrieve Click Track Settings +// RetrieveClickTrackSettings Retrieve Click Track Settings // GET /tracking_settings/click - func RetrieveClickTrackSettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -71,21 +66,19 @@ func RetrieveClickTrackSettings() { } } -/////////////////////////////////////////////////// -// Update Google Analytics Settings +// UpdateGoogleAnalyticsSettings Update Google Analytics Settings // PATCH /tracking_settings/google_analytics - func UpdateGoogleAnalyticsSettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/tracking_settings/google_analytics", host) request.Method = "PATCH" request.Body = []byte(` { - "enabled": true, - "utm_campaign": "website", - "utm_content": "", - "utm_medium": "email", - "utm_source": "sendgrid.com", + "enabled": true, + "utm_campaign": "website", + "utm_content": "", + "utm_medium": "email", + "utm_source": "sendgrid.com", "utm_term": "" }`) response, err := sendgrid.API(request) @@ -98,10 +91,8 @@ func UpdateGoogleAnalyticsSettings() { } } -/////////////////////////////////////////////////// -// Retrieve Google Analytics Settings +// RetrieveGoogleAnalyticsSettings Retrieve Google Analytics Settings // GET /tracking_settings/google_analytics - func RetrieveGoogleAnalyticsSettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -117,10 +108,8 @@ func RetrieveGoogleAnalyticsSettings() { } } -/////////////////////////////////////////////////// -// Update Open Tracking Settings +// UpdateOpenTrackingSettings Update Open Tracking Settings // PATCH /tracking_settings/open - func UpdateOpenTrackingSettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -139,10 +128,8 @@ func UpdateOpenTrackingSettings() { } } -/////////////////////////////////////////////////// -// Get Open Tracking Settings +// GetOpenTrackingSettings Get Open Tracking Settings // GET /tracking_settings/open - func GetOpenTrackingSettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -158,21 +145,19 @@ func GetOpenTrackingSettings() { } } -/////////////////////////////////////////////////// -// Update Subscription Tracking Settings +// UpdateSubscriptionTrackingSettings Update Subscription Tracking Settings // PATCH /tracking_settings/subscription - func UpdateSubscriptionTrackingSettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/tracking_settings/subscription", host) request.Method = "PATCH" request.Body = []byte(` { - "enabled": true, - "html_content": "html content", - "landing": "landing page html", - "plain_content": "text content", - "replace": "replacement tag", + "enabled": true, + "html_content": "html content", + "landing": "landing page html", + "plain_content": "text content", + "replace": "replacement tag", "url": "url" }`) response, err := sendgrid.API(request) @@ -185,10 +170,8 @@ func UpdateSubscriptionTrackingSettings() { } } -/////////////////////////////////////////////////// -// Retrieve Subscription Tracking Settings +// RetrieveSubscriptionTrackingSettings Retrieve Subscription Tracking Settings // GET /tracking_settings/subscription - func RetrieveSubscriptionTrackingSettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" diff --git a/examples/user/user.go b/examples/user/user.go index d67e5716..0ea4a580 100644 --- a/examples/user/user.go +++ b/examples/user/user.go @@ -2,15 +2,14 @@ package main import ( "fmt" - "github.com/sendgrid/sendgrid-go" "log" "os" + + "github.com/sendgrid/sendgrid-go" ) -/////////////////////////////////////////////////// -// Get a user's account information. +// Getausersaccountinformation Get a user's account information. // GET /user/account - func Getausersaccountinformation() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -26,10 +25,8 @@ func Getausersaccountinformation() { } } -/////////////////////////////////////////////////// -// Retrieve your credit balance +// Retrieveyourcreditbalance Retrieve your credit balance // GET /user/credits - func Retrieveyourcreditbalance() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -45,10 +42,8 @@ func Retrieveyourcreditbalance() { } } -/////////////////////////////////////////////////// -// Update your account email address +// Updateyouraccountemailaddress Update your account email address // PUT /user/email - func Updateyouraccountemailaddress() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -67,10 +62,8 @@ func Updateyouraccountemailaddress() { } } -/////////////////////////////////////////////////// -// Retrieve your account email address +// Retrieveyouraccountemailaddress Retrieve your account email address // GET /user/email - func Retrieveyouraccountemailaddress() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -86,17 +79,15 @@ func Retrieveyouraccountemailaddress() { } } -/////////////////////////////////////////////////// -// Update your password +// Updateyourpassword Update your password // PUT /user/password - func Updateyourpassword() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/user/password", host) request.Method = "PUT" request.Body = []byte(` { - "new_password": "new_password", + "new_password": "new_password", "old_password": "old_password" }`) response, err := sendgrid.API(request) @@ -109,18 +100,16 @@ func Updateyourpassword() { } } -/////////////////////////////////////////////////// -// Update a user's profile +// Updateausersprofile Update a user's profile // PATCH /user/profile - func Updateausersprofile() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/user/profile", host) request.Method = "PATCH" request.Body = []byte(` { - "city": "Orange", - "first_name": "Example", + "city": "Orange", + "first_name": "Example", "last_name": "User" }`) response, err := sendgrid.API(request) @@ -133,10 +122,8 @@ func Updateausersprofile() { } } -/////////////////////////////////////////////////// -// Get a user's profile +// Getausersprofile Get a user's profile // GET /user/profile - func Getausersprofile() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -152,17 +139,15 @@ func Getausersprofile() { } } -/////////////////////////////////////////////////// -// Cancel or pause a scheduled send +// Cancelorpauseascheduledsend Cancel or pause a scheduled send // POST /user/scheduled_sends - func Cancelorpauseascheduledsend() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/user/scheduled_sends", host) request.Method = "POST" request.Body = []byte(` { - "batch_id": "YOUR_BATCH_ID", + "batch_id": "YOUR_BATCH_ID", "status": "pause" }`) response, err := sendgrid.API(request) @@ -175,10 +160,8 @@ func Cancelorpauseascheduledsend() { } } -/////////////////////////////////////////////////// -// Retrieve all scheduled sends +// Retrieveallscheduledsends Retrieve all scheduled sends // GET /user/scheduled_sends - func Retrieveallscheduledsends() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -194,10 +177,8 @@ func Retrieveallscheduledsends() { } } -/////////////////////////////////////////////////// -// Update user scheduled send information +// Updateuserscheduledsendinformation Update user scheduled send information // PATCH /user/scheduled_sends/{batch_id} - func Updateuserscheduledsendinformation() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -216,10 +197,8 @@ func Updateuserscheduledsendinformation() { } } -/////////////////////////////////////////////////// -// Retrieve scheduled send +// Retrievescheduledsend Retrieve scheduled send // GET /user/scheduled_sends/{batch_id} - func Retrievescheduledsend() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -235,10 +214,8 @@ func Retrievescheduledsend() { } } -/////////////////////////////////////////////////// -// Delete a cancellation or pause of a scheduled send +// Deleteacancellationorpauseofascheduledsend Delete a cancellation or pause of a scheduled send // DELETE /user/scheduled_sends/{batch_id} - func Deleteacancellationorpauseofascheduledsend() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -254,17 +231,15 @@ func Deleteacancellationorpauseofascheduledsend() { } } -/////////////////////////////////////////////////// -// Update Enforced TLS settings +// UpdateEnforcedTLSsettings Update Enforced TLS settings // PATCH /user/settings/enforced_tls - func UpdateEnforcedTLSsettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/user/settings/enforced_tls", host) request.Method = "PATCH" request.Body = []byte(` { - "require_tls": true, + "require_tls": true, "require_valid_cert": false }`) response, err := sendgrid.API(request) @@ -277,10 +252,8 @@ func UpdateEnforcedTLSsettings() { } } -/////////////////////////////////////////////////// -// Retrieve current Enforced TLS settings. +// RetrievecurrentEnforcedTLSsettings Retrieve current Enforced TLS settings. // GET /user/settings/enforced_tls - func RetrievecurrentEnforcedTLSsettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -296,10 +269,8 @@ func RetrievecurrentEnforcedTLSsettings() { } } -/////////////////////////////////////////////////// -// Update your username +// Updateyourusername Update your username // PUT /user/username - func Updateyourusername() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -318,10 +289,8 @@ func Updateyourusername() { } } -/////////////////////////////////////////////////// -// Retrieve your username +// Retrieveyourusername Retrieve your username // GET /user/username - func Retrieveyourusername() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -337,28 +306,26 @@ func Retrieveyourusername() { } } -/////////////////////////////////////////////////// -// Update Event Notification Settings +// UpdateEventNotificationSettings Update Event Notification Settings // PATCH /user/webhooks/event/settings - func UpdateEventNotificationSettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/user/webhooks/event/settings", host) request.Method = "PATCH" request.Body = []byte(` { - "bounce": true, - "click": true, - "deferred": true, - "delivered": true, - "dropped": true, - "enabled": true, - "group_resubscribe": true, - "group_unsubscribe": true, - "open": true, - "processed": true, - "spam_report": true, - "unsubscribe": true, + "bounce": true, + "click": true, + "deferred": true, + "delivered": true, + "dropped": true, + "enabled": true, + "group_resubscribe": true, + "group_unsubscribe": true, + "open": true, + "processed": true, + "spam_report": true, + "unsubscribe": true, "url": "url" }`) response, err := sendgrid.API(request) @@ -371,10 +338,8 @@ func UpdateEventNotificationSettings() { } } -/////////////////////////////////////////////////// -// Retrieve Event Webhook settings +// RetrieveEventWebhooksettings Retrieve Event Webhook settings // GET /user/webhooks/event/settings - func RetrieveEventWebhooksettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -390,10 +355,8 @@ func RetrieveEventWebhooksettings() { } } -/////////////////////////////////////////////////// -// Test Event Notification Settings +// TestEventNotificationSettings Test Event Notification Settings // POST /user/webhooks/event/test - func TestEventNotificationSettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -412,19 +375,17 @@ func TestEventNotificationSettings() { } } -/////////////////////////////////////////////////// -// Create a parse setting +// Createaparsesetting Create a parse setting // POST /user/webhooks/parse/settings - func Createaparsesetting() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/user/webhooks/parse/settings", host) request.Method = "POST" request.Body = []byte(` { - "hostname": "myhostname.com", - "send_raw": false, - "spam_check": true, + "hostname": "myhostname.com", + "send_raw": false, + "spam_check": true, "url": "http://email.myhosthame.com" }`) response, err := sendgrid.API(request) @@ -437,10 +398,8 @@ func Createaparsesetting() { } } -/////////////////////////////////////////////////// -// Retrieve all parse settings +// Retrieveallparsesettings Retrieve all parse settings // GET /user/webhooks/parse/settings - func Retrieveallparsesettings() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -456,18 +415,16 @@ func Retrieveallparsesettings() { } } -/////////////////////////////////////////////////// -// Update a parse setting +// Updateaparsesetting Update a parse setting // PATCH /user/webhooks/parse/settings/{hostname} - func Updateaparsesetting() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/user/webhooks/parse/settings/{hostname}", host) request.Method = "PATCH" request.Body = []byte(` { - "send_raw": true, - "spam_check": false, + "send_raw": true, + "spam_check": false, "url": "http://newdomain.com/parse" }`) response, err := sendgrid.API(request) @@ -480,10 +437,8 @@ func Updateaparsesetting() { } } -/////////////////////////////////////////////////// -// Retrieve a specific parse setting +// Retrieveaspecificparsesetting Retrieve a specific parse setting // GET /user/webhooks/parse/settings/{hostname} - func Retrieveaspecificparsesetting() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -499,10 +454,8 @@ func Retrieveaspecificparsesetting() { } } -/////////////////////////////////////////////////// -// Delete a parse setting +// Deleteaparsesetting Delete a parse setting // DELETE /user/webhooks/parse/settings/{hostname} - func Deleteaparsesetting() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -518,10 +471,8 @@ func Deleteaparsesetting() { } } -/////////////////////////////////////////////////// -// Retrieves Inbound Parse Webhook statistics. +// RetrievesInboundParseWebhookstatistics tRetrieves Inbound Parse Webhook statistics. // GET /user/webhooks/parse/stats - func RetrievesInboundParseWebhookstatistics() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" diff --git a/examples/whitelabel/whitelabel.go b/examples/whitelabel/whitelabel.go index 0dd03e15..33df076a 100644 --- a/examples/whitelabel/whitelabel.go +++ b/examples/whitelabel/whitelabel.go @@ -2,30 +2,29 @@ package main import ( "fmt" - "github.com/sendgrid/sendgrid-go" "log" "os" + + "github.com/sendgrid/sendgrid-go" ) -/////////////////////////////////////////////////// -// Create a domain whitelabel. +// Createadomainwhitelabel Create a domain whitelabel. // POST /whitelabel/domains - func Createadomainwhitelabel() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/whitelabel/domains", host) request.Method = "POST" request.Body = []byte(` { - "automatic_security": false, - "custom_spf": true, - "default": true, - "domain": "example.com", + "automatic_security": false, + "custom_spf": true, + "default": true, + "domain": "example.com", "ips": [ - "192.168.1.1", + "192.168.1.1", "192.168.1.2" - ], - "subdomain": "news", + ], + "subdomain": "news", "username": "john@example.com" }`) response, err := sendgrid.API(request) @@ -38,10 +37,8 @@ func Createadomainwhitelabel() { } } -/////////////////////////////////////////////////// -// List all domain whitelabels. +// Listalldomainwhitelabels List all domain whitelabels. // GET /whitelabel/domains - func Listalldomainwhitelabels() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -64,10 +61,8 @@ func Listalldomainwhitelabels() { } } -/////////////////////////////////////////////////// -// Get the default domain whitelabel. +// Getthedefaultdomainwhitelabel Get the default domain whitelabel. // GET /whitelabel/domains/default - func Getthedefaultdomainwhitelabel() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -83,10 +78,8 @@ func Getthedefaultdomainwhitelabel() { } } -/////////////////////////////////////////////////// -// List the domain whitelabel associated with the given user. +// Listthedomainwhitelabelassociatedwiththegivenuser List the domain whitelabel associated with the given user. // GET /whitelabel/domains/subuser - func Listthedomainwhitelabelassociatedwiththegivenuser() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -102,10 +95,8 @@ func Listthedomainwhitelabelassociatedwiththegivenuser() { } } -/////////////////////////////////////////////////// -// Disassociate a domain whitelabel from a given user. +// Disassociateadomainwhitelabelfromagivenuser Disassociate a domain whitelabel from a given user. // DELETE /whitelabel/domains/subuser - func Disassociateadomainwhitelabelfromagivenuser() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -121,17 +112,15 @@ func Disassociateadomainwhitelabelfromagivenuser() { } } -/////////////////////////////////////////////////// -// Update a domain whitelabel. +// Updateadomainwhitelabel Update a domain whitelabel. // PATCH /whitelabel/domains/{domain_id} - func Updateadomainwhitelabel() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/whitelabel/domains/{domain_id}", host) request.Method = "PATCH" request.Body = []byte(` { - "custom_spf": true, + "custom_spf": true, "default": false }`) response, err := sendgrid.API(request) @@ -144,10 +133,8 @@ func Updateadomainwhitelabel() { } } -/////////////////////////////////////////////////// -// Retrieve a domain whitelabel. +// Retrieveadomainwhitelabel Retrieve a domain whitelabel. // GET /whitelabel/domains/{domain_id} - func Retrieveadomainwhitelabel() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -163,10 +150,8 @@ func Retrieveadomainwhitelabel() { } } -/////////////////////////////////////////////////// -// Delete a domain whitelabel. +// Deleteadomainwhitelabel Delete a domain whitelabel. // DELETE /whitelabel/domains/{domain_id} - func Deleteadomainwhitelabel() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -182,10 +167,8 @@ func Deleteadomainwhitelabel() { } } -/////////////////////////////////////////////////// -// Associate a domain whitelabel with a given user. +// Associateadomainwhitelabelwithagivenuser Associate a domain whitelabel with a given user. // POST /whitelabel/domains/{domain_id}/subuser - func Associateadomainwhitelabelwithagivenuser() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -204,10 +187,8 @@ func Associateadomainwhitelabelwithagivenuser() { } } -/////////////////////////////////////////////////// -// Add an IP to a domain whitelabel. +// AddanIPtoadomainwhitelabel Add an IP to a domain whitelabel. // POST /whitelabel/domains/{id}/ips - func AddanIPtoadomainwhitelabel() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -226,10 +207,8 @@ func AddanIPtoadomainwhitelabel() { } } -/////////////////////////////////////////////////// -// Remove an IP from a domain whitelabel. +// RemoveanIPfromadomainwhitelabel Remove an IP from a domain whitelabel. // DELETE /whitelabel/domains/{id}/ips/{ip} - func RemoveanIPfromadomainwhitelabel() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -245,10 +224,8 @@ func RemoveanIPfromadomainwhitelabel() { } } -/////////////////////////////////////////////////// -// Validate a domain whitelabel. +// Validateadomainwhitelabel Validate a domain whitelabel. // POST /whitelabel/domains/{id}/validate - func Validateadomainwhitelabel() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -264,18 +241,16 @@ func Validateadomainwhitelabel() { } } -/////////////////////////////////////////////////// -// Create an IP whitelabel +// CreateanIPwhitelabel Create an IP whitelabel // POST /whitelabel/ips - func CreateanIPwhitelabel() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/whitelabel/ips", host) request.Method = "POST" request.Body = []byte(` { - "domain": "example.com", - "ip": "192.168.1.1", + "domain": "example.com", + "ip": "192.168.1.1", "subdomain": "email" }`) response, err := sendgrid.API(request) @@ -288,10 +263,8 @@ func CreateanIPwhitelabel() { } } -/////////////////////////////////////////////////// -// Retrieve all IP whitelabels +// RetrieveallIPwhitelabels Retrieve all IP whitelabels // GET /whitelabel/ips - func RetrieveallIPwhitelabels() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -312,10 +285,8 @@ func RetrieveallIPwhitelabels() { } } -/////////////////////////////////////////////////// -// Retrieve an IP whitelabel +// RetrieveanIPwhitelabel Retrieve an IP whitelabel // GET /whitelabel/ips/{id} - func RetrieveanIPwhitelabel() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -331,10 +302,8 @@ func RetrieveanIPwhitelabel() { } } -/////////////////////////////////////////////////// -// Delete an IP whitelabel +// DeleteanIPwhitelabel Delete an IP whitelabel // DELETE /whitelabel/ips/{id} - func DeleteanIPwhitelabel() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -350,10 +319,8 @@ func DeleteanIPwhitelabel() { } } -/////////////////////////////////////////////////// -// Validate an IP whitelabel +// ValidateanIPwhitelabel Validate an IP whitelabel // POST /whitelabel/ips/{id}/validate - func ValidateanIPwhitelabel() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -369,18 +336,16 @@ func ValidateanIPwhitelabel() { } } -/////////////////////////////////////////////////// -// Create a Link Whitelabel +// CreateaLinkWhitelabel Create a Link Whitelabel // POST /whitelabel/links - func CreateaLinkWhitelabel() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" request := sendgrid.GetRequest(apiKey, "/v3/whitelabel/links", host) request.Method = "POST" request.Body = []byte(` { - "default": true, - "domain": "example.com", + "default": true, + "domain": "example.com", "subdomain": "mail" }`) queryParams := make(map[string]string) @@ -397,10 +362,8 @@ func CreateaLinkWhitelabel() { } } -/////////////////////////////////////////////////// -// Retrieve all link whitelabels +// Retrievealllinkwhitelabels Retrieve all link whitelabels // GET /whitelabel/links - func Retrievealllinkwhitelabels() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -419,10 +382,8 @@ func Retrievealllinkwhitelabels() { } } -/////////////////////////////////////////////////// -// Retrieve a Default Link Whitelabel +// RetrieveaDefaultLinkWhitelabel Retrieve a Default Link Whitelabel // GET /whitelabel/links/default - func RetrieveaDefaultLinkWhitelabel() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -441,10 +402,8 @@ func RetrieveaDefaultLinkWhitelabel() { } } -/////////////////////////////////////////////////// -// Retrieve Associated Link Whitelabel +// RetrieveAssociatedLinkWhitelabel Retrieve Associated Link Whitelabel // GET /whitelabel/links/subuser - func RetrieveAssociatedLinkWhitelabel() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -463,10 +422,8 @@ func RetrieveAssociatedLinkWhitelabel() { } } -/////////////////////////////////////////////////// -// Disassociate a Link Whitelabel +// DisassociateaLinkWhitelabel Disassociate a Link Whitelabel // DELETE /whitelabel/links/subuser - func DisassociateaLinkWhitelabel() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -485,10 +442,8 @@ func DisassociateaLinkWhitelabel() { } } -/////////////////////////////////////////////////// -// Update a Link Whitelabel +// UpdateaLinkWhitelabel Update a Link Whitelabel // PATCH /whitelabel/links/{id} - func UpdateaLinkWhitelabel() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -507,10 +462,8 @@ func UpdateaLinkWhitelabel() { } } -/////////////////////////////////////////////////// -// Retrieve a Link Whitelabel +// RetrieveaLinkWhitelabel Retrieve a Link Whitelabel // GET /whitelabel/links/{id} - func RetrieveaLinkWhitelabel() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -526,10 +479,8 @@ func RetrieveaLinkWhitelabel() { } } -/////////////////////////////////////////////////// -// Delete a Link Whitelabel +// DeleteaLinkWhitelabel Delete a Link Whitelabel // DELETE /whitelabel/links/{id} - func DeleteaLinkWhitelabel() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -545,10 +496,8 @@ func DeleteaLinkWhitelabel() { } } -/////////////////////////////////////////////////// -// Validate a Link Whitelabel +// ValidateaLinkWhitelabel Validate a Link Whitelabel // POST /whitelabel/links/{id}/validate - func ValidateaLinkWhitelabel() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" @@ -564,10 +513,8 @@ func ValidateaLinkWhitelabel() { } } -/////////////////////////////////////////////////// -// Associate a Link Whitelabel +// AssociateaLinkWhitelabel Associate a Link Whitelabel // POST /whitelabel/links/{link_id}/subuser - func AssociateaLinkWhitelabel() { apiKey := os.Getenv("YOUR_SENDGRID_APIKEY") host := "https://api.sendgrid.com" diff --git a/helpers/mail/mail_v3.go b/helpers/mail/mail_v3.go index efad1351..ddab9f7d 100644 --- a/helpers/mail/mail_v3.go +++ b/helpers/mail/mail_v3.go @@ -5,6 +5,7 @@ import ( "log" ) +// SGMailV3 contains mail struct type SGMailV3 struct { From *Email `json:"from,omitempty"` Subject string `json:"subject,omitempty"` @@ -25,6 +26,7 @@ type SGMailV3 struct { ReplyTo *Email `json:"reply_to,omitempty"` } +// Personalization holds mail body struct type Personalization struct { To []*Email `json:"to,omitempty"` CC []*Email `json:"cc,omitempty"` @@ -37,16 +39,19 @@ type Personalization struct { SendAt int `json:"send_at,omitempty"` } +// Email holds email Name and adress info type Email struct { Name string `json:"name,omitempty"` Address string `json:"email,omitempty"` } +// Content defines content of the mail body type Content struct { Type string `json:"type,omitempty"` Value string `json:"value,omitempty"` } +// Attachment holds attachement information type Attachment struct { Content string `json:"content,omitempty"` Type string `json:"type,omitempty"` @@ -56,11 +61,13 @@ type Attachment struct { ContentID string `json:"content_id,omitempty"` } +// Asm contains Grpip Id and int array of groups ID type Asm struct { GroupID int `json:"group_id,omitempty"` GroupsToDisplay []int `json:"groups_to_display,omitempty"` } +// MailSettings defines mail and spamCheck settings type MailSettings struct { BCC *BccSetting `json:"bcc,omitempty"` BypassListManagement *Setting `json:"bypass_list_management,omitempty"` @@ -69,6 +76,7 @@ type MailSettings struct { SpamCheckSetting *SpamCheckSetting `json:"spam_check,omitempty"` } +// TrackingSettings holds tracking settings and mail settings type TrackingSettings struct { ClickTracking *ClickTrackingSetting `json:"click_tracking,omitempty"` OpenTracking *OpenTrackingSetting `json:"open_tracking,omitempty"` @@ -80,11 +88,15 @@ type TrackingSettings struct { SandboxMode *SandboxModeSetting `json:"sandbox_mode,omitempty"` } +// BccSetting holds email bcc setings to enable of disable +// default is false type BccSetting struct { Enable *bool `json:"enable,omitempty"` Email string `json:"email,omitempty"` } +// FooterSetting holds enaable/disable settings +// and the format of footer i.e HTML/Text type FooterSetting struct { Enable *bool `json:"enable,omitempty"` Text string `json:"text,omitempty"` @@ -107,6 +119,9 @@ type SandboxModeSetting struct { SpamCheck *SpamCheckSetting `json:"spam_check,omitempty"` } +// SpamCheckSetting holds spam settings and +// which can be enable or disable and +// contains spamThreshold value type SpamCheckSetting struct { Enable *bool `json:"enable,omitempty"` SpamThreshold int `json:"threshold,omitempty"` @@ -129,6 +144,7 @@ type GaSetting struct { CampaignMedium string `json:"utm_medium,omitempty"` } +// Setting enables the mail settings type Setting struct { Enable *bool `json:"enable,omitempty"` } diff --git a/helpers/mail/mail_v3_test.go b/helpers/mail/mail_v3_test.go index 74d835b4..59e805f2 100644 --- a/helpers/mail/mail_v3_test.go +++ b/helpers/mail/mail_v3_test.go @@ -8,6 +8,7 @@ import ( "time" ) +// TestV3NewMail will test New mail method func TestV3NewMail(t *testing.T) { m := NewV3Mail() diff --git a/sendgrid.go b/sendgrid.go index b8277d09..86860c70 100644 --- a/sendgrid.go +++ b/sendgrid.go @@ -9,6 +9,7 @@ import ( // Version is this client library's current version const Version = "3.1.0" +// Client contains rest.Request to an a API call type Client struct { rest.Request } @@ -30,11 +31,13 @@ func GetRequest(key string, endpoint string, host string) rest.Request { return request } +// Send gets API rest.Response to the give request body of type SGMailV3 func (cl *Client) Send(email *mail.SGMailV3) (*rest.Response, error) { cl.Body = mail.GetRequestBody(email) return API(cl.Request) } +// NewSendClient create a new Client for a given key func NewSendClient(key string) *Client { request := GetRequest(key, "/v3/mail/send", "") request.Method = "POST"