umsatz / go-aqbanking

golang wrapper for the aqbanking C library
https://nicolai86.eu
GNU General Public License v2.0
12 stars 4 forks source link

Provide fast start sample #1

Closed joscha closed 10 years ago

joscha commented 10 years ago

Hi there,

would it be possible for you to provide a fast start sample on how to use your wrapper? For me it does not seem to be able to start it without having one or the other problem - for example where to put the required libraries, etc.

nicolai86 commented 10 years ago

Right now there are two examples available in the examples folder, including adding a user, requesting accounts and transactions.

for them to work you need to have aqbanking installed. I'm using it with 5.0.25 on osx, and haven't used it with more recent versions.

please not that the wrapper only supports pintan authentication at the moment because that's my sole use case. PR s are welcome, however.

nicolai86 commented 10 years ago

so if you are on osx "brew install aqbanking" should make it work, as for unix apt-get install aqbanking. Please note that compilation on *nix has not been tested, yet. I'll be working on that during my next slacktime

joscha commented 10 years ago

@nicolai86 in the test folder it says

go run examples/add_pintan_user.go
examples/add_pintan_user.go:7:2: cannot find package "github.com/umsatz/go-aqbanking" in any of:
    /usr/local/Cellar/go/1.3/libexec/src/pkg/github.com/umsatz/go-aqbanking (from $GOROOT)
    ($GOPATH not set)

and in the base directory I get

go run main.go
# command-line-arguments
ld: library not found for -laqbanking

AqBanking 5.0.25 is installed via homebrew. Go is version 1.3 Sorry, I am new to Go, if I am doing something obviously stupid, feel free to point me to the right place...

nicolai86 commented 10 years ago

Looks like your go env is not setup properly. i'll write a more detailed list once i'm home, but it looks like a simple env issue.

nicolai86 commented 10 years ago

so, here it goes.

First, regarding the go env configuration you might want to spent 3 minutes watching https://gophercasts.io/lessons/1-getting-started-with-go .

The video just covers setting up GOPATH etc properly.

Secondly, the short getting started guide:

$ go version
go version go1.3 darwin/amd64
$ brew install aqbanking
$ brew unlink aqbanking && brew link aqbanking
$ go install github.com/umsatz/go-aqbanking
$ cd $GOPATH/src/github.com/umsatz/go-aqbanking
$ go test
PASS
ok      github.com/umsatz/go-aqbanking  0.190s

The tests are green, the following parts differ depending on your aqbanking settings

$ cd examples
$ go run add_pintan_user.go
using aqbanking 5.0.25
3:2014/07/07 20-16-19:aqhbci(78129):dialog.c:  281: Error sending message for dialog (-43)
3:2014/07/07 20-16-19:aqhbci(78129):provider.c: 1248: Job has errors

The error is expected. You need to properly adjust line 27 (your hbci pintan informations). Also note: you need to update example_pins.json for this to work.

$ go run list_users_accounts.go
using aqbanking 5.0.25
found 2 users.
found 2 accounts.

This lists your local ($HOME/.aqbanking) aqbanking settings. Might be different, depending on your system.

nicolai86 commented 10 years ago

Regarding the programming interface:

  1. get a reference to aqbanking: aq, err := aqb.DefaultAQBanking()
  2. make sure it gets free'd properly defer aq.Free()
  3. prepare aqbanking for headless usage (in my use case, the gwenhyfar pin prompt is not desireable.) You need register account pins for that: aq.RegisterPin(&pin) See Pin interface for more details. (ATM : BankCode, UserId, Pin).
  4. either register new users or list existing users, and use an existing user to fetch accounts/ transactions.
user := aqb.User{Id: 0, UserId: "userid", CustomerId: "userid", BankCode: "bankcode", Name: "name of bank", ServerUri: "https://your hbci server url", HbciVersion: 300}
if err := aq.AddPinTanUser(&user); err != nil {
  fmt.Printf("unable to add user. %v\n", err)
} else {
  user.FetchAccounts(aq)
}

or

userCollection, err := aq.Users()
defer userCollection.Free()

accountCollection, err := aq.Accounts()
defer accountCollection.Free()
nicolai86 commented 10 years ago

see https://github.com/umsatz/transactions for a basic api usage example. Note that transactions rely on an older version of go-aqbanking ATM.

nicolai86 commented 10 years ago

If you have further questions I'd be more than happy to help!

nicolai86 commented 10 years ago

Issue seems inactive. If further questions arise we can reopen it.

joscha commented 10 years ago

Yes, thank you! Am 17.08.2014 13:12 schrieb "Raphael Randschau" notifications@github.com:

Closed #1 https://github.com/umsatz/go-aqbanking/issues/1.

— Reply to this email directly or view it on GitHub https://github.com/umsatz/go-aqbanking/issues/1#event-153677788.