Exemplo n.º 1
0
// Users implements AB_Banking_GetUsers, returning all users registered
// with aqbanking
func (ab *AQBanking) Users() (*UserCollection, error) {
	abUserList := C.AB_Banking_GetUsers(ab.ptr)
	if abUserList == nil {
		// no users available
		return &UserCollection{}, nil
	}

	collection := &UserCollection{}
	collection.Users = make([]User, C.AB_User_List2_GetSize(abUserList))
	collection.ptr = abUserList

	abIterator := C.AB_User_List2_First(abUserList)
	if abIterator == nil {
		return nil, errors.New("Unable to get user iterator.")
	}

	var abUser *C.AB_USER
	abUser = C.AB_User_List2Iterator_Data(abIterator)

	for i := 0; abUser != nil; i++ {
		collection.Users[i] = newUser(abUser)
		abUser = C.AB_User_List2Iterator_Next(abIterator)
	}

	C.AB_User_List2Iterator_free(abIterator)
	C.AB_User_free(abUser)

	return collection, nil
}
Exemplo n.º 2
0
// Free frees the underlying aqbanking pointer for this user
func (u *User) Free() {
	C.AB_User_free(u.ptr)
}