Skip to content

Commit

Permalink
Added membershipType to Memberships and ChannelMembers APIs
Browse files Browse the repository at this point in the history
Introduced new API with userId instead of UUID and possibility to include optional data in respons. See MemberInclude and MembershipInclude.
  • Loading branch information
marcin-cebo authored Dec 6, 2024
1 parent c8ae89e commit 8f73f23
Show file tree
Hide file tree
Showing 16 changed files with 258 additions and 24 deletions.
13 changes: 9 additions & 4 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ You will need the publish and subscribe keys to authenticate your app. Get your
<dependency>
<groupId>com.pubnub</groupId>
<artifactId>pubnub-kotlin</artifactId>
<version>10.2.1</version>
<version>10.3.0</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class ManageChannelMembersImpl extends DelegatingEndpoint<PNMemberArrayRe
private Collection<PNUUID> uuidsToSet; // deprecated
private Collection<PNUUID> uuidsToRemove; // deprecated
private Collection<PNUser> usersToSet;
private List<String> usersIdsToRemove;
private List<String> userIdsToRemove;
private MemberInclude include;

@Deprecated
Expand All @@ -57,11 +57,11 @@ public ManageChannelMembersImpl(String channel, Collection<PNUUID> uuidsToSet, C
this.uuidsToRemove = uuidsToRemove;
}

public ManageChannelMembersImpl(final PubNub pubnubInstance, String channel, Collection<PNUser> usersToSet, Collection<String> usersIdsToRemove) {
public ManageChannelMembersImpl(final PubNub pubnubInstance, String channel, Collection<PNUser> usersToSet, Collection<String> userIdsToRemove) {
super(pubnubInstance);
this.channel = channel;
this.usersToSet = usersToSet;
this.usersIdsToRemove = new ArrayList<>(usersIdsToRemove);
this.userIdsToRemove = new ArrayList<>(userIdsToRemove);
}

@NotNull
Expand All @@ -77,9 +77,9 @@ protected Endpoint<PNMemberArrayResult> createRemoteAction() {
List<String> 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();
Expand Down
4 changes: 2 additions & 2 deletions pubnub-kotlin/pubnub-kotlin-api/config/ktlint/baseline.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<baseline version="1.0">
<file name="src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/MemberInclude.kt">
<error line="3" column="5" source="standard:function-naming" />
<error line="20" column="5" source="standard:function-naming" />
</file>
<file name="src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/MembershipInclude.kt">
<error line="3" column="5" source="standard:function-naming" />
<error line="20" column="5" source="standard:function-naming" />
</file>
<file name="src/jsMain/kotlin/Pubnub.d.kt">
<error line="156" column="40" source="standard:comment-wrapping" />
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Loading

0 comments on commit 8f73f23

Please sign in to comment.