The following sections will help you to get started quickly.
Use go get
to install the latest version of this library:
$ go get -u github.com/jsattler/comdirect-golang
Creating a new Authenticator from AuthOptions:
// omitting error validation, imports and packages
options := &comdirect.AuthOptions{
Username: os.Getenv("COMDIRECT_USERNAME"),
Password: os.Getenv("COMDIRECT_PASSWORD"),
ClientId: os.Getenv("COMDIRECT_CLIENT_ID"),
ClientSecret: os.Getenv("COMDIRECT_CLIENT_SECRET"),
}
authenticator := options.NewAuthenticator()
Creating a new Authenticator with AuthOptions:
// omitting error validation, imports and packages
options := &comdirect.AuthOptions{
Username: os.Getenv("COMDIRECT_USERNAME"),
Password: os.Getenv("COMDIRECT_PASSWORD"),
ClientId: os.Getenv("COMDIRECT_CLIENT_ID"),
ClientSecret: os.Getenv("COMDIRECT_CLIENT_SECRET"),
}
authenticator := comdirect.NewAuthenticator(options)
Authenticate using the Authenticator
authentication, err := authenticator.Authenticate()
The Authentication
struct holds all relevant information for subsequent requests to the API.
Create a new Client
from AuthOptions
// omitting error validation, imports and packages
options := &comdirect.AuthOptions{
Username: os.Getenv("COMDIRECT_USERNAME"),
Password: os.Getenv("COMDIRECT_PASSWORD"),
ClientId: os.Getenv("COMDIRECT_CLIENT_ID"),
ClientSecret: os.Getenv("COMDIRECT_CLIENT_SECRET"),
}
client := comdirect.NewWithAuthOptions(options)
Create a new Client
from an Authenticator
// omitting error validation, imports and packages
options := &comdirect.AuthOptions{
Username: os.Getenv("COMDIRECT_USERNAME"),
Password: os.Getenv("COMDIRECT_PASSWORD"),
ClientId: os.Getenv("COMDIRECT_CLIENT_ID"),
ClientSecret: os.Getenv("COMDIRECT_CLIENT_SECRET"),
}
authenticator := options.NewAuthenticator()
client := comdirect.NewWithAuthenticator(authenticator)