Skip to content

Commit

Permalink
Clean up the BambooHR module's API credentials loading
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Cummer committed Jul 31, 2018
1 parent 4e90570 commit 9059b73
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions bamboohr/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

Expand Down Expand Up @@ -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"),
)
}

0 comments on commit 9059b73

Please sign in to comment.