getDeviceHardwareByModel

suspend fun getDeviceHardwareByModel(hwModel: Int, forceRefresh: Boolean = false): Result<DeviceHardware?>

Retrieves device hardware information by its model ID.

This function implements a cache-aside pattern with a fallback mechanism:

  1. Check for a valid, non-expired local cache entry.

  2. If not found or expired, fetch fresh data from the remote API.

  3. If the remote fetch fails, attempt to use stale data from the cache.

  4. If the cache is empty, fall back to loading data from a bundled JSON asset.

Return

A Result containing the DeviceHardware on success (or null if not found), or an exception on failure.

Parameters

hwModel

The hardware model identifier.

forceRefresh

If true, the local cache will be invalidated and data will be fetched remotely.