feat: finish writing tests for getRecordsByIds method

This commit is contained in:
StevanFreeborn
2023-02-12 15:04:08 -06:00
parent 827ad9c5a1
commit abf571f415
4 changed files with 306 additions and 1 deletions
+26
View File
@@ -392,6 +392,32 @@ export class ApiResponse<T> {
);
}
public asRecordCollectionType(): ApiResponse<CollectionResponse<Record>> {
const apiResponse = this as ApiResponse<any>;
const records = apiResponse.data.items.map((item: any) => {
const recordValues = item.fieldData.map((fieldData: any) => {
return new RecordValue(
fieldData.type,
fieldData.fieldId,
fieldData.value
);
});
return new Record(item.appId, item.recordId, recordValues);
});
const collectionResponse = new CollectionResponse<Record>(
apiResponse.data.count,
records
);
return new ApiResponse<CollectionResponse<Record>>(
apiResponse.statusCode,
apiResponse.message,
collectionResponse
);
}
/**
* @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.