1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Clean up the BambooHR module's API credentials loading

This commit is contained in:
Chris Cummer 2018-07-31 14:34:18 -07:00
parent 4e905700b9
commit 9059b73c51

View File

@ -4,6 +4,8 @@ import (
"encoding/xml"
"fmt"
"os"
"github.com/senorprogrammer/wtf/wtf"
)
// A Client represents the data required to connect to the BambooHR API
@ -16,11 +18,13 @@ type Client struct {
// NewClient creates and returns a new BambooHR client
func NewClient(url string) *Client {
client := Client{
apiBase: url,
apiKey: os.Getenv("WTF_BAMBOO_HR_TOKEN"),
subdomain: os.Getenv("WTF_BAMBOO_HR_SUBDOMAIN"),
apiBase: url,
//apiKey: os.Getenv("WTF_BAMBOO_HR_TOKEN"),
//subdomain: os.Getenv("WTF_BAMBOO_HR_SUBDOMAIN"),
}
client.loadAPICredentials()
return &client
}
@ -60,3 +64,15 @@ func (client *Client) away(startDate, endDate string) (cal Calendar, err error)
return
}
func (client *Client) loadAPICredentials() {
client.apiKey = wtf.Config.UString(
"wtf.mods.bamboohr.apiKey",
os.Getenv("WTF_BAMBOO_HR_TOKEN"),
)
client.subdomain = wtf.Config.UString(
"wtf.mods.bamboohr.subdomain",
os.Getenv("WTF_BAMBOO_HR_SUBDOMAIN"),
)
}