dadata/client/credential.go
Alexander Zhuravlev e058bfd6aa V2.
2019-04-09 17:08:32 +03:00

36 lines
642 B
Go

package client
import (
"os"
)
type (
// Credentials provides constant credential values.
Credentials struct {
ApiKeyValue string
SecretKeyValue string
}
// EnvironmentCredentials provides credentials from environment variables.
EnvironmentCredentials struct {
ApiKeyName string
SecretKeyName string
}
)
func (c *Credentials) ApiKey() string {
return c.ApiKeyValue
}
func (c *Credentials) SecretKey() string {
return c.SecretKeyValue
}
func (c *EnvironmentCredentials) ApiKey() string {
return os.Getenv(c.ApiKeyName)
}
func (c *EnvironmentCredentials) SecretKey() string {
return os.Getenv(c.SecretKeyName)
}