package com.rooksdk.utils import com.facebook.react.bridge.ReadableArray import io.tryrook.api.sources.domain.enums.DataSourceType object DatasourceUtils { /** * Maps a data source string to its corresponding DataSourceType enum. * @param source The data source name as a string (e.g., "Garmin", "Fitbit"). * @return The corresponding DataSourceType enum or null if the string does not match. */ fun mapToDataSourceType(source: String): DataSourceType? { return try { DataSourceType.valueOf(source.uppercase()) } catch (e: IllegalArgumentException) { null } } fun readableArrayToSourceList(sources: ReadableArray): List { val rawList = sources.toArrayList() return rawList .mapNotNull { it as? String } .mapNotNull { try { Source.valueOf(it) } catch (e: IllegalArgumentException) { null } } } }