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:
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()
|
||||
|
@ -2,5 +2,6 @@ wtf:
|
||||
refreshInterval: 1
|
||||
bamboohr:
|
||||
refreshInterval: 900
|
||||
url: "https://api.bamboohr.com/api/gateway.php"
|
||||
status:
|
||||
refreshInterval: 1
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os/exec"
|
||||
"time"
|
||||
)
|
||||
|
||||
func CenterText(str string, width int) string {
|
||||
@ -29,3 +30,8 @@ func ExecuteCommand(cmd *exec.Cmd) string {
|
||||
|
||||
return str
|
||||
}
|
||||
|
||||
func Today() string {
|
||||
localNow := time.Now().Local()
|
||||
return localNow.Format("2006-01-02")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user