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

com.river.connector.github.model.QueryParameters.kt Maven / Gradle / Ivy

There is a newer version: 1.0.0-alpha18
Show newest version
package com.river.connector.github.model

import com.river.connector.github.internal.snakeCase
import kotlin.reflect.full.declaredMemberProperties

interface QueryParameters

internal fun QueryParameters.asMap(): Map> =
    this::class.declaredMemberProperties
        .map { it.name to it.call(this) }
        .filter { (_, v) -> v != null }
        .toMap()
        .mapKeys { (k, _) -> k.snakeCase() }
        .mapValues { (_, value) ->
            when (value) {
                is List<*> -> value.map {
                    when (it) {
                        is Enum<*> -> it.name.lowercase()
                        else -> "$it"
                    }
                }

                is Enum<*> -> listOf(value.name.lowercase())

                else -> listOf("$value")
            }
        }
        .filter { (_, values) -> values.isNotEmpty() }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy