All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.lithic.api.core.Utils.kt Maven / Gradle / Ivy

Go to download

The Lithic Developer API is designed to provide a predictable programmatic interface for accessing your Lithic account through an API and transaction webhooks. Note that your API key is a secret and should be treated as such. Don't share it with anyone, including us. We will never ask you for it.

The newest version!
@file:JvmName("Utils")

package com.lithic.api.core

import com.lithic.api.core.http.Headers
import com.lithic.api.errors.LithicInvalidDataException
import java.util.Collections
import java.util.SortedMap

internal fun  T?.getOrThrow(name: String): T =
    this ?: throw LithicInvalidDataException("`${name}` is not present")

internal fun  List.toImmutable(): List =
    if (isEmpty()) Collections.emptyList() else Collections.unmodifiableList(toList())

internal fun  Map.toImmutable(): Map =
    if (isEmpty()) Collections.emptyMap() else Collections.unmodifiableMap(toMap())

internal fun , V> SortedMap.toImmutable(): SortedMap =
    if (isEmpty()) Collections.emptySortedMap()
    else Collections.unmodifiableSortedMap(toSortedMap(comparator()))

internal fun Headers.getRequiredHeader(name: String): String =
    values(name).firstOrNull() ?: throw LithicInvalidDataException("Could not find $name header")

internal interface Enum




© 2015 - 2024 Weber Informatics LLC | Privacy Policy