package pl.firmatpp.kierowca.data.upload

import com.google.gson.Gson

private val routeActionPhotoDependencyGson = Gson()

fun routeActionReferencesPhotoClientRequest(action: RouteActionEntity, clientRequestId: String): Boolean {
    val needle = clientRequestId.trim()
    if (needle.isBlank()) return false

    return runCatching {
        routeActionPhotoDependencyGson
            .fromJson(action.photoClientRequestIdsJson, Array<String>::class.java)
            ?.any { it.trim() == needle }
            ?: false
    }.getOrDefault(false)
}
