package ru.fincode.tsudesk.core.network.model

inline fun <T, R> NetworkResult<T>.map(
    transform: (T, NetworkMeta) -> R
): NetworkResult<R> = when (val source = this) {

    is NetworkResult.Success -> NetworkResult.Success(
        data = transform(source.data, source.meta), meta = source.meta
    )

    is NetworkResult.Error -> NetworkResult.Error(source.error)
}
