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

com.pubnub.extension.RetrofitResponse.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.extension

import com.pubnub.api.models.consumer.objects.PNPage
import com.pubnub.api.models.consumer.objects.member.PNMember
import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult
import com.pubnub.api.models.consumer.objects.membership.PNChannelMembership
import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult
import com.pubnub.api.models.server.objects_api.EntityArrayEnvelope
import retrofit2.Response

internal fun Response>.toPNMemberArrayResult(): PNMemberArrayResult? =
    body()?.let { arrayEnvelope ->
        PNMemberArrayResult(
            status = arrayEnvelope.status,
            data = arrayEnvelope.data,
            totalCount = arrayEnvelope.totalCount,
            next = arrayEnvelope.next?.let { PNPage.PNNext(it) },
            prev = arrayEnvelope.prev?.let { PNPage.PNPrev(it) }
        )
    }

internal fun Response>.toPNChannelMembershipArrayResult(): PNChannelMembershipArrayResult? =
    body()?.let { arrayEnvelope ->
        PNChannelMembershipArrayResult(
            status = arrayEnvelope.status,
            data = arrayEnvelope.data,
            totalCount = arrayEnvelope.totalCount,
            next = arrayEnvelope.next?.let { PNPage.PNNext(it) },
            prev = arrayEnvelope.prev?.let { PNPage.PNPrev(it) }
        )
    }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy