示例#1
0
// Accounts returns all accounts registered with the given AQBanking instance
func (ab *AQBanking) Accounts() (*AccountCollection, error) {
	abAccountList := C.AB_Banking_GetAccounts(ab.ptr)
	if abAccountList == nil {
		// no accounts available
		return &AccountCollection{}, nil
	}

	list := &AccountCollection{}
	list.Accounts = make([]Account, C.AB_Account_List2_GetSize(abAccountList))

	abIterator := C.AB_Account_List2_First(abAccountList)
	if abIterator == nil {
		return nil, errors.New("Unable to get account iterator.")
	}

	var abAccount *C.AB_ACCOUNT
	abAccount = C.AB_Account_List2Iterator_Data(abIterator)

	for i := 0; abAccount != nil; i++ {
		list.Accounts[i] = newAccount(abAccount)

		abAccount = C.AB_Account_List2Iterator_Next(abIterator)
	}

	C.AB_Account_List2Iterator_free(abIterator)
	C.AB_Account_free(abAccount)
	C.AB_Account_List2_free(abAccountList)

	return list, nil
}
示例#2
0
// Free frees the underlying aqbanking account pointer
func (a *Account) Free() {
	C.AB_Account_free(a.ptr)
}