doorUpdater: Add support for the "misc access" folder in MembershipWorks

This commit is contained in:
Adam Goldsmith 2018-08-07 18:33:12 -04:00
parent cec414ca36
commit 207c36a147
4 changed files with 13 additions and 4 deletions

View File

@ -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():

View File

@ -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'])

View File

@ -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)

View File

@ -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)