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
|
package bamboohr
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
//"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Fetch() []Item {
|
// TODO Move this into the client. Why is it separate?
|
||||||
client := NewClient()
|
//func Fetch() []Item {
|
||||||
result := client.Away("timeOff", today(), today())
|
//client := NewClient()
|
||||||
|
//result := client.Away("timeOff", today(), today())
|
||||||
|
|
||||||
return result
|
//return result
|
||||||
}
|
//}
|
||||||
|
|
||||||
func today() string {
|
//func today() string {
|
||||||
localNow := time.Now().Local()
|
//localNow := time.Now().Local()
|
||||||
return localNow.Format("2006-01-02")
|
//return localNow.Format("2006-01-02")
|
||||||
}
|
//}
|
||||||
|
@ -14,9 +14,9 @@ type Client struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewClient creates and returns a new BambooHR client
|
// NewClient creates and returns a new BambooHR client
|
||||||
func NewClient() *Client {
|
func NewClient(url string) *Client {
|
||||||
client := Client{
|
client := Client{
|
||||||
apiBase: "https://api.bamboohr.com/api/gateway.php",
|
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"),
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ func NewWidget(config *config.Config) *Widget {
|
|||||||
RefreshedAt: time.Now(),
|
RefreshedAt: time.Now(),
|
||||||
RefreshInt: refreshInterval,
|
RefreshInt: refreshInterval,
|
||||||
},
|
},
|
||||||
|
Config: config,
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.addView()
|
widget.addView()
|
||||||
@ -40,7 +41,10 @@ func NewWidget(config *config.Config) *Widget {
|
|||||||
/* -------------------- Exported Functions -------------------- */
|
/* -------------------- Exported Functions -------------------- */
|
||||||
|
|
||||||
func (widget *Widget) Refresh() {
|
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.View.SetTitle(fmt.Sprintf(" 👽 Away (%d) ", len(items)))
|
||||||
widget.RefreshedAt = time.Now()
|
widget.RefreshedAt = time.Now()
|
||||||
|
@ -2,5 +2,6 @@ wtf:
|
|||||||
refreshInterval: 1
|
refreshInterval: 1
|
||||||
bamboohr:
|
bamboohr:
|
||||||
refreshInterval: 900
|
refreshInterval: 900
|
||||||
|
url: "https://api.bamboohr.com/api/gateway.php"
|
||||||
status:
|
status:
|
||||||
refreshInterval: 1
|
refreshInterval: 1
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func CenterText(str string, width int) string {
|
func CenterText(str string, width int) string {
|
||||||
@ -29,3 +30,8 @@ func ExecuteCommand(cmd *exec.Cmd) string {
|
|||||||
|
|
||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Today() string {
|
||||||
|
localNow := time.Now().Local()
|
||||||
|
return localNow.Format("2006-01-02")
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user