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" "encoding/xml"
"fmt" "fmt"
"os" "os"
"github.com/senorprogrammer/wtf/wtf"
) )
// A Client represents the data required to connect to the BambooHR API // A Client represents the data required to connect to the BambooHR API
@ -17,10 +19,12 @@ type Client struct {
func NewClient(url string) *Client { func NewClient(url string) *Client {
client := Client{ client := Client{
apiBase: url, apiBase: url,
apiKey: os.Getenv("WTF_BAMBOO_HR_TOKEN"), //apiKey: os.Getenv("WTF_BAMBOO_HR_TOKEN"),
subdomain: os.Getenv("WTF_BAMBOO_HR_SUBDOMAIN"), //subdomain: os.Getenv("WTF_BAMBOO_HR_SUBDOMAIN"),
} }
client.loadAPICredentials()
return &client return &client
} }
@ -60,3 +64,15 @@ func (client *Client) away(startDate, endDate string) (cal Calendar, err error)
return 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"),
)
}