took way to long to figure out acceptable timespan
This commit is contained in:
+5
-5
@@ -50,7 +50,7 @@ def main():
|
|||||||
return
|
return
|
||||||
|
|
||||||
if command == 'getrecordbyid':
|
if command == 'getrecordbyid':
|
||||||
PrintGetRecordById(onspring, 195, 5)
|
PrintGetRecordById(onspring, 195, 3,dataFormat=DataFormat.Raw.name)
|
||||||
return
|
return
|
||||||
|
|
||||||
if command == 'deleterecord':
|
if command == 'deleterecord':
|
||||||
@@ -71,8 +71,8 @@ def main():
|
|||||||
if command == 'addrecord':
|
if command == 'addrecord':
|
||||||
|
|
||||||
fields = [
|
fields = [
|
||||||
RecordFieldValue(6983, 'A New Test Task'),
|
StringFieldValue(6983, 'A New Test Task'),
|
||||||
RecordFieldValue(6984, 'This is a test task.')
|
StringFieldValue(6984, 'This is a test task.')
|
||||||
]
|
]
|
||||||
|
|
||||||
PrintAddOrUpdateRecord(onspring, 195, fields)
|
PrintAddOrUpdateRecord(onspring, 195, fields)
|
||||||
@@ -81,8 +81,8 @@ def main():
|
|||||||
if command == 'updaterecord':
|
if command == 'updaterecord':
|
||||||
|
|
||||||
fields = [
|
fields = [
|
||||||
RecordFieldValue(6983, 'Updated'),
|
StringFieldValue(6983, 'Updated'),
|
||||||
RecordFieldValue(6984, 'Updated')
|
StringFieldValue(6984, 'Updated')
|
||||||
]
|
]
|
||||||
|
|
||||||
PrintAddOrUpdateRecord(onspring, 195, fields, 60)
|
PrintAddOrUpdateRecord(onspring, 195, fields, 60)
|
||||||
|
|||||||
@@ -19,13 +19,13 @@ class ResultValueType(Enum):
|
|||||||
FileList = 11
|
FileList = 11
|
||||||
|
|
||||||
class Increment(Enum):
|
class Increment(Enum):
|
||||||
Seconds = 0
|
Seconds = "Second(s)"
|
||||||
Minutes = 1
|
Minutes = "Minute(s)"
|
||||||
Hours = 2
|
Hours = "Hour(s)"
|
||||||
Days = 3
|
Days = "Day(s)"
|
||||||
Weeks = 4
|
Weeks = "Week(s)"
|
||||||
Months = 5
|
Months = "Month(s)"
|
||||||
Years = 6
|
Years = "Year(s)"
|
||||||
|
|
||||||
class Recurrence(Enum):
|
class Recurrence(Enum):
|
||||||
Empty = "None"
|
Empty = "None"
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
from dataclasses import field
|
||||||
import datetime
|
import datetime
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
@@ -132,89 +133,7 @@ class AddOrUpdateListItemResponse:
|
|||||||
def __init__(self, id: uuid):
|
def __init__(self, id: uuid):
|
||||||
self.id = id
|
self.id = id
|
||||||
|
|
||||||
# field types
|
|
||||||
|
|
||||||
class StringFieldValue:
|
|
||||||
def __init__(self, value: str, fieldId: int):
|
|
||||||
self.fieldId = fieldId
|
|
||||||
self.value = value
|
|
||||||
|
|
||||||
class IntegerFieldValue:
|
|
||||||
def __init__(self, value: int, fieldId: int):
|
|
||||||
self.value = value
|
|
||||||
self.fieldId = fieldId
|
|
||||||
|
|
||||||
class DecimalFieldValue:
|
|
||||||
def __init__(self, value: Decimal, fieldId: int):
|
|
||||||
self.value = value
|
|
||||||
self.fieldId = fieldId
|
|
||||||
|
|
||||||
class DateFieldValue:
|
|
||||||
def __init__(self, value: datetime, fieldId: int):
|
|
||||||
self.value = value
|
|
||||||
self.fieldId = fieldId
|
|
||||||
|
|
||||||
class GuidFieldValue:
|
|
||||||
def __init__(self, value: uuid.UUID, fieldId: int):
|
|
||||||
self.value = value
|
|
||||||
self.fieldId = fieldId
|
|
||||||
|
|
||||||
class TimeSpanData:
|
|
||||||
def __init__(self, quantity: Decimal, increment: str, recurrence: str=None, endByDate: datetime=None, endAfterOccurrences: int=None):
|
|
||||||
self.quantity = quantity
|
|
||||||
self.increment = increment
|
|
||||||
self.recurrence = recurrence
|
|
||||||
self.endByDate = endByDate
|
|
||||||
self.endAfterOccurrences = endAfterOccurrences
|
|
||||||
|
|
||||||
class TimeSpanValue:
|
|
||||||
def __init__(self, value: TimeSpanData, fieldId: int):
|
|
||||||
self.value = value
|
|
||||||
self.fieldId = fieldId
|
|
||||||
|
|
||||||
class StringListValue:
|
|
||||||
def __init__(self, value: list[str], fieldId: int):
|
|
||||||
self.value = value
|
|
||||||
self.fieldId = fieldId
|
|
||||||
|
|
||||||
class IntegerListValue:
|
|
||||||
def __init__(self, value: list[int], fieldId: int):
|
|
||||||
self.value = value
|
|
||||||
self.fieldId = fieldId
|
|
||||||
|
|
||||||
class GuidListValue:
|
|
||||||
def __init__(self, value: list[uuid.UUID], fieldId: int):
|
|
||||||
self.value = value
|
|
||||||
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
|
||||||
|
|
||||||
@@ -229,7 +148,7 @@ class RecordFieldValue:
|
|||||||
if self.type != ResultValueType.String.name:
|
if self.type != ResultValueType.String.name:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return StringFieldValue(self.value, self.fieldId).value
|
return StringFieldValue(self.fieldId, self.value).value
|
||||||
|
|
||||||
def AsInteger(self):
|
def AsInteger(self):
|
||||||
|
|
||||||
@@ -442,3 +361,107 @@ class AddOrUpdateRecordResponse:
|
|||||||
def __init__(self, id: int, warnings: list[str]=[]):
|
def __init__(self, id: int, warnings: list[str]=[]):
|
||||||
self.id = id
|
self.id = id
|
||||||
self.warnings = warnings
|
self.warnings = warnings
|
||||||
|
|
||||||
|
# field types
|
||||||
|
|
||||||
|
class StringFieldValue(RecordFieldValue):
|
||||||
|
def __init__(self, fieldId: int, value):
|
||||||
|
self.type = ResultValueType.String.name
|
||||||
|
RecordFieldValue.__init__(self, fieldId, value, self.type)
|
||||||
|
|
||||||
|
class IntegerFieldValue:
|
||||||
|
def __init__(self, value: int, fieldId: int):
|
||||||
|
self.value = value
|
||||||
|
self.fieldId = fieldId
|
||||||
|
self.type = ResultValueType.Integer.name
|
||||||
|
|
||||||
|
class DecimalFieldValue:
|
||||||
|
def __init__(self, value: Decimal, fieldId: int):
|
||||||
|
self.value = value
|
||||||
|
self.fieldId = fieldId
|
||||||
|
self.type = ResultValueType.Decimal.name
|
||||||
|
|
||||||
|
class DateFieldValue:
|
||||||
|
def __init__(self, value: datetime, fieldId: int):
|
||||||
|
self.value = value
|
||||||
|
self.fieldId = fieldId
|
||||||
|
self.type = ResultValueType.Date.name
|
||||||
|
|
||||||
|
class GuidFieldValue:
|
||||||
|
def __init__(self, value: uuid.UUID, fieldId: int):
|
||||||
|
self.value = value
|
||||||
|
self.fieldId = fieldId
|
||||||
|
self.type = ResultValueType.Guid.name
|
||||||
|
|
||||||
|
class TimeSpanData:
|
||||||
|
def __init__(self, quantity: Decimal, increment: Increment, recurrence: Recurrence=None, endByDate: datetime=None, endAfterOccurrences: int=None):
|
||||||
|
self.quantity = quantity
|
||||||
|
self.increment = increment
|
||||||
|
self.recurrence = recurrence
|
||||||
|
self.endByDate = endByDate
|
||||||
|
self.endAfterOccurrences = endAfterOccurrences
|
||||||
|
|
||||||
|
def AsString(self):
|
||||||
|
if self.endByDate != None:
|
||||||
|
formattedDate = self.endByDate.strftime("%m/%d/%Y %I:%M %p")
|
||||||
|
return f'Every {self.quantity} {self.increment} End By {formattedDate}'
|
||||||
|
elif self.endAfterOccurrences != None:
|
||||||
|
return f'Every {self.quantity} {self.increment} End After {self.endAfterOccurrences}'
|
||||||
|
else:
|
||||||
|
return f'{self.quantity} {self.increment}'
|
||||||
|
|
||||||
|
class TimeSpanValue:
|
||||||
|
def __init__(self, value: TimeSpanData, fieldId: int):
|
||||||
|
self.value = value
|
||||||
|
self.fieldId = fieldId
|
||||||
|
self.type = ResultValueType.TimeSpan.name
|
||||||
|
|
||||||
|
class StringListValue:
|
||||||
|
def __init__(self, value: list[str], fieldId: int):
|
||||||
|
self.value = value
|
||||||
|
self.fieldId = fieldId
|
||||||
|
self.type = ResultValueType.StringList.name
|
||||||
|
|
||||||
|
class IntegerListValue:
|
||||||
|
def __init__(self, value: list[int], fieldId: int):
|
||||||
|
self.value = value
|
||||||
|
self.fieldId = fieldId
|
||||||
|
self.type = ResultValueType.IntegerList.name
|
||||||
|
|
||||||
|
class GuidListValue:
|
||||||
|
def __init__(self, value: list[uuid.UUID], fieldId: int):
|
||||||
|
self.value = value
|
||||||
|
self.fieldId = fieldId
|
||||||
|
self.type = ResultValueType.GuidList.name
|
||||||
|
|
||||||
|
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
|
||||||
|
self.type = ResultValueType.AttachmentList.name
|
||||||
|
|
||||||
|
class FileListValue:
|
||||||
|
def __init__(self, value: list[int], fieldId: int):
|
||||||
|
self.value = value
|
||||||
|
self.fieldId = fieldId
|
||||||
|
self.type = ResultValueType.FileList.name
|
||||||
|
|
||||||
|
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
|
||||||
|
self.type = ResultValueType.ScoringGroupList.name
|
||||||
+3
-6
@@ -1,4 +1,3 @@
|
|||||||
from urllib import response
|
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
@@ -1134,14 +1133,12 @@ class OnspringClient:
|
|||||||
|
|
||||||
self.headers['Content-Type'] = 'application/json'
|
self.headers['Content-Type'] = 'application/json'
|
||||||
|
|
||||||
dictFields = []
|
fieldsDict = {}
|
||||||
|
|
||||||
for field in record.fields:
|
for field in record.fields:
|
||||||
field = field.__dict__
|
fieldsDict[field.fieldId] = field.value
|
||||||
del field['type']
|
|
||||||
dictFields.append(field)
|
|
||||||
|
|
||||||
record.fields = dictFields
|
record.fields = fieldsDict
|
||||||
|
|
||||||
requestData = json.dumps(record.__dict__)
|
requestData = json.dumps(record.__dict__)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user