How to get third balance?
Closed this issue · 3 comments
lreiner commented
I have 3 Balances in JSON Output.
0: Real
1: Old Practice
2: Current Practice
This Piece of Code in your API always select the first Practice Account (1). How can I get my (2) Practice Account?
self.real_balance = jsondata["result"]["balances"][0]["amount"]/1000000
self.practice_balance = jsondata["result"]["balances"][1]["amount"]/1000000
self.currency = jsondata["result"]["currency"]
self.account_to_id = {"real":jsondata["result"]["balances"][0]["id"],"practice":jsondata["result"]["balances"][1]["id"]}
self.id_to_account = {jsondata["result"]["balances"][0]["id"]:"real",jsondata["result"]["balances"][1]["id"]:"practice"}
self.active_account = ["real" if jsondata["result"]["balance_type"] == 1 else "practice"][0]
self.group_id = jsondata["result"]["balance_type"]
self.balance = jsondata["result"]["balance"]
harwee commented
There is no method directly available, you can always manually override index of list jsondata["result"]["balances"]
in source code
lreiner commented
Ok can you give me a code example please?
harwee commented
if 1 is your old practice and 2 is your new one then this snippet should probably work
self.real_balance = jsondata["result"]["balances"][0]["amount"]/1000000
self.practice_balance = jsondata["result"]["balances"][2]["amount"]/1000000
self.currency = jsondata["result"]["currency"]
self.account_to_id = {"real":jsondata["result"]["balances"][0]["id"],"practice":jsondata["result"]["balances"][2]["id"]}
self.id_to_account = {jsondata["result"]["balances"][0]["id"]:"real",jsondata["result"]["balances"][2]["id"]:"practice"}
self.active_account = ["real" if jsondata["result"]["balance_type"] == 1 else "practice"][0]
self.group_id = jsondata["result"]["balance_type"]
self.balance = jsondata["result"]["balance"]