Generic function to retrieve and convert a contract to OCF format.
This function combines contract fetching, data extraction, and OCF conversion into a single operation, eliminating the duplicated pattern across get*AsOcf functions.
The LedgerJsonApiClient instance
The OCF entity type
The contract ID to fetch
The entity data in native OCF format along with the contract ID
OcpParseError if the contract data is invalid or conversion fails
// Generic read using dispatcherconst result = await getEntityAsOcf(client, 'stockAcceptance', contractId);// result.data is typed as OcfStockAcceptance// Can be used in place of specific get*AsOcf functionsconst acceptance = await getEntityAsOcf(client, 'convertibleAcceptance', id); Copy
// Generic read using dispatcherconst result = await getEntityAsOcf(client, 'stockAcceptance', contractId);// result.data is typed as OcfStockAcceptance// Can be used in place of specific get*AsOcf functionsconst acceptance = await getEntityAsOcf(client, 'convertibleAcceptance', id);
Generic function to retrieve and convert a contract to OCF format.
This function combines contract fetching, data extraction, and OCF conversion into a single operation, eliminating the duplicated pattern across get*AsOcf functions.