more work;

This commit is contained in:
StevanFreeborn
2022-04-19 12:37:10 -05:00
parent 4b9a386a43
commit c9bc3062ed
2 changed files with 82 additions and 5 deletions
+60
View File
@@ -1,4 +1,5 @@
from datetime import datetime
from Enums import *
def parseDate(date: str):
@@ -10,3 +11,62 @@ def parseDate(date: str):
return datetime.strptime(date, format)
except ValueError:
pass
def GetResultValueString(value):
match value.type:
case ResultValueType.String.name:
return value.AsString()
case ResultValueType.Integer.name:
return value.AsInteger()
case ResultValueType.Decimal.name:
return value.AsDecimal()
case ResultValueType.Date.name:
return value.AsDate()
case ResultValueType.TimeSpan.name:
data = value.AsTimeSpan()
return f'Quantity: {data.quantity}, Increment: {data.increment}, Recurrence: {data.recurrence}, EndByDate: {data.endByDate}, EndAfterOccurrences: {data.endAfterOccurrences}'
case ResultValueType.Guid.name:
return value.AsGuid()
case ResultValueType.StringList.name:
data = value.AsStringList()
return f'{",".join(data)}'
case ResultValueType.IntegerList.name:
data = value.AsIntegerList()
return f'{",".join([str(i) for i in data])}'
case ResultValueType.GuidList.name:
data = value.AsGuidList()
return f'{",".join([str(guid) for guid in data])}'
case ResultValueType.AttachmentList.name:
data = value.AsAttachmentList()
strings = []
for attachment in data:
string = f'FileId: {attachment.fileId}, FileName: {attachment.fileName}, Notes: {attachment.notes}, StorageLocation: {attachment.storageLocation}'
strings.append(string)
return f'{"; ".join(strings)}'
case ResultValueType.ScoringGroupList.name:
data = value.AsScoringGroupList()
strings = []
for scoringGroup in data:
string = f'ListValueId: {scoringGroup.listValueId}, Name: {scoringGroup.name}, Score: {scoringGroup.score}, Max Score: {scoringGroup.maximumScore}'
strings.append(string)
return f'{"; ".join(strings)}'
case ResultValueType.FileList.name:
data = value.AsFileList()
return f'{",".join([str(i) for i in data])}'
+20 -3
View File
@@ -1,6 +1,9 @@
from OnspringClient import OnspringClient
from configparser import ConfigParser
from Helpers import GetResultValueString
from Models import *
from Enums import *
cfg = ConfigParser()
cfg.read('config.ini')
@@ -10,6 +13,13 @@ url = cfg['prod']['url']
onspringClient = OnspringClient(url, key)
def main():
GetRecordsByAppIdTest()
# apps
def GetRecordsByAppIdTest():
request = GetRecordsByAppRequest(240, dataFormat=DataFormat.Raw.name)
@@ -23,11 +33,15 @@ def GetRecordsByAppIdTest():
print(f'Total Records: {response.data.totalRecords}')
for record in response.data.records:
print(f' AppId: {record.appId}')
print(f' RecordId: {record.recordId}')
print(f'AppId: {record.appId}')
print(f'RecordId: {record.recordId}')
for field in record.fields:
print(f' Type: {field.type}, FieldId: {field.fieldId}, Value: {field.getValue()}')
print(f'Type: {field.type}')
print(f'FieldId: {field.fieldId}')
print(f'Value: {GetResultValueString(field)}')
# files
def SaveFileTest():
@@ -44,3 +58,6 @@ def SaveFileTest():
print(response.statusCode)
print(response.data.id)
if __name__ == "__main__":
main()