Add project files.

This commit is contained in:
Dima yawaflua Andreev
2024-06-22 23:21:48 +03:00
parent bc437be3dc
commit 7d6932fdc6
26 changed files with 626 additions and 0 deletions

13
Types/Enums/SkinPart.cs Normal file
View File

@@ -0,0 +1,13 @@
namespace SPWorldsApi.Types.Enums
{
public enum SkinPart
{
face,
front,
front_full,
head,
bust,
full,
skin
}
}

View File

@@ -0,0 +1,8 @@
namespace SPWorldsApi.Types.Interfaces
{
public interface ICard
{
public int Balance { get; set; }
public string Webhook { get; set; }
}
}

12
Types/Interfaces/ICity.cs Normal file
View File

@@ -0,0 +1,12 @@
namespace SPWorldsApi.Types.Interfaces
{
public interface ICity
{
public string id { get; set; }
public string name { get; set; }
public string description { get; set; }
public int x { get; set; }
public int z { get; set; }
public bool isMayor { get; set; }
}
}

View File

@@ -0,0 +1,10 @@
namespace SPWorldsApi.Types.Interfaces
{
public interface IPaymentData
{
public IPaymentItems[] Items { get; set; }
public string RedirectUrl { get; set; }
public string WebHookUrl { get; set; }
public string Data { get; set; }
}
}

View File

@@ -0,0 +1,10 @@
namespace SPWorldsApi.Types.Interfaces
{
public interface IPaymentItems
{
public string Name { get; set; }
public int Count { get; set; }
public int Price { get; set; }
public string? Comment { get; set; }
}
}

29
Types/Interfaces/IUser.cs Normal file
View File

@@ -0,0 +1,29 @@
using SPWorldsApi.Types.Enums;
using SPWorldsApi.Types.Models;
using System.Text.Json.Nodes;
namespace SPWorldsApi.Types.Interfaces
{
public interface IUser
{
public string Name { get; }
public string Uuid { get; }
public static async Task<IUser> CreateUserAsync(string name)
{
string? uuid;
using (System.Net.Http.HttpClient client = new())
{
uuid = (string?)JsonNode.Parse(await client.GetStringAsync($"https://api.mojang.com/users/profiles/minecraft/{name}"))["id"];
}
User user = new(name, uuid);
return user;
}
public string GetSkinPart(SkinPart skinPart, string size = "64")
{
return (string)$"https://avatar.spworlds.ru/{skinPart}/{size}/{Name}";
}
}
}

View File

@@ -0,0 +1,14 @@
namespace SPWorldsApi.Types.Interfaces
{
public interface IUserAccount
{
public string id { get; set; }
public string username { get; set; }
public string minecraftUUID { get; set; }
public string status { get; set; }
public List<string> roles { get; set; }
public ICity city { get; set; }
public List<IUserCard> cards { get; set; }
public DateTime createdAt { get; set; }
}
}

View File

@@ -0,0 +1,10 @@
namespace SPWorldsApi.Types.Interfaces
{
public interface IUserCard
{
public string id { get; set; }
public string name { get; set; }
public string number { get; set; }
public int color { get; set; }
}
}

View File

@@ -0,0 +1,8 @@
namespace SPWorldsApi.Types.Interfaces
{
public interface IWebhookResponse
{
public int Id { get; set; }
public string Webhook { get; set; }
}
}

10
Types/Models/Card.cs Normal file
View File

@@ -0,0 +1,10 @@
using SPWorldsApi.Types.Interfaces;
namespace SPWorldsApi.Types.Models
{
internal class Card : ICard
{
public int Balance { get; set; }
public string Webhook { get; set; }
}
}

14
Types/Models/City.cs Normal file
View File

@@ -0,0 +1,14 @@
using SPWorldsApi.Types.Interfaces;
namespace SPWorldsApi.Types.Models
{
internal class City : ICity
{
public string id { get; set; }
public string name { get; set; }
public string description { get; set; }
public int x { get; set; }
public int z { get; set; }
public bool isMayor { get; set; }
}
}

View File

@@ -0,0 +1,12 @@
using SPWorldsApi.Types.Interfaces;
namespace SPWorldsApi.Types.Models
{
internal class PaymentData : IPaymentData
{
public IPaymentItems[] Items { get; set; }
public string RedirectUrl { get; set; }
public string WebHookUrl { get; set; }
public string Data { get; set; }
}
}

View File

@@ -0,0 +1,12 @@
using SPWorldsApi.Types.Interfaces;
namespace SPWorldsApi.Types.Models
{
public class PaymentItems : IPaymentItems
{
public string Name { get; set; }
public int Count { get; set; }
public int Price { get; set; }
public string? Comment { get; set; } = null;
}
}

16
Types/Models/User.cs Normal file
View File

@@ -0,0 +1,16 @@
using SPWorldsApi.Types.Interfaces;
namespace SPWorldsApi.Types.Models
{
internal class User : IUser
{
public string Name { get; }
public string Uuid { get; }
public User(string name, string uuid)
{
Name = name;
Uuid = uuid;
}
}
}

View File

@@ -0,0 +1,16 @@
using SPWorldsApi.Types.Interfaces;
namespace SPWorldsApi.Types.Models
{
internal class UserAccount : IUserAccount
{
public string id { get; set; }
public string username { get; set; }
public string minecraftUUID { get; set; }
public string status { get; set; }
public List<string> roles { get; set; }
public ICity city { get; set; }
public List<IUserCard> cards { get; set; }
public DateTime createdAt { get; set; }
}
}

12
Types/Models/UserCard.cs Normal file
View File

@@ -0,0 +1,12 @@
using SPWorldsApi.Types.Interfaces;
namespace SPWorldsApi.Types.Models
{
internal class UserCard : IUserCard
{
public string id { get; set; }
public string name { get; set; }
public string number { get; set; }
public int color { get; set; }
}
}

View File

@@ -0,0 +1,10 @@
using SPWorldsApi.Types.Interfaces;
namespace SPWorldsApi.Types.Models
{
internal class WebhookResponse : IWebhookResponse
{
public int Id { get; set; }
public string Webhook { get; set; }
}
}