Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/kmp-dev' into wkal/kmp-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
wkal-pubnub committed Aug 16, 2024
2 parents 90c6f92 + 22a7566 commit 0e30bb1
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class PubNubImpl(private val pubNubObjC: PubNubObjC) : PubNub {
}

// TODO: usePost parameter is not present in Swift SDK
override fun fire(channel: String, message: Any, meta: Any?, usePost: Boolean, ttl: Int?): Publish {
override fun fire(channel: String, message: Any, meta: Any?, usePost: Boolean): Publish {
return PublishImpl(
pubnub = pubNubObjC,
channel = channel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class GetChannelMetadataImpl(
onSuccess = callback.onSuccessHandler {
PNChannelMetadataResult(
status = 200,
data = it?.let { rawValue -> createPNChannelMetadata(from = rawValue) }
data = createPNChannelMetadata(it)
)
},
onFailure = callback.onFailureHandler()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class SetChannelMetadataImpl(
onSuccess = callback.onSuccessHandler {
PNChannelMetadataResult(
status = 200,
data = it?.let { rawValue -> createPNChannelMetadata(from = rawValue) }
data = createPNChannelMetadata(it)
)
},
onFailure = callback.onFailureHandler()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class GetUUIDMetadataImpl(
onSuccess = callback.onSuccessHandler {
PNUUIDMetadataResult(
status = 200,
data = it?.let { createPNUUIDMetadata(from = it) }
data = createPNUUIDMetadata(it)
)
},
onFailure = callback.onFailureHandler()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class SetUUIDMetadataImpl(
onSuccess = callback.onSuccessHandler {
PNUUIDMetadataResult(
status = 200,
data = it?.let { createPNUUIDMetadata(from = it) }
data = createPNUUIDMetadata(it)
)
},
onFailure = callback.onFailureHandler()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata
import com.pubnub.api.models.consumer.objects.member.PNMember
import com.pubnub.api.models.consumer.objects.membership.PNChannelMembership
import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata
import com.pubnub.api.utils.PatchValue
import kotlinx.cinterop.ExperimentalForeignApi
import platform.Foundation.NSData
import platform.Foundation.NSString
Expand Down Expand Up @@ -39,33 +40,35 @@ internal fun createPubNubHashedPage(from: PNPage?): PubNubHashedPageObjC {
)
}

// TODO: PatchValue should consider cases where there is no response for a given field
@OptIn(ExperimentalForeignApi::class)
internal fun createPNUUIDMetadata(from: PubNubUUIDMetadataObjC): PNUUIDMetadata {
internal fun createPNUUIDMetadata(from: PubNubUUIDMetadataObjC?): PNUUIDMetadata {
return PNUUIDMetadata(
id = from.id(),
name = from.name(),
externalId = from.externalId(),
profileUrl = from.profileUrl(),
email = from.email(),
custom = from.custom()?.safeCast(),
updated = from.updated(),
eTag = from.eTag(),
type = from.type(),
status = from.status()
id = from!!.id(),
name = PatchValue.of(from.name()),
externalId = PatchValue.of(from.externalId()),
profileUrl = PatchValue.of(from.profileUrl()),
email = PatchValue.of(from.email()),
custom = PatchValue.of(from.custom()?.safeCast()),
updated = PatchValue.of(from.updated().orEmpty()),
eTag = PatchValue.of(from.eTag().orEmpty()),
type = PatchValue.of(from.type()),
status = PatchValue.of(from.status())
)
}

// TODO: PatchValue should consider cases where there is no response for a given field
@OptIn(ExperimentalForeignApi::class)
internal fun createPNChannelMetadata(from: PubNubChannelMetadataObjC): PNChannelMetadata {
internal fun createPNChannelMetadata(from: PubNubChannelMetadataObjC?): PNChannelMetadata {
return PNChannelMetadata(
id = from.id(),
name = from.name(),
description = from.descr(),
custom = from.custom()?.safeCast(),
updated = from.updated(),
eTag = from.eTag(),
type = from.type(),
status = from.status()
id = from!!.id(),
name = PatchValue.of(from.name()),
description = PatchValue.of(from.descr()),
custom = PatchValue.of(from.custom()?.safeCast()),
updated = PatchValue.of(from.updated().orEmpty()),
eTag = PatchValue.of(from.eTag().orEmpty()),
type = PatchValue.of(from.type()),
status = PatchValue.of(from.status())
)
}

Expand All @@ -79,34 +82,36 @@ internal fun createObjectSortProperties(from: Collection<PNSortKey<PNKey>>): Lis
}
}

// TODO: PatchValue should consider cases where there is no response for a given field
@OptIn(ExperimentalForeignApi::class)
internal fun createPNChannelMembership(from: PubNubMembershipMetadataObjC): PNChannelMembership {
return PNChannelMembership(
channel = PNChannelMetadata(
id = from.channelMetadataId(),
name = from.channel()?.name(),
description = from.channel()?.descr(),
custom = from.channel()?.custom()?.safeCast(),
updated = from.channel()?.updated(),
eTag = from.channel()?.eTag(),
type = from.channel()?.type(),
status = from.channel()?.status()
name = PatchValue.of(from.channel()?.name()),
description = PatchValue.of(from.channel()?.descr()),
custom = PatchValue.of(from.channel()?.custom()?.safeCast()),
updated = PatchValue.of(from.channel()?.updated().orEmpty()),
eTag = PatchValue.of(from.channel()?.eTag().orEmpty()),
type = PatchValue.of(from.channel()?.type()),
status = PatchValue.of(from.channel()?.status())
),
custom = from.custom()?.safeCast(),
custom = PatchValue.of(from.custom()?.safeCast()),
updated = from.updated().orEmpty(),
eTag = from.eTag().orEmpty(),
status = from.status()
status = PatchValue.of(from.status())
)
}

// TODO: PatchValue should consider cases where there is no response for a given field
@OptIn(ExperimentalForeignApi::class)
internal fun createPNMember(from: PubNubMembershipMetadataObjC): PNMember {
internal fun createPNMember(from: PubNubMembershipMetadataObjC?): PNMember {
return PNMember(
uuid = from.uuid()?.let { createPNUUIDMetadata(from = it) },
custom = from.custom()?.safeCast(),
uuid = createPNUUIDMetadata(from = from!!.uuid()),
custom = PatchValue.of(from.custom()?.safeCast()),
updated = from.updated().orEmpty(),
eTag = from.eTag().orEmpty(),
status = from.status()
status = PatchValue.of(from.status())
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import com.pubnub.api.models.consumer.pubsub.objects.PNSetChannelMetadataEventMe
import com.pubnub.api.models.consumer.pubsub.objects.PNSetMembershipEvent
import com.pubnub.api.models.consumer.pubsub.objects.PNSetMembershipEventMessage
import com.pubnub.api.models.consumer.pubsub.objects.PNSetUUIDMetadataEventMessage
import com.pubnub.api.utils.PatchValue
import com.pubnub.api.v2.PNConfiguration
import com.pubnub.api.v2.callbacks.EventListener
import com.pubnub.api.v2.callbacks.EventListenerImpl
Expand Down Expand Up @@ -192,6 +193,7 @@ private fun createObjectEvent(from: PubNubAppContextEventObjC?): PNObjectEventRe
}
}

// TODO: PatchValue should consider cases where there is no response for a given field
@OptIn(ExperimentalForeignApi::class)
private fun mapAppContextEvent(from: PubNubAppContextEventObjC?): PNObjectEventMessage? {
when (from) {
Expand All @@ -203,15 +205,15 @@ private fun mapAppContextEvent(from: PubNubAppContextEventObjC?): PNObjectEventM
type = from.type(),
data = PNUUIDMetadata(
id = from.metadata().id(),
name = from.metadata().name(),
externalId = from.metadata().externalId(),
profileUrl = from.metadata().profileUrl(),
email = from.metadata().email(),
custom = from.metadata().custom()?.safeCast(),
updated = from.metadata().updated(),
eTag = from.metadata().eTag(),
type = from.metadata().type(),
status = from.metadata().status()
name = PatchValue.of(from.metadata().name()),
externalId = PatchValue.of(from.metadata().externalId()),
profileUrl = PatchValue.of(from.metadata().profileUrl()),
email = PatchValue.of(from.metadata().email()),
custom = PatchValue.of(from.metadata().custom()?.safeCast()),
updated = PatchValue.of(from.metadata().updated().orEmpty()),
eTag = PatchValue.of(from.metadata().eTag().orEmpty()),
type = PatchValue.of(from.metadata().type()),
status = PatchValue.of(from.metadata().status())
)
)
is PubNubRemoveUUIDMetadataResultObjC ->
Expand All @@ -230,13 +232,13 @@ private fun mapAppContextEvent(from: PubNubAppContextEventObjC?): PNObjectEventM
type = from.type(),
data = PNChannelMetadata(
id = from.metadata().id(),
name = from.metadata().name(),
description = from.metadata().descr(),
custom = from.metadata().custom()?.safeCast(),
updated = from.metadata().updated(),
eTag = from.metadata().eTag(),
type = from.metadata().type(),
status = from.metadata().status()
name = PatchValue.of(from.metadata().name()),
description = PatchValue.of(from.metadata().descr()),
custom = PatchValue.of(from.metadata().custom()?.safeCast()),
updated = PatchValue.of(from.metadata().updated().orEmpty()),
eTag = PatchValue.of(from.metadata().eTag().orEmpty()),
type = PatchValue.of(from.metadata().type()),
status = PatchValue.of(from.metadata().status())
)
)
is PubNubRemoveChannelMetadataResultObjC ->
Expand All @@ -256,10 +258,10 @@ private fun mapAppContextEvent(from: PubNubAppContextEventObjC?): PNObjectEventM
data = PNSetMembershipEvent(
channel = from.metadata().channelMetadataId(),
uuid = from.metadata().uuidMetadataId(),
custom = from.metadata().custom()?.safeCast(),
custom = PatchValue.of(from.metadata().custom()?.safeCast()),
eTag = from.metadata().eTag().orEmpty(),
updated = from.metadata().updated().orEmpty(),
status = from.metadata().status().orEmpty()
status = PatchValue.of(from.metadata().status().orEmpty())
)
)
is PubNubRemoveMembershipResultObjC ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ actual interface PubNub {
channel: String,
message: Any,
meta: Any?,
usePost: Boolean,
ttl: Int?
usePost: Boolean
): Publish

actual fun signal(channel: String, message: Any): Signal
Expand Down

0 comments on commit 0e30bb1

Please sign in to comment.