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)}))))
|
E.FixedField({"value": str(facilityCode)}))))
|
||||||
return self.doXMLRequest(el)
|
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):
|
def get_cardholders(self):
|
||||||
return self.doXMLRequest(
|
return self.get_records(E.Cardholders, 1000,
|
||||||
ROOT(E.Cardholders({"action": "LR",
|
{"responseFormat": "expanded"})
|
||||||
"responseFormat": "expanded",
|
|
||||||
"recordOffset": "0",
|
|
||||||
"recordCount": "1000"})))[0]
|
|
||||||
|
|
||||||
def get_credentials(self):
|
def get_credentials(self):
|
||||||
return self.doXMLRequest(
|
return self.get_records(E.Credentials, 1000)
|
||||||
ROOT(E.Credentials({"action": "LR",
|
|
||||||
"recordOffset": "0",
|
|
||||||
"recordCount": "1000"})))[0]
|
|
||||||
|
|
||||||
def get_lock(self):
|
def get_lock(self):
|
||||||
el = ROOT(
|
el = ROOT(
|
||||||
|
Reference in New Issue
Block a user