From a0de5e6fba8618dfa355b69d53e888eac118b76f Mon Sep 17 00:00:00 2001 From: StevanFreeborn Date: Thu, 21 Apr 2022 16:22:44 -0500 Subject: [PATCH] finished implementing methods; --- ConsoleSnippets.py => Commands.py | 405 ++++++++++++++---------------- ConsoleApp.py | 142 +++++++++++ Enums.py | 4 + Models.py | 73 +++++- OnspringClient.py | 215 +++++++++++++++- 5 files changed, 611 insertions(+), 228 deletions(-) rename ConsoleSnippets.py => Commands.py (69%) create mode 100644 ConsoleApp.py diff --git a/ConsoleSnippets.py b/Commands.py similarity index 69% rename from ConsoleSnippets.py rename to Commands.py index 01002af..14febd5 100644 --- a/ConsoleSnippets.py +++ b/Commands.py @@ -1,95 +1,14 @@ +import json import mimetypes import os -import sys + +from requests import request from OnspringClient import OnspringClient -from configparser import ConfigParser from Models import * from Enums import * -cfg = ConfigParser() -cfg.read('config.ini') - -key = cfg['prod']['key'] -url = cfg['prod']['url'] - -onspring = OnspringClient(url, key) - -def main(): - - if not len(sys.argv) > 1: - print('No valid command given') - return - - command = sys.argv[1].lower() - - if command =='connect': - PrintCanConnect(onspring) - - if command == 'getapps': - PrintGetApps(onspring) - - if command == 'getappbyid': - PrintGetAppById(onspring, 195) - - if command == 'getappsbyids': - PrintGetAppsByIds(onspring, [195, 240]) - - if command == 'savefile': - PrintSaveFile( - onspring, - 'C:\\Users\\sfree\\OneDrive\\Desktop\\Test Attachment.txt', - 60, - 6989 - ) - - if command == 'getrecordsbyappid': - PrintGetRecordsByAppId(onspring, 195) - return - - if command == 'getrecordbyid': - PrintGetRecordById(onspring, 195, 3,dataFormat=DataFormat.Raw.name) - return - - if command == 'deleterecord': - PrintDeleteRecord(onspring, 195, sys.argv[2]) - return - - if command == 'getrecordsbyids': - PrintGetRecordsByIds(onspring, 195, [1, 2], [6983, 6984]) - return - - if command == 'queryrecords': - fieldId = 6983 - operator = 'eq' - value = '\'Test Task 5\'' - PrintQueryRecords(onspring, 195, f'{fieldId} {operator} {value}') - return - - if command == 'addrecord': - - fields = [ - StringFieldValue(6983, 'A New Test Task'), - StringFieldValue(6984, 'This is a test task.') - ] - - PrintAddOrUpdateRecord(onspring, 195, fields) - return - - if command == 'updaterecord': - - fields = [ - StringFieldValue(6983, 'Updated'), - StringFieldValue(6984, 'Updated') - ] - - PrintAddOrUpdateRecord(onspring, 195, fields, 60) - return - - print('No valid command given') - return - #connectivity def PrintCanConnect(client: OnspringClient): @@ -107,15 +26,11 @@ def PrintGetApps(client: OnspringClient): print(f'Page Number: {response.data.pageNumber}') print(f'Total Pages: {response.data.totalPages}') print(f'Total Records: {response.data.totalRecords}') - print('----') for app in response.data.apps: print(f'Id: {app.id}') print(f'Name: {app.name}') print(f'href: {app.href}') - print('--') - - print('----') def PrintGetAppById(client: OnspringClient, appId: int): @@ -132,148 +47,59 @@ def PrintGetAppsByIds(client: OnspringClient, appIds: list[int]): print(f'Status Code: {response.statusCode}') print(f'Count: {response.data.count}') - print('----') for app in response.data.apps: print(f'Id: {app.id}') print(f'Name: {app.name}') print(f'href: {app.href}') - print('--') - print('----') +# fields -# records - -def PrintGetRecordsByAppId(client: OnspringClient, appId: int): - - request = GetRecordsByAppRequest(appId, dataFormat=DataFormat.Raw.name) - - response = client.GetRecordsByAppId(request) - - print(f'Status Code: {response.statusCode}') - print(f'Page Size: {response.data.pageSize}') - print(f'Page Number: {response.data.pageNumber}') - print(f'Total Pages: {response.data.totalPages}') - print(f'Total Records: {response.data.totalRecords}') - print('----') - - for record in response.data.records: - print(f'AppId: {record.appId}') - print(f'RecordId: {record.recordId}') - print('--') - - for field in record.fields: - print(f'Type: {field.type}') - print(f'FieldId: {field.fieldId}') - print(f'Value: {field.GetResultValueString()}') - print('--') - - print('----') - -def PrintGetRecordById(client: OnspringClient, appId: int, recordId: int, fieldIds: list[int]=[], dataFormat: str=DataFormat.Raw.name): - - request = GetRecordByIdRequest( - appId, - recordId, - fieldIds, - dataFormat) - - response = client.GetRecordById(request) - - print(f'Status Code: {response.statusCode}') - print('----') - print(f'AppId: {response.data.appId}') - print(f'RecordId: {response.data.recordId}') - print('--') - - for field in response.data.fields: - print(f'Type: {field.type}') - print(f'FieldId: {field.fieldId}') - print(f'Value: {field.GetResultValueString()}') - print('--') +def PrintField(field: Field): - print('----') + print('Field:') + print(f' Id: {field.id}') + print(f' App Id: {field.appId}') + print(f' Name: {field.name}') + print(f' Type: {field.type}') + print(f' Status: {field.status}') + print(f' IsRequired: {field.isRequired}') + print(f' IsUnique: {field.isUnique}') -def PrintDeleteRecord(client: OnspringClient, appId: int, recordId: int): + if field.type == 'Formula': - response = client.DeleteRecordById(appId, recordId) + print(f' Output Type: {field.outputType}') + + if field.outputType == 'ListValue': + + print(f' Multiplicity: {field.multiplicity}') + print(' Values:') + + for value in field.values: + + print(f' {value.AsString()}') + + if field.type == 'List': + + print(f' Multiplicity: {field.multiplicity}') + print(' Values:') + + for value in field.values: + + print(f' {value.AsString()}') + +def PrintGetFieldById(client: OnspringClient, fieldId: int): + + response = client.GetFieldById(fieldId) print(f'Status Code: {response.statusCode}') - print(f'Message: {response.message}') - -def PrintGetRecordsByIds(client: OnspringClient, appId: int, recordIds: list[int], fieldIds: list[int]=[], dataFormat: str=DataFormat.Raw.name): - - request = GetBatchRecordsRequest( - appId, - recordIds, - fieldIds, - dataFormat) - - response = client.GetRecordsByIds(request) - - print(f'Status Code: {response.statusCode}') - print(f'Count: {response.data.count}') - print('----') - - for record in response.data.records: - print(f'AppId: {record.appId}') - print(f'RecordId: {record.recordId}') - print('--') - - for field in record.fields: - print(f'Type: {field.type}') - print(f'FieldId: {field.fieldId}') - print(f'Value: {field.GetResultValueString()}') - print('--') - - print('----') -def PrintQueryRecords(client: OnspringClient, appId: int, filter: str, fieldIds: list[int]=[], dataFormat: str=DataFormat.Raw.name, pagingRequest: PagingRequest=PagingRequest(1,50)): + if response.isSuccessful: + PrintField(response.data.field) + else: + print(f'Message: {response.message}') - request = QueryRecordsRequest( - appId, - filter, - fieldIds, - dataFormat, - pagingRequest) - - response = client.QueryRecords(request) - - print(f'Status Code: {response.statusCode}') - print(f'Page Size: {response.data.pageSize}') - print(f'Page Number: {response.data.pageNumber}') - print(f'Total Pages: {response.data.totalPages}') - print(f'Total Records: {response.data.totalRecords}') - print('----') - - for record in response.data.records: - print(f'AppId: {record.appId}') - print(f'RecordId: {record.recordId}') - print('--') - - for field in record.fields: - print(f'Type: {field.type}') - print(f'FieldId: {field.fieldId}') - print(f'Value: {field.GetResultValueString()}') - print('--') - - print('----') - -def PrintAddOrUpdateRecord(client: OnspringClient, appId: int, fields: list[RecordFieldValue], recordId: int=None): - - record = Record( - appId, - fields, - recordId) - - response = client.AddOrUpdateRecord(record) - - print(f'Status Code: {response.statusCode}') - print(f'Id: {response.data.id}') - for warning in response.data.warnings: - print(f'Warning: {warning}') - # files def PrintSaveFile(client: OnspringClient, filePath: str, recordId: int, fieldId: int, notes: str=None, modifiedDate: datetime=None): @@ -296,5 +122,150 @@ def PrintSaveFile(client: OnspringClient, filePath: str, recordId: int, fieldId: print(f'Status Code: {response.statusCode}') print(f'File Id: {response.data.id}') -if __name__ == "__main__": - main() \ No newline at end of file +# records + +def PrintGetRecordsByAppId(client: OnspringClient, appId: int): + + request = GetRecordsByAppRequest(appId, dataFormat=DataFormat.Raw.name) + + response = client.GetRecordsByAppId(request) + + print(f'Status Code: {response.statusCode}') + print(f'Page Size: {response.data.pageSize}') + print(f'Page Number: {response.data.pageNumber}') + print(f'Total Pages: {response.data.totalPages}') + print(f'Total Records: {response.data.totalRecords}') + + for record in response.data.records: + print(f'AppId: {record.appId}') + print(f'RecordId: {record.recordId}') + + for field in record.fields: + print(f'Type: {field.type}') + print(f'FieldId: {field.fieldId}') + print(f'Value: {field.GetResultValueString()}') + +def PrintGetRecordById(client: OnspringClient, appId: int, recordId: int, fieldIds: list[int]=[], dataFormat: str=DataFormat.Raw.name): + + request = GetRecordByIdRequest( + appId, + recordId, + fieldIds, + dataFormat) + + response = client.GetRecordById(request) + + print(f'Status Code: {response.statusCode}') + print(f'AppId: {response.data.appId}') + print(f'RecordId: {response.data.recordId}') + + for field in response.data.fields: + print(f'Type: {field.type}') + print(f'FieldId: {field.fieldId}') + print(f'Value: {field.GetResultValueString()}') + +def PrintDeleteRecord(client: OnspringClient, appId: int, recordId: int): + + response = client.DeleteRecordById(appId, recordId) + + print(f'Status Code: {response.statusCode}') + print(f'Message: {response.message}') + +def PrintGetRecordsByIds(client: OnspringClient, appId: int, recordIds: list[int], fieldIds: list[int]=[], dataFormat: str=DataFormat.Raw.name): + + request = GetBatchRecordsRequest( + appId, + recordIds, + fieldIds, + dataFormat) + + response = client.GetRecordsByIds(request) + + print(f'Status Code: {response.statusCode}') + print(f'Count: {response.data.count}') + + for record in response.data.records: + print(f'AppId: {record.appId}') + print(f'RecordId: {record.recordId}') + + for field in record.fields: + print(f'Type: {field.type}') + print(f'FieldId: {field.fieldId}') + print(f'Value: {field.GetResultValueString()}') + +def PrintQueryRecords(client: OnspringClient, appId: int, filter: str, fieldIds: list[int]=[], dataFormat: str=DataFormat.Raw.name, pagingRequest: PagingRequest=PagingRequest(1,50)): + + request = QueryRecordsRequest( + appId, + filter, + fieldIds, + dataFormat, + pagingRequest) + + response = client.QueryRecords(request) + + print(f'Status Code: {response.statusCode}') + print(f'Page Size: {response.data.pageSize}') + print(f'Page Number: {response.data.pageNumber}') + print(f'Total Pages: {response.data.totalPages}') + print(f'Total Records: {response.data.totalRecords}') + + for record in response.data.records: + print(f'AppId: {record.appId}') + print(f'RecordId: {record.recordId}') + + for field in record.fields: + print(f'Type: {field.type}') + print(f'FieldId: {field.fieldId}') + print(f'Value: {field.GetResultValueString()}') + +def PrintAddOrUpdateRecord(client: OnspringClient, appId: int, fields: list[RecordFieldValue], recordId: int=None): + + record = Record( + appId, + fields, + recordId) + + response = client.AddOrUpdateRecord(record) + + print(f'Status Code: {response.statusCode}') + print(f'Id: {response.data.id}') + for warning in response.data.warnings: + print(f'Warning: {warning}') + +def PrintDeleteRecordsByIds(client: OnspringClient, appId: int, recordIds: list[int]): + + request = DeleteBatchRecordsRequest(appId, recordIds) + + response = client.DeleteRecordsByIds(request) + + print(f'Status Code: {response.statusCode}') + print(f'Message: {response.message}') + +# reports + +def PrintGetReportById(client: OnspringClient, reportId: int, apiDataFormat: str=DataFormat.Raw.name, dataFormat: str=ReportDataType.ReportData.name): + + request = GetReportByIdRequest(reportId, apiDataFormat, dataFormat) + + response = client.GetReportById(request) + + print(f'Status Code: {response.statusCode}') + print('Columns:') + print(f'{", ".join(response.data.columns)}') + print('Rows:') + for row in response.data.rows: + print(f'Record Id {row.recordId}: {", ".join([str(cell) for cell in row.cells])}') + +def PrintGetReportsByAppId(client: OnspringClient, appId: int, pagingRequest: PagingRequest=PagingRequest(1,50)): + + response = client.GetReportsByAppId(appId, pagingRequest) + + print(f'Status Code: {response.statusCode}') + print(f'App Id: {appId}') + print('Reports:') + + for report in response.data.reports: + print(f' Id: {report.id}') + print(f' Name: {report.name}') + print(f' Description: {report.description}') \ No newline at end of file diff --git a/ConsoleApp.py b/ConsoleApp.py new file mode 100644 index 0000000..0d57182 --- /dev/null +++ b/ConsoleApp.py @@ -0,0 +1,142 @@ +import sys + +from OnspringClient import OnspringClient +from configparser import ConfigParser + +from Models import * +from Enums import * +from Commands import * + +cfg = ConfigParser() +cfg.read('config.ini') + +key = cfg['prod']['key'] +url = cfg['prod']['url'] + +onspring = OnspringClient(url, key) + +def main(): + + argsLength = len(sys.argv) + + if not argsLength > 1: + print('No valid command given') + return + + command = sys.argv[1].lower() + + if command =='connect': + PrintCanConnect(onspring) + + if command == 'getapps': + PrintGetApps(onspring) + + if command == 'getappbyid': + PrintGetAppById(onspring, 195) + + if command == 'getappsbyids': + PrintGetAppsByIds(onspring, [195, 240]) + + if command == 'getfieldbyid': + PrintGetFieldById(onspring, 9686 ) + return + + if command == 'savefile': + PrintSaveFile( + onspring, + 'C:\\Users\\sfree\\OneDrive\\Desktop\\Test Attachment.txt', + 60, + 6989 + ) + + if command == 'getrecordsbyappid': + PrintGetRecordsByAppId(onspring, 195) + return + + if command == 'getrecordbyid': + PrintGetRecordById(onspring, 195, 3,dataFormat=DataFormat.Raw.name) + return + + if command == 'deleterecord': + PrintDeleteRecord(onspring, 195, sys.argv[2]) + return + + if command == 'getrecordsbyids': + PrintGetRecordsByIds(onspring, 195, [1, 2], [6983, 6984]) + return + + if command == 'queryrecords': + fieldId = 6983 + operator = 'eq' + value = '\'Test Task 5\'' + PrintQueryRecords(onspring, 195, f'{fieldId} {operator} {value}') + return + + if command == 'addrecord': + + fields = [ + StringFieldValue(6983, 'A New Test Task'), + StringFieldValue(6984, 'This is a test task.') + ] + + PrintAddOrUpdateRecord(onspring, 195, fields) + return + + if command == 'updaterecord': + + fields = [ + StringFieldValue(6983, 'Updated'), + StringFieldValue(6984, 'Updated') + ] + + PrintAddOrUpdateRecord(onspring, 195, fields, 60) + return + + if command == 'deleterecordsbyids': + + appId = sys.argv[2] + + ids = sys.argv[3].split(',') + + recordIds = [int(id) for id in ids] + + PrintDeleteRecordsByIds(onspring, appId, recordIds) + return + + if command == 'getreportbyid': + + if not argsLength > 2: + print('Please provide report id value') + return + + reportId = sys.argv[2] + + if argsLength > 3: + apiDataFormat = sys.argv[3] + else: + apiDataFormat = DataFormat.Raw.name + + if argsLength > 4: + dataType = sys.argv[4] + else: + dataType = ReportDataType.ReportData.name + + PrintGetReportById(onspring, reportId, apiDataFormat, dataType) + return + + if command == 'getreportsbyappid': + + if not argsLength > 2: + print('Please provide app id value') + return + + appId = sys.argv[2] + + PrintGetReportsByAppId(onspring, appId) + return + + print('No valid command given') + return + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/Enums.py b/Enums.py index c1ff1d4..2854772 100644 --- a/Enums.py +++ b/Enums.py @@ -4,6 +4,10 @@ class DataFormat(Enum): Raw = 0 Formatted = 1 +class ReportDataType(Enum): + ReportData = 0 + ChartData = 1 + class ResultValueType(Enum): String = 0 Integer = 1 diff --git a/Models.py b/Models.py index 0f4a351..28d4ca5 100644 --- a/Models.py +++ b/Models.py @@ -1,3 +1,4 @@ +from audioop import mul import datetime import uuid @@ -50,8 +51,37 @@ class GetAppsByIdsResponse: # field specific +class ListValue: + def __init__(self, id: int, name: str, sortOrder: int, numericValue: Decimal, color: str): + self.id = id + self.name = name + self.sortOrder = sortOrder + + if numericValue != None: + self.numericValue = Decimal(numericValue) + else: + self.numericValue = numericValue + + self.color = color + + def AsString(self): + return f'Id: {self.id}, Name: {self.name}, Value: {self.numericValue}, Sort Order: {self.sortOrder}, Color: {self.color}' + class Field: - def __init__(self, id: int, appId: int, name: str, type: str, status: str, isRequired: bool, isUnique: bool): + def __init__( + self, id: int, + appId: int, + name: str, + type: str, + status: str, + isRequired: bool, + isUnique: bool, + listId: int=None, + values: list[ListValue]=None, + multiplicity: str=None, + outputType: str=None + ): + self.id = id self.appId = appId self.name = name @@ -59,6 +89,10 @@ class Field: self.status = status self.isRequired = isRequired self.isUnique = isUnique + self.listId = listId + self.values = values + self.outputType = outputType + self.multiplicity = multiplicity class GetFieldByIdResponse: def __init__(self, field: Field): @@ -426,7 +460,7 @@ class AddOrUpdateRecordResponse: class DeleteBatchRecordsRequest: def __init__(self, appId: int, recordIds: list[int]): - self.id = id + self.appId = appId self.recordIds = recordIds # field types @@ -520,4 +554,37 @@ class ScoringGroup: class ScoringGroupListValue(RecordFieldValue): def __init__(self, fieldId: int, value: list[ScoringGroup]): self.type = ResultValueType.ScoringGroupList.name - RecordFieldValue.__init__(self, fieldId, value, self.type) \ No newline at end of file + RecordFieldValue.__init__(self, fieldId, value, self.type) + +# report specific + +class GetReportByIdRequest: + def __init__(self, reportId: int, apiDataFormat: str=DataFormat.Raw.name, dataType: str=ReportDataType.ReportData.name): + self.reportId = reportId + self.apiDataFormat = apiDataFormat + self.dataType = dataType + +class Row: + def __init__(self, recordId: int, cells: list[str]): + self.recordId = recordId + self.cells = cells + +class GetReportByIdResponse: + def __init__(self, columns: list[str], rows: list[Row]): + self.columns = columns + self.rows = rows + +class Report: + def __init__(self, appId: int, id: int, name: str, description: str): + self.appId = appId + self.id = id + self.name = name + self.description = description + +class GetReportsByAppIdResponse: + def __init__(self, pageNumber: int, pageSize: int, totalPages: int, totalRecords: int, reports: list[Report]): + self.pageNumber = pageNumber + self.pageSize = pageSize + self.totalPages = totalPages + self.totalRecords = totalRecords + self.reports = reports \ No newline at end of file diff --git a/OnspringClient.py b/OnspringClient.py index 0a3dd18..803aebb 100644 --- a/OnspringClient.py +++ b/OnspringClient.py @@ -235,6 +235,25 @@ class OnspringClient: jsonResponse = dict(response.json()) + values = jsonResponse.get('values') + + if values != None: + + listValues = [] + + for value in values: + + value = dict(value) + + value = ListValue( + value.get('id'), + value.get('name'), + value.get('sortOrder'), + value.get('numericValue'), + value.get('color')) + + listValues.append(value) + field = Field( jsonResponse.get('id'), jsonResponse.get('appId'), @@ -242,7 +261,11 @@ class OnspringClient: jsonResponse.get('type'), jsonResponse.get('status'), jsonResponse.get('isRequired'), - jsonResponse.get('isUnique')) + jsonResponse.get('isUnique'), + jsonResponse.get("listId"), + listValues, + jsonResponse.get('multiplicity'), + jsonResponse.get('outputType')) data = GetFieldByIdResponse(field) @@ -1193,22 +1216,198 @@ class OnspringClient: response.status_code, raw=response) - def DeleteRecordsByIds(self): + def DeleteRecordsByIds(self, deleteBatchRecordsRequest: DeleteBatchRecordsRequest): endpoint = DeleteRecordsByIds(self.baseUrl) - return + self.headers['Content-Type'] = 'application/json' + + requestData = json.dumps(deleteBatchRecordsRequest.__dict__) + + response = requests.request( + 'POST', + endpoint, + headers=self.headers, + data=requestData) + + if response.status_code == 400: + + return ApiResponse( + response.status_code, + message='Invalid request provided', + raw=response) + + if response.status_code == 401: + + return ApiResponse( + response.status_code, + message='Unauthorized request', + raw=response) + + if response.status_code == 403: + + jsonResponse = dict(response.json()) + + return ApiResponse( + response.status_code, + message=jsonResponse.get('message'), + raw=response) + + if response.status_code == 404: + + return ApiResponse( + response.status_code, + message='Records could not be found', + raw=response) + + if response.status_code == 204: + + return ApiResponse( + response.status_code, + message='Record(s) deleted successfully', + raw=response) + + return ApiResponse( + response.status_code, + raw=response) # report methods - def GetReportById(self, reportId: int): + def GetReportById(self, getReportByIdRequest: GetReportByIdRequest): - endpoint = GetReportByIdEndpoint(self.baseUrl, reportId) + endpoint = GetReportByIdEndpoint(self.baseUrl, getReportByIdRequest.reportId) - return + params = getReportByIdRequest.__dict__ + del params['reportId'] - def GetReportsByAppId(self, appId: int): + response = requests.request( + 'GET', + endpoint, + headers=self.headers, + params=params) + + if response.status_code == 400: + + return ApiResponse( + response.status_code, + message='Invalid request based on underlying data', + raw=response) + + if response.status_code == 401: + + return ApiResponse( + response.status_code, + message='Unauthorized request', + raw=response) + + if response.status_code == 403: + + jsonResponse = dict(response.json()) + + return ApiResponse( + response.status_code, + message=jsonResponse.get('message'), + raw=response) + + if response.status_code == 404: + + return ApiResponse( + response.status_code, + message='Report could not be found', + raw=response) + + if response.status_code == 200: + + jsonResponse = dict(response.json()) + + rows = [] + + for row in jsonResponse.get('rows'): + + row = dict(row) + + row = Row( + row.get('recordId'), + row.get('cells')) + + rows.append(row) + + data = GetReportByIdResponse( + jsonResponse.get('columns'), + rows) + + return ApiResponse( + response.status_code, + data=data, + raw=response) + + return ApiResponse( + response.status_code, + raw=response) + + def GetReportsByAppId(self, appId: int, pagingRequest: PagingRequest=PagingRequest(1,50)): endpoint = GetReportsByAppIdEndpoint(self.baseUrl, appId) - return \ No newline at end of file + params = pagingRequest.__dict__ + + response = requests.request( + 'GET', + endpoint, + headers=self.headers, + params=params) + + if response.status_code == 400: + return ApiResponse( + response.status_code, + message='Client does not have read access to the app.', + raw=response) + + if response.status_code == 401: + return ApiResponse( + response.status_code, + message='Unauthorized request', + raw=response) + + if response.status_code == 403: + + jsonResponse = dict(response.json()) + + return ApiResponse( + response.status_code, + message=jsonResponse.get('message'), + raw=response) + + if response.status_code == 200: + + responseJson = dict(response.json()) + + reports = [] + + for item in responseJson.get('items'): + + item = dict(item) + + report = Report( + item.get('appId'), + item.get('id'), + item.get('name'), + item.get('description')) + + reports.append(report) + + data = GetReportsByAppIdResponse( + responseJson.get('pageNumber'), + responseJson.get('pageSize'), + responseJson.get('totalPages'), + responseJson.get('totalRecords'), + reports) + + return ApiResponse( + response.status_code, + data, + raw=response) + + return ApiResponse( + response.status_code, + raw=response) \ No newline at end of file