beginning to work on record endpoints;
This commit is contained in:
@@ -1 +1,5 @@
|
|||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
|
class DataFormat(Enum):
|
||||||
|
Raw = 0
|
||||||
|
Formatted = 1
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import datetime
|
import datetime
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
from Enums import DataFormat
|
||||||
|
|
||||||
# generic
|
# generic
|
||||||
|
|
||||||
class ApiResponse:
|
class ApiResponse:
|
||||||
@@ -124,4 +126,14 @@ class ListItemRequest:
|
|||||||
|
|
||||||
class AddOrUpdateListItemResponse:
|
class AddOrUpdateListItemResponse:
|
||||||
def __init__(self, id: uuid):
|
def __init__(self, id: uuid):
|
||||||
self.id = id
|
self.id = id
|
||||||
|
|
||||||
|
# record specific
|
||||||
|
|
||||||
|
class GetRecordsByAppRequest:
|
||||||
|
def __init__(self, appId: int, fieldIds: list[int]=[], dataFormat: str=DataFormat.Raw.name, pagingRequest: PagingRequest=PagingRequest(1,50)):
|
||||||
|
self.appId = appId
|
||||||
|
self.fieldIds = fieldIds
|
||||||
|
self.dataFormat = dataFormat
|
||||||
|
self.pageSize = pagingRequest.pageSize
|
||||||
|
self.pageNumber = pagingRequest.pageNumber
|
||||||
+15
-4
@@ -798,14 +798,25 @@ class OnspringClient:
|
|||||||
|
|
||||||
# record methods
|
# record methods
|
||||||
|
|
||||||
def GetRecordsByAppId(self, appId: int):
|
def GetRecordsByAppId(self, getRecordsByAppRequest: GetRecordsByAppRequest):
|
||||||
|
|
||||||
endpoint = GetRecordsByAppIdEndpoint(self.baseUrl, appId)
|
endpoint = GetRecordsByAppIdEndpoint(self.baseUrl, getRecordsByAppRequest.appId)
|
||||||
|
|
||||||
|
params = getRecordsByAppRequest.__dict__
|
||||||
|
|
||||||
|
# remove appId from params
|
||||||
|
del params['appId']
|
||||||
|
|
||||||
|
# convert list of fieldIds to string of comma separated values
|
||||||
|
params['fieldIds'] = ",".join([str(i) for i in params['fieldIds']])
|
||||||
|
|
||||||
response = requests.request(
|
response = requests.request(
|
||||||
'GET',)
|
'GET',
|
||||||
|
endpoint,
|
||||||
|
headers=self.headers,
|
||||||
|
params=params)
|
||||||
|
|
||||||
return
|
return response
|
||||||
|
|
||||||
def GetRecordById(self, appId: int, recordId: int):
|
def GetRecordById(self, appId: int, recordId: int):
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from OnspringClient import OnspringClient
|
from OnspringClient import OnspringClient
|
||||||
from configparser import ConfigParser
|
from configparser import ConfigParser
|
||||||
|
from Models import *
|
||||||
|
|
||||||
cfg = ConfigParser()
|
cfg = ConfigParser()
|
||||||
cfg.read('config.ini')
|
cfg.read('config.ini')
|
||||||
@@ -9,14 +10,12 @@ url = cfg['prod']['url']
|
|||||||
|
|
||||||
onspringClient = OnspringClient(url, key)
|
onspringClient = OnspringClient(url, key)
|
||||||
|
|
||||||
response =onspringClient.GetAppById(8)
|
request = GetRecordsByAppRequest(195, dataFormat=DataFormat.Formatted.name, fieldIds=[6985,6978])
|
||||||
|
|
||||||
|
response = onspringClient.GetRecordsByAppId(request)
|
||||||
|
|
||||||
|
print(response.status_code)
|
||||||
|
print(response.url)
|
||||||
|
print(response.json())
|
||||||
|
|
||||||
print(response.statusCode)
|
|
||||||
print(response.isSuccessful)
|
|
||||||
print(response.message)
|
|
||||||
print(response.responseText)
|
|
||||||
print(response.headers)
|
|
||||||
print(response.data.app.href)
|
|
||||||
print(response.data.app.id)
|
|
||||||
print(response.data.app.name)
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user