Skip to content

Commit

Permalink
Add support for handling PatchValue in Kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
jguz-pubnub committed Sep 9, 2024
1 parent 6abd60b commit 154fdfa
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Sources/PubNub/KMM/Wrappers/PubNubAppContextEventObjC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ public class PubNubChannelMetadataObjC: NSObject {
@objc public var eTag: String?
@objc public var type: String?
@objc public var status: String?

@objc public var hasName: Bool = false
@objc public var hasDescr: Bool = false
@objc public var hasCustom: Bool = false
@objc public var hasType: Bool = false
@objc public var hasStatus: Bool = false

init(changeset: PubNubChannelMetadataChangeset) {
self.id = changeset.metadataId
Expand All @@ -168,20 +174,26 @@ public class PubNubChannelMetadataObjC: NSObject {
switch keyPath {
case \.name:
self.name = value
self.hasName = true
case \.type:
self.type = value
self.hasType = true
case \.status:
self.status = value
self.hasStatus = true
case \.channelDescription:
self.descr = value
self.hasDescr = true
default:
break
}
case .customOptional(_, let value):
if let value {
self.custom = value.asObjCRepresentable()
self.hasCustom = true
} else {
self.custom = nil
self.hasCustom = true
}
}
}
Expand Down Expand Up @@ -220,6 +232,14 @@ public class PubNubUUIDMetadataObjC: NSObject {
@objc public var eTag: String?
@objc public var type: String?
@objc public var status: String?

@objc public var hasName: Bool = false
@objc public var hasExternalId: Bool = false
@objc public var hasProfileUrl: Bool = false
@objc public var hasEmail: Bool = false
@objc public var hasCustom: Bool = false
@objc public var hasType: Bool = false
@objc public var hasStatus: Bool = false

@objc
public init(
Expand All @@ -244,24 +264,32 @@ public class PubNubUUIDMetadataObjC: NSObject {
switch keyPath {
case \.name:
self.name = value
self.hasName = true
case \.type:
self.type = value
self.hasType = true
case \.status:
self.status = value
self.hasStatus = true
case \.externalId:
self.externalId = value
self.hasExternalId = true
case \.profileURL:
self.profileUrl = value
self.hasProfileUrl = true
case \.email:
self.email = value
self.hasEmail = true
default:
break
}
case .customOptional(_, let value):
if let value {
self.custom = value.asObjCRepresentable()
self.hasCustom = true
} else {
self.custom = nil
self.hasCustom = true
}
}
}
Expand Down

0 comments on commit 154fdfa

Please sign in to comment.