예제 #1
0
파일: main.go 프로젝트: umsatz/go-aqbanking
func main() {
	aq, err := aqb.DefaultAQBanking()
	if err != nil {
		log.Fatal("unable to init aqbanking: %v", err)
	}
	defer aq.Free()

	fmt.Printf("using aqbanking %d.%d.%d\n",
		aq.Version.Major,
		aq.Version.Minor,
		aq.Version.Patchlevel,
	)

	for _, pin := range loadPins("pins.json") {
		aq.RegisterPin(pin)
	}

	var user aqb.User
	if err := aq.AddPinTanUser(&user); err != nil {
		fmt.Printf("unable to add user. %v\n", err)
	} else {
		user.FetchAccounts(aq)
	}

	accountCollection, err := aq.Accounts()
	if err != nil {
		log.Fatal("unable to list accounts: %v", err)
	}
	fmt.Printf("found %d accounts.\n", len(accountCollection.Accounts))
}
예제 #2
0
파일: main.go 프로젝트: umsatz/go-aqbanking
func main() {
	aq, err := aqb.DefaultAQBanking()
	// alternativly, customize the aqbanking path:
	// aq, err := aq.NewAQBanking("custom", "./tmp")
	if err != nil {
		log.Fatal("unable to init aqbanking: %v", err)
	}
	defer aq.Free()

	fmt.Printf("using aqbanking %d.%d.%d\n",
		aq.Version.Major,
		aq.Version.Minor,
		aq.Version.Patchlevel,
	)

	for _, pin := range loadPins("pins.json") {
		aq.RegisterPin(pin)
	}

	userCollection, err := aq.Users()
	if err != nil {
		log.Fatal("unable to list users: %v", err)
	}
	defer userCollection.Free()
	fmt.Printf("found %d users.\n", len(userCollection.Users))

	for _, user := range userCollection.Users {
		fmt.Printf("User %d\n", user.ID)
	}

	accountCollection, err := aq.Accounts()
	if err != nil {
		log.Fatal("unable to list accounts: %v", err)
	}

	fmt.Printf("found %d accounts.\n", len(accountCollection.Accounts))

	for _, account := range accountCollection.Accounts {
		fmt.Printf("Account %v\n", account.Name)

		transactions, _ := aq.Transactions(&account, nil, nil)
		fmt.Printf("%d transactions\n", len(transactions))
	}
}