@@ -256,6 +256,7 @@ - (void)getStatisticsWithIdentities:(NSArray<NSString *> *)identities
256256 });
257257 return ;
258258 }
259+ NSDictionary *parameters = @{ @" ids" : identities };
259260 NSString *path = [NSString stringWithFormat: @" leaderboard/%@ /statistics/%@ " , leaderboardPath, self .statisticName];
260261 if (option) {
261262 NSMutableArray <NSString *> *queryStrings = [NSMutableArray array ];
@@ -274,7 +275,7 @@ - (void)getStatisticsWithIdentities:(NSArray<NSString *> *)identities
274275 }
275276 }
276277 [[LCPaasClient sharedInstance ] postObject: path
277- withParameters: identities
278+ withParameters: parameters
278279 block: ^(id _Nullable object, NSError * _Nullable error) {
279280 [[self class ] handleStatisticsCallback: callback error: error object: object];
280281 }];
@@ -389,6 +390,98 @@ - (void)getResultsAroundIdentity:(NSString *)identity
389390 }];
390391}
391392
393+ - (void )getGroupUserResultsWithUserIds : (NSArray <NSString *> *)userIds
394+ option : (LCLeaderboardQueryOption *)option
395+ callback : (void (^)(NSArray <LCLeaderboardRanking *> * _Nullable, NSError * _Nullable))callback
396+ {
397+ [self getGroupUserResultsWithIdentities: userIds
398+ leaderboardPath: LCLeaderboardPathUser
399+ aroundIdentity: nil
400+ option: option
401+ callback: callback];
402+ }
403+
404+ - (void )getGroupUserResultsWithUserIds : (NSArray <NSString *> *)userIds
405+ aroundUser : (NSString *)userId
406+ option : (LCLeaderboardQueryOption *)option
407+ callback : (void (^)(NSArray <LCLeaderboardRanking *> * _Nullable, NSError * _Nullable))callback
408+ {
409+ [self getGroupUserResultsWithIdentities: userIds
410+ leaderboardPath: LCLeaderboardPathUser
411+ aroundIdentity: userId
412+ option: option
413+ callback: callback];
414+ }
415+
416+ - (void )getGroupUserResultsWithIdentities : (NSArray <NSString *> *)identities
417+ leaderboardPath : (LCLeaderboardPath)leaderboardPath
418+ aroundIdentity : (NSString *)identity
419+ option : (LCLeaderboardQueryOption *)option
420+ callback : (void (^)(NSArray <LCLeaderboardRanking *> * _Nullable, NSError * _Nullable))callback
421+ {
422+ if (!identities || identities.count == 0 ) {
423+ NSError *error = LCError (LCErrorInternalErrorCodeInconsistency, @" First parameter invalid." , nil );
424+ [LCUtils callArrayResultBlock: callback array: nil error: error];
425+ return ;
426+ }
427+ NSDictionary *parameters = @{ @" ids" : identities };
428+ NSString *path = [NSString stringWithFormat: @" leaderboard/leaderboards/%@ /%@ /group/ranks" , leaderboardPath, self .statisticName];
429+ if (identity && identity.length > 0 ) {
430+ path = [path stringByAppendingPathComponent: identity];
431+ }
432+ NSMutableDictionary <NSString *, NSString *> *urlQueryDictionary = [NSMutableDictionary dictionary ];
433+ [[self class ] trySetOption: option parameters: urlQueryDictionary];
434+ if (!identity && self.skip > 0 ) {
435+ urlQueryDictionary[@" startPosition" ] = @(self.skip ).stringValue ;
436+ }
437+ if (self.limit > 0 ) {
438+ urlQueryDictionary[@" maxResultsCount" ] = @(self.limit ).stringValue ;
439+ }
440+ if (self.includeStatistics && self.includeStatistics .count > 0 ) {
441+ urlQueryDictionary[@" includeStatistics" ] = [self .includeStatistics componentsJoinedByString: @" ," ];
442+ }
443+ if (self.version > -1 ) {
444+ urlQueryDictionary[@" version" ] = @(self.version ).stringValue ;
445+ }
446+ NSString *urlQuery;
447+ if (urlQueryDictionary.count > 0 ) {
448+ NSMutableArray <NSURLQueryItem *> *queryItems = [NSMutableArray arrayWithCapacity: urlQueryDictionary.count];
449+ for (NSString *key in urlQueryDictionary) {
450+ NSString *value = urlQueryDictionary[key];
451+ NSURLQueryItem *queryItem = [NSURLQueryItem queryItemWithName: key value: value];
452+ [queryItems addObject: queryItem];
453+ }
454+ NSURLComponents *urlComponents = [NSURLComponents componentsWithString: @" http://example.com" ];
455+ urlComponents.queryItems = queryItems;
456+ urlQuery = urlComponents.URL .query ;
457+ }
458+ if (urlQuery) {
459+ path = [path stringByAppendingFormat: @" ?%@ " , urlQuery];
460+ }
461+ [[LCPaasClient sharedInstance ] postObject: path
462+ withParameters: parameters
463+ block: ^(id _Nullable object, NSError * _Nullable error) {
464+ if (error) {
465+ [LCUtils callArrayResultBlock: callback array: nil error: error];
466+ return ;
467+ }
468+ if ([NSDictionary _lc_isTypeOf: object]) {
469+ NSArray *results = [NSArray _lc_decoding: object key: @" results" ];
470+ NSMutableArray <LCLeaderboardRanking *> *rankings = [NSMutableArray arrayWithCapacity: results.count];
471+ for (NSDictionary *item in results) {
472+ if ([NSDictionary _lc_isTypeOf: item]) {
473+ LCLeaderboardRanking *ranking = [[LCLeaderboardRanking alloc ] initWithDictionary: item];
474+ [rankings addObject: ranking];
475+ }
476+ }
477+ [LCUtils callArrayResultBlock: callback array: rankings error: nil ];
478+ } else {
479+ NSError *error = LCError (LCErrorInternalErrorCodeMalformedData, @" Malformed response data." , nil );
480+ [LCUtils callArrayResultBlock: callback array: nil error: error];
481+ }
482+ }];
483+ }
484+
392485// MARK: Misc
393486
394487+ (void )trySetOption : (LCLeaderboardQueryOption * _Nullable)option parameters : (NSMutableDictionary *)parameters {
0 commit comments