github.com/wtfutil/wtf@v0.43.0/modules/bamboohr/calendar.go (about)

     1  package bamboohr
     2  
     3  type Calendar struct {
     4  	Items []Item `xml:"item"`
     5  }
     6  
     7  /* -------------------- Public Functions -------------------- */
     8  
     9  func (calendar *Calendar) Holidays() []Item {
    10  	return calendar.filteredItems("holiday")
    11  }
    12  
    13  func (calendar *Calendar) ItemsByType(itemType string) []Item {
    14  	if itemType == "timeOff" {
    15  		return calendar.TimeOffs()
    16  	}
    17  
    18  	return calendar.Holidays()
    19  }
    20  
    21  func (calendar *Calendar) TimeOffs() []Item {
    22  	return calendar.filteredItems("timeOff")
    23  }
    24  
    25  /* -------------------- Private Functions -------------------- */
    26  
    27  func (calendar *Calendar) filteredItems(itemType string) []Item {
    28  	items := []Item{}
    29  
    30  	for _, item := range calendar.Items {
    31  		if item.Type == itemType {
    32  			items = append(items, item)
    33  		}
    34  	}
    35  
    36  	return items
    37  }