Allow DoorController to handle paginated records requests
This commit is contained in:
parent
82a54b8f41
commit
d248e41fdb
@ -125,18 +125,32 @@ class DoorController():
|
||||
E.FixedField({"value": str(facilityCode)}))))
|
||||
return self.doXMLRequest(el)
|
||||
|
||||
def get_records(self, req, count, params={}):
|
||||
result = []
|
||||
recordCount = 0
|
||||
moreRecords = True
|
||||
|
||||
while moreRecords:
|
||||
res = self.doXMLRequest(ROOT(
|
||||
req({
|
||||
"action": "LR",
|
||||
"recordCount": str(count - recordCount),
|
||||
"recordOffset": str(recordCount),
|
||||
**params
|
||||
})))
|
||||
result += list(res[0])
|
||||
|
||||
recordCount += int(res[0].get('recordCount'))
|
||||
moreRecords = res[0].get('moreRecords') == 'true'
|
||||
|
||||
return result
|
||||
|
||||
def get_cardholders(self):
|
||||
return self.doXMLRequest(
|
||||
ROOT(E.Cardholders({"action": "LR",
|
||||
"responseFormat": "expanded",
|
||||
"recordOffset": "0",
|
||||
"recordCount": "1000"})))[0]
|
||||
return self.get_records(E.Cardholders, 1000,
|
||||
{"responseFormat": "expanded"})
|
||||
|
||||
def get_credentials(self):
|
||||
return self.doXMLRequest(
|
||||
ROOT(E.Credentials({"action": "LR",
|
||||
"recordOffset": "0",
|
||||
"recordCount": "1000"})))[0]
|
||||
return self.get_records(E.Credentials, 1000)
|
||||
|
||||
def get_lock(self):
|
||||
el = ROOT(
|
||||
|
Reference in New Issue
Block a user