Skip to content

Commit

Permalink
Add default values to ListUsersStorageObjectsAsync method.
Browse files Browse the repository at this point in the history
  • Loading branch information
novabyte committed Mar 30, 2020
1 parent a0cafa8 commit de4c391
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 23 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Expand Up @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- New ListStorageObjectsAsync method and marked ListStorageObjects as obsolete.

### Changed
- ListUsersStorageObjectsAsync now uses default arguments for optional inputs.

## [2.3.1] - 2019-09-21
### Changed
Expand Down
38 changes: 25 additions & 13 deletions src/Nakama/Client.cs
Expand Up @@ -307,7 +307,8 @@ public Task DeleteStorageObjectsAsync(ISession session, params StorageObjectId[]
_apiClient.ListFriendsAsync(session.AuthToken, limit, state, cursor);

/// <inheritdoc cref="ListGroupUsersAsync"/>
public Task<IApiGroupUserList> ListGroupUsersAsync(ISession session, string groupId, int? state, int limit, string cursor) =>
public Task<IApiGroupUserList> ListGroupUsersAsync(ISession session, string groupId, int? state, int limit,
string cursor) =>
_apiClient.ListGroupUsersAsync(session.AuthToken, groupId, limit, state, cursor);

/// <inheritdoc cref="ListGroupsAsync"/>
Expand All @@ -317,12 +318,14 @@ public Task DeleteStorageObjectsAsync(ISession session, params StorageObjectId[]
/// <inheritdoc cref="ListLeaderboardRecordsAsync"/>
public Task<IApiLeaderboardRecordList> ListLeaderboardRecordsAsync(ISession session, string leaderboardId,
IEnumerable<string> ownerIds = null, long? expiry = null, int limit = 1, string cursor = null) =>
_apiClient.ListLeaderboardRecordsAsync(session.AuthToken, leaderboardId, ownerIds, limit, cursor, expiry?.ToString());
_apiClient.ListLeaderboardRecordsAsync(session.AuthToken, leaderboardId, ownerIds, limit, cursor,
expiry?.ToString());

/// <inheritdoc cref="ListLeaderboardRecordsAroundOwnerAsync"/>
public Task<IApiLeaderboardRecordList> ListLeaderboardRecordsAroundOwnerAsync(ISession session,
string leaderboardId, string ownerId, long? expiry = null, int limit = 1) =>
_apiClient.ListLeaderboardRecordsAroundOwnerAsync(session.AuthToken, leaderboardId, ownerId, limit, expiry?.ToString());
_apiClient.ListLeaderboardRecordsAroundOwnerAsync(session.AuthToken, leaderboardId, ownerId, limit,
expiry?.ToString());

/// <inheritdoc cref="ListMatchesAsync"/>
public Task<IApiMatchList> ListMatchesAsync(ISession session, int min, int max, int limit, bool authoritative,
Expand All @@ -334,20 +337,27 @@ public Task DeleteStorageObjectsAsync(ISession session, params StorageObjectId[]
string cacheableCursor = null) =>
_apiClient.ListNotificationsAsync(session.AuthToken, limit, cacheableCursor);

/// <inheritdoc cref="ListStorageObjects"/>
[Obsolete("ListStorageObjects is obsolete, please use ListStorageObjectsAsync instead.", false)]
public Task<IApiStorageObjectList> ListStorageObjects(ISession session, string collection, int limit = 1,
string cursor = null) =>
_apiClient.ListStorageObjectsAsync(session.AuthToken, collection, string.Empty, limit, cursor);

/// <inheritdoc cref="ListStorageObjectsAsync"/>
public Task<IApiStorageObjectList> ListStorageObjectsAsync(ISession session, string collection, int limit = 1,
string cursor = null) =>
_apiClient.ListStorageObjectsAsync(session.AuthToken, collection, string.Empty, limit, cursor);

/// <inheritdoc cref="ListTournamentRecordsAroundOwnerAsync"/>
public Task<IApiTournamentRecordList> ListTournamentRecordsAroundOwnerAsync(ISession session,
string tournamentId, string ownerId, long? expiry = null, int limit = 1) =>
_apiClient.ListTournamentRecordsAroundOwnerAsync(session.AuthToken, tournamentId, ownerId, limit, expiry?.ToString());
_apiClient.ListTournamentRecordsAroundOwnerAsync(session.AuthToken, tournamentId, ownerId, limit,
expiry?.ToString());

/// <inheritdoc cref="ListTournamentRecordsAsync"/>
public Task<IApiTournamentRecordList> ListTournamentRecordsAsync(ISession session, string tournamentId,
IEnumerable<string> ownerIds = null, long? expiry = null, int limit = 1, string cursor = null) =>
_apiClient.ListTournamentRecordsAsync(session.AuthToken, tournamentId, ownerIds, limit, cursor, expiry?.ToString());
_apiClient.ListTournamentRecordsAsync(session.AuthToken, tournamentId, ownerIds, limit, cursor,
expiry?.ToString());

/// <inheritdoc cref="ListTournamentsAsync"/>
public Task<IApiTournamentList> ListTournamentsAsync(ISession session, int categoryStart, int categoryEnd,
Expand All @@ -360,12 +370,13 @@ public Task DeleteStorageObjectsAsync(ISession session, params StorageObjectId[]
ListUserGroupsAsync(session, session.UserId, state, limit, cursor);

/// <inheritdoc cref="ListUserGroupsAsync(Nakama.ISession,string,int?,int,string)"/>
public Task<IApiUserGroupList> ListUserGroupsAsync(ISession session, string userId, int? state, int limit, string cursor) =>
public Task<IApiUserGroupList> ListUserGroupsAsync(ISession session, string userId, int? state, int limit,
string cursor) =>
_apiClient.ListUserGroupsAsync(session.AuthToken, userId, limit, state, cursor);

/// <inheritdoc cref="ListUsersStorageObjectsAsync"/>
public Task<IApiStorageObjectList> ListUsersStorageObjectsAsync(ISession session, string collection,
string userId, int limit, string cursor) =>
string userId, int limit = 1, string cursor = null) =>
_apiClient.ListStorageObjects2Async(session.AuthToken, collection, userId, limit, cursor);

/// <inheritdoc cref="PromoteGroupUsersAsync"/>
Expand Down Expand Up @@ -460,7 +471,8 @@ public override string ToString()
});

/// <inheritdoc cref="UpdateGroupAsync"/>
public Task UpdateGroupAsync(ISession session, string groupId, string name, bool open, string description = null,
public Task UpdateGroupAsync(ISession session, string groupId, string name, bool open,
string description = null,
string avatarUrl = null, string langTag = null) => _apiClient.UpdateGroupAsync(
session.AuthToken, groupId,
new ApiUpdateGroupRequest
Expand All @@ -474,13 +486,13 @@ public override string ToString()

/// <inheritdoc cref="WriteLeaderboardRecordAsync"/>
public Task<IApiLeaderboardRecord> WriteLeaderboardRecordAsync(ISession session, string leaderboardId,
long score, long subscore = 0, string metadata = null) => _apiClient.WriteLeaderboardRecordAsync(
long score, long subScore = 0, string metadata = null) => _apiClient.WriteLeaderboardRecordAsync(
session.AuthToken, leaderboardId,
new WriteLeaderboardRecordRequestLeaderboardRecordWrite
{
Metadata = metadata,
Score = score.ToString(),
Subscore = subscore.ToString()
Subscore = subScore.ToString()
});

/// <inheritdoc cref="WriteStorageObjectsAsync"/>
Expand All @@ -507,13 +519,13 @@ public override string ToString()

/// <inheritdoc cref="WriteTournamentRecordAsync"/>
public Task<IApiLeaderboardRecord> WriteTournamentRecordAsync(ISession session, string tournamentId, long score,
long subscore = 0, string metadata = null) => _apiClient.WriteTournamentRecordAsync(session.AuthToken,
long subScore = 0, string metadata = null) => _apiClient.WriteTournamentRecordAsync(session.AuthToken,
tournamentId,
new WriteTournamentRecordRequestTournamentRecordWrite
{
Metadata = metadata,
Score = score.ToString(),
Subscore = subscore.ToString()
Subscore = subScore.ToString()
});
}
}
25 changes: 15 additions & 10 deletions src/Nakama/IClient.cs
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

using System;
using System.Collections.Generic;
using System.Threading.Tasks;

Expand Down Expand Up @@ -448,15 +449,19 @@ public interface IClient
Task<IApiNotificationList> ListNotificationsAsync(ISession session, int limit = 1,
string cacheableCursor = null);

[Obsolete("ListStorageObjects is obsolete, please use ListStorageObjectsAsync instead.", false)]
Task<IApiStorageObjectList> ListStorageObjects(ISession session, string collection, int limit = 1,
string cursor = null);

/// <summary>
/// List storage objects in a collection which have public read access.
/// </summary>
/// <param name="session">The session of the user.</param>
/// <param name="collection">The collection to list over.</param>
/// <param name="limit">The number of objects to list.</param>
/// <param name="cursor">A cursor to paginate over the collection.</param>
/// <param name="limit">The number of objects to list. Maximum 100.</param>
/// <param name="cursor">A cursor to paginate over the collection. May be null.</param>
/// <returns>A task which resolves to the storage object list.</returns>
Task<IApiStorageObjectList> ListStorageObjects(ISession session, string collection, int limit = 1,
Task<IApiStorageObjectList> ListStorageObjectsAsync(ISession session, string collection, int limit = 1,
string cursor = null);

/// <summary>
Expand Down Expand Up @@ -531,7 +536,7 @@ public interface IClient
/// <param name="cursor">A cursor to paginate over the collection.</param>
/// <returns>A task which resolves to the storage object list.</returns>
Task<IApiStorageObjectList> ListUsersStorageObjectsAsync(ISession session, string collection, string userId,
int limit, string cursor);
int limit = 1, string cursor = null);

/// <summary>
/// Promote one or more users in the group.
Expand Down Expand Up @@ -573,11 +578,11 @@ public interface IClient
/// <remarks>
/// This function is usually used with server side code. DO NOT USE client side.
/// </remarks>
/// <param name="httpkey">The secure HTTP key used to authenticate.</param>
/// <param name="httpKey">The secure HTTP key used to authenticate.</param>
/// <param name="id">The id of the function to execute on the server.</param>
/// <param name="payload">A payload to send with the function call.</param>
/// <returns>A task to resolve an RPC response.</returns>
Task<IApiRpc> RpcAsync(string httpkey, string id, string payload = null);
Task<IApiRpc> RpcAsync(string httpKey, string id, string payload = null);

/// <summary>
/// Unlink a custom ID from the user account owned by the session.
Expand Down Expand Up @@ -679,11 +684,11 @@ public interface IClient
/// <param name="session">The session for the user.</param>
/// <param name="leaderboardId">The ID of the leaderboard to write.</param>
/// <param name="score">The score for the leaderboard record.</param>
/// <param name="subscore">The subscore for the leaderboard record.</param>
/// <param name="subScore">The sub score for the leaderboard record.</param>
/// <param name="metadata">The metadata for the leaderboard record.</param>
/// <returns>A task which resolves to the leaderboard record object written.</returns>
Task<IApiLeaderboardRecord> WriteLeaderboardRecordAsync(ISession session, string leaderboardId, long score,
long subscore = 0L, string metadata = null);
long subScore = 0L, string metadata = null);

/// <summary>
/// Write objects to the storage engine.
Expand All @@ -699,10 +704,10 @@ public interface IClient
/// <param name="session">The session of the user.</param>
/// <param name="tournamentId">The ID of the tournament to write.</param>
/// <param name="score">The score of the tournament record.</param>
/// <param name="subscore">The subscore for the tournament record.</param>
/// <param name="subScore">The sub score for the tournament record.</param>
/// <param name="metadata">The metadata for the tournament record.</param>
/// <returns>A task which resolves to the tournament record object written.</returns>
Task<IApiLeaderboardRecord> WriteTournamentRecordAsync(ISession session, string tournamentId, long score,
long subscore = 0L, string metadata = null);
long subScore = 0L, string metadata = null);
}
}

0 comments on commit de4c391

Please sign in to comment.