mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Url added to BambooHR config
This commit is contained in:
committed by
Chris Cummer
parent
b91e1be8df
commit
b58c0ea212
@@ -1,17 +1,18 @@
|
||||
package bamboohr
|
||||
|
||||
import (
|
||||
"time"
|
||||
//"time"
|
||||
)
|
||||
|
||||
func Fetch() []Item {
|
||||
client := NewClient()
|
||||
result := client.Away("timeOff", today(), today())
|
||||
// TODO Move this into the client. Why is it separate?
|
||||
//func Fetch() []Item {
|
||||
//client := NewClient()
|
||||
//result := client.Away("timeOff", today(), today())
|
||||
|
||||
return result
|
||||
}
|
||||
//return result
|
||||
//}
|
||||
|
||||
func today() string {
|
||||
localNow := time.Now().Local()
|
||||
return localNow.Format("2006-01-02")
|
||||
}
|
||||
//func today() string {
|
||||
//localNow := time.Now().Local()
|
||||
//return localNow.Format("2006-01-02")
|
||||
//}
|
||||
|
||||
@@ -14,9 +14,9 @@ type Client struct {
|
||||
}
|
||||
|
||||
// NewClient creates and returns a new BambooHR client
|
||||
func NewClient() *Client {
|
||||
func NewClient(url string) *Client {
|
||||
client := Client{
|
||||
apiBase: "https://api.bamboohr.com/api/gateway.php",
|
||||
apiBase: url,
|
||||
apiKey: os.Getenv("WTF_BAMBOO_HR_TOKEN"),
|
||||
subdomain: os.Getenv("WTF_BAMBOO_HR_SUBDOMAIN"),
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ func NewWidget(config *config.Config) *Widget {
|
||||
RefreshedAt: time.Now(),
|
||||
RefreshInt: refreshInterval,
|
||||
},
|
||||
Config: config,
|
||||
}
|
||||
|
||||
widget.addView()
|
||||
@@ -40,7 +41,10 @@ func NewWidget(config *config.Config) *Widget {
|
||||
/* -------------------- Exported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) Refresh() {
|
||||
items := Fetch()
|
||||
url, _ := widget.Config.String("wtf.bamboohr.url")
|
||||
|
||||
client := NewClient(url)
|
||||
items := client.Away("timeOff", wtf.Today(), wtf.Today())
|
||||
|
||||
widget.View.SetTitle(fmt.Sprintf(" 👽 Away (%d) ", len(items)))
|
||||
widget.RefreshedAt = time.Now()
|
||||
|
||||
Reference in New Issue
Block a user