Skip to content

Commit

Permalink
Fix in other targets
Browse files Browse the repository at this point in the history
  • Loading branch information
jguz-pubnub committed Nov 19, 2024
1 parent 100b6c9 commit f2028d5
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 8 deletions.
6 changes: 3 additions & 3 deletions PubNubSpace/Sources/Space+PubNub.swift
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public extension PubNubSpaceInterface {
) {
let router = ObjectsChannelRouter(
.all(
customFields: includeCustom,
include: PubNub.IncludeFields(custom: includeCustom).channelIncludeFields,
totalCount: includeTotalCount,
filter: filter,
sort: sort.map { $0.routerParameter },
Expand Down Expand Up @@ -229,7 +229,7 @@ public extension PubNubSpaceInterface {
completion: @escaping (Result<PubNubSpace, Error>) -> Void
) {
let router = ObjectsChannelRouter(
.fetch(metadataId: spaceId, customFields: includeCustom),
.fetch(metadataId: spaceId, include: PubNub.IncludeFields(custom: includeCustom).channelIncludeFields),
configuration: requestConfig.customConfiguration ?? configuration
)

Expand Down Expand Up @@ -265,7 +265,7 @@ public extension PubNubSpaceInterface {
channelDescription: description,
custom: custom?.flatJSON
),
customFields: includeCustom
include: PubNub.IncludeFields(custom: includeCustom).channelIncludeFields
),
configuration: requestConfig.customConfiguration ?? configuration
)
Expand Down
6 changes: 3 additions & 3 deletions PubNubUser/Sources/User+PubNub.swift
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public extension PubNubUserInterface {
) {
let router = ObjectsUUIDRouter(
.all(
customFields: includeCustom,
include: PubNub.IncludeFields(custom: includeCustom).uuidIncludeFields,
totalCount: includeTotalCount,
filter: filter,
sort: sort.map { $0.routerParameter },
Expand Down Expand Up @@ -239,7 +239,7 @@ public extension PubNubUserInterface {
let router = ObjectsUUIDRouter(
.fetch(
metadataId: userId ?? (requestConfig.customConfiguration?.uuid ?? configuration.uuid),
customFields: includeCustom
include: PubNub.IncludeFields(custom: includeCustom).uuidIncludeFields
),
configuration: requestConfig.customConfiguration ?? configuration
)
Expand Down Expand Up @@ -280,7 +280,7 @@ public extension PubNubUserInterface {
email: email,
custom: custom?.flatJSON
),
customFields: includeCustom
include: PubNub.IncludeFields(custom: includeCustom).uuidIncludeFields
),
configuration: requestConfig.customConfiguration ?? configuration
)
Expand Down
4 changes: 2 additions & 2 deletions Sources/PubNub/APIs/Objects+PubNub.swift
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public extension PubNub {
self.totalCount = totalCount
}

var uuidIncludeFields: [ObjectsUUIDRouter.Include]? {
public var uuidIncludeFields: [ObjectsUUIDRouter.Include]? {
var includes = [ObjectsUUIDRouter.Include]()

if customFields { includes.append(.custom) }
Expand All @@ -230,7 +230,7 @@ public extension PubNub {
return includes.isEmpty ? nil : includes
}

var channelIncludeFields: [ObjectsChannelRouter.Include]? {
public var channelIncludeFields: [ObjectsChannelRouter.Include]? {
var includes = [ObjectsChannelRouter.Include]()

if customFields { includes.append(.custom) }
Expand Down
71 changes: 71 additions & 0 deletions Tests/PubNubTests/Integration/SubscriptionIntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -444,4 +444,75 @@ class SubscriptionIntegrationTests: XCTestCase {

wait(for: [expectation], timeout: 5.0)
}

func testMembership() {
let expectation = XCTestExpectation(description: "Description")
expectation.assertForOverFulfill = true
expectation.expectedFulfillmentCount = 1

let config = PubNubConfiguration(
publishKey: "pub-c-f210bade-4506-4b99-b572-888bddc01d75",
subscribeKey: "sub-c-9822b8a7-80eb-4320-a2fb-d88d1f37e284",
userId: "JG"
)
let pubnub = PubNub(
configuration: config
)

pubnub.set(uuid: PubNubUUIDMetadataBase(metadataId: "JG", name: "JG")) { [unowned pubnub] in
switch $0 {
case let .success(uuid):
pubnub.set(channel: PubNubChannelMetadataBase(metadataId: "JG-CHANNEL")) {
switch $0 {
case let .success(channel):
pubnub.setMemberships(
uuid: "JG",
channels: [PubNubMembershipMetadataBase(uuidMetadataId: "JG", channelMetadataId: "JG-CHANNEL", status: "mystatus", type: "mytype")],
include: .init(statusField: true, typeField: true)
) {
switch $0 {
case let .success((memberships, pages)):
expectation.fulfill()
case let .failure(error):
XCTFail("Unexpected condition")
}
}
case let .failure(error):
XCTFail("Unexpected condition")
}
}
case let .failure(error):
XCTFail("Unexpected condition")
}
}

wait(for: [expectation], timeout: 100)
}

func testMembership2() {
let expectation = XCTestExpectation(description: "Description")
expectation.assertForOverFulfill = true
expectation.expectedFulfillmentCount = 1

let config = PubNubConfiguration(
publishKey: "pub-c-f210bade-4506-4b99-b572-888bddc01d75",
subscribeKey: "sub-c-9822b8a7-80eb-4320-a2fb-d88d1f37e284",
userId: "JG"
)
let pubnub = PubNub(
configuration: config
)

pubnub.fetchMemberships(uuid: "JG", include: .init(statusField: true, typeField: true)) {
switch $0 {
case let .success((memberships, page)):
debugPrint("!")
expectation.fulfill()
case let .failure(error):
XCTFail("Unexpected condition")
}
}

wait(for: [expectation], timeout: 100)
}
}

0 comments on commit f2028d5

Please sign in to comment.