more work;
This commit is contained in:
@@ -166,7 +166,6 @@ class TimeSpanData:
|
|||||||
self.endByDate = endByDate
|
self.endByDate = endByDate
|
||||||
self.endAfterOccurrences = endAfterOccurrences
|
self.endAfterOccurrences = endAfterOccurrences
|
||||||
|
|
||||||
|
|
||||||
class TimeSpanValue:
|
class TimeSpanValue:
|
||||||
def __init__(self, value: TimeSpanData, fieldId: int):
|
def __init__(self, value: TimeSpanData, fieldId: int):
|
||||||
self.value = value
|
self.value = value
|
||||||
@@ -187,6 +186,34 @@ class GuidListValue:
|
|||||||
self.value = value
|
self.value = value
|
||||||
self.fieldId = fieldId
|
self.fieldId = fieldId
|
||||||
|
|
||||||
|
class Attachment:
|
||||||
|
def __init__(self, fileId: int, fileName: str, notes: str, storageLocation: str):
|
||||||
|
self.fileId = fileId
|
||||||
|
self.fileName = fileName
|
||||||
|
self.notes = notes
|
||||||
|
self.storageLocation = storageLocation
|
||||||
|
|
||||||
|
class AttachmentListValue:
|
||||||
|
def __init__(self, value: list[Attachment], fieldId: int):
|
||||||
|
self.value = value
|
||||||
|
self.fieldId = fieldId
|
||||||
|
|
||||||
|
class FileListValue:
|
||||||
|
def __init__(self, value: list[int], fieldId: int):
|
||||||
|
self.value = value
|
||||||
|
self.fieldId = fieldId
|
||||||
|
|
||||||
|
class ScoringGroup:
|
||||||
|
def __init__(self, listValueId: uuid.UUID, name: str, score: Decimal, maximumScore: Decimal):
|
||||||
|
self.listValueId = listValueId
|
||||||
|
self.name = name
|
||||||
|
self.score = score
|
||||||
|
self.maximumScore = maximumScore
|
||||||
|
|
||||||
|
class ScoringGroupListValue:
|
||||||
|
def __init__(self, value: list[ScoringGroup], fieldId: int):
|
||||||
|
self.value = value
|
||||||
|
self.fieldId = fieldId
|
||||||
|
|
||||||
# record specific
|
# record specific
|
||||||
|
|
||||||
@@ -203,7 +230,7 @@ class RecordFieldValue:
|
|||||||
|
|
||||||
return StringFieldValue(self.value, self.fieldId).value
|
return StringFieldValue(self.value, self.fieldId).value
|
||||||
|
|
||||||
def AsInt(self):
|
def AsInteger(self):
|
||||||
|
|
||||||
if self.type != ResultValueType.Integer.name:
|
if self.type != ResultValueType.Integer.name:
|
||||||
return None
|
return None
|
||||||
@@ -284,13 +311,82 @@ class RecordFieldValue:
|
|||||||
return GuidListValue(guids, self.fieldId).value
|
return GuidListValue(guids, self.fieldId).value
|
||||||
|
|
||||||
def AsAttachmentList(self):
|
def AsAttachmentList(self):
|
||||||
return
|
|
||||||
|
if self.type != ResultValueType.AttachmentList.name:
|
||||||
|
return None
|
||||||
|
|
||||||
|
attachments = []
|
||||||
|
|
||||||
|
for attachment in self.value:
|
||||||
|
|
||||||
|
attachment = dict(attachment)
|
||||||
|
|
||||||
|
attachment = Attachment(
|
||||||
|
attachment.get('fileId'),
|
||||||
|
attachment.get('fileName'),
|
||||||
|
attachment.get('notes'),
|
||||||
|
attachment.get('storageLocation'))
|
||||||
|
|
||||||
|
attachments.append(attachment)
|
||||||
|
|
||||||
|
return AttachmentListValue(attachments, self.fieldId).value
|
||||||
|
|
||||||
def AsScoringGroupList(self):
|
def AsScoringGroupList(self):
|
||||||
return
|
|
||||||
|
if self.type != ResultValueType.ScoringGroupList.name:
|
||||||
|
return
|
||||||
|
|
||||||
|
scoringGroups = []
|
||||||
|
|
||||||
|
for scoringGroup in self.value:
|
||||||
|
|
||||||
|
scoringGroup = dict(scoringGroup)
|
||||||
|
|
||||||
|
scoringGroup = ScoringGroup(
|
||||||
|
uuid.UUID(scoringGroup.get('listValueId')),
|
||||||
|
scoringGroup.get('name'),
|
||||||
|
Decimal(scoringGroup.get('score')),
|
||||||
|
Decimal(scoringGroup.get('maximumScore')))
|
||||||
|
|
||||||
|
scoringGroups.append(scoringGroup)
|
||||||
|
|
||||||
|
return ScoringGroupListValue(scoringGroups, self.fieldId).value
|
||||||
|
|
||||||
def AsFileList(self):
|
def AsFileList(self):
|
||||||
return
|
|
||||||
|
if self.type != ResultValueType.FileList.name:
|
||||||
|
return None
|
||||||
|
|
||||||
|
return FileListValue(self.value, self.fieldId).value
|
||||||
|
|
||||||
|
def getValue(self):
|
||||||
|
|
||||||
|
if self.type == ResultValueType.String.name:
|
||||||
|
return self.AsString()
|
||||||
|
elif self.type == ResultValueType.Integer.name:
|
||||||
|
return self.AsInteger()
|
||||||
|
elif self.type == ResultValueType.Decimal.name:
|
||||||
|
return self.AsDecimal()
|
||||||
|
elif self.type == ResultValueType.Date.name:
|
||||||
|
return self.AsDate()
|
||||||
|
elif self.type == ResultValueType.TimeSpan.name:
|
||||||
|
return self.AsTimeSpan()
|
||||||
|
elif self.type == ResultValueType.Guid.name:
|
||||||
|
return self.AsGuid()
|
||||||
|
elif self.type == ResultValueType.StringList.name:
|
||||||
|
return self.AsStringList()
|
||||||
|
elif self.type == ResultValueType.IntegerList.name:
|
||||||
|
return self.AsIntegerList()
|
||||||
|
elif self.type == ResultValueType.GuidList.name:
|
||||||
|
return self.AsGuidList()
|
||||||
|
elif self.type == ResultValueType.AttachmentList.name:
|
||||||
|
return self.AsAttachmentList()
|
||||||
|
elif self.type == ResultValueType.ScoringGroupList.name:
|
||||||
|
return self.AsScoringGroupList()
|
||||||
|
elif self.type == ResultValueType.FileList.name:
|
||||||
|
return self.AsFileList()
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
class Record:
|
class Record:
|
||||||
def __init__(self, appId: int, recordId: int, fields: list[RecordFieldValue]):
|
def __init__(self, appId: int, recordId: int, fields: list[RecordFieldValue]):
|
||||||
|
|||||||
+33
-34
@@ -817,47 +817,46 @@ class OnspringClient:
|
|||||||
headers=self.headers,
|
headers=self.headers,
|
||||||
params=params)
|
params=params)
|
||||||
|
|
||||||
if response.status_code != 200:
|
if response.status_code == 200:
|
||||||
return response
|
|
||||||
|
|
||||||
jsonResponse = response.json()
|
jsonResponse = response.json()
|
||||||
|
|
||||||
records = []
|
records = []
|
||||||
|
|
||||||
for item in jsonResponse['items']:
|
for item in jsonResponse['items']:
|
||||||
|
|
||||||
fields = []
|
|
||||||
|
|
||||||
record = Record(
|
|
||||||
item['appId'],
|
|
||||||
item['recordId'],
|
|
||||||
fields)
|
|
||||||
|
|
||||||
for field in item['fieldData']:
|
|
||||||
|
|
||||||
field = RecordFieldValue(
|
|
||||||
field['type'],
|
|
||||||
field['fieldId'],
|
|
||||||
field['value'])
|
|
||||||
|
|
||||||
fields.append(field)
|
fields = []
|
||||||
|
|
||||||
record.fields = fields
|
|
||||||
|
|
||||||
records.append(record)
|
record = Record(
|
||||||
|
item['appId'],
|
||||||
|
item['recordId'],
|
||||||
|
fields)
|
||||||
|
|
||||||
data = GetRecordsByAppResponse(
|
for field in item['fieldData']:
|
||||||
jsonResponse['pageNumber'],
|
|
||||||
jsonResponse['pageSize'],
|
|
||||||
jsonResponse['totalPages'],
|
|
||||||
jsonResponse['totalRecords'],
|
|
||||||
records)
|
|
||||||
|
|
||||||
return ApiResponse(
|
field = RecordFieldValue(
|
||||||
response.status_code,
|
field['type'],
|
||||||
data,
|
field['fieldId'],
|
||||||
headers=response.headers,
|
field['value'])
|
||||||
responseText=response.text)
|
|
||||||
|
fields.append(field)
|
||||||
|
|
||||||
|
record.fields = fields
|
||||||
|
|
||||||
|
records.append(record)
|
||||||
|
|
||||||
|
data = GetRecordsByAppResponse(
|
||||||
|
jsonResponse['pageNumber'],
|
||||||
|
jsonResponse['pageSize'],
|
||||||
|
jsonResponse['totalPages'],
|
||||||
|
jsonResponse['totalRecords'],
|
||||||
|
records)
|
||||||
|
|
||||||
|
return ApiResponse(
|
||||||
|
response.status_code,
|
||||||
|
data,
|
||||||
|
headers=response.headers,
|
||||||
|
responseText=response.text)
|
||||||
|
|
||||||
def GetRecordById(self, appId: int, recordId: int):
|
def GetRecordById(self, appId: int, recordId: int):
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ url = cfg['prod']['url']
|
|||||||
|
|
||||||
onspringClient = OnspringClient(url, key)
|
onspringClient = OnspringClient(url, key)
|
||||||
|
|
||||||
request = GetRecordsByAppRequest(195, dataFormat=DataFormat.Raw.name)
|
request = GetRecordsByAppRequest(240, dataFormat=DataFormat.Raw.name)
|
||||||
|
|
||||||
response = onspringClient.GetRecordsByAppId(request)
|
response = onspringClient.GetRecordsByAppId(request)
|
||||||
|
|
||||||
@@ -25,6 +25,4 @@ for record in response.data.records:
|
|||||||
print(f' RecordId: {record.recordId}')
|
print(f' RecordId: {record.recordId}')
|
||||||
|
|
||||||
for field in record.fields:
|
for field in record.fields:
|
||||||
if field.type == ResultValueType.Decimal.name:
|
print(f' Type: {field.type}, FieldId: {field.fieldId}, Value: {field.getValue()}')
|
||||||
print(f' Type: {field.type}, FieldId: {field.fieldId}, Value: {field.AsDecimal()}')
|
|
||||||
print(field.AsDecimal())
|
|
||||||
Reference in New Issue
Block a user