Skip to content

Commit

Permalink
Add support for the type field in PubNubMembershipMetadata (#194)
Browse files Browse the repository at this point in the history
feat(membership): add support for the `type` field in `PubNubMembershipMetadata`

feat(app-context): deprecate methods containing `uuid` parameter,  introduce new versions

feat(app-context): deprecate methods containing the `include` parameter of the `Bool` type, introduce new versions

feat(app-context): deprecate `remove(channel:custom:completion:)`, introduce new version 

feat(app-context): replace `PubNubUUIDMetadata` with `PubNubUserMetadata`

feat(app-context): replace `PubNubUUIDMetadataBase` with `PubNubUserMetadataBase`

feat(app-context): add an alias for backward compatibility with the customer code using `PubNubUUIDMetadata`

feat(app-context): add an alias for backward compatibility with the customer code using `PubNubUUIDMetadataBase`

feat(listeners): replace `PubNubUUIDMetadataChangeset` with `PubNubUserMetadataChangeset`

feat(listeners): add an alias for backward compatibility with the customer code using `PubNubUUIDMetadataChangeset`
  • Loading branch information
jguz-pubnub authored Dec 4, 2024
1 parent 022aa54 commit 7b131fb
Show file tree
Hide file tree
Showing 40 changed files with 1,754 additions and 805 deletions.
27 changes: 25 additions & 2 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@
---
name: swift
scm: github.com/pubnub/swift
version: "8.1.0"
version: "8.2.0"
schema: 1
changelog:
- date: 2024-12-04
version: 8.2.0
changes:
- type: feature
text: "Add support for the Membership `type` field."
- type: feature
text: "Deprecate methods containing `uuid` parameter, introduce new versions."
- type: feature
text: "Deprecate methods containing `include` parameter of `Bool` type, introduce new versions."
- type: feature
text: "Deprecate `remove(channel:custom:completion:)`, introduce new version ."
- type: feature
text: "Replace `PubNubUUIDMetadata` with `PubNubUserMetadata`."
- type: feature
text: "Replace `PubNubUUIDMetadataBase` with `PubNubUserMetadataBase`."
- type: feature
text: "Add an alias for backward compatibility with the customer code using `PubNubUUIDMetadata`."
- type: feature
text: "Add an alias for backward compatibility with the customer code using `PubNubUUIDMetadataBase`."
- type: feature
text: "Replace `PubNubUUIDMetadataChangeset` with `PubNubUserMetadataChangeset`."
- type: feature
text: "Add an alias for backward compatibility with the customer code using `PubNubUUIDMetadataChangeset`."
- date: 2024-11-18
version: 8.1.0
changes:
Expand Down Expand Up @@ -596,7 +619,7 @@ sdks:
- distribution-type: source
distribution-repository: GitHub release
package-name: PubNub
location: https://github.com/pubnub/swift/archive/refs/tags/8.1.0.zip
location: https://github.com/pubnub/swift/archive/refs/tags/8.2.0.zip
supported-platforms:
supported-operating-systems:
macOS:
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ source "https://rubygems.org"

gem "cocoapods"
gem "fastlane"
gem 'rexml', '3.3.8'
gem 'rexml', '3.3.9'
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ GEM
trailblazer-option (>= 0.1.1, < 0.2.0)
uber (< 0.2.0)
retriable (3.1.2)
rexml (3.3.8)
rexml (3.3.9)
rouge (2.0.7)
ruby-macho (2.5.1)
ruby2_keywords (0.0.5)
Expand Down Expand Up @@ -311,7 +311,7 @@ PLATFORMS
DEPENDENCIES
cocoapods
fastlane
rexml (= 3.3.8)
rexml (= 3.3.9)

BUNDLED WITH
2.5.22
52 changes: 26 additions & 26 deletions PubNub.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions PubNubMembership/Sources/Membership+PubNub.swift
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public extension PubNubMembershipInterface {
customFields: nil,
totalCount: false,
changes: .init(
set: users.map { .init(metadataId: $0.user.id, status: $0.status, custom: $0.custom?.flatJSON) },
set: users.map { .init(metadataId: $0.user.id, status: $0.status, type: nil, custom: $0.custom?.flatJSON) },
delete: []
),
filter: nil,
Expand Down Expand Up @@ -387,7 +387,7 @@ public extension PubNubMembershipInterface {
customFields: nil,
totalCount: false,
changes: .init(
set: spaces.map { .init(metadataId: $0.space.id, status: $0.status, custom: $0.custom?.flatJSON) },
set: spaces.map { .init(metadataId: $0.space.id, status: $0.status, type: nil, custom: $0.custom?.flatJSON) },
delete: []
),
filter: nil,
Expand Down Expand Up @@ -451,7 +451,7 @@ public extension PubNubMembershipInterface {
totalCount: false,
changes: .init(
set: [],
delete: userIds.map { .init(metadataId: $0, status: nil, custom: nil) }
delete: userIds.map { .init(metadataId: $0, status: nil, type: nil, custom: nil) }
),
filter: nil,
sort: [],
Expand Down Expand Up @@ -488,7 +488,7 @@ public extension PubNubMembershipInterface {
totalCount: false,
changes: .init(
set: [],
delete: spaceIds.map { .init(metadataId: $0, status: nil, custom: nil) }
delete: spaceIds.map { .init(metadataId: $0, status: nil, type: nil, custom: nil) }
),
filter: nil,
sort: [],
Expand Down
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.ChannelIncludeFields(custom: includeCustom).includeFields,
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.ChannelIncludeFields(custom: includeCustom).includeFields),
configuration: requestConfig.customConfiguration ?? configuration
)

Expand Down Expand Up @@ -265,7 +265,7 @@ public extension PubNubSpaceInterface {
channelDescription: description,
custom: custom?.flatJSON
),
customFields: includeCustom
include: PubNub.ChannelIncludeFields(custom: includeCustom).includeFields
),
configuration: requestConfig.customConfiguration ?? configuration
)
Expand Down
2 changes: 1 addition & 1 deletion PubNubSwift.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'PubNubSwift'
s.version = '8.1.0'
s.version = '8.2.0'
s.homepage = 'https://github.com/pubnub/swift'
s.documentation_url = 'https://www.pubnub.com/docs/swift-native/pubnub-swift-sdk'
s.authors = { 'PubNub, Inc.' => '[email protected]' }
Expand Down
4 changes: 2 additions & 2 deletions PubNubUser/Sources/PubNubUser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ extension PubNubUser: Codable {

// MARK: Object v2 Migration

public extension PubNubUUIDMetadata {
/// Converts Object V2 UUID Metadata to a Space entity
public extension PubNubUserMetadata {
/// Converts Object V2 User Metadata to a User entity
///
/// - returns: The `PubNubUser` built from the Object V2 data
func convert() -> PubNubUser {
Expand Down
18 changes: 9 additions & 9 deletions PubNubUser/Sources/User+PubNub.swift
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ public extension PubNubUserInterface {
requestConfig: PubNub.RequestConfiguration = .init(),
completion: @escaping ((Result<(users: [PubNubUser], next: PubNubHashedPage?), Error>) -> Void)
) {
let router = ObjectsUUIDRouter(
let router = ObjectsUserRouter(
.all(
customFields: includeCustom,
include: PubNub.UserIncludeFields(custom: includeCustom).includeFields,
totalCount: includeTotalCount,
filter: filter,
sort: sort.map { $0.routerParameter },
Expand All @@ -226,7 +226,7 @@ public extension PubNubUserInterface {
completion(result.map { (
users: $0.payload.data,
next: PubNub.Page(next: $0.payload.next, prev: $0.payload.prev, totalCount: $0.payload.totalCount)
) })
)})
}
}

Expand All @@ -236,10 +236,10 @@ public extension PubNubUserInterface {
requestConfig: PubNub.RequestConfiguration = .init(),
completion: @escaping (Result<PubNubUser, Error>) -> Void
) {
let router = ObjectsUUIDRouter(
let router = ObjectsUserRouter(
.fetch(
metadataId: userId ?? (requestConfig.customConfiguration?.uuid ?? configuration.uuid),
customFields: includeCustom
include: PubNub.UserIncludeFields(custom: includeCustom).includeFields
),
configuration: requestConfig.customConfiguration ?? configuration
)
Expand Down Expand Up @@ -268,9 +268,9 @@ public extension PubNubUserInterface {
requestConfig: PubNub.RequestConfiguration = .init(),
completion: ((Result<PubNubUser, Error>) -> Void)?
) {
let router = ObjectsUUIDRouter(
let router = ObjectsUserRouter(
.set(
metadata: PubNubUUIDMetadataBase(
metadata: PubNubUserMetadataBase(
metadataId: userId ?? (requestConfig.customConfiguration?.uuid ?? configuration.uuid),
name: name,
type: type,
Expand All @@ -280,7 +280,7 @@ public extension PubNubUserInterface {
email: email,
custom: custom?.flatJSON
),
customFields: includeCustom
include: PubNub.UserIncludeFields(custom: includeCustom).includeFields
),
configuration: requestConfig.customConfiguration ?? configuration
)
Expand Down Expand Up @@ -329,7 +329,7 @@ public extension PubNubUserInterface {
requestConfig: PubNub.RequestConfiguration = .init(),
completion: ((Result<Void, Error>) -> Void)?
) {
let router = ObjectsUUIDRouter(
let router = ObjectsUserRouter(
.remove(metadataId: userId ?? (requestConfig.customConfiguration?.uuid ?? configuration.uuid)),
configuration: requestConfig.customConfiguration ?? configuration
)
Expand Down
6 changes: 3 additions & 3 deletions PubNubUser/Tests/Test+PubNubUser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class PubNubUserModelTests: XCTestCase {
}

func testPubNubUser_Convert_UUIDMetadata() {
let userMetadata = PubNubUUIDMetadataBase(
let userMetadata = PubNubUserMetadataBase(
metadataId: testUser.id,
name: testUser.name,
type: testUser.type,
Expand All @@ -120,7 +120,7 @@ class PubNubUserModelTests: XCTestCase {
}

func testPubNubUser_Convert_UUIDMetadata_nilProfileUrl() {
let userMetadata = PubNubUUIDMetadataBase(
let userMetadata = PubNubUserMetadataBase(
metadataId: testUser.id,
name: testUser.name,
type: testUser.type,
Expand All @@ -140,7 +140,7 @@ class PubNubUserModelTests: XCTestCase {
}

func testPubNubUser_Convert_UUIDMetadata_nilCustom() {
let userMetadata = PubNubUUIDMetadataBase(
let userMetadata = PubNubUserMetadataBase(
metadataId: testUser.id,
name: testUser.name,
type: testUser.type,
Expand Down
24 changes: 12 additions & 12 deletions PubNubUser/Tests/Test+PubNubUserInterface.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class PubNubUserInterfaceTests: XCTestCase {
func testUser_FetchUsers() {
let expectation = XCTestExpectation(description: "Fetch Users API")

let testRouterEndpoint = ObjectsUUIDRouter.Endpoint.all(
let testRouterEndpoint = ObjectsUserRouter.Endpoint.all(
customFields: true,
totalCount: true,
filter: nil,
Expand All @@ -113,7 +113,7 @@ class PubNubUserInterfaceTests: XCTestCase {

// Validate Inputs
mockSession.validateRouter = { router in
XCTAssertEqual(testRouterEndpoint, (router as? ObjectsUUIDRouter)?.endpoint)
XCTAssertEqual(testRouterEndpoint, (router as? ObjectsUserRouter)?.endpoint)
}

// Provide Output
Expand Down Expand Up @@ -141,14 +141,14 @@ class PubNubUserInterfaceTests: XCTestCase {
func testUser_FetchUser_ConfigUserId() {
let expectation = XCTestExpectation(description: "Fetch User API")

let testRouterEndpoint = ObjectsUUIDRouter.Endpoint.fetch(
let testRouterEndpoint = ObjectsUserRouter.Endpoint.fetch(
metadataId: pubnub.configuration.userId,
customFields: true
)

// Validate Inputs
mockSession.validateRouter = { router in
XCTAssertEqual(testRouterEndpoint, (router as? ObjectsUUIDRouter)?.endpoint)
XCTAssertEqual(testRouterEndpoint, (router as? ObjectsUserRouter)?.endpoint)
}

// Provide Output
Expand All @@ -173,8 +173,8 @@ class PubNubUserInterfaceTests: XCTestCase {
func testUser_CreateUser() {
let expectation = XCTestExpectation(description: "Fetch User API")

let testRouterEndpoint = ObjectsUUIDRouter.Endpoint.set(
metadata: PubNubUUIDMetadataBase(
let testRouterEndpoint = ObjectsUserRouter.Endpoint.set(
metadata: PubNubUserMetadataBase(
metadataId: pubnub.configuration.userId,
name: testUser.name,
type: testUser.type,
Expand All @@ -191,7 +191,7 @@ class PubNubUserInterfaceTests: XCTestCase {

// Validate Inputs
mockSession.validateRouter = { router in
XCTAssertEqual(testRouterEndpoint, (router as? ObjectsUUIDRouter)?.endpoint)
XCTAssertEqual(testRouterEndpoint, (router as? ObjectsUserRouter)?.endpoint)
}

// Provide Output
Expand Down Expand Up @@ -227,8 +227,8 @@ class PubNubUserInterfaceTests: XCTestCase {
func testUser_UpdateUser() {
let expectation = XCTestExpectation(description: "Fetch User API")

let testRouterEndpoint = ObjectsUUIDRouter.Endpoint.set(
metadata: PubNubUUIDMetadataBase(
let testRouterEndpoint = ObjectsUserRouter.Endpoint.set(
metadata: PubNubUserMetadataBase(
metadataId: pubnub.configuration.userId,
name: testUser.name,
type: testUser.type,
Expand All @@ -245,7 +245,7 @@ class PubNubUserInterfaceTests: XCTestCase {

// Validate Inputs
mockSession.validateRouter = { router in
XCTAssertEqual(testRouterEndpoint, (router as? ObjectsUUIDRouter)?.endpoint)
XCTAssertEqual(testRouterEndpoint, (router as? ObjectsUserRouter)?.endpoint)
}

// Provide Output
Expand Down Expand Up @@ -281,13 +281,13 @@ class PubNubUserInterfaceTests: XCTestCase {
func testUser_RemoveUser() {
let expectation = XCTestExpectation(description: "Fetch User API")

let testRouterEndpoint = ObjectsUUIDRouter.Endpoint.remove(
let testRouterEndpoint = ObjectsUserRouter.Endpoint.remove(
metadataId: pubnub.configuration.uuid
)

// Validate Inputs
mockSession.validateRouter = { router in
XCTAssertEqual(testRouterEndpoint, (router as? ObjectsUUIDRouter)?.endpoint)
XCTAssertEqual(testRouterEndpoint, (router as? ObjectsUserRouter)?.endpoint)
}

// Provide Output
Expand Down
Loading

0 comments on commit 7b131fb

Please sign in to comment.