From 207c36a14708a933e5bc9a7095b93f6bab8f85e2 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Tue, 7 Aug 2018 18:33:12 -0400 Subject: [PATCH] doorUpdater: Add support for the "misc access" folder in MembershipWorks --- common.py | 9 +++++++-- doorUpdater.py | 4 +++- membershipViewer.py | 1 + ucsAccounts.py | 3 ++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/common.py b/common.py index 2e9db28..0328eed 100644 --- a/common.py +++ b/common.py @@ -18,10 +18,15 @@ ET.register_namespace("hid", "http://www.hidcorp.com/VertX") fieldnames = "CardNumber,CardFormat,PinRequired,PinCode,ExtendedAccess,ExpiryDate,Forename,Initial,Surname,Email,Phone,Custom1,Custom2,Schedule1,Schedule2,Schedule3,Schedule4,Schedule5,Schedule6,Schedule7,Schedule8".split(",") -def getMembershipworksData(columns): +def getMembershipworksData(folders, columns): """ Pull the members csv from the membershipworks api + folders: a list of the names of the folders to get + (see folder_map in this function for mapping to ids) columns: which columns to get""" BASE_URL = "https://api.membershipworks.com/v1/" + folder_map = {'members': '5ae37979f033bfe8534f8799', + 'staff': '5771675edcdf126302a2f6b9', + 'misc': '5b69ee9bf033bf8e7346c434'} # login r = requests.post(BASE_URL + 'usr', @@ -38,7 +43,7 @@ def getMembershipworksData(columns): # get list of member/staff IDs r = requests.get(BASE_URL + "ylp", params={"SF": SFtoken, - "lbl": "5ae37979f033bfe8534f8799,5771675edcdf126302a2f6b9", # members and staff + "lbl": ",".join([folder_map[f] for f in folders]), "org": "15475", # unknown "var": "_id,nam,ctc"}) if r.status_code != 200 or 'usr' not in r.json(): diff --git a/doorUpdater.py b/doorUpdater.py index bc31726..d3db6a4 100755 --- a/doorUpdater.py +++ b/doorUpdater.py @@ -14,7 +14,8 @@ memberLevels = {"CMS Staff": "7x24", "CMS Weekends Only": "Weekends Only", "CMS Weekdays Only": "Weekdays Only", "CMS Unlimited": "Unlimited", - "CMS Nights & Weekends": "Nights and Weekends"} + "CMS Nights & Weekends": "Nights and Weekends", + "CMS Day Pass": "Unlimited"} def makeMember(member, doorAuth): """Create an output CSV row for the member""" @@ -72,6 +73,7 @@ def makeDoor(doorName, doorData, members, hashes): def main(): members = getMembershipworksData( + ['members', 'staff', 'misc'], "lvl,xws,xms,xsc,xas,xfd,xac,phn,eml,lbl,xcf,nam") members.sort(key=lambda x: x['Last Name']) diff --git a/membershipViewer.py b/membershipViewer.py index 4459900..b5e4e9a 100644 --- a/membershipViewer.py +++ b/membershipViewer.py @@ -44,6 +44,7 @@ def main(): # TODO: renewal date members = getMembershipworksData( + ['members', 'staff'], "lvl,xws,xms,xsc,xas,xfd,xac,phn,eml,lbl,xcf,nam,end") data = parse_members(members) diff --git a/ucsAccounts.py b/ucsAccounts.py index 73f85dd..62b62c9 100755 --- a/ucsAccounts.py +++ b/ucsAccounts.py @@ -13,7 +13,8 @@ def makeSets(props): for key, value in props.items()], []) def main(): - members = getMembershipworksData("lvl,phn,eml,lbl,nam,end,_id") + members = getMembershipworksData(['members', 'staff'], + "lvl,phn,eml,lbl,nam,end,_id") for member in members: randomPass = ''.join(random.choice(string.ascii_letters + string.digits)