From 7a7f0a324b0b1e12f4f684162633613553edaa18 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Tue, 8 May 2018 15:59:27 -0400 Subject: [PATCH] Don't use a session for getting membershipworks data --- doorUpdater.py | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/doorUpdater.py b/doorUpdater.py index d7f3165..9de0171 100644 --- a/doorUpdater.py +++ b/doorUpdater.py @@ -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"""