Skip to content

Commit 34fe8f2

Browse files
committed
update request paths, add payload validations and update midori
1 parent 98b73cf commit 34fe8f2

28 files changed

Lines changed: 63 additions & 31 deletions

fluXis.sln

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "osu.Framework.Android", "Fr
3232
EndProject
3333
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LuaDefinitionMaker", "LuaDefinitionMaker\LuaDefinitionMaker.csproj", "{AE7A49FF-10A5-4E87-9C10-85EFDDC49B4F}"
3434
EndProject
35-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Midori", "..\..\flustix\Midori\Midori\Midori.csproj", "{DC435D54-56FB-435F-8C9A-F65232AEAFE3}"
36-
EndProject
3735
Global
3836
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3937
Debug|Any CPU = Debug|Any CPU

fluXis/Online/API/APIRequest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public abstract class APIRequest
6565
protected abstract string Path { get; }
6666
protected virtual HttpMethod Method => HttpMethod.Get;
6767
protected virtual string RootUrl => APIClient.Endpoint.APIUrl;
68+
protected virtual string ContentType => "application/json";
6869

6970
protected FluxelClient APIClient { get; private set; }
7071
protected WebRequest Request { get; private set; }
@@ -95,7 +96,7 @@ public void Perform(IAPIClient client)
9596
APIClient = fluxel;
9697

9798
Request = CreateWebRequest($"{RootUrl}{Path}");
98-
Request.ContentType = "application/json";
99+
Request.ContentType = ContentType;
99100
Request.Method = Method;
100101
Request.AllowRetryOnTimeout = false;
101102

fluXis/Online/API/Payloads/Chat/ChatCreateChannelPayload.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.ComponentModel.DataAnnotations;
23
using fluXis.Utils;
34
using Newtonsoft.Json;
45

@@ -9,6 +10,7 @@ namespace fluXis.Online.API.Payloads.Chat;
910
public class ChatCreateChannelPayload
1011
{
1112
[JsonProperty("target")]
13+
[Required]
1214
public long? TargetID { get; set; }
1315

1416
public ChatCreateChannelPayload(long target)

fluXis/Online/API/Payloads/Clubs/CreateClubPayload.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,35 @@
1-
using fluXis.Online.API.Models.Clubs;
1+
using System.ComponentModel.DataAnnotations;
2+
using fluXis.Online.API.Models.Clubs;
3+
using fluXis.Utils;
24
using Newtonsoft.Json;
35

46
namespace fluXis.Online.API.Payloads.Clubs;
57

68
public class CreateClubPayload
79
{
8-
/// <summary>
9-
/// 3-16 characters. has to be unique
10-
/// </summary>
1110
[JsonProperty("name")]
11+
[Required, StringLength(24, MinimumLength = 3)]
1212
public string Name { get; set; } = null!;
1313

1414
/// <summary>
1515
/// 3-5 characters. has to be unique
1616
/// </summary>
1717
[JsonProperty("tag")]
18+
[Required, RegularExpression("^[A-Z0-9]{3,5}$")]
1819
public string Tag { get; set; } = null!;
1920

2021
/// <summary>
2122
/// B64-encoded image
2223
/// </summary>
2324
[JsonProperty("icon")]
25+
[Base64String]
2426
public string Icon { get; set; } = null!;
2527

2628
/// <summary>
2729
/// B64-encoded image
2830
/// </summary>
2931
[JsonProperty("banner")]
32+
[Base64String]
3033
public string Banner { get; set; } = null!;
3134

3235
/// <summary>
@@ -39,11 +42,13 @@ public class CreateClubPayload
3942
/// Hex color code
4043
/// </summary>
4144
[JsonProperty("color-start")]
45+
[Required, RegularExpression(Validate.REGEX_HEX_COLOR)]
4246
public string ColorStart { get; set; } = null!;
4347

4448
/// <summary>
4549
/// Hex color code
4650
/// </summary>
4751
[JsonProperty("color-end")]
52+
[Required, RegularExpression(Validate.REGEX_HEX_COLOR)]
4853
public string ColorEnd { get; set; } = null!;
4954
}

fluXis/Online/API/Payloads/Users/UserProfileUpdatePayload.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.ComponentModel.DataAnnotations;
12
using Newtonsoft.Json;
23

34
namespace fluXis.Online.API.Payloads.Users;
@@ -10,32 +11,41 @@ public class UserProfileUpdatePayload
1011
/// base64 encoded image
1112
/// </summary>
1213
[JsonProperty("avatar")]
14+
[Base64String]
1315
public string? Avatar { get; set; }
1416

1517
/// <summary>
1618
/// base64 encoded image
1719
/// </summary>
1820
[JsonProperty("banner")]
21+
[Base64String]
1922
public string? Banner { get; set; }
2023

2124
[JsonProperty("nick")]
25+
[RegularExpression("^.{2,24}$", ErrorMessage = "Display name must be between 2-24 characters.")]
2226
public string? DisplayName { get; set; }
2327

2428
[JsonProperty("about")]
29+
[MaxLength(256, ErrorMessage = "AboutMe must be shorter than 256 characters.")]
2530
public string? AboutMe { get; set; }
2631

2732
[JsonProperty("twitter")]
33+
[RegularExpression("^.{1,15}$", ErrorMessage = "Twitter handle must be between 1-15 characters.")]
2834
public string? Twitter { get; set; }
2935

3036
[JsonProperty("discord")]
37+
[RegularExpression("^.{2,32}$", ErrorMessage = "Discord handle must be between 2-32 characters.")]
3138
public string? Discord { get; set; }
3239

3340
[JsonProperty("twitch")]
41+
[RegularExpression("^.{4,25}$", ErrorMessage = "Twitch handle must be between 4-25 characters.")]
3442
public string? Twitch { get; set; }
3543

3644
[JsonProperty("youtube")]
45+
[RegularExpression("^.{1,30}$", ErrorMessage = "YouTube handle must be between 1-30 characters.")]
3746
public string? YouTube { get; set; }
3847

3948
[JsonProperty("pronouns")]
49+
[MaxLength(16, ErrorMessage = "Pronouns must be shorter than 16 characters.")]
4050
public string? Pronouns { get; set; }
4151
}

fluXis/Online/API/Requests/Clubs/ClubRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace fluXis.Online.API.Requests.Clubs;
44

55
public class ClubRequest : APIRequest<APIClub>
66
{
7-
protected override string Path => $"/club/{id}";
7+
protected override string Path => $"/clubs/{id}";
88

99
private long id { get; }
1010

fluXis/Online/API/Requests/Clubs/EditClubRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace fluXis.Online.API.Requests.Clubs;
88

99
public class EditClubRequest : APIRequest<APIClub>
1010
{
11-
protected override string Path => $"/club/{id}";
11+
protected override string Path => $"/clubs/{id}";
1212
protected override HttpMethod Method => HttpMethod.Patch;
1313

1414
private long id { get; }

fluXis/Online/API/Requests/Leaderboards/OverallRatingLeaderboardRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ namespace fluXis.Online.API.Requests.Leaderboards;
55

66
public class OverallRatingLeaderboardRequest : APIRequest<List<APIUser>>
77
{
8-
protected override string Path => "/leaderboards/overall";
8+
protected override string Path => "/leaderboards/users/overall";
99
}

fluXis/Online/API/Requests/MapSets/Favorite/MapFavoriteRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace fluXis.Online.API.Requests.MapSets.Favorite;
44

55
public class MapFavoriteRequest : APIRequest<APIMapSetFavoriteState>
66
{
7-
protected override string Path => $"/mapset/{id}/favorite";
7+
protected override string Path => $"/mapsets/{id}/favorite";
88

99
private long id { get; }
1010

fluXis/Online/API/Requests/MapSets/Favorite/MapFavoriteUpdateRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace fluXis.Online.API.Requests.MapSets.Favorite;
77

88
public class MapFavoriteUpdateRequest : APIRequest<APIMapSetFavoriteState>
99
{
10-
protected override string Path => $"/mapset/{id}/favorite";
10+
protected override string Path => $"/mapsets/{id}/favorite";
1111
protected override HttpMethod Method => HttpMethod.Patch;
1212

1313
private long id { get; }

0 commit comments

Comments
 (0)