Less noise, more data. Get the biggest data report on software developer careers in South Africa.

Dev Report mobile

Programmable Banking Community: Vincent’s Java and Python Wrappers

30 September 2020 , by Ben Blaine

Every week, we run a meetup for the Investec Programmable Banking community. Developers demo cool projects they've been working on and everyone has the chance to ask questions. If you've been wondering where programmable banking is at, here's your sneak peek!

In this demo, Vincent Chegwidden shares how he built Java and Python wrappers for the OpenAPI. They’ve been uploaded to the community projects tab on the community GitLab page, and anyone is welcome to contribute to the code.

You can find the Java repo here, and the Python repo here.

Transcript of the demo

Ben [33:48]

We're going to move on to Vincent, who's going to take us through the Java and Python wrappers that he built this week. He also did a screencast really nicely today.

Vincent [34:21]

Howzit everyone. My name is Vincent. As Ben said, I made a screencast in preparation for load shedding and so let’s see what happens. So, top tip for next time, when there's load shedding, make some screencasts.

Vincent [34:37]

Cool. I went and created two wrappers for the OpenAPI. They're by no means perfect, but it's always nice to have a starting point. If you want to go and implement something, it's easier to go and look at something that someone else has done rather than starting from scratch. Both of these are available on GitLab. They're open to everyone – you can view it, and you can make major requests into them if you want to or copy the code. It doesn't matter. Let’s chat about the Java one first.

Vincent [35:23]

So, inside the project, there are two modules. There's an okay HTTP client and a spring client. The first one uses the HTTP library to make requests, and the second one uses the spring's rest template. It just gives people some options. The only caveat is that the spring one doesn't work – the auth portion works, but then any other requests are still giving me HTTP 500.

Vincent [35:57]

I'm going to open the code quickly. So, you guys can see there's a bunch of modules, there's the domain – here’s all of the objects that we want to deserialise the JSON response to inside the model here. There's the access token balance and all of that. There's also a shared interface so both clients only expose three methods, get accounts, get transactions, and get balance.

Vincent [36:31]

And then if I go into one of the examples here, you'll see all you need to do to create an instance of this client is give it your client ID and secret from the Investec platform, and then you can go and say give me my accounts. Once I've got the accounts, give me the balance for one of them or give me all the transactions.

Vincent [37:00]

Inside this thing, it handles the AUTH for you. So, if I go down here, you'll see it will go and check if you've got an access token. If you don't have an access token, or the one you've got has expired, it will get a new one. Otherwise, it will use the existing one. I'm just going to fire this debugger, and you guys can see, it's set a breakpoint here, so it's going to go up, it takes a little while to get the initial token, and that's because the function in AWS is spinning up, but after a few seconds, you'll see get some results back.

Vincent [37:43]

So, here I've got two accounts, you can see – there's my name, the two accounts that I have, the response from the balance says the currency is Rand and 13 transactions are coming back. Here's one of them – this is for my Azure subscription, and the other one is from the N1 Kranskop Toll Plaza.

Vincent [38:13]

The Python one is the same thing, except for the access token – I haven't figured out how to handle that inside the client yet. The other caveats are that if I go into this, it just returns a dictionary at this point. It takes the JSON response and converts it to a dictionary and returns that. You can go query what comes back, but you must do it in this fashion.

Vincent [38:45]

Starting it up, the same thing – you create an instance, and you can go and call those endpoints. You'll see, when I go and run this thing, I'm going to get the same results back.

Vincent [38:59]

There we go, two accounts, same account details and there are the two transactions. The other thing I want to talk about is the next steps for both.

Vincent [39:17]

So, for the Java client, we need to add some error handling. It's pretty bare-bones at this point. I also need to add some unit tests – the only unit tests I have at this point are making sure that it can deserialise the JSON response into an object. And then I want to get the spring client working. For the Python one, I would go and create some models so that the JSON can be serialised into classes and you don't have to do all this stuff with the dictionaries. Also, I want to move this access token logic inside the client, so you don't have to worry about that. And then some error handling and unit tests.

Vincent [40:06]

That's it, from my side.

Ben [40:11]

Awesome. Thanks so much. I've added those on GitLab already under community projects. I think we're getting close to an hour now and I don't know if anyone has questions, around that stuff.

Imraan [40:23]

Yeah, I have a question. Vincent, would you mind if we contributed to that because I can help you with the Python one.

Vincent [40:35]

Of course. You can either make pull or virtual requests into that repository, or you can copy the code and make a new one. It doesn't matter to me.

Imraan [40:47]

I don't think we should make a new one. Let's contribute to your one because then everybody thinks it's the same one that everyone then uses. Cool.

Ben [40:56]

Sweet, that will be awesome.

Programmable-Banking-Community--Vincent-s-Java-and-Python-Wrappers_Inner-Article-Image@2x

Vincent works as a technical lead at Entelect, and he's currently placed at Vitality as a solution architect. In his free time, he enjoys gaming and playing guitar. He's also a bit of a fitness guru and runs, cycles and surfs. He's keen on learning, and when he's not coding for work, he's levelling up his Kotlin and Kubernetes skills.


Get involved in the Programmable Banking Community

If you’re not part of our community yet, sign up and join the fun. You can also see more of the demos from our meetups on our YouTube channel here.

For those of you in the community, check out our GitLab to see more of the awesome projects members of our community are working on. You can also sign up for challenges, where you can help find solutions for real life problems.

For more information, get in touch!

Recent posts

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.