Skip to content

Commit 8f73f23

Browse files
authored
Added membershipType to Memberships and ChannelMembers APIs
Introduced new API with userId instead of UUID and possibility to include optional data in respons. See MemberInclude and MembershipInclude.
1 parent c8ae89e commit 8f73f23

File tree

16 files changed

+258
-24
lines changed

16 files changed

+258
-24
lines changed

.pubnub.yml

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: kotlin
2-
version: 10.2.1
2+
version: 10.3.0
33
schema: 1
44
scm: github.com/pubnub/kotlin
55
files:
6-
- build/libs/pubnub-kotlin-10.2.1-all.jar
6+
- build/libs/pubnub-kotlin-10.3.0-all.jar
77
sdks:
88
-
99
type: library
@@ -23,8 +23,8 @@ sdks:
2323
-
2424
distribution-type: library
2525
distribution-repository: maven
26-
package-name: pubnub-kotlin-10.2.1
27-
location: https://repo.maven.apache.org/maven2/com/pubnub/pubnub-kotlin/10.2.1/pubnub-kotlin-10.2.1.jar
26+
package-name: pubnub-kotlin-10.3.0
27+
location: https://repo.maven.apache.org/maven2/com/pubnub/pubnub-kotlin/10.3.0/pubnub-kotlin-10.3.0.jar
2828
supported-platforms:
2929
supported-operating-systems:
3030
Android:
@@ -114,6 +114,11 @@ sdks:
114114
license-url: https://www.apache.org/licenses/LICENSE-2.0.txt
115115
is-required: Required
116116
changelog:
117+
- date: 2024-12-05
118+
version: v10.3.0
119+
changes:
120+
- type: feature
121+
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."
117122
- date: 2024-12-03
118123
version: v10.2.1
119124
changes:

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## v10.3.0
2+
December 05 2024
3+
4+
#### Added
5+
- 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.
6+
17
## v10.2.1
28
December 03 2024
39

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ You will need the publish and subscribe keys to authenticate your app. Get your
2020
<dependency>
2121
<groupId>com.pubnub</groupId>
2222
<artifactId>pubnub-kotlin</artifactId>
23-
<version>10.2.1</version>
23+
<version>10.3.0</version>
2424
</dependency>
2525
```
2626

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ RELEASE_SIGNING_ENABLED=true
1818
SONATYPE_HOST=DEFAULT
1919
SONATYPE_AUTOMATIC_RELEASE=false
2020
GROUP=com.pubnub
21-
VERSION_NAME=10.2.1
21+
VERSION_NAME=10.3.0
2222
POM_PACKAGING=jar
2323

2424
POM_NAME=PubNub SDK

pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/member/MemberInclude.kt

+67
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
11
package com.pubnub.api.java.models.consumer.objects_api.member
22

3+
/**
4+
* Represents the options for including additional details in member-related operations.
5+
*
6+
* This interface extends [com.pubnub.api.models.consumer.objects.member.MemberInclude]
7+
* and provides a flexible builder pattern to configure the desired inclusion options.
8+
*/
39
interface MemberInclude : com.pubnub.api.models.consumer.objects.member.MemberInclude {
410
companion object {
11+
/**
12+
* Creates a new [Builder] for constructing a [MemberInclude] instance.
13+
*
14+
* @return a new [Builder] instance.
15+
*/
516
@JvmStatic
617
fun builder() = Builder()
718
}
819

20+
/**
21+
* Builder class for configuring and creating instances of [MemberInclude].
22+
*/
923
class Builder internal constructor() {
1024
var includeCustom: Boolean = false
1125
var includeStatus: Boolean = false
@@ -16,46 +30,99 @@ interface MemberInclude : com.pubnub.api.models.consumer.objects.member.MemberIn
1630
var includeUserType: Boolean = false
1731
var includeUserStatus: Boolean = false
1832

33+
/**
34+
* Specifies whether to include custom data in the member data.
35+
*
36+
* @param includeCustom `true` to include custom fields, `false` otherwise.
37+
* @return the current [Builder] instance.
38+
*/
1939
fun includeCustom(includeCustom: Boolean): Builder {
2040
this.includeCustom = includeCustom
2141
return this
2242
}
2343

44+
/**
45+
* Specifies whether to include the status of the member.
46+
*
47+
* @param includeStatus `true` to include status, `false` otherwise.
48+
* @return the current [Builder] instance.
49+
*/
2450
fun includeStatus(includeStatus: Boolean): Builder {
2551
this.includeStatus = includeStatus
2652
return this
2753
}
2854

55+
/**
56+
* Specifies whether to include the type of the member.
57+
*
58+
* @param includeType `true` to include type, `false` otherwise.
59+
* @return the current [Builder] instance.
60+
*/
2961
fun includeType(includeType: Boolean): Builder {
3062
this.includeType = includeType
3163
return this
3264
}
3365

66+
/**
67+
* Specifies whether to include the total count of members.
68+
*
69+
* @param includeTotalCount `true` to include the total count, `false` otherwise.
70+
* @return the current [Builder] instance.
71+
*/
3472
fun includeTotalCount(includeTotalCount: Boolean): Builder {
3573
this.includeTotalCount = includeTotalCount
3674
return this
3775
}
3876

77+
/**
78+
* Specifies whether to include user information in the member data.
79+
*
80+
* @param includeUser `true` to include user information, `false` otherwise.
81+
* @return the current [Builder] instance.
82+
*/
3983
fun includeUser(includeUser: Boolean): Builder {
4084
this.includeUser = includeUser
4185
return this
4286
}
4387

88+
/**
89+
* Specifies whether to include custom fields for the user in the member data.
90+
*
91+
* @param includeUserCustom `true` to include user custom fields, `false` otherwise.
92+
* @return the current [Builder] instance.
93+
*/
4494
fun includeUserCustom(includeUserCustom: Boolean): Builder {
4595
this.includeUserCustom = includeUserCustom
4696
return this
4797
}
4898

99+
/**
100+
* Specifies whether to include the type of the user in the member data.
101+
*
102+
* @param includeUserType `true` to include user type, `false` otherwise.
103+
* @return the current [Builder] instance.
104+
*/
49105
fun includeUserType(includeUserType: Boolean): Builder {
50106
this.includeUserType = includeUserType
51107
return this
52108
}
53109

110+
/**
111+
* Specifies whether to include the status of the user in the member data.
112+
*
113+
* @param includeUserStatus `true` to include user status, `false` otherwise.
114+
* @return the current [Builder] instance.
115+
*/
54116
fun includeUserStatus(includeUserStatus: Boolean): Builder {
55117
this.includeUserStatus = includeUserStatus
56118
return this
57119
}
58120

121+
/**
122+
* Builds and returns a new [MemberInclude] instance with the configured options.
123+
*
124+
* @return a new [MemberInclude] instance.
125+
*/
59126
fun build(): MemberInclude {
60127
return object : MemberInclude {
61128
override val includeCustom: Boolean = this@Builder.includeCustom

pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/membership/MembershipInclude.kt

+67
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
11
package com.pubnub.api.java.models.consumer.objects_api.membership
22

3+
/**
4+
* Represents the options for including additional details in membership-related operations.
5+
*
6+
* This interface extends [com.pubnub.api.models.consumer.objects.membership.MembershipInclude]
7+
* and provides a flexible builder pattern to configure the desired inclusion options.
8+
*/
39
interface MembershipInclude : com.pubnub.api.models.consumer.objects.membership.MembershipInclude {
410
companion object {
11+
/**
12+
* Creates a new [Builder] for constructing a [MembershipInclude] instance.
13+
*
14+
* @return a new [Builder] instance.
15+
*/
516
@JvmStatic
617
fun builder() = Builder()
718
}
819

20+
/**
21+
* Builder class for configuring and creating instances of [MembershipInclude].
22+
*/
923
class Builder internal constructor() {
1024
var includeCustom: Boolean = false
1125
var includeStatus: Boolean = false
@@ -16,46 +30,99 @@ interface MembershipInclude : com.pubnub.api.models.consumer.objects.membership.
1630
var includeChannelType: Boolean = false
1731
var includeChannelStatus: Boolean = false
1832

33+
/**
34+
* Specifies whether to include custom fields in the membership data.
35+
*
36+
* @param includeCustom `true` to include custom data, `false` otherwise.
37+
* @return the current [Builder] instance.
38+
*/
1939
fun includeCustom(includeCustom: Boolean): Builder {
2040
this.includeCustom = includeCustom
2141
return this
2242
}
2343

44+
/**
45+
* Specifies whether to include the status of the membership.
46+
*
47+
* @param includeStatus `true` to include status, `false` otherwise.
48+
* @return the current [Builder] instance.
49+
*/
2450
fun includeStatus(includeStatus: Boolean): Builder {
2551
this.includeStatus = includeStatus
2652
return this
2753
}
2854

55+
/**
56+
* Specifies whether to include the type of the membership.
57+
*
58+
* @param includeType `true` to include type, `false` otherwise.
59+
* @return the current [Builder] instance.
60+
*/
2961
fun includeType(includeType: Boolean): Builder {
3062
this.includeType = includeType
3163
return this
3264
}
3365

66+
/**
67+
* Specifies whether to include the total count of memberships.
68+
*
69+
* @param includeTotalCount `true` to include the total count, `false` otherwise.
70+
* @return the current [Builder] instance.
71+
*/
3472
fun includeTotalCount(includeTotalCount: Boolean): Builder {
3573
this.includeTotalCount = includeTotalCount
3674
return this
3775
}
3876

77+
/**
78+
* Specifies whether to include channel information in the membership data.
79+
*
80+
* @param includeChannel `true` to include channel information, `false` otherwise.
81+
* @return the current [Builder] instance.
82+
*/
3983
fun includeChannel(includeChannel: Boolean): Builder {
4084
this.includeChannel = includeChannel
4185
return this
4286
}
4387

88+
/**
89+
* Specifies whether to include custom data for the channel in the membership data.
90+
*
91+
* @param includeChannelCustom `true` to include channel custom fields, `false` otherwise.
92+
* @return the current [Builder] instance.
93+
*/
4494
fun includeChannelCustom(includeChannelCustom: Boolean): Builder {
4595
this.includeChannelCustom = includeChannelCustom
4696
return this
4797
}
4898

99+
/**
100+
* Specifies whether to include the type of the channel in the membership data.
101+
*
102+
* @param includeChannelType `true` to include channel type, `false` otherwise.
103+
* @return the current [Builder] instance.
104+
*/
49105
fun includeChannelType(includeChannelType: Boolean): Builder {
50106
this.includeChannelType = includeChannelType
51107
return this
52108
}
53109

110+
/**
111+
* Specifies whether to include the status of the channel in the membership data.
112+
*
113+
* @param includeChannelStatus `true` to include channel status, `false` otherwise.
114+
* @return the current [Builder] instance.
115+
*/
54116
fun includeChannelStatus(includeChannelStatus: Boolean): Builder {
55117
this.includeChannelStatus = includeChannelStatus
56118
return this
57119
}
58120

121+
/**
122+
* Builds and returns a new [MembershipInclude] instance with the configured options.
123+
*
124+
* @return a new [MembershipInclude] instance.
125+
*/
59126
fun build(): MembershipInclude {
60127
return object : MembershipInclude {
61128
override val includeCustom: Boolean = this@Builder.includeCustom

pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/members/ManageChannelMembersImpl.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class ManageChannelMembersImpl extends DelegatingEndpoint<PNMemberArrayRe
4646
private Collection<PNUUID> uuidsToSet; // deprecated
4747
private Collection<PNUUID> uuidsToRemove; // deprecated
4848
private Collection<PNUser> usersToSet;
49-
private List<String> usersIdsToRemove;
49+
private List<String> userIdsToRemove;
5050
private MemberInclude include;
5151

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

60-
public ManageChannelMembersImpl(final PubNub pubnubInstance, String channel, Collection<PNUser> usersToSet, Collection<String> usersIdsToRemove) {
60+
public ManageChannelMembersImpl(final PubNub pubnubInstance, String channel, Collection<PNUser> usersToSet, Collection<String> userIdsToRemove) {
6161
super(pubnubInstance);
6262
this.channel = channel;
6363
this.usersToSet = usersToSet;
64-
this.usersIdsToRemove = new ArrayList<>(usersIdsToRemove);
64+
this.userIdsToRemove = new ArrayList<>(userIdsToRemove);
6565
}
6666

6767
@NotNull
@@ -77,9 +77,9 @@ protected Endpoint<PNMemberArrayResult> createRemoteAction() {
7777
List<String> toRemove;
7878

7979
// new API use
80-
if (usersToSet != null || usersIdsToRemove != null) {
80+
if (usersToSet != null || userIdsToRemove != null) {
8181
toSet = createMemberInputFromUserToSet();
82-
toRemove = usersIdsToRemove;
82+
toRemove = userIdsToRemove;
8383
} else { // old API used
8484
toSet = createMemberInputFromUUIDToSet();
8585
toRemove = createUserIdsFromUUIDToRemove();

pubnub-kotlin/pubnub-kotlin-api/config/ktlint/baseline.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<baseline version="1.0">
33
<file name="src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/MemberInclude.kt">
4-
<error line="3" column="5" source="standard:function-naming" />
4+
<error line="20" column="5" source="standard:function-naming" />
55
</file>
66
<file name="src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/MembershipInclude.kt">
7-
<error line="3" column="5" source="standard:function-naming" />
7+
<error line="20" column="5" source="standard:function-naming" />
88
</file>
99
<file name="src/jsMain/kotlin/Pubnub.d.kt">
1010
<error line="156" column="40" source="standard:comment-wrapping" />

pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/MemberInclude.kt

+17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
package com.pubnub.api.models.consumer.objects.member
22

3+
/**
4+
* Factory function to create an instance of [MemberInclude].
5+
*
6+
* This function provides default values for all inclusion flags and returns an
7+
* implementation of the [MemberInclude] interface with the specified options.
8+
*
9+
* @param includeCustom Whether to include custom properties in the result. Default is `false`.
10+
* @param includeStatus Whether to include the status of the Members in the result. Default is `false`.
11+
* @param includeType Whether to include the type of the Members in the result. Default is `false`.
12+
* @param includeTotalCount Whether to include the total count of Members in the result. Default is `false`.
13+
* @param includeUser Whether to include user information in the result. Default is `false`.
14+
* @param includeUserCustom Whether to include custom properties of the user in the result. Default is `false`.
15+
* @param includeUserType Whether to include the type of the user in the result. Default is `false`.
16+
* @param includeUserStatus Whether to include the status of the user in the result. Default is `false`.
17+
*
18+
* @return An instance of [MemberInclude] with the specified inclusion options.
19+
*/
320
fun MemberInclude(
421
includeCustom: Boolean = false,
522
includeStatus: Boolean = false,

0 commit comments

Comments
 (0)