-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Kotlin] Change PNChannelMetadata and PNUUIDMetadata to contain parti…
…al update information (#266) * Add partial updates when querying channel metadata * Add partial updates when querying user metadata * Deprecate TTL parameter in PubNub.fire()
- Loading branch information
1 parent
3e82af3
commit f5d37b8
Showing
27 changed files
with
429 additions
and
227 deletions.
There are no files selected for viewing
33 changes: 25 additions & 8 deletions
33
...src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadata.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,29 @@ | ||
package com.pubnub.api.models.consumer.objects.channel | ||
|
||
import com.pubnub.api.utils.PatchValue | ||
|
||
data class PNChannelMetadata( | ||
val id: String, | ||
val name: String?, | ||
val description: String?, | ||
val custom: Map<String, Any?>?, | ||
val updated: String?, | ||
val eTag: String?, | ||
val type: String?, | ||
val status: String?, | ||
) | ||
val name: PatchValue<String?>? = null, | ||
val description: PatchValue<String?>? = null, | ||
val custom: PatchValue<Map<String, Any?>?>? = null, | ||
val updated: PatchValue<String>? = null, | ||
val eTag: PatchValue<String>? = null, | ||
val type: PatchValue<String?>? = null, | ||
val status: PatchValue<String?>? = null, | ||
) { | ||
/** | ||
* Merge information from this `PNChannelMetadata` with new data from `update`, returning a new `PNChannelMetadata` instance. | ||
*/ | ||
operator fun plus(update: PNChannelMetadata): PNChannelMetadata { | ||
return copy( | ||
name = update.name ?: name, | ||
description = update.description ?: description, | ||
custom = update.custom ?: custom, | ||
updated = update.updated ?: updated, | ||
eTag = update.eTag ?: eTag, | ||
type = update.type ?: type, | ||
status = update.status ?: status, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 30 additions & 10 deletions
40
...e-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadata.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,34 @@ | ||
package com.pubnub.api.models.consumer.objects.uuid | ||
|
||
import com.pubnub.api.utils.PatchValue | ||
|
||
// TODO add a test that checks sending patch values to server and reading them back when we have the "sending" part | ||
data class PNUUIDMetadata( | ||
val id: String, | ||
val name: String?, | ||
val externalId: String?, | ||
val profileUrl: String?, | ||
val email: String?, | ||
val custom: Map<String, Any?>?, | ||
val updated: String?, | ||
val eTag: String?, | ||
val type: String?, | ||
val status: String?, | ||
) | ||
val name: PatchValue<String?>? = null, | ||
val externalId: PatchValue<String?>? = null, | ||
val profileUrl: PatchValue<String?>? = null, | ||
val email: PatchValue<String?>? = null, | ||
val custom: PatchValue<Map<String, Any?>?>? = null, | ||
val updated: PatchValue<String>? = null, | ||
val eTag: PatchValue<String>? = null, | ||
val type: PatchValue<String?>? = null, | ||
val status: PatchValue<String?>? = null, | ||
) { | ||
/** | ||
* Merge information from this `PNUUIDMetadata` with new data from `update`, returning a new `PNUUIDMetadata` instance. | ||
*/ | ||
operator fun plus(update: PNUUIDMetadata): PNUUIDMetadata { | ||
return copy( | ||
name = update.name ?: name, | ||
externalId = update.externalId ?: externalId, | ||
profileUrl = update.profileUrl ?: profileUrl, | ||
email = update.email ?: email, | ||
custom = update.custom ?: custom, | ||
updated = update.updated ?: updated, | ||
eTag = update.eTag ?: eTag, | ||
type = update.type ?: type, | ||
status = update.status ?: status, | ||
) | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/utils/PatchValue.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.pubnub.api.utils | ||
|
||
/** | ||
* An optional that accepts nullable values. Thus, it can represent two (`PatchValue<T>`) or three (`PatchValue<T>?`) states: | ||
* * `PatchValue.of(someValue)` - value is present and that value is `someValue` | ||
* * `PatchValue.of(null)` - value is present and that value is `null` | ||
* * `null` - lack of information about value (no update for this field) | ||
*/ | ||
data class PatchValue<out T> internal constructor(val value: T) { | ||
companion object { | ||
/** | ||
* Create an optional with the specified value (which can be null). | ||
*/ | ||
@JvmStatic | ||
fun <T> of(value: T): PatchValue<T> = PatchValue(value) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.