Skip to content

Commit

Permalink
Commonize CustomObject handling for JS/iOS (#315)
Browse files Browse the repository at this point in the history
Removes separate CustomObject implementations from JS and iOS sourcesets and creates a common one in `nonJvm` sourceset.
  • Loading branch information
wkal-pubnub authored Nov 27, 2024
1 parent effb8a9 commit 4e27a06
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import platform.Foundation.NSData
import platform.Foundation.NSInputStream
import platform.Foundation.NSURL

actual class CustomObject(val value: Any)

actual abstract class Uploadable

data class DataUploadContent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,3 @@ actual fun createStatusListener(
onStatusChange = onStatus
)
}

actual fun createCustomObject(map: Map<String, Any?>): CustomObject {
return CustomObject(map)
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package com.pubnub.kmp

actual typealias CustomObject = CustomObjectImpl

class CustomObjectImpl(map: Map<String, Any?> = emptyMap()) : Map<String, Any?> by map

actual abstract class Uploadable(val fileInput: Any)

class UploadableImpl(fileInput: Any) : Uploadable(fileInput)
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,3 @@ actual fun createStatusListener(
}
return listener
}

actual fun createCustomObject(map: Map<String, Any?>): CustomObject {
return CustomObjectImpl(map)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.pubnub.kmp

actual class CustomObject(val value: Map<String, Any?> = emptyMap()) : Map<String, Any?> by value
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.pubnub.kmp

actual fun createCustomObject(map: Map<String, Any?>): CustomObject {
return CustomObject(map)
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ actual fun createPNConfiguration(
this.authKey = NO_AUTH_KEY
this.secretKey = secretKey.orEmpty()
this.logVerbosity = logVerbosity
this.authToken = authToken.orEmpty()
this.authToken = authToken
}.build()
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class FetchMessagesEndpoint internal constructor(
internal const val INCLUDE_MESSAGE_TYPE_QUERY_PARAM = "include_message_type"
private const val INCLUDE_CUSTOM_MESSAGE_TYPE = "include_custom_message_type"


internal fun effectiveMax(
maximumPerChannel: Int?,
includeMessageActions: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class PublishEndpoint internal constructor(
* @param queryParams hashMap to add parameters
*/
private fun addQueryParams(queryParams: MutableMap<String, String>) {
meta?.let { queryParams["meta"] = pubnub.mapper.toJson(it) }
meta?.let { queryParams["meta"] = pubnub.mapper.toJson(it) }
shouldStore?.let { queryParams["store"] = it.numericString }
ttl?.let { queryParams["ttl"] = it.toString() }
if (!replicate) {
Expand Down
5 changes: 2 additions & 3 deletions pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ kotlin {
defaultConfigs {
val testProps = Properties()
try {
rootProject.file("test.properties").inputStream().use {
testProps.load(it)
}
val bytes = providers.fileContents(rootProject.layout.projectDirectory.file("test.properties")).asBytes.get()
testProps.load(bytes.inputStream())
} catch (e: Exception) {
println("No test.properties found in root project. Trying to get keys from env")
try {
Expand Down

0 comments on commit 4e27a06

Please sign in to comment.