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

com.pubnub.api.endpoints.objects.internal.IncludeQueryParam.kt Maven / Gradle / Ivy

Go to download

PubNub is a cross-platform client-to-client (1:1 and 1:many) push service in the cloud, capable of broadcasting real-time messages to millions of web and mobile clients simultaneously, in less than a quarter second!

There is a newer version: 10.2.0
Show newest version
package com.pubnub.api.endpoints.objects.internal

import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel
import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel

data class IncludeQueryParam(
    private val includeCustom: Boolean = false,
    private val includeChannelDetails: PNChannelDetailsLevel? = null,
    private val includeUUIDDetails: PNUUIDDetailsLevel? = null,
    private val includeType: Boolean = true,
    private val includeStatus: Boolean = true
) {
    internal fun createIncludeQueryParams(): Map {
        val includeList = mutableListOf()
        if (includeCustom) includeList.add("custom")
        when (includeChannelDetails) {
            PNChannelDetailsLevel.CHANNEL -> includeList.add("channel")
            PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM -> includeList.add("channel.custom")
            null -> {}
        }
        when (includeUUIDDetails) {
            PNUUIDDetailsLevel.UUID -> includeList.add("uuid")
            PNUUIDDetailsLevel.UUID_WITH_CUSTOM -> includeList.add("uuid.custom")
            null -> {}
        }
        if (includeType) includeList.add("type")
        if (includeStatus) includeList.add("status")
        return if (includeList.isNotEmpty()) {
            mapOf("include" to includeList.joinToString(","))
        } else {
            mapOf()
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy