Skip to content

Commit 3476d42

Browse files
authored
Merge pull request pubnub#36 from pubnub/develop
Objects Filtering
2 parents 9cdcae0 + 2a4b71b commit 3476d42

15 files changed

+300
-29
lines changed

.pubnub.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
---
22
changelog:
3+
-
4+
changes:
5+
-
6+
text: "Objects Filtering"
7+
type: improvement
8+
date: Jan 6, 19
9+
version: v4.7.1
310
-
411
changes:
512
-
@@ -437,6 +444,7 @@ features:
437444
- OBJECTS-MANAGE-MEMBERSHIPS
438445
- OBJECTS-GET-MEMBERS
439446
- OBJECTS-MANAGE-MEMBERS
447+
- OBJECTS-FILTERING
440448
message-actions:
441449
- MESSAGE-ACTIONS-GET
442450
- MESSAGE-ACTIONS-ADD
@@ -467,4 +475,4 @@ supported-platforms:
467475
- "Ubuntu 12.04+, with Graphics card DX9 (shader model 3.0) or DX11 with feature level 9.3 capabilities; and CPU SSE2 instruction set support."
468476
- "Mac OS X 10.8+, with Graphics card DX9 (shader model 3.0) or DX11 with feature level 9.3 capabilities; and CPU SSE2 instruction set support."
469477
version: "PubNub Unity SDK"
470-
version: v4.7.0
478+
version: v4.7.1

PubNubUnity/Assets/PubNub/Builders/Objects/GetMembersRequestBuilder.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class GetMembersRequestBuilder: PubNubNonSubBuilder<GetMembersRequestBuil
1111
private int GetMembersLimit { get; set;}
1212
private string GetMembersEnd { get; set;}
1313
private string GetMembersStart { get; set;}
14+
private string GetMembersFilter { get; set;}
1415
private bool GetMembersCount { get; set;}
1516
private PNMembersInclude[] GetMembersInclude { get; set;}
1617

@@ -47,6 +48,10 @@ public GetMembersRequestBuilder End(string end){
4748
GetMembersEnd = end;
4849
return this;
4950
}
51+
public GetMembersRequestBuilder Filter(string filter){
52+
GetMembersFilter = filter;
53+
return this;
54+
}
5055
public GetMembersRequestBuilder Count(bool count){
5156
GetMembersCount = count;
5257
return this;
@@ -65,7 +70,8 @@ protected override void RunWebRequest(QueueManager qm){
6570
GetMembersCount,
6671
string.Join(",", includeString),
6772
this.PubNubInstance,
68-
this.QueryParams
73+
this.QueryParams,
74+
GetMembersFilter
6975
);
7076
base.RunWebRequest(qm, request, requestState, this.PubNubInstance.PNConfig.NonSubscribeTimeout, 0, this);
7177
}

PubNubUnity/Assets/PubNub/Builders/Objects/GetMembershipsRequestBuilder.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public class GetMembershipsRequestBuilder: PubNubNonSubBuilder<GetMembershipsReq
1212
private string GetMembershipsEnd { get; set;}
1313
private string GetMembershipsStart { get; set;}
1414
private bool GetMembershipsCount { get; set;}
15+
private string GetMembershipsFilter { get; set;}
1516
private PNMembershipsInclude[] GetMembershipsInclude { get; set;}
1617

1718
public GetMembershipsRequestBuilder(PubNubUnity pn): base(pn, PNOperationType.PNGetMembershipsOperation){
@@ -47,6 +48,10 @@ public GetMembershipsRequestBuilder End(string end){
4748
GetMembershipsEnd = end;
4849
return this;
4950
}
51+
public GetMembershipsRequestBuilder Filter(string filter){
52+
GetMembershipsFilter = filter;
53+
return this;
54+
}
5055
public GetMembershipsRequestBuilder Count(bool count){
5156
GetMembershipsCount = count;
5257
return this;
@@ -65,7 +70,8 @@ protected override void RunWebRequest(QueueManager qm){
6570
GetMembershipsCount,
6671
string.Join(",", includeString),
6772
this.PubNubInstance,
68-
this.QueryParams
73+
this.QueryParams,
74+
GetMembershipsFilter
6975
);
7076
base.RunWebRequest(qm, request, requestState, this.PubNubInstance.PNConfig.NonSubscribeTimeout, 0, this);
7177
}

PubNubUnity/Assets/PubNub/Builders/Objects/GetSpacesRequestBuilder.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public class GetSpacesRequestBuilder : PubNubNonSubBuilder<GetSpacesRequestBuild
99
private int GetSpacesLimit { get; set; }
1010
private string GetSpacesEnd { get; set; }
1111
private string GetSpacesStart { get; set; }
12+
private string GetSpacesFilter { get; set; }
1213
private bool GetSpacesCount { get; set; }
1314
private PNUserSpaceInclude[] GetSpacesInclude { get; set; }
1415
public GetSpacesRequestBuilder(PubNubUnity pn) : base(pn, PNOperationType.PNGetSpacesOperation)
@@ -44,6 +45,10 @@ public GetSpacesRequestBuilder End(string end)
4445
GetSpacesEnd = end;
4546
return this;
4647
}
48+
public GetSpacesRequestBuilder Filter(string filter){
49+
GetSpacesFilter = filter;
50+
return this;
51+
}
4752
public GetSpacesRequestBuilder Count(bool count)
4853
{
4954
GetSpacesCount = count;
@@ -63,7 +68,8 @@ protected override void RunWebRequest(QueueManager qm)
6368
GetSpacesCount,
6469
string.Join(",", includeString),
6570
this.PubNubInstance,
66-
this.QueryParams
71+
this.QueryParams,
72+
GetSpacesFilter
6773
);
6874
base.RunWebRequest(qm, request, requestState, this.PubNubInstance.PNConfig.NonSubscribeTimeout, 0, this);
6975
}

PubNubUnity/Assets/PubNub/Builders/Objects/GetUsersRequestBuilder.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public class GetUsersRequestBuilder: PubNubNonSubBuilder<GetUsersRequestBuilder,
1010
private int GetUsersLimit { get; set;}
1111
private string GetUsersEnd { get; set;}
1212
private string GetUsersStart { get; set;}
13+
private string GetUsersFilter { get; set;}
1314
private bool GetUsersCount { get; set;}
1415
private PNUserSpaceInclude[] GetUsersInclude { get; set;}
1516

@@ -41,6 +42,10 @@ public GetUsersRequestBuilder End(string end){
4142
GetUsersEnd = end;
4243
return this;
4344
}
45+
public GetUsersRequestBuilder Filter(string filter){
46+
GetUsersFilter = filter;
47+
return this;
48+
}
4449
public GetUsersRequestBuilder Count(bool count){
4550
GetUsersCount = count;
4651
return this;
@@ -58,7 +63,8 @@ protected override void RunWebRequest(QueueManager qm){
5863
GetUsersCount,
5964
string.Join(",", includeString),
6065
this.PubNubInstance,
61-
this.QueryParams
66+
this.QueryParams,
67+
GetUsersFilter
6268
);
6369
base.RunWebRequest(qm, request, requestState, this.PubNubInstance.PNConfig.NonSubscribeTimeout, 0, this);
6470
}

PubNubUnity/Assets/PubNub/Editor/ObjectsTest.cs

+80-16
Original file line numberDiff line numberDiff line change
@@ -1019,8 +1019,17 @@ public void TestObjectsGetUsersRequestQueryParam64 ()
10191019
TestObjectsGetUsersCommon (true, true, true, 0, "", "", false);
10201020
}
10211021

1022-
10231022
public void TestObjectsGetUsersCommon(bool ssl, bool sendQueryParams, bool withIncl, int limit, string start, string end, bool count){
1023+
TestObjectsGetUsersCommon(ssl, sendQueryParams, withIncl, limit, start, end, count, false);
1024+
}
1025+
1026+
[Test]
1027+
public void TestObjectsGetUsersRequestWithFilterQueryParam64 ()
1028+
{
1029+
TestObjectsGetUsersCommon (true, true, true, 0, "", "", false, true);
1030+
}
1031+
1032+
public void TestObjectsGetUsersCommon(bool ssl, bool sendQueryParams, bool withIncl, int limit, string start, string end, bool count, bool withFilter){
10241033
string uuid = "customuuid";
10251034

10261035
Dictionary<string,string> queryParams = new Dictionary<string, string>();
@@ -1032,6 +1041,11 @@ public void TestObjectsGetUsersCommon(bool ssl, bool sendQueryParams, bool withI
10321041
queryParams = null;
10331042
}
10341043

1044+
string filter = "";
1045+
if(withFilter){
1046+
filter = "name like 'abc - / s*'";
1047+
}
1048+
10351049
PNConfiguration pnConfiguration = new PNConfiguration ();
10361050
pnConfiguration.Origin = EditorCommon.Origin;
10371051
pnConfiguration.SubscribeKey = EditorCommon.SubscribeKey;
@@ -1052,10 +1066,10 @@ public void TestObjectsGetUsersCommon(bool ssl, bool sendQueryParams, bool withI
10521066
incl = "";
10531067
}
10541068

1055-
Uri uri = BuildRequests.BuildObjectsGetUsersRequest (limit, start, end, count, incl, pnUnity, queryParams);
1069+
Uri uri = BuildRequests.BuildObjectsGetUsersRequest (limit, start, end, count, incl, pnUnity, queryParams, filter);
10561070

10571071
//https://ps.pndsn.com/v1/objects/demo/spaces/UnityUnitTests_86?uuid=customuuid&pnsdk=PubNub-CSharp-UnityOSX%2F4.3.0
1058-
string expected = string.Format ("http{0}://{1}/v1/objects/{2}/users?uuid={3}{7}{10}{4}{8}{9}&pnsdk={5}{6}",
1072+
string expected = string.Format ("http{0}://{1}/v1/objects/{2}/users?uuid={3}{7}{10}{11}{4}{8}{9}&pnsdk={5}{6}",
10591073
ssl?"s":"",
10601074
pnConfiguration.Origin,
10611075
EditorCommon.SubscribeKey,
@@ -1066,7 +1080,8 @@ public void TestObjectsGetUsersCommon(bool ssl, bool sendQueryParams, bool withI
10661080
(string.IsNullOrEmpty(incl))?"":string.Format("&include={0}",incl),
10671081
(string.IsNullOrEmpty(start))?"":string.Format("&start={0}",start),
10681082
(string.IsNullOrEmpty(end))?"":string.Format("&end={0}",end),
1069-
(count) ? "&count=1" : "&count=0"
1083+
(count) ? "&count=1" : "&count=0",
1084+
(withFilter)?"&filter=name%20like%20%27abc%20-%20%2F%20s%2A%27":""
10701085
);
10711086

10721087
string received = uri.OriginalString;
@@ -1457,8 +1472,17 @@ public void TestObjectsGetSpacesRequestQueryParam64 ()
14571472
TestObjectsGetSpacesCommon (true, true, true, 0, "", "", false);
14581473
}
14591474

1460-
1475+
[Test]
1476+
public void TestObjectsGetSpacesRequestWithFilterQueryParam64 ()
1477+
{
1478+
TestObjectsGetSpacesCommon (true, true, true, 0, "", "", false, true);
1479+
}
1480+
14611481
public void TestObjectsGetSpacesCommon(bool ssl, bool sendQueryParams, bool withIncl, int limit, string start, string end, bool count){
1482+
TestObjectsGetSpacesCommon(ssl, sendQueryParams, withIncl, limit, start, end, count, false);
1483+
}
1484+
1485+
public void TestObjectsGetSpacesCommon(bool ssl, bool sendQueryParams, bool withIncl, int limit, string start, string end, bool count, bool withFilter){
14621486
string uuid = "customuuid";
14631487

14641488
Dictionary<string,string> queryParams = new Dictionary<string, string>();
@@ -1490,10 +1514,16 @@ public void TestObjectsGetSpacesCommon(bool ssl, bool sendQueryParams, bool with
14901514
incl = "";
14911515
}
14921516

1493-
Uri uri = BuildRequests.BuildObjectsGetSpacesRequest (limit, start, end, count, incl, pnUnity, queryParams);
1517+
string filter = "";
1518+
if(withFilter){
1519+
filter = "name == 'abc - / s*'";
1520+
}
1521+
1522+
1523+
Uri uri = BuildRequests.BuildObjectsGetSpacesRequest (limit, start, end, count, incl, pnUnity, queryParams, filter);
14941524

14951525
//https://ps.pndsn.com/v1/objects/demo/spaces/UnityUnitTests_86?uuid=customuuid&pnsdk=PubNub-CSharp-UnityOSX%2F4.3.0
1496-
string expected = string.Format ("http{0}://{1}/v1/objects/{2}/spaces?uuid={3}{7}{10}{4}{8}{9}&pnsdk={5}{6}",
1526+
string expected = string.Format ("http{0}://{1}/v1/objects/{2}/spaces?uuid={3}{7}{10}{11}{4}{8}{9}&pnsdk={5}{6}",
14971527
ssl?"s":"",
14981528
pnConfiguration.Origin,
14991529
EditorCommon.SubscribeKey,
@@ -1504,7 +1534,8 @@ public void TestObjectsGetSpacesCommon(bool ssl, bool sendQueryParams, bool with
15041534
(string.IsNullOrEmpty(incl))?"":string.Format("&include={0}",incl),
15051535
(string.IsNullOrEmpty(start))?"":string.Format("&start={0}",start),
15061536
(string.IsNullOrEmpty(end))?"":string.Format("&end={0}",end),
1507-
(count) ? "&count=1" : "&count=0"
1537+
(count) ? "&count=1" : "&count=0",
1538+
(withFilter)?"&filter=name%20%3D%3D%20%27abc%20-%20%2F%20s%2A%27":""
15081539
);
15091540

15101541
string received = uri.OriginalString;
@@ -1897,6 +1928,17 @@ public void TestObjectsGetMembersRequestQueryParam64 ()
18971928

18981929

18991930
public void TestObjectsGetMembersCommon(bool ssl, bool sendQueryParams, bool withIncl, int limit, string start, string end, bool count){
1931+
TestObjectsGetMembersCommon(ssl, sendQueryParams, withIncl, limit, start, end, count, false);
1932+
}
1933+
1934+
[Test]
1935+
public void TestObjectsGetMembersRequestWithFilterQueryParam64 ()
1936+
{
1937+
TestObjectsGetMembersCommon (true, true, true, 0, "", "", false, true);
1938+
}
1939+
1940+
1941+
public void TestObjectsGetMembersCommon(bool ssl, bool sendQueryParams, bool withIncl, int limit, string start, string end, bool count, bool withFilter){
19001942
string uuid = "customuuid";
19011943

19021944
Dictionary<string,string> queryParams = new Dictionary<string, string>();
@@ -1929,10 +1971,15 @@ public void TestObjectsGetMembersCommon(bool ssl, bool sendQueryParams, bool wit
19291971
}
19301972
string ch = "ch";
19311973

1932-
Uri uri = BuildRequests.BuildObjectsGetMembersRequest (ch, limit, start, end, count, incl, pnUnity, queryParams);
1974+
string filter = "";
1975+
if(withFilter){
1976+
filter = "name == 'abc - / s'*";
1977+
}
1978+
1979+
Uri uri = BuildRequests.BuildObjectsGetMembersRequest (ch, limit, start, end, count, incl, pnUnity, queryParams, filter);
19331980

19341981
//https://ps.pndsn.com/v1/objects/demo/spaces/UnityUnitTests_86?uuid=customuuid&pnsdk=PubNub-CSharp-UnityOSX%2F4.3.0
1935-
string expected = string.Format ("http{0}://{1}/v1/objects/{2}/spaces/{11}/users?uuid={3}{7}{10}{4}{8}{9}&pnsdk={5}{6}",
1982+
string expected = string.Format ("http{0}://{1}/v1/objects/{2}/spaces/{11}/users?uuid={3}{7}{10}{12}{4}{8}{9}&pnsdk={5}{6}",
19361983
ssl?"s":"",
19371984
pnConfiguration.Origin,
19381985
EditorCommon.SubscribeKey,
@@ -1944,7 +1991,8 @@ public void TestObjectsGetMembersCommon(bool ssl, bool sendQueryParams, bool wit
19441991
(string.IsNullOrEmpty(start))?"":string.Format("&start={0}",start),
19451992
(string.IsNullOrEmpty(end))?"":string.Format("&end={0}",end),
19461993
(count) ? "&count=1" : "&count=0",
1947-
ch
1994+
ch,
1995+
(withFilter)?"&filter=name%20%3D%3D%20%27abc%20-%20%2F%20s%27%2A":""
19481996
);
19491997

19501998
string received = uri.OriginalString;
@@ -2334,9 +2382,19 @@ public void TestObjectsGetMembershipsRequestQueryParam64 ()
23342382
{
23352383
TestObjectsGetMembershipsCommon (true, true, true, 0, "", "", false);
23362384
}
2337-
23382385

2339-
public void TestObjectsGetMembershipsCommon(bool ssl, bool sendQueryParams, bool withIncl, int limit, string start, string end, bool count){
2386+
public void TestObjectsGetMembershipsCommon(bool ssl, bool sendQueryParams, bool withIncl, int limit, string start, string end, bool count){
2387+
TestObjectsGetMembershipsCommon(ssl, sendQueryParams, withIncl, limit, start, end, count, false);
2388+
}
2389+
2390+
2391+
[Test]
2392+
public void TestObjectsGetMembershipsRequestWithFilterQueryParam64 ()
2393+
{
2394+
TestObjectsGetMembershipsCommon (true, true, true, 0, "", "", false, true);
2395+
}
2396+
2397+
public void TestObjectsGetMembershipsCommon(bool ssl, bool sendQueryParams, bool withIncl, int limit, string start, string end, bool count, bool withFilter){
23402398
string uuid = "customuuid";
23412399

23422400
Dictionary<string,string> queryParams = new Dictionary<string, string>();
@@ -2368,11 +2426,16 @@ public void TestObjectsGetMembershipsCommon(bool ssl, bool sendQueryParams, bool
23682426
incl = "";
23692427
}
23702428
string ch = "ch";
2429+
2430+
string filter = "name == 's1236 9'";
2431+
if(!withFilter){
2432+
filter = "";
2433+
}
23712434

2372-
Uri uri = BuildRequests.BuildObjectsGetMembershipsRequest (ch, limit, start, end, count, incl, pnUnity, queryParams);
2435+
Uri uri = BuildRequests.BuildObjectsGetMembershipsRequest (ch, limit, start, end, count, incl, pnUnity, queryParams, filter);
23732436

23742437
//https://ps.pndsn.com/v1/objects/demo/spaces/UnityUnitTests_86?uuid=customuuid&pnsdk=PubNub-CSharp-UnityOSX%2F4.3.0
2375-
string expected = string.Format ("http{0}://{1}/v1/objects/{2}/users/{11}/spaces?uuid={3}{7}{10}{4}{8}{9}&pnsdk={5}{6}",
2438+
string expected = string.Format ("http{0}://{1}/v1/objects/{2}/users/{11}/spaces?uuid={3}{7}{10}{12}{4}{8}{9}&pnsdk={5}{6}",
23762439
ssl?"s":"",
23772440
pnConfiguration.Origin,
23782441
EditorCommon.SubscribeKey,
@@ -2384,7 +2447,8 @@ public void TestObjectsGetMembershipsCommon(bool ssl, bool sendQueryParams, bool
23842447
(string.IsNullOrEmpty(start))?"":string.Format("&start={0}",start),
23852448
(string.IsNullOrEmpty(end))?"":string.Format("&end={0}",end),
23862449
(count) ? "&count=1" : "&count=0",
2387-
ch
2450+
ch,
2451+
(withFilter)?"&filter=name%20%3D%3D%20%27s1236%209%27":""
23882452
);
23892453

23902454
string received = uri.OriginalString;

PubNubUnity/Assets/PubNub/EndPoints/Objects/GetMembersBuilder.cs

+6
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ public GetMembersBuilder End(string end){
3434
getMembersBuilder.End(end);
3535
return this;
3636
}
37+
public GetMembersBuilder Filter(string filter)
38+
{
39+
getMembersBuilder.Filter(filter);
40+
return this;
41+
}
42+
3743
public GetMembersBuilder Count(bool count){
3844
getMembersBuilder.Count(count);
3945
return this;

PubNubUnity/Assets/PubNub/EndPoints/Objects/GetMembershipsBuilder.cs

+6
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ public GetMembershipsBuilder End(string end){
3535
getMembershipsBuilder.End(end);
3636
return this;
3737
}
38+
public GetMembershipsBuilder Filter(string filter)
39+
{
40+
getMembershipsBuilder.Filter(filter);
41+
return this;
42+
}
43+
3844
public GetMembershipsBuilder Count(bool count){
3945
getMembershipsBuilder.Count(count);
4046
return this;

PubNubUnity/Assets/PubNub/EndPoints/Objects/GetSpacesBuilder.cs

+5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ public GetSpacesBuilder End(string end)
3333
getSpacesBuilder.End(end);
3434
return this;
3535
}
36+
public GetSpacesBuilder Filter(string filter)
37+
{
38+
getSpacesBuilder.Filter(filter);
39+
return this;
40+
}
3641
public GetSpacesBuilder Count(bool count)
3742
{
3843
getSpacesBuilder.Count(count);

PubNubUnity/Assets/PubNub/EndPoints/Objects/GetUsersBuilder.cs

+6
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ public GetUsersBuilder End(string end){
3030
getUsersBuilder.End(end);
3131
return this;
3232
}
33+
public GetUsersBuilder Filter(string filter)
34+
{
35+
getUsersBuilder.Filter(filter);
36+
return this;
37+
}
38+
3339
public GetUsersBuilder Count(bool count){
3440
getUsersBuilder.Count(count);
3541
return this;

0 commit comments

Comments
 (0)