Пример #1
0
// HandleRequest handles the get family summary request
func (g GetFamilySummary) HandleRequest(vars map[string]string) (interface{}, error) {
	var loginInfo LoginTokenInfo
	var err error
	var family dbapi.Family
	if loginInfo, err = ParseLoginToken(g.Token); err != nil {
		return family, err
	}

	family, err = dbapi.GetFamily(loginInfo.FamilyID)
	if err != nil {
		return family, err
	}

	family.Kids, err = dbapi.GetKids(loginInfo.FamilyID)
	if err != nil {
		return family, err
	}

	for idx := range family.Kids {
		family.Kids[idx].Buckets, err = dbapi.GetBuckets(family.Kids[idx].ID)
		if err != nil {
			return family, err
		}
	}

	return family, err
}
Пример #2
0
// HandleRequest handles the getbuckets request
func (g GetBuckets) HandleRequest(vars map[string]string) (interface{}, error) {
	var loginInfo LoginTokenInfo
	var err error
	if loginInfo, err = ParseLoginToken(g.Token); err != nil {
		return nil, err
	}

	if err = dbapi.CheckFamilyMembership(loginInfo.FamilyID, g.KidID); err != nil {
		return nil, err
	}

	return dbapi.GetBuckets(g.KidID)
}