From a05e56a06f27a1090896d8b2830e069be8445867 Mon Sep 17 00:00:00 2001 From: Oliver Brunsmann Date: Sat, 18 Feb 2023 19:34:07 +0100 Subject: [PATCH] Added listTournamentRecordsAroundOwner to client --- CHANGELOG.md | 1 + lib/src/nakama_client/nakama_api_client.dart | 20 +++++++++++++++++++ lib/src/nakama_client/nakama_client.dart | 12 +++++++++++ lib/src/nakama_client/nakama_grpc_client.dart | 19 ++++++++++++++++++ 4 files changed, 52 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dda7d18..864e0c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ * **Breaking:** Renamed `ChannelJoinType` enum to `ChannelType` * **Breaking:** Renamed `leaderboardId` parameter to `leaderboardName` in `writeLeaderboardRecord` and `deleteLeaderboardRecord` * Added `onPartyData` stream to realtime client +* Added `listTournamentRecordsAroundOwner` to client ## 1.0.0-dev.3 diff --git a/lib/src/nakama_client/nakama_api_client.dart b/lib/src/nakama_client/nakama_api_client.dart index 0fe7da1..fbb039e 100644 --- a/lib/src/nakama_client/nakama_api_client.dart +++ b/lib/src/nakama_client/nakama_api_client.dart @@ -1319,6 +1319,26 @@ class NakamaRestApiClient extends NakamaBaseClient { return model.TournamentRecordList.fromJson(res.body!.toJson()); } + @override + Future listTournamentRecordsAroundOwner({ + required model.Session session, + required String tournamentId, + required String ownerId, + int? expiry, + int limit = defaultLimit, + }) async { + _session = session; + + final res = await _api.v2TournamentTournamentIdOwnerOwnerIdGet( + ownerId: ownerId, + tournamentId: tournamentId, + expiry: expiry?.toString(), + limit: limit, + ); + + return model.TournamentRecordList.fromJson(res.body!.toJson()); + } + @override Future writeTournamentRecord({ required model.Session session, diff --git a/lib/src/nakama_client/nakama_client.dart b/lib/src/nakama_client/nakama_client.dart index 953b523..cd783aa 100644 --- a/lib/src/nakama_client/nakama_client.dart +++ b/lib/src/nakama_client/nakama_client.dart @@ -653,6 +653,18 @@ abstract class NakamaBaseClient { String? cursor, }); + /// # Listing records around a user** + /// + /// Similarly to leaderboards, Sagi-shi players can get other player scores + /// around them. + Future listTournamentRecordsAroundOwner({ + required model.Session session, + required String tournamentId, + required String ownerId, + int? expiry, + int limit = defaultLimit, + }); + /// # Submitting scores /// /// Players can submit scores, subscores and metadata to the tournament. diff --git a/lib/src/nakama_client/nakama_grpc_client.dart b/lib/src/nakama_client/nakama_grpc_client.dart index 20cf808..59aedeb 100644 --- a/lib/src/nakama_client/nakama_grpc_client.dart +++ b/lib/src/nakama_client/nakama_grpc_client.dart @@ -1246,6 +1246,25 @@ class NakamaGrpcClient extends NakamaBaseClient { return model.TournamentRecordList.fromDto(res); } + @override + Future listTournamentRecordsAroundOwner({ + required model.Session session, + required String tournamentId, + required String ownerId, + int? expiry, + int limit = defaultLimit, + }) async { + final res = await _client.listTournamentRecordsAroundOwner( + api.ListTournamentRecordsAroundOwnerRequest( + expiry: expiry == null ? null : api.Int64Value(value: Int64(expiry)), + limit: api.UInt32Value(value: limit), + ownerId: ownerId, + tournamentId: tournamentId, + )); + + return model.TournamentRecordList.fromDto(res); + } + @override Future writeTournamentRecord({ required model.Session session,