1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00
wtf/modules/bamboohr/calendar.go
2019-02-18 11:16:34 -05:00

38 lines
751 B
Go

package bamboohr
type Calendar struct {
Items []Item `xml:"item"`
}
/* -------------------- Public Functions -------------------- */
func (calendar *Calendar) Holidays() []Item {
return calendar.filteredItems("holiday")
}
func (calendar *Calendar) ItemsByType(itemType string) []Item {
if itemType == "timeOff" {
return calendar.TimeOffs()
}
return calendar.Holidays()
}
func (calendar *Calendar) TimeOffs() []Item {
return calendar.filteredItems("timeOff")
}
/* -------------------- Private Functions -------------------- */
func (calendar *Calendar) filteredItems(itemType string) []Item {
items := []Item{}
for _, item := range calendar.Items {
if item.Type == itemType {
items = append(items, item)
}
}
return items
}