feat: implement getReportById method

This commit is contained in:
StevanFreeborn
2023-02-09 18:23:49 -06:00
parent 61cb4d2929
commit 3b3e210920
10 changed files with 393 additions and 4 deletions
+18
View File
@@ -15,6 +15,8 @@ import { ListItemResponse } from './ListItemResponse';
import { ListValue } from './ListValue';
import { ReferenceField } from './ReferenceField';
import { Report } from './Report';
import { ReportData } from './ReportData';
import { Row } from './Row';
/**
* @class ApiResponse - A generic response object for API requests.
@@ -303,6 +305,22 @@ export class ApiResponse<T> {
);
}
asReportDataType(): ApiResponse<ReportData> {
const apiResponse = this as ApiResponse<any>;
const rows = apiResponse.data.rows.map((row) => {
return new Row(row.recordId, row.cells);
});
const reportData = new ReportData(apiResponse.data.columns, rows);
return new ApiResponse<ReportData>(
apiResponse.statusCode,
apiResponse.message,
reportData
);
}
/**
* @method asFileCollectionType - Converts the field item to the appropriate field object based upon the field item's type.
* @param {any} fieldItem - The field item to convert.