You've already forked CC-Framework.BriskGameServer
Update Unity SDK for daily space like API
This commit is contained in:
@@ -249,8 +249,10 @@ internal static class BriskModelMapper
|
||||
ContentSizeBytes = BriskValueReader.GetLong(data, "content_size_bytes"),
|
||||
ContentChecksum = BriskValueReader.GetString(data, "content_checksum"),
|
||||
LikeCount = BriskValueReader.GetLong(data, "like_count"),
|
||||
TodayLikeCount = BriskValueReader.GetLong(data, "today_like_count"),
|
||||
VisitCount = BriskValueReader.GetLong(data, "visit_count"),
|
||||
LikedByMe = BriskValueReader.GetBool(data, "liked_by_me"),
|
||||
LikeResetAt = BriskValueReader.GetString(data, "like_reset_at"),
|
||||
UpdatedAt = BriskValueReader.GetString(data, "updated_at")
|
||||
};
|
||||
}
|
||||
@@ -276,7 +278,9 @@ internal static class BriskModelMapper
|
||||
ContentSizeBytes = BriskValueReader.GetLong(data, "content_size_bytes"),
|
||||
ContentChecksum = BriskValueReader.GetString(data, "content_checksum"),
|
||||
LikeCount = BriskValueReader.GetLong(data, "like_count"),
|
||||
TodayLikeCount = BriskValueReader.GetLong(data, "today_like_count"),
|
||||
VisitCount = BriskValueReader.GetLong(data, "visit_count"),
|
||||
LikeResetAt = BriskValueReader.GetString(data, "like_reset_at"),
|
||||
UpdatedAt = BriskValueReader.GetString(data, "updated_at")
|
||||
};
|
||||
}
|
||||
@@ -309,7 +313,11 @@ internal static class BriskModelMapper
|
||||
return new BriskSpaceLikeResult
|
||||
{
|
||||
Liked = BriskValueReader.GetBool(data, "liked"),
|
||||
LikeCount = BriskValueReader.GetLong(data, "like_count")
|
||||
Created = BriskValueReader.GetBool(data, "created"),
|
||||
LikedByMe = BriskValueReader.GetBool(data, "liked_by_me"),
|
||||
LikeCount = BriskValueReader.GetLong(data, "like_count"),
|
||||
TodayLikeCount = BriskValueReader.GetLong(data, "today_like_count"),
|
||||
LikeResetAt = BriskValueReader.GetString(data, "like_reset_at")
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
public sealed class BriskSpaceLikeResult
|
||||
{
|
||||
public bool Liked;
|
||||
public bool Created;
|
||||
public bool LikedByMe;
|
||||
public long LikeCount;
|
||||
public long TodayLikeCount;
|
||||
public string LikeResetAt;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ public sealed class BriskSpaceStats
|
||||
public long ContentSizeBytes;
|
||||
public string ContentChecksum;
|
||||
public long LikeCount;
|
||||
public long TodayLikeCount;
|
||||
public long VisitCount;
|
||||
public string LikeResetAt;
|
||||
public string UpdatedAt;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,9 @@ public sealed class BriskSpaceView
|
||||
public long ContentSizeBytes;
|
||||
public string ContentChecksum;
|
||||
public long LikeCount;
|
||||
public long TodayLikeCount;
|
||||
public long VisitCount;
|
||||
public bool LikedByMe;
|
||||
public string LikeResetAt;
|
||||
public string UpdatedAt;
|
||||
}
|
||||
|
||||
@@ -68,23 +68,23 @@ public sealed class BriskSpaceModule
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按玩家 ID 获取最近点赞列表。
|
||||
/// 按玩家 ID 获取点赞列表。
|
||||
/// </summary>
|
||||
public async Task<IReadOnlyList<BriskSpaceLikeItem>> GetLikesByPlayerIdAsync(string playerId, int limit = 20)
|
||||
public async Task<IReadOnlyList<BriskSpaceLikeItem>> GetLikesByPlayerIdAsync(string playerId, int limit = 20, bool currentCycleOnly = false)
|
||||
{
|
||||
ValidatePlayerId(playerId);
|
||||
|
||||
return await ExecuteAsync(async context =>
|
||||
{
|
||||
var data = await context.HttpClient.GetRawDataAsync($"/spaces/{playerId}/likes", CreateLimitQuery(limit), true);
|
||||
var data = await context.HttpClient.GetRawDataAsync($"/spaces/{playerId}/likes", CreateLikesQuery(limit, currentCycleOnly), true);
|
||||
return (IReadOnlyList<BriskSpaceLikeItem>)BriskModelMapper.ToSpaceLikeItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按登录身份获取最近点赞列表。
|
||||
/// 按登录身份获取点赞列表。
|
||||
/// </summary>
|
||||
public async Task<IReadOnlyList<BriskSpaceLikeItem>> GetLikesByLoginIdentityAsync(string loginProvider, string loginUserId, int limit = 20)
|
||||
public async Task<IReadOnlyList<BriskSpaceLikeItem>> GetLikesByLoginIdentityAsync(string loginProvider, string loginUserId, int limit = 20, bool currentCycleOnly = false)
|
||||
{
|
||||
ValidateLoginIdentity(loginProvider, loginUserId);
|
||||
|
||||
@@ -92,6 +92,10 @@ public sealed class BriskSpaceModule
|
||||
{
|
||||
var query = CreateLoginIdentityQuery(loginProvider, loginUserId);
|
||||
query["limit"] = NormalizeLimit(limit);
|
||||
if (currentCycleOnly)
|
||||
{
|
||||
query["scope"] = "cycle";
|
||||
}
|
||||
var data = await context.HttpClient.GetRawDataAsync("/spaces/by-login/likes", query, true);
|
||||
return (IReadOnlyList<BriskSpaceLikeItem>)BriskModelMapper.ToSpaceLikeItems(data);
|
||||
});
|
||||
@@ -262,6 +266,17 @@ public sealed class BriskSpaceModule
|
||||
};
|
||||
}
|
||||
|
||||
private static Dictionary<string, string> CreateLikesQuery(int limit, bool currentCycleOnly)
|
||||
{
|
||||
var query = CreateLimitQuery(limit);
|
||||
if (currentCycleOnly)
|
||||
{
|
||||
query["scope"] = "cycle";
|
||||
}
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
private static void ValidatePlayerId(string playerId)
|
||||
{
|
||||
RequireNotEmpty(playerId, nameof(playerId));
|
||||
|
||||
Reference in New Issue
Block a user