From 9059b73c5194f46ad66bd11d2e806bf90e606d17 Mon Sep 17 00:00:00 2001 From: Chris Cummer Date: Tue, 31 Jul 2018 14:34:18 -0700 Subject: [PATCH] Clean up the BambooHR module's API credentials loading --- bamboohr/client.go | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/bamboohr/client.go b/bamboohr/client.go index fd8664d0b..532342bdf 100644 --- a/bamboohr/client.go +++ b/bamboohr/client.go @@ -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"), + ) +}