66
77namespace  TaloGameServices 
88{ 
9+     public  class  GetEntriesOptions 
10+     { 
11+         public  int  page  =  0 ; 
12+         public  int  aliasId  =  - 1 ; 
13+         public  bool  includeArchived  =  false ; 
14+         public  string  propKey  =  "" ; 
15+         public  string  propValue  =  "" ; 
16+     } 
17+ 
918    public  class  LeaderboardsAPI  :  BaseAPI 
1019    { 
1120        private  LeaderboardEntriesManager  _entriesManager  =  new ( ) ; 
@@ -24,9 +33,22 @@ public List<LeaderboardEntry> GetCachedEntriesForCurrentPlayer(string internalNa
2433            return  _entriesManager . GetEntries ( internalName ) . FindAll ( e =>  e . playerAlias . id  ==  Talo . CurrentAlias . id ) ; 
2534        } 
2635
27-         public  async  Task < LeaderboardEntriesResponse >  GetEntries ( string  internalName ,  int  page ,  int  aliasId  =  - 1 ,  bool  includeArchived  =  false ) 
36+         private  string  BuildGetEntriesQueryParams ( GetEntriesOptions  options ) 
37+         { 
38+             options  ??=  new  GetEntriesOptions ( ) ; 
39+ 
40+             var  query  =  new  Dictionary < string ,  string >  {  [ "page" ]  =  options . page . ToString ( )  } ; 
41+             if  ( options . aliasId  !=  - 1 )  query [ "aliasId" ]  =  options . aliasId . ToString ( ) ; 
42+             if  ( options . includeArchived )  query [ "withDeleted" ]  =  "1" ; 
43+             if  ( ! string . IsNullOrEmpty ( options . propKey ) )  query [ "propKey" ]  =  options . propKey ; 
44+             if  ( ! string . IsNullOrEmpty ( options . propValue ) )  query [ "propValue" ]  =  options . propValue ; 
45+ 
46+             return  string . Join ( "&" ,  query . Select ( x =>  $ "{ x . Key } ={ x . Value } ") ) ; 
47+         } 
48+ 
49+         public  async  Task < LeaderboardEntriesResponse >  GetEntries ( string  internalName ,  GetEntriesOptions  options  =  null ) 
2850        { 
29-             var  uri  =  new  Uri ( $ "{ baseUrl } /{ internalName } /entries?page= { page } "   +   ( aliasId   !=   - 1   ?   $ "&aliasId= { aliasId } "   :   "" )   +   ( includeArchived   ?   "&withDeleted=1"   :   "" ) ) ; 
51+             var  uri  =  new  Uri ( $ "{ baseUrl } /{ internalName } /entries?{ BuildGetEntriesQueryParams ( options ) } " ) ; 
3052            var  json  =  await  Call ( uri ,  "GET" ) ; 
3153
3254            var  res  =  JsonUtility . FromJson < LeaderboardEntriesResponse > ( json ) ; 
@@ -39,10 +61,28 @@ public async Task<LeaderboardEntriesResponse> GetEntries(string internalName, in
3961            return  res ; 
4062        } 
4163
64+         [ Obsolete ( "Use GetEntries(string internalName, GetEntriesOptions options) instead." ) ] 
65+         public  async  Task < LeaderboardEntriesResponse >  GetEntries ( string  internalName ,  int  page ,  int  aliasId  =  - 1 ,  bool  includeArchived  =  false ) 
66+         { 
67+             return  await  GetEntries ( internalName ,  new  GetEntriesOptions 
68+             { 
69+                 page  =  page , 
70+                 aliasId  =  aliasId , 
71+                 includeArchived  =  includeArchived 
72+             } ) ; 
73+         } 
74+ 
75+         [ Obsolete ( "Use GetEntries(string internalName, GetEntriesOptions options) and set options.aliasId = Talo.CurrentAlias.id instead." ) ] 
4276        public  async  Task < LeaderboardEntriesResponse >  GetEntriesForCurrentPlayer ( string  internalName ,  int  page ,  bool  includeArchived  =  false ) 
4377        { 
4478            Talo . IdentityCheck ( ) ; 
45-             return  await  GetEntries ( internalName ,  page ,  Talo . CurrentAlias . id ,  includeArchived ) ; 
79+ 
80+             return  await  GetEntries ( internalName ,  new  GetEntriesOptions 
81+             { 
82+                 page  =  page , 
83+                 aliasId  =  Talo . CurrentAlias . id , 
84+                 includeArchived  =  includeArchived 
85+             } ) ;  
4686        } 
4787
4888        public  async  Task < ( LeaderboardEntry ,  bool ) >  AddEntry ( string  internalName ,  float  score ,  params  ( string ,  string ) [ ]  propTuples ) 
0 commit comments