Exemple #1
0
// HandleRequest handles the get transactions request
func (g GetTransactions) 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
	}
	log.Println("Offset, Count: ", g.Offset, g.Count)
	var response getTransactionsResponse
	var trans []dbapi.Transaction
	if trans, err = dbapi.GetTransactions(g.KidID, g.Offset, g.Count+1); err != nil {
		return nil, err
	}

	log.Println("Transactions: ", len(trans))
	if len(trans) == g.Count+1 {
		response.HasNextPage = true
		response.Transactions = trans[0:g.Count]
	} else {
		response.HasNextPage = false
		response.Transactions = trans
	}
	if response.Transactions == nil {
		log.Println("Transactions nil")
	} else {
		log.Println("Transactions length: ", len(response.Transactions))
	}

	return response, nil
}
Exemple #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)
}
Exemple #3
0
// HandleRequest handles the addmoney request
func (a AddMoney) HandleRequest(vars map[string]string) (interface{}, error) {
	var loginInfo LoginTokenInfo
	var err error
	if loginInfo, err = ParseLoginToken(a.Token); err != nil {
		return nil, err
	}

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

	// Get buckets
	return dbapi.AddMoney(loginInfo.ParentID, a.KidID, a.Amount, a.Note, a.Allocations, nil)
}