Beispiel #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
}
Beispiel #2
0
// HandleRequest handles the user request
func (g GetKidFromToken) HandleRequest(vars map[string]string) (interface{}, error) {
	token := vars["token"]
	var response getKidFromTokenResponse
	var err error
	response.Kid, err = dbapi.GetKidFromToken(token)
	if err != nil {
		return nil, err
	}

	response.Transactions, err = dbapi.GetTransactions(response.Kid.ID, 0, 10)

	return response, err
}
Beispiel #3
0
// HandleRequest handles the get kid summary request
func (g GetKidSummary) HandleRequest(vars map[string]string) (interface{}, error) {
	var loginInfo LoginTokenInfo
	var err error
	if loginInfo, err = ParseLoginToken(g.Token); err != nil {
		return nil, err
	}
	var response getKidSummaryResponse
	response.Kid, err = dbapi.GetKid(loginInfo.FamilyID, g.KidID)
	if err != nil {
		return nil, err
	}

	response.Transactions, err = dbapi.GetTransactions(g.KidID, 0, 10)

	return response, err
}