You've already forked email-api-client
We Had To Use Dark Magic To Make This Work
This commit is contained in:
36
client/configuration.go
Executable file
36
client/configuration.go
Executable file
@@ -0,0 +1,36 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"git.siteworxpro.com/golang/packages/utilities/Env"
|
||||
"log"
|
||||
)
|
||||
|
||||
const (
|
||||
apiEndpoint Env.EnvironmentVariable = "API_ENDPOINT"
|
||||
clientId Env.EnvironmentVariable = "CLIENT_ID"
|
||||
clientSecret Env.EnvironmentVariable = "CLIENT_SECRET"
|
||||
)
|
||||
|
||||
type Configuration struct {
|
||||
Endpoint string
|
||||
ClientId string
|
||||
ClientSecret string
|
||||
}
|
||||
|
||||
func ConfigFromEnv() *Configuration {
|
||||
config := Configuration{
|
||||
Endpoint: apiEndpoint.GetEnvString("https://email.siteworxpro.com"),
|
||||
ClientId: clientId.GetEnvString(""),
|
||||
ClientSecret: clientSecret.GetEnvString(""),
|
||||
}
|
||||
|
||||
if config.ClientId == "" {
|
||||
log.Fatal("Client ID not provided in ENV. use CLIENT_ID")
|
||||
}
|
||||
|
||||
if config.ClientSecret == "" {
|
||||
log.Fatal("Client Secret not provided in ENV. use ClientSecret")
|
||||
}
|
||||
|
||||
return &config
|
||||
}
|
||||
Reference in New Issue
Block a user