Implement AuthService and ApiClient core logic

This commit is contained in:
2026-04-09 14:22:47 +02:00
parent 3ee4edac6c
commit 8cbfa61766
22 changed files with 503 additions and 13 deletions

125
Models/AuthModels.cs Normal file
View File

@@ -0,0 +1,125 @@
using Newtonsoft.Json;
using System.Collections.Generic;
namespace Chtn.CSharp.SDK.Models.Auth
{
public class LoginPasswordAuthReq
{
[JsonProperty("unameMailPhone")] public string UnameMailPhone { get; set; }
[JsonProperty("password")] public string Password { get; set; }
[JsonProperty("os")] public string Os { get; set; }
[JsonProperty("language")] public string Language { get; set; }
}
public class SignInSuccessResp
{
[JsonProperty("token")] public string Token { get; set; }
[JsonProperty("userid")] public string UserId { get; set; }
[JsonProperty("username")] public string Username { get; set; }
}
public class GetAuthMethods
{
[JsonProperty("identifier")] public string Identifier { get; set; }
}
public class AuthMethods
{
[JsonProperty("methods")] public List<string> Methods { get; set; }
}
public class OtpPleSendCodeReq
{
[JsonProperty("identifier")] public List<string> Identifier { get; set; }
}
public class OtpPleVerifyCodeReq
{
[JsonProperty("identifier")] public string Identifier { get; set; }
[JsonProperty("code")] public string Code { get; set; }
}
public class UnameUsageReq
{
[JsonProperty("username")] public string Username { get; set; }
}
public class EmailUsageReq
{
[JsonProperty("email")] public string Email { get; set; }
}
public class PleSendVCodeReq
{
[JsonProperty("email")] public string Email { get; set; }
}
public class PleVerifyVCodeReq
{
[JsonProperty("email")] public string Email { get; set; }
[JsonProperty("code")] public string Code { get; set; }
}
public class PleVerifyCodeResp
{
[JsonProperty("verifyOk")] public string VerifyOk { get; set; }
[JsonProperty("tempToken")] public string TempToken { get; set; }
}
public class FinishPleAccountReq
{
[JsonProperty("temptoken")] public string TempToken { get; set; }
[JsonProperty("username")] public string Username { get; set; }
[JsonProperty("password")] public string Password { get; set; }
}
public class LoginWithGoogleReq
{
[JsonProperty("idToken")] public string IdToken { get; set; }
}
public class LoginWithAppleReq
{
[JsonProperty("idToken")] public string IdToken { get; set; }
[JsonProperty("firstName")] public string FirstName { get; set; }
[JsonProperty("lastName")] public string LastName { get; set; }
}
public class CheckloginReq
{
[JsonProperty("token")] public string Token { get; set; }
}
public class RegisterReq
{
[JsonProperty("username")] public string Username { get; set; }
[JsonProperty("email")] public string Email { get; set; }
[JsonProperty("password")] public string Password { get; set; }
}
public class ResetPasswordReq
{
[JsonProperty("identifier")] public string Identifier { get; set; }
}
public class ResetPasswordResp
{
[JsonProperty("success")] public string Success { get; set; }
}
public class VerifyPasswordResetReq
{
[JsonProperty("identifier")] public string Identifier { get; set; }
[JsonProperty("code")] public string Code { get; set; }
[JsonProperty("newPassword")] public string NewPassword { get; set; }
}
public class UserDataValidationResp
{
[JsonProperty("available")] public string Available { get; set; }
}
public class GetAuthMethodsReq
{
public string Identifier { get; set; }
}
public class PleVerifyCodeReq
{
public string Email { get; set; }
public string Code { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
namespace Chtn.CSharp.SDK.Models.Call
{
public class StreamRegistry
{
public string StreamKey { get; set; }
public string Status { get; set; }
public string StreamUrl { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
namespace Chtn.CSharp.SDK.Models.Call
{
public class InviteToCallReq
{
public string UserId { get; set; }
public string ChatId { get; set; }
public string TargetId { get; set; }
}
}

24
Models/ChatModels.cs Normal file
View File

@@ -0,0 +1,24 @@
using Chtn.CSharp.SDK.Models.Common;
using Newtonsoft.Json;
using System.Collections.Generic;
namespace Chtn.CSharp.SDK.Models.Chat
{
public class Chat
{
[JsonProperty("chatid")] public string ChatId { get; set; }
[JsonProperty("displayName")] public string DisplayName { get; set; }
[JsonProperty("latestMessage")] public LatestMessage Latest { get; set; }
}
public class Message
{
[JsonProperty("msgid")] public string MsgId { get; set; }
[JsonProperty("author")] public string Author { get; set; }
[JsonProperty("message")] public string Content { get; set; }
[JsonProperty("sent_at")] public TimeStamp SentAt { get; set; }
[JsonProperty("files")] public List<Attachment> Files { get; set; }
}
public class LatestMessage { public string Message { get; set; } public string MsgId { get; set; } }
}

32
Models/CommonModels.cs Normal file
View File

@@ -0,0 +1,32 @@
using Newtonsoft.Json;
namespace Chtn.CSharp.SDK.Models.Common
{
public class RGB
{
public int R { get; set; }
public int G { get; set; }
public int B { get; set; }
}
public class TimeStamp
{
[JsonProperty("T")] public long T { get; set; }
[JsonProperty("I")] public int I { get; set; }
}
public class PublicUserData
{
[JsonProperty("pfp")] public string Pfp { get; set; }
[JsonProperty("displayName")] public string DisplayName { get; set; }
[JsonProperty("username")] public string Username { get; set; }
[JsonProperty("userid")] public string UserId { get; set; }
}
public class Attachment
{
public string FileId { get; set; }
public string FileName { get; set; }
public string Path { get; set; }
public string Type { get; set; }
}
}

29
Models/DMServiceModels.cs Normal file
View File

@@ -0,0 +1,29 @@
using Chtn.CSharp.SDK.Models.Common;
using Newtonsoft.Json;
using System.Collections.Generic;
namespace Chtn.CSharp.SDK.Models.Chat.DM
{
public class DmMessage
{
[JsonProperty("msgid")] public string MsgId { get; set; }
[JsonProperty("author")] public string Author { get; set; }
[JsonProperty("message")] public string Content { get; set; }
[JsonProperty("sent_at")] public TimeStamp SentAt { get; set; }
[JsonProperty("files")] public List<Attachment> Files { get; set; }
}
public class DmPinMessageReq
{
[JsonProperty("chatid")] public string ChatId { get; set; }
[JsonProperty("messageId")] public string MessageId { get; set; }
[JsonProperty("userid")] public string UserId { get; set; }
}
public class DmJoinWsRoomReq
{
[JsonProperty("connId")] public string ConnId { get; set; }
[JsonProperty("chatid")] public string ChatId { get; set; }
[JsonProperty("userid")] public string UserId { get; set; }
}
}

View File

@@ -0,0 +1,17 @@
using System.Collections.Generic;
namespace Chtn.CSharp.SDK.Models.Media
{
public class StartNewFileTransferReq
{
public string UserId { get; set; }
public string TargetUserId { get; set; }
public List<TransferableFileMetadata> Metadata { get; set; }
}
public class TransferableFileMetadata
{
public string FileId { get; set; }
public string Name { get; set; }
public long Size { get; set; }
}
}

View File

@@ -0,0 +1,20 @@
using Newtonsoft.Json;
using System.Collections.Generic;
namespace Chtn.CSharp.SDK.Models.Media
{
public class RegisterUploadReq
{
[JsonProperty("roomId")] public string RoomId { get; set; }
[JsonProperty("userid")] public string UserId { get; set; }
[JsonProperty("files")] public List<FileUploadRegistration> Files { get; set; }
}
public class FileUploadRegistration
{
[JsonProperty("size")] public long Size { get; set; }
[JsonProperty("type")] public string Type { get; set; }
[JsonProperty("name")] public string Name { get; set; }
[JsonProperty("fileId")] public string FileId { get; set; }
}
public class RegisterUploadResp { public string UploadId { get; set; } }
}

View File

@@ -0,0 +1,5 @@
namespace Chtn.CSharp.SDK.Models.Network
{
public class GenericErrorBody { public string Error { get; set; } }
public class GenericSuccessBody { public string Response { get; set; } }
}

16
Models/NetworkModels.cs Normal file
View File

@@ -0,0 +1,16 @@
namespace Chtn.CSharp.SDK.Models.Network
{
public class CreateNetworkReq
{
public string Name { get; set; }
public string Visibility { get; set; }
public string UserId { get; set; }
}
public class NetworkChannel
{
public string ChannelId { get; set; }
public string Name { get; set; }
public string Desc { get; set; }
}
}

21
Models/PictureModels.cs Normal file
View File

@@ -0,0 +1,21 @@
using Chtn.CSharp.SDK.Models.Common;
using Newtonsoft.Json;
using System.Collections.Generic;
namespace Chtn.CSharp.SDK.Models.Media
{
public class Album
{
[JsonProperty("albumId")] public string ImageId { get; set; }
[JsonProperty("name")] public string Name { get; set; }
[JsonProperty("images")] public List<Image> Images { get; set; }
}
public class Image
{
[JsonProperty("imageId")] public string ImageId { get; set; }
[JsonProperty("path")] public string Path { get; set; }
[JsonProperty("title")] public string Title { get; set; }
[JsonProperty("uploaded_at")] public TimeStamp UploadedAt { get; set; }
}
}

View File

@@ -0,0 +1,4 @@
namespace Chtn.CSharp.SDK.Models.Session
{
public class ValidateSessionReq { public string Token { get; set; } }
}

12
Models/SessionModels.cs Normal file
View File

@@ -0,0 +1,12 @@
using Chtn.CSharp.SDK.Models.User;
using Newtonsoft.Json;
namespace Chtn.CSharp.SDK.Models.Session
{
public class Session
{
[JsonProperty("userData")] public PersonalUserData UserData { get; set; }
[JsonProperty("token")] public string Token { get; set; }
}
public class ValidateSessionResp { public bool ValidationOk { get; set; } }
}

View File

@@ -0,0 +1,27 @@
using Chtn.CSharp.SDK.Models.Common;
using Newtonsoft.Json;
using System.Collections.Generic;
namespace Chtn.CSharp.SDK.Models.Chat.TextChannel
{
public class ChannelMessage
{
[JsonProperty("msgid")] public string MsgId { get; set; }
[JsonProperty("author")] public PublicUserData Author { get; set; }
[JsonProperty("message")] public string Message { get; set; }
[JsonProperty("channelId")] public string ChannelId { get; set; }
[JsonProperty("files")] public List<Attachment> Files { get; set; }
}
public class ChannelPinMessageReq
{
[JsonProperty("channelId")] public string ChannelId { get; set; }
[JsonProperty("messageId")] public string MessageId { get; set; }
}
public class ChannelJoinWsRoomReq
{
[JsonProperty("connId")] public string ConnId { get; set; }
[JsonProperty("channelId")] public string ChannelId { get; set; }
}
}

11
Models/UserModels.cs Normal file
View File

@@ -0,0 +1,11 @@
using Newtonsoft.Json;
namespace Chtn.CSharp.SDK.Models.User
{
public class PersonalUserData
{
[JsonProperty("userid")] public string UserId { get; set; }
[JsonProperty("username")] public string Username { get; set; }
[JsonProperty("email")] public string Email { get; set; }
}
}

20
Models/WebSocketModels.cs Normal file
View File

@@ -0,0 +1,20 @@
using Newtonsoft.Json;
namespace Chtn.CSharp.SDK.Models.Websocket
{
public class WSMessagePayload
{
[JsonProperty("action")] public string Action { get; set; }
[JsonProperty("data")] public string Data { get; set; }
}
public class WSMakeTokenReq
{
[JsonProperty("userid")] public string UserId { get; set; }
}
public class WSMakeTokenResp
{
[JsonProperty("token")] public string Token { get; set; }
}
}