diff --git a/.pubnub.yml b/.pubnub.yml index d8120da65..f0997cff7 100644 --- a/.pubnub.yml +++ b/.pubnub.yml @@ -1,9 +1,9 @@ name: kotlin -version: 10.2.1 +version: 10.3.0 schema: 1 scm: github.com/pubnub/kotlin files: - - build/libs/pubnub-kotlin-10.2.1-all.jar + - build/libs/pubnub-kotlin-10.3.0-all.jar sdks: - type: library @@ -23,8 +23,8 @@ sdks: - distribution-type: library distribution-repository: maven - package-name: pubnub-kotlin-10.2.1 - location: https://repo.maven.apache.org/maven2/com/pubnub/pubnub-kotlin/10.2.1/pubnub-kotlin-10.2.1.jar + package-name: pubnub-kotlin-10.3.0 + location: https://repo.maven.apache.org/maven2/com/pubnub/pubnub-kotlin/10.3.0/pubnub-kotlin-10.3.0.jar supported-platforms: supported-operating-systems: Android: @@ -114,6 +114,11 @@ sdks: license-url: https://www.apache.org/licenses/LICENSE-2.0.txt is-required: Required changelog: + - date: 2024-12-05 + version: v10.3.0 + changes: + - type: feature + text: "Added type aka. membershipType to Memberships and ChannelMembers APIs. Added also a way to specify optional data being added to the response for Membership and ChannelMembers APIs." - date: 2024-12-03 version: v10.2.1 changes: diff --git a/CHANGELOG.md b/CHANGELOG.md index 6df6e4439..39b623f5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## v10.3.0 +December 05 2024 + +#### Added +- Added type aka. membershipType to Memberships and ChannelMembers APIs. Added also a way to specify optional data being added to the response for Membership and ChannelMembers APIs. + ## v10.2.1 December 03 2024 diff --git a/README.md b/README.md index 440ff75c1..e8dc8c5cb 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ You will need the publish and subscribe keys to authenticate your app. Get your com.pubnub pubnub-kotlin - 10.2.1 + 10.3.0 ``` diff --git a/gradle.properties b/gradle.properties index aad1df2cd..6af73796b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,7 +18,7 @@ RELEASE_SIGNING_ENABLED=true SONATYPE_HOST=DEFAULT SONATYPE_AUTOMATIC_RELEASE=false GROUP=com.pubnub -VERSION_NAME=10.2.1 +VERSION_NAME=10.3.0 POM_PACKAGING=jar POM_NAME=PubNub SDK diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/member/MemberInclude.kt b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/member/MemberInclude.kt index d7617f6ff..937a8e0e8 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/member/MemberInclude.kt +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/member/MemberInclude.kt @@ -1,11 +1,25 @@ package com.pubnub.api.java.models.consumer.objects_api.member +/** + * Represents the options for including additional details in member-related operations. + * + * This interface extends [com.pubnub.api.models.consumer.objects.member.MemberInclude] + * and provides a flexible builder pattern to configure the desired inclusion options. + */ interface MemberInclude : com.pubnub.api.models.consumer.objects.member.MemberInclude { companion object { + /** + * Creates a new [Builder] for constructing a [MemberInclude] instance. + * + * @return a new [Builder] instance. + */ @JvmStatic fun builder() = Builder() } + /** + * Builder class for configuring and creating instances of [MemberInclude]. + */ class Builder internal constructor() { var includeCustom: Boolean = false var includeStatus: Boolean = false @@ -16,46 +30,99 @@ interface MemberInclude : com.pubnub.api.models.consumer.objects.member.MemberIn var includeUserType: Boolean = false var includeUserStatus: Boolean = false + /** + * Specifies whether to include custom data in the member data. + * + * @param includeCustom `true` to include custom fields, `false` otherwise. + * @return the current [Builder] instance. + */ fun includeCustom(includeCustom: Boolean): Builder { this.includeCustom = includeCustom return this } + /** + * Specifies whether to include the status of the member. + * + * @param includeStatus `true` to include status, `false` otherwise. + * @return the current [Builder] instance. + */ fun includeStatus(includeStatus: Boolean): Builder { this.includeStatus = includeStatus return this } + /** + * Specifies whether to include the type of the member. + * + * @param includeType `true` to include type, `false` otherwise. + * @return the current [Builder] instance. + */ fun includeType(includeType: Boolean): Builder { this.includeType = includeType return this } + /** + * Specifies whether to include the total count of members. + * + * @param includeTotalCount `true` to include the total count, `false` otherwise. + * @return the current [Builder] instance. + */ fun includeTotalCount(includeTotalCount: Boolean): Builder { this.includeTotalCount = includeTotalCount return this } + /** + * Specifies whether to include user information in the member data. + * + * @param includeUser `true` to include user information, `false` otherwise. + * @return the current [Builder] instance. + */ fun includeUser(includeUser: Boolean): Builder { this.includeUser = includeUser return this } + /** + * Specifies whether to include custom fields for the user in the member data. + * + * @param includeUserCustom `true` to include user custom fields, `false` otherwise. + * @return the current [Builder] instance. + */ fun includeUserCustom(includeUserCustom: Boolean): Builder { this.includeUserCustom = includeUserCustom return this } + /** + * Specifies whether to include the type of the user in the member data. + * + * @param includeUserType `true` to include user type, `false` otherwise. + * @return the current [Builder] instance. + */ fun includeUserType(includeUserType: Boolean): Builder { this.includeUserType = includeUserType return this } + /** + * Specifies whether to include the status of the user in the member data. + * + * @param includeUserStatus `true` to include user status, `false` otherwise. + * @return the current [Builder] instance. + */ fun includeUserStatus(includeUserStatus: Boolean): Builder { this.includeUserStatus = includeUserStatus return this } + /** + * Builds and returns a new [MemberInclude] instance with the configured options. + * + * @return a new [MemberInclude] instance. + */ fun build(): MemberInclude { return object : MemberInclude { override val includeCustom: Boolean = this@Builder.includeCustom diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/membership/MembershipInclude.kt b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/membership/MembershipInclude.kt index e4df62ced..64a0c8ce6 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/membership/MembershipInclude.kt +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/membership/MembershipInclude.kt @@ -1,11 +1,25 @@ package com.pubnub.api.java.models.consumer.objects_api.membership +/** + * Represents the options for including additional details in membership-related operations. + * + * This interface extends [com.pubnub.api.models.consumer.objects.membership.MembershipInclude] + * and provides a flexible builder pattern to configure the desired inclusion options. + */ interface MembershipInclude : com.pubnub.api.models.consumer.objects.membership.MembershipInclude { companion object { + /** + * Creates a new [Builder] for constructing a [MembershipInclude] instance. + * + * @return a new [Builder] instance. + */ @JvmStatic fun builder() = Builder() } + /** + * Builder class for configuring and creating instances of [MembershipInclude]. + */ class Builder internal constructor() { var includeCustom: Boolean = false var includeStatus: Boolean = false @@ -16,46 +30,99 @@ interface MembershipInclude : com.pubnub.api.models.consumer.objects.membership. var includeChannelType: Boolean = false var includeChannelStatus: Boolean = false + /** + * Specifies whether to include custom fields in the membership data. + * + * @param includeCustom `true` to include custom data, `false` otherwise. + * @return the current [Builder] instance. + */ fun includeCustom(includeCustom: Boolean): Builder { this.includeCustom = includeCustom return this } + /** + * Specifies whether to include the status of the membership. + * + * @param includeStatus `true` to include status, `false` otherwise. + * @return the current [Builder] instance. + */ fun includeStatus(includeStatus: Boolean): Builder { this.includeStatus = includeStatus return this } + /** + * Specifies whether to include the type of the membership. + * + * @param includeType `true` to include type, `false` otherwise. + * @return the current [Builder] instance. + */ fun includeType(includeType: Boolean): Builder { this.includeType = includeType return this } + /** + * Specifies whether to include the total count of memberships. + * + * @param includeTotalCount `true` to include the total count, `false` otherwise. + * @return the current [Builder] instance. + */ fun includeTotalCount(includeTotalCount: Boolean): Builder { this.includeTotalCount = includeTotalCount return this } + /** + * Specifies whether to include channel information in the membership data. + * + * @param includeChannel `true` to include channel information, `false` otherwise. + * @return the current [Builder] instance. + */ fun includeChannel(includeChannel: Boolean): Builder { this.includeChannel = includeChannel return this } + /** + * Specifies whether to include custom data for the channel in the membership data. + * + * @param includeChannelCustom `true` to include channel custom fields, `false` otherwise. + * @return the current [Builder] instance. + */ fun includeChannelCustom(includeChannelCustom: Boolean): Builder { this.includeChannelCustom = includeChannelCustom return this } + /** + * Specifies whether to include the type of the channel in the membership data. + * + * @param includeChannelType `true` to include channel type, `false` otherwise. + * @return the current [Builder] instance. + */ fun includeChannelType(includeChannelType: Boolean): Builder { this.includeChannelType = includeChannelType return this } + /** + * Specifies whether to include the status of the channel in the membership data. + * + * @param includeChannelStatus `true` to include channel status, `false` otherwise. + * @return the current [Builder] instance. + */ fun includeChannelStatus(includeChannelStatus: Boolean): Builder { this.includeChannelStatus = includeChannelStatus return this } + /** + * Builds and returns a new [MembershipInclude] instance with the configured options. + * + * @return a new [MembershipInclude] instance. + */ fun build(): MembershipInclude { return object : MembershipInclude { override val includeCustom: Boolean = this@Builder.includeCustom diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/members/ManageChannelMembersImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/members/ManageChannelMembersImpl.java index 83934c095..c4a7fda8e 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/members/ManageChannelMembersImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/members/ManageChannelMembersImpl.java @@ -46,7 +46,7 @@ public class ManageChannelMembersImpl extends DelegatingEndpoint uuidsToSet; // deprecated private Collection uuidsToRemove; // deprecated private Collection usersToSet; - private List usersIdsToRemove; + private List userIdsToRemove; private MemberInclude include; @Deprecated @@ -57,11 +57,11 @@ public ManageChannelMembersImpl(String channel, Collection uuidsToSet, C this.uuidsToRemove = uuidsToRemove; } - public ManageChannelMembersImpl(final PubNub pubnubInstance, String channel, Collection usersToSet, Collection usersIdsToRemove) { + public ManageChannelMembersImpl(final PubNub pubnubInstance, String channel, Collection usersToSet, Collection userIdsToRemove) { super(pubnubInstance); this.channel = channel; this.usersToSet = usersToSet; - this.usersIdsToRemove = new ArrayList<>(usersIdsToRemove); + this.userIdsToRemove = new ArrayList<>(userIdsToRemove); } @NotNull @@ -77,9 +77,9 @@ protected Endpoint createRemoteAction() { List toRemove; // new API use - if (usersToSet != null || usersIdsToRemove != null) { + if (usersToSet != null || userIdsToRemove != null) { toSet = createMemberInputFromUserToSet(); - toRemove = usersIdsToRemove; + toRemove = userIdsToRemove; } else { // old API used toSet = createMemberInputFromUUIDToSet(); toRemove = createUserIdsFromUUIDToRemove(); diff --git a/pubnub-kotlin/pubnub-kotlin-api/config/ktlint/baseline.xml b/pubnub-kotlin/pubnub-kotlin-api/config/ktlint/baseline.xml index 48f5566e5..73f3810db 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/config/ktlint/baseline.xml +++ b/pubnub-kotlin/pubnub-kotlin-api/config/ktlint/baseline.xml @@ -1,10 +1,10 @@ - + - + diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/MemberInclude.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/MemberInclude.kt index 75e85be53..ac252ffe1 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/MemberInclude.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/MemberInclude.kt @@ -1,5 +1,22 @@ package com.pubnub.api.models.consumer.objects.member +/** + * Factory function to create an instance of [MemberInclude]. + * + * This function provides default values for all inclusion flags and returns an + * implementation of the [MemberInclude] interface with the specified options. + * + * @param includeCustom Whether to include custom properties in the result. Default is `false`. + * @param includeStatus Whether to include the status of the Members in the result. Default is `false`. + * @param includeType Whether to include the type of the Members in the result. Default is `false`. + * @param includeTotalCount Whether to include the total count of Members in the result. Default is `false`. + * @param includeUser Whether to include user information in the result. Default is `false`. + * @param includeUserCustom Whether to include custom properties of the user in the result. Default is `false`. + * @param includeUserType Whether to include the type of the user in the result. Default is `false`. + * @param includeUserStatus Whether to include the status of the user in the result. Default is `false`. + * + * @return An instance of [MemberInclude] with the specified inclusion options. + */ fun MemberInclude( includeCustom: Boolean = false, includeStatus: Boolean = false, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/MembershipInclude.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/MembershipInclude.kt index ead05909e..592e05841 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/MembershipInclude.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/MembershipInclude.kt @@ -1,5 +1,22 @@ package com.pubnub.api.models.consumer.objects.membership +/** + * Factory function to create an instance of [MembershipInclude]. + * + * This function provides default values for all inclusion flags and returns an + * implementation of the [MembershipInclude] interface with the specified options. + * + * @param includeCustom Whether to include custom properties in the result. Default is `false`. + * @param includeStatus Whether to include the status of the Memberships in the result. Default is `false`. + * @param includeType Whether to include the type of the Memberships in the result. Default is `false`. + * @param includeTotalCount Whether to include the total count of Memberships in the result. Default is `false`. + * @param includeChannel Whether to include channel information in the result. Default is `false`. + * @param includeChannelCustom Whether to include custom properties of the channel in the result. Default is `false`. + * @param includeChannelType Whether to include the type of the channel in the result. Default is `false`. + * @param includeChannelStatus Whether to include the status of the channel in the result. Default is `false`. + * + * @return An instance of [MembershipInclude] with the specified inclusion options. + */ fun MembershipInclude( includeCustom: Boolean = false, includeStatus: Boolean = false, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt index f714f7e7a..27a9901d8 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt @@ -1868,7 +1868,7 @@ actual interface PubNub : StatusEmitter, EventEmitter { * * @param channel Channel name * @param usersToSet Collection of members to add to the channel. @see [com.pubnub.api.models.consumer.objects.member.PNMember.Partial] - * @param usersToRemove Members to remove from channel. + * @param userIdsToRemove Members to remove from channel. * @param limit Number of objects to return in the response. * Default is 100, which is also the maximum value. * Set limit to 0 (zero) and includeCount to true if you want to retrieve only a result count. @@ -1886,7 +1886,7 @@ actual interface PubNub : StatusEmitter, EventEmitter { fun manageChannelMembers( channel: String, usersToSet: Collection, - usersToRemove: Collection, + userIdsToRemove: Collection, limit: Int? = null, page: PNPage? = null, filter: String? = null, diff --git a/pubnub-kotlin/pubnub-kotlin-core-api/config/ktlint/baseline.xml b/pubnub-kotlin/pubnub-kotlin-core-api/config/ktlint/baseline.xml index 981420778..d9e947930 100644 --- a/pubnub-kotlin/pubnub-kotlin-core-api/config/ktlint/baseline.xml +++ b/pubnub-kotlin/pubnub-kotlin-core-api/config/ktlint/baseline.xml @@ -1,3 +1,6 @@ + + + diff --git a/pubnub-kotlin/pubnub-kotlin-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/MemberInclude.kt b/pubnub-kotlin/pubnub-kotlin-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/MemberInclude.kt index a6e60be11..8a52d666c 100644 --- a/pubnub-kotlin/pubnub-kotlin-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/MemberInclude.kt +++ b/pubnub-kotlin/pubnub-kotlin-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/MemberInclude.kt @@ -1,15 +1,51 @@ package com.pubnub.api.models.consumer.objects.member +/** + * Base interface defining options to include additional data when using Memberships API and ChannelMembers. + */ interface Include { + /** + * Whether to include custom data of the Membership in the result. + */ val includeCustom: Boolean + + /** + * Whether to include the status of the Membership in the result. + */ val includeStatus: Boolean + + /** + * Whether to include the type of the Membership in the result. + */ val includeType: Boolean + + /** + * Whether to include the total count of Memberships in the result. + */ val includeTotalCount: Boolean } +/** + * Interface representing options to include additional data when using Channel Members API. + */ interface MemberInclude : Include { + /** + * Whether to include user information in the result. + */ val includeUser: Boolean + + /** + * Whether to include custom properties of the user in the result. + */ val includeUserCustom: Boolean + + /** + * Whether to include the type of the user in the result. + */ val includeUserType: Boolean + + /** + * Whether to include the status of the user in the result. + */ val includeUserStatus: Boolean } diff --git a/pubnub-kotlin/pubnub-kotlin-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/MembershipInclude.kt b/pubnub-kotlin/pubnub-kotlin-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/MembershipInclude.kt index a87527f09..49f82f30a 100644 --- a/pubnub-kotlin/pubnub-kotlin-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/MembershipInclude.kt +++ b/pubnub-kotlin/pubnub-kotlin-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/MembershipInclude.kt @@ -2,9 +2,28 @@ package com.pubnub.api.models.consumer.objects.membership import com.pubnub.api.models.consumer.objects.member.Include +/** + * Interface representing options to include additional data when using Memberships API. + */ interface MembershipInclude : Include { + + /** + * Whether to include channel information in the result. + */ val includeChannel: Boolean + + /** + * Whether to include custom properties of the channel in the result. + */ val includeChannelCustom: Boolean + + /** + * Whether to include the type of the channel in the result. + */ val includeChannelType: Boolean + + /** + * Whether to include the status of the channel in the result. + */ val includeChannelStatus: Boolean } diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/ObjectsIntegrationTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/ObjectsIntegrationTest.kt index 53ec5c7da..79ac31f12 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/ObjectsIntegrationTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/ObjectsIntegrationTest.kt @@ -540,11 +540,8 @@ class ObjectsIntegrationTest : BaseIntegrationTest() { pubnub.manageChannelMembers( channel = channel, usersToSet = listOf(PNMember.Partial(uuidId = testUserId01, status = status01, type = type01)), - usersToRemove = listOf(), - include = MemberInclude( - includeStatus = true, - includeType = true, - ) + userIdsToRemove = listOf(), + include = MemberInclude(includeStatus = true, includeType = true) ).sync() val getAllResult = @@ -585,7 +582,7 @@ class ObjectsIntegrationTest : BaseIntegrationTest() { pubnub.manageChannelMembers( channel = channel, usersToSet = listOf(), - usersToRemove = listOf(testUserId01, testUserId02), + userIdsToRemove = listOf(testUserId01, testUserId02), ).sync().data assertThat(removeResult, not(containsInAnyOrder(testUuidMatcher, otherTestUuidMatcher))) @@ -601,7 +598,7 @@ class ObjectsIntegrationTest : BaseIntegrationTest() { pubnub.manageChannelMembers( channel = channel, usersToSet = listOf(PNMember.Partial(uuidId = testUserId01, status = status01)), - usersToRemove = listOf(), + userIdsToRemove = listOf(), ).sync() val getAllResult = @@ -635,7 +632,7 @@ class ObjectsIntegrationTest : BaseIntegrationTest() { pubnub.manageChannelMembers( channel = channel, usersToSet = listOf(), - usersToRemove = listOf(testUserId01, testUserId02), + userIdsToRemove = listOf(testUserId01, testUserId02), ).sync().data assertThat(removeResult, not(containsInAnyOrder(testUuidMatcher, otherTestUuidMatcher))) diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/PubNubImplTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/PubNubImplTest.kt index 184856ac8..462749a43 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/PubNubImplTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/PubNubImplTest.kt @@ -56,7 +56,7 @@ class PubNubImplTest : BaseTest() { fun getVersionAndTimeStamp() { val version = PubNubImpl.SDK_VERSION val timeStamp = PubNubImpl.timestamp() - assertEquals("10.2.1", version) + assertEquals("10.3.0", version) assertTrue(timeStamp > 0) }