-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHoldingApp.py
executable file
·55 lines (45 loc) · 2.27 KB
/
HoldingApp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#Copyright (c) 2015 Yodlee, Inc. All Rights Reserved.
# This software is the confidential and proprietary information of Yodlee, Inc.
# Use is subject to license terms.
import loginapp #importing loginapp, to get a coBrand and User Session response and used
import http1 #importing http1, its the key for all the apps, and to post and get the json response
import json #library package for the json response access
import yaml #converts unicode to byte code
import requests #requests, for requesting the response from json
#<summary>
#The HoldingApp class provides holdings for a member account.
#Holdings are Investment accounts which a member has aggregated using Aggregation Apps.
#Steps to Use this App:
#i) doCoBrandLogin(coBrandUserName, coBrandPassword)
#ii) doMemberLogin(userName, userPassword)
#Browse all Accounts for member profile:
#getHoldings()
class HoldingApp:
fqcn = "HoldingApp"
global userSession
global cobSession
@staticmethod
def getHoldings():
global userSession
global cobSession
uSession = loginapp.userSession
cSession = loginapp.cobSession
hdr = {'Authorization':'{userSession='+uSession+',cobSession='+cSession+'}'}
mn = "getHoldings()"
print(HoldingApp.fqcn + " :: " + mn)
holdingURL = loginapp.LoginApp.localURLVer1 + "v1/holdings/"
jsonResponse = http1.HTTP.doGet(holdingURL, hdr)
parsed_json = json.loads(jsonResponse)
node = parsed_json.get("holding",{})
print '--------------------------------------------------'
print "holdingType - price.amount - price.currency - quantity"
print '--------------------------------------------------'
for i in node:
#print i
if ('price' in i and 'quantity' in i):
print i['holdingType']," - ",i['price']['amount']," - ",i['price']['currency']," - ",i['quantity']
elif (('price' in i) and not ('quantity' in i)):
print i['holdingType']," - ",i['price']['amount']," - ",i['price']['currency']," - "
elif (not ('price' in i) and ('quantity' in i)):
print i['holdingType']," - "," - "," - "," - "," - ",i['quantity']
print '--------------------------------------------------'