Skip to content

Commit

Permalink
Merge pull request #197 from nafisfaysal/master
Browse files Browse the repository at this point in the history
Make Getenv("message") parameter more professional
  • Loading branch information
thinkingserious committed Oct 23, 2018
2 parents 7440206 + 3e597c3 commit 7dcfc0a
Show file tree
Hide file tree
Showing 27 changed files with 278 additions and 279 deletions.
2 changes: 1 addition & 1 deletion USAGE.md
Expand Up @@ -12,7 +12,7 @@ import (
"os"
)

apiKey := os.Getenv("YOUR_SENDGRID_APIKEY")
apiKey := os.Getenv("SENDGRID_API_KEY")
host := "https://api.sendgrid.com"
```

Expand Down
21 changes: 10 additions & 11 deletions examples/accesssettings/accesssettings.go
Expand Up @@ -2,15 +2,14 @@ package main

import (
"fmt"
"github.com/sendgrid/sendgrid-go"
"log"
"os"
)

// Retrieveallrecentaccessattempts : Retrieve all recent access attempts
// GET /access_settings/activity
func Retrieveallrecentaccessattempts() {
apiKey := os.Getenv("YOUR_SENDGRID_APIKEY")
apiKey := os.Getenv("SENDGRID_API_KEY")
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/access_settings/activity", host)
request.Method = "GET"
Expand All @@ -30,18 +29,18 @@ func Retrieveallrecentaccessattempts() {
// AddoneormoreIPstothewhitelist : Add one or more IPs to the whitelist
// POST /access_settings/whitelist
func AddoneormoreIPstothewhitelist() {
apiKey := os.Getenv("YOUR_SENDGRID_APIKEY")
apiKey := os.Getenv("SENDGRID_API_KEY")
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/access_settings/whitelist", host)
request.Method = "POST"
request.Body = []byte(` {
"ips": [
{
"ip": "192.168.1.1"
},
},
{
"ip": "192.*.*.*"
},
},
{
"ip": "192.168.1.3/32"
}
Expand All @@ -60,7 +59,7 @@ func AddoneormoreIPstothewhitelist() {
// RetrievealistofcurrentlywhitelistedIPs : Retrieve a list of currently whitelisted IPs
// GET /access_settings/whitelist
func RetrievealistofcurrentlywhitelistedIPs() {
apiKey := os.Getenv("YOUR_SENDGRID_APIKEY")
apiKey := os.Getenv("SENDGRID_API_KEY")
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/access_settings/whitelist", host)
request.Method = "GET"
Expand All @@ -77,14 +76,14 @@ func RetrievealistofcurrentlywhitelistedIPs() {
// RemoveoneormoreIPsfromthewhitelist : Remove one or more IPs from the whitelist
// DELETE /access_settings/whitelist
func RemoveoneormoreIPsfromthewhitelist() {
apiKey := os.Getenv("YOUR_SENDGRID_APIKEY")
apiKey := os.Getenv("SENDGRID_API_KEY")
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/access_settings/whitelist", host)
request.Method = "DELETE"
request.Body = []byte(` {
"ids": [
1,
2,
1,
2,
3
]
}`)
Expand All @@ -101,7 +100,7 @@ func RemoveoneormoreIPsfromthewhitelist() {
// RetrieveaspecificwhitelistedIP : Retrieve a specific whitelisted IP
// GET /access_settings/whitelist/{rule_id}
func RetrieveaspecificwhitelistedIP() {
apiKey := os.Getenv("YOUR_SENDGRID_APIKEY")
apiKey := os.Getenv("SENDGRID_API_KEY")
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/access_settings/whitelist/{rule_id}", host)
request.Method = "GET"
Expand All @@ -118,7 +117,7 @@ func RetrieveaspecificwhitelistedIP() {
// RemoveaspecificIPfromthewhitelist : Remove a specific IP from the whitelist
// DELETE /access_settings/whitelist/{rule_id}
func RemoveaspecificIPfromthewhitelist() {
apiKey := os.Getenv("YOUR_SENDGRID_APIKEY")
apiKey := os.Getenv("SENDGRID_API_KEY")
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/access_settings/whitelist/{rule_id}", host)
request.Method = "DELETE"
Expand Down
10 changes: 5 additions & 5 deletions examples/alerts/alerts.go
Expand Up @@ -10,7 +10,7 @@ import (
// CreateanewAlert : Create a new Alert
// POST /alerts
func CreateanewAlert() {
apiKey := os.Getenv("YOUR_SENDGRID_APIKEY")
apiKey := os.Getenv("SENDGRID_API_KEY")
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/alerts", host)
request.Method = "POST"
Expand All @@ -32,7 +32,7 @@ func CreateanewAlert() {
// Retrieveallalerts : Retrieve all alerts
// GET /alerts
func Retrieveallalerts() {
apiKey := os.Getenv("YOUR_SENDGRID_APIKEY")
apiKey := os.Getenv("SENDGRID_API_KEY")
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/alerts", host)
request.Method = "GET"
Expand All @@ -49,7 +49,7 @@ func Retrieveallalerts() {
// Updateanalert : Update an alert
// PATCH /alerts/{alert_id}
func Updateanalert() {
apiKey := os.Getenv("YOUR_SENDGRID_APIKEY")
apiKey := os.Getenv("SENDGRID_API_KEY")
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/alerts/{alert_id}", host)
request.Method = "PATCH"
Expand All @@ -69,7 +69,7 @@ func Updateanalert() {
// Retrieveaspecificalert : Retrieve a specific alert
// GET /alerts/{alert_id}
func Retrieveaspecificalert() {
apiKey := os.Getenv("YOUR_SENDGRID_APIKEY")
apiKey := os.Getenv("SENDGRID_API_KEY")
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/alerts/{alert_id}", host)
request.Method = "GET"
Expand All @@ -86,7 +86,7 @@ func Retrieveaspecificalert() {
// Deleteanalert : Delete an alert
// DELETE /alerts/{alert_id}
func Deleteanalert() {
apiKey := os.Getenv("YOUR_SENDGRID_APIKEY")
apiKey := os.Getenv("SENDGRID_API_KEY")
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/alerts/{alert_id}", host)
request.Method = "DELETE"
Expand Down
25 changes: 12 additions & 13 deletions examples/apikeys/apikeys.go
Expand Up @@ -2,24 +2,23 @@ package main

import (
"fmt"
"github.com/sendgrid/sendgrid-go"
"log"
"os"
)

// CreateAPIkeys : Create API keys
// POST /api_keys
func CreateAPIkeys() {
apiKey := os.Getenv("YOUR_SENDGRID_APIKEY")
apiKey := os.Getenv("SENDGRID_API_KEY")
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"
]
}`)
Expand All @@ -36,7 +35,7 @@ func CreateAPIkeys() {
// RetrieveallAPIKeysbelongingtotheauthenticateduser : Retrieve all API Keys belonging to the authenticated user
// GET /api_keys
func RetrieveallAPIKeysbelongingtotheauthenticateduser() {
apiKey := os.Getenv("YOUR_SENDGRID_APIKEY")
apiKey := os.Getenv("SENDGRID_API_KEY")
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/api_keys", host)
request.Method = "GET"
Expand All @@ -56,14 +55,14 @@ func RetrieveallAPIKeysbelongingtotheauthenticateduser() {
// UpdatethenamescopesofanAPIKey : Update the name & scopes of an API Key
// PUT /api_keys/{api_key_id}
func UpdatethenamescopesofanAPIKey() {
apiKey := os.Getenv("YOUR_SENDGRID_APIKEY")
apiKey := os.Getenv("SENDGRID_API_KEY")
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"
]
}`)
Expand All @@ -80,7 +79,7 @@ func UpdatethenamescopesofanAPIKey() {
// UpdateAPIkeys : Update API keys
// PATCH /api_keys/{api_key_id}
func UpdateAPIkeys() {
apiKey := os.Getenv("YOUR_SENDGRID_APIKEY")
apiKey := os.Getenv("SENDGRID_API_KEY")
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/api_keys/{api_key_id}", host)
request.Method = "PATCH"
Expand All @@ -100,7 +99,7 @@ func UpdateAPIkeys() {
// RetrieveanexistingAPIKey : Retrieve an existing API Key
// GET /api_keys/{api_key_id}
func RetrieveanexistingAPIKey() {
apiKey := os.Getenv("YOUR_SENDGRID_APIKEY")
apiKey := os.Getenv("SENDGRID_API_KEY")
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/api_keys/{api_key_id}", host)
request.Method = "GET"
Expand All @@ -117,7 +116,7 @@ func RetrieveanexistingAPIKey() {
// DeleteAPIkeys : Delete API keys
// DELETE /api_keys/{api_key_id}
func DeleteAPIkeys() {
apiKey := os.Getenv("YOUR_SENDGRID_APIKEY")
apiKey := os.Getenv("SENDGRID_API_KEY")
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/api_keys/{api_key_id}", host)
request.Method = "DELETE"
Expand Down
28 changes: 14 additions & 14 deletions examples/asm/asm.go
Expand Up @@ -10,7 +10,7 @@ import (
// Createanewsuppressiongroup : Create a new suppression group
// POST /asm/groups
func Createanewsuppressiongroup() {
apiKey := os.Getenv("YOUR_SENDGRID_APIKEY")
apiKey := os.Getenv("SENDGRID_API_KEY")
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/asm/groups", host)
request.Method = "POST"
Expand All @@ -32,7 +32,7 @@ func Createanewsuppressiongroup() {
// Retrieveinformationaboutmultiplesuppressiongroups : Retrieve information about multiple suppression groups
// GET /asm/groups
func Retrieveinformationaboutmultiplesuppressiongroups() {
apiKey := os.Getenv("YOUR_SENDGRID_APIKEY")
apiKey := os.Getenv("SENDGRID_API_KEY")
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/asm/groups", host)
request.Method = "GET"
Expand All @@ -52,7 +52,7 @@ func Retrieveinformationaboutmultiplesuppressiongroups() {
// Updateasuppressiongroup : Update a suppression group.
// PATCH /asm/groups/{group_id}
func Updateasuppressiongroup() {
apiKey := os.Getenv("YOUR_SENDGRID_APIKEY")
apiKey := os.Getenv("SENDGRID_API_KEY")
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/asm/groups/{group_id}", host)
request.Method = "PATCH"
Expand All @@ -74,7 +74,7 @@ func Updateasuppressiongroup() {
// Getinformationonasinglesuppressiongroup : Get information on a single suppression group.
// GET /asm/groups/{group_id}
func Getinformationonasinglesuppressiongroup() {
apiKey := os.Getenv("YOUR_SENDGRID_APIKEY")
apiKey := os.Getenv("SENDGRID_API_KEY")
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/asm/groups/{group_id}", host)
request.Method = "GET"
Expand All @@ -91,7 +91,7 @@ func Getinformationonasinglesuppressiongroup() {
// Deleteasuppressiongroup : Delete a suppression group.
// DELETE /asm/groups/{group_id}
func Deleteasuppressiongroup() {
apiKey := os.Getenv("YOUR_SENDGRID_APIKEY")
apiKey := os.Getenv("SENDGRID_API_KEY")
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/asm/groups/{group_id}", host)
request.Method = "DELETE"
Expand All @@ -108,7 +108,7 @@ func Deleteasuppressiongroup() {
// Addsuppressionstoasuppressiongroup : Add suppressions to a suppression group
// POST /asm/groups/{group_id}/suppressions
func Addsuppressionstoasuppressiongroup() {
apiKey := os.Getenv("YOUR_SENDGRID_APIKEY")
apiKey := os.Getenv("SENDGRID_API_KEY")
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/asm/groups/{group_id}/suppressions", host)
request.Method = "POST"
Expand All @@ -131,7 +131,7 @@ func Addsuppressionstoasuppressiongroup() {
// Retrieveallsuppressionsforasuppressiongroup : Retrieve all suppressions for a suppression group
// GET /asm/groups/{group_id}/suppressions
func Retrieveallsuppressionsforasuppressiongroup() {
apiKey := os.Getenv("YOUR_SENDGRID_APIKEY")
apiKey := os.Getenv("SENDGRID_API_KEY")
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/asm/groups/{group_id}/suppressions", host)
request.Method = "GET"
Expand All @@ -148,7 +148,7 @@ func Retrieveallsuppressionsforasuppressiongroup() {
// Searchforsuppressionswithinagroup : Search for suppressions within a group
// POST /asm/groups/{group_id}/suppressions/search
func Searchforsuppressionswithinagroup() {
apiKey := os.Getenv("YOUR_SENDGRID_APIKEY")
apiKey := os.Getenv("SENDGRID_API_KEY")
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/asm/groups/{group_id}/suppressions/search", host)
request.Method = "POST"
Expand All @@ -172,7 +172,7 @@ func Searchforsuppressionswithinagroup() {
// Deleteasuppressionfromasuppressiongroup : Delete a suppression from a suppression group
// DELETE /asm/groups/{group_id}/suppressions/{email}
func Deleteasuppressionfromasuppressiongroup() {
apiKey := os.Getenv("YOUR_SENDGRID_APIKEY")
apiKey := os.Getenv("SENDGRID_API_KEY")
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/asm/groups/{group_id}/suppressions/{email}", host)
request.Method = "DELETE"
Expand All @@ -189,7 +189,7 @@ func Deleteasuppressionfromasuppressiongroup() {
// Retrieveallsuppressions : Retrieve all suppressions
// GET /asm/suppressions
func Retrieveallsuppressions() {
apiKey := os.Getenv("YOUR_SENDGRID_APIKEY")
apiKey := os.Getenv("SENDGRID_API_KEY")
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/asm/suppressions", host)
request.Method = "GET"
Expand All @@ -206,7 +206,7 @@ func Retrieveallsuppressions() {
// Addrecipientaddressestotheglobalsuppressiongroup : Add recipient addresses to the global suppression group.
// POST /asm/suppressions/global
func Addrecipientaddressestotheglobalsuppressiongroup() {
apiKey := os.Getenv("YOUR_SENDGRID_APIKEY")
apiKey := os.Getenv("SENDGRID_API_KEY")
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/asm/suppressions/global", host)
request.Method = "POST"
Expand All @@ -229,7 +229,7 @@ func Addrecipientaddressestotheglobalsuppressiongroup() {
// RetrieveaGlobalSuppression : Retrieve a Global Suppression
// GET /asm/suppressions/global/{email}
func RetrieveaGlobalSuppression() {
apiKey := os.Getenv("YOUR_SENDGRID_APIKEY")
apiKey := os.Getenv("SENDGRID_API_KEY")
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/asm/suppressions/global/{email}", host)
request.Method = "GET"
Expand All @@ -246,7 +246,7 @@ func RetrieveaGlobalSuppression() {
// DeleteaGlobalSuppression : Delete a Global Suppression
// DELETE /asm/suppressions/global/{email}
func DeleteaGlobalSuppression() {
apiKey := os.Getenv("YOUR_SENDGRID_APIKEY")
apiKey := os.Getenv("SENDGRID_API_KEY")
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/asm/suppressions/global/{email}", host)
request.Method = "DELETE"
Expand All @@ -263,7 +263,7 @@ func DeleteaGlobalSuppression() {
// Retrieveallsuppressiongroupsforanemailaddress : Retrieve all suppression groups for an email address
// GET /asm/suppressions/{email}
func Retrieveallsuppressiongroupsforanemailaddress() {
apiKey := os.Getenv("YOUR_SENDGRID_APIKEY")
apiKey := os.Getenv("SENDGRID_API_KEY")
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/asm/suppressions/{email}", host)
request.Method = "GET"
Expand Down
3 changes: 1 addition & 2 deletions examples/browsers/browsers.go
Expand Up @@ -2,15 +2,14 @@ package main

import (
"fmt"
"github.com/sendgrid/sendgrid-go"
"log"
"os"
)

// Retrieveemailstatisticsbybrowser : Retrieve email statistics by browser.
// GET /browsers/stats
func Retrieveemailstatisticsbybrowser() {
apiKey := os.Getenv("YOUR_SENDGRID_APIKEY")
apiKey := os.Getenv("SENDGRID_API_KEY")
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/browsers/stats", host)
request.Method = "GET"
Expand Down

0 comments on commit 7dcfc0a

Please sign in to comment.