Don't use a session for getting membershipworks data

This commit is contained in:
Adam Goldsmith 2018-05-08 15:59:27 -04:00
parent 437503a5b1
commit 7a7f0a324b

View File

@ -31,32 +31,31 @@ def getMembershipworksData():
BASE_URL = "https://api.membershipworks.com/v1/"
# login
sess = requests.Session()
r = sess.post(BASE_URL + 'usr',
data={"_st": "all",
"eml": MEMBERSHIPWORKS_USERNAME,
"org": "10000",
"pwd": MEMBERSHIPWORKS_PASSWORD})
r = requests.post(BASE_URL + 'usr',
data={"_st": "all",
"eml": MEMBERSHIPWORKS_USERNAME,
"org": "10000",
"pwd": MEMBERSHIPWORKS_PASSWORD})
SFtoken = r.json()['SF']
# get list of member/staff IDs
r = sess.get(BASE_URL + "ylp",
params={"SF": SFtoken,
"lbl": "5ae37979f033bfe8534f8799,5771675edcdf126302a2f6b9", # members and staff
"org": "15475", # unknown
"var": "_id,nam,ctc"})
r = requests.get(BASE_URL + "ylp",
params={"SF": SFtoken,
"lbl": "5ae37979f033bfe8534f8799,5771675edcdf126302a2f6b9", # members and staff
"org": "15475", # unknown
"var": "_id,nam,ctc"})
ids = [user['_id'] for user in r.json()['usr']]
# get members CSV
# TODO: maybe can just use previous get instead? would return JSON
r = sess.post(BASE_URL + "csv",
params={"SF": SFtoken},
data={"_rt": "946702800", # unknown
"mux": "", # unknown
"tid": ",".join(ids), # ids of members to get
"var": "lvl,xws,xms,xsc,xrs,xfd,xac,phn,eml,lbl,nam"}) # which columns to get
return r.text
r = requests.post(BASE_URL + "csv",
params={"SF": SFtoken},
data={"_rt": "946702800", # unknown
"mux": "", # unknown
"tid": ",".join(ids), # ids of members to get
"var": "lvl,xws,xms,xsc,xrs,xfd,xac,phn,eml,lbl,nam"}) # which columns to get
return r.text
def makeMember(member, doorAuth):
"""Create an output CSV row for the member"""